forked from 1b-agent/opencadstudio-upstream
feat(view): DVIEW twists the view about its line of sight
DVIEW (alias DV) offers TWist and Undo. TWist rolls the active view or viewport camera to the typed angle; Undo steps back through the twists made in the session. The new alias reaches existing profiles through the alias migration table. Refs #638 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6490a625f2
commit
4ffae00199
31 files changed
+203
-1
No files matched your search
+2
-1
@@ -80,7 +80,7 @@ const WEB_ALIAS_KEY: &str = "opencadstudio.aliases";
|
||||
/// migrated forward (see `introduced_at` / `migrate_aliases`). Version 1 shipped
|
||||
/// the pre-REDRAW table; version 2 introduced the REDRAW-family aliases; version 3
|
||||
/// introduced HB (HATCHTOBACK); version 4 introduced ER (EXTERNALREFERENCES).
|
||||
const DEFAULT_ALIASES_VERSION: u32 = 6;
|
||||
const DEFAULT_ALIASES_VERSION: u32 = 7;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
const WEB_ALIAS_VERSION_KEY: &str = "opencadstudio.aliases.version";
|
||||
@@ -101,6 +101,7 @@ fn introduced_at(version: u32) -> &'static [(&'static str, &'static str)] {
|
||||
4 => &[("ER", "EXTERNALREFERENCES")],
|
||||
5 => &[("-ATT", "-ATTDEF")],
|
||||
6 => &[("VV", "QLAYER")],
|
||||
7 => &[("DV", "DVIEW")],
|
||||
_ => &[],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -882,6 +882,9 @@ impl OpenCADStudio {
|
||||
CmdResult::ZoomToWindow { p1, p2 } => {
|
||||
self.handle_zoom_to_window(p1, p2);
|
||||
}
|
||||
CmdResult::TwistView(twist) => {
|
||||
self.handle_twist_view(twist);
|
||||
}
|
||||
CmdResult::Measurement(msg) => {
|
||||
self.handle_measurement(msg);
|
||||
}
|
||||
|
||||
@@ -447,6 +447,26 @@ impl OpenCADStudio {
|
||||
.push_output(crate::t!("Zoom Window").as_ref());
|
||||
}
|
||||
|
||||
/// 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) {
|
||||
let i = self.active_tab;
|
||||
self.tabs[i].scene.remember_current_view();
|
||||
let set = |camera: &mut crate::scene::view::camera::Camera| {
|
||||
// The drawing turns one way when the camera rolls the other.
|
||||
camera.roll_by(-twist as f32 - camera.roll());
|
||||
};
|
||||
if self.tabs[i].scene.active_viewport.is_some() {
|
||||
self.tabs[i].scene.mutate_active_viewport_camera(set);
|
||||
} else {
|
||||
set(&mut self.tabs[i].scene.camera.borrow_mut());
|
||||
}
|
||||
self.tabs[i].scene.camera_generation += 1;
|
||||
if let Some(prompt) = self.tabs[i].active_cmd.as_ref().map(|c| c.prompt()) {
|
||||
self.command_line.push_info(&prompt);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn handle_set_plot_window(&mut self, p1: glam::DVec3, p2: glam::DVec3) {
|
||||
let i = self.active_tab;
|
||||
let layout_name = self.tabs[i].scene.current_layout.clone();
|
||||
|
||||
@@ -935,6 +935,21 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(cmd));
|
||||
}
|
||||
|
||||
"DVIEW" => {
|
||||
use crate::modules::view::dview::DviewCommand;
|
||||
let twist = {
|
||||
let scene = &self.tabs[i].scene;
|
||||
let roll = match scene.active_viewport {
|
||||
Some(_) => scene.navigation_camera().roll(),
|
||||
None => scene.camera.borrow().roll(),
|
||||
};
|
||||
-(roll as f64)
|
||||
};
|
||||
let cmd = DviewCommand::new(twist.rem_euclid(std::f64::consts::TAU));
|
||||
self.command_line.push_info(&cmd.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(cmd));
|
||||
}
|
||||
|
||||
"ZOOM" | "ZOOM WINDOW" | "ZOOM W" | "ZW" => {
|
||||
use crate::modules::view::zoom_window::ZoomWindowCommand;
|
||||
let new_cmd = ZoomWindowCommand::new();
|
||||
|
||||
Reference in new issue
Block a user