forked from 1b-agent/opencadstudio-upstream
Merge pull request #1447 from ramox81:codex/diameter-constraint-parity
#1447 branched from the same commit as #1443 and rewrote the radial dimensional constraint a second time, so the two designs had to be reconciled rather than stacked. #1447's is the one kept: it covers DCRADIUS and DCDIAMETER through one command, places the dimension by the direction the location was picked in rather than storing a text point, and names the parameters `radN` / `diaN`. #1443's radial command result, its entity builder call and its follow-up code are gone; its own independent work stays — the ribbon's small-button grid and tool descriptions, the magnitude reading of a negative radius, and the centre anchor a parameter edit resizes a circle about. The DIMCONSTRAINT default follows #1443: running DCRADIUS or DCDIAMETER directly leaves it alone, and the Dispatch arm sets it when DIMCONSTRAINT is what asked for the command. The second commit's radial drawing — the dimension line broken around the text, the elbowed leader, the centre-mark and arrowhead rules — applied to every radius and diameter dimension, not just a constraint's, and three layout-parity tests said the old layout was the measured one. It is now scoped to a dimensional constraint's own dimension, as #1443 scoped its version, and ordinary radial dimensions draw as they did. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
commit
889a19c362
9 files changed
+706
-415
No files matched your search
@@ -87,6 +87,25 @@ impl DiameterDimensionCommand {
|
||||
}
|
||||
}
|
||||
|
||||
/// A diameter dimension for a dimensional constraint: the dimension line
|
||||
/// runs through the centre towards `location`, and the style places the
|
||||
/// text.
|
||||
pub(crate) fn diameter_constraint_entity(
|
||||
center: DVec3,
|
||||
radius: f64,
|
||||
location: DVec3,
|
||||
text: Option<String>,
|
||||
) -> Option<EntityType> {
|
||||
let direction = super::radius_dim::radial_direction(center, location)?;
|
||||
let chord = center + direction * radius;
|
||||
let far_chord = center - direction * radius;
|
||||
let mut dim = DimensionDiameter::new(v3(chord), v3(far_chord));
|
||||
dim.leader_length = chord.distance(location).max(radius * 0.5);
|
||||
dim.base.actual_measurement = dim.measurement();
|
||||
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
||||
Some(EntityType::Dimension(Dimension::Diameter(dim)))
|
||||
}
|
||||
|
||||
impl CadCommand for DiameterDimensionCommand {
|
||||
fn set_working_plane(&mut self, _plane: WorkingPlane) {
|
||||
}
|
||||
|
||||
@@ -96,6 +96,31 @@ pub(crate) fn radial_dimension_entity(
|
||||
plane.place_entity(EntityType::Dimension(Dimension::Radius(dim)))
|
||||
}
|
||||
|
||||
/// A radius dimension for a dimensional constraint: the leader leaves the
|
||||
/// centre towards `location`, and the style places the text.
|
||||
pub(crate) fn radius_constraint_entity(
|
||||
center: DVec3,
|
||||
radius: f64,
|
||||
location: DVec3,
|
||||
text: Option<String>,
|
||||
) -> Option<EntityType> {
|
||||
let direction = radial_direction(center, location)?;
|
||||
let chord = center + direction * radius;
|
||||
let mut dim = DimensionRadius::new(v3(center), v3(chord));
|
||||
dim.base.definition_point = v3(chord);
|
||||
dim.leader_length = chord.distance(location).max(radius * 0.5);
|
||||
dim.base.actual_measurement = dim.measurement();
|
||||
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
||||
Some(EntityType::Dimension(Dimension::Radius(dim)))
|
||||
}
|
||||
|
||||
/// The unit direction a radial constraint's dimension points in, from the
|
||||
/// centre to where its dimension line was picked.
|
||||
pub(crate) fn radial_direction(center: DVec3, location: DVec3) -> Option<DVec3> {
|
||||
let delta = location - center;
|
||||
(delta.length() > 1.0e-9).then(|| delta.normalize())
|
||||
}
|
||||
|
||||
impl CadCommand for RadiusDimensionCommand {
|
||||
fn set_working_plane(&mut self, _plane: WorkingPlane) {
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user