Files
OneCAD-Draft/src/modules/draw/defaults.rs
T
Hakan SevenandClaude Opus 4.8 3666c7fa69 refactor(modules): rename home module to draw, restore first-tab order
The Home tab was already titled "Draw"; rename the module to match:
folder modules/home → modules/draw, HomeModule → DrawModule, id "home"
→ "draw". The inner draw/ command folder is kept (modules::draw::draw).

Update build.rs PRIORITY ("home" → "draw") so the tab returns to the
front of the ribbon; registry.rs regenerates accordingly.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-16 11:49:14 +03:00

50 lines
2.2 KiB
Rust

// Persistent command defaults — last-used values survive across command runs
// within the same session. Uses thread_local! so no synchronisation needed.
use std::cell::Cell;
thread_local! {
static CIRCLE_RADIUS: Cell<f32> = Cell::new(1.0);
static CIRCLE_DIAM: Cell<f32> = Cell::new(2.0);
static ROTATE_ANGLE: Cell<f32> = Cell::new(0.0); // degrees
static SCALE_FACTOR: Cell<f32> = Cell::new(1.0);
static OFFSET_DIST: Cell<f32> = Cell::new(1.0);
static FILLET_RADIUS: Cell<f32> = Cell::new(1.0);
static CHAMFER_DIST1: Cell<f32> = Cell::new(10.0);
static CHAMFER_DIST2: Cell<f32> = Cell::new(10.0);
static ARRAY_ROWS: Cell<f32> = Cell::new(2.0);
static ARRAY_COLS: Cell<f32> = Cell::new(2.0);
static ARRAY_ROW_SP: Cell<f32> = Cell::new(100.0);
static ARRAY_COL_SP: Cell<f32> = Cell::new(100.0);
static ARRAY_P_COUNT: Cell<f32> = Cell::new(6.0);
static ARRAY_P_ANGLE: Cell<f32> = Cell::new(360.0); // degrees
static ARRAY_PATH_COUNT: Cell<f32> = Cell::new(6.0);
}
macro_rules! accessors {
($get:ident, $set:ident, $var:ident) => {
pub fn $get() -> f32 {
$var.with(|c| c.get())
}
pub fn $set(v: f32) {
$var.with(|c| c.set(v));
}
};
}
accessors!(get_circle_radius, set_circle_radius, CIRCLE_RADIUS);
accessors!(get_circle_diam, set_circle_diam, CIRCLE_DIAM);
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);