mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-19 15:03:05 +00:00
Equal radius and Collinear, and one Equal button that knows what it picked
Port of snaporca 9ec6405e2d. Parity OK: 17 files identical, 8 diverging at their
expected counts (DesignPanel.cpp 32, test_slvs_constraints.cpp 3).
Measured on the CAD-1000-hours corpus: 51.5% of observed CAD time is 2D sketch
work, and dimensioning/constraining alone is 31.9% -- the largest single class.
Two constraints every industrial sketcher has were missing here.
EqualRadius fixes a dead end rather than adding a feature. Picking two circles
and pressing Equal emitted EqualLength, which maps to SLVS_C_EQUAL_LENGTH_LINES
and constrains nothing on a curve: a silent no-op with no error. Equal is now
one button with two meanings, as in Onshape and SolidWorks.
Collinear emits PARALLEL plus PT_LINE_DISTANCE=0 rather than PT_ON_LINE, whose
internal valP param this libslvs port leaves at 0, drifting an already-collinear
pair.
Both types are appended at the END of SketchConstraintType: cereal serializes it
positionally, so inserting elsewhere reinterprets every saved recipe.
VERIFICATION LIMIT, stated rather than implied: this fork's kernel suite could
NOT be run. scripts/CAD/run-kernel-tests.sh fails at CMake configure time on
find_package(assimp), before any source compiles -- a pre-existing deps gap
(snaporca-w80c), not this change. The shared sources are byte-identical to
snaporca's, where the full gate passed: kernel 2588/195 and ALL LADDERS HELD
across all seven rungs.
Also fixes two defects in this fork's scripts/CAD/run-all-checks.sh:
- `cd $(dirname $0)/..` landed in scripts/ instead of the repo root, so every
rung looked for itself under scripts/scripts/. Broken since the script moved
into scripts/CAD/; the three sibling scripts were fixed then and this was
missed, so the gate has not run since.
- C defaulted to snaporca-gui, the OTHER fork's rig container, so this fork's
gate would drive snaporca's app and report green about the wrong binary.
run-kernel-tests.sh:31 documents the identical defect being fixed once
already for the build volume; this is the third instance.
This commit is contained in:
@@ -1520,6 +1520,8 @@ DesignPanel::DesignPanel(wxWindow* parent)
|
||||
cbtn("design_c_perpendicular", _L("Perpendicular"), SketchConstraintType::Perpendicular);
|
||||
cbtn("design_c_coincident", _L("Coincident"), SketchConstraintType::Coincident);
|
||||
cbtn("design_c_equal", _L("Equal length"), SketchConstraintType::EqualLength);
|
||||
cbtn("design_c_equal_radius", _L("Equal radius"), SketchConstraintType::EqualRadius);
|
||||
cbtn("design_c_collinear", _L("Collinear"), SketchConstraintType::Collinear);
|
||||
cbtn("design_c_concentric", _L("Concentric"), SketchConstraintType::Concentric);
|
||||
cbtn("design_c_tangent", _L("Tangent"), SketchConstraintType::Tangent);
|
||||
cbtn("design_c_midpoint", _L("Midpoint"), SketchConstraintType::Midpoint);
|
||||
@@ -7717,18 +7719,27 @@ void DesignPanel::apply_entity_constraint(SketchConstraintType type)
|
||||
};
|
||||
|
||||
CadFeature& feat = m_doc.features[m_constrain_feat];
|
||||
|
||||
auto is_round = [](const SketchEntity& e) {
|
||||
return e.type == SketchEntity::Type::Circle || e.type == SketchEntity::Type::Arc; };
|
||||
|
||||
// One Equal button, two meanings: lines get equal length, curves equal radius.
|
||||
if (type == T::EqualLength && e0 >= 0 && e1 >= 0 &&
|
||||
e0 < int(feat.entities.size()) && e1 < int(feat.entities.size()) &&
|
||||
is_round(feat.entities[e0]) && is_round(feat.entities[e1]))
|
||||
type = T::EqualRadius;
|
||||
|
||||
const bool needs_two = (type == T::Parallel || type == T::Perpendicular ||
|
||||
type == T::EqualLength || type == T::Coincident ||
|
||||
type == T::Concentric || type == T::Tangent ||
|
||||
type == T::Angle || type == T::Midpoint ||
|
||||
type == T::Symmetric);
|
||||
type == T::Symmetric || type == T::EqualRadius ||
|
||||
type == T::Collinear);
|
||||
if (e0 < 0 || e0 >= int(feat.entities.size()) ||
|
||||
(needs_two && (e1 < 0 || e1 >= int(feat.entities.size())))) {
|
||||
fail(needs_two ? _L("Pick two entities first") : _L("Pick an entity first"));
|
||||
return;
|
||||
}
|
||||
auto is_round = [](const SketchEntity& e) {
|
||||
return e.type == SketchEntity::Type::Circle || e.type == SketchEntity::Type::Arc; };
|
||||
|
||||
SketchEntityConstraintDef def;
|
||||
def.type = type;
|
||||
@@ -7832,6 +7843,21 @@ void DesignPanel::apply_entity_constraint(SketchConstraintType type)
|
||||
commit_entity_constraints(defs);
|
||||
return; // multi-def commit done here
|
||||
}
|
||||
case T::EqualRadius: {
|
||||
if (!is_round(feat.entities[e0]) || !is_round(feat.entities[e1])) {
|
||||
fail(_L("Equal radius needs two circles or arcs")); return;
|
||||
}
|
||||
def.ea = e0; def.eb = e1;
|
||||
break;
|
||||
}
|
||||
case T::Collinear: {
|
||||
using ET = SketchEntity::Type;
|
||||
if (feat.entities[e0].type != ET::Line || feat.entities[e1].type != ET::Line) {
|
||||
fail(_L("Collinear needs two lines")); return;
|
||||
}
|
||||
def.ea = e0; def.eb = e1;
|
||||
break;
|
||||
}
|
||||
case T::Fix: {
|
||||
// Anchor the picked entity's reference point to its current coordinate (the
|
||||
// kernel pins it to a fixed reference). A single point — not both endpoints —
|
||||
|
||||
Reference in New Issue
Block a user