forked from 1b-agent/opencadstudio-upstream
Complete angular dimension interaction and associations
This commit is contained in:
1 parent
a8f05716cf
commit
24b344b2b2
7 files changed
+777
-75
No files matched your search
@@ -581,6 +581,36 @@ impl OpenCADStudio {
|
||||
let _ = self.apply_cmd_result(r);
|
||||
return;
|
||||
}
|
||||
let accepts_points = self.tabs[i]
|
||||
.active_cmd
|
||||
.as_ref()
|
||||
.is_some_and(|command| command.entity_pick_accepts_points());
|
||||
if accepts_points {
|
||||
if let Some((coord, kind)) = super::helpers::parse_coord(token) {
|
||||
let ucs = self.tabs[i].active_ucs.clone();
|
||||
let wcs = match (
|
||||
matches!(kind, super::helpers::CoordKind::Relative),
|
||||
self.last_point,
|
||||
) {
|
||||
(true, Some(base)) => {
|
||||
base + match &ucs {
|
||||
Some(value) => super::helpers::ucs_rotate_vec(coord, value),
|
||||
None => coord,
|
||||
}
|
||||
}
|
||||
_ => match &ucs {
|
||||
Some(value) => super::helpers::ucs_to_wcs(coord, value),
|
||||
None => coord,
|
||||
},
|
||||
};
|
||||
if self.command_point_allowed(i, wcs) {
|
||||
self.last_point = Some(wcs);
|
||||
self.push_ucs_to_cmd(i);
|
||||
let _ = self.feed_command(StepInput::Point(wcs));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if let Ok(v) = u64::from_str_radix(token.trim_start_matches("0x"), 16) {
|
||||
let handle = Handle::new(v);
|
||||
let pt = self.tabs[i]
|
||||
@@ -1257,6 +1287,30 @@ impl OpenCADStudio {
|
||||
self.commit_undo_delta(i, pending);
|
||||
}
|
||||
}
|
||||
CmdResult::CommitAssociativeDimensionDetailed { entity, sources } => {
|
||||
let label = self.history_label_from_active_cmd(i, "DIMENSION");
|
||||
let pending = self.begin_undo(i, label, 1, false);
|
||||
if let Some(handle) = self.commit_entity_handle(entity) {
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.attach_dimension_association_sources(handle, sources.clone());
|
||||
let mut changed = vec![(handle, crate::scene::ChangeKind::Modified)];
|
||||
changed.extend(sources.iter().flatten().map(|source| {
|
||||
(source.handle, crate::scene::ChangeKind::Modified)
|
||||
}));
|
||||
changed.sort_by_key(|(handle, _)| handle.value());
|
||||
changed.dedup_by_key(|(handle, _)| handle.value());
|
||||
self.tabs[i].scene.bump_entities(&changed);
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
self.tabs[i].scene.clear_preview_wire();
|
||||
self.tabs[i].active_cmd = None;
|
||||
self.tabs[i].snap_result = None;
|
||||
self.restore_pre_cmd_tangent();
|
||||
if let Some(pending) = pending {
|
||||
self.commit_undo_delta(i, pending);
|
||||
}
|
||||
}
|
||||
CmdResult::CommitSolid {
|
||||
entity,
|
||||
solid,
|
||||
@@ -3572,6 +3626,19 @@ impl OpenCADStudio {
|
||||
self.tabs[i].snap_result = None;
|
||||
self.open_mtext_editor(pos, handle, &initial, height);
|
||||
}
|
||||
CmdResult::SuspendForMTextInput {
|
||||
pos,
|
||||
initial,
|
||||
height,
|
||||
} => {
|
||||
self.tabs[i].suspended_cmd = self.tabs[i].active_cmd.take();
|
||||
self.tabs[i].snap_result = None;
|
||||
self.tabs[i].scene.clear_preview_wire();
|
||||
self.restore_pre_cmd_tangent();
|
||||
self.command_mtext_input = true;
|
||||
self.pending_command_editor_text = None;
|
||||
self.open_mtext_editor(pos, None, &initial, height);
|
||||
}
|
||||
CmdResult::OpenTextEditor {
|
||||
pos,
|
||||
handle,
|
||||
|
||||
@@ -764,6 +764,10 @@ pub(super) struct OpenCADStudio {
|
||||
ctrl_down: bool,
|
||||
/// Open in-place MText editor (toolbar + text area + live preview), if any.
|
||||
mtext_editor: Option<mtext_editor::MTextEditorState>,
|
||||
/// The current rich-text editor belongs to a suspended drawing command and
|
||||
/// must return text instead of creating a standalone MText entity.
|
||||
command_mtext_input: bool,
|
||||
pending_command_editor_text: Option<String>,
|
||||
/// Open in-place single-line TEXT editor (plain text-entry box), if any.
|
||||
text_inline: Option<text_inline::TextInlineState>,
|
||||
/// Cursor-anchored one-shot snap override menu (Shift+RMB): the canvas
|
||||
@@ -3252,6 +3256,8 @@ impl OpenCADStudio {
|
||||
ctrl_down: false,
|
||||
cont_anchor: None,
|
||||
mtext_editor: None,
|
||||
command_mtext_input: false,
|
||||
pending_command_editor_text: None,
|
||||
text_inline: None,
|
||||
snap_override_popup: None,
|
||||
axis_lock_dir: None,
|
||||
|
||||
@@ -1209,6 +1209,12 @@ impl super::OpenCADStudio {
|
||||
pub(super) fn mtext_commit(&mut self) -> bool {
|
||||
let i = self.active_tab;
|
||||
let Some(ed) = self.mtext_editor.take() else { return false };
|
||||
if self.command_mtext_input {
|
||||
self.pending_command_editor_text = Some(ed.build_mtext().value);
|
||||
self.command_mtext_input = false;
|
||||
self.refresh_properties();
|
||||
return true;
|
||||
}
|
||||
let body_empty = ed.content.text().trim().is_empty();
|
||||
let mut mt = ed.build_mtext();
|
||||
let annotative = ed.editing.is_none()
|
||||
@@ -1302,6 +1308,10 @@ impl super::OpenCADStudio {
|
||||
/// then updated in place on later applies, so repeated Apply never leaves
|
||||
/// duplicate entities behind.
|
||||
pub(super) fn mtext_apply(&mut self) {
|
||||
if self.command_mtext_input {
|
||||
self.rebuild_mtext_preview();
|
||||
return;
|
||||
}
|
||||
let i = self.active_tab;
|
||||
let (mut mt, editing, body_empty) = match self.mtext_editor.as_ref() {
|
||||
Some(ed) => (
|
||||
@@ -1398,6 +1408,8 @@ impl super::OpenCADStudio {
|
||||
/// Discard the editor without changing the drawing.
|
||||
pub(super) fn mtext_cancel(&mut self) {
|
||||
self.mtext_editor = None;
|
||||
self.command_mtext_input = false;
|
||||
self.pending_command_editor_text = None;
|
||||
self.reset_modal_geometry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,6 +492,13 @@ impl OpenCADStudio {
|
||||
self.reset_modal_geometry();
|
||||
let i = self.active_tab;
|
||||
if let Some(mut cmd) = self.tabs[i].suspended_cmd.take() {
|
||||
if committed {
|
||||
if let Some(value) = self.pending_command_editor_text.take() {
|
||||
cmd.on_editor_text(value);
|
||||
}
|
||||
} else {
|
||||
self.pending_command_editor_text = None;
|
||||
}
|
||||
let res = cmd.on_editor_closed(committed);
|
||||
self.tabs[i].active_cmd = Some(cmd);
|
||||
self.apply_cmd_result(res)
|
||||
|
||||
Reference in new issue
Block a user