mirror of https://codeberg.org/topola/topola.git
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:
parent
61c0134db4
commit
739bdafea2
|
|
@ -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};
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
@ -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(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue