Replace `RouteSelector` with `NetSelector`

I don't think identifying routes by pin name pair is going to be really
useful.
This commit is contained in:
Mikolaj Wielgus 2026-05-26 12:16:45 +02:00
parent 61c0134db4
commit 739bdafea2
3 changed files with 13 additions and 21 deletions

View File

@ -3,10 +3,11 @@
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
mod component; mod component;
mod net;
mod persistable; mod persistable;
mod pin; mod pin;
mod route;
pub use component::{ComponentSelection, ComponentSelector}; pub use component::{ComponentSelection, ComponentSelector};
pub use net::{NetSelection, NetSelector};
pub use persistable::PersistableSelection; pub use persistable::PersistableSelection;
pub use pin::{PinSelection, PinSelector}; pub use pin::{PinSelection, PinSelector};

View File

@ -6,32 +6,26 @@ use std::collections::BTreeSet;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::selections::PinSelector;
#[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct RouteSelector { pub struct NetSelector {
lesser_pin: PinSelector, pub net: String,
greater_pin: PinSelector,
} }
impl RouteSelector { impl NetSelector {
pub fn new(pin1: PinSelector, pin2: PinSelector) -> Self { pub fn new(net: String) -> Self {
Self { Self { net }
lesser_pin: std::cmp::min(pin1.clone(), pin2.clone()),
greater_pin: std::cmp::max(pin1, pin2),
}
} }
} }
#[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct RouteSelection(pub BTreeSet<RouteSelector>); pub struct NetSelection(pub BTreeSet<NetSelector>);
impl RouteSelection { impl NetSelection {
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
} }
pub fn toggle(&mut self, selector: RouteSelector) { pub fn toggle(&mut self, selector: NetSelector) {
if self.0.contains(&selector) { if self.0.contains(&selector) {
self.0.remove(&selector); self.0.remove(&selector);
} else { } else {

View File

@ -4,15 +4,12 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::board::selections::{ComponentSelection, NetSelection, PinSelection};
board::selections::{ComponentSelection, PinSelection},
selections::route::RouteSelection,
};
#[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct PersistableSelection { pub struct PersistableSelection {
pub components: ComponentSelection, pub components: ComponentSelection,
pub routes: RouteSelection, pub nets: NetSelection,
pub pins: PinSelection, pub pins: PinSelection,
} }
@ -20,7 +17,7 @@ impl PersistableSelection {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
components: ComponentSelection::new(), components: ComponentSelection::new(),
routes: RouteSelection::new(), nets: NetSelection::new(),
pins: PinSelection::new(), pins: PinSelection::new(),
} }
} }