forked from 1b-agent/opencadstudio-upstream
Merge pull request #1667 from ramox81/codex/view-presets
-VIEW command-line form: presets with orthographic UCS, sEttings and Window # Conflicts: # src/app/commands/mod.rs # src/io/mod.rs
This commit is contained in:
commit
e5df2fd113
13 files changed
+1101
-42
No files matched your search
@@ -787,6 +787,22 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
|
||||
// -VIEW: the command-line form of VIEW (modules/view/view_cmd.rs).
|
||||
// The command gathers the input; `-VIEW >…` carries out what it
|
||||
// gathered. A whole line (`-VIEW _O _FRONT`) feeds its words to
|
||||
// the command one by one, as typed.
|
||||
"-VIEW" => {
|
||||
use crate::command::CadCommand;
|
||||
let c = crate::modules::view::view_cmd::DashViewCommand::new(self.dash_view_names(i));
|
||||
self.command_line.push_info(&c.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("-VIEW >") => {
|
||||
return Some(self.run_dash_view(&cmd["-VIEW >".len()..], i));
|
||||
}
|
||||
cmd if cmd.starts_with("-VIEW ") => {
|
||||
return Some(self.run_command_line(cmd));
|
||||
}
|
||||
"VIEW" => {
|
||||
use crate::command::KeywordCommand;
|
||||
let c = KeywordCommand::new(
|
||||
@@ -910,45 +926,14 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Standard orientation presets — snap the camera to a world
|
||||
// axis view (these names take precedence over a same-named
|
||||
// saved view, matching the standard orientation behaviour).
|
||||
"TOP" | "FRONT" | "BACK" | "LEFT" | "RIGHT" | "BOTTOM" => {
|
||||
use crate::scene::pipeline::viewcube::{
|
||||
FACE_BACK, FACE_BOTTOM, FACE_FRONT, FACE_LEFT, FACE_RIGHT, FACE_TOP,
|
||||
};
|
||||
let face = match sub.as_str() {
|
||||
"TOP" => FACE_TOP,
|
||||
"BOTTOM" => FACE_BOTTOM,
|
||||
"FRONT" => FACE_FRONT,
|
||||
"BACK" => FACE_BACK,
|
||||
"RIGHT" => FACE_RIGHT,
|
||||
_ => FACE_LEFT,
|
||||
};
|
||||
return Some(Task::done(Message::ViewCubeSnapWorld(
|
||||
crate::scene::CubeRegion::Face(face),
|
||||
)));
|
||||
// Standard orientation presets: the world views -VIEW sets,
|
||||
// with the orthographic UCS while UCSORTHO is on. These
|
||||
// names take precedence over a same-named saved view.
|
||||
"TOP" | "FRONT" | "BACK" | "LEFT" | "RIGHT" | "BOTTOM" | "SWISO" | "SEISO" | "NEISO" | "NWISO" => {
|
||||
return Some(self.apply_view_preset(&sub));
|
||||
}
|
||||
// Isometric presets snap to the matching ViewCube corner;
|
||||
// ISO alone is the south-west one.
|
||||
"ISO" | "ISOMETRIC" | "SWISO" | "SEISO" | "NEISO" | "NWISO" => {
|
||||
let (x, y) = match sub.as_str() {
|
||||
"SEISO" => (1.0, -1.0),
|
||||
"NEISO" => (1.0, 1.0),
|
||||
"NWISO" => (-1.0, 1.0),
|
||||
_ => (-1.0, -1.0),
|
||||
};
|
||||
let want = glam::Vec3::new(x, y, 1.0).normalize();
|
||||
let corner = (18..26)
|
||||
.map(crate::scene::CubeRegion::Corner)
|
||||
.max_by(|a, b| {
|
||||
a.snap_direction()
|
||||
.dot(want)
|
||||
.total_cmp(&b.snap_direction().dot(want))
|
||||
})
|
||||
.expect("the cube has corners");
|
||||
return Some(Task::done(Message::ViewCubeSnap(corner)));
|
||||
}
|
||||
"ISO" | "ISOMETRIC" => return Some(self.apply_view_preset("SWISO")),
|
||||
// VIEW <name> shortcut for restore
|
||||
_ => {
|
||||
let name = sub.clone();
|
||||
|
||||
Reference in new issue
Block a user