forked from 1b-agent/opencadstudio-upstream
Add constraint bar visibility command
This commit is contained in:
1 parent
bb29b987c2
commit
fc4eeb3296
4 files changed
+121
No files matched your search
@@ -68,6 +68,21 @@ impl SelectObjectsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
/// Standard selection behavior routed to a private apply command while
|
||||
/// retaining the public command name in the visible prompt.
|
||||
pub fn routed(prompt_cmd: &str, pending_cmd: &str) -> Self {
|
||||
Self {
|
||||
prompt_cmd: prompt_cmd.to_string(),
|
||||
pending_cmd: pending_cmd.to_string(),
|
||||
handles: Vec::new(),
|
||||
commit_on_enter: true,
|
||||
show_options: true,
|
||||
pick: None,
|
||||
pick_crossing: true,
|
||||
auto_constrain_settings: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Single-object variant: the first completed selection action applies
|
||||
/// immediately, with no Enter (used by commands that act on one object).
|
||||
pub fn instant(pending_cmd: &str) -> Self {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
use acadrust::Handle;
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdOption, CmdResult};
|
||||
|
||||
pub struct ConstraintBarOptionCommand {
|
||||
handles: Vec<Handle>,
|
||||
}
|
||||
|
||||
impl ConstraintBarOptionCommand {
|
||||
pub fn new(handles: Vec<Handle>) -> Self {
|
||||
Self { handles }
|
||||
}
|
||||
|
||||
fn finish(&mut self, command: &str) -> CmdResult {
|
||||
CmdResult::Relaunch(command.to_string(), std::mem::take(&mut self.handles))
|
||||
}
|
||||
}
|
||||
|
||||
impl CadCommand for ConstraintBarOptionCommand {
|
||||
fn name(&self) -> &'static str {
|
||||
"CONSTRAINTBAR"
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
"CONSTRAINTBAR Enter an option [Show/Hide/Reset] <Show>:".to_string()
|
||||
}
|
||||
|
||||
fn options(&self) -> Vec<CmdOption> {
|
||||
vec![
|
||||
CmdOption::new("Show", "S"),
|
||||
CmdOption::new("Hide", "H"),
|
||||
CmdOption::new("Reset", "R"),
|
||||
]
|
||||
}
|
||||
|
||||
fn wants_text_input(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
|
||||
let keyword = text.trim().trim_start_matches('_').to_ascii_uppercase();
|
||||
match keyword.as_str() {
|
||||
"S" | "SHOW" => Some(self.finish("GCSHOW")),
|
||||
"H" | "HIDE" => Some(self.finish("GCHIDE")),
|
||||
"R" | "RESET" => Some(self.finish("CONSTRAINTBAR_RESET")),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn on_point(&mut self, _point: DVec3) -> CmdResult {
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
self.finish("GCSHOW")
|
||||
}
|
||||
|
||||
fn on_escape(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
}
|
||||
|
||||
inventory::submit!(crate::command::CommandRegistration {
|
||||
names: &["CONSTRAINTBAR"]
|
||||
});
|
||||
@@ -3,6 +3,7 @@
|
||||
//! resulting constraints through the geometry kernel.
|
||||
|
||||
mod coincident;
|
||||
mod constraint_bar;
|
||||
mod equal_distance;
|
||||
mod geom_constraint;
|
||||
#[path = "perpendicular.rs"]
|
||||
@@ -13,6 +14,7 @@ mod tangent_command;
|
||||
mod tools;
|
||||
mod value;
|
||||
pub use coincident::{coincident_tool, CoincidentConstraintCommand};
|
||||
pub use constraint_bar::ConstraintBarOptionCommand;
|
||||
pub use equal_distance::{equal_distance_tool, EqualDistanceConstraintCommand};
|
||||
pub use geom_constraint::GeomConstraintCommand;
|
||||
pub use perpendicular_command::{PerpendicularConstraintCommand, PerpendicularPick};
|
||||
|
||||
Reference in new issue
Block a user