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);
|
board.pins_contain_joint(&workspace.workspace.selection().pins, joint_id);
|
||||||
let net_selected =
|
let net_selected =
|
||||||
board.nets_contain_joint(&workspace.workspace.selection().nets, joint_id);
|
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(
|
self.paint_joint(
|
||||||
ctx,
|
ctx,
|
||||||
ui,
|
ui,
|
||||||
|
|
@ -62,7 +66,8 @@ impl Display {
|
||||||
workspace.appearance_panel.layer_color(
|
workspace.appearance_panel.layer_color(
|
||||||
ctx,
|
ctx,
|
||||||
board.layer_desc(joint.spec.layer),
|
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);
|
board.pins_contain_segment(&workspace.workspace.selection().pins, segment_id);
|
||||||
let net_selected =
|
let net_selected =
|
||||||
board.nets_contain_segment(&workspace.workspace.selection().nets, segment_id);
|
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(
|
self.paint_segment(
|
||||||
ctx,
|
ctx,
|
||||||
ui,
|
ui,
|
||||||
|
|
@ -81,7 +90,8 @@ impl Display {
|
||||||
workspace.appearance_panel.layer_color(
|
workspace.appearance_panel.layer_color(
|
||||||
ctx,
|
ctx,
|
||||||
board.layer_desc(segment.layer),
|
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);
|
board.pins_contain_via(&workspace.workspace.selection().pins, via_id);
|
||||||
let net_selected =
|
let net_selected =
|
||||||
board.nets_contain_via(&workspace.workspace.selection().nets, via_id);
|
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(
|
self.paint_via(
|
||||||
ctx,
|
ctx,
|
||||||
ui,
|
ui,
|
||||||
|
|
@ -100,7 +112,8 @@ impl Display {
|
||||||
workspace.appearance_panel.layer_color(
|
workspace.appearance_panel.layer_color(
|
||||||
ctx,
|
ctx,
|
||||||
board.layer_desc(layer),
|
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);
|
board.pins_contain_polygon(&workspace.workspace.selection().pins, polygon_id);
|
||||||
let net_selected =
|
let net_selected =
|
||||||
board.nets_contain_polygon(&workspace.workspace.selection().nets, polygon_id);
|
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(
|
self.paint_polygon(
|
||||||
ctx,
|
ctx,
|
||||||
ui,
|
ui,
|
||||||
|
|
@ -119,7 +136,8 @@ impl Display {
|
||||||
workspace.appearance_panel.layer_color(
|
workspace.appearance_panel.layer_color(
|
||||||
ctx,
|
ctx,
|
||||||
board.layer_desc(polygon.layer),
|
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 struct LayerColors {
|
||||||
pub normal: egui::Color32,
|
pub normal: egui::Color32,
|
||||||
pub highlighted: egui::Color32,
|
pub highlighted: egui::Color32,
|
||||||
|
pub pin_selected: egui::Color32,
|
||||||
|
pub pin_selected_highlighted: egui::Color32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
|
@ -58,26 +60,34 @@ impl LayersPanel {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let color = match layer_desc.typ {
|
let dark_light_colors = match layer_desc.typ {
|
||||||
LayerType::Copper => match layer_desc.side {
|
LayerType::Copper => match layer_desc.side {
|
||||||
LayerSide::Top => Some((
|
LayerSide::Top => Some((
|
||||||
LayerColors {
|
LayerColors {
|
||||||
normal: egui::Color32::from_rgb(255, 52, 52),
|
normal: egui::Color32::from_rgb(255, 52, 52),
|
||||||
highlighted: egui::Color32::from_rgb(255, 100, 100),
|
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 {
|
LayerColors {
|
||||||
normal: egui::Color32::from_rgb(255, 27, 27),
|
normal: egui::Color32::from_rgb(255, 27, 27),
|
||||||
highlighted: egui::Color32::from_rgb(255, 52, 52),
|
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((
|
LayerSide::Bottom => Some((
|
||||||
LayerColors {
|
LayerColors {
|
||||||
normal: egui::Color32::from_rgb(52, 52, 255),
|
normal: egui::Color32::from_rgb(52, 52, 255),
|
||||||
highlighted: egui::Color32::from_rgb(100, 100, 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 {
|
LayerColors {
|
||||||
normal: egui::Color32::from_rgb(27, 27, 255),
|
normal: egui::Color32::from_rgb(27, 27, 255),
|
||||||
highlighted: egui::Color32::from_rgb(52, 52, 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)
|
LayerSide::Inner => (layer_desc.index % 2 == 0)
|
||||||
|
|
@ -85,36 +95,65 @@ impl LayersPanel {
|
||||||
LayerColors {
|
LayerColors {
|
||||||
normal: egui::Color32::from_rgb(127, 200, 127),
|
normal: egui::Color32::from_rgb(127, 200, 127),
|
||||||
highlighted: egui::Color32::from_rgb(213, 236, 213),
|
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 {
|
LayerColors {
|
||||||
normal: egui::Color32::from_rgb(76, 169, 76),
|
normal: egui::Color32::from_rgb(76, 169, 76),
|
||||||
highlighted: egui::Color32::from_rgb(127, 200, 127),
|
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((
|
.or(Some((
|
||||||
LayerColors {
|
LayerColors {
|
||||||
normal: egui::Color32::from_rgb(206, 125, 44),
|
normal: egui::Color32::from_rgb(206, 125, 44),
|
||||||
highlighted: egui::Color32::from_rgb(232, 195, 158),
|
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 {
|
LayerColors {
|
||||||
normal: egui::Color32::from_rgb(183, 80, 12),
|
normal: egui::Color32::from_rgb(183, 80, 12),
|
||||||
highlighted: egui::Color32::from_rgb(206, 125, 44),
|
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((
|
LayerType::Outline => match layer_desc.side {
|
||||||
LayerColors {
|
LayerSide::Top => Some((
|
||||||
normal: egui::Color32::from_rgb(255, 255, 255),
|
LayerColors {
|
||||||
highlighted: egui::Color32::from_rgb(255, 255, 255),
|
normal: egui::Color32::from_rgb(222, 217, 141),
|
||||||
},
|
highlighted: egui::Color32::from_rgb(255, 255, 215),
|
||||||
LayerColors {
|
pin_selected: egui::Color32::from_rgb(170, 235, 100),
|
||||||
normal: egui::Color32::from_rgb(255, 255, 255),
|
pin_selected_highlighted: egui::Color32::from_rgb(210, 255, 160),
|
||||||
highlighted: egui::Color32::from_rgb(255, 255, 255),
|
},
|
||||||
},
|
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);
|
dark_layer_colors.insert(layer_desc.clone(), dark_color);
|
||||||
light_layer_colors.insert(layer_desc.clone(), light_color);
|
light_layer_colors.insert(layer_desc.clone(), light_color);
|
||||||
}
|
}
|
||||||
|
|
@ -125,6 +164,8 @@ impl LayersPanel {
|
||||||
default: LayerColors {
|
default: LayerColors {
|
||||||
normal: egui::Color32::from_rgb(255, 255, 255),
|
normal: egui::Color32::from_rgb(255, 255, 255),
|
||||||
highlighted: 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,
|
colors: dark_layer_colors,
|
||||||
},
|
},
|
||||||
|
|
@ -134,6 +175,8 @@ impl LayersPanel {
|
||||||
default: LayerColors {
|
default: LayerColors {
|
||||||
normal: egui::Color32::from_rgb(0, 0, 0),
|
normal: egui::Color32::from_rgb(0, 0, 0),
|
||||||
highlighted: 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,
|
colors: light_layer_colors,
|
||||||
},
|
},
|
||||||
|
|
@ -199,12 +242,20 @@ impl LayersPanel {
|
||||||
&self,
|
&self,
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
layer_desc: Option<&LayerDesc>,
|
layer_desc: Option<&LayerDesc>,
|
||||||
|
pin_selected: bool,
|
||||||
highlight: bool,
|
highlight: bool,
|
||||||
) -> egui::Color32 {
|
) -> egui::Color32 {
|
||||||
if highlight {
|
let colors = self.colors(ctx).layers.colors(layer_desc);
|
||||||
self.colors(ctx).layers.colors(layer_desc).highlighted
|
if pin_selected {
|
||||||
|
if highlight {
|
||||||
|
colors.pin_selected_highlighted
|
||||||
|
} else {
|
||||||
|
colors.pin_selected
|
||||||
|
}
|
||||||
|
} else if highlight {
|
||||||
|
colors.highlighted
|
||||||
} else {
|
} 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),
|
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 => {
|
SelectionContainMode::Crossing => {
|
||||||
self.selection
|
board
|
||||||
.components
|
.layout()
|
||||||
.add(board.locate_components_prefer_layer_intersecting_rect(rect));
|
.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 => {
|
SelectionContainMode::Window => {
|
||||||
self.selection
|
board
|
||||||
.components
|
.layout()
|
||||||
.add(board.locate_components_prefer_layer_inside_rect(rect));
|
.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 {
|
if !all_belong_to_pins {
|
||||||
SelectionContainMode::Crossing => {
|
match self.options.contain {
|
||||||
self.selection
|
SelectionContainMode::Crossing => {
|
||||||
.nets
|
self.selection
|
||||||
.add(board.locate_nets_prefer_layer_intersecting_rect(rect));
|
.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
|
match self.options.contain {
|
||||||
.nets
|
SelectionContainMode::Crossing => {
|
||||||
.add(board.locate_nets_prefer_layer_inside_rect(rect));
|
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 {
|
pub fn nets_contain_joint(&self, selection: &NetSelection, id: JointId) -> bool {
|
||||||
let joint = self.layout.joint(id);
|
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;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ impl Board {
|
||||||
|
|
||||||
pub fn nets_contain_segment(&self, selection: &NetSelection, id: SegmentId) -> bool {
|
pub fn nets_contain_segment(&self, selection: &NetSelection, id: SegmentId) -> bool {
|
||||||
let segment = self.layout.segment(id);
|
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;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -174,7 +174,7 @@ impl Board {
|
||||||
|
|
||||||
pub fn nets_contain_via(&self, selection: &NetSelection, id: ViaId) -> bool {
|
pub fn nets_contain_via(&self, selection: &NetSelection, id: ViaId) -> bool {
|
||||||
let via = self.layout.via(id);
|
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;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -185,7 +185,7 @@ impl Board {
|
||||||
|
|
||||||
pub fn nets_contain_polygon(&self, selection: &NetSelection, id: PolygonId) -> bool {
|
pub fn nets_contain_polygon(&self, selection: &NetSelection, id: PolygonId) -> bool {
|
||||||
let polygon = self.layout.polygon(id);
|
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;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -198,7 +198,7 @@ impl Board {
|
||||||
let joint = self.layout.joint(id);
|
let joint = self.layout.joint(id);
|
||||||
|
|
||||||
Some(NetSelector {
|
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);
|
let segment = self.layout.segment(id);
|
||||||
|
|
||||||
Some(NetSelector {
|
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);
|
let via = self.layout.via(id);
|
||||||
|
|
||||||
Some(NetSelector {
|
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);
|
let polygon = self.layout.polygon(id);
|
||||||
|
|
||||||
Some(NetSelector {
|
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();
|
let mut nets = BTreeSet::new();
|
||||||
|
|
||||||
for joint_id in self.locate_joints_prefer_layer_intersecting_rect(rect) {
|
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) {
|
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) {
|
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) {
|
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()
|
nets.into_iter()
|
||||||
|
|
@ -550,19 +558,27 @@ impl Layout {
|
||||||
let mut nets = BTreeSet::new();
|
let mut nets = BTreeSet::new();
|
||||||
|
|
||||||
for joint_id in self.locate_joints_intersecting_rect(rect) {
|
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) {
|
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) {
|
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) {
|
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()
|
nets.into_iter()
|
||||||
|
|
@ -575,19 +591,27 @@ impl Layout {
|
||||||
let mut nets = BTreeSet::new();
|
let mut nets = BTreeSet::new();
|
||||||
|
|
||||||
for joint_id in self.locate_joints_prefer_layer_inside_rect(rect) {
|
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) {
|
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) {
|
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) {
|
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()
|
nets.into_iter()
|
||||||
|
|
@ -597,19 +621,27 @@ impl Layout {
|
||||||
let mut nets = BTreeSet::new();
|
let mut nets = BTreeSet::new();
|
||||||
|
|
||||||
for joint_id in self.locate_joints_inside_rect(rect) {
|
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) {
|
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) {
|
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) {
|
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()
|
nets.into_iter()
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ pub struct JointSpec {
|
||||||
pub position: Vector2<i64>,
|
pub position: Vector2<i64>,
|
||||||
pub layer: LayerId,
|
pub layer: LayerId,
|
||||||
pub radius: u64,
|
pub radius: u64,
|
||||||
pub net: NetId,
|
pub net: Option<NetId>,
|
||||||
pub component: Option<ComponentId>,
|
pub component: Option<ComponentId>,
|
||||||
pub pin: Option<PinId>,
|
pub pin: Option<PinId>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ impl PolygonId {
|
||||||
pub struct Polygon {
|
pub struct Polygon {
|
||||||
pub vertices: Vec<Vector2<i64>>,
|
pub vertices: Vec<Vector2<i64>>,
|
||||||
pub layer: LayerId,
|
pub layer: LayerId,
|
||||||
pub net: NetId,
|
pub net: Option<NetId>,
|
||||||
pub component: Option<ComponentId>,
|
pub component: Option<ComponentId>,
|
||||||
pub pin: Option<PinId>,
|
pub pin: Option<PinId>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ pub struct Segment {
|
||||||
pub spec: SegmentSpec,
|
pub spec: SegmentSpec,
|
||||||
pub endpoints: [Vector2<i64>; 2],
|
pub endpoints: [Vector2<i64>; 2],
|
||||||
pub layer: LayerId,
|
pub layer: LayerId,
|
||||||
pub net: NetId,
|
pub net: Option<NetId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Segment {
|
impl Segment {
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ pub struct Via {
|
||||||
pub position: Vector2<i64>,
|
pub position: Vector2<i64>,
|
||||||
pub min_layer: LayerId,
|
pub min_layer: LayerId,
|
||||||
pub max_layer: LayerId,
|
pub max_layer: LayerId,
|
||||||
pub net: NetId,
|
pub net: Option<NetId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Via {
|
impl Via {
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,12 @@ impl Ratsnest {
|
||||||
BTreeMap::new();
|
BTreeMap::new();
|
||||||
|
|
||||||
for (i, joint) in board.layout().joints().container().iter() {
|
for (i, joint) in board.layout().joints().container().iter() {
|
||||||
|
let Some(net) = joint.spec.net else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
let _ = triangulations
|
let _ = triangulations
|
||||||
.entry((joint.spec.net, joint.spec.layer))
|
.entry((net, joint.spec.layer))
|
||||||
.or_insert_with(DelaunayTriangulation::new)
|
.or_insert_with(DelaunayTriangulation::new)
|
||||||
.insert(DelaunayVertex {
|
.insert(DelaunayVertex {
|
||||||
layer: joint.spec.layer,
|
layer: joint.spec.layer,
|
||||||
|
|
@ -63,9 +67,13 @@ impl Ratsnest {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, segment) in board.layout().segments().container().iter() {
|
for (i, segment) in board.layout().segments().container().iter() {
|
||||||
|
let Some(net) = segment.net else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
let segment_center = segment.center();
|
let segment_center = segment.center();
|
||||||
let _ = triangulations
|
let _ = triangulations
|
||||||
.entry((segment.net, segment.layer))
|
.entry((net, segment.layer))
|
||||||
.or_insert_with(DelaunayTriangulation::new)
|
.or_insert_with(DelaunayTriangulation::new)
|
||||||
.insert(DelaunayVertex {
|
.insert(DelaunayVertex {
|
||||||
layer: segment.layer,
|
layer: segment.layer,
|
||||||
|
|
@ -76,8 +84,12 @@ impl Ratsnest {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, polygon) in board.layout().polygons().container().iter() {
|
for (i, polygon) in board.layout().polygons().container().iter() {
|
||||||
|
let Some(net) = polygon.net else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
let _ = triangulations
|
let _ = triangulations
|
||||||
.entry((polygon.net, polygon.layer))
|
.entry((net, polygon.layer))
|
||||||
.or_insert_with(DelaunayTriangulation::new)
|
.or_insert_with(DelaunayTriangulation::new)
|
||||||
.insert(DelaunayVertex {
|
.insert(DelaunayVertex {
|
||||||
layer: polygon.layer,
|
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 {
|
macro_rules! impl_rect2_contains_circle {
|
||||||
($type:ty) => {
|
($type:ty) => {
|
||||||
impl Rect2<$type> {
|
impl Rect2<$type> {
|
||||||
|
|
@ -152,12 +178,15 @@ macro_rules! impl_rect2_intersects_polygon {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.contains_polygon(polygon) {
|
if polygon.iter().any(|&vertex| self.contains_point(vertex)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let corners = self.corners();
|
if self
|
||||||
if corners.iter().any(|corner| corner.inside_polygon(polygon)) {
|
.corners()
|
||||||
|
.iter()
|
||||||
|
.any(|corner| corner.inside_polygon(polygon))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,6 @@ impl Board {
|
||||||
.chain(dsn.pcb.network.nets.iter().map(|net| &net.name))
|
.chain(dsn.pcb.network.nets.iter().map(|net| &net.name))
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
// deduplicate net names
|
|
||||||
tmp.push("outlines".to_string());
|
|
||||||
tmp.sort_unstable();
|
tmp.sort_unstable();
|
||||||
tmp.dedup();
|
tmp.dedup();
|
||||||
|
|
||||||
|
|
@ -99,7 +97,6 @@ impl Board {
|
||||||
layer_descs,
|
layer_descs,
|
||||||
net_names,
|
net_names,
|
||||||
);
|
);
|
||||||
let outline_net = board.net_id("outlines").unwrap();
|
|
||||||
|
|
||||||
// Mapping of pin -> net prepared for adding pins.
|
// Mapping of pin -> net prepared for adding pins.
|
||||||
let pin_nets: BTreeMap<String, NetId> = dsn
|
let pin_nets: BTreeMap<String, NetId> = dsn
|
||||||
|
|
@ -152,7 +149,7 @@ impl Board {
|
||||||
&outline.path.coords,
|
&outline.path.coords,
|
||||||
outline.path.width,
|
outline.path.width,
|
||||||
outline_layer_id,
|
outline_layer_id,
|
||||||
outline_net,
|
None,
|
||||||
Some(component_id),
|
Some(component_id),
|
||||||
None,
|
None,
|
||||||
!place_side_is_front,
|
!place_side_is_front,
|
||||||
|
|
@ -180,7 +177,7 @@ impl Board {
|
||||||
pin.point_with_rotation(),
|
pin.point_with_rotation(),
|
||||||
circle.diameter / 2.0,
|
circle.diameter / 2.0,
|
||||||
layer,
|
layer,
|
||||||
net,
|
Some(net),
|
||||||
Some(component_id),
|
Some(component_id),
|
||||||
Some(pin_id),
|
Some(pin_id),
|
||||||
!place_side_is_front,
|
!place_side_is_front,
|
||||||
|
|
@ -198,7 +195,7 @@ impl Board {
|
||||||
rect.x2,
|
rect.x2,
|
||||||
rect.y2,
|
rect.y2,
|
||||||
layer,
|
layer,
|
||||||
net,
|
Some(net),
|
||||||
Some(component_id),
|
Some(component_id),
|
||||||
Some(pin_id),
|
Some(pin_id),
|
||||||
!place_side_is_front,
|
!place_side_is_front,
|
||||||
|
|
@ -214,7 +211,7 @@ impl Board {
|
||||||
&path.coords,
|
&path.coords,
|
||||||
path.width,
|
path.width,
|
||||||
layer,
|
layer,
|
||||||
net,
|
Some(net),
|
||||||
Some(component_id),
|
Some(component_id),
|
||||||
Some(pin_id),
|
Some(pin_id),
|
||||||
!place_side_is_front,
|
!place_side_is_front,
|
||||||
|
|
@ -230,7 +227,7 @@ impl Board {
|
||||||
&polygon.coords,
|
&polygon.coords,
|
||||||
polygon.width,
|
polygon.width,
|
||||||
layer,
|
layer,
|
||||||
net,
|
Some(net),
|
||||||
Some(component_id),
|
Some(component_id),
|
||||||
Some(pin_id),
|
Some(pin_id),
|
||||||
!place_side_is_front,
|
!place_side_is_front,
|
||||||
|
|
@ -261,7 +258,7 @@ impl Board {
|
||||||
PointWithRotation::default(),
|
PointWithRotation::default(),
|
||||||
circle.diameter / 2.0,
|
circle.diameter / 2.0,
|
||||||
layer,
|
layer,
|
||||||
net,
|
Some(net),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
|
|
@ -279,7 +276,7 @@ impl Board {
|
||||||
rect.x2,
|
rect.x2,
|
||||||
rect.y2,
|
rect.y2,
|
||||||
layer,
|
layer,
|
||||||
net,
|
Some(net),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
|
|
@ -295,7 +292,7 @@ impl Board {
|
||||||
&path.coords,
|
&path.coords,
|
||||||
path.width,
|
path.width,
|
||||||
layer,
|
layer,
|
||||||
net,
|
Some(net),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
|
|
@ -311,7 +308,7 @@ impl Board {
|
||||||
&polygon.coords,
|
&polygon.coords,
|
||||||
polygon.width,
|
polygon.width,
|
||||||
layer,
|
layer,
|
||||||
net,
|
Some(net),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
|
|
@ -333,7 +330,7 @@ impl Board {
|
||||||
&wire.path.coords,
|
&wire.path.coords,
|
||||||
wire.path.width,
|
wire.path.width,
|
||||||
layer,
|
layer,
|
||||||
net,
|
Some(net),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
|
|
@ -350,7 +347,7 @@ impl Board {
|
||||||
pin_pos: PointWithRotation,
|
pin_pos: PointWithRotation,
|
||||||
radius: f64,
|
radius: f64,
|
||||||
layer: LayerId,
|
layer: LayerId,
|
||||||
net: NetId,
|
net: Option<NetId>,
|
||||||
component: Option<ComponentId>,
|
component: Option<ComponentId>,
|
||||||
pin: Option<PinId>,
|
pin: Option<PinId>,
|
||||||
flip: bool,
|
flip: bool,
|
||||||
|
|
@ -375,7 +372,7 @@ impl Board {
|
||||||
x2: f64,
|
x2: f64,
|
||||||
y2: f64,
|
y2: f64,
|
||||||
layer: LayerId,
|
layer: LayerId,
|
||||||
net: NetId,
|
net: Option<NetId>,
|
||||||
component: Option<ComponentId>,
|
component: Option<ComponentId>,
|
||||||
pin: Option<PinId>,
|
pin: Option<PinId>,
|
||||||
flip: bool,
|
flip: bool,
|
||||||
|
|
@ -402,7 +399,7 @@ impl Board {
|
||||||
coords: &[Point],
|
coords: &[Point],
|
||||||
width: f64,
|
width: f64,
|
||||||
layer: LayerId,
|
layer: LayerId,
|
||||||
net: NetId,
|
net: Option<NetId>,
|
||||||
component: Option<ComponentId>,
|
component: Option<ComponentId>,
|
||||||
pin: Option<PinId>,
|
pin: Option<PinId>,
|
||||||
flip: bool,
|
flip: bool,
|
||||||
|
|
@ -465,7 +462,7 @@ impl Board {
|
||||||
coords: &[Point],
|
coords: &[Point],
|
||||||
_width: f64,
|
_width: f64,
|
||||||
layer: LayerId,
|
layer: LayerId,
|
||||||
net: NetId,
|
net: Option<NetId>,
|
||||||
component: Option<ComponentId>,
|
component: Option<ComponentId>,
|
||||||
pin: Option<PinId>,
|
pin: Option<PinId>,
|
||||||
flip: bool,
|
flip: bool,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue