forked from 1b-agent/opencadstudio-upstream
Complete jogged radius dimension workflow
This commit is contained in:
1 parent
bbd58eb9f2
commit
5a9894fd3e
11 files changed
+664
-85
No files matched your search
+11
-43
@@ -48,6 +48,17 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
|
||||
}
|
||||
|
||||
"DIMJOGGED" | "DIMJOG" => {
|
||||
use crate::modules::annotate::jogged_radius_dim::JoggedRadiusDimensionCommand;
|
||||
let defaults = crate::scene::creation_style::current_dimension_defaults(
|
||||
&self.tabs[i].scene.document,
|
||||
);
|
||||
let multiplier = self.tabs[i].scene.creation_annotation_multiplier();
|
||||
let new_cmd = JoggedRadiusDimensionCommand::new(defaults, multiplier);
|
||||
self.command_line.push_info(&new_cmd.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
|
||||
}
|
||||
|
||||
"DIMANGULAR" => {
|
||||
use crate::modules::annotate::angular_dim::AngularDimensionCommand;
|
||||
let new_cmd = AngularDimensionCommand::new();
|
||||
@@ -1289,49 +1300,6 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
|
||||
}
|
||||
|
||||
// DIMJOGGED <DJO> — create a jogged radius dimension on the selected
|
||||
// arc/circle: a standard radius dim carrying an OCS_JOGGED XData marker
|
||||
// that the geometry generator renders with a foreshortened zig-zag.
|
||||
"DIMJOGGED" | "DIMJOG" => {
|
||||
use acadrust::entities::{Dimension, DimensionRadius};
|
||||
use acadrust::types::Vector3;
|
||||
use acadrust::xdata::{ExtendedDataRecord, XDataValue};
|
||||
let found =
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
.find_map(|(_, e)| match e {
|
||||
acadrust::EntityType::Arc(a) => Some((a.center, a.radius)),
|
||||
acadrust::EntityType::Circle(c) => Some((c.center, c.radius)),
|
||||
_ => None,
|
||||
});
|
||||
let Some((center, radius)) = found else {
|
||||
self.command_line
|
||||
.push_error(crate::t!("DIMJOGGED: select an arc or circle first.").as_ref());
|
||||
return None;
|
||||
};
|
||||
if radius <= 0.0 {
|
||||
self.command_line.push_error(crate::t!("DIMJOGGED: invalid radius.").as_ref());
|
||||
return None;
|
||||
}
|
||||
let k = std::f64::consts::FRAC_1_SQRT_2;
|
||||
let arc_point =
|
||||
Vector3::new(center.x + radius * k, center.y + radius * k, center.z);
|
||||
let mut dim = DimensionRadius::new(center, arc_point);
|
||||
dim.base.common.layer = self.tabs[i].active_layer.clone();
|
||||
let mut rec = ExtendedDataRecord::new("OCS_JOGGED");
|
||||
rec.add_value(XDataValue::String("1".to_string()));
|
||||
dim.base.common.extended_data.add_record(rec);
|
||||
self.push_undo_snapshot(i, "DIMJOGGED");
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.add_entity(acadrust::EntityType::Dimension(Dimension::Radius(dim)));
|
||||
self.tabs[i].dirty = true;
|
||||
self.command_line
|
||||
.push_output(crate::t!("DIMJOGGED: created a jogged radius dimension.").as_ref());
|
||||
}
|
||||
|
||||
// ARCTEXT <text> — lay the text out as one Text entity per character
|
||||
// along the selected arc, each rotated to follow the tangent.
|
||||
"ARCTEXT" => {
|
||||
|
||||
+23
-16
@@ -1030,22 +1030,19 @@ impl OpenCADStudio {
|
||||
if !dim_style_names.is_empty() {
|
||||
// Current style is already shown as text in the geom section;
|
||||
// replace/upgrade it to a Choice if we have a list.
|
||||
if let Some(geom) = sections.last_mut() {
|
||||
// Replace the style name with a choice.
|
||||
if let Some(prop) =
|
||||
geom.props.iter_mut().find(|p| p.field == "style_name")
|
||||
{
|
||||
let current = match &prop.value {
|
||||
crate::scene::model::object::PropValue::PlainText(s) => {
|
||||
s.clone()
|
||||
}
|
||||
_ => String::new(),
|
||||
};
|
||||
prop.value = crate::scene::model::object::PropValue::Choice {
|
||||
selected: current,
|
||||
options: dim_style_names,
|
||||
};
|
||||
}
|
||||
if let Some(prop) = sections
|
||||
.iter_mut()
|
||||
.flat_map(|section| section.props.iter_mut())
|
||||
.find(|property| property.field == "style_name")
|
||||
{
|
||||
let current = match &prop.value {
|
||||
crate::scene::model::object::PropValue::PlainText(s) => s.clone(),
|
||||
_ => String::new(),
|
||||
};
|
||||
prop.value = crate::scene::model::object::PropValue::Choice {
|
||||
selected: current,
|
||||
options: dim_style_names,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1065,6 +1062,16 @@ impl OpenCADStudio {
|
||||
&self.tabs[i].scene.document,
|
||||
));
|
||||
|
||||
if matches!(d, acadrust::entities::Dimension::LargeRadial(_)) {
|
||||
if let Some(index) = sections
|
||||
.iter()
|
||||
.position(|section| section.title == t!("Misc").as_ref())
|
||||
{
|
||||
let misc = sections.remove(index);
|
||||
sections.push(misc);
|
||||
}
|
||||
}
|
||||
|
||||
// Prefer entity-level dimension-variable overrides;
|
||||
// fall back to the assigned style values.
|
||||
use crate::entities::dim_override as dov;
|
||||
|
||||
Reference in new issue
Block a user