forked from 1b-agent/opencadstudio-upstream
Layouts: first opening follows the page setup; viewports picked by their frame
- A layout opens for the first time when its page setup was never initialized (no paper size, no media name) or it was created in this session; its page setup is initialized then, and with LAYOUTCREATEVIEWPORT it gets its first viewport. A layout never opened is saved with an uninitialized page setup and no viewports, so it gets its viewport when the file is opened again, here or in the reference. - Select Viewport for view: a viewport is selected when the pick box (PICKBOX pixels at the sheet's zoom) touches its frame; a pick well inside or outside selects nothing and the prompt repeats. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
006be8909e
commit
c55dbb886e
7 files changed
+88
-6
No files matched your search
@@ -71,6 +71,9 @@ pub struct ViewNames {
|
||||
/// (handle, [min x, min y, max x, max y]), one of which takes a
|
||||
/// model-space view being restored.
|
||||
pub sheet_viewports: Option<Vec<(u64, [f64; 4])>>,
|
||||
/// The pick box (PICKBOX pixels) in sheet units: a viewport is selected
|
||||
/// by its frame, within this distance of it.
|
||||
pub sheet_pick_tolerance: f64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
@@ -513,9 +516,14 @@ impl CadCommand for DashViewCommand {
|
||||
name, first.x, first.y, pt.x, pt.y
|
||||
)),
|
||||
Step::RestoreViewport(name) => {
|
||||
// The topmost viewport under the pick.
|
||||
// The topmost viewport whose frame the pick box touches; a
|
||||
// pick well inside a viewport selects nothing, as in the
|
||||
// reference.
|
||||
let tol = self.names.sheet_pick_tolerance.max(0.0);
|
||||
let hit = self.names.sheet_viewports.iter().flatten().rev().find(|(_, [x0, y0, x1, y1])| {
|
||||
pt.x >= *x0 && pt.x <= *x1 && pt.y >= *y0 && pt.y <= *y1
|
||||
let outside = pt.x < x0 - tol || pt.x > x1 + tol || pt.y < y0 - tol || pt.y > y1 + tol;
|
||||
let inside = pt.x > x0 + tol && pt.x < x1 - tol && pt.y > y0 + tol && pt.y < y1 - tol;
|
||||
!outside && !inside
|
||||
});
|
||||
match hit {
|
||||
Some((handle, _)) => CmdResult::Dispatch(format!("-VIEW >RESTOREVP {name}\u{1f}{handle:X}")),
|
||||
|
||||
Reference in new issue
Block a user