Merge pull request #1336 from ramox81/codex/constraintbar-command

# Conflicts:
#	src/modules/parametric/mod.rs
This commit is contained in:
Hakan Seven committed 2026-09-17 17:58:34 +03:00
commit c8e34e47ef
4 files changed
+121

No files matched your search

+66
View File
@@ -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"]
});
+2
View File
@@ -4,6 +4,7 @@
mod coincident;
mod concentric;
mod constraint_bar;
mod equal_distance;
mod geom_constraint;
#[path = "horizontal.rs"]
@@ -18,6 +19,7 @@ mod tools;
mod value;
pub use coincident::{coincident_tool, CoincidentConstraintCommand};
pub use concentric::ConcentricConstraintCommand;
pub use constraint_bar::ConstraintBarOptionCommand;
pub use equal_distance::{equal_distance_tool, EqualDistanceConstraintCommand};
pub use geom_constraint::GeomConstraintCommand;
pub use horizontal_command::HorizontalConstraintCommand;