mirror of https://codeberg.org/topola/topola.git
Make it possible to select whole components. Use different color for pin selection
This commit is contained in:
parent
9221663d66
commit
df5a9b57ec
|
|
@ -54,6 +54,10 @@ impl Display {
|
|||
board.pins_contain_joint(&workspace.workspace.selection().pins, joint_id);
|
||||
let net_selected =
|
||||
board.nets_contain_joint(&workspace.workspace.selection().nets, joint_id);
|
||||
let component_selected = board.components_contain_joint(
|
||||
&workspace.workspace.selection().components,
|
||||
joint_id,
|
||||
);
|
||||
self.paint_joint(
|
||||
ctx,
|
||||
ui,
|
||||
|
|
@ -62,7 +66,8 @@ impl Display {
|
|||
workspace.appearance_panel.layer_color(
|
||||
ctx,
|
||||
board.layer_desc(joint.spec.layer),
|
||||
pin_selected || (joint.spec.pin.is_none() && net_selected),
|
||||
pin_selected,
|
||||
(joint.spec.pin.is_none() && net_selected) || component_selected,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -73,6 +78,10 @@ impl Display {
|
|||
board.pins_contain_segment(&workspace.workspace.selection().pins, segment_id);
|
||||
let net_selected =
|
||||
board.nets_contain_segment(&workspace.workspace.selection().nets, segment_id);
|
||||
let component_selected = board.components_contain_segment(
|
||||
&workspace.workspace.selection().components,
|
||||
segment_id,
|
||||
);
|
||||
self.paint_segment(
|
||||
ctx,
|
||||
ui,
|
||||
|
|
@ -81,7 +90,8 @@ impl Display {
|
|||
workspace.appearance_panel.layer_color(
|
||||
ctx,
|
||||
board.layer_desc(segment.layer),
|
||||
pin_selected || (segment.spec.pin.is_none() && net_selected),
|
||||
pin_selected,
|
||||
(segment.spec.pin.is_none() && net_selected) || component_selected,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -92,6 +102,8 @@ impl Display {
|
|||
board.pins_contain_via(&workspace.workspace.selection().pins, via_id);
|
||||
let net_selected =
|
||||
board.nets_contain_via(&workspace.workspace.selection().nets, via_id);
|
||||
let component_selected =
|
||||
board.components_contain_via(&workspace.workspace.selection().components, via_id);
|
||||
self.paint_via(
|
||||
ctx,
|
||||
ui,
|
||||
|
|
@ -100,7 +112,8 @@ impl Display {
|
|||
workspace.appearance_panel.layer_color(
|
||||
ctx,
|
||||
board.layer_desc(layer),
|
||||
pin_selected || (via.spec.pin.is_none() && net_selected),
|
||||
pin_selected,
|
||||
(via.spec.pin.is_none() && net_selected) || component_selected,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -111,6 +124,10 @@ impl Display {
|
|||
board.pins_contain_polygon(&workspace.workspace.selection().pins, polygon_id);
|
||||
let net_selected =
|
||||
board.nets_contain_polygon(&workspace.workspace.selection().nets, polygon_id);
|
||||
let component_selected = board.components_contain_polygon(
|
||||
&workspace.workspace.selection().components,
|
||||
polygon_id,
|
||||
);
|
||||
self.paint_polygon(
|
||||
ctx,
|
||||
ui,
|
||||
|
|
@ -119,7 +136,8 @@ impl Display {
|
|||
workspace.appearance_panel.layer_color(
|
||||
ctx,
|
||||
board.layer_desc(polygon.layer),
|
||||
pin_selected || (polygon.pin.is_none() && net_selected),
|
||||
pin_selected,
|
||||
(polygon.pin.is_none() && net_selected) || component_selected,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ impl ColorLayers {
|
|||
pub struct LayerColors {
|
||||
pub normal: egui::Color32,
|
||||
pub highlighted: egui::Color32,
|
||||
pub pin_selected: egui::Color32,
|
||||
pub pin_selected_highlighted: egui::Color32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
|
|
@ -58,26 +60,34 @@ impl LayersPanel {
|
|||
continue;
|
||||
};
|
||||
|
||||
let color = match layer_desc.typ {
|
||||
let dark_light_colors = match layer_desc.typ {
|
||||
LayerType::Copper => match layer_desc.side {
|
||||
LayerSide::Top => Some((
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(255, 52, 52),
|
||||
highlighted: egui::Color32::from_rgb(255, 100, 100),
|
||||
pin_selected: egui::Color32::from_rgb(190, 200, 70),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(210, 240, 110),
|
||||
},
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(255, 27, 27),
|
||||
highlighted: egui::Color32::from_rgb(255, 52, 52),
|
||||
pin_selected: egui::Color32::from_rgb(160, 170, 50),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(190, 210, 80),
|
||||
},
|
||||
)),
|
||||
LayerSide::Bottom => Some((
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(52, 52, 255),
|
||||
highlighted: egui::Color32::from_rgb(100, 100, 255),
|
||||
pin_selected: egui::Color32::from_rgb(70, 190, 190),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(100, 230, 230),
|
||||
},
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(27, 27, 255),
|
||||
highlighted: egui::Color32::from_rgb(52, 52, 255),
|
||||
pin_selected: egui::Color32::from_rgb(50, 160, 160),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(70, 200, 200),
|
||||
},
|
||||
)),
|
||||
LayerSide::Inner => (layer_desc.index % 2 == 0)
|
||||
|
|
@ -85,36 +95,65 @@ impl LayersPanel {
|
|||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(127, 200, 127),
|
||||
highlighted: egui::Color32::from_rgb(213, 236, 213),
|
||||
pin_selected: egui::Color32::from_rgb(100, 230, 100),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(170, 250, 170),
|
||||
},
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(76, 169, 76),
|
||||
highlighted: egui::Color32::from_rgb(127, 200, 127),
|
||||
pin_selected: egui::Color32::from_rgb(60, 200, 60),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(100, 230, 100),
|
||||
},
|
||||
))
|
||||
.or(Some((
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(206, 125, 44),
|
||||
highlighted: egui::Color32::from_rgb(232, 195, 158),
|
||||
pin_selected: egui::Color32::from_rgb(170, 200, 70),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(200, 230, 120),
|
||||
},
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(183, 80, 12),
|
||||
highlighted: egui::Color32::from_rgb(206, 125, 44),
|
||||
pin_selected: egui::Color32::from_rgb(140, 170, 50),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(170, 200, 80),
|
||||
},
|
||||
))),
|
||||
},
|
||||
LayerType::Outline => Some((
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(255, 255, 255),
|
||||
highlighted: egui::Color32::from_rgb(255, 255, 255),
|
||||
},
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(255, 255, 255),
|
||||
highlighted: egui::Color32::from_rgb(255, 255, 255),
|
||||
},
|
||||
)),
|
||||
LayerType::Outline => match layer_desc.side {
|
||||
LayerSide::Top => Some((
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(222, 217, 141),
|
||||
highlighted: egui::Color32::from_rgb(255, 255, 215),
|
||||
pin_selected: egui::Color32::from_rgb(170, 235, 100),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(210, 255, 160),
|
||||
},
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(185, 180, 110),
|
||||
highlighted: egui::Color32::from_rgb(245, 240, 165),
|
||||
pin_selected: egui::Color32::from_rgb(140, 210, 80),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(190, 245, 130),
|
||||
},
|
||||
)),
|
||||
LayerSide::Bottom => Some((
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(212, 158, 147),
|
||||
highlighted: egui::Color32::from_rgb(255, 228, 210),
|
||||
pin_selected: egui::Color32::from_rgb(160, 210, 110),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(200, 245, 165),
|
||||
},
|
||||
LayerColors {
|
||||
normal: egui::Color32::from_rgb(170, 130, 120),
|
||||
highlighted: egui::Color32::from_rgb(235, 195, 185),
|
||||
pin_selected: egui::Color32::from_rgb(130, 190, 85),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(175, 230, 140),
|
||||
},
|
||||
)),
|
||||
LayerSide::Inner => None,
|
||||
},
|
||||
};
|
||||
|
||||
if let Some((dark_color, light_color)) = color {
|
||||
if let Some((dark_color, light_color)) = dark_light_colors {
|
||||
dark_layer_colors.insert(layer_desc.clone(), dark_color);
|
||||
light_layer_colors.insert(layer_desc.clone(), light_color);
|
||||
}
|
||||
|
|
@ -125,6 +164,8 @@ impl LayersPanel {
|
|||
default: LayerColors {
|
||||
normal: egui::Color32::from_rgb(255, 255, 255),
|
||||
highlighted: egui::Color32::from_rgb(255, 255, 255),
|
||||
pin_selected: egui::Color32::from_rgb(200, 255, 200),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(220, 255, 220),
|
||||
},
|
||||
colors: dark_layer_colors,
|
||||
},
|
||||
|
|
@ -134,6 +175,8 @@ impl LayersPanel {
|
|||
default: LayerColors {
|
||||
normal: egui::Color32::from_rgb(0, 0, 0),
|
||||
highlighted: egui::Color32::from_rgb(0, 0, 0),
|
||||
pin_selected: egui::Color32::from_rgb(0, 100, 0),
|
||||
pin_selected_highlighted: egui::Color32::from_rgb(0, 140, 0),
|
||||
},
|
||||
colors: light_layer_colors,
|
||||
},
|
||||
|
|
@ -199,12 +242,20 @@ impl LayersPanel {
|
|||
&self,
|
||||
ctx: &Context,
|
||||
layer_desc: Option<&LayerDesc>,
|
||||
pin_selected: bool,
|
||||
highlight: bool,
|
||||
) -> egui::Color32 {
|
||||
if highlight {
|
||||
self.colors(ctx).layers.colors(layer_desc).highlighted
|
||||
let colors = self.colors(ctx).layers.colors(layer_desc);
|
||||
if pin_selected {
|
||||
if highlight {
|
||||
colors.pin_selected_highlighted
|
||||
} else {
|
||||
colors.pin_selected
|
||||
}
|
||||
} else if highlight {
|
||||
colors.highlighted
|
||||
} else {
|
||||
self.colors(ctx).layers.colors(layer_desc).normal
|
||||
colors.normal
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,29 +60,70 @@ impl DragSelectionInteractor {
|
|||
Vector3::new(input.pointer.x, input.pointer.y, self.layer.index() as i64),
|
||||
);
|
||||
|
||||
match self.options.contain {
|
||||
let all_belong_to_pins = match self.options.contain {
|
||||
SelectionContainMode::Crossing => {
|
||||
self.selection
|
||||
.components
|
||||
.add(board.locate_components_prefer_layer_intersecting_rect(rect));
|
||||
board
|
||||
.layout()
|
||||
.locate_joints_prefer_layer_intersecting_rect(rect)
|
||||
.all(|joint_id| board.layout().joint(joint_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_segments_prefer_layer_intersecting_rect(rect)
|
||||
.all(|segment_id| board.layout().segment(segment_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_vias_prefer_layer_intersecting_rect(rect)
|
||||
.all(|via_id| board.layout().via(via_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_polygons_prefer_layer_intersecting_rect(rect)
|
||||
.all(|polygon_id| board.layout().polygon(polygon_id).pin.is_some())
|
||||
}
|
||||
SelectionContainMode::Window => {
|
||||
self.selection
|
||||
.components
|
||||
.add(board.locate_components_prefer_layer_inside_rect(rect));
|
||||
board
|
||||
.layout()
|
||||
.locate_joints_prefer_layer_inside_rect(rect)
|
||||
.all(|joint_id| board.layout().joint(joint_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_segments_prefer_layer_inside_rect(rect)
|
||||
.all(|segment_id| board.layout().segment(segment_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_vias_prefer_layer_inside_rect(rect)
|
||||
.all(|via_id| board.layout().via(via_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_polygons_prefer_layer_inside_rect(rect)
|
||||
.all(|polygon_id| board.layout().polygon(polygon_id).pin.is_some())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
match self.options.contain {
|
||||
SelectionContainMode::Crossing => {
|
||||
self.selection
|
||||
.nets
|
||||
.add(board.locate_nets_prefer_layer_intersecting_rect(rect));
|
||||
if !all_belong_to_pins {
|
||||
match self.options.contain {
|
||||
SelectionContainMode::Crossing => {
|
||||
self.selection
|
||||
.components
|
||||
.add(board.locate_components_prefer_layer_intersecting_rect(rect));
|
||||
}
|
||||
SelectionContainMode::Window => {
|
||||
self.selection
|
||||
.components
|
||||
.add(board.locate_components_prefer_layer_inside_rect(rect));
|
||||
}
|
||||
}
|
||||
SelectionContainMode::Window => {
|
||||
self.selection
|
||||
.nets
|
||||
.add(board.locate_nets_prefer_layer_inside_rect(rect));
|
||||
|
||||
match self.options.contain {
|
||||
SelectionContainMode::Crossing => {
|
||||
self.selection
|
||||
.nets
|
||||
.add(board.locate_nets_prefer_layer_intersecting_rect(rect));
|
||||
}
|
||||
SelectionContainMode::Window => {
|
||||
self.selection
|
||||
.nets
|
||||
.add(board.locate_nets_prefer_layer_inside_rect(rect));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ impl Board {
|
|||
|
||||
pub fn nets_contain_joint(&self, selection: &NetSelection, id: JointId) -> bool {
|
||||
let joint = self.layout.joint(id);
|
||||
let Some(net_name) = self.net_name(joint.spec.net) else {
|
||||
let Some(net_name) = joint.spec.net.and_then(|net| self.net_name(net)) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ impl Board {
|
|||
|
||||
pub fn nets_contain_segment(&self, selection: &NetSelection, id: SegmentId) -> bool {
|
||||
let segment = self.layout.segment(id);
|
||||
let Some(net_name) = self.net_name(segment.net) else {
|
||||
let Some(net_name) = segment.net.and_then(|net| self.net_name(net)) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ impl Board {
|
|||
|
||||
pub fn nets_contain_via(&self, selection: &NetSelection, id: ViaId) -> bool {
|
||||
let via = self.layout.via(id);
|
||||
let Some(net_name) = self.net_name(via.net) else {
|
||||
let Some(net_name) = via.net.and_then(|net| self.net_name(net)) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ impl Board {
|
|||
|
||||
pub fn nets_contain_polygon(&self, selection: &NetSelection, id: PolygonId) -> bool {
|
||||
let polygon = self.layout.polygon(id);
|
||||
let Some(net_name) = self.net_name(polygon.net) else {
|
||||
let Some(net_name) = polygon.net.and_then(|net| self.net_name(net)) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ impl Board {
|
|||
let joint = self.layout.joint(id);
|
||||
|
||||
Some(NetSelector {
|
||||
net: self.net_name(joint.spec.net)?.to_string(),
|
||||
net: self.net_name(joint.spec.net?)?.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ impl Board {
|
|||
let segment = self.layout.segment(id);
|
||||
|
||||
Some(NetSelector {
|
||||
net: self.net_name(segment.net)?.to_string(),
|
||||
net: self.net_name(segment.net?)?.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ impl Board {
|
|||
let via = self.layout.via(id);
|
||||
|
||||
Some(NetSelector {
|
||||
net: self.net_name(via.net)?.to_string(),
|
||||
net: self.net_name(via.net?)?.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ impl Board {
|
|||
let polygon = self.layout.polygon(id);
|
||||
|
||||
Some(NetSelector {
|
||||
net: self.net_name(polygon.net)?.to_string(),
|
||||
net: self.net_name(polygon.net?)?.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -528,19 +528,27 @@ impl Layout {
|
|||
let mut nets = BTreeSet::new();
|
||||
|
||||
for joint_id in self.locate_joints_prefer_layer_intersecting_rect(rect) {
|
||||
nets.insert(self.joint(joint_id).spec.net);
|
||||
if let Some(net) = self.joint(joint_id).spec.net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for segment_id in self.locate_segments_prefer_layer_intersecting_rect(rect) {
|
||||
nets.insert(self.segment(segment_id).net);
|
||||
if let Some(net) = self.segment(segment_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for via_id in self.locate_vias_prefer_layer_intersecting_rect(rect) {
|
||||
nets.insert(self.via(via_id).net);
|
||||
if let Some(net) = self.via(via_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for polygon_id in self.locate_polygons_prefer_layer_intersecting_rect(rect) {
|
||||
nets.insert(self.polygon(polygon_id).net);
|
||||
if let Some(net) = self.polygon(polygon_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
nets.into_iter()
|
||||
|
|
@ -550,19 +558,27 @@ impl Layout {
|
|||
let mut nets = BTreeSet::new();
|
||||
|
||||
for joint_id in self.locate_joints_intersecting_rect(rect) {
|
||||
nets.insert(self.joint(joint_id).spec.net);
|
||||
if let Some(net) = self.joint(joint_id).spec.net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for segment_id in self.locate_segments_intersecting_rect(rect) {
|
||||
nets.insert(self.segment(segment_id).net);
|
||||
if let Some(net) = self.segment(segment_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for via_id in self.locate_vias_intersecting_rect(rect) {
|
||||
nets.insert(self.via(via_id).net);
|
||||
if let Some(net) = self.via(via_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for polygon_id in self.locate_polygons_intersecting_rect(rect) {
|
||||
nets.insert(self.polygon(polygon_id).net);
|
||||
if let Some(net) = self.polygon(polygon_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
nets.into_iter()
|
||||
|
|
@ -575,19 +591,27 @@ impl Layout {
|
|||
let mut nets = BTreeSet::new();
|
||||
|
||||
for joint_id in self.locate_joints_prefer_layer_inside_rect(rect) {
|
||||
nets.insert(self.joint(joint_id).spec.net);
|
||||
if let Some(net) = self.joint(joint_id).spec.net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for segment_id in self.locate_segments_prefer_layer_inside_rect(rect) {
|
||||
nets.insert(self.segment(segment_id).net);
|
||||
if let Some(net) = self.segment(segment_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for via_id in self.locate_vias_prefer_layer_inside_rect(rect) {
|
||||
nets.insert(self.via(via_id).net);
|
||||
if let Some(net) = self.via(via_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for polygon_id in self.locate_polygons_prefer_layer_inside_rect(rect) {
|
||||
nets.insert(self.polygon(polygon_id).net);
|
||||
if let Some(net) = self.polygon(polygon_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
nets.into_iter()
|
||||
|
|
@ -597,19 +621,27 @@ impl Layout {
|
|||
let mut nets = BTreeSet::new();
|
||||
|
||||
for joint_id in self.locate_joints_inside_rect(rect) {
|
||||
nets.insert(self.joint(joint_id).spec.net);
|
||||
if let Some(net) = self.joint(joint_id).spec.net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for segment_id in self.locate_segments_inside_rect(rect) {
|
||||
nets.insert(self.segment(segment_id).net);
|
||||
if let Some(net) = self.segment(segment_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for via_id in self.locate_vias_inside_rect(rect) {
|
||||
nets.insert(self.via(via_id).net);
|
||||
if let Some(net) = self.via(via_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
for polygon_id in self.locate_polygons_inside_rect(rect) {
|
||||
nets.insert(self.polygon(polygon_id).net);
|
||||
if let Some(net) = self.polygon(polygon_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
||||
nets.into_iter()
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ pub struct JointSpec {
|
|||
pub position: Vector2<i64>,
|
||||
pub layer: LayerId,
|
||||
pub radius: u64,
|
||||
pub net: NetId,
|
||||
pub net: Option<NetId>,
|
||||
pub component: Option<ComponentId>,
|
||||
pub pin: Option<PinId>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ impl PolygonId {
|
|||
pub struct Polygon {
|
||||
pub vertices: Vec<Vector2<i64>>,
|
||||
pub layer: LayerId,
|
||||
pub net: NetId,
|
||||
pub net: Option<NetId>,
|
||||
pub component: Option<ComponentId>,
|
||||
pub pin: Option<PinId>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ pub struct Segment {
|
|||
pub spec: SegmentSpec,
|
||||
pub endpoints: [Vector2<i64>; 2],
|
||||
pub layer: LayerId,
|
||||
pub net: NetId,
|
||||
pub net: Option<NetId>,
|
||||
}
|
||||
|
||||
impl Segment {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ pub struct Via {
|
|||
pub position: Vector2<i64>,
|
||||
pub min_layer: LayerId,
|
||||
pub max_layer: LayerId,
|
||||
pub net: NetId,
|
||||
pub net: Option<NetId>,
|
||||
}
|
||||
|
||||
impl Via {
|
||||
|
|
|
|||
|
|
@ -51,8 +51,12 @@ impl Ratsnest {
|
|||
BTreeMap::new();
|
||||
|
||||
for (i, joint) in board.layout().joints().container().iter() {
|
||||
let Some(net) = joint.spec.net else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let _ = triangulations
|
||||
.entry((joint.spec.net, joint.spec.layer))
|
||||
.entry((net, joint.spec.layer))
|
||||
.or_insert_with(DelaunayTriangulation::new)
|
||||
.insert(DelaunayVertex {
|
||||
layer: joint.spec.layer,
|
||||
|
|
@ -63,9 +67,13 @@ impl Ratsnest {
|
|||
}
|
||||
|
||||
for (i, segment) in board.layout().segments().container().iter() {
|
||||
let Some(net) = segment.net else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let segment_center = segment.center();
|
||||
let _ = triangulations
|
||||
.entry((segment.net, segment.layer))
|
||||
.entry((net, segment.layer))
|
||||
.or_insert_with(DelaunayTriangulation::new)
|
||||
.insert(DelaunayVertex {
|
||||
layer: segment.layer,
|
||||
|
|
@ -76,8 +84,12 @@ impl Ratsnest {
|
|||
}
|
||||
|
||||
for (i, polygon) in board.layout().polygons().container().iter() {
|
||||
let Some(net) = polygon.net else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let _ = triangulations
|
||||
.entry((polygon.net, polygon.layer))
|
||||
.entry((net, polygon.layer))
|
||||
.or_insert_with(DelaunayTriangulation::new)
|
||||
.insert(DelaunayVertex {
|
||||
layer: polygon.layer,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,32 @@ impl<T: RTreeNum> Rect2<T> {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_rect2_contains_point {
|
||||
($type:ty) => {
|
||||
impl Rect2<$type> {
|
||||
pub fn contains_point(&self, point: Vector2<$type>) -> bool {
|
||||
point.x >= self.min.x
|
||||
&& point.x <= self.max.x
|
||||
&& point.y >= self.min.y
|
||||
&& point.y <= self.max.y
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl_rect2_contains_point!(i8);
|
||||
impl_rect2_contains_point!(i16);
|
||||
impl_rect2_contains_point!(i32);
|
||||
impl_rect2_contains_point!(i64);
|
||||
impl_rect2_contains_point!(i128);
|
||||
impl_rect2_contains_point!(u8);
|
||||
impl_rect2_contains_point!(u16);
|
||||
impl_rect2_contains_point!(u32);
|
||||
impl_rect2_contains_point!(u64);
|
||||
impl_rect2_contains_point!(u128);
|
||||
impl_rect2_contains_point!(f32);
|
||||
impl_rect2_contains_point!(f64);
|
||||
|
||||
macro_rules! impl_rect2_contains_circle {
|
||||
($type:ty) => {
|
||||
impl Rect2<$type> {
|
||||
|
|
@ -152,12 +178,15 @@ macro_rules! impl_rect2_intersects_polygon {
|
|||
return false;
|
||||
}
|
||||
|
||||
if self.contains_polygon(polygon) {
|
||||
if polygon.iter().any(|&vertex| self.contains_point(vertex)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let corners = self.corners();
|
||||
if corners.iter().any(|corner| corner.inside_polygon(polygon)) {
|
||||
if self
|
||||
.corners()
|
||||
.iter()
|
||||
.any(|corner| corner.inside_polygon(polygon))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,8 +72,6 @@ impl Board {
|
|||
.chain(dsn.pcb.network.nets.iter().map(|net| &net.name))
|
||||
.cloned()
|
||||
.collect();
|
||||
// deduplicate net names
|
||||
tmp.push("outlines".to_string());
|
||||
tmp.sort_unstable();
|
||||
tmp.dedup();
|
||||
|
||||
|
|
@ -99,7 +97,6 @@ impl Board {
|
|||
layer_descs,
|
||||
net_names,
|
||||
);
|
||||
let outline_net = board.net_id("outlines").unwrap();
|
||||
|
||||
// Mapping of pin -> net prepared for adding pins.
|
||||
let pin_nets: BTreeMap<String, NetId> = dsn
|
||||
|
|
@ -152,7 +149,7 @@ impl Board {
|
|||
&outline.path.coords,
|
||||
outline.path.width,
|
||||
outline_layer_id,
|
||||
outline_net,
|
||||
None,
|
||||
Some(component_id),
|
||||
None,
|
||||
!place_side_is_front,
|
||||
|
|
@ -180,7 +177,7 @@ impl Board {
|
|||
pin.point_with_rotation(),
|
||||
circle.diameter / 2.0,
|
||||
layer,
|
||||
net,
|
||||
Some(net),
|
||||
Some(component_id),
|
||||
Some(pin_id),
|
||||
!place_side_is_front,
|
||||
|
|
@ -198,7 +195,7 @@ impl Board {
|
|||
rect.x2,
|
||||
rect.y2,
|
||||
layer,
|
||||
net,
|
||||
Some(net),
|
||||
Some(component_id),
|
||||
Some(pin_id),
|
||||
!place_side_is_front,
|
||||
|
|
@ -214,7 +211,7 @@ impl Board {
|
|||
&path.coords,
|
||||
path.width,
|
||||
layer,
|
||||
net,
|
||||
Some(net),
|
||||
Some(component_id),
|
||||
Some(pin_id),
|
||||
!place_side_is_front,
|
||||
|
|
@ -230,7 +227,7 @@ impl Board {
|
|||
&polygon.coords,
|
||||
polygon.width,
|
||||
layer,
|
||||
net,
|
||||
Some(net),
|
||||
Some(component_id),
|
||||
Some(pin_id),
|
||||
!place_side_is_front,
|
||||
|
|
@ -261,7 +258,7 @@ impl Board {
|
|||
PointWithRotation::default(),
|
||||
circle.diameter / 2.0,
|
||||
layer,
|
||||
net,
|
||||
Some(net),
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
|
|
@ -279,7 +276,7 @@ impl Board {
|
|||
rect.x2,
|
||||
rect.y2,
|
||||
layer,
|
||||
net,
|
||||
Some(net),
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
|
|
@ -295,7 +292,7 @@ impl Board {
|
|||
&path.coords,
|
||||
path.width,
|
||||
layer,
|
||||
net,
|
||||
Some(net),
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
|
|
@ -311,7 +308,7 @@ impl Board {
|
|||
&polygon.coords,
|
||||
polygon.width,
|
||||
layer,
|
||||
net,
|
||||
Some(net),
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
|
|
@ -333,7 +330,7 @@ impl Board {
|
|||
&wire.path.coords,
|
||||
wire.path.width,
|
||||
layer,
|
||||
net,
|
||||
Some(net),
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
|
|
@ -350,7 +347,7 @@ impl Board {
|
|||
pin_pos: PointWithRotation,
|
||||
radius: f64,
|
||||
layer: LayerId,
|
||||
net: NetId,
|
||||
net: Option<NetId>,
|
||||
component: Option<ComponentId>,
|
||||
pin: Option<PinId>,
|
||||
flip: bool,
|
||||
|
|
@ -375,7 +372,7 @@ impl Board {
|
|||
x2: f64,
|
||||
y2: f64,
|
||||
layer: LayerId,
|
||||
net: NetId,
|
||||
net: Option<NetId>,
|
||||
component: Option<ComponentId>,
|
||||
pin: Option<PinId>,
|
||||
flip: bool,
|
||||
|
|
@ -402,7 +399,7 @@ impl Board {
|
|||
coords: &[Point],
|
||||
width: f64,
|
||||
layer: LayerId,
|
||||
net: NetId,
|
||||
net: Option<NetId>,
|
||||
component: Option<ComponentId>,
|
||||
pin: Option<PinId>,
|
||||
flip: bool,
|
||||
|
|
@ -465,7 +462,7 @@ impl Board {
|
|||
coords: &[Point],
|
||||
_width: f64,
|
||||
layer: LayerId,
|
||||
net: NetId,
|
||||
net: Option<NetId>,
|
||||
component: Option<ComponentId>,
|
||||
pin: Option<PinId>,
|
||||
flip: bool,
|
||||
|
|
|
|||
Loading…
Reference in New Issue