Add a Drafting page for the rotation angle and the polar increment

Two drafting preferences had no proper home. The Drafting Settings dialog
displays the drafting rotation and offers only a Reset button — there was no
way to type an angle short of `SETVAR SNAPANG`. The polar tracking increment
existed in exactly one place: a pop-up hanging off the status-bar pill.

The rotation is a text field over an edit buffer rather than the value
itself, so clearing it to retype does not snap the crosshair to zero on the
way through; the buffer is reseeded whenever the value is restored from
behind it. Angles render without a trailing `.0`, matching how the polar
pop-up has always shown them — same kind of number, same reader.

Snap modes, grid spacing and object snap stay in Drafting Settings, where
they belong; the page links to it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
PanosandClaude Opus 5 committed 2026-09-10 08:33:19 +03:00
1 parent 9c3f3625da
commit b5f4b4d1cc
6 files changed
+123

No files matched your search

+8
View File
@@ -517,6 +517,9 @@ pub(super) struct OpenCADStudio {
crosshair_color: Option<[u8; 3]>,
/// Editable Options buffer for the crosshair colour.
crosshair_color_input: String,
/// Edit buffer for the SNAPANG field on the Options Drafting page. Kept
/// separate from `snap_angle_deg` so a half-typed angle is not parsed.
snap_angle_input: String,
/// Model-space lineweight preview scale, in percent (25..=200).
lineweight_display_scale: i32,
/// Isometric drafting state and active axis pair.
@@ -2029,6 +2032,10 @@ pub enum Message {
QdimSnapPriorityChanged(u8),
/// Change which annotative objects pick up a new scale (ANNOAUTOSCALE).
AnnoAutoScaleChanged(i8),
/// Edit the drafting rotation field; parsed when it holds a valid angle (SNAPANG).
SnapAngleInputChanged(String),
/// Change the polar tracking increment in degrees.
PolarIncrementChanged(f32),
/// Restore Model Space display/canvas appearance to defaults.
RestoreModelSpaceDisplayDefaults,
/// Restore Selection visual effect settings to defaults.
@@ -3429,6 +3436,7 @@ impl OpenCADStudio {
cursor_type: settings::CursorType::Crosshair,
crosshair_color: None,
crosshair_color_input: String::new(),
snap_angle_input: "0".to_string(),
lineweight_display_scale: 100,
isometric_drafting: false,
iso_plane: settings::IsoPlane::Left,
+12
View File
@@ -145,6 +145,18 @@ pub(crate) fn snaps_from_osmode(osmode: i32) -> (Vec<SnapType>, bool) {
(modes, osmode & OSMODE_SUPPRESS == 0)
}
/// Render a drafting angle without a trailing `.0`, so `22.5` but `30`.
///
/// The polar pop-up formats its presets the same way; both are showing the
/// same kind of number to the same person.
pub fn format_snap_angle(deg: f32) -> String {
if (deg - deg.round()).abs() < 1e-4 {
format!("{}", deg.round() as i32)
} else {
format!("{deg}")
}
}
/// GRIPOBJLIMIT default: past this many selected objects, no grips are drawn.
pub const DEFAULT_GRIP_OBJECT_LIMIT: i32 = 100;
+3
View File
@@ -452,6 +452,9 @@ impl OpenCADStudio {
} else {
0.0
};
// The Options field edits a buffer rather than the value, so it has to
// be reseeded whenever the value is restored from behind it.
self.snap_angle_input = crate::app::settings::format_snap_angle(self.snap_angle_deg);
// Ortho + running OSNAP are per-drawing (adopted from the header on
// open / tab switch), not app-global, so they are not applied here.
self.snapper.otrack_enabled = s.otrack;
+21
View File
@@ -6266,6 +6266,27 @@ impl OpenCADStudio {
Task::none()
}
// Typed into freely; only committed when it parses, so clearing
// the field to retype does not snap the crosshair back to zero.
Message::SnapAngleInputChanged(value) => {
self.snap_angle_input = value;
if let Ok(angle) = self.snap_angle_input.trim().parse::<f32>() {
if angle.is_finite() {
self.snap_angle_deg = angle.rem_euclid(360.0);
self.persist_settings_if_changed();
}
}
Task::none()
}
Message::PolarIncrementChanged(deg) => {
if deg.is_finite() && deg > 0.0 {
self.polar_increment_deg = deg;
self.persist_settings_if_changed();
}
Task::none()
}
Message::PickDragRectToggled(rectangle) => {
self.pick_drag_rect = rectangle;
self.persist_settings_if_changed();
+2
View File
@@ -204,7 +204,9 @@ impl OpenCADStudio {
dimension_continue_mode: self.dimension_continue_mode,
qdim_snap_priority: self.quick_dimension_snap_priority,
annotation_auto_scale: self.annotation_auto_scale,
polar_increment_deg: self.polar_increment_deg,
},
&self.snap_angle_input,
self.double_click_block_refedit,
self.double_click_block_attedit,
self.cursor_type,