forked from 1b-agent/opencadstudio-upstream
feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire previously-unreachable ribbon/menu buttons, and correct name/behaviour mismatches. Every UI command token now resolves (real handler where the infrastructure exists, an honest "not yet implemented" status otherwise). New commands: - Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER (DCE/CENTERMARK) - Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST - Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner), FINDNONPURGEABLE Behaviour fixes: - LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64 (correct at large coordinates) - ATTEDIT/ATE unified so the alias and the ribbon button open the interactive editor; -ATTEDIT is the command-line form - Linear/aligned/radius/diameter dimensions gain a text override (Text) and text angle (Angle) option - INSERT gains Scale/Rotate options; COPY gains an Array option - LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides - UNDO accepts a step count Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE, EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/ DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling (CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points (CUI/ALIASEDIT). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
e04b580a70
commit
0ca3954b5d
32 files changed
+2763
-67
No files matched your search
@@ -28,12 +28,24 @@ enum Step {
|
||||
|
||||
pub struct DiameterDimensionCommand {
|
||||
step: Step,
|
||||
/// Optional text that replaces the measured value (None = measurement).
|
||||
text_override: Option<String>,
|
||||
/// True while the next typed line is captured as the text override.
|
||||
awaiting_text: bool,
|
||||
/// Explicit text rotation in radians (None = follow the UCS/style).
|
||||
text_angle: Option<f64>,
|
||||
/// True while the next typed value is captured as the text angle.
|
||||
awaiting_angle: bool,
|
||||
}
|
||||
|
||||
impl DiameterDimensionCommand {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
step: Step::CenterPoint,
|
||||
text_override: None,
|
||||
awaiting_text: false,
|
||||
text_angle: None,
|
||||
awaiting_angle: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,10 +56,18 @@ impl CadCommand for DiameterDimensionCommand {
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
if self.awaiting_text {
|
||||
return "DIMDIAMETER Enter dimension text (blank = measured value):".into();
|
||||
}
|
||||
if self.awaiting_angle {
|
||||
return "DIMDIAMETER Specify text angle (degrees):".into();
|
||||
}
|
||||
match self.step {
|
||||
Step::CenterPoint => "DIMDIAMETER Specify center point:".into(),
|
||||
Step::ArcPoint(_) => "DIMDIAMETER Specify point on circle:".into(),
|
||||
Step::TextPoint { .. } => "DIMDIAMETER Specify dimension line location:".into(),
|
||||
Step::TextPoint { .. } => {
|
||||
"DIMDIAMETER Specify dimension line location [Text/Angle]:".into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,15 +88,79 @@ impl CadCommand for DiameterDimensionCommand {
|
||||
dim.base.insertion_point = v3(pt);
|
||||
dim.leader_length = arc_pt.distance(pt) as f64;
|
||||
dim.base.actual_measurement = dim.measurement();
|
||||
dim.base.user_text = self.text_override.clone();
|
||||
// An explicit text angle overrides the default rotation.
|
||||
if let Some(a) = self.text_angle {
|
||||
dim.base.text_rotation = a;
|
||||
}
|
||||
CmdResult::CommitAndExit(EntityType::Dimension(Dimension::Diameter(dim)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
// A bare Enter while entering override text accepts the measured value.
|
||||
if self.awaiting_text {
|
||||
self.awaiting_text = false;
|
||||
return CmdResult::NeedPoint;
|
||||
}
|
||||
if self.awaiting_angle {
|
||||
self.awaiting_angle = false;
|
||||
return CmdResult::NeedPoint;
|
||||
}
|
||||
CmdResult::Cancel
|
||||
}
|
||||
|
||||
fn wants_text_input(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn point_step_accepts_keywords(&self) -> bool {
|
||||
// While entering the override text or angle it is a value, not a point step.
|
||||
!self.awaiting_text && !self.awaiting_angle
|
||||
}
|
||||
|
||||
fn wants_text_with_spaces(&self) -> bool {
|
||||
// The override text may contain spaces.
|
||||
self.awaiting_text
|
||||
}
|
||||
|
||||
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
|
||||
if self.awaiting_text {
|
||||
let t = text.trim();
|
||||
// Blank (or the "<>" placeholder) keeps the measured value.
|
||||
self.text_override = if t.is_empty() || t == "<>" {
|
||||
None
|
||||
} else {
|
||||
Some(t.to_string())
|
||||
};
|
||||
self.awaiting_text = false;
|
||||
return Some(CmdResult::NeedPoint);
|
||||
}
|
||||
if self.awaiting_angle {
|
||||
let t = text.trim();
|
||||
// Blank clears any explicit angle (follow the default again).
|
||||
self.text_angle = if t.is_empty() {
|
||||
None
|
||||
} else {
|
||||
t.parse::<f64>().ok().map(f64::to_radians)
|
||||
};
|
||||
self.awaiting_angle = false;
|
||||
return Some(CmdResult::NeedPoint);
|
||||
}
|
||||
match text.trim().to_uppercase().as_str() {
|
||||
"T" | "TEXT" | "M" | "MTEXT" => {
|
||||
self.awaiting_text = true;
|
||||
Some(CmdResult::NeedPoint)
|
||||
}
|
||||
"A" | "ANGLE" => {
|
||||
self.awaiting_angle = true;
|
||||
Some(CmdResult::NeedPoint)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
|
||||
match self.step {
|
||||
Step::CenterPoint => None,
|
||||
|
||||
Reference in new issue
Block a user