Sketcher_Dimension : adds arc-angle mode for arcs.
This commit is contained in:
@@ -1794,10 +1794,19 @@ protected:
|
||||
|
||||
void makeCts_1Circle(bool& selAllowed, Base::Vector2d onSketchPos)
|
||||
{
|
||||
//Radius/diameter. Mode changes in createRadiusDiameterConstrain.
|
||||
restartCommand(QT_TRANSLATE_NOOP("Command", "Add Radius constraint"));
|
||||
createRadiusDiameterConstrain(selCircleArc[0].GeoId, onSketchPos);
|
||||
selAllowed = true;
|
||||
const Part::Geometry* geom = Obj->getGeometry(selCircleArc[0].GeoId);
|
||||
if (availableConstraint == AvailableConstraint::FIRST
|
||||
|| availableConstraint == AvailableConstraint::SECOND) {
|
||||
//Radius/diameter. Mode changes in createRadiusDiameterConstrain.
|
||||
restartCommand(QT_TRANSLATE_NOOP("Command", "Add Radius constraint"));
|
||||
createRadiusDiameterConstrain(selCircleArc[0].GeoId, onSketchPos);
|
||||
selAllowed = true;
|
||||
}
|
||||
if (availableConstraint == AvailableConstraint::THIRD) {
|
||||
restartCommand(QT_TRANSLATE_NOOP("Command", "Add arc angle constraint"));
|
||||
createArcAngleConstrain(selCircleArc[0].GeoId, onSketchPos);
|
||||
availableConstraint = AvailableConstraint::RESET;
|
||||
}
|
||||
}
|
||||
|
||||
void makeCts_2Circle(bool& selAllowed, Base::Vector2d onSketchPos)
|
||||
@@ -2037,9 +2046,10 @@ protected:
|
||||
radius = circle->getRadius();
|
||||
}
|
||||
|
||||
if (isBsplinePole(geom))
|
||||
if (isBsplinePole(geom)) {
|
||||
Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Weight',%d,%f)) ",
|
||||
GeoId, radius);
|
||||
}
|
||||
else {
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/dimensioning");
|
||||
bool dimensioningDiameter = hGrp->GetBool("DimensioningDiameter", true);
|
||||
@@ -2048,8 +2058,10 @@ protected:
|
||||
bool firstCstr = true;
|
||||
if (availableConstraint != AvailableConstraint::FIRST) {
|
||||
firstCstr = false;
|
||||
//This way if key is pressed again it goes back to FIRST
|
||||
availableConstraint = AvailableConstraint::RESET;
|
||||
if (!isArcOfCircle(*geom)) {
|
||||
//This way if key is pressed again it goes back to FIRST
|
||||
availableConstraint = AvailableConstraint::RESET;
|
||||
}
|
||||
}
|
||||
|
||||
if ((firstCstr && dimensioningRadius && !dimensioningDiameter) ||
|
||||
@@ -2213,6 +2225,26 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
void createArcAngleConstrain(int GeoId, Base::Vector2d onSketchPos) {
|
||||
const Part::Geometry* geom = Obj->getGeometry(GeoId);
|
||||
if (isArcOfCircle(*geom)) {
|
||||
|
||||
const auto* arc = static_cast<const Part::GeomArcOfCircle*>(geom);
|
||||
double angle = arc->getAngle(/*EmulateCCWXY=*/true);
|
||||
|
||||
Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Angle',%d,%f))",
|
||||
GeoId, angle);
|
||||
|
||||
const std::vector<Sketcher::Constraint*>& ConStr = Obj->Constraints.getValues();
|
||||
if (isPointOrSegmentFixed(Obj, GeoId) || constraintCreationMode == Reference) {
|
||||
// it is a constraint on a external line, make it non-driving
|
||||
Gui::cmdAppObjectArgs(Obj, "setDriving(%i,%s)", ConStr.size() - 1, "False");
|
||||
}
|
||||
numberOfConstraintsCreated++;
|
||||
moveConstraint(ConStr.size() - 1, onSketchPos);
|
||||
}
|
||||
}
|
||||
|
||||
void createVerticalConstrain(int GeoId1, Sketcher::PointPos PosId1, int GeoId2, Sketcher::PointPos PosId2) {
|
||||
if (selLine.size() == 1) {
|
||||
Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Vertical',%d)) ", GeoId1);
|
||||
|
||||
Reference in New Issue
Block a user