2026-03-22 14:56:27 +03:00
|
|
|
use acadrust::entities::{Dimension, DimensionAngular3Pt};
|
|
|
|
|
use acadrust::types::Vector3;
|
|
|
|
|
use acadrust::EntityType;
|
|
|
|
|
|
|
|
|
|
use crate::command::{CadCommand, CmdResult};
|
|
|
|
|
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
2026-06-16 11:33:46 +03:00
|
|
|
use crate::scene::model::wire_model::WireModel;
|
feat(f64): command layer compiles on DVec3
Whole command/snap/grip/cursor chain now builds on f64 DVec3 end to end,
so picked points, snaps and grip drags stay precise at UTM-scale
coordinates instead of quantizing to ~0.5 m through f32.
- All ~80 command files migrated: draw (line/circle/arc/ellipse/shapes
in full f64; others via point methods), modify, annotate, insert, view,
inquiry, layers, groups, clipboard, layout.
- Entity apply_grip impls updated for GripApply::{Absolute,Translate}(DVec3).
- Construction sites (EntityTransform/CmdResult/DynAnchor) emit DVec3;
wire-preview boundaries cast to f32 only at the GPU edge.
- Modify/annotate commands keep internal Vec3 geometry where precision is
non-critical, casting at the DVec3 boundary; key draw commands store f64.
Builds clean (no warnings). Visual verification of crosshair/snap/grip at
extreme UTM zoom pending.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 03:51:50 +03:00
|
|
|
use glam::{DVec3, Vec3};
|
2026-03-22 14:56:27 +03:00
|
|
|
|
feat: redesign Annotate ribbon tab with proper groups and SVG icons
Added 15 SVG icons for all annotation tools (dimensions, leaders,
table, wipeout, revision cloud, tolerance, ddedit).
Annotate ribbon now has 6 groups matching standard CAD layout:
- Text: MText (large dropdown) + Text + Edit Text
- Dimensions: Linear (large dropdown with 6 types) + Continue + Baseline + Tolerance
- Leaders: Multileader (large dropdown) + Leader
- Tables: Table (large)
- Markup: Wipeout + Rev Cloud
- Annotation Scaling: Scale List, Add Scale, Scale Edit, Sync Scales
Added pub tool() + ICON to all annotate tools that were missing them
(aligned_dim, diameter_dim, dim_continue, dim_baseline, table_cmd,
tolerance_cmd, ddedit), and to home/draw/wipeout and revcloud.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 03:03:08 +03:00
|
|
|
pub const ICON: IconKind = IconKind::Svg(include_bytes!("../../../assets/icons/dim_angular.svg"));
|
2026-03-22 14:56:27 +03:00
|
|
|
|
|
|
|
|
pub fn tool() -> ToolDef {
|
|
|
|
|
ToolDef {
|
|
|
|
|
id: "DIMANGULAR",
|
|
|
|
|
label: "Angular",
|
|
|
|
|
icon: ICON,
|
|
|
|
|
event: ModuleEvent::Command("DIMANGULAR".to_string()),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum Step {
|
|
|
|
|
Vertex,
|
|
|
|
|
FirstRay(Vec3),
|
2026-05-12 10:36:15 +03:00
|
|
|
SecondRay {
|
|
|
|
|
vertex: Vec3,
|
|
|
|
|
first: Vec3,
|
|
|
|
|
},
|
|
|
|
|
ArcPoint {
|
|
|
|
|
vertex: Vec3,
|
|
|
|
|
first: Vec3,
|
|
|
|
|
second: Vec3,
|
|
|
|
|
},
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct AngularDimensionCommand {
|
|
|
|
|
step: Step,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AngularDimensionCommand {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self { step: Step::Vertex }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl CadCommand for AngularDimensionCommand {
|
|
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
|
"DIMANGULAR"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn prompt(&self) -> String {
|
|
|
|
|
match self.step {
|
|
|
|
|
Step::Vertex => "DIMANGULAR Specify angle vertex:".into(),
|
|
|
|
|
Step::FirstRay(_) => "DIMANGULAR Specify first extension line point:".into(),
|
|
|
|
|
Step::SecondRay { .. } => "DIMANGULAR Specify second extension line point:".into(),
|
|
|
|
|
Step::ArcPoint { .. } => "DIMANGULAR Specify dimension arc location:".into(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
feat(f64): command layer compiles on DVec3
Whole command/snap/grip/cursor chain now builds on f64 DVec3 end to end,
so picked points, snaps and grip drags stay precise at UTM-scale
coordinates instead of quantizing to ~0.5 m through f32.
- All ~80 command files migrated: draw (line/circle/arc/ellipse/shapes
in full f64; others via point methods), modify, annotate, insert, view,
inquiry, layers, groups, clipboard, layout.
- Entity apply_grip impls updated for GripApply::{Absolute,Translate}(DVec3).
- Construction sites (EntityTransform/CmdResult/DynAnchor) emit DVec3;
wire-preview boundaries cast to f32 only at the GPU edge.
- Modify/annotate commands keep internal Vec3 geometry where precision is
non-critical, casting at the DVec3 boundary; key draw commands store f64.
Builds clean (no warnings). Visual verification of crosshair/snap/grip at
extreme UTM zoom pending.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 03:51:50 +03:00
|
|
|
fn on_point(&mut self, pt: DVec3) -> CmdResult { let pt = pt.as_vec3();
|
2026-03-22 14:56:27 +03:00
|
|
|
match self.step {
|
|
|
|
|
Step::Vertex => {
|
|
|
|
|
self.step = Step::FirstRay(pt);
|
|
|
|
|
CmdResult::NeedPoint
|
|
|
|
|
}
|
|
|
|
|
Step::FirstRay(vertex) => {
|
|
|
|
|
self.step = Step::SecondRay { vertex, first: pt };
|
|
|
|
|
CmdResult::NeedPoint
|
|
|
|
|
}
|
|
|
|
|
Step::SecondRay { vertex, first } => {
|
|
|
|
|
self.step = Step::ArcPoint {
|
|
|
|
|
vertex,
|
|
|
|
|
first,
|
|
|
|
|
second: pt,
|
|
|
|
|
};
|
|
|
|
|
CmdResult::NeedPoint
|
|
|
|
|
}
|
|
|
|
|
Step::ArcPoint {
|
|
|
|
|
vertex,
|
|
|
|
|
first,
|
|
|
|
|
second,
|
|
|
|
|
} => {
|
|
|
|
|
let mut dim = DimensionAngular3Pt::new(v3(vertex), v3(first), v3(second));
|
|
|
|
|
dim.definition_point = v3(pt);
|
|
|
|
|
dim.base.definition_point = v3(pt);
|
|
|
|
|
dim.base.text_middle_point = v3(pt);
|
|
|
|
|
dim.base.insertion_point = v3(pt);
|
|
|
|
|
dim.base.actual_measurement = dim.measurement_degrees();
|
|
|
|
|
CmdResult::CommitAndExit(EntityType::Dimension(Dimension::Angular3Pt(dim)))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn on_enter(&mut self) -> CmdResult {
|
|
|
|
|
CmdResult::Cancel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn on_escape(&mut self) -> CmdResult {
|
|
|
|
|
CmdResult::Cancel
|
|
|
|
|
}
|
|
|
|
|
|
feat(f64): command layer compiles on DVec3
Whole command/snap/grip/cursor chain now builds on f64 DVec3 end to end,
so picked points, snaps and grip drags stay precise at UTM-scale
coordinates instead of quantizing to ~0.5 m through f32.
- All ~80 command files migrated: draw (line/circle/arc/ellipse/shapes
in full f64; others via point methods), modify, annotate, insert, view,
inquiry, layers, groups, clipboard, layout.
- Entity apply_grip impls updated for GripApply::{Absolute,Translate}(DVec3).
- Construction sites (EntityTransform/CmdResult/DynAnchor) emit DVec3;
wire-preview boundaries cast to f32 only at the GPU edge.
- Modify/annotate commands keep internal Vec3 geometry where precision is
non-critical, casting at the DVec3 boundary; key draw commands store f64.
Builds clean (no warnings). Visual verification of crosshair/snap/grip at
extreme UTM zoom pending.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 03:51:50 +03:00
|
|
|
fn on_mouse_move(&mut self, pt: DVec3) -> Option<WireModel> { let pt = pt.as_vec3();
|
2026-03-22 14:56:27 +03:00
|
|
|
match self.step {
|
|
|
|
|
Step::Vertex => None,
|
|
|
|
|
Step::FirstRay(vertex) => Some(preview_wire(vec![vertex, pt])),
|
2026-05-12 10:36:15 +03:00
|
|
|
Step::SecondRay { vertex, first } => Some(preview_wire(vec![
|
|
|
|
|
vertex,
|
|
|
|
|
first,
|
|
|
|
|
Vec3::new(f32::NAN, f32::NAN, f32::NAN),
|
|
|
|
|
vertex,
|
|
|
|
|
pt,
|
|
|
|
|
])),
|
2026-03-22 14:56:27 +03:00
|
|
|
Step::ArcPoint {
|
|
|
|
|
vertex,
|
|
|
|
|
first,
|
|
|
|
|
second,
|
|
|
|
|
} => Some(preview_wire(angular_preview(vertex, first, second, pt))),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn v3(pt: Vec3) -> Vector3 {
|
|
|
|
|
Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn preview_wire(points: Vec<Vec3>) -> WireModel {
|
|
|
|
|
WireModel {
|
refactor(text): per-entity SDF text — all text kinds, selection/hover highlight
Rearchitect SDF text from a document-wide collector to per-entity
production during tessellation, so each entity owns its glyph quads and
composite/nested text is covered for free (no re-explosion, no per-frame
document walk).
- WireModel gains `text_verts`: glyph quads ride on the wire, so they are
cached by the tess memo, cloned on hit, and transformed by the block
expand loop exactly like `points`.
- Text arm (tessellate.rs) builds the quads when SDF is on and suppresses
the strokes; render gathers text_verts from the viewport wire set
(`gather_text_verts`, cached on wire content id) — the old collector is
removed. Covers model, dimension, table, block-internal and paper-sheet
text uniformly.
- MLEADER text (lays out via layout_mtext, not the Text arm) gets its own
SDF branch driven by the per-run GlyphRun.
- Pick box comes from the rendered glyph quads (true text extent), not
entity_aabb which mis-places the box for MTEXT; composite paths no longer
clobber the empty text wire's tight AABB (dim pick box hugs the text).
- Selection / hover highlight via a text-highlight overlay (upload_text_
highlight, keyed on selection_generation) mirroring the selected-wire
xray overlay; base glyphs stay neutral so a deselect leaves no stale tint.
- Debug: env OCS_TEXT_BOX draws each run's glyph-bounds rectangle.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 17:01:36 +03:00
|
|
|
text_verts: Vec::new(),
|
2026-03-22 14:56:27 +03:00
|
|
|
name: "dimangular_preview".to_string(),
|
|
|
|
|
points: points.into_iter().map(|p| [p.x, p.y, p.z]).collect(),
|
2026-06-23 17:08:54 +03:00
|
|
|
points_low: Vec::new(),
|
2026-03-22 14:56:27 +03:00
|
|
|
color: WireModel::CYAN,
|
|
|
|
|
selected: false,
|
|
|
|
|
pattern_length: 0.0,
|
|
|
|
|
pattern: [0.0; 8],
|
|
|
|
|
line_weight_px: 1.0,
|
|
|
|
|
snap_pts: vec![],
|
|
|
|
|
tangent_geoms: vec![],
|
2026-04-06 23:19:08 +03:00
|
|
|
aci: 0,
|
2026-05-12 10:36:15 +03:00
|
|
|
key_vertices: vec![],
|
|
|
|
|
aabb: WireModel::UNBOUNDED_AABB,
|
|
|
|
|
plinegen: true,
|
|
|
|
|
vp_scissor: None,
|
|
|
|
|
fill_tris: vec![],
|
2026-06-23 18:03:40 +03:00
|
|
|
fill_tris_low: Vec::new(),
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn angular_preview(vertex: Vec3, first: Vec3, second: Vec3, arc_pt: Vec3) -> Vec<Vec3> {
|
|
|
|
|
let mut points = vec![
|
|
|
|
|
vertex,
|
|
|
|
|
first,
|
|
|
|
|
Vec3::new(f32::NAN, f32::NAN, f32::NAN),
|
|
|
|
|
vertex,
|
|
|
|
|
second,
|
|
|
|
|
Vec3::new(f32::NAN, f32::NAN, f32::NAN),
|
|
|
|
|
];
|
|
|
|
|
let r = vertex.distance(arc_pt);
|
|
|
|
|
if r <= 1e-6 {
|
|
|
|
|
return points;
|
|
|
|
|
}
|
|
|
|
|
let a0 = (first.y - vertex.y).atan2(first.x - vertex.x);
|
|
|
|
|
let mut a1 = (second.y - vertex.y).atan2(second.x - vertex.x);
|
|
|
|
|
let mut delta = a1 - a0;
|
|
|
|
|
while delta <= 0.0 {
|
|
|
|
|
delta += std::f32::consts::TAU;
|
|
|
|
|
}
|
|
|
|
|
if delta > std::f32::consts::PI {
|
|
|
|
|
a1 -= std::f32::consts::TAU;
|
|
|
|
|
delta = a1 - a0;
|
|
|
|
|
}
|
|
|
|
|
let steps = 24;
|
|
|
|
|
for i in 0..=steps {
|
|
|
|
|
let t = i as f32 / steps as f32;
|
|
|
|
|
let a = a0 + delta * t;
|
|
|
|
|
points.push(vertex + Vec3::new(a.cos() * r, a.sin() * r, 0.0));
|
|
|
|
|
}
|
|
|
|
|
points
|
|
|
|
|
}
|
2026-05-26 22:45:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// ── Autocomplete registry ─────────────────────────────────
|
feat(alias): centralize command aliases in user-editable ocad.pgp (#286/#288)
Command aliases (L→LINE, CC→COPYCLIP) were scattered across dispatch match
arms and CommandRegistration name arrays. Move them all into a single
user-editable file:
- assets/ocad.pgp: shipped default alias table (ALIAS,*COMMAND format),
embedded and copied to config/ocad.pgp on first launch; only that user
copy is read after. AA→AREA default closes #286.
- resolve_alias() rewrites the leading command token at the top of
dispatch_command_inner, so aliases resolve for every path (families,
plugins, Repeat menu). Args after the first space are untouched.
- Autocomplete hides alias keys and, when the whole input is an alias,
surfaces its target command as the top (highlighted) suggestion so the
highlight matches what Enter runs (AA→AREA, L→LINE).
- ALIASEDIT opens a new editor modal (add/edit/delete rows) with an Apply
button; Apply persists to ocad.pgp, closing discards unapplied edits.
- Strip alias tokens from all 8 dispatch match-arm files and 71 module
CommandRegistration arrays, keeping canonical/synonym/distinct-command
names. ocad.pgp is now the sole source: deleting or remapping an alias
there takes effect. CUI stays on the keyboard-shortcut panel.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-10 12:39:22 +03:00
|
|
|
inventory::submit!(crate::command::CommandRegistration { names: &["DIMANGULAR"] }); // AngularDimensionCommand
|