fix(plot): correct style mode behavior (#874)

This commit is contained in:
Hakan Seven 2026-08-25 18:08:52 +03:00
commit 47612fd662
23 changed files with 108 additions and 23 deletions

View file

@ -203,11 +203,15 @@ impl OpenCADStudio {
})
.unwrap_or_else(|| "ByLayer".to_string())
};
let plot_style = match header.current_plotstyle_type {
1 => "ByBlock",
2 => "ByColor",
3 => "ByObject",
_ => "ByLayer",
let plot_style = if header.plotstyle_mode {
"ByColor"
} else {
match header.current_plotstyle_type {
1 => "ByBlock",
2 => "Normal",
3 => "ByObject",
_ => "ByLayer",
}
};
let layout_plot_table = doc.objects.values().find_map(|object| {
let acadrust::objects::ObjectType::Layout(layout) = object else {
@ -316,7 +320,7 @@ impl OpenCADStudio {
Property {
label: t!("Plot style").into_owned(),
field: "plot_style",
value: if header.plotstyle_mode {
value: if !header.plotstyle_mode {
PropValue::Choice {
selected: plot_style.to_string(),
options: vec![
@ -327,7 +331,7 @@ impl OpenCADStudio {
}
} else {
PropValue::ReadOnlyWithTooltip {
value: plot_style.to_string(),
value: t!("ByColor").into_owned(),
tooltip: t!("Plot style is locked to color in Color-Dependent (CTB) mode").into_owned(),
}
},
@ -344,9 +348,9 @@ impl OpenCADStudio {
read_only(
t!("Plot table type").as_ref(),
if header.plotstyle_mode {
"Named plot styles".to_string()
t!("Color-dependent plot styles").into_owned()
} else {
"Color-dependent plot styles".to_string()
t!("Named plot styles").into_owned()
},
),
],
@ -746,11 +750,7 @@ impl OpenCADStudio {
}
}
// In named plot-style mode (PSTYLEMODE=1) the Plot style row
// picks a named style from the drawing's plot style table. In
// the color-dependent mode it stays read-only (the object's
// color drives the plot style), so it is left untouched.
if self.tabs[i].scene.document.header.plotstyle_mode {
if !self.tabs[i].scene.document.header.plotstyle_mode {
let doc = &self.tabs[i].scene.document;
let dict_h = doc.header.acad_plotstylename_dict_handle;
let common = entity.common();
@ -797,15 +797,8 @@ impl OpenCADStudio {
if let Some(row) =
section.props.iter_mut().find(|p| p.field == "plot_style")
{
let common = entity.common();
let plot_style_str = match common.plotstyle_flags {
0 => "ByLayer",
1 => "ByBlock",
2 => "Normal",
_ => "ByColor",
};
row.value = crate::scene::model::object::PropValue::ReadOnlyWithTooltip {
value: plot_style_str.to_string(),
value: t!("ByColor").into_owned(),
tooltip: t!("Plot style is locked to color in Color-Dependent (CTB) mode").into_owned(),
};
}

View file

@ -2169,6 +2169,10 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
}
}
} else if field == "plot_style" {
if self.tabs[i].scene.document.header.plotstyle_mode {
self.refresh_properties();
return Task::none();
}
// Named plot-style pick: ByLayer / ByBlock clear the
// handle; a named style resolves through the drawing's
// ACAD_PLOTSTYLENAME dictionary to its placeholder handle.
@ -2349,11 +2353,15 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
self.refresh_properties();
}
"plot_style" => {
if self.tabs[i].scene.document.header.plotstyle_mode {
self.refresh_properties();
return Task::none();
}
match value.as_str() {
"ByBlock" => {
self.tabs[i].scene.document.header.current_plotstyle_type = 1
}
"Normal" | "ByColor" => {
"Normal" => {
self.tabs[i].scene.document.header.current_plotstyle_type = 2
}
_ => self.tabs[i].scene.document.header.current_plotstyle_type = 0,

View file

@ -478,6 +478,7 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
"By layer" => Some(("common", "by-layer")),
"By style" => Some(("properties", "by-style")),
"ByBlock" => Some(("common", "byblock")),
"ByColor" => Some(("common", "bycolor")),
"ByLayer" => Some(("common", "bylayer")),
"C++ Class" => Some(("properties", "c-class")),
"CAD application for Architecture & Engineering" => Some(("ui", "cad-application-for-architecture-engineering")),
@ -618,6 +619,7 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
"Collapsed" => Some(("ui", "collapsed")),
"Collect Leaders" => Some(("annotate", "collect-leaders")),
"Color" => Some(("common", "color")),
"Color-dependent plot styles" => Some(("properties", "color-dependent-plot-styles")),
"Color 1" => Some(("properties", "color-1")),
"Color 2" => Some(("properties", "color-2")),
"Color Book" => Some(("properties", "color-book")),
@ -1706,6 +1708,7 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
"Name:" => Some(("common", "name-label-title-case")),
"Named" => Some(("view", "named")),
"Named View" => Some(("properties", "named-view")),
"Named plot styles" => Some(("properties", "named-plot-styles")),
"Named views: {}" => Some(("layers", "named-views")),
"Navigate" => Some(("view", "navigate")),
"Nearest" => Some(("common", "nearest")),
@ -1992,6 +1995,7 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
"Plot scale" => Some(("plot", "plot-scale")),
"Plot stamp" => Some(("plot", "plot-stamp")),
"Plot style" => Some(("common", "plot-style")),
"Plot style is locked to color in Color-Dependent (CTB) mode" => Some(("properties", "plot-style-is-locked-to-color-in-color-dependent")),
"Plot style '{}' loaded ({} color entries)." => Some(("common", "plot-style-loaded-color-entries")),
"Plot style ACI {aci} updated." => Some(("file", "plot-style-aci-aci-updated")),
"Plot style table" => Some(("properties", "plot-style-table")),