forked from 1b-agent/opencadstudio-upstream
PDF import keeps drawing order when joining strokes; automation: layer toggle and page selection
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
f63e351a12
commit
28853cd32e
2 files changed
+23
-3
No files matched your search
@@ -48,6 +48,8 @@ fn color_value(color: acadrust::types::Color) -> Value {
|
||||
pub(super) const NAMES: &[&str] = &[
|
||||
"close_modal",
|
||||
"pdf_dialog_ok",
|
||||
"pdf_layer_toggle",
|
||||
"pdf_page_select",
|
||||
"close_document",
|
||||
"toggle_properties",
|
||||
"toggle_layers",
|
||||
@@ -665,6 +667,22 @@ impl OpenCADStudio {
|
||||
let msg = match name {
|
||||
"close_modal" => Message::CloseModal,
|
||||
// The open PDF dialog's OK button.
|
||||
// Underlay Layers: switch a layer of the shown underlay.
|
||||
"pdf_layer_toggle" => Message::PdfDialog(
|
||||
crate::ui::window::pdf_dialogs::PdfDialogMsg::LayersToggle(string(req, "value")?.into()),
|
||||
),
|
||||
// Attach dialog: choose pages by index ("0,2").
|
||||
"pdf_page_select" => {
|
||||
let pages: Vec<usize> = string(req, "value")?
|
||||
.split(',')
|
||||
.filter_map(|p| p.trim().parse().ok())
|
||||
.collect();
|
||||
let Some(state) = self.pdf_attach.as_mut() else {
|
||||
return Err(failure("no_dialog", "The Attach dialog is not open"));
|
||||
};
|
||||
state.selected = pages;
|
||||
return Ok(Task::none());
|
||||
}
|
||||
"pdf_dialog_ok" => {
|
||||
use crate::ui::window::pdf_dialogs::PdfDialogMsg;
|
||||
Message::PdfDialog(match self.active_modal {
|
||||
|
||||
@@ -584,7 +584,9 @@ fn join_strokes(strokes: Vec<Stroke>) -> Vec<Stroke> {
|
||||
open.push(s);
|
||||
}
|
||||
}
|
||||
while let Some(mut chain) = open.pop() {
|
||||
// Drawing order is kept: dashes read as a run only in the order drawn.
|
||||
while !open.is_empty() {
|
||||
let mut chain = open.remove(0);
|
||||
loop {
|
||||
let end = *chain.points.last().expect("strokes have points");
|
||||
let start = chain.points[0];
|
||||
@@ -594,7 +596,7 @@ fn join_strokes(strokes: Vec<Stroke>) -> Vec<Stroke> {
|
||||
if let Some(i) = open.iter().position(|o| {
|
||||
fits(o) && (same_point(o.points[0], end) || same_point(*o.points.last().unwrap(), end))
|
||||
}) {
|
||||
let mut next = open.swap_remove(i);
|
||||
let mut next = open.remove(i);
|
||||
if !same_point(next.points[0], end) {
|
||||
next.points.reverse();
|
||||
}
|
||||
@@ -603,7 +605,7 @@ fn join_strokes(strokes: Vec<Stroke>) -> Vec<Stroke> {
|
||||
fits(o)
|
||||
&& (same_point(*o.points.last().unwrap(), start) || same_point(o.points[0], start))
|
||||
}) {
|
||||
let mut prev = open.swap_remove(i);
|
||||
let mut prev = open.remove(i);
|
||||
if !same_point(*prev.points.last().unwrap(), start) {
|
||||
prev.points.reverse();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user