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
|
||||
|
||||
mod component;
|
||||
mod net;
|
||||
mod persistable;
|
||||
mod pin;
|
||||
mod route;
|
||||
|
||||
pub use component::{ComponentSelection, ComponentSelector};
|
||||
pub use net::{NetSelection, NetSelector};
|
||||
pub use persistable::PersistableSelection;
|
||||
pub use pin::{PinSelection, PinSelector};
|
||||
|
|
|
|||
|
|
@ -6,32 +6,26 @@ use std::collections::BTreeSet;
|
|||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::selections::PinSelector;
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct RouteSelector {
|
||||
lesser_pin: PinSelector,
|
||||
greater_pin: PinSelector,
|
||||
pub struct NetSelector {
|
||||
pub net: String,
|
||||
}
|
||||
|
||||
impl RouteSelector {
|
||||
pub fn new(pin1: PinSelector, pin2: PinSelector) -> Self {
|
||||
Self {
|
||||
lesser_pin: std::cmp::min(pin1.clone(), pin2.clone()),
|
||||
greater_pin: std::cmp::max(pin1, pin2),
|
||||
}
|
||||
impl NetSelector {
|
||||
pub fn new(net: String) -> Self {
|
||||
Self { net }
|
||||
}
|
||||
}
|
||||
|
||||
#[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 {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
pub fn toggle(&mut self, selector: RouteSelector) {
|
||||
pub fn toggle(&mut self, selector: NetSelector) {
|
||||
if self.0.contains(&selector) {
|
||||
self.0.remove(&selector);
|
||||
} else {
|
||||
|
|
@ -4,15 +4,12 @@
|
|||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
board::selections::{ComponentSelection, PinSelection},
|
||||
selections::route::RouteSelection,
|
||||
};
|
||||
use crate::board::selections::{ComponentSelection, NetSelection, PinSelection};
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct PersistableSelection {
|
||||
pub components: ComponentSelection,
|
||||
pub routes: RouteSelection,
|
||||
pub nets: NetSelection,
|
||||
pub pins: PinSelection,
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +17,7 @@ impl PersistableSelection {
|
|||
pub fn new() -> Self {
|
||||
Self {
|
||||
components: ComponentSelection::new(),
|
||||
routes: RouteSelection::new(),
|
||||
nets: NetSelection::new(),
|
||||
pins: PinSelection::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue