forked from 1b-agent/opencadstudio-upstream
feat(gradient): align editing and rendering
This commit is contained in:
commit
2a852f4479
37 files changed
+539
-371
No files matched your search
@@ -676,8 +676,9 @@ impl OpenCADStudio {
|
||||
|
||||
"GRADIENT" => {
|
||||
use crate::modules::draw::draw::hatch::GradientCommand;
|
||||
let outlines = self.tabs[i].scene.closed_outlines();
|
||||
let new_cmd = GradientCommand::new(outlines);
|
||||
let outlines = self.tabs[i].scene.hatch_boundary_outlines();
|
||||
let boundary_sources = self.tabs[i].scene.hatch_boundary_sources();
|
||||
let new_cmd = GradientCommand::new(outlines, boundary_sources);
|
||||
self.command_line.push_info(&new_cmd.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
|
||||
}
|
||||
|
||||
@@ -1224,7 +1224,8 @@ impl OpenCADStudio {
|
||||
acadrust::EntityType::Text(_)
|
||||
| acadrust::EntityType::MText(_)
|
||||
| acadrust::EntityType::Insert(_)
|
||||
| acadrust::EntityType::Leader(_) => Some(("annotative", None)),
|
||||
| acadrust::EntityType::Leader(_)
|
||||
| acadrust::EntityType::Hatch(_) => Some(("annotative", None)),
|
||||
acadrust::EntityType::MultiLeader(_) => {
|
||||
Some(("enable_annotation_scale", None))
|
||||
}
|
||||
@@ -1267,7 +1268,8 @@ impl OpenCADStudio {
|
||||
},
|
||||
),
|
||||
acadrust::EntityType::Text(_)
|
||||
| acadrust::EntityType::Insert(_) => set_row_value(
|
||||
| acadrust::EntityType::Insert(_)
|
||||
| acadrust::EntityType::Hatch(_) => set_row_value(
|
||||
&mut sections,
|
||||
"annotative",
|
||||
crate::scene::model::object::PropValue::BoolToggle {
|
||||
|
||||
+76
-25
@@ -1749,33 +1749,84 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
let handles = self.property_target_handles(i);
|
||||
|
||||
if !handles.is_empty() {
|
||||
if matches!(field, "spline_method" | "knot_param" | "cv_frame") {
|
||||
if matches!(
|
||||
field,
|
||||
"spline_method"
|
||||
| "knot_param"
|
||||
| "cv_frame"
|
||||
| "fill_type"
|
||||
| "gradient_type"
|
||||
| "style"
|
||||
| "pattern_type_label"
|
||||
) {
|
||||
let unchanged = handles.iter().all(|handle| {
|
||||
let Some(acadrust::EntityType::Spline(spline)) =
|
||||
self.tabs[i].scene.document.get_entity(*handle)
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
match field {
|
||||
"spline_method" => {
|
||||
value == if crate::entities::spline::shows_fit_points(spline) {
|
||||
"Fit"
|
||||
} else {
|
||||
"Control Vertices"
|
||||
match self.tabs[i].scene.document.get_entity(*handle) {
|
||||
Some(acadrust::EntityType::Spline(spline)) => match field {
|
||||
"spline_method" => {
|
||||
value
|
||||
== if crate::entities::spline::shows_fit_points(spline) {
|
||||
"Fit"
|
||||
} else {
|
||||
"Control Vertices"
|
||||
}
|
||||
}
|
||||
}
|
||||
"knot_param" => {
|
||||
let current = match spline.knot_parameterization {
|
||||
0 => "Chord",
|
||||
1 => "Square Root",
|
||||
2 => "Uniform",
|
||||
_ => "Custom",
|
||||
};
|
||||
value == current
|
||||
}
|
||||
"cv_frame" => {
|
||||
value == if spline.cv_frame_visible { "Show" } else { "Hide" }
|
||||
}
|
||||
"knot_param" => {
|
||||
let current = match spline.knot_parameterization {
|
||||
0 => "Chord",
|
||||
1 => "Square Root",
|
||||
2 => "Uniform",
|
||||
_ => "Custom",
|
||||
};
|
||||
value == current
|
||||
}
|
||||
"cv_frame" => {
|
||||
value
|
||||
== if spline.cv_frame_visible {
|
||||
"Show"
|
||||
} else {
|
||||
"Hide"
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
},
|
||||
Some(acadrust::EntityType::Hatch(hatch)) => match field {
|
||||
"fill_type" => {
|
||||
value
|
||||
== if hatch.gradient_color.is_single_color {
|
||||
"One color"
|
||||
} else {
|
||||
"Two color"
|
||||
}
|
||||
}
|
||||
"gradient_type" => {
|
||||
let (kind, inverted) =
|
||||
crate::scene::model::hatch_model::GradientKind::from_name(
|
||||
&hatch.gradient_color.name,
|
||||
);
|
||||
value == kind.choice_label(inverted)
|
||||
}
|
||||
"style" => {
|
||||
value
|
||||
== match hatch.style {
|
||||
acadrust::entities::HatchStyleType::Normal => "Normal",
|
||||
acadrust::entities::HatchStyleType::Outer => "Outer",
|
||||
acadrust::entities::HatchStyleType::Ignore => "Ignore",
|
||||
}
|
||||
}
|
||||
"pattern_type_label" => {
|
||||
value
|
||||
== match hatch.pattern_type {
|
||||
acadrust::entities::HatchPatternType::Predefined => {
|
||||
"Predefined"
|
||||
}
|
||||
acadrust::entities::HatchPatternType::UserDefined => {
|
||||
"User Defined"
|
||||
}
|
||||
acadrust::entities::HatchPatternType::Custom => "Custom",
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user