Create and use new enum to later use different master interactors using the same interface

This commit is contained in:
Mikolaj Wielgus 2026-06-05 00:24:00 +02:00
parent c7430f9fc9
commit b2ef23c06c
39 changed files with 215 additions and 98 deletions

View File

@ -5,7 +5,7 @@
use std::sync::mpsc::{Receiver, Sender, channel}; use std::sync::mpsc::{Receiver, Sender, channel};
use specctra::{error::ParseErrorContext, structure::DsnFile}; use specctra::{error::ParseErrorContext, structure::DsnFile};
use topola::Board; use topola::board::Board;
use unic_langid::langid; use unic_langid::langid;
use crate::{ use crate::{

View File

@ -3,8 +3,10 @@
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{viewport::Viewport, workspace::GuiWorkspace}; use crate::{viewport::Viewport, workspace::GuiWorkspace};
use topola::primitives::{Joint, Polygon, Segment, Via}; use topola::{
use topola::{Orientation, Vector2, Workspace}; Orientation, Vector2, Workspace,
layout::primitives::{Joint, Polygon, Segment, Via},
};
pub struct Display {} pub struct Display {}

View File

@ -6,7 +6,8 @@ use std::collections::BTreeMap;
use egui::{Context, Grid, ScrollArea, SidePanel, widget_text::WidgetText}; use egui::{Context, Grid, ScrollArea, SidePanel, widget_text::WidgetText};
use serde::{Deserialize, Serialize}; 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)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Colors { pub struct Colors {

View File

@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use egui::Pos2; 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}; use crate::{display::Display, menu_bar::MenuBar, translator::Translator, workspace::GuiWorkspace};

View File

@ -4,7 +4,7 @@
use std::{ops::ControlFlow, time::Instant}; use std::{ops::ControlFlow, time::Instant};
use topola::{Board, Workspace}; use topola::{Workspace, board::Board};
use crate::{layers_panel::LayersPanel, translator::Translator}; use crate::{layers_panel::LayersPanel, translator::Translator};

View File

@ -7,8 +7,11 @@ use rand_distr::{Distribution, Normal};
use undoredo::{FlushDelta, ResetDelta}; use undoredo::{FlushDelta, ResetDelta};
use crate::{ use crate::{
Board, Vector2, board::BoardDelta, layout::compounds::ComponentId, orientation::Orientation, board::{Board, BoardDelta},
layout::compounds::ComponentId,
orientation::Orientation,
selections::ComponentSelection, selections::ComponentSelection,
vector::Vector2,
}; };
pub struct AutoplacerSchedule { pub struct AutoplacerSchedule {

View File

@ -4,7 +4,7 @@
use derive_getters::Getters; use derive_getters::Getters;
use crate::{Board, Ratsnest, router::Router}; use crate::{board::Board, ratsnest::Ratsnest, router::Router};
#[derive(Clone, Debug, Getters)] #[derive(Clone, Debug, Getters)]
pub struct Autorouter { pub struct Autorouter {

View File

@ -2,7 +2,12 @@
// //
// SPDX-License-Identifier: MIT OR Apache-2.0 // 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 { impl Board {
pub fn components_bbox2(&self, selection: ComponentSelection) -> Option<Rect2<i64>> { pub fn components_bbox2(&self, selection: ComponentSelection) -> Option<Rect2<i64>> {

View File

@ -3,9 +3,10 @@
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{ use crate::{
Board, Vector2, board::Board,
primitives::{JointId, PolygonId, SegmentId, ViaId}, layout::primitives::{JointId, PolygonId, SegmentId, ViaId},
selections::{ComponentSelection, NetSelection, NetSelector, PinSelection}, selections::{ComponentSelection, NetSelection, NetSelector, PinSelection},
vector::Vector2,
}; };
impl Board { impl Board {

View File

@ -4,10 +4,12 @@
use crate::{ use crate::{
board::Board, board::Board,
layout::compounds::ComponentId, layout::{
primitives::{ compounds::ComponentId,
JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId, primitives::{
ViaSpec, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId,
ViaSpec,
},
}, },
}; };

View File

@ -6,7 +6,13 @@ use derive_getters::Getters;
use derive_more::Constructor; use derive_more::Constructor;
use undoredo::ResetDelta; 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)] #[derive(Clone, Constructor, Debug, Eq, Getters, PartialEq)]
pub struct DragMoveInteractor { pub struct DragMoveInteractor {
@ -15,18 +21,20 @@ pub struct DragMoveInteractor {
selection: ComponentSelection, selection: ComponentSelection,
} }
impl DragMoveInteractor { impl Interactor for DragMoveInteractor {
pub fn hold(&mut self, board: &mut Board, pointer: Vector2<i64>) { fn delete(&mut self, _board: &mut Board) {}
fn hold(&mut self, board: &mut Board, _layer: LayerId, pointer: Vector2<i64>) {
board.reset_delta(); board.reset_delta();
board.move_components_by(self.selection.clone(), pointer - self.origin); board.move_components_by(self.selection.clone(), pointer - self.origin);
} }
pub fn abort(&mut self, board: &mut Board) { fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>) {
board.reset_delta(); self.hold(board, layer, pointer);
} }
pub fn release(&mut self, board: &mut Board, pointer: Vector2<i64>) { fn abort(&mut self, board: &mut Board) {
self.hold(board, pointer); board.reset_delta();
} }
} }

View File

@ -7,13 +7,15 @@ use derive_more::Constructor;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
Rect3, Vector2, Vector3,
board::{ board::{
Board, Board,
interactors::{SelectionCombineMode, SelectionContainMode}, interactors::{SelectionCombineMode, SelectionContainMode},
selections::PersistableSelection, selections::PersistableSelection,
}, },
interactor::Interactor,
layout::LayerId, layout::LayerId,
rect::Rect3,
vector::{Vector2, Vector3},
}; };
#[derive(Clone, Constructor, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] #[derive(Clone, Constructor, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
@ -46,8 +48,12 @@ impl DragSelectInteractor {
options, options,
} }
} }
}
pub fn hold(&mut self, board: &Board, pointer: Vector2<i64>) { impl Interactor for DragSelectInteractor {
fn delete(&mut self, _board: &mut Board) {}
fn hold(&mut self, board: &mut Board, _layer: LayerId, pointer: Vector2<i64>) {
self.selection = PersistableSelection::new(); self.selection = PersistableSelection::new();
let rect = Rect3::new( let rect = Rect3::new(
@ -181,7 +187,11 @@ impl DragSelectInteractor {
self.selection = combined_selection; self.selection = combined_selection;
} }
pub fn abort(&mut self) { fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>) {
self.hold(board, layer, pointer);
}
fn abort(&mut self, _board: &mut Board) {
self.selection = self.original_selection.clone(); self.selection = self.original_selection.clone();
} }
} }

View File

@ -5,13 +5,14 @@
use derive_getters::Getters; use derive_getters::Getters;
use crate::{ use crate::{
Vector2,
board::{ board::{
Board, Board,
interactors::{DragMoveInteractor, SelectInteractor, SelectionCombineMode}, interactors::{DragMoveInteractor, SelectInteractor, SelectionCombineMode},
selections::PersistableSelection, selections::PersistableSelection,
}, },
interactor::Interactor,
layout::LayerId, layout::LayerId,
vector::Vector2,
}; };
#[derive(Clone, Debug, Eq, Getters, PartialEq)] #[derive(Clone, Debug, Eq, Getters, PartialEq)]
@ -29,12 +30,14 @@ impl MasterInteractor {
selection, 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()); board.delete_net_free_primitives(self.selection.nets.clone());
} }
pub fn hold(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>) { fn hold(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>) {
if self.select_interactor.is_none() && self.drag_move_interactor.is_none() { if self.select_interactor.is_none() && self.drag_move_interactor.is_none() {
if board.components_contain_point(&self.selection.components, pointer) { if board.components_contain_point(&self.selection.components, pointer) {
self.drag_move_interactor = Some(DragMoveInteractor::new( 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() { 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() { } else if let Some(select_interactor) = self.select_interactor.as_mut() {
select_interactor.hold(board, layer, pointer); select_interactor.hold(board, layer, pointer);
self.selection = select_interactor.selection().clone(); self.selection = select_interactor.selection().clone();
} }
} }
pub fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>) { fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>) {
if let Some(drag_move_interactor) = self.drag_move_interactor.as_mut() { 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() { } else if let Some(select_interactor) = self.select_interactor.as_mut() {
select_interactor.release(board, layer, pointer); select_interactor.release(board, layer, pointer);
self.selection = select_interactor.selection().clone(); self.selection = select_interactor.selection().clone();
@ -71,13 +74,13 @@ impl MasterInteractor {
self.drag_move_interactor = None; 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() { if let Some(drag_move_interactor) = self.drag_move_interactor.as_mut() {
drag_move_interactor.abort(board); drag_move_interactor.abort(board);
} }
if let Some(select_interactor) = self.select_interactor.as_mut() { if let Some(select_interactor) = self.select_interactor.as_mut() {
select_interactor.abort(); select_interactor.abort(board);
self.selection = select_interactor.original_selection().clone(); self.selection = select_interactor.original_selection().clone();
} }

View File

@ -5,7 +5,6 @@
use derive_getters::Getters; use derive_getters::Getters;
use crate::{ use crate::{
Vector2, Vector3,
board::{ board::{
Board, Board,
interactors::{ interactors::{
@ -13,7 +12,9 @@ use crate::{
}, },
selections::PersistableSelection, selections::PersistableSelection,
}, },
interactor::Interactor,
layout::LayerId, layout::LayerId,
vector::{Vector2, Vector3},
}; };
#[derive(Clone, Debug, Eq, Getters, PartialEq)] #[derive(Clone, Debug, Eq, Getters, PartialEq)]
@ -37,12 +38,12 @@ impl SelectInteractor {
combine, combine,
} }
} }
}
pub fn abort(&mut self) { impl Interactor for SelectInteractor {
self.selection = self.original_selection.clone(); fn delete(&mut self, _board: &mut Board) {}
}
pub fn hold(&mut self, board: &Board, layer: LayerId, pointer: Vector2<i64>) { fn hold(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>) {
let contain = if pointer.x >= self.origin.x { let contain = if pointer.x >= self.origin.x {
SelectionContainMode::Window SelectionContainMode::Window
} else { } else {
@ -53,11 +54,11 @@ impl SelectInteractor {
let mut drag_selection_interactor = let mut drag_selection_interactor =
DragSelectInteractor::new(self.origin, layer, self.original_selection.clone(), options); 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(); self.selection = drag_selection_interactor.selection().clone();
} }
pub fn release(&mut self, board: &Board, layer: LayerId, pointer: Vector2<i64>) { fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>) {
if pointer == self.origin { if pointer == self.origin {
let mut selection = self.original_selection.clone(); let mut selection = self.original_selection.clone();
let point = Vector3::new(pointer.x, pointer.y, layer.index() as i64); let point = Vector3::new(pointer.x, pointer.y, layer.index() as i64);
@ -82,4 +83,8 @@ impl SelectInteractor {
self.hold(board, layer, pointer); self.hold(board, layer, pointer);
} }
fn abort(&mut self, _board: &mut Board) {
self.selection = self.original_selection.clone();
}
} }

View File

@ -4,8 +4,10 @@
use crate::{ use crate::{
board::{Board, selections::ComponentSelection}, board::{Board, selections::ComponentSelection},
layout::compounds::ComponentId, layout::{
primitives::{JointId, PolygonId, SegmentId, ViaId}, compounds::ComponentId,
primitives::{JointId, PolygonId, SegmentId, ViaId},
},
selections::NetSelection, selections::NetSelection,
}; };

View File

@ -9,7 +9,7 @@ use crate::{
ComponentSelection, ComponentSelector, NetSelector, PinSelection, PinSelector, ComponentSelection, ComponentSelector, NetSelector, PinSelection, PinSelector,
}, },
}, },
primitives::{JointId, PolygonId, SegmentId, ViaId}, layout::primitives::{JointId, PolygonId, SegmentId, ViaId},
}; };
impl Board { impl Board {

View File

@ -2,7 +2,7 @@
// //
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{Board, selections::NetSelection}; use crate::{board::Board, selections::NetSelection};
impl Board { impl Board {
pub fn delete_net_free_primitives(&mut self, selection: NetSelection) { pub fn delete_net_free_primitives(&mut self, selection: NetSelection) {

View File

@ -2,7 +2,12 @@
// //
// SPDX-License-Identifier: MIT OR Apache-2.0 // 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 { impl Board {
pub fn move_components_by(&mut self, selection: ComponentSelection, translation: Vector2<i64>) { pub fn move_components_by(&mut self, selection: ComponentSelection, translation: Vector2<i64>) {

View File

@ -4,7 +4,7 @@
use polygon_unionfind::UnionFind; use polygon_unionfind::UnionFind;
use crate::Board; use crate::board::Board;
pub struct Connectivity { pub struct Connectivity {
joints_unionfind: UnionFind, joints_unionfind: UnionFind,

68
topola/src/interactor.rs Normal file
View File

@ -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<i64>);
fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>);
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<SelectInteractor> {
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<i64>) {
match self {
Self::Board(interactor) => interactor.hold(board, layer, pointer),
}
}
fn release(&mut self, board: &mut Board, layer: LayerId, pointer: Vector2<i64>) {
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),
}
}
}

View File

@ -3,8 +3,11 @@
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{ use crate::{
Layout, Vector2, layout::{
layout::compounds::{ComponentId, PinId}, Layout,
compounds::{ComponentId, PinId},
},
vector::Vector2,
}; };
impl Layout { impl Layout {

View File

@ -5,10 +5,9 @@
use derive_more::{Constructor, From}; use derive_more::{Constructor, From};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::layout::{
PinId, compounds::PinId,
layout::primitives::{JointId, PolygonId, SegmentId, ViaId}, primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId},
primitives::PrimitiveId,
}; };
#[derive( #[derive(

View File

@ -5,7 +5,7 @@
use derive_more::{Constructor, From}; use derive_more::{Constructor, From};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::PinId; use crate::layout::compounds::PinId;
#[derive( #[derive(
Clone, Clone,

View File

@ -6,12 +6,12 @@ use derive_more::{Constructor, From};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
Layout, Vector2,
layout::{ layout::{
Layout,
compounds::{ComponentId, NetId}, compounds::{ComponentId, NetId},
primitives::{JointId, PolygonId, SegmentId, ViaId}, primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId},
}, },
primitives::PrimitiveId, vector::Vector2,
}; };
#[derive( #[derive(

View File

@ -4,8 +4,8 @@
use rstar::primitives::GeomWithData; use rstar::primitives::GeomWithData;
use crate::{ use crate::layout::{
layout::Layout, Layout,
primitives::{JointId, PolygonId, SegmentId, ViaId}, primitives::{JointId, PolygonId, SegmentId, ViaId},
}; };

View File

@ -11,7 +11,7 @@ use rstar::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::primitives::PrimitiveId; use crate::layout::primitives::PrimitiveId;
use super::Layout; use super::Layout;
use super::compounds::{ComponentId, NetId, PinId}; use super::compounds::{ComponentId, NetId, PinId};

View File

@ -4,11 +4,9 @@
use rstar::primitives::GeomWithData; use rstar::primitives::GeomWithData;
use crate::{ use crate::layout::{
layout::{ Layout,
Layout, compounds::{Component, ComponentId, Pin, PinId, PinSpec},
compounds::{Component, ComponentId, Pin, PinId, PinSpec},
},
primitives::{ primitives::{
Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId, Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId,
ViaSpec, ViaSpec,

View File

@ -5,9 +5,13 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use crate::{ use crate::{
Rect2, Rect3, Vector2, Vector3, layout::{
layout::{Layout, compounds::NetId}, Layout,
primitives::{JointId, PolygonId, SegmentId, ViaId}, compounds::NetId,
primitives::{JointId, PolygonId, SegmentId, ViaId},
},
rect::{Rect2, Rect3},
vector::{Vector2, Vector3},
}; };
impl Layout { impl Layout {

View File

@ -4,8 +4,8 @@
use rstar::primitives::GeomWithData; use rstar::primitives::GeomWithData;
use crate::{ use crate::layout::{
layout::Layout, Layout,
primitives::{ primitives::{
Joint, JointId, JointSpec, Polygon, PolygonId, SegmentId, SegmentSpec, ViaId, ViaSpec, Joint, JointId, JointSpec, Polygon, PolygonId, SegmentId, SegmentSpec, ViaId, ViaSpec,
}, },

View File

@ -6,7 +6,7 @@ use derive_more::{Constructor, From};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::layout::compounds::{ComponentId, NetId, PinId}; use crate::layout::compounds::{ComponentId, NetId, PinId};
use crate::primitives::{SegmentId, ViaId}; use crate::layout::primitives::{SegmentId, ViaId};
use crate::vector::Vector2; use crate::vector::Vector2;
use crate::{Rect3, Vector3, layout::LayerId}; use crate::{Rect3, Vector3, layout::LayerId};

View File

@ -15,7 +15,7 @@ pub use polygon::*;
pub use segment::*; pub use segment::*;
pub use via::*; pub use via::*;
use crate::{Layout, PinId}; use crate::layout::{Layout, compounds::PinId};
#[derive(Clone, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize)] #[derive(Clone, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize)]
pub enum PrimitiveId { pub enum PrimitiveId {

View File

@ -3,14 +3,15 @@
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{ use crate::{
Rect2, Vector2,
compass::CompassDirection, compass::CompassDirection,
layout::{ layout::{
Layout, Layout,
compounds::{ComponentId, PinId}, compounds::{ComponentId, PinId},
primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId},
}, },
orientation::Orientation, orientation::Orientation,
primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId}, rect::Rect2,
vector::Vector2,
}; };
impl Layout { impl Layout {

View File

@ -2,7 +2,10 @@
// //
// SPDX-License-Identifier: MIT OR Apache-2.0 // 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 { impl Layout {
pub fn move_component_by(&mut self, id: ComponentId, translation: Vector2<i64>) { pub fn move_component_by(&mut self, id: ComponentId, translation: Vector2<i64>) {

View File

@ -4,10 +4,11 @@
mod autoplacer; mod autoplacer;
mod autorouter; mod autorouter;
mod board; pub mod board;
mod compass; mod compass;
mod drawer; mod drawer;
mod layout; mod interactor;
pub mod layout;
mod math; mod math;
mod navmesher; mod navmesher;
mod orientation; mod orientation;
@ -20,19 +21,8 @@ mod vector;
mod workspace; mod workspace;
pub use crate::autorouter::Autorouter; 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::board::selections;
pub use crate::layout::LayerId; pub use crate::interactor::{Interactor, MasterInteractor};
pub use crate::layout::Layout;
pub use crate::layout::compounds::{Pin, PinId};
pub use crate::layout::primitives;
pub use crate::orientation::Orientation; pub use crate::orientation::Orientation;
pub use crate::ratsnest::{Ratline, Ratsnest}; pub use crate::ratsnest::{Ratline, Ratsnest};
pub use crate::rect::{Rect2, Rect3}; pub use crate::rect::{Rect2, Rect3};

View File

@ -10,9 +10,11 @@ use stable_vec::StableVec;
use undoredo::Recorder; use undoredo::Recorder;
use crate::{ use crate::{
Board, board::Board,
layout::LayerId, layout::{
primitives::{Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId}, LayerId,
primitives::{Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId},
},
vector::Vector2, vector::Vector2,
}; };

View File

@ -9,10 +9,12 @@ use serde::{Deserialize, Serialize};
use spade::{DelaunayTriangulation, HasPosition, Triangulation, handles::FixedVertexHandle}; use spade::{DelaunayTriangulation, HasPosition, Triangulation, handles::FixedVertexHandle};
use crate::{ use crate::{
Board, board::Board,
layout::LayerId, layout::{
layout::compounds::NetId, LayerId,
primitives::{JointId, PolygonId, PrimitiveId, SegmentId}, compounds::NetId,
primitives::{JointId, PolygonId, PrimitiveId, SegmentId},
},
vector::Vector2, vector::Vector2,
}; };

View File

@ -2,7 +2,7 @@
// //
// SPDX-License-Identifier: MIT OR Apache-2.0 // 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)] #[derive(Clone, Debug)]
pub enum Router { pub enum Router {

View File

@ -16,7 +16,7 @@ use crate::{
LayerId, LayerId,
compounds::{ComponentId, NetId, PinId, PinSpec}, compounds::{ComponentId, NetId, PinId, PinSpec},
}, },
primitives::{JointSpec, Polygon, Segment, SegmentSpec}, layout::primitives::{JointSpec, Polygon, Segment, SegmentSpec},
vector::Vector2, vector::Vector2,
}; };

View File

@ -4,7 +4,7 @@
use undoredo::FlushDelta; use undoredo::FlushDelta;
use crate::{Autorouter, Board, selections::PersistableSelection}; use crate::{autorouter::Autorouter, board::Board, selections::PersistableSelection};
pub enum Workspace { pub enum Workspace {
Board(BoardWorkspace), Board(BoardWorkspace),