2026-03-22 22:44:32 +03:00
|
|
|
|
use crate::command::CadCommand;
|
2026-06-26 23:06:40 +03:00
|
|
|
|
use crate::io::linetypes;
|
2026-06-16 11:49:14 +03:00
|
|
|
|
use crate::modules::draw::modify::refedit::RefEditSession;
|
2026-06-16 11:33:46 +03:00
|
|
|
|
use crate::scene::pick::grip::GripEdit;
|
2026-03-22 22:44:32 +03:00
|
|
|
|
use crate::scene::GripDef;
|
2026-05-12 10:36:15 +03:00
|
|
|
|
use crate::scene::Scene;
|
|
|
|
|
|
use crate::snap::SnapResult;
|
|
|
|
|
|
use crate::ui::{LayerPanel, PropertiesPanel};
|
2026-04-06 14:16:06 +03:00
|
|
|
|
use acadrust::tables::Ucs;
|
2026-05-12 10:36:15 +03:00
|
|
|
|
use acadrust::{CadDocument, Handle};
|
2026-04-08 00:12:09 +03:00
|
|
|
|
use iced;
|
2026-06-17 15:50:52 +03:00
|
|
|
|
use std::any::Any;
|
2026-06-09 13:41:21 -04:00
|
|
|
|
use std::collections::HashMap;
|
2026-05-12 10:36:15 +03:00
|
|
|
|
use std::path::PathBuf;
|
2026-03-22 22:44:32 +03:00
|
|
|
|
|
feat(dyn-input): TAB-editable distance/angle/coordinate fields
Dinamik giriş artık cursor yanında düzenlenebilir kutular gösteriyor.
TAB ile kutular arası geçilir, bir kutuya yazınca o kutu kilitlenir
(değer sabitlenir), diğerleri cursor'ı takip etmeye devam eder, Enter
ile çözülen nokta komuta point-pick olarak iletilir.
- DocumentTab.dyn_fields / dyn_active state; DynComponent + DynFieldEntry
- sync_dyn_fields komutun dyn_field() + base noktasına göre kutu kümesini
türetir: nokta+base → [d, açı], nokta+base yok → [X, Y], radius → [d],
açı → [açı]
- klavye yönlendirme: rakam/./-/+ aktif kutuya, TAB sonraki kutuya,
Enter try_dyn_commit, Backspace kilidi açar
- dyn_capturing iken command-line text alanı on_input'suz bırakılıyor
ki focus'u ve tuşları çalmasın; girişler global key aboneliğinden
geliyor (numpad dahil text alanı üzerinden yakalanıyor)
- çoklu-kutu overlay render: aktif kutu vurgulu, kilitli kutu farklı
kenar rengi
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:08:57 +03:00
|
|
|
|
// ── Dynamic input ──────────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
/// One quantity shown in the dynamic-input overlay near the cursor.
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
|
|
|
|
|
pub(super) enum DynComponent {
|
|
|
|
|
|
/// Absolute X ordinate.
|
|
|
|
|
|
X,
|
|
|
|
|
|
/// Absolute Y ordinate.
|
|
|
|
|
|
Y,
|
fix(dyn-input): support cartesian coords via "," (#35)
Typing \`,\` while DYN was on appended the character to the focused
field's buffer (treated as a European decimal point), so users
couldn't switch to cartesian coordinates mid-command. The dynamic
input was stuck in polar \`[Distance, Angle]\` whenever a base point
existed.
\`,\` now acts as the coordinate separator (matching the AutoCAD
convention): pressing it locks the current field's buffer, then
either advances within the existing cartesian set or reshapes a
polar configuration into cartesian:
- \`[Distance, Angle]\` + \`,\` on the first field → \`[X(buf), Y]\`
- \`[X, Y]\` + \`,\` on Y → \`[X, Y, Z]\`
- otherwise advances to the next field (Tab-equivalent)
\`sync_dyn_fields\` accepts both polar and cartesian shapes as valid
\`Point\` configurations so a mouse-move after the reshape doesn't
revert to polar. \`dyn_resolve_point\` and the overlay's live-value
formatter treat cartesian inputs as RELATIVE to the base point when
one exists — matching the DYN-on relative-coords convention from
#26. \`DynComponent::Z\` plus its label / value paths fill out the
3-D variant.
Closes #35
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 00:46:18 +03:00
|
|
|
|
/// Absolute Z ordinate (only visible after the user types a second
|
|
|
|
|
|
/// `,` separator from a cartesian X/Y configuration).
|
|
|
|
|
|
Z,
|
feat(dyn-input): TAB-editable distance/angle/coordinate fields
Dinamik giriş artık cursor yanında düzenlenebilir kutular gösteriyor.
TAB ile kutular arası geçilir, bir kutuya yazınca o kutu kilitlenir
(değer sabitlenir), diğerleri cursor'ı takip etmeye devam eder, Enter
ile çözülen nokta komuta point-pick olarak iletilir.
- DocumentTab.dyn_fields / dyn_active state; DynComponent + DynFieldEntry
- sync_dyn_fields komutun dyn_field() + base noktasına göre kutu kümesini
türetir: nokta+base → [d, açı], nokta+base yok → [X, Y], radius → [d],
açı → [açı]
- klavye yönlendirme: rakam/./-/+ aktif kutuya, TAB sonraki kutuya,
Enter try_dyn_commit, Backspace kilidi açar
- dyn_capturing iken command-line text alanı on_input'suz bırakılıyor
ki focus'u ve tuşları çalmasın; girişler global key aboneliğinden
geliyor (numpad dahil text alanı üzerinden yakalanıyor)
- çoklu-kutu overlay render: aktif kutu vurgulu, kilitli kutu farklı
kenar rengi
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:08:57 +03:00
|
|
|
|
/// Linear distance from the last point.
|
|
|
|
|
|
Distance,
|
|
|
|
|
|
/// Angle from the last point, in degrees.
|
|
|
|
|
|
Angle,
|
2026-06-09 18:32:03 +03:00
|
|
|
|
/// A scalar the command reads from the command line (a count, a radius,
|
|
|
|
|
|
/// a delta). Typed-only — it has no geometric live value derived from
|
|
|
|
|
|
/// the cursor unless the command supplies one via `dyn_live_value`.
|
|
|
|
|
|
Scalar,
|
feat(dyn-input): TAB-editable distance/angle/coordinate fields
Dinamik giriş artık cursor yanında düzenlenebilir kutular gösteriyor.
TAB ile kutular arası geçilir, bir kutuya yazınca o kutu kilitlenir
(değer sabitlenir), diğerleri cursor'ı takip etmeye devam eder, Enter
ile çözülen nokta komuta point-pick olarak iletilir.
- DocumentTab.dyn_fields / dyn_active state; DynComponent + DynFieldEntry
- sync_dyn_fields komutun dyn_field() + base noktasına göre kutu kümesini
türetir: nokta+base → [d, açı], nokta+base yok → [X, Y], radius → [d],
açı → [açı]
- klavye yönlendirme: rakam/./-/+ aktif kutuya, TAB sonraki kutuya,
Enter try_dyn_commit, Backspace kilidi açar
- dyn_capturing iken command-line text alanı on_input'suz bırakılıyor
ki focus'u ve tuşları çalmasın; girişler global key aboneliğinden
geliyor (numpad dahil text alanı üzerinden yakalanıyor)
- çoklu-kutu overlay render: aktif kutu vurgulu, kilitli kutu farklı
kenar rengi
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:08:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A single editable dynamic-input field. `buffer == None` means the box
|
|
|
|
|
|
/// tracks the cursor live; once the user types, the typed text is held in
|
|
|
|
|
|
/// `buffer` and the box stops following the cursor (it is "locked").
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
|
|
pub(super) struct DynFieldEntry {
|
|
|
|
|
|
pub(super) component: DynComponent,
|
2026-06-15 17:12:08 +03:00
|
|
|
|
/// Semantic role — drives the label and value scaling (e.g. diameter).
|
|
|
|
|
|
/// Defaults to the role matching `component` on the legacy path.
|
|
|
|
|
|
pub(super) role: crate::command::DynRole,
|
feat(dyn-input): TAB-editable distance/angle/coordinate fields
Dinamik giriş artık cursor yanında düzenlenebilir kutular gösteriyor.
TAB ile kutular arası geçilir, bir kutuya yazınca o kutu kilitlenir
(değer sabitlenir), diğerleri cursor'ı takip etmeye devam eder, Enter
ile çözülen nokta komuta point-pick olarak iletilir.
- DocumentTab.dyn_fields / dyn_active state; DynComponent + DynFieldEntry
- sync_dyn_fields komutun dyn_field() + base noktasına göre kutu kümesini
türetir: nokta+base → [d, açı], nokta+base yok → [X, Y], radius → [d],
açı → [açı]
- klavye yönlendirme: rakam/./-/+ aktif kutuya, TAB sonraki kutuya,
Enter try_dyn_commit, Backspace kilidi açar
- dyn_capturing iken command-line text alanı on_input'suz bırakılıyor
ki focus'u ve tuşları çalmasın; girişler global key aboneliğinden
geliyor (numpad dahil text alanı üzerinden yakalanıyor)
- çoklu-kutu overlay render: aktif kutu vurgulu, kilitli kutu farklı
kenar rengi
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:08:57 +03:00
|
|
|
|
pub(super) buffer: Option<String>,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl DynFieldEntry {
|
|
|
|
|
|
pub(super) fn new(component: DynComponent) -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
component,
|
2026-06-15 17:12:08 +03:00
|
|
|
|
role: default_role_for(component),
|
|
|
|
|
|
buffer: None,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// Build from an explicit role (spec-driven path); the resolution
|
|
|
|
|
|
/// component is derived from the role.
|
|
|
|
|
|
pub(super) fn from_role(role: crate::command::DynRole) -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
component: component_for_role(role),
|
|
|
|
|
|
role,
|
feat(dyn-input): TAB-editable distance/angle/coordinate fields
Dinamik giriş artık cursor yanında düzenlenebilir kutular gösteriyor.
TAB ile kutular arası geçilir, bir kutuya yazınca o kutu kilitlenir
(değer sabitlenir), diğerleri cursor'ı takip etmeye devam eder, Enter
ile çözülen nokta komuta point-pick olarak iletilir.
- DocumentTab.dyn_fields / dyn_active state; DynComponent + DynFieldEntry
- sync_dyn_fields komutun dyn_field() + base noktasına göre kutu kümesini
türetir: nokta+base → [d, açı], nokta+base yok → [X, Y], radius → [d],
açı → [açı]
- klavye yönlendirme: rakam/./-/+ aktif kutuya, TAB sonraki kutuya,
Enter try_dyn_commit, Backspace kilidi açar
- dyn_capturing iken command-line text alanı on_input'suz bırakılıyor
ki focus'u ve tuşları çalmasın; girişler global key aboneliğinden
geliyor (numpad dahil text alanı üzerinden yakalanıyor)
- çoklu-kutu overlay render: aktif kutu vurgulu, kilitli kutu farklı
kenar rengi
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:08:57 +03:00
|
|
|
|
buffer: None,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
pub(super) fn locked(&self) -> bool {
|
|
|
|
|
|
self.buffer.is_some()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-15 17:12:08 +03:00
|
|
|
|
/// Map a [`DynRole`](crate::command::DynRole) to the ordinate/distance/angle
|
|
|
|
|
|
/// component used by point resolution.
|
|
|
|
|
|
pub(super) fn component_for_role(role: crate::command::DynRole) -> DynComponent {
|
|
|
|
|
|
use crate::command::DynRole;
|
|
|
|
|
|
match role {
|
|
|
|
|
|
DynRole::X | DynRole::Width => DynComponent::X,
|
|
|
|
|
|
DynRole::Y | DynRole::Height => DynComponent::Y,
|
|
|
|
|
|
DynRole::Z => DynComponent::Z,
|
|
|
|
|
|
DynRole::Distance | DynRole::Radius | DynRole::Diameter => DynComponent::Distance,
|
|
|
|
|
|
DynRole::Angle => DynComponent::Angle,
|
|
|
|
|
|
DynRole::Factor | DynRole::Count => DynComponent::Scalar,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn default_role_for(component: DynComponent) -> crate::command::DynRole {
|
|
|
|
|
|
use crate::command::DynRole;
|
|
|
|
|
|
match component {
|
|
|
|
|
|
DynComponent::X => DynRole::X,
|
|
|
|
|
|
DynComponent::Y => DynRole::Y,
|
|
|
|
|
|
DynComponent::Z => DynRole::Z,
|
|
|
|
|
|
DynComponent::Distance => DynRole::Distance,
|
|
|
|
|
|
DynComponent::Angle => DynRole::Angle,
|
|
|
|
|
|
DynComponent::Scalar => DynRole::Factor,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-22 22:44:32 +03:00
|
|
|
|
// ── Per-document tab state ─────────────────────────────────────────────────
|
|
|
|
|
|
|
feat(commands): expand standard CAD command coverage
Integrate a large batch of standard CAD commands and fix several
name/behaviour mismatches, with no product references in code.
3D solids (reusing the truck B-rep pipeline):
- SLICE, INTERFERE, PRESSPULL, POLYSOLID, PYRAMID, SECTION
- 3DROTATE, 3DMIRROR, 3DALIGN (cached-solid transforms)
Annotation / text:
- ARCTEXT, SPLINEFIT (Catmull-Rom to Bezier), DIMJOGGED, OBJECTSCALE
(XData markers honoured by the existing geometry-gen / tessellator)
Blocks / misc:
- NCOPY (block-content extraction via explode_entity)
- OPTIONS, SYNCPVIEWPORTS, THICKEN, plus earlier toggles, aliases,
system variables, and layer/style/view commands
POINTCLOUD/RECAP and UNDERLAYLAYERS/UOSNAP are intentionally left out:
they require a proprietary binary / PDF-layer parser, a GPU point
renderer, and real test files.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 08:23:58 +03:00
|
|
|
|
/// One layer's display state, captured and restored by LAYERSTATE.
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
|
pub(super) struct LayerSnap {
|
|
|
|
|
|
pub name: String,
|
|
|
|
|
|
pub off: bool,
|
|
|
|
|
|
pub frozen: bool,
|
|
|
|
|
|
pub locked: bool,
|
|
|
|
|
|
pub color: acadrust::types::Color,
|
|
|
|
|
|
pub line_type: String,
|
|
|
|
|
|
pub line_weight: acadrust::types::LineWeight,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl DocumentTab {
|
|
|
|
|
|
/// Snapshot every layer's current display state under `name` (overwrites
|
|
|
|
|
|
/// any existing state of that name).
|
|
|
|
|
|
pub(super) fn save_layer_state(&mut self, name: &str) {
|
|
|
|
|
|
let snaps: Vec<LayerSnap> = self
|
|
|
|
|
|
.scene
|
|
|
|
|
|
.document
|
|
|
|
|
|
.layers
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|l| LayerSnap {
|
|
|
|
|
|
name: l.name.clone(),
|
|
|
|
|
|
off: l.flags.off,
|
|
|
|
|
|
frozen: l.flags.frozen,
|
|
|
|
|
|
locked: l.flags.locked,
|
|
|
|
|
|
color: l.color.clone(),
|
|
|
|
|
|
line_type: l.line_type.clone(),
|
|
|
|
|
|
line_weight: l.line_weight.clone(),
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
self.layer_states.insert(name.to_string(), snaps);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Reapply the saved state `name` to the matching layers; returns the number
|
|
|
|
|
|
/// of layers updated, or `None` if no such state exists.
|
|
|
|
|
|
pub(super) fn restore_layer_state(&mut self, name: &str) -> Option<usize> {
|
|
|
|
|
|
let snaps = self.layer_states.get(name)?.clone();
|
|
|
|
|
|
let mut applied = 0usize;
|
|
|
|
|
|
for s in &snaps {
|
|
|
|
|
|
if let Some(l) = self.scene.document.layers.get_mut(&s.name) {
|
|
|
|
|
|
l.flags.off = s.off;
|
|
|
|
|
|
l.flags.frozen = s.frozen;
|
|
|
|
|
|
l.flags.locked = s.locked;
|
|
|
|
|
|
l.color = s.color.clone();
|
|
|
|
|
|
l.line_type = s.line_type.clone();
|
|
|
|
|
|
l.line_weight = s.line_weight.clone();
|
|
|
|
|
|
applied += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Some(applied)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-22 22:44:32 +03:00
|
|
|
|
pub(super) struct DocumentTab {
|
|
|
|
|
|
pub(super) scene: Scene,
|
|
|
|
|
|
pub(super) current_path: Option<PathBuf>,
|
|
|
|
|
|
pub(super) dirty: bool,
|
|
|
|
|
|
pub(super) tab_title: String,
|
|
|
|
|
|
pub(super) properties: PropertiesPanel,
|
|
|
|
|
|
pub(super) layers: LayerPanel,
|
|
|
|
|
|
pub(super) active_cmd: Option<Box<dyn CadCommand>>,
|
|
|
|
|
|
pub(super) last_cmd: Option<String>,
|
|
|
|
|
|
pub(super) snap_result: Option<SnapResult>,
|
|
|
|
|
|
pub(super) active_grip: Option<GripEdit>,
|
|
|
|
|
|
pub(super) selected_grips: Vec<GripDef>,
|
|
|
|
|
|
pub(super) selected_handle: Option<Handle>,
|
2026-06-11 20:11:19 +03:00
|
|
|
|
/// Dynamic-block visibility grip for the current single selection.
|
|
|
|
|
|
pub(super) visibility_grip: Option<super::visibility::VisibilityGrip>,
|
2026-03-22 22:44:32 +03:00
|
|
|
|
pub(super) wireframe: bool,
|
2026-05-27 00:08:37 +03:00
|
|
|
|
pub(super) render_mode: acadrust::entities::ViewportRenderMode,
|
2026-03-22 22:44:32 +03:00
|
|
|
|
pub(super) visual_style: String,
|
|
|
|
|
|
pub(super) last_cursor_world: glam::Vec3,
|
2026-04-08 00:12:09 +03:00
|
|
|
|
pub(super) last_cursor_screen: iced::Point,
|
2026-06-15 17:12:08 +03:00
|
|
|
|
/// Base point (`App::last_point`) projected to viewport pixels, refreshed
|
|
|
|
|
|
/// on cursor move. Lets the dynamic-input overlay place the distance label
|
|
|
|
|
|
/// along the rubber-band line and the angle label at its end.
|
|
|
|
|
|
pub(super) last_point_screen: Option<iced::Point>,
|
feat(dyn-input): TAB-editable distance/angle/coordinate fields
Dinamik giriş artık cursor yanında düzenlenebilir kutular gösteriyor.
TAB ile kutular arası geçilir, bir kutuya yazınca o kutu kilitlenir
(değer sabitlenir), diğerleri cursor'ı takip etmeye devam eder, Enter
ile çözülen nokta komuta point-pick olarak iletilir.
- DocumentTab.dyn_fields / dyn_active state; DynComponent + DynFieldEntry
- sync_dyn_fields komutun dyn_field() + base noktasına göre kutu kümesini
türetir: nokta+base → [d, açı], nokta+base yok → [X, Y], radius → [d],
açı → [açı]
- klavye yönlendirme: rakam/./-/+ aktif kutuya, TAB sonraki kutuya,
Enter try_dyn_commit, Backspace kilidi açar
- dyn_capturing iken command-line text alanı on_input'suz bırakılıyor
ki focus'u ve tuşları çalmasın; girişler global key aboneliğinden
geliyor (numpad dahil text alanı üzerinden yakalanıyor)
- çoklu-kutu overlay render: aktif kutu vurgulu, kilitli kutu farklı
kenar rengi
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:08:57 +03:00
|
|
|
|
/// Dynamic-input fields shown near the cursor while a command waits
|
|
|
|
|
|
/// for a point/distance/angle. Rebuilt whenever the active command's
|
|
|
|
|
|
/// `dyn_field()` or the presence of a base point changes. Empty when
|
|
|
|
|
|
/// dynamic input is not active.
|
|
|
|
|
|
pub(super) dyn_fields: Vec<DynFieldEntry>,
|
2026-06-15 17:12:08 +03:00
|
|
|
|
/// Guide geometry the overlay draws for the current step (set alongside
|
|
|
|
|
|
/// `dyn_fields`). Polar arc, radius line, axis-delta projections, etc.
|
|
|
|
|
|
pub(super) dyn_guide: crate::command::DynGuide,
|
|
|
|
|
|
/// World-space anchor the current step's values are measured from. `None`
|
|
|
|
|
|
/// falls back to `App::last_point`.
|
|
|
|
|
|
pub(super) dyn_anchor: Option<glam::Vec3>,
|
2026-06-15 18:46:34 +03:00
|
|
|
|
/// Far end of a reference line through `dyn_anchor` (for the `Perp` guide:
|
|
|
|
|
|
/// the base edge / major axis the offset is measured square to).
|
|
|
|
|
|
pub(super) dyn_ref: Option<glam::Vec3>,
|
|
|
|
|
|
/// `dyn_ref` projected to viewport pixels.
|
|
|
|
|
|
pub(super) dyn_ref_screen: Option<iced::Point>,
|
feat(dyn-input): TAB-editable distance/angle/coordinate fields
Dinamik giriş artık cursor yanında düzenlenebilir kutular gösteriyor.
TAB ile kutular arası geçilir, bir kutuya yazınca o kutu kilitlenir
(değer sabitlenir), diğerleri cursor'ı takip etmeye devam eder, Enter
ile çözülen nokta komuta point-pick olarak iletilir.
- DocumentTab.dyn_fields / dyn_active state; DynComponent + DynFieldEntry
- sync_dyn_fields komutun dyn_field() + base noktasına göre kutu kümesini
türetir: nokta+base → [d, açı], nokta+base yok → [X, Y], radius → [d],
açı → [açı]
- klavye yönlendirme: rakam/./-/+ aktif kutuya, TAB sonraki kutuya,
Enter try_dyn_commit, Backspace kilidi açar
- dyn_capturing iken command-line text alanı on_input'suz bırakılıyor
ki focus'u ve tuşları çalmasın; girişler global key aboneliğinden
geliyor (numpad dahil text alanı üzerinden yakalanıyor)
- çoklu-kutu overlay render: aktif kutu vurgulu, kilitli kutu farklı
kenar rengi
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:08:57 +03:00
|
|
|
|
/// Index of the field that TAB has focused (the one keystrokes edit).
|
|
|
|
|
|
pub(super) dyn_active: usize,
|
2026-03-22 22:44:32 +03:00
|
|
|
|
pub(super) history: HistoryState,
|
|
|
|
|
|
pub(super) active_layer: String,
|
feat(commands): expand standard CAD command coverage
Integrate a large batch of standard CAD commands and fix several
name/behaviour mismatches, with no product references in code.
3D solids (reusing the truck B-rep pipeline):
- SLICE, INTERFERE, PRESSPULL, POLYSOLID, PYRAMID, SECTION
- 3DROTATE, 3DMIRROR, 3DALIGN (cached-solid transforms)
Annotation / text:
- ARCTEXT, SPLINEFIT (Catmull-Rom to Bezier), DIMJOGGED, OBJECTSCALE
(XData markers honoured by the existing geometry-gen / tessellator)
Blocks / misc:
- NCOPY (block-content extraction via explode_entity)
- OPTIONS, SYNCPVIEWPORTS, THICKEN, plus earlier toggles, aliases,
system variables, and layer/style/view commands
POINTCLOUD/RECAP and UNDERLAYLAYERS/UOSNAP are intentionally left out:
they require a proprietary binary / PDF-layer parser, a GPU point
renderer, and real test files.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 08:23:58 +03:00
|
|
|
|
/// Named layer-state snapshots saved by LAYERSTATE (name → per-layer state).
|
|
|
|
|
|
pub(super) layer_states: std::collections::HashMap<String, Vec<LayerSnap>>,
|
2026-04-06 14:16:06 +03:00
|
|
|
|
/// Currently active UCS. `None` means WCS (identity transform).
|
|
|
|
|
|
pub(super) active_ucs: Option<Ucs>,
|
2026-04-06 23:26:26 +03:00
|
|
|
|
/// Custom model-space background color. `None` = default dark grey.
|
|
|
|
|
|
pub(super) bg_color: Option<[f32; 4]>,
|
|
|
|
|
|
/// Custom paper-space background color. `None` = default off-white grey.
|
|
|
|
|
|
pub(super) paper_bg_color: Option<[f32; 4]>,
|
2026-04-08 12:40:19 +03:00
|
|
|
|
/// Active REFEDIT session, if any.
|
|
|
|
|
|
pub(super) refedit_session: Option<RefEditSession>,
|
2026-04-08 18:13:21 +03:00
|
|
|
|
/// Currently active MLeader style name.
|
|
|
|
|
|
pub(super) active_mleader_style: String,
|
2026-05-01 07:07:19 +03:00
|
|
|
|
/// Last camera_generation value written back to the document.
|
|
|
|
|
|
pub(super) last_synced_camera_gen: u64,
|
feat(app): add fixed Start tab with welcome page and recent documents
A pinned "Start" tab now lives at index 0. It cannot be closed, opens
on launch, and replaces the model-space viewport with a welcome page —
similar to Thunderbird's first-run screen.
- Boot opens with only the Start tab; Drawing1 is no longer auto-spawned.
- The Properties left panel becomes a Recent Documents rail on the
Start tab. Recents persist to disk
(%APPDATA%/H7CAD/recent.txt on Windows, $XDG_CONFIG_HOME/H7CAD/recent.txt
on Linux, ~/Library/Application Support/H7CAD/recent.txt on macOS), up
to 20 entries, saved on every open and rehydrated at boot.
Each row opens or removes the file in place.
- The Support ribbon group (Donate / Report / About / Changelog) is
retired; the same actions surface on the welcome page instead. The
Donate button is the primary call-to-action — solid #B03020 brand
fill with a soft brand-tinted ambient glow halo behind the action row
(Thunderbird-style coloured glow against the neutral page).
- Drawing-only overlays (mouse-area, viewcube, navbar, dynamic input,
selection markers) are suppressed on the Start tab so its clicks
don't trigger CAD commands. OpenFile's "current_is_empty" check
refuses to replace the Start tab, and TabClose ignores requests on
it.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 16:19:31 +03:00
|
|
|
|
/// Sentinel "Welcome / Start" tab. Always at index 0 when present.
|
|
|
|
|
|
/// Cannot be closed; the viewport area renders a welcome page instead
|
|
|
|
|
|
/// of the model-space shader. The scene is still constructed so the
|
|
|
|
|
|
/// rest of the code can treat it as a normal tab when reading.
|
|
|
|
|
|
pub(super) is_start: bool,
|
2026-06-25 10:03:54 +03:00
|
|
|
|
/// Interactive PAN mode (the PAN command / tool). While active, a left-
|
|
|
|
|
|
/// button drag pans the view instead of selecting — the only pan path on a
|
|
|
|
|
|
/// device with no middle mouse button (a trackpad / web client). Exited
|
|
|
|
|
|
/// with Esc or by starting another command.
|
|
|
|
|
|
pub(super) pan_mode: bool,
|
2026-06-09 13:41:21 -04:00
|
|
|
|
/// Per-plugin document state (`plugin::BuiltinPlugin` manifest id → state).
|
2026-06-22 02:03:34 +03:00
|
|
|
|
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
|
2026-06-09 13:41:21 -04:00
|
|
|
|
pub(super) plugin_state: HashMap<&'static str, Box<dyn Any + Send + Sync>>,
|
2026-06-18 14:55:08 +01:00
|
|
|
|
pub(super) suspended_cmd: Option<Box<dyn CadCommand>>,
|
2026-03-22 22:44:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl DocumentTab {
|
feat(ucs): central WCS↔UCS converter; adopt file UCS, drive readout + icon
Introduce one bridge between WCS (how geometry and the file are stored)
and the active UCS (the coordinate system the user works in), so every
UCS-aware system routes through it instead of re-deriving axis math.
- UcsXform (app/helpers.rs): the converter — to_wcs/to_ucs (points),
vec_to_wcs/vec_to_ucs (directions), axes(), is_identity(). Orthonormal
axes, so the inverse is the transpose. The old ucs_to_wcs / ucs_rotate_vec
free fns now delegate to it (one implementation).
- DocumentTab::ucs_xform() builds it from the tab's active_ucs (None = WCS).
- DocumentTab::adopt_active_ucs_from_header() loads the document's saved
current UCS (header model-space UCS) into active_ucs on open, so the file's
coordinate system is live immediately; called from both load paths.
- Status-bar coordinate readout reports the cursor in the active UCS.
- UCS icon tripod projects the active UCS axes, so it rotates to the UCS
instead of always showing world X/Y/Z.
First slice of routing the app's coordinate systems through the converter;
input/picking, grid, ViewCube, and the remaining readouts follow.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 09:57:39 +03:00
|
|
|
|
/// The active WCS↔UCS converter for this tab — identity when no UCS is set.
|
|
|
|
|
|
/// Every consumer that needs UCS-relative coordinates goes through this.
|
|
|
|
|
|
pub(super) fn ucs_xform(&self) -> super::helpers::UcsXform {
|
|
|
|
|
|
super::helpers::UcsXform::from_active(self.active_ucs.as_ref())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-27 01:12:45 +03:00
|
|
|
|
/// World-space UCS origin in full f64 precision (stored f64 in the header /
|
|
|
|
|
|
/// viewport). Used to anchor the UCS icon and as the cursor-pick plane point
|
|
|
|
|
|
/// — `UcsXform`'s origin is f32 and would quantize the anchor at UTM scale.
|
|
|
|
|
|
pub(super) fn ucs_origin_world(&self) -> glam::DVec3 {
|
|
|
|
|
|
self.active_ucs
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
.map(|u| glam::dvec3(u.origin.x, u.origin.y, u.origin.z))
|
|
|
|
|
|
.unwrap_or(glam::DVec3::ZERO)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-24 17:23:29 +03:00
|
|
|
|
/// True when the active pane edits **model-space** geometry: the Model tab,
|
|
|
|
|
|
/// or inside a floating viewport (MSPACE). The UCS applies in both; plain
|
|
|
|
|
|
/// paper space (no active viewport) is excluded. Single predicate so every
|
|
|
|
|
|
/// UCS-aware system shares one rule. [[feedback_shared_infra]]
|
|
|
|
|
|
pub(super) fn editing_model_space(&self) -> bool {
|
|
|
|
|
|
self.scene.current_layout == "Model" || self.scene.active_viewport.is_some()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The document's saved model-space UCS (header), as a `Ucs`. `None` when it
|
|
|
|
|
|
/// is identity (plain WCS).
|
|
|
|
|
|
fn model_ucs_from_header(&self) -> Option<Ucs> {
|
feat(ucs): central WCS↔UCS converter; adopt file UCS, drive readout + icon
Introduce one bridge between WCS (how geometry and the file are stored)
and the active UCS (the coordinate system the user works in), so every
UCS-aware system routes through it instead of re-deriving axis math.
- UcsXform (app/helpers.rs): the converter — to_wcs/to_ucs (points),
vec_to_wcs/vec_to_ucs (directions), axes(), is_identity(). Orthonormal
axes, so the inverse is the transpose. The old ucs_to_wcs / ucs_rotate_vec
free fns now delegate to it (one implementation).
- DocumentTab::ucs_xform() builds it from the tab's active_ucs (None = WCS).
- DocumentTab::adopt_active_ucs_from_header() loads the document's saved
current UCS (header model-space UCS) into active_ucs on open, so the file's
coordinate system is live immediately; called from both load paths.
- Status-bar coordinate readout reports the cursor in the active UCS.
- UCS icon tripod projects the active UCS axes, so it rotates to the UCS
instead of always showing world X/Y/Z.
First slice of routing the app's coordinate systems through the converter;
input/picking, grid, ViewCube, and the remaining readouts follow.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 09:57:39 +03:00
|
|
|
|
let h = &self.scene.document.header;
|
|
|
|
|
|
let mut u = Ucs::new(h.model_space_ucs_name.clone());
|
|
|
|
|
|
u.origin = h.model_space_ucs_origin;
|
|
|
|
|
|
u.x_axis = h.model_space_ucs_x_axis;
|
|
|
|
|
|
u.y_axis = h.model_space_ucs_y_axis;
|
2026-06-24 17:23:29 +03:00
|
|
|
|
if super::helpers::UcsXform::from_ucs(&u).is_identity() {
|
|
|
|
|
|
None
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Some(u)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A floating viewport's own per-viewport UCS, if it has one set. `None`
|
|
|
|
|
|
/// when the viewport uses world coordinates or the handle is not a viewport.
|
|
|
|
|
|
pub(super) fn ucs_from_viewport(&self, h: Handle) -> Option<Ucs> {
|
|
|
|
|
|
let vp = match self.scene.document.get_entity(h) {
|
|
|
|
|
|
Some(acadrust::EntityType::Viewport(vp)) => vp,
|
|
|
|
|
|
_ => return None,
|
|
|
|
|
|
};
|
|
|
|
|
|
if !vp.ucs_per_viewport {
|
|
|
|
|
|
return None;
|
|
|
|
|
|
}
|
|
|
|
|
|
let mut u = Ucs::new("*VPUCS*");
|
|
|
|
|
|
u.origin = vp.ucs_origin;
|
|
|
|
|
|
u.x_axis = vp.ucs_x_axis;
|
|
|
|
|
|
u.y_axis = vp.ucs_y_axis;
|
|
|
|
|
|
if super::helpers::UcsXform::from_ucs(&u).is_identity() {
|
feat(ucs): central WCS↔UCS converter; adopt file UCS, drive readout + icon
Introduce one bridge between WCS (how geometry and the file are stored)
and the active UCS (the coordinate system the user works in), so every
UCS-aware system routes through it instead of re-deriving axis math.
- UcsXform (app/helpers.rs): the converter — to_wcs/to_ucs (points),
vec_to_wcs/vec_to_ucs (directions), axes(), is_identity(). Orthonormal
axes, so the inverse is the transpose. The old ucs_to_wcs / ucs_rotate_vec
free fns now delegate to it (one implementation).
- DocumentTab::ucs_xform() builds it from the tab's active_ucs (None = WCS).
- DocumentTab::adopt_active_ucs_from_header() loads the document's saved
current UCS (header model-space UCS) into active_ucs on open, so the file's
coordinate system is live immediately; called from both load paths.
- Status-bar coordinate readout reports the cursor in the active UCS.
- UCS icon tripod projects the active UCS axes, so it rotates to the UCS
instead of always showing world X/Y/Z.
First slice of routing the app's coordinate systems through the converter;
input/picking, grid, ViewCube, and the remaining readouts follow.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 09:57:39 +03:00
|
|
|
|
None
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Some(u)
|
2026-06-24 17:23:29 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Set `active_ucs` to the UCS of the *current pane*: the entered viewport's
|
|
|
|
|
|
/// own per-viewport UCS, the model header UCS in the Model tab, or none in
|
|
|
|
|
|
/// plain paper space. Keeps the ViewCube in lock-step. Call on every pane
|
|
|
|
|
|
/// change (enter/exit viewport, layout / tab switch, load) so one field
|
|
|
|
|
|
/// drives all UCS-aware systems regardless of where editing happens.
|
|
|
|
|
|
pub(super) fn refresh_active_ucs(&mut self) {
|
|
|
|
|
|
self.active_ucs = if let Some(h) = self.scene.active_viewport {
|
|
|
|
|
|
self.ucs_from_viewport(h)
|
|
|
|
|
|
} else if self.scene.current_layout == "Model" {
|
|
|
|
|
|
self.model_ucs_from_header()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
None
|
feat(ucs): central WCS↔UCS converter; adopt file UCS, drive readout + icon
Introduce one bridge between WCS (how geometry and the file are stored)
and the active UCS (the coordinate system the user works in), so every
UCS-aware system routes through it instead of re-deriving axis math.
- UcsXform (app/helpers.rs): the converter — to_wcs/to_ucs (points),
vec_to_wcs/vec_to_ucs (directions), axes(), is_identity(). Orthonormal
axes, so the inverse is the transpose. The old ucs_to_wcs / ucs_rotate_vec
free fns now delegate to it (one implementation).
- DocumentTab::ucs_xform() builds it from the tab's active_ucs (None = WCS).
- DocumentTab::adopt_active_ucs_from_header() loads the document's saved
current UCS (header model-space UCS) into active_ucs on open, so the file's
coordinate system is live immediately; called from both load paths.
- Status-bar coordinate readout reports the cursor in the active UCS.
- UCS icon tripod projects the active UCS axes, so it rotates to the UCS
instead of always showing world X/Y/Z.
First slice of routing the app's coordinate systems through the converter;
input/picking, grid, ViewCube, and the remaining readouts follow.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 09:57:39 +03:00
|
|
|
|
};
|
2026-06-22 10:10:47 +03:00
|
|
|
|
self.sync_ucs_to_scene();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-24 17:23:29 +03:00
|
|
|
|
/// Persist `active_ucs` back to its pane's storage so it round-trips: the
|
|
|
|
|
|
/// entered viewport's per-viewport UCS fields, or the document header's
|
|
|
|
|
|
/// model-space UCS in the Model tab. No-op in plain paper space. Call after
|
|
|
|
|
|
/// any UCS change.
|
|
|
|
|
|
pub(super) fn persist_active_ucs(&mut self) {
|
|
|
|
|
|
use acadrust::types::Vector3;
|
|
|
|
|
|
if let Some(h) = self.scene.active_viewport {
|
|
|
|
|
|
let (o, x, y, per) = match &self.active_ucs {
|
|
|
|
|
|
Some(u) => (u.origin, u.x_axis, u.y_axis, true),
|
|
|
|
|
|
None => (Vector3::ZERO, Vector3::UNIT_X, Vector3::UNIT_Y, false),
|
|
|
|
|
|
};
|
feat(commands): expand standard CAD command coverage
Integrate a large batch of standard CAD commands and fix several
name/behaviour mismatches, with no product references in code.
3D solids (reusing the truck B-rep pipeline):
- SLICE, INTERFERE, PRESSPULL, POLYSOLID, PYRAMID, SECTION
- 3DROTATE, 3DMIRROR, 3DALIGN (cached-solid transforms)
Annotation / text:
- ARCTEXT, SPLINEFIT (Catmull-Rom to Bezier), DIMJOGGED, OBJECTSCALE
(XData markers honoured by the existing geometry-gen / tessellator)
Blocks / misc:
- NCOPY (block-content extraction via explode_entity)
- OPTIONS, SYNCPVIEWPORTS, THICKEN, plus earlier toggles, aliases,
system variables, and layer/style/view commands
POINTCLOUD/RECAP and UNDERLAYLAYERS/UOSNAP are intentionally left out:
they require a proprietary binary / PDF-layer parser, a GPU point
renderer, and real test files.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 08:23:58 +03:00
|
|
|
|
if let Some(acadrust::EntityType::Viewport(vp)) = self.scene.document.get_entity_mut(h)
|
2026-06-24 17:23:29 +03:00
|
|
|
|
{
|
|
|
|
|
|
vp.ucs_origin = o;
|
|
|
|
|
|
vp.ucs_x_axis = x;
|
|
|
|
|
|
vp.ucs_y_axis = y;
|
|
|
|
|
|
vp.ucs_per_viewport = per;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if self.scene.current_layout == "Model" {
|
|
|
|
|
|
let h = &mut self.scene.document.header;
|
|
|
|
|
|
match &self.active_ucs {
|
|
|
|
|
|
Some(u) => {
|
|
|
|
|
|
h.model_space_ucs_origin = u.origin;
|
|
|
|
|
|
h.model_space_ucs_x_axis = u.x_axis;
|
|
|
|
|
|
h.model_space_ucs_y_axis = u.y_axis;
|
|
|
|
|
|
}
|
|
|
|
|
|
None => {
|
|
|
|
|
|
h.model_space_ucs_origin = Vector3::ZERO;
|
|
|
|
|
|
h.model_space_ucs_x_axis = Vector3::UNIT_X;
|
|
|
|
|
|
h.model_space_ucs_y_axis = Vector3::UNIT_Y;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Adopt the active pane's UCS on load (the file's saved model-space UCS in
|
|
|
|
|
|
/// the Model tab). Thin wrapper over [`refresh_active_ucs`] kept for the
|
|
|
|
|
|
/// load call sites.
|
|
|
|
|
|
pub(super) fn adopt_active_ucs_from_header(&mut self) {
|
|
|
|
|
|
self.refresh_active_ucs();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-22 10:10:47 +03:00
|
|
|
|
/// Push the active UCS rotation into the scene so the ViewCube composes with
|
|
|
|
|
|
/// it. Call after any change to `active_ucs`.
|
|
|
|
|
|
pub(super) fn sync_ucs_to_scene(&mut self) {
|
2026-06-22 11:17:55 +03:00
|
|
|
|
self.scene.viewcube_ucs = self.ucs_xform().rotation_mat();
|
feat(ucs): central WCS↔UCS converter; adopt file UCS, drive readout + icon
Introduce one bridge between WCS (how geometry and the file are stored)
and the active UCS (the coordinate system the user works in), so every
UCS-aware system routes through it instead of re-deriving axis math.
- UcsXform (app/helpers.rs): the converter — to_wcs/to_ucs (points),
vec_to_wcs/vec_to_ucs (directions), axes(), is_identity(). Orthonormal
axes, so the inverse is the transpose. The old ucs_to_wcs / ucs_rotate_vec
free fns now delegate to it (one implementation).
- DocumentTab::ucs_xform() builds it from the tab's active_ucs (None = WCS).
- DocumentTab::adopt_active_ucs_from_header() loads the document's saved
current UCS (header model-space UCS) into active_ucs on open, so the file's
coordinate system is live immediately; called from both load paths.
- Status-bar coordinate readout reports the cursor in the active UCS.
- UCS icon tripod projects the active UCS axes, so it rotates to the UCS
instead of always showing world X/Y/Z.
First slice of routing the app's coordinate systems through the converter;
input/picking, grid, ViewCube, and the remaining readouts follow.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 09:57:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-22 17:30:42 +03:00
|
|
|
|
/// UCS→render(wire)-space affine for commands that build axis-aligned
|
|
|
|
|
|
/// geometry. Columns are the UCS axes; translation is the UCS origin in wire
|
|
|
|
|
|
/// space. Identity outside model space (no UCS there).
|
|
|
|
|
|
pub(super) fn ucs_wire_affine(&self) -> glam::Mat4 {
|
2026-06-24 17:23:29 +03:00
|
|
|
|
if !self.editing_model_space() {
|
2026-06-22 17:30:42 +03:00
|
|
|
|
return glam::Mat4::IDENTITY;
|
|
|
|
|
|
}
|
|
|
|
|
|
let (o, x, y, z) = self.ucs_xform().axes();
|
feat(commands): expand standard CAD command coverage
Integrate a large batch of standard CAD commands and fix several
name/behaviour mismatches, with no product references in code.
3D solids (reusing the truck B-rep pipeline):
- SLICE, INTERFERE, PRESSPULL, POLYSOLID, PYRAMID, SECTION
- 3DROTATE, 3DMIRROR, 3DALIGN (cached-solid transforms)
Annotation / text:
- ARCTEXT, SPLINEFIT (Catmull-Rom to Bezier), DIMJOGGED, OBJECTSCALE
(XData markers honoured by the existing geometry-gen / tessellator)
Blocks / misc:
- NCOPY (block-content extraction via explode_entity)
- OPTIONS, SYNCPVIEWPORTS, THICKEN, plus earlier toggles, aliases,
system variables, and layer/style/view commands
POINTCLOUD/RECAP and UNDERLAYLAYERS/UOSNAP are intentionally left out:
they require a proprietary binary / PDF-layer parser, a GPU point
renderer, and real test files.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 08:23:58 +03:00
|
|
|
|
let origin = glam::Vec3::new(o.x as f32, o.y as f32, o.z as f32);
|
2026-06-22 17:30:42 +03:00
|
|
|
|
glam::Mat4::from_cols(
|
|
|
|
|
|
x.extend(0.0),
|
|
|
|
|
|
y.extend(0.0),
|
|
|
|
|
|
z.extend(0.0),
|
|
|
|
|
|
origin.extend(1.0),
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-22 18:18:35 +03:00
|
|
|
|
/// World-space rotation angle (radians) of the active UCS X axis — the
|
|
|
|
|
|
/// default rotation for new text-bearing objects so their text aligns to
|
|
|
|
|
|
/// the user's coordinate system. Zero outside model space / with no UCS.
|
|
|
|
|
|
pub(super) fn ucs_rotation_angle(&self) -> f64 {
|
2026-06-24 17:23:29 +03:00
|
|
|
|
if !self.editing_model_space() {
|
2026-06-22 18:18:35 +03:00
|
|
|
|
return 0.0;
|
|
|
|
|
|
}
|
|
|
|
|
|
let (_, x, ..) = self.ucs_xform().axes();
|
|
|
|
|
|
(x.y as f64).atan2(x.x as f64)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-22 11:27:34 +03:00
|
|
|
|
/// Grid origin (render/wire space) and UCS→world rotation for grid snap and
|
|
|
|
|
|
/// the grid overlay. Identity / origin-at-zero outside model space.
|
|
|
|
|
|
pub(super) fn ucs_grid_basis(&self) -> (glam::Vec3, glam::Mat4) {
|
2026-06-24 17:23:29 +03:00
|
|
|
|
if !self.editing_model_space() {
|
2026-06-22 11:27:34 +03:00
|
|
|
|
return (glam::Vec3::ZERO, glam::Mat4::IDENTITY);
|
|
|
|
|
|
}
|
|
|
|
|
|
let xf = self.ucs_xform();
|
|
|
|
|
|
let (o, ..) = xf.axes();
|
feat(commands): expand standard CAD command coverage
Integrate a large batch of standard CAD commands and fix several
name/behaviour mismatches, with no product references in code.
3D solids (reusing the truck B-rep pipeline):
- SLICE, INTERFERE, PRESSPULL, POLYSOLID, PYRAMID, SECTION
- 3DROTATE, 3DMIRROR, 3DALIGN (cached-solid transforms)
Annotation / text:
- ARCTEXT, SPLINEFIT (Catmull-Rom to Bezier), DIMJOGGED, OBJECTSCALE
(XData markers honoured by the existing geometry-gen / tessellator)
Blocks / misc:
- NCOPY (block-content extraction via explode_entity)
- OPTIONS, SYNCPVIEWPORTS, THICKEN, plus earlier toggles, aliases,
system variables, and layer/style/view commands
POINTCLOUD/RECAP and UNDERLAYLAYERS/UOSNAP are intentionally left out:
they require a proprietary binary / PDF-layer parser, a GPU point
renderer, and real test files.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 08:23:58 +03:00
|
|
|
|
let origin = glam::Vec3::new(o.x as f32, o.y as f32, o.z as f32);
|
2026-06-22 11:27:34 +03:00
|
|
|
|
(origin, xf.rotation_mat())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-22 22:44:32 +03:00
|
|
|
|
pub(super) fn new_drawing(n: usize) -> Self {
|
|
|
|
|
|
let mut scene = Scene::new();
|
|
|
|
|
|
linetypes::populate_document(&mut scene.document);
|
2026-04-23 14:23:38 +03:00
|
|
|
|
// Override acadrust's imperial default limits (12×9) with A4 landscape.
|
|
|
|
|
|
for obj in scene.document.objects.values_mut() {
|
|
|
|
|
|
if let acadrust::objects::ObjectType::Layout(l) = obj {
|
|
|
|
|
|
if l.name != "Model" {
|
|
|
|
|
|
l.min_limits = (0.0, 0.0);
|
|
|
|
|
|
l.max_limits = (297.0, 210.0);
|
|
|
|
|
|
l.min_extents = (0.0, 0.0, 0.0);
|
|
|
|
|
|
l.max_extents = (297.0, 210.0, 0.0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-22 22:44:32 +03:00
|
|
|
|
Self {
|
|
|
|
|
|
scene,
|
|
|
|
|
|
current_path: None,
|
|
|
|
|
|
dirty: false,
|
|
|
|
|
|
tab_title: format!("Drawing{}", n),
|
|
|
|
|
|
properties: PropertiesPanel::empty(),
|
|
|
|
|
|
layers: LayerPanel::default(),
|
|
|
|
|
|
active_cmd: None,
|
|
|
|
|
|
last_cmd: None,
|
|
|
|
|
|
snap_result: None,
|
|
|
|
|
|
active_grip: None,
|
|
|
|
|
|
selected_grips: vec![],
|
|
|
|
|
|
selected_handle: None,
|
2026-06-11 20:11:19 +03:00
|
|
|
|
visibility_grip: None,
|
2026-03-22 22:44:32 +03:00
|
|
|
|
wireframe: false,
|
2026-05-27 00:08:37 +03:00
|
|
|
|
render_mode: acadrust::entities::ViewportRenderMode::Wireframe2D,
|
|
|
|
|
|
visual_style: "Wireframe 2D".into(),
|
2026-03-22 22:44:32 +03:00
|
|
|
|
last_cursor_world: glam::Vec3::ZERO,
|
2026-04-08 00:12:09 +03:00
|
|
|
|
last_cursor_screen: iced::Point::ORIGIN,
|
2026-06-15 17:12:08 +03:00
|
|
|
|
last_point_screen: None,
|
feat(dyn-input): TAB-editable distance/angle/coordinate fields
Dinamik giriş artık cursor yanında düzenlenebilir kutular gösteriyor.
TAB ile kutular arası geçilir, bir kutuya yazınca o kutu kilitlenir
(değer sabitlenir), diğerleri cursor'ı takip etmeye devam eder, Enter
ile çözülen nokta komuta point-pick olarak iletilir.
- DocumentTab.dyn_fields / dyn_active state; DynComponent + DynFieldEntry
- sync_dyn_fields komutun dyn_field() + base noktasına göre kutu kümesini
türetir: nokta+base → [d, açı], nokta+base yok → [X, Y], radius → [d],
açı → [açı]
- klavye yönlendirme: rakam/./-/+ aktif kutuya, TAB sonraki kutuya,
Enter try_dyn_commit, Backspace kilidi açar
- dyn_capturing iken command-line text alanı on_input'suz bırakılıyor
ki focus'u ve tuşları çalmasın; girişler global key aboneliğinden
geliyor (numpad dahil text alanı üzerinden yakalanıyor)
- çoklu-kutu overlay render: aktif kutu vurgulu, kilitli kutu farklı
kenar rengi
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:08:57 +03:00
|
|
|
|
dyn_fields: Vec::new(),
|
2026-06-15 17:12:08 +03:00
|
|
|
|
dyn_guide: crate::command::DynGuide::Polar,
|
|
|
|
|
|
dyn_anchor: None,
|
2026-06-15 18:46:34 +03:00
|
|
|
|
dyn_ref: None,
|
|
|
|
|
|
dyn_ref_screen: None,
|
feat(dyn-input): TAB-editable distance/angle/coordinate fields
Dinamik giriş artık cursor yanında düzenlenebilir kutular gösteriyor.
TAB ile kutular arası geçilir, bir kutuya yazınca o kutu kilitlenir
(değer sabitlenir), diğerleri cursor'ı takip etmeye devam eder, Enter
ile çözülen nokta komuta point-pick olarak iletilir.
- DocumentTab.dyn_fields / dyn_active state; DynComponent + DynFieldEntry
- sync_dyn_fields komutun dyn_field() + base noktasına göre kutu kümesini
türetir: nokta+base → [d, açı], nokta+base yok → [X, Y], radius → [d],
açı → [açı]
- klavye yönlendirme: rakam/./-/+ aktif kutuya, TAB sonraki kutuya,
Enter try_dyn_commit, Backspace kilidi açar
- dyn_capturing iken command-line text alanı on_input'suz bırakılıyor
ki focus'u ve tuşları çalmasın; girişler global key aboneliğinden
geliyor (numpad dahil text alanı üzerinden yakalanıyor)
- çoklu-kutu overlay render: aktif kutu vurgulu, kilitli kutu farklı
kenar rengi
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 14:08:57 +03:00
|
|
|
|
dyn_active: 0,
|
2026-03-22 22:44:32 +03:00
|
|
|
|
history: HistoryState::default(),
|
|
|
|
|
|
active_layer: "0".to_string(),
|
feat(commands): expand standard CAD command coverage
Integrate a large batch of standard CAD commands and fix several
name/behaviour mismatches, with no product references in code.
3D solids (reusing the truck B-rep pipeline):
- SLICE, INTERFERE, PRESSPULL, POLYSOLID, PYRAMID, SECTION
- 3DROTATE, 3DMIRROR, 3DALIGN (cached-solid transforms)
Annotation / text:
- ARCTEXT, SPLINEFIT (Catmull-Rom to Bezier), DIMJOGGED, OBJECTSCALE
(XData markers honoured by the existing geometry-gen / tessellator)
Blocks / misc:
- NCOPY (block-content extraction via explode_entity)
- OPTIONS, SYNCPVIEWPORTS, THICKEN, plus earlier toggles, aliases,
system variables, and layer/style/view commands
POINTCLOUD/RECAP and UNDERLAYLAYERS/UOSNAP are intentionally left out:
they require a proprietary binary / PDF-layer parser, a GPU point
renderer, and real test files.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 08:23:58 +03:00
|
|
|
|
layer_states: std::collections::HashMap::new(),
|
2026-04-06 14:16:06 +03:00
|
|
|
|
active_ucs: None,
|
2026-04-06 23:26:26 +03:00
|
|
|
|
bg_color: None,
|
|
|
|
|
|
paper_bg_color: None,
|
2026-04-08 12:40:19 +03:00
|
|
|
|
refedit_session: None,
|
2026-04-08 18:13:21 +03:00
|
|
|
|
active_mleader_style: "Standard".to_string(),
|
2026-05-01 07:07:19 +03:00
|
|
|
|
last_synced_camera_gen: 0,
|
feat(app): add fixed Start tab with welcome page and recent documents
A pinned "Start" tab now lives at index 0. It cannot be closed, opens
on launch, and replaces the model-space viewport with a welcome page —
similar to Thunderbird's first-run screen.
- Boot opens with only the Start tab; Drawing1 is no longer auto-spawned.
- The Properties left panel becomes a Recent Documents rail on the
Start tab. Recents persist to disk
(%APPDATA%/H7CAD/recent.txt on Windows, $XDG_CONFIG_HOME/H7CAD/recent.txt
on Linux, ~/Library/Application Support/H7CAD/recent.txt on macOS), up
to 20 entries, saved on every open and rehydrated at boot.
Each row opens or removes the file in place.
- The Support ribbon group (Donate / Report / About / Changelog) is
retired; the same actions surface on the welcome page instead. The
Donate button is the primary call-to-action — solid #B03020 brand
fill with a soft brand-tinted ambient glow halo behind the action row
(Thunderbird-style coloured glow against the neutral page).
- Drawing-only overlays (mouse-area, viewcube, navbar, dynamic input,
selection markers) are suppressed on the Start tab so its clicks
don't trigger CAD commands. OpenFile's "current_is_empty" check
refuses to replace the Start tab, and TabClose ignores requests on
it.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 16:19:31 +03:00
|
|
|
|
is_start: false,
|
2026-06-25 10:03:54 +03:00
|
|
|
|
pan_mode: false,
|
2026-06-09 13:41:21 -04:00
|
|
|
|
plugin_state: HashMap::new(),
|
2026-06-18 14:55:08 +01:00
|
|
|
|
suspended_cmd: None,
|
2026-03-22 22:44:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat(app): add fixed Start tab with welcome page and recent documents
A pinned "Start" tab now lives at index 0. It cannot be closed, opens
on launch, and replaces the model-space viewport with a welcome page —
similar to Thunderbird's first-run screen.
- Boot opens with only the Start tab; Drawing1 is no longer auto-spawned.
- The Properties left panel becomes a Recent Documents rail on the
Start tab. Recents persist to disk
(%APPDATA%/H7CAD/recent.txt on Windows, $XDG_CONFIG_HOME/H7CAD/recent.txt
on Linux, ~/Library/Application Support/H7CAD/recent.txt on macOS), up
to 20 entries, saved on every open and rehydrated at boot.
Each row opens or removes the file in place.
- The Support ribbon group (Donate / Report / About / Changelog) is
retired; the same actions surface on the welcome page instead. The
Donate button is the primary call-to-action — solid #B03020 brand
fill with a soft brand-tinted ambient glow halo behind the action row
(Thunderbird-style coloured glow against the neutral page).
- Drawing-only overlays (mouse-area, viewcube, navbar, dynamic input,
selection markers) are suppressed on the Start tab so its clicks
don't trigger CAD commands. OpenFile's "current_is_empty" check
refuses to replace the Start tab, and TabClose ignores requests on
it.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 16:19:31 +03:00
|
|
|
|
/// Welcome / Start tab. Carries a dummy Scene so the rest of the app
|
|
|
|
|
|
/// can read tab state uniformly; the viewport renderer detects
|
|
|
|
|
|
/// `is_start` and shows a welcome page instead.
|
|
|
|
|
|
pub(super) fn new_start() -> Self {
|
|
|
|
|
|
let mut t = Self::new_drawing(0);
|
|
|
|
|
|
t.tab_title = "Start".to_string();
|
|
|
|
|
|
t.is_start = true;
|
|
|
|
|
|
t
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-22 22:44:32 +03:00
|
|
|
|
pub(super) fn tab_display_name(&self) -> String {
|
|
|
|
|
|
match &self.current_path {
|
|
|
|
|
|
Some(p) => p
|
|
|
|
|
|
.file_name()
|
|
|
|
|
|
.unwrap_or_default()
|
|
|
|
|
|
.to_string_lossy()
|
|
|
|
|
|
.to_string(),
|
|
|
|
|
|
None => self.tab_title.clone(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
|
pub(super) struct HistorySnapshot {
|
|
|
|
|
|
pub(super) document: CadDocument,
|
|
|
|
|
|
pub(super) current_layout: String,
|
|
|
|
|
|
pub(super) selected: Vec<Handle>,
|
|
|
|
|
|
pub(super) dirty: bool,
|
|
|
|
|
|
pub(super) label: String,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
|
pub(super) struct HistoryState {
|
|
|
|
|
|
pub(super) undo_stack: Vec<HistorySnapshot>,
|
|
|
|
|
|
pub(super) redo_stack: Vec<HistorySnapshot>,
|
|
|
|
|
|
}
|