forked from 1b-agent/opencadstudio-upstream
feat(layout): MVSETUP sets a drawing up for plotting
In model space MVSETUP draws the sheet border at the drawing scale (scale factor, paper width and height) and zooms to it, or switches to a layout. On a layout it creates viewports in a bounding area (a single one, a 2x2 engineering set of top/front/right/isometric views, or an array with spacing), deletes picked objects, and scales picked viewports to a paper/model unit ratio. A viewport's fit to the model now measures the model along the viewport's own view direction, so side and isometric views frame it too. Refs #1501 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b1d4c9bd9b
commit
57eb7fe4db
31 files changed
+929
-10
No files matched your search
@@ -882,6 +882,13 @@ impl OpenCADStudio {
|
||||
CmdResult::ZoomToWindow { p1, p2 } => {
|
||||
self.handle_zoom_to_window(p1, p2);
|
||||
}
|
||||
CmdResult::CommitAndZoom { entity, p1, p2 } => {
|
||||
self.handle_commit_entities_and_exit(vec![entity], false, false);
|
||||
self.handle_zoom_to_window(p1, p2);
|
||||
}
|
||||
CmdResult::ScaleViewports { handles, factor } => {
|
||||
self.handle_scale_viewports(handles, factor);
|
||||
}
|
||||
CmdResult::TwistView(twist) => {
|
||||
self.handle_twist_view(twist);
|
||||
}
|
||||
|
||||
@@ -447,6 +447,33 @@ impl OpenCADStudio {
|
||||
.push_output(crate::t!("Zoom Window").as_ref());
|
||||
}
|
||||
|
||||
/// MVSETUP Scale viewports: each picked layout viewport shows the model
|
||||
/// at `factor` paper units per model unit. One undo step.
|
||||
pub(in crate::app) fn handle_scale_viewports(&mut self, handles: Vec<Handle>, factor: f64) {
|
||||
let i = self.active_tab;
|
||||
self.tabs[i].active_cmd = None;
|
||||
self.tabs[i].snap_result = None;
|
||||
let handles: Vec<Handle> = handles
|
||||
.into_iter()
|
||||
.filter(|handle| {
|
||||
matches!(
|
||||
self.tabs[i].scene.document.get_entity(*handle),
|
||||
Some(codec::EntityType::Viewport(viewport)) if viewport.id > 1
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
if handles.is_empty() {
|
||||
return;
|
||||
}
|
||||
self.push_undo_snapshot(i, "MVSETUP");
|
||||
for handle in handles {
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.set_viewport_scale_factor_for(handle, factor);
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
}
|
||||
|
||||
/// Turn the active view about its line of sight so the drawing shows
|
||||
/// `twist` radians counter-clockwise from its untwisted orientation.
|
||||
pub(in crate::app) fn handle_twist_view(&mut self, twist: f64) {
|
||||
|
||||
Reference in new issue
Block a user