forked from 1b-agent/opencadstudio-upstream
Separate spline fit and control properties
This commit is contained in:
1 parent
1a6b61fb3a
commit
96e8d75cc5
3 files changed
+35
-9
No files matched your search
@@ -121,10 +121,12 @@ impl OpenCADStudio {
|
|||||||
acadrust::EntityType::LwPolyline(polyline) => Some(polyline.vertices.len()),
|
acadrust::EntityType::LwPolyline(polyline) => Some(polyline.vertices.len()),
|
||||||
acadrust::EntityType::Polyline2D(polyline) => Some(polyline.vertices.len()),
|
acadrust::EntityType::Polyline2D(polyline) => Some(polyline.vertices.len()),
|
||||||
acadrust::EntityType::Leader(leader) => Some(leader.vertices.len()),
|
acadrust::EntityType::Leader(leader) => Some(leader.vertices.len()),
|
||||||
acadrust::EntityType::Spline(spline) => Some(if spline.fit_points.is_empty() {
|
acadrust::EntityType::Spline(spline) => Some(if !spline.cv_frame_visible
|
||||||
spline.control_points.len()
|
&& !spline.fit_points.is_empty()
|
||||||
} else {
|
{
|
||||||
spline.fit_points.len()
|
spline.fit_points.len()
|
||||||
|
} else {
|
||||||
|
crate::entities::spline::control_vertex_count(spline)
|
||||||
}),
|
}),
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2138,7 +2138,9 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
|||||||
(
|
(
|
||||||
"current_control_point",
|
"current_control_point",
|
||||||
acadrust::EntityType::Spline(spline),
|
acadrust::EntityType::Spline(spline),
|
||||||
) => Some(spline.control_points.len()),
|
) => Some(
|
||||||
|
crate::entities::spline::control_vertex_count(spline),
|
||||||
|
),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
+27
-5
@@ -575,6 +575,14 @@ fn control_vertices(spline: &Spline) -> Vec<acadrust::types::Vector3> {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn control_vertex_count(spline: &Spline) -> usize {
|
||||||
|
if spline.control_points.is_empty() {
|
||||||
|
control_vertices(spline).len()
|
||||||
|
} else {
|
||||||
|
spline.control_points.len()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn choice_prop(
|
fn choice_prop(
|
||||||
label: &str,
|
label: &str,
|
||||||
field: &'static str,
|
field: &'static str,
|
||||||
@@ -776,7 +784,10 @@ fn grips(spline: &Spline) -> Vec<GripDef> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn properties(spline: &Spline) -> Vec<PropSection> {
|
fn properties(spline: &Spline) -> Vec<PropSection> {
|
||||||
let fit_method = !spline.fit_points.is_empty();
|
// The start-grip selector chooses the active editing page. A fit spline
|
||||||
|
// can expose its derived control polygon without replacing its stored fit
|
||||||
|
// data; the first actual control-point edit materializes that same curve.
|
||||||
|
let fit_method = !spline.cv_frame_visible && !spline.fit_points.is_empty();
|
||||||
let method = if fit_method { "Fit" } else { "Control Vertices" };
|
let method = if fit_method { "Fit" } else { "Control Vertices" };
|
||||||
let closed = spline.flags.closed || spline.flags.periodic;
|
let closed = spline.flags.closed || spline.flags.periodic;
|
||||||
let yes_no = |b: bool| if b { "Yes" } else { "No" };
|
let yes_no = |b: bool| if b { "Yes" } else { "No" };
|
||||||
@@ -828,9 +839,10 @@ fn properties(spline: &Spline) -> Vec<PropSection> {
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
let count = spline.control_points.len();
|
let controls = control_vertices(spline);
|
||||||
|
let count = controls.len();
|
||||||
let index = current.min(count.saturating_sub(1));
|
let index = current.min(count.saturating_sub(1));
|
||||||
let point = spline.control_points.get(index);
|
let point = controls.get(index);
|
||||||
let weight = spline.weights.get(index).copied().unwrap_or(1.0);
|
let weight = spline.weights.get(index).copied().unwrap_or(1.0);
|
||||||
vec![
|
vec![
|
||||||
ro(
|
ro(
|
||||||
@@ -950,9 +962,13 @@ fn apply_geom_prop(spline: &mut Spline, field: &str, value: &str) {
|
|||||||
match field {
|
match field {
|
||||||
"spline_method" => {
|
"spline_method" => {
|
||||||
if value == "Fit" {
|
if value == "Fit" {
|
||||||
convert_to_fit_method(spline);
|
if convert_to_fit_method(spline) {
|
||||||
|
spline.cv_frame_visible = false;
|
||||||
|
}
|
||||||
} else if value == "Control Vertices" {
|
} else if value == "Control Vertices" {
|
||||||
convert_to_control_method(spline);
|
if convert_to_control_method(spline) {
|
||||||
|
spline.cv_frame_visible = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -989,6 +1005,12 @@ fn apply_geom_prop(spline: &mut Spline, field: &str, value: &str) {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
if matches!(field, "ctrl_pt_x" | "ctrl_pt_y" | "ctrl_pt_z" | "weight")
|
||||||
|
&& spline.control_points.is_empty()
|
||||||
|
&& !convert_to_control_method(spline)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
let (effective_begin_tangent, effective_end_tangent) = effective_fit_tangents(spline);
|
let (effective_begin_tangent, effective_end_tangent) = effective_fit_tangents(spline);
|
||||||
let Some(v) = parse_f64(value) else { return };
|
let Some(v) = parse_f64(value) else { return };
|
||||||
let control_index = crate::scene::view::dispatch::prop_current_vertex()
|
let control_index = crate::scene::view::dispatch::prop_current_vertex()
|
||||||
|
|||||||
Reference in new issue
Block a user