From b2ef23c06c6f61554c83a610e7a67b0c87a95fc3 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Fri, 5 Jun 2026 00:24:00 +0200 Subject: [PATCH] Create and use new enum to later use different master interactors using the same interface --- topola-egui/src/app.rs | 2 +- topola-egui/src/display.rs | 6 +- topola-egui/src/layers_panel.rs | 3 +- topola-egui/src/viewport.rs | 2 +- topola-egui/src/workspace.rs | 2 +- topola/src/autoplacer.rs | 5 +- topola/src/autorouter.rs | 2 +- topola/src/board/bbox.rs | 7 ++- topola/src/board/contains.rs | 5 +- topola/src/board/insert.rs | 10 +-- topola/src/board/interactors/drag_move.rs | 22 ++++--- topola/src/board/interactors/drag_select.rs | 16 ++++- topola/src/board/interactors/master.rs | 19 +++--- topola/src/board/interactors/select.rs | 19 +++--- topola/src/board/resolve.rs | 6 +- topola/src/board/select.rs | 2 +- topola/src/board/transforms/delete.rs | 2 +- topola/src/board/transforms/move_by.rs | 7 ++- topola/src/connectivity.rs | 2 +- topola/src/interactor.rs | 68 +++++++++++++++++++++ topola/src/layout/attraction.rs | 7 ++- topola/src/layout/compounds/component.rs | 7 +-- topola/src/layout/compounds/net.rs | 2 +- topola/src/layout/compounds/pin.rs | 6 +- topola/src/layout/delete.rs | 4 +- topola/src/layout/infringement.rs | 2 +- topola/src/layout/insert.rs | 8 +-- topola/src/layout/locate.rs | 10 ++- topola/src/layout/modify.rs | 4 +- topola/src/layout/primitives/joint.rs | 2 +- topola/src/layout/primitives/mod.rs | 2 +- topola/src/layout/repulsion.rs | 5 +- topola/src/layout/transforms/move_by.rs | 5 +- topola/src/lib.rs | 18 ++---- topola/src/navmesher.rs | 8 ++- topola/src/ratsnest.rs | 10 +-- topola/src/router.rs | 2 +- topola/src/specctra.rs | 2 +- topola/src/workspace.rs | 2 +- 39 files changed, 215 insertions(+), 98 deletions(-) create mode 100644 topola/src/interactor.rs diff --git a/topola-egui/src/app.rs b/topola-egui/src/app.rs index 7431584..a4bbb3e 100644 --- a/topola-egui/src/app.rs +++ b/topola-egui/src/app.rs @@ -5,7 +5,7 @@ use std::sync::mpsc::{Receiver, Sender, channel}; use specctra::{error::ParseErrorContext, structure::DsnFile}; -use topola::Board; +use topola::board::Board; use unic_langid::langid; use crate::{ diff --git a/topola-egui/src/display.rs b/topola-egui/src/display.rs index ce0b365..05614fb 100644 --- a/topola-egui/src/display.rs +++ b/topola-egui/src/display.rs @@ -3,8 +3,10 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use crate::{viewport::Viewport, workspace::GuiWorkspace}; -use topola::primitives::{Joint, Polygon, Segment, Via}; -use topola::{Orientation, Vector2, Workspace}; +use topola::{ + Orientation, Vector2, Workspace, + layout::primitives::{Joint, Polygon, Segment, Via}, +}; pub struct Display {} diff --git a/topola-egui/src/layers_panel.rs b/topola-egui/src/layers_panel.rs index 6f1e449..3d7fd06 100644 --- a/topola-egui/src/layers_panel.rs +++ b/topola-egui/src/layers_panel.rs @@ -6,7 +6,8 @@ use std::collections::BTreeMap; use egui::{Context, Grid, ScrollArea, SidePanel, widget_text::WidgetText}; use serde::{Deserialize, Serialize}; -use topola::{Board, LayerDesc, LayerId, LayerSide, LayerType}; +use topola::board::{Board, LayerDesc, LayerSide, LayerType}; +use topola::layout::LayerId; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Colors { diff --git a/topola-egui/src/viewport.rs b/topola-egui/src/viewport.rs index a631ea3..7b386f9 100644 --- a/topola-egui/src/viewport.rs +++ b/topola-egui/src/viewport.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use egui::Pos2; -use topola::{MasterInteractor, Vector2, Workspace}; +use topola::{Interactor, MasterInteractor, Vector2, Workspace}; use crate::{display::Display, menu_bar::MenuBar, translator::Translator, workspace::GuiWorkspace}; diff --git a/topola-egui/src/workspace.rs b/topola-egui/src/workspace.rs index 86c97e8..040bc2c 100644 --- a/topola-egui/src/workspace.rs +++ b/topola-egui/src/workspace.rs @@ -4,7 +4,7 @@ use std::{ops::ControlFlow, time::Instant}; -use topola::{Board, Workspace}; +use topola::{Workspace, board::Board}; use crate::{layers_panel::LayersPanel, translator::Translator}; diff --git a/topola/src/autoplacer.rs b/topola/src/autoplacer.rs index af0a9a2..cda9d6c 100644 --- a/topola/src/autoplacer.rs +++ b/topola/src/autoplacer.rs @@ -7,8 +7,11 @@ use rand_distr::{Distribution, Normal}; use undoredo::{FlushDelta, ResetDelta}; use crate::{ - Board, Vector2, board::BoardDelta, layout::compounds::ComponentId, orientation::Orientation, + board::{Board, BoardDelta}, + layout::compounds::ComponentId, + orientation::Orientation, selections::ComponentSelection, + vector::Vector2, }; pub struct AutoplacerSchedule { diff --git a/topola/src/autorouter.rs b/topola/src/autorouter.rs index a2a15e8..0590520 100644 --- a/topola/src/autorouter.rs +++ b/topola/src/autorouter.rs @@ -4,7 +4,7 @@ use derive_getters::Getters; -use crate::{Board, Ratsnest, router::Router}; +use crate::{board::Board, ratsnest::Ratsnest, router::Router}; #[derive(Clone, Debug, Getters)] pub struct Autorouter { diff --git a/topola/src/board/bbox.rs b/topola/src/board/bbox.rs index b0391f4..44ba20d 100644 --- a/topola/src/board/bbox.rs +++ b/topola/src/board/bbox.rs @@ -2,7 +2,12 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::{Board, Rect2, layout::compounds::ComponentId, selections::ComponentSelection}; +use crate::{ + board::Board, + layout::compounds::ComponentId, + rect::Rect2, + selections::ComponentSelection, +}; impl Board { pub fn components_bbox2(&self, selection: ComponentSelection) -> Option> { diff --git a/topola/src/board/contains.rs b/topola/src/board/contains.rs index c0c09ec..50cbecf 100644 --- a/topola/src/board/contains.rs +++ b/topola/src/board/contains.rs @@ -3,9 +3,10 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use crate::{ - Board, Vector2, - primitives::{JointId, PolygonId, SegmentId, ViaId}, + board::Board, + layout::primitives::{JointId, PolygonId, SegmentId, ViaId}, selections::{ComponentSelection, NetSelection, NetSelector, PinSelection}, + vector::Vector2, }; impl Board { diff --git a/topola/src/board/insert.rs b/topola/src/board/insert.rs index 245ecd3..3a4258b 100644 --- a/topola/src/board/insert.rs +++ b/topola/src/board/insert.rs @@ -4,10 +4,12 @@ use crate::{ board::Board, - layout::compounds::ComponentId, - primitives::{ - JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId, - ViaSpec, + layout::{ + compounds::ComponentId, + primitives::{ + JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId, + ViaSpec, + }, }, }; diff --git a/topola/src/board/interactors/drag_move.rs b/topola/src/board/interactors/drag_move.rs index 81b0476..9700d9c 100644 --- a/topola/src/board/interactors/drag_move.rs +++ b/topola/src/board/interactors/drag_move.rs @@ -6,7 +6,13 @@ use derive_getters::Getters; use derive_more::Constructor; use undoredo::ResetDelta; -use crate::{Board, LayerId, Vector2, selections::ComponentSelection}; +use crate::{ + board::Board, + interactor::Interactor, + layout::LayerId, + selections::ComponentSelection, + vector::Vector2, +}; #[derive(Clone, Constructor, Debug, Eq, Getters, PartialEq)] pub struct DragMoveInteractor { @@ -15,18 +21,20 @@ pub struct DragMoveInteractor { selection: ComponentSelection, } -impl DragMoveInteractor { - pub fn hold(&mut self, board: &mut Board, pointer: Vector2) { +impl Interactor for DragMoveInteractor { + fn delete(&mut self, _board: &mut Board) {} + + fn hold(&mut self, board: &mut Board, _layer: LayerId, pointer: Vector2) { board.reset_delta(); board.move_components_by(self.selection.clone(), pointer - self.origin); } - pub fn abort(&mut self, board: &mut Board) { - board.reset_delta(); + fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { + self.hold(board, layer, pointer); } - pub fn release(&mut self, board: &mut Board, pointer: Vector2) { - self.hold(board, pointer); + fn abort(&mut self, board: &mut Board) { + board.reset_delta(); } } diff --git a/topola/src/board/interactors/drag_select.rs b/topola/src/board/interactors/drag_select.rs index 47d1a45..a6ab71c 100644 --- a/topola/src/board/interactors/drag_select.rs +++ b/topola/src/board/interactors/drag_select.rs @@ -7,13 +7,15 @@ use derive_more::Constructor; use serde::{Deserialize, Serialize}; use crate::{ - Rect3, Vector2, Vector3, board::{ Board, interactors::{SelectionCombineMode, SelectionContainMode}, selections::PersistableSelection, }, + interactor::Interactor, layout::LayerId, + rect::Rect3, + vector::{Vector2, Vector3}, }; #[derive(Clone, Constructor, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] @@ -46,8 +48,12 @@ impl DragSelectInteractor { options, } } +} - pub fn hold(&mut self, board: &Board, pointer: Vector2) { +impl Interactor for DragSelectInteractor { + fn delete(&mut self, _board: &mut Board) {} + + fn hold(&mut self, board: &mut Board, _layer: LayerId, pointer: Vector2) { self.selection = PersistableSelection::new(); let rect = Rect3::new( @@ -181,7 +187,11 @@ impl DragSelectInteractor { self.selection = combined_selection; } - pub fn abort(&mut self) { + fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { + self.hold(board, layer, pointer); + } + + fn abort(&mut self, _board: &mut Board) { self.selection = self.original_selection.clone(); } } diff --git a/topola/src/board/interactors/master.rs b/topola/src/board/interactors/master.rs index d032fba..d83928f 100644 --- a/topola/src/board/interactors/master.rs +++ b/topola/src/board/interactors/master.rs @@ -5,13 +5,14 @@ use derive_getters::Getters; use crate::{ - Vector2, board::{ Board, interactors::{DragMoveInteractor, SelectInteractor, SelectionCombineMode}, selections::PersistableSelection, }, + interactor::Interactor, layout::LayerId, + vector::Vector2, }; #[derive(Clone, Debug, Eq, Getters, PartialEq)] @@ -29,12 +30,14 @@ impl MasterInteractor { selection, } } +} - pub fn delete(&mut self, board: &mut Board) { +impl Interactor for MasterInteractor { + fn delete(&mut self, board: &mut Board) { board.delete_net_free_primitives(self.selection.nets.clone()); } - pub fn hold(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { + fn hold(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { if self.select_interactor.is_none() && self.drag_move_interactor.is_none() { if board.components_contain_point(&self.selection.components, pointer) { self.drag_move_interactor = Some(DragMoveInteractor::new( @@ -52,16 +55,16 @@ impl MasterInteractor { } if let Some(drag_move_interactor) = self.drag_move_interactor.as_mut() { - drag_move_interactor.hold(board, pointer); + drag_move_interactor.hold(board, layer, pointer); } else if let Some(select_interactor) = self.select_interactor.as_mut() { select_interactor.hold(board, layer, pointer); self.selection = select_interactor.selection().clone(); } } - pub fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { + fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { if let Some(drag_move_interactor) = self.drag_move_interactor.as_mut() { - drag_move_interactor.release(board, pointer); + drag_move_interactor.release(board, layer, pointer); } else if let Some(select_interactor) = self.select_interactor.as_mut() { select_interactor.release(board, layer, pointer); self.selection = select_interactor.selection().clone(); @@ -71,13 +74,13 @@ impl MasterInteractor { self.drag_move_interactor = None; } - pub fn abort(&mut self, board: &mut Board) { + fn abort(&mut self, board: &mut Board) { if let Some(drag_move_interactor) = self.drag_move_interactor.as_mut() { drag_move_interactor.abort(board); } if let Some(select_interactor) = self.select_interactor.as_mut() { - select_interactor.abort(); + select_interactor.abort(board); self.selection = select_interactor.original_selection().clone(); } diff --git a/topola/src/board/interactors/select.rs b/topola/src/board/interactors/select.rs index b5b8904..e4c70f2 100644 --- a/topola/src/board/interactors/select.rs +++ b/topola/src/board/interactors/select.rs @@ -5,7 +5,6 @@ use derive_getters::Getters; use crate::{ - Vector2, Vector3, board::{ Board, interactors::{ @@ -13,7 +12,9 @@ use crate::{ }, selections::PersistableSelection, }, + interactor::Interactor, layout::LayerId, + vector::{Vector2, Vector3}, }; #[derive(Clone, Debug, Eq, Getters, PartialEq)] @@ -37,12 +38,12 @@ impl SelectInteractor { combine, } } +} - pub fn abort(&mut self) { - self.selection = self.original_selection.clone(); - } +impl Interactor for SelectInteractor { + fn delete(&mut self, _board: &mut Board) {} - pub fn hold(&mut self, board: &Board, layer: LayerId, pointer: Vector2) { + fn hold(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { let contain = if pointer.x >= self.origin.x { SelectionContainMode::Window } else { @@ -53,11 +54,11 @@ impl SelectInteractor { let mut drag_selection_interactor = DragSelectInteractor::new(self.origin, layer, self.original_selection.clone(), options); - drag_selection_interactor.hold(board, pointer); + drag_selection_interactor.hold(board, layer, pointer); self.selection = drag_selection_interactor.selection().clone(); } - pub fn release(&mut self, board: &Board, layer: LayerId, pointer: Vector2) { + fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { if pointer == self.origin { let mut selection = self.original_selection.clone(); let point = Vector3::new(pointer.x, pointer.y, layer.index() as i64); @@ -82,4 +83,8 @@ impl SelectInteractor { self.hold(board, layer, pointer); } + + fn abort(&mut self, _board: &mut Board) { + self.selection = self.original_selection.clone(); + } } diff --git a/topola/src/board/resolve.rs b/topola/src/board/resolve.rs index 28982cd..6dd772e 100644 --- a/topola/src/board/resolve.rs +++ b/topola/src/board/resolve.rs @@ -4,8 +4,10 @@ use crate::{ board::{Board, selections::ComponentSelection}, - layout::compounds::ComponentId, - primitives::{JointId, PolygonId, SegmentId, ViaId}, + layout::{ + compounds::ComponentId, + primitives::{JointId, PolygonId, SegmentId, ViaId}, + }, selections::NetSelection, }; diff --git a/topola/src/board/select.rs b/topola/src/board/select.rs index d003308..58076ba 100644 --- a/topola/src/board/select.rs +++ b/topola/src/board/select.rs @@ -9,7 +9,7 @@ use crate::{ ComponentSelection, ComponentSelector, NetSelector, PinSelection, PinSelector, }, }, - primitives::{JointId, PolygonId, SegmentId, ViaId}, + layout::primitives::{JointId, PolygonId, SegmentId, ViaId}, }; impl Board { diff --git a/topola/src/board/transforms/delete.rs b/topola/src/board/transforms/delete.rs index 4919097..1195616 100644 --- a/topola/src/board/transforms/delete.rs +++ b/topola/src/board/transforms/delete.rs @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::{Board, selections::NetSelection}; +use crate::{board::Board, selections::NetSelection}; impl Board { pub fn delete_net_free_primitives(&mut self, selection: NetSelection) { diff --git a/topola/src/board/transforms/move_by.rs b/topola/src/board/transforms/move_by.rs index deb370b..22aaf32 100644 --- a/topola/src/board/transforms/move_by.rs +++ b/topola/src/board/transforms/move_by.rs @@ -2,7 +2,12 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::{Board, Vector2, layout::compounds::ComponentId, selections::ComponentSelection}; +use crate::{ + board::Board, + layout::compounds::ComponentId, + selections::ComponentSelection, + vector::Vector2, +}; impl Board { pub fn move_components_by(&mut self, selection: ComponentSelection, translation: Vector2) { diff --git a/topola/src/connectivity.rs b/topola/src/connectivity.rs index 411a576..f9218a7 100644 --- a/topola/src/connectivity.rs +++ b/topola/src/connectivity.rs @@ -4,7 +4,7 @@ use polygon_unionfind::UnionFind; -use crate::Board; +use crate::board::Board; pub struct Connectivity { joints_unionfind: UnionFind, diff --git a/topola/src/interactor.rs b/topola/src/interactor.rs new file mode 100644 index 0000000..1b78345 --- /dev/null +++ b/topola/src/interactor.rs @@ -0,0 +1,68 @@ +// SPDX-FileCopyrightText: 2026 Topola contributors +// +// SPDX-License-Identifier: MIT OR Apache-2.0 + +use crate::{ + board::{ + Board, + interactors::SelectInteractor, + selections::PersistableSelection, + }, + layout::LayerId, + vector::Vector2, +}; + +pub trait Interactor { + fn delete(&mut self, board: &mut Board); + fn hold(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2); + fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2); + fn abort(&mut self, board: &mut Board); +} + +pub enum MasterInteractor { + Board(crate::board::interactors::MasterInteractor), +} + +impl MasterInteractor { + pub fn new(selection: PersistableSelection) -> Self { + Self::Board(crate::board::interactors::MasterInteractor::new(selection)) + } + + pub fn selection(&self) -> &PersistableSelection { + match self { + Self::Board(interactor) => interactor.selection(), + } + } + + pub fn select_interactor(&self) -> &Option { + match self { + Self::Board(interactor) => interactor.select_interactor(), + } + } +} + +impl Interactor for MasterInteractor { + fn delete(&mut self, board: &mut Board) { + match self { + Self::Board(interactor) => interactor.delete(board), + } + } + + fn hold(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { + match self { + Self::Board(interactor) => interactor.hold(board, layer, pointer), + } + } + + fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2) { + match self { + Self::Board(interactor) => interactor.release(board, layer, pointer), + } + } + + fn abort(&mut self, board: &mut Board) { + match self { + Self::Board(interactor) => interactor.abort(board), + } + } +} diff --git a/topola/src/layout/attraction.rs b/topola/src/layout/attraction.rs index c014082..0332c49 100644 --- a/topola/src/layout/attraction.rs +++ b/topola/src/layout/attraction.rs @@ -3,8 +3,11 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use crate::{ - Layout, Vector2, - layout::compounds::{ComponentId, PinId}, + layout::{ + Layout, + compounds::{ComponentId, PinId}, + }, + vector::Vector2, }; impl Layout { diff --git a/topola/src/layout/compounds/component.rs b/topola/src/layout/compounds/component.rs index c351765..28051dd 100644 --- a/topola/src/layout/compounds/component.rs +++ b/topola/src/layout/compounds/component.rs @@ -5,10 +5,9 @@ use derive_more::{Constructor, From}; use serde::{Deserialize, Serialize}; -use crate::{ - PinId, - layout::primitives::{JointId, PolygonId, SegmentId, ViaId}, - primitives::PrimitiveId, +use crate::layout::{ + compounds::PinId, + primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId}, }; #[derive( diff --git a/topola/src/layout/compounds/net.rs b/topola/src/layout/compounds/net.rs index ca8d410..3b729d1 100644 --- a/topola/src/layout/compounds/net.rs +++ b/topola/src/layout/compounds/net.rs @@ -5,7 +5,7 @@ use derive_more::{Constructor, From}; use serde::{Deserialize, Serialize}; -use crate::PinId; +use crate::layout::compounds::PinId; #[derive( Clone, diff --git a/topola/src/layout/compounds/pin.rs b/topola/src/layout/compounds/pin.rs index cd377a7..79007ac 100644 --- a/topola/src/layout/compounds/pin.rs +++ b/topola/src/layout/compounds/pin.rs @@ -6,12 +6,12 @@ use derive_more::{Constructor, From}; use serde::{Deserialize, Serialize}; use crate::{ - Layout, Vector2, layout::{ + Layout, compounds::{ComponentId, NetId}, - primitives::{JointId, PolygonId, SegmentId, ViaId}, + primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId}, }, - primitives::PrimitiveId, + vector::Vector2, }; #[derive( diff --git a/topola/src/layout/delete.rs b/topola/src/layout/delete.rs index d2d3682..6f0dd14 100644 --- a/topola/src/layout/delete.rs +++ b/topola/src/layout/delete.rs @@ -4,8 +4,8 @@ use rstar::primitives::GeomWithData; -use crate::{ - layout::Layout, +use crate::layout::{ + Layout, primitives::{JointId, PolygonId, SegmentId, ViaId}, }; diff --git a/topola/src/layout/infringement.rs b/topola/src/layout/infringement.rs index e9b6d46..67a7eb3 100644 --- a/topola/src/layout/infringement.rs +++ b/topola/src/layout/infringement.rs @@ -11,7 +11,7 @@ use rstar::{ }; use serde::{Deserialize, Serialize}; -use crate::primitives::PrimitiveId; +use crate::layout::primitives::PrimitiveId; use super::Layout; use super::compounds::{ComponentId, NetId, PinId}; diff --git a/topola/src/layout/insert.rs b/topola/src/layout/insert.rs index fb0aab9..9a199d5 100644 --- a/topola/src/layout/insert.rs +++ b/topola/src/layout/insert.rs @@ -4,11 +4,9 @@ use rstar::primitives::GeomWithData; -use crate::{ - layout::{ - Layout, - compounds::{Component, ComponentId, Pin, PinId, PinSpec}, - }, +use crate::layout::{ + Layout, + compounds::{Component, ComponentId, Pin, PinId, PinSpec}, primitives::{ Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId, ViaSpec, diff --git a/topola/src/layout/locate.rs b/topola/src/layout/locate.rs index 2c54ded..682e008 100644 --- a/topola/src/layout/locate.rs +++ b/topola/src/layout/locate.rs @@ -5,9 +5,13 @@ use std::collections::BTreeSet; use crate::{ - Rect2, Rect3, Vector2, Vector3, - layout::{Layout, compounds::NetId}, - primitives::{JointId, PolygonId, SegmentId, ViaId}, + layout::{ + Layout, + compounds::NetId, + primitives::{JointId, PolygonId, SegmentId, ViaId}, + }, + rect::{Rect2, Rect3}, + vector::{Vector2, Vector3}, }; impl Layout { diff --git a/topola/src/layout/modify.rs b/topola/src/layout/modify.rs index 3c17ce6..89f5077 100644 --- a/topola/src/layout/modify.rs +++ b/topola/src/layout/modify.rs @@ -4,8 +4,8 @@ use rstar::primitives::GeomWithData; -use crate::{ - layout::Layout, +use crate::layout::{ + Layout, primitives::{ Joint, JointId, JointSpec, Polygon, PolygonId, SegmentId, SegmentSpec, ViaId, ViaSpec, }, diff --git a/topola/src/layout/primitives/joint.rs b/topola/src/layout/primitives/joint.rs index 0a1bbd6..7712470 100644 --- a/topola/src/layout/primitives/joint.rs +++ b/topola/src/layout/primitives/joint.rs @@ -6,7 +6,7 @@ use derive_more::{Constructor, From}; use serde::{Deserialize, Serialize}; use crate::layout::compounds::{ComponentId, NetId, PinId}; -use crate::primitives::{SegmentId, ViaId}; +use crate::layout::primitives::{SegmentId, ViaId}; use crate::vector::Vector2; use crate::{Rect3, Vector3, layout::LayerId}; diff --git a/topola/src/layout/primitives/mod.rs b/topola/src/layout/primitives/mod.rs index 9bc1ea7..6964bd3 100644 --- a/topola/src/layout/primitives/mod.rs +++ b/topola/src/layout/primitives/mod.rs @@ -15,7 +15,7 @@ pub use polygon::*; pub use segment::*; pub use via::*; -use crate::{Layout, PinId}; +use crate::layout::{Layout, compounds::PinId}; #[derive(Clone, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize)] pub enum PrimitiveId { diff --git a/topola/src/layout/repulsion.rs b/topola/src/layout/repulsion.rs index 09d58be..5b7119e 100644 --- a/topola/src/layout/repulsion.rs +++ b/topola/src/layout/repulsion.rs @@ -3,14 +3,15 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use crate::{ - Rect2, Vector2, compass::CompassDirection, layout::{ Layout, compounds::{ComponentId, PinId}, + primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId}, }, orientation::Orientation, - primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId}, + rect::Rect2, + vector::Vector2, }; impl Layout { diff --git a/topola/src/layout/transforms/move_by.rs b/topola/src/layout/transforms/move_by.rs index b8c8d29..867cd02 100644 --- a/topola/src/layout/transforms/move_by.rs +++ b/topola/src/layout/transforms/move_by.rs @@ -2,7 +2,10 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::{Layout, layout::compounds::ComponentId, vector::Vector2}; +use crate::{ + layout::{Layout, compounds::ComponentId}, + vector::Vector2, +}; impl Layout { pub fn move_component_by(&mut self, id: ComponentId, translation: Vector2) { diff --git a/topola/src/lib.rs b/topola/src/lib.rs index d40dbb2..4182b2a 100644 --- a/topola/src/lib.rs +++ b/topola/src/lib.rs @@ -4,10 +4,11 @@ mod autoplacer; mod autorouter; -mod board; +pub mod board; mod compass; mod drawer; -mod layout; +mod interactor; +pub mod layout; mod math; mod navmesher; mod orientation; @@ -20,19 +21,8 @@ mod vector; mod workspace; pub use crate::autorouter::Autorouter; -pub use crate::board::Board; -pub use crate::board::LayerDesc; -pub use crate::board::LayerSide; -pub use crate::board::LayerType; -pub use crate::board::interactors::{ - DragSelectInteractor, DragSelectOptions, MasterInteractor, SelectInteractor, - SelectionCombineMode, SelectionContainMode, -}; pub use crate::board::selections; -pub use crate::layout::LayerId; -pub use crate::layout::Layout; -pub use crate::layout::compounds::{Pin, PinId}; -pub use crate::layout::primitives; +pub use crate::interactor::{Interactor, MasterInteractor}; pub use crate::orientation::Orientation; pub use crate::ratsnest::{Ratline, Ratsnest}; pub use crate::rect::{Rect2, Rect3}; diff --git a/topola/src/navmesher.rs b/topola/src/navmesher.rs index 7aa82f0..bbcf86c 100644 --- a/topola/src/navmesher.rs +++ b/topola/src/navmesher.rs @@ -10,9 +10,11 @@ use stable_vec::StableVec; use undoredo::Recorder; use crate::{ - Board, - layout::LayerId, - primitives::{Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId}, + board::Board, + layout::{ + LayerId, + primitives::{Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId}, + }, vector::Vector2, }; diff --git a/topola/src/ratsnest.rs b/topola/src/ratsnest.rs index 7337144..1d87a4b 100644 --- a/topola/src/ratsnest.rs +++ b/topola/src/ratsnest.rs @@ -9,10 +9,12 @@ use serde::{Deserialize, Serialize}; use spade::{DelaunayTriangulation, HasPosition, Triangulation, handles::FixedVertexHandle}; use crate::{ - Board, - layout::LayerId, - layout::compounds::NetId, - primitives::{JointId, PolygonId, PrimitiveId, SegmentId}, + board::Board, + layout::{ + LayerId, + compounds::NetId, + primitives::{JointId, PolygonId, PrimitiveId, SegmentId}, + }, vector::Vector2, }; diff --git a/topola/src/router.rs b/topola/src/router.rs index 68427e0..08a4986 100644 --- a/topola/src/router.rs +++ b/topola/src/router.rs @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::{Board, drawer::Drawer, navmesher::NavmesherBoard, pathfinder::Pathfinder}; +use crate::{board::Board, drawer::Drawer, navmesher::NavmesherBoard, pathfinder::Pathfinder}; #[derive(Clone, Debug)] pub enum Router { diff --git a/topola/src/specctra.rs b/topola/src/specctra.rs index d0d03d7..76d6da7 100644 --- a/topola/src/specctra.rs +++ b/topola/src/specctra.rs @@ -16,7 +16,7 @@ use crate::{ LayerId, compounds::{ComponentId, NetId, PinId, PinSpec}, }, - primitives::{JointSpec, Polygon, Segment, SegmentSpec}, + layout::primitives::{JointSpec, Polygon, Segment, SegmentSpec}, vector::Vector2, }; diff --git a/topola/src/workspace.rs b/topola/src/workspace.rs index 7362853..92bb04a 100644 --- a/topola/src/workspace.rs +++ b/topola/src/workspace.rs @@ -4,7 +4,7 @@ use undoredo::FlushDelta; -use crate::{Autorouter, Board, selections::PersistableSelection}; +use crate::{autorouter::Autorouter, board::Board, selections::PersistableSelection}; pub enum Workspace { Board(BoardWorkspace),