forked from 1b-agent/opencadstudio-upstream
Fixes: - Font prompt no longer lists bundled ltypeshp/qcadshp shape files (#1626) - Wide polylines step at a discontinuous segment width; PEDIT marks the current vertex; keyword steps refresh the command preview (#1628) - Radius-0 fillet drops the zero-length segment it left, so the corner fillets again (#1422) - FILLET Trim / No trim option (#1558) - True-colour wires plot in their own colour; colour picker stores the value it shows (#1621) - Model tab keeps its page setup; "Save changes to layout" in Model (#1620) - QNEW default template in Options > Files; .dwt in the open dialog (#1134, #1113) - GRIDUNIT / GRIDMODE / PERSPECTIVE variables (#1618, #1524) - PTYPE (#1433) - ZOOM nX / nXP (#1465) - CHSPACE between model and paper space through a viewport (#1428) - Moving a dimension keeps its automatic text placement - Shell icon; "&&" button labels (#1554) - LINETYPE Load from a .lin file (#1588) - XLINE / RAY hide the crosshair arms (#1437) - Dynamic-input boxes keep clear of the crosshair and each other (#1546) - Snap marker colour setting, dark default on light canvases (#1497, #1229, #1128) - Dimension style precision as a 0.00 pattern dropdown (#1426) - Node graph nodes left of the origin no longer clip away (#1592) - Collapse button in the command history header (#1094) - Freeze-in-current-viewport toggle in the ribbon layer list (#1466) - Geometric Center object snap for closed polylines (#1369) New strings translated in all 21 locales. Co-Authored-By: Claude Opus 5.5 <[email protected]>
106 lines
4.4 KiB
Rust
106 lines
4.4 KiB
Rust
// Last-used command values for this session.
|
|
|
|
use std::cell::Cell;
|
|
|
|
thread_local! {
|
|
static CIRCLE_RADIUS: Cell<f64> = Cell::new(1.0);
|
|
static ROTATE_ANGLE: Cell<f64> = Cell::new(0.0); // degrees
|
|
static SCALE_FACTOR: Cell<f64> = Cell::new(1.0);
|
|
static OFFSET_DIST: Cell<f64> = Cell::new(1.0);
|
|
static FILLET_RADIUS: Cell<f64> = Cell::new(1.0);
|
|
static CHAMFER_DIST1: Cell<f64> = Cell::new(10.0);
|
|
static CHAMFER_DIST2: Cell<f64> = Cell::new(10.0);
|
|
static ARRAY_ROWS: Cell<f64> = Cell::new(2.0);
|
|
static ARRAY_COLS: Cell<f64> = Cell::new(2.0);
|
|
static ARRAY_ROW_SP: Cell<f64> = Cell::new(100.0);
|
|
static ARRAY_COL_SP: Cell<f64> = Cell::new(100.0);
|
|
static ARRAY_P_COUNT: Cell<f64> = Cell::new(6.0);
|
|
static ARRAY_P_ANGLE: Cell<f64> = Cell::new(360.0); // degrees
|
|
static ARRAY_PATH_COUNT: Cell<f64> = Cell::new(6.0);
|
|
static POLYGON_SIDES: Cell<f64> = Cell::new(6.0);
|
|
static RECT_ELEVATION: Cell<f64> = Cell::new(0.0);
|
|
static RECT_THICKNESS: Cell<f64> = Cell::new(0.0);
|
|
static RECT_WIDTH: Cell<f64> = Cell::new(0.0);
|
|
static PLINE_WIDTH: Cell<f64> = Cell::new(0.0); // PLINEWID
|
|
static RECT_ROTATION: Cell<f64> = Cell::new(0.0); // degrees
|
|
static RECT_CHAMFER1: Cell<f64> = Cell::new(0.0);
|
|
static RECT_CHAMFER2: Cell<f64> = Cell::new(0.0);
|
|
static RECT_FILLET: Cell<f64> = Cell::new(0.0);
|
|
static DONUT_INNER_DIAMETER: Cell<f64> = Cell::new(0.5);
|
|
static DONUT_OUTER_DIAMETER: Cell<f64> = Cell::new(1.0);
|
|
static HELIX_BASE_RADIUS: Cell<f64> = Cell::new(1.0);
|
|
static HELIX_HEIGHT: Cell<f64> = Cell::new(1.0);
|
|
static HELIX_TURNS: Cell<f64> = Cell::new(3.0);
|
|
static HELIX_COUNTER_CLOCKWISE: Cell<bool> = Cell::new(true);
|
|
static FILLET_TRIM: Cell<bool> = Cell::new(true); // TRIMMODE
|
|
}
|
|
|
|
macro_rules! accessors {
|
|
($get:ident, $set:ident, $var:ident) => {
|
|
pub fn $get() -> f64 {
|
|
$var.with(|c| c.get())
|
|
}
|
|
pub fn $set(v: f64) {
|
|
$var.with(|c| c.set(v));
|
|
}
|
|
};
|
|
}
|
|
|
|
accessors!(get_circle_radius, set_circle_radius, CIRCLE_RADIUS);
|
|
pub fn get_circle_diam() -> f64 {
|
|
get_circle_radius() * 2.0
|
|
}
|
|
|
|
pub fn set_circle_diam(value: f64) {
|
|
set_circle_radius(value * 0.5);
|
|
}
|
|
accessors!(get_rotate_angle, set_rotate_angle, ROTATE_ANGLE);
|
|
accessors!(get_scale_factor, set_scale_factor, SCALE_FACTOR);
|
|
accessors!(get_offset_dist, set_offset_dist, OFFSET_DIST);
|
|
accessors!(get_fillet_radius, set_fillet_radius, FILLET_RADIUS);
|
|
accessors!(get_chamfer_dist1, set_chamfer_dist1, CHAMFER_DIST1);
|
|
accessors!(get_chamfer_dist2, set_chamfer_dist2, CHAMFER_DIST2);
|
|
accessors!(get_array_rows, set_array_rows, ARRAY_ROWS);
|
|
accessors!(get_array_cols, set_array_cols, ARRAY_COLS);
|
|
accessors!(get_array_row_sp, set_array_row_sp, ARRAY_ROW_SP);
|
|
accessors!(get_array_col_sp, set_array_col_sp, ARRAY_COL_SP);
|
|
accessors!(get_array_p_count, set_array_p_count, ARRAY_P_COUNT);
|
|
accessors!(get_array_p_angle, set_array_p_angle, ARRAY_P_ANGLE);
|
|
accessors!(get_array_path_count, set_array_path_count, ARRAY_PATH_COUNT);
|
|
accessors!(get_polygon_sides, set_polygon_sides, POLYGON_SIDES);
|
|
accessors!(get_rect_elevation, set_rect_elevation, RECT_ELEVATION);
|
|
accessors!(get_rect_thickness, set_rect_thickness, RECT_THICKNESS);
|
|
accessors!(get_rect_width, set_rect_width, RECT_WIDTH);
|
|
accessors!(get_pline_width, set_pline_width, PLINE_WIDTH);
|
|
accessors!(get_rect_rotation, set_rect_rotation, RECT_ROTATION);
|
|
accessors!(get_rect_chamfer1, set_rect_chamfer1, RECT_CHAMFER1);
|
|
accessors!(get_rect_chamfer2, set_rect_chamfer2, RECT_CHAMFER2);
|
|
accessors!(get_rect_fillet, set_rect_fillet, RECT_FILLET);
|
|
accessors!(get_helix_base_radius, set_helix_base_radius, HELIX_BASE_RADIUS);
|
|
accessors!(get_helix_height, set_helix_height, HELIX_HEIGHT);
|
|
accessors!(get_helix_turns, set_helix_turns, HELIX_TURNS);
|
|
pub fn get_helix_counter_clockwise() -> bool {
|
|
HELIX_COUNTER_CLOCKWISE.with(|value| value.get())
|
|
}
|
|
|
|
pub fn set_helix_counter_clockwise(value: bool) {
|
|
HELIX_COUNTER_CLOCKWISE.with(|current| current.set(value));
|
|
}
|
|
pub fn get_fillet_trim() -> bool {
|
|
FILLET_TRIM.with(|value| value.get())
|
|
}
|
|
|
|
pub fn set_fillet_trim(value: bool) {
|
|
FILLET_TRIM.with(|current| current.set(value));
|
|
}
|
|
accessors!(
|
|
get_donut_inner_diameter,
|
|
set_donut_inner_diameter,
|
|
DONUT_INNER_DIAMETER
|
|
);
|
|
accessors!(
|
|
get_donut_outer_diameter,
|
|
set_donut_outer_diameter,
|
|
DONUT_OUTER_DIAMETER
|
|
);
|