cargo fmt
This commit is contained in:
parent
468cbde5e1
commit
ca07268c7c
204 changed files with 13988 additions and 5516 deletions
File diff suppressed because it is too large
Load diff
2516
src/app/commands.rs
2516
src/app/commands.rs
File diff suppressed because it is too large
Load diff
|
|
@ -1,15 +1,15 @@
|
|||
use crate::scene::Scene;
|
||||
use crate::ui::{LayerPanel, PropertiesPanel};
|
||||
use crate::command::CadCommand;
|
||||
use crate::snap::SnapResult;
|
||||
use crate::linetypes;
|
||||
use crate::modules::home::modify::refedit::RefEditSession;
|
||||
use crate::scene::grip::GripEdit;
|
||||
use crate::scene::GripDef;
|
||||
use crate::modules::home::modify::refedit::RefEditSession;
|
||||
use acadrust::{CadDocument, Handle};
|
||||
use crate::scene::Scene;
|
||||
use crate::snap::SnapResult;
|
||||
use crate::ui::{LayerPanel, PropertiesPanel};
|
||||
use acadrust::tables::Ucs;
|
||||
use crate::linetypes;
|
||||
use std::path::PathBuf;
|
||||
use acadrust::{CadDocument, Handle};
|
||||
use iced;
|
||||
use std::path::PathBuf;
|
||||
|
||||
// ── Per-document tab state ─────────────────────────────────────────────────
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::ui::overlay::GridPlane;
|
||||
use crate::scene::WireModel;
|
||||
use crate::ui::overlay::GridPlane;
|
||||
use acadrust::tables::Ucs;
|
||||
|
||||
// ── Coordinate parsing ─────────────────────────────────────────────────────
|
||||
|
|
@ -27,9 +27,21 @@ pub(super) fn parse_coord(text: &str) -> Option<glam::Vec3> {
|
|||
///
|
||||
/// WCS = origin + x_axis*u + y_axis*v + z_axis*w
|
||||
pub(super) fn ucs_to_wcs(pt: glam::Vec3, ucs: &Ucs) -> glam::Vec3 {
|
||||
let o = glam::Vec3::new(ucs.origin.x as f32, ucs.origin.y as f32, ucs.origin.z as f32);
|
||||
let x = glam::Vec3::new(ucs.x_axis.x as f32, ucs.x_axis.y as f32, ucs.x_axis.z as f32);
|
||||
let y = glam::Vec3::new(ucs.y_axis.x as f32, ucs.y_axis.y as f32, ucs.y_axis.z as f32);
|
||||
let o = glam::Vec3::new(
|
||||
ucs.origin.x as f32,
|
||||
ucs.origin.y as f32,
|
||||
ucs.origin.z as f32,
|
||||
);
|
||||
let x = glam::Vec3::new(
|
||||
ucs.x_axis.x as f32,
|
||||
ucs.x_axis.y as f32,
|
||||
ucs.x_axis.z as f32,
|
||||
);
|
||||
let y = glam::Vec3::new(
|
||||
ucs.y_axis.x as f32,
|
||||
ucs.y_axis.y as f32,
|
||||
ucs.y_axis.z as f32,
|
||||
);
|
||||
let z_ax = ucs_z_axis(ucs);
|
||||
o + x * pt.x + y * pt.y + z_ax * pt.z
|
||||
}
|
||||
|
|
@ -37,9 +49,21 @@ pub(super) fn ucs_to_wcs(pt: glam::Vec3, ucs: &Ucs) -> glam::Vec3 {
|
|||
/// Convert a WCS point back to UCS local coordinates.
|
||||
#[allow(dead_code)]
|
||||
pub(super) fn wcs_to_ucs(pt: glam::Vec3, ucs: &Ucs) -> glam::Vec3 {
|
||||
let o = glam::Vec3::new(ucs.origin.x as f32, ucs.origin.y as f32, ucs.origin.z as f32);
|
||||
let x = glam::Vec3::new(ucs.x_axis.x as f32, ucs.x_axis.y as f32, ucs.x_axis.z as f32);
|
||||
let y = glam::Vec3::new(ucs.y_axis.x as f32, ucs.y_axis.y as f32, ucs.y_axis.z as f32);
|
||||
let o = glam::Vec3::new(
|
||||
ucs.origin.x as f32,
|
||||
ucs.origin.y as f32,
|
||||
ucs.origin.z as f32,
|
||||
);
|
||||
let x = glam::Vec3::new(
|
||||
ucs.x_axis.x as f32,
|
||||
ucs.x_axis.y as f32,
|
||||
ucs.x_axis.z as f32,
|
||||
);
|
||||
let y = glam::Vec3::new(
|
||||
ucs.y_axis.x as f32,
|
||||
ucs.y_axis.y as f32,
|
||||
ucs.y_axis.z as f32,
|
||||
);
|
||||
let z_ax = ucs_z_axis(ucs);
|
||||
let d = pt - o;
|
||||
glam::Vec3::new(d.dot(x), d.dot(y), d.dot(z_ax))
|
||||
|
|
@ -47,8 +71,16 @@ pub(super) fn wcs_to_ucs(pt: glam::Vec3, ucs: &Ucs) -> glam::Vec3 {
|
|||
|
||||
/// Return the normalised Z axis of a UCS (cross product of X and Y axes).
|
||||
pub(super) fn ucs_z_axis(ucs: &Ucs) -> glam::Vec3 {
|
||||
let x = glam::Vec3::new(ucs.x_axis.x as f32, ucs.x_axis.y as f32, ucs.x_axis.z as f32);
|
||||
let y = glam::Vec3::new(ucs.y_axis.x as f32, ucs.y_axis.y as f32, ucs.y_axis.z as f32);
|
||||
let x = glam::Vec3::new(
|
||||
ucs.x_axis.x as f32,
|
||||
ucs.x_axis.y as f32,
|
||||
ucs.x_axis.z as f32,
|
||||
);
|
||||
let y = glam::Vec3::new(
|
||||
ucs.y_axis.x as f32,
|
||||
ucs.y_axis.y as f32,
|
||||
ucs.y_axis.z as f32,
|
||||
);
|
||||
x.cross(y).normalize_or_zero()
|
||||
}
|
||||
|
||||
|
|
@ -57,9 +89,7 @@ pub(super) fn ucs_rotated_z(origin: glam::Vec3, angle_z: f32) -> Ucs {
|
|||
let cos = angle_z.cos() as f64;
|
||||
let sin = angle_z.sin() as f64;
|
||||
let mut ucs = Ucs::new("*ACTIVE*");
|
||||
ucs.origin = acadrust::types::Vector3::new(
|
||||
origin.x as f64, origin.y as f64, origin.z as f64,
|
||||
);
|
||||
ucs.origin = acadrust::types::Vector3::new(origin.x as f64, origin.y as f64, origin.z as f64);
|
||||
ucs.x_axis = acadrust::types::Vector3::new(cos, sin, 0.0);
|
||||
ucs.y_axis = acadrust::types::Vector3::new(-sin, cos, 0.0);
|
||||
ucs
|
||||
|
|
@ -134,7 +164,11 @@ pub(super) fn entities_centroid(wires: &[WireModel]) -> glam::Vec3 {
|
|||
count += 1;
|
||||
}
|
||||
}
|
||||
if count > 0 { sum / count as f32 } else { glam::Vec3::ZERO }
|
||||
if count > 0 {
|
||||
sum / count as f32
|
||||
} else {
|
||||
glam::Vec3::ZERO
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate the next available auto group name ("*A1", "*A2", …).
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use super::{H7CAD, document::HistorySnapshot};
|
||||
use super::{document::HistorySnapshot, H7CAD};
|
||||
use std::collections::HashSet;
|
||||
|
||||
impl H7CAD {
|
||||
|
|
@ -10,7 +10,11 @@ impl H7CAD {
|
|||
.unwrap_or_else(|| fallback.to_string())
|
||||
}
|
||||
|
||||
pub(super) fn capture_history_snapshot(&self, i: usize, label: impl Into<String>) -> HistorySnapshot {
|
||||
pub(super) fn capture_history_snapshot(
|
||||
&self,
|
||||
i: usize,
|
||||
label: impl Into<String>,
|
||||
) -> HistorySnapshot {
|
||||
HistorySnapshot {
|
||||
document: self.tabs[i].scene.document.clone(),
|
||||
current_layout: self.tabs[i].scene.current_layout.clone(),
|
||||
|
|
@ -45,7 +49,9 @@ impl H7CAD {
|
|||
self.tabs[i].dirty = snapshot.dirty;
|
||||
let doc_layers = self.tabs[i].scene.document.layers.clone();
|
||||
let vp_info = self.tabs[i].scene.viewport_list();
|
||||
self.tabs[i].layers.sync_with_viewports(&doc_layers, vp_info);
|
||||
self.tabs[i]
|
||||
.layers
|
||||
.sync_with_viewports(&doc_layers, vp_info);
|
||||
self.sync_ribbon_layers();
|
||||
self.refresh_properties();
|
||||
}
|
||||
|
|
@ -78,7 +84,8 @@ impl H7CAD {
|
|||
self.restore_history_snapshot(i, snapshot);
|
||||
last_label = label;
|
||||
}
|
||||
self.command_line.push_output(&format!("Undo: {last_label}"));
|
||||
self.command_line
|
||||
.push_output(&format!("Undo: {last_label}"));
|
||||
}
|
||||
|
||||
pub(super) fn redo_steps(&mut self, steps: usize) {
|
||||
|
|
@ -101,10 +108,15 @@ impl H7CAD {
|
|||
self.restore_history_snapshot(i, snapshot);
|
||||
last_label = label;
|
||||
}
|
||||
self.command_line.push_output(&format!("Redo: {last_label}"));
|
||||
self.command_line
|
||||
.push_output(&format!("Redo: {last_label}"));
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn history_dropdown_labels(stack: &[HistorySnapshot]) -> Vec<String> {
|
||||
stack.iter().rev().map(|snapshot| snapshot.label.clone()).collect()
|
||||
stack
|
||||
.iter()
|
||||
.rev()
|
||||
.map(|snapshot| snapshot.label.clone())
|
||||
.collect()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ impl H7CAD {
|
|||
})
|
||||
.collect();
|
||||
let names: Vec<String> = infos.iter().map(|l| l.name.clone()).collect();
|
||||
let active = if names.contains(&active) { active } else { "0".to_string() };
|
||||
let active = if names.contains(&active) {
|
||||
active
|
||||
} else {
|
||||
"0".to_string()
|
||||
};
|
||||
self.tabs[i].active_layer = active.clone();
|
||||
self.tabs[i].layers.current_layer = active.clone();
|
||||
self.ribbon.set_layers(infos, &active);
|
||||
|
|
@ -48,44 +52,74 @@ impl H7CAD {
|
|||
|
||||
let text_names: Vec<String> = doc.text_styles.iter().map(|s| s.name.clone()).collect();
|
||||
let active_text = doc.header.current_text_style_name.clone();
|
||||
let active_text = if text_names.contains(&active_text) { active_text } else {
|
||||
text_names.first().cloned().unwrap_or_else(|| "Standard".to_string())
|
||||
let active_text = if text_names.contains(&active_text) {
|
||||
active_text
|
||||
} else {
|
||||
text_names
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "Standard".to_string())
|
||||
};
|
||||
|
||||
let dim_names: Vec<String> = doc.dim_styles.iter().map(|s| s.name.clone()).collect();
|
||||
let active_dim = doc.header.current_dimstyle_name.clone();
|
||||
let active_dim = if dim_names.contains(&active_dim) { active_dim } else {
|
||||
dim_names.first().cloned().unwrap_or_else(|| "Standard".to_string())
|
||||
let active_dim = if dim_names.contains(&active_dim) {
|
||||
active_dim
|
||||
} else {
|
||||
dim_names
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "Standard".to_string())
|
||||
};
|
||||
|
||||
let mleader_names: Vec<String> = doc.objects.values().filter_map(|o| {
|
||||
if let acadrust::objects::ObjectType::MultiLeaderStyle(mls) = o {
|
||||
Some(mls.name.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).collect();
|
||||
let mleader_names: Vec<String> = doc
|
||||
.objects
|
||||
.values()
|
||||
.filter_map(|o| {
|
||||
if let acadrust::objects::ObjectType::MultiLeaderStyle(mls) = o {
|
||||
Some(mls.name.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let active_mleader = self.tabs[i].active_mleader_style.clone();
|
||||
let active_mleader = if mleader_names.contains(&active_mleader) { active_mleader } else {
|
||||
mleader_names.first().cloned().unwrap_or_else(|| "Standard".to_string())
|
||||
let active_mleader = if mleader_names.contains(&active_mleader) {
|
||||
active_mleader
|
||||
} else {
|
||||
mleader_names
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "Standard".to_string())
|
||||
};
|
||||
|
||||
let table_names: Vec<String> = doc.objects.values().filter_map(|o| {
|
||||
if let acadrust::objects::ObjectType::TableStyle(ts) = o {
|
||||
Some(ts.name.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).collect();
|
||||
let active_table = table_names.first().cloned().unwrap_or_else(|| "Standard".to_string());
|
||||
let table_names: Vec<String> = doc
|
||||
.objects
|
||||
.values()
|
||||
.filter_map(|o| {
|
||||
if let acadrust::objects::ObjectType::TableStyle(ts) = o {
|
||||
Some(ts.name.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let active_table = table_names
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "Standard".to_string());
|
||||
|
||||
let active_mleader2 = active_mleader.clone();
|
||||
let active_table2 = active_table.clone();
|
||||
self.ribbon.set_styles(
|
||||
text_names, &active_text,
|
||||
dim_names, &active_dim,
|
||||
mleader_names, &active_mleader2,
|
||||
table_names, &active_table2,
|
||||
text_names,
|
||||
&active_text,
|
||||
dim_names,
|
||||
&active_dim,
|
||||
mleader_names,
|
||||
&active_mleader2,
|
||||
table_names,
|
||||
&active_table2,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
214
src/app/mod.rs
214
src/app/mod.rs
|
|
@ -1,21 +1,21 @@
|
|||
mod cmd_result;
|
||||
mod commands;
|
||||
mod document;
|
||||
mod helpers;
|
||||
mod history;
|
||||
mod properties;
|
||||
mod layers;
|
||||
mod commands;
|
||||
mod cmd_result;
|
||||
mod view;
|
||||
mod properties;
|
||||
mod update;
|
||||
mod view;
|
||||
|
||||
use document::DocumentTab;
|
||||
|
||||
use acadrust::types::{Color as AcadColor, LineWeight};
|
||||
use acadrust::CadDocument;
|
||||
use crate::modules::ModuleEvent;
|
||||
use crate::scene::CubeRegion;
|
||||
use crate::snap::Snapper;
|
||||
use crate::ui::{AppMenu, CommandLine, Ribbon, StatusBar};
|
||||
use acadrust::types::{Color as AcadColor, LineWeight};
|
||||
use acadrust::CadDocument;
|
||||
|
||||
use iced::time::Instant;
|
||||
use iced::window;
|
||||
|
|
@ -71,15 +71,15 @@ pub(super) struct H7CAD {
|
|||
/// OS window Id of the primary application window.
|
||||
main_window: Option<window::Id>,
|
||||
// ── Floating panel windows ────────────────────────────────────────────
|
||||
page_setup_window: Option<window::Id>,
|
||||
textstyle_window: Option<window::Id>,
|
||||
tablestyle_window: Option<window::Id>,
|
||||
mlstyle_window: Option<window::Id>,
|
||||
layout_manager_window: Option<window::Id>,
|
||||
plotstyle_window: Option<window::Id>,
|
||||
dimstyle_window: Option<window::Id>,
|
||||
shortcuts_window: Option<window::Id>,
|
||||
about_window: Option<window::Id>,
|
||||
page_setup_window: Option<window::Id>,
|
||||
textstyle_window: Option<window::Id>,
|
||||
tablestyle_window: Option<window::Id>,
|
||||
mlstyle_window: Option<window::Id>,
|
||||
layout_manager_window: Option<window::Id>,
|
||||
plotstyle_window: Option<window::Id>,
|
||||
dimstyle_window: Option<window::Id>,
|
||||
shortcuts_window: Option<window::Id>,
|
||||
about_window: Option<window::Id>,
|
||||
/// In-memory clipboard: cloned entities waiting to be pasted.
|
||||
clipboard: Vec<acadrust::EntityType>,
|
||||
/// Centroid of the clipboard entities (XZ plane, Y-up).
|
||||
|
|
@ -174,18 +174,34 @@ pub(super) struct H7CAD {
|
|||
/// Active tab: 0=Lines, 1=Arrows, 2=Text, 3=Scale/Units, 4=Tolerances.
|
||||
dimstyle_tab: u8,
|
||||
// Edit buffers (strings while typing):
|
||||
ds_dimdle: String, ds_dimdli: String, ds_dimgap: String,
|
||||
ds_dimexe: String, ds_dimexo: String,
|
||||
ds_dimsd1: bool, ds_dimsd2: bool,
|
||||
ds_dimse1: bool, ds_dimse2: bool,
|
||||
ds_dimasz: String, ds_dimcen: String, ds_dimtsz: String,
|
||||
ds_dimtxt: String, ds_dimtxsty: String, ds_dimtad: String,
|
||||
ds_dimtih: bool, ds_dimtoh: bool,
|
||||
ds_dimscale: String, ds_dimlfac: String,
|
||||
ds_dimlunit: String, ds_dimdec: String, ds_dimpost: String,
|
||||
ds_dimtol: bool, ds_dimlim: bool,
|
||||
ds_dimtp: String, ds_dimtm: String,
|
||||
ds_dimtdec: String, ds_dimtfac: String,
|
||||
ds_dimdle: String,
|
||||
ds_dimdli: String,
|
||||
ds_dimgap: String,
|
||||
ds_dimexe: String,
|
||||
ds_dimexo: String,
|
||||
ds_dimsd1: bool,
|
||||
ds_dimsd2: bool,
|
||||
ds_dimse1: bool,
|
||||
ds_dimse2: bool,
|
||||
ds_dimasz: String,
|
||||
ds_dimcen: String,
|
||||
ds_dimtsz: String,
|
||||
ds_dimtxt: String,
|
||||
ds_dimtxsty: String,
|
||||
ds_dimtad: String,
|
||||
ds_dimtih: bool,
|
||||
ds_dimtoh: bool,
|
||||
ds_dimscale: String,
|
||||
ds_dimlfac: String,
|
||||
ds_dimlunit: String,
|
||||
ds_dimdec: String,
|
||||
ds_dimpost: String,
|
||||
ds_dimtol: bool,
|
||||
ds_dimlim: bool,
|
||||
ds_dimtp: String,
|
||||
ds_dimtm: String,
|
||||
ds_dimtdec: String,
|
||||
ds_dimtfac: String,
|
||||
}
|
||||
|
||||
/// What triggered the "unsaved changes" dialog.
|
||||
|
|
@ -200,12 +216,34 @@ pub(super) enum PendingClose {
|
|||
/// Identifies a DimStyle field that can be edited in the dialog.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum DsField {
|
||||
Dimdle, Dimdli, Dimgap, Dimexe, Dimexo,
|
||||
Dimsd1, Dimsd2, Dimse1, Dimse2,
|
||||
Dimasz, Dimcen, Dimtsz,
|
||||
Dimtxt, Dimtxsty, Dimtad, Dimtih, Dimtoh,
|
||||
Dimscale, Dimlfac, Dimlunit, Dimdec, Dimpost,
|
||||
Dimtol, Dimlim, Dimtp, Dimtm, Dimtdec, Dimtfac,
|
||||
Dimdle,
|
||||
Dimdli,
|
||||
Dimgap,
|
||||
Dimexe,
|
||||
Dimexo,
|
||||
Dimsd1,
|
||||
Dimsd2,
|
||||
Dimse1,
|
||||
Dimse2,
|
||||
Dimasz,
|
||||
Dimcen,
|
||||
Dimtsz,
|
||||
Dimtxt,
|
||||
Dimtxsty,
|
||||
Dimtad,
|
||||
Dimtih,
|
||||
Dimtoh,
|
||||
Dimscale,
|
||||
Dimlfac,
|
||||
Dimlunit,
|
||||
Dimdec,
|
||||
Dimpost,
|
||||
Dimtol,
|
||||
Dimlim,
|
||||
Dimtp,
|
||||
Dimtm,
|
||||
Dimtdec,
|
||||
Dimtfac,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -372,7 +410,10 @@ pub enum Message {
|
|||
/// User changed the active lineweight in the Properties toolbar.
|
||||
RibbonLineweightChanged(LineWeight),
|
||||
/// User selected a style from a style combobox in the ribbon.
|
||||
RibbonStyleChanged { key: crate::modules::StyleKey, name: String },
|
||||
RibbonStyleChanged {
|
||||
key: crate::modules::StyleKey,
|
||||
name: String,
|
||||
},
|
||||
|
||||
// ── Properties panel ──────────────────────────────────────────────────
|
||||
/// User selected a layer from the layer pick_list in the Properties panel.
|
||||
|
|
@ -524,7 +565,10 @@ pub enum Message {
|
|||
TextStyleDialogNew,
|
||||
TextStyleDialogDelete,
|
||||
/// Edit a string field (FontFile / Width / Oblique).
|
||||
TextStyleEdit { field: &'static str, value: String },
|
||||
TextStyleEdit {
|
||||
field: &'static str,
|
||||
value: String,
|
||||
},
|
||||
/// Commit edits to the selected text style.
|
||||
TextStyleApply,
|
||||
/// Select a font from the built-in font list.
|
||||
|
|
@ -631,15 +675,15 @@ impl H7CAD {
|
|||
last_point: None,
|
||||
layer_window: None,
|
||||
main_window: None,
|
||||
page_setup_window: None,
|
||||
textstyle_window: None,
|
||||
tablestyle_window: None,
|
||||
mlstyle_window: None,
|
||||
page_setup_window: None,
|
||||
textstyle_window: None,
|
||||
tablestyle_window: None,
|
||||
mlstyle_window: None,
|
||||
layout_manager_window: None,
|
||||
plotstyle_window: None,
|
||||
dimstyle_window: None,
|
||||
shortcuts_window: None,
|
||||
about_window: None,
|
||||
plotstyle_window: None,
|
||||
dimstyle_window: None,
|
||||
shortcuts_window: None,
|
||||
about_window: None,
|
||||
clipboard: Vec::new(),
|
||||
clipboard_centroid: glam::Vec3::ZERO,
|
||||
layout_context_menu: None,
|
||||
|
|
@ -690,22 +734,34 @@ impl H7CAD {
|
|||
// DimStyle dialog
|
||||
dimstyle_selected: "Standard".to_string(),
|
||||
dimstyle_tab: 0,
|
||||
ds_dimdle: "0".to_string(), ds_dimdli: "3.75".to_string(),
|
||||
ds_dimgap: "0.625".to_string(), ds_dimexe: "1.25".to_string(),
|
||||
ds_dimdle: "0".to_string(),
|
||||
ds_dimdli: "3.75".to_string(),
|
||||
ds_dimgap: "0.625".to_string(),
|
||||
ds_dimexe: "1.25".to_string(),
|
||||
ds_dimexo: "0.625".to_string(),
|
||||
ds_dimsd1: false, ds_dimsd2: false,
|
||||
ds_dimse1: false, ds_dimse2: false,
|
||||
ds_dimasz: "0.18".to_string(), ds_dimcen: "0.09".to_string(),
|
||||
ds_dimsd1: false,
|
||||
ds_dimsd2: false,
|
||||
ds_dimse1: false,
|
||||
ds_dimse2: false,
|
||||
ds_dimasz: "0.18".to_string(),
|
||||
ds_dimcen: "0.09".to_string(),
|
||||
ds_dimtsz: "0".to_string(),
|
||||
ds_dimtxt: "0.18".to_string(), ds_dimtxsty: "Standard".to_string(),
|
||||
ds_dimtxt: "0.18".to_string(),
|
||||
ds_dimtxsty: "Standard".to_string(),
|
||||
ds_dimtad: "1".to_string(),
|
||||
ds_dimtih: false, ds_dimtoh: false,
|
||||
ds_dimscale: "1".to_string(), ds_dimlfac: "1".to_string(),
|
||||
ds_dimlunit: "2".to_string(), ds_dimdec: "2".to_string(),
|
||||
ds_dimtih: false,
|
||||
ds_dimtoh: false,
|
||||
ds_dimscale: "1".to_string(),
|
||||
ds_dimlfac: "1".to_string(),
|
||||
ds_dimlunit: "2".to_string(),
|
||||
ds_dimdec: "2".to_string(),
|
||||
ds_dimpost: "<>".to_string(),
|
||||
ds_dimtol: false, ds_dimlim: false,
|
||||
ds_dimtp: "0".to_string(), ds_dimtm: "0".to_string(),
|
||||
ds_dimtdec: "2".to_string(), ds_dimtfac: "1".to_string(),
|
||||
ds_dimtol: false,
|
||||
ds_dimlim: false,
|
||||
ds_dimtp: "0".to_string(),
|
||||
ds_dimtm: "0".to_string(),
|
||||
ds_dimtdec: "2".to_string(),
|
||||
ds_dimtfac: "1".to_string(),
|
||||
};
|
||||
app.sync_ribbon_layers();
|
||||
app
|
||||
|
|
@ -735,18 +791,42 @@ pub fn run() -> iced::Result {
|
|||
iced::daemon(H7CAD::boot, H7CAD::update, H7CAD::view)
|
||||
.subscription(H7CAD::subscription)
|
||||
.title(|state: &H7CAD, window_id: window::Id| {
|
||||
if Some(window_id) == state.layer_window { return "Layer Properties Manager".into(); }
|
||||
if Some(window_id) == state.page_setup_window { return "Page Setup".into(); }
|
||||
if Some(window_id) == state.textstyle_window { return "Text Style".into(); }
|
||||
if Some(window_id) == state.tablestyle_window { return "Table Style".into(); }
|
||||
if Some(window_id) == state.mlstyle_window { return "Multiline Style".into(); }
|
||||
if Some(window_id) == state.layout_manager_window { return "Layout Manager".into(); }
|
||||
if Some(window_id) == state.plotstyle_window { return "Plot Style Table Editor".into(); }
|
||||
if Some(window_id) == state.dimstyle_window { return "Dimension Style Manager".into(); }
|
||||
if Some(window_id) == state.shortcuts_window { return "Keyboard Shortcuts".into(); }
|
||||
if Some(window_id) == state.about_window { return "About H7CAD".into(); }
|
||||
if Some(window_id) == state.unsaved_dialog_window { return "Unsaved Changes".into(); }
|
||||
if Some(window_id) == state.save_dialog_window { return "Save As".into(); }
|
||||
if Some(window_id) == state.layer_window {
|
||||
return "Layer Properties Manager".into();
|
||||
}
|
||||
if Some(window_id) == state.page_setup_window {
|
||||
return "Page Setup".into();
|
||||
}
|
||||
if Some(window_id) == state.textstyle_window {
|
||||
return "Text Style".into();
|
||||
}
|
||||
if Some(window_id) == state.tablestyle_window {
|
||||
return "Table Style".into();
|
||||
}
|
||||
if Some(window_id) == state.mlstyle_window {
|
||||
return "Multiline Style".into();
|
||||
}
|
||||
if Some(window_id) == state.layout_manager_window {
|
||||
return "Layout Manager".into();
|
||||
}
|
||||
if Some(window_id) == state.plotstyle_window {
|
||||
return "Plot Style Table Editor".into();
|
||||
}
|
||||
if Some(window_id) == state.dimstyle_window {
|
||||
return "Dimension Style Manager".into();
|
||||
}
|
||||
if Some(window_id) == state.shortcuts_window {
|
||||
return "Keyboard Shortcuts".into();
|
||||
}
|
||||
if Some(window_id) == state.about_window {
|
||||
return "About H7CAD".into();
|
||||
}
|
||||
if Some(window_id) == state.unsaved_dialog_window {
|
||||
return "Unsaved Changes".into();
|
||||
}
|
||||
if Some(window_id) == state.save_dialog_window {
|
||||
return "Save As".into();
|
||||
}
|
||||
if let Some(tab) = state.tabs.get(state.active_tab) {
|
||||
let dot = if tab.dirty { "● " } else { "" };
|
||||
let name = tab.tab_display_name();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use super::helpers::{entity_type_key, entity_type_label, title_case_word};
|
||||
use super::{H7CAD, VARIES_LABEL};
|
||||
use super::helpers::{entity_type_label, entity_type_key, title_case_word};
|
||||
use crate::linetypes;
|
||||
use crate::scene::dispatch;
|
||||
use crate::ui;
|
||||
use crate::linetypes;
|
||||
use acadrust::{EntityType, Handle};
|
||||
|
||||
impl H7CAD {
|
||||
|
|
@ -62,28 +62,41 @@ impl H7CAD {
|
|||
.frozen_layers
|
||||
.iter()
|
||||
.filter_map(|&h| {
|
||||
self.tabs[i].scene.document.layers.iter()
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.layers
|
||||
.iter()
|
||||
.find(|l| l.handle == h)
|
||||
.map(|l| l.name.clone())
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Collect available UCS names for the name picker.
|
||||
let ucs_names: Vec<String> = self.tabs[i].scene.document.ucss
|
||||
let ucs_names: Vec<String> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.ucss
|
||||
.iter()
|
||||
.map(|u| u.name.clone())
|
||||
.filter(|n| !n.is_empty())
|
||||
.collect();
|
||||
|
||||
// Current UCS name (resolved from vp.ucs_handle).
|
||||
let current_ucs = self.tabs[i].scene.document.ucss
|
||||
let current_ucs = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.ucss
|
||||
.iter()
|
||||
.find(|u| u.handle == vp.ucs_handle)
|
||||
.map(|u| u.name.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
// Collect available named view names.
|
||||
let view_names: Vec<String> = self.tabs[i].scene.document.views
|
||||
let view_names: Vec<String> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.views
|
||||
.iter()
|
||||
.map(|v| v.name.clone())
|
||||
.filter(|n| !n.is_empty())
|
||||
|
|
@ -122,7 +135,10 @@ impl H7CAD {
|
|||
|
||||
// Inject DimStyle picker for Dimension entities.
|
||||
if let acadrust::EntityType::Dimension(_) = entity {
|
||||
let dim_style_names: Vec<String> = self.tabs[i].scene.document.dim_styles
|
||||
let dim_style_names: Vec<String> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.dim_styles
|
||||
.iter()
|
||||
.map(|s| s.name.clone())
|
||||
.filter(|n| !n.is_empty())
|
||||
|
|
@ -132,7 +148,9 @@ impl H7CAD {
|
|||
// replace/upgrade it to a Choice if we have a list.
|
||||
if let Some(geom) = sections.last_mut() {
|
||||
// Find and replace the style_name EditText with a Choice.
|
||||
if let Some(prop) = geom.props.iter_mut().find(|p| p.field == "style_name") {
|
||||
if let Some(prop) =
|
||||
geom.props.iter_mut().find(|p| p.field == "style_name")
|
||||
{
|
||||
let current = match &prop.value {
|
||||
crate::scene::object::PropValue::EditText(s) => s.clone(),
|
||||
_ => String::new(),
|
||||
|
|
@ -247,7 +265,11 @@ impl H7CAD {
|
|||
let is_paper = self.tabs[i].scene.current_layout != "Model";
|
||||
// Paper-space entity coordinates are NOT offset by world_offset (same rule
|
||||
// as wire tessellation in wires_for_block). Only subtract in model space.
|
||||
let wo = if is_paper { [0.0f64; 3] } else { self.tabs[i].scene.world_offset };
|
||||
let wo = if is_paper {
|
||||
[0.0f64; 3]
|
||||
} else {
|
||||
self.tabs[i].scene.world_offset
|
||||
};
|
||||
let (new_handle, new_grips) = {
|
||||
let selected = self.tabs[i].scene.selected_entities();
|
||||
if selected.len() == 1 {
|
||||
|
|
@ -320,7 +342,11 @@ impl H7CAD {
|
|||
.entities()
|
||||
.filter_map(|e| {
|
||||
if let acadrust::EntityType::Viewport(v) = e {
|
||||
if v.common.owner_handle == layout_block { Some(v.id) } else { None }
|
||||
if v.common.owner_handle == layout_block {
|
||||
Some(v.id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
@ -404,13 +430,17 @@ fn merge_sections(
|
|||
) -> Vec<crate::scene::object::PropSection> {
|
||||
left.iter()
|
||||
.filter_map(|section| {
|
||||
let rhs = right.iter().find(|candidate| candidate.title == section.title)?;
|
||||
let rhs = right
|
||||
.iter()
|
||||
.find(|candidate| candidate.title == section.title)?;
|
||||
let props: Vec<crate::scene::object::Property> = section
|
||||
.props
|
||||
.iter()
|
||||
.filter_map(|prop| {
|
||||
let other =
|
||||
rhs.props.iter().find(|candidate| candidate.field == prop.field)?;
|
||||
let other = rhs
|
||||
.props
|
||||
.iter()
|
||||
.find(|candidate| candidate.field == prop.field)?;
|
||||
Some(crate::scene::object::Property {
|
||||
label: prop.label.clone(),
|
||||
field: prop.field,
|
||||
|
|
@ -475,8 +505,7 @@ fn merge_prop_value(
|
|||
(
|
||||
PropValue::BoolToggle { field, .. },
|
||||
PropValue::BoolToggle {
|
||||
field: other_field,
|
||||
..
|
||||
field: other_field, ..
|
||||
},
|
||||
) if field == other_field => PropValue::ReadOnly(VARIES_LABEL.into()),
|
||||
_ => left.clone(),
|
||||
|
|
|
|||
1545
src/app/update.rs
1545
src/app/update.rs
File diff suppressed because it is too large
Load diff
912
src/app/view.rs
912
src/app/view.rs
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue