diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 64bc1cf696..e674731549 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -143,7 +143,7 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr) if (dlg.exec()) { Base::Quantity newQuant = ui_ins_datum.labelEdit->value(); if (newQuant.isQuantity() || (Constr->Type == Sketcher::SnellsLaw && newQuant.isDimensionless())) { - // save the value for the history + // save the value for the history ui_ins_datum.labelEdit->pushToHistory(); double newDatum = newQuant.getValue(); @@ -164,7 +164,7 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr) ConstrNbr, escapedstr.c_str()); } Gui::Command::commitCommand(); - + if (sketch->noRecomputes && sketch->ExpressionEngine.depsAreTouched()) { sketch->ExpressionEngine.execute(); sketch->solve(); @@ -226,13 +226,13 @@ void finishDistanceConstraint(Gui::Command* cmd, Sketcher::SketchObject* sketch, void showNoConstraintBetweenExternal() { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Cannot add a constraint between two external geometries!")); + QObject::tr("Cannot add a constraint between two external geometries!")); } void showNoConstraintBetweenFixedGeometry() { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Cannot add a constraint between two fixed geometries! Fixed geometries involve external geometry, blocked geometry or special points as B-spline knot points.")); + QObject::tr("Cannot add a constraint between two fixed geometries! Fixed geometries involve external geometry, blocked geometry or special points as B-spline knot points.")); } bool SketcherGui::checkBothExternal(int GeoId1, int GeoId2) @@ -252,7 +252,7 @@ bool SketcherGui::checkBothExternalOrConstructionPoints(const Sketcher::SketchOb (GeoId1 < 0 && isConstructionPoint(Obj,GeoId2)) || (GeoId2 < 0 && isConstructionPoint(Obj,GeoId1)); } -bool SketcherGui::isPointOrSegmentFixed(const Sketcher::SketchObject* Obj, int GeoId) +bool SketcherGui::isPointOrSegmentFixed(const Sketcher::SketchObject* Obj, int GeoId) { const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues(); @@ -262,7 +262,7 @@ bool SketcherGui::isPointOrSegmentFixed(const Sketcher::SketchObject* Obj, int G return checkConstraint(vals, Sketcher::Block, GeoId, Sketcher::none) || GeoId <= Sketcher::GeoEnum::RefExt || isConstructionPoint(Obj,GeoId); } -bool SketcherGui::areBothPointsOrSegmentsFixed(const Sketcher::SketchObject* Obj, int GeoId1, int GeoId2) +bool SketcherGui::areBothPointsOrSegmentsFixed(const Sketcher::SketchObject* Obj, int GeoId1, int GeoId2) { const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues(); @@ -361,14 +361,14 @@ bool SketcherGui::IsPointAlreadyOnCurve(int GeoIdCurve, int GeoIdPoint, Sketcher /// commits or aborts as appropriate. The reason is for compatibility reasons with /// other code e.g. "Autoconstraints" in DrawSketchHandler.cpp void SketcherGui::makeTangentToEllipseviaNewPoint(Sketcher::SketchObject* Obj, - const Part::Geometry *geom1, + const Part::Geometry *geom1, const Part::Geometry *geom2, int geoId1, int geoId2 ) { const Part::GeomEllipse *ellipse = static_cast(geom1); - + Base::Vector3d center=ellipse->getCenter(); double majord=ellipse->getMajorRadius(); double minord=ellipse->getMinorRadius(); @@ -381,7 +381,7 @@ void SketcherGui::makeTangentToEllipseviaNewPoint(Sketcher::SketchObject* Obj, else if( geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) center2= (static_cast(geom2))->getCenter(); else if( geom2->getTypeId() == Part::GeomCircle::getClassTypeId()) - center2= (static_cast(geom2))->getCenter(); + center2= (static_cast(geom2))->getCenter(); else if( geom2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) center2= (static_cast(geom2))->getCenter(); @@ -390,8 +390,8 @@ void SketcherGui::makeTangentToEllipseviaNewPoint(Sketcher::SketchObject* Obj, Base::Vector3d PoE = Base::Vector3d(center.x+majord*cos(tapprox)*cos(phi)-minord*sin(tapprox)*sin(phi), center.y+majord*cos(tapprox)*sin(phi)+minord*sin(tapprox)*cos(phi), 0); - - try { + + try { // Add a point Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Point(App.Vector(%f,%f,0)))", Obj->getNameInDocument(), PoE.x,PoE.y); @@ -411,7 +411,7 @@ void SketcherGui::makeTangentToEllipseviaNewPoint(Sketcher::SketchObject* Obj, catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); - + tryAutoRecompute(Obj); return; } @@ -427,25 +427,25 @@ void SketcherGui::makeTangentToEllipseviaNewPoint(Sketcher::SketchObject* Obj, /// commits or aborts as appropriate. The reason is for compatibility reasons with /// other code e.g. "Autoconstraints" in DrawSketchHandler.cpp void SketcherGui::makeTangentToArcOfEllipseviaNewPoint(Sketcher::SketchObject* Obj, - const Part::Geometry *geom1, + const Part::Geometry *geom1, const Part::Geometry *geom2, int geoId1, int geoId2 ) { const Part::GeomArcOfEllipse *aoe = static_cast(geom1); - + Base::Vector3d center=aoe->getCenter(); double majord=aoe->getMajorRadius(); double minord=aoe->getMinorRadius(); double phi=atan2(aoe->getMajorAxisDir().y, aoe->getMajorAxisDir().x); Base::Vector3d center2; - + if( geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) center2= (static_cast(geom2))->getCenter(); else if( geom2->getTypeId() == Part::GeomCircle::getClassTypeId()) - center2= (static_cast(geom2))->getCenter(); + center2= (static_cast(geom2))->getCenter(); else if( geom2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) center2= (static_cast(geom2))->getCenter(); @@ -454,13 +454,13 @@ void SketcherGui::makeTangentToArcOfEllipseviaNewPoint(Sketcher::SketchObject* O Base::Vector3d PoE = Base::Vector3d(center.x+majord*cos(tapprox)*cos(phi)-minord*sin(tapprox)*sin(phi), center.y+majord*cos(tapprox)*sin(phi)+minord*sin(tapprox)*cos(phi), 0); - + try { // Add a point Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Point(App.Vector(%f,%f,0)))", Obj->getNameInDocument(), PoE.x,PoE.y); int GeoIdPoint = Obj->getHighestCurveIndex(); - + // Point on first object Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", Obj->getNameInDocument(),GeoIdPoint,Sketcher::start,geoId1); // constrain major axis @@ -491,14 +491,14 @@ void SketcherGui::makeTangentToArcOfEllipseviaNewPoint(Sketcher::SketchObject* O /// commits or aborts as appropriate. The reason is for compatibility reasons with /// other code e.g. "Autoconstraints" in DrawSketchHandler.cpp void SketcherGui::makeTangentToArcOfHyperbolaviaNewPoint(Sketcher::SketchObject* Obj, - const Part::Geometry *geom1, + const Part::Geometry *geom1, const Part::Geometry *geom2, int geoId1, int geoId2 ) { const Part::GeomArcOfHyperbola *aoh = static_cast(geom1); - + Base::Vector3d center=aoh->getCenter(); double majord=aoh->getMajorRadius(); double minord=aoh->getMinorRadius(); @@ -573,14 +573,14 @@ void SketcherGui::makeTangentToArcOfHyperbolaviaNewPoint(Sketcher::SketchObject* /// commits or aborts as appropriate. The reason is for compatibility reasons with /// other code e.g. "Autoconstraints" in DrawSketchHandler.cpp void SketcherGui::makeTangentToArcOfParabolaviaNewPoint(Sketcher::SketchObject* Obj, - const Part::Geometry *geom1, + const Part::Geometry *geom1, const Part::Geometry *geom2, int geoId1, int geoId2 ) { const Part::GeomArcOfParabola *aop = static_cast(geom1); - + //Base::Vector3d center=aop->getCenter(); //Base::Vector3d dirx = aop->getXAxisDir(); @@ -618,8 +618,8 @@ void SketcherGui::makeTangentToArcOfParabolaviaNewPoint(Sketcher::SketchObject* double tapprox = 4*df*tan(angle);*/ Base::Vector3d PoP = focus + direction / 2; - - + + /*Base::Vector3d(center.x + tapprox * tapprox / 4 / df * cos(phi) - tapprox * sin(phi), center.y + tapprox * tapprox / 4 / df * sin(phi) + tapprox * cos(phi), 0);*/ @@ -655,7 +655,7 @@ void SketcherGui::makeTangentToArcOfParabolaviaNewPoint(Sketcher::SketchObject* std::string SketcherGui::getStrippedPythonExceptionString(const Base::Exception& e) { std::string msg = e.what(); - + if( msg.length() > 26 && msg.substr(0,26) == "FreeCAD exception thrown (") { return msg.substr(26, msg.length()-27); } @@ -671,41 +671,41 @@ bool SketcherGui::tryAutoRecompute(Sketcher::SketchObject* obj, bool &autoremove // We need to make sure the solver has right redundancy information before trying to remove the redundants. // for example if a non-driving constraint has been added. - if(autoRemoveRedundants && autoRecompute) + if(autoRemoveRedundants && autoRecompute) obj->solve(); - + if(autoRemoveRedundants) obj->autoRemoveRedundants(); - + if (autoRecompute) Gui::Command::updateActive(); - + autoremoveredundants = autoRemoveRedundants; - + return autoRecompute; } bool SketcherGui::tryAutoRecompute(Sketcher::SketchObject* obj) { bool autoremoveredundants; - + return tryAutoRecompute(obj,autoremoveredundants); } void SketcherGui::tryAutoRecomputeIfNotSolve(Sketcher::SketchObject* obj) -{ +{ bool autoremoveredundants; - + if(!tryAutoRecompute(obj,autoremoveredundants)) { obj->solve(); - + if(autoremoveredundants) { obj->autoRemoveRedundants(); } } } -bool SketcherGui::checkConstraint(const std::vector< Sketcher::Constraint * > &vals, ConstraintType type, int geoid, PointPos pos) +bool SketcherGui::checkConstraint(const std::vector< Sketcher::Constraint * > &vals, ConstraintType type, int geoid, PointPos pos) { for (std::vector< Sketcher::Constraint * >::const_iterator itc= vals.begin(); itc != vals.end(); ++itc) { if ((*itc)->Type == type && (*itc)->First == geoid && (*itc)->FirstPos == pos){ @@ -722,18 +722,18 @@ void SketcherGui::doEndpointTangency(Sketcher::SketchObject* Obj, Gui::Selection // This code supports simple B-spline endpoint tangency to any other geometric curve const Part::Geometry *geom1 = Obj->getGeometry(GeoId1); const Part::Geometry *geom2 = Obj->getGeometry(GeoId2); - + if (geom1 && geom2 && (geom1->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() || geom2->getTypeId() == Part::GeomBSplineCurve::getClassTypeId())){ - + if(geom1->getTypeId() != Part::GeomBSplineCurve::getClassTypeId()) { std::swap(GeoId1,GeoId2); std::swap(PosId1,PosId2); } // GeoId1 is the B-spline now } // end of code supports simple B-spline endpoint tangency - + Gui::Command::doCommand( Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%d,%d,%d,%d)) ", selection.getFeatName(),GeoId1,PosId1,GeoId2,PosId2); @@ -1220,7 +1220,7 @@ void CmdSketcherConstrainHorizontal::activated(int iMsg) ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(constraintCursor, this)); getSelection().clearSelection(); - } else { + } else { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select an edge from the sketch.")); } @@ -1235,15 +1235,15 @@ void CmdSketcherConstrainHorizontal::activated(int iMsg) std::vector edgegeoids; std::vector pointgeoids; std::vector pointpos; - + int fixedpoints = 0; // go through the selected subelements for (std::vector::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) { int GeoId; Sketcher::PointPos PosId; getIdsFromName((*it), Obj, GeoId, PosId); - - + + if (isEdge(GeoId,PosId)) {// it is an edge const Part::Geometry *geo = Obj->getGeometry(GeoId); if (geo->getTypeId() != Part::GeomLineSegment::getClassTypeId()) { @@ -1290,7 +1290,7 @@ void CmdSketcherConstrainHorizontal::activated(int iMsg) QObject::tr("The selected item(s) can't accept a horizontal constraint!")); return; } - + // if there is at least one edge selected, ignore the point alignment functionality if (!edgegeoids.empty()) { // undo command open @@ -1482,15 +1482,15 @@ void CmdSketcherConstrainVertical::activated(int iMsg) std::vector edgegeoids; std::vector pointgeoids; std::vector pointpos; - + int fixedpoints = 0; // go through the selected subelements for (std::vector::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) { int GeoId; Sketcher::PointPos PosId; getIdsFromName((*it), Obj, GeoId, PosId); - - + + if (isEdge(GeoId,PosId)) {// it is an edge const Part::Geometry *geo = Obj->getGeometry(GeoId); if (geo->getTypeId() != Part::GeomLineSegment::getClassTypeId()) { @@ -1498,7 +1498,7 @@ void CmdSketcherConstrainVertical::activated(int iMsg) QObject::tr("The selected edge is not a line segment")); return; } - + // check if the edge has already a Horizontal/Vertical/Block constraint for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); it != vals.end(); ++it) { @@ -1726,14 +1726,14 @@ void CmdSketcherConstrainLock::activated(int iMsg) std::vector GeoId; std::vector PosId; - + for (std::vector::const_iterator it = SubNames.begin(); it != SubNames.end(); ++it) { int GeoIdt; Sketcher::PointPos PosIdt; getIdsFromName((*it), Obj, GeoIdt, PosIdt); GeoId.push_back(GeoIdt); PosId.push_back(PosIdt); - + if ((it != std::prev(SubNames.end()) && (isEdge(GeoIdt,PosIdt) || (GeoIdt < 0 && GeoIdt >= Sketcher::GeoEnum::VAxis))) || (it == std::prev(SubNames.end()) && isEdge(GeoIdt,PosIdt)) ) { if(selection.size() == 1) { @@ -1749,7 +1749,7 @@ void CmdSketcherConstrainLock::activated(int iMsg) return; } } - + int lastconstraintindex = Obj->Constraints.getSize()-1; if( GeoId.size() == 1 ) { // absolute mode @@ -1925,7 +1925,7 @@ static const char *cursor_createblock[]={ ".............###########........", ".............##########.........", ".............########...........", - ".............#######............", + ".............#######............", ".............########...........", ".............##########.........", ".............###########........", @@ -1936,7 +1936,7 @@ static const char *cursor_createblock[]={ "....................##..........", ".................###............", "................................"}; - + class CmdSketcherConstrainBlock : public CmdSketcherConstraint { public: @@ -1967,16 +1967,16 @@ CmdSketcherConstrainBlock::CmdSketcherConstrainBlock() void CmdSketcherConstrainBlock::activated(int iMsg) { - Q_UNUSED(iMsg); - + Q_UNUSED(iMsg); + // get the selection std::vector selection = getSelection().getSelectionEx(); - + // only one sketch with its subelements are allowed to be selected if (selection.size() != 1 || !selection[0].isObjectTypeOf(Sketcher::SketchObject::getClassTypeId())) { ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); - + if (constraintMode) { ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(constraintCursor, this)); @@ -1991,7 +1991,7 @@ void CmdSketcherConstrainBlock::activated(int iMsg) // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - + // Check that the solver does not report redundant/conflicting constraints if(Obj->getLastSolverStatus()!=GCS::Success || Obj->getLastHasConflicts() || Obj->getLastHasRedundancies()) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong solver status"), @@ -2077,7 +2077,7 @@ void CmdSketcherConstrainBlock::applyConstraint(std::vector &selSeq, QObject::tr("The selected edge has already a Block constraint!")); return; } - + // undo command open openCommand("add block constraint"); @@ -2344,7 +2344,7 @@ void CmdSketcherConstrainCoincident::activated(int iMsg) int j=0; for (std::vector::const_iterator it = cvals.begin(); it != cvals.end(); ++it,++j) { - if( (*it)->Type == Sketcher::Tangent && + if( (*it)->Type == Sketcher::Tangent && (*it)->FirstPos == Sketcher::none && (*it)->SecondPos == Sketcher::none && (*it)->Third == Constraint::GeoUndef && (((*it)->First == GeoId1 && (*it)->Second == GeoId2) || @@ -2357,7 +2357,7 @@ void CmdSketcherConstrainCoincident::activated(int iMsg) Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.delConstraintOnPoint(%i,%i)", selection[0].getFeatName(), GeoId1, PosId1); } - + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.delConstraint(%i)" ,selection[0].getFeatName(), j); @@ -2367,7 +2367,7 @@ void CmdSketcherConstrainCoincident::activated(int iMsg) tryAutoRecomputeIfNotSolve(Obj); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General"); - + if(hGrp->GetBool("NotifyConstraintSubstitutions", true)) { QMessageBox::information(Gui::getMainWindow(), QObject::tr("Constraint Substitution"), QObject::tr("Endpoint to endpoint tangency was applied instead.")); @@ -2511,7 +2511,7 @@ void CmdSketcherConstrainDistance::activated(int iMsg) getIdsFromName(SubNames[1], Obj, GeoId2, PosId2); bool arebothpointsorsegmentsfixed=areBothPointsOrSegmentsFixed(Obj,GeoId1, GeoId2); - + if (isVertex(GeoId1,PosId1) && (GeoId2 == Sketcher::GeoEnum::VAxis || GeoId2 == Sketcher::GeoEnum::HAxis)) { std::swap(GeoId1,GeoId2); std::swap(PosId1,PosId2); @@ -2581,14 +2581,14 @@ void CmdSketcherConstrainDistance::activated(int iMsg) if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else finishDistanceConstraint(this, Obj,true); - + return; } } @@ -2605,23 +2605,23 @@ void CmdSketcherConstrainDistance::activated(int iMsg) if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { const Part::GeomLineSegment *lineSeg; lineSeg = static_cast(geom); - double ActLength = (lineSeg->getEndPoint()-lineSeg->getStartPoint()).Length(); + double ActLength = (lineSeg->getEndPoint()-lineSeg->getStartPoint()).Length(); openCommand("add length constraint"); Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Distance',%d,%f)) ", selection[0].getFeatName(),GeoId1,ActLength); - + if (arebothpointsorsegmentsfixed || GeoId1 <= Sketcher::GeoEnum::RefExt || isConstructionPoint(Obj,GeoId1) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else finishDistanceConstraint(this, Obj,true); - + return; } } @@ -3098,7 +3098,7 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg) QObject::tr("Cannot add a horizontal length constraint on an axis!")); return; } - + arebothpointsorsegmentsfixed = isPointOrSegmentFixed(Obj,GeoId1); const Part::Geometry *geom = Obj->getGeometry(GeoId1); @@ -3130,7 +3130,7 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg) if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); @@ -3157,18 +3157,18 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg) Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%f)) ", selection[0].getFeatName(),GeoId1,PosId1,ActX); - + if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else finishDistanceConstraint(this, Obj,true); - + return; } @@ -3328,7 +3328,7 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg) getIdsFromName(SubNames[1], Obj, GeoId2, PosId2); bool arebothpointsorsegmentsfixed=areBothPointsOrSegmentsFixed(Obj,GeoId1, GeoId2); - + if (GeoId2 == Sketcher::GeoEnum::HAxis || GeoId2 == Sketcher::GeoEnum::VAxis) { std::swap(GeoId1,GeoId2); std::swap(PosId1,PosId2); @@ -3345,7 +3345,7 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg) QObject::tr("Cannot add a vertical length constraint on an axis!")); return; } - + arebothpointsorsegmentsfixed = isPointOrSegmentFixed(Obj,GeoId1); const Part::Geometry *geom = Obj->getGeometry(GeoId1); @@ -3378,14 +3378,14 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg) if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else finishDistanceConstraint(this, Obj,true); - + return; } else if (isVertex(GeoId1,PosId1) && GeoId2 == Constraint::GeoUndef) { // point on fixed y-coordinate @@ -3408,14 +3408,14 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg) if (GeoId1 <= Sketcher::GeoEnum::RefExt || isConstructionPoint(Obj,GeoId1) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else finishDistanceConstraint(this, Obj,true); - + return; } @@ -3649,7 +3649,7 @@ void CmdSketcherConstrainParallel::activated(int iMsg) } // finish the transaction and update commitCommand(); - + tryAutoRecompute(Obj); // clear the selection (convenience) @@ -3676,7 +3676,7 @@ void CmdSketcherConstrainParallel::applyConstraint(std::vector &selSe QObject::tr("The selected edge is not a valid line")); return; } - + if( areBothPointsOrSegmentsFixed(Obj,GeoId1, GeoId2)) { showNoConstraintBetweenFixedGeometry(); return; @@ -3898,7 +3898,7 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) QObject::tr("Cannot add a perpendicularity constraint at an unconnected point!")); return; } - + // This code supports simple B-spline endpoint perp to any other geometric curve const Part::Geometry *geom1 = Obj->getGeometry(GeoId1); const Part::Geometry *geom2 = Obj->getGeometry(GeoId2); @@ -3936,9 +3936,9 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) QObject::tr("Cannot add a perpendicularity constraint at an unconnected point!")); return; } - + const Part::Geometry *geom2 = Obj->getGeometry(GeoId2); - + if( geom2 && geom2->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() ){ // unsupported until normal to B-spline at any point implemented. QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), @@ -3952,7 +3952,7 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) selection[0].getFeatName(),GeoId1,PosId1,GeoId2); commitCommand(); tryAutoRecompute(Obj); - + getSelection().clearSelection(); return; } @@ -3970,10 +3970,10 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) QObject::tr("One of the selected edges should be a line.")); return; } - + if (geo1->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() || geo2->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()){ - + // unsupported until tangent to B-spline at any point implemented. QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Perpendicular to B-spline edge currently unsupported.")); @@ -4041,7 +4041,7 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) if( geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() ) { double df=sqrt(majord*majord+minord*minord); Base::Vector3d direction=point1-(center+majdir*df); // towards the focus - double tapprox=atan2(direction.y,direction.x)-phi; + double tapprox=atan2(direction.y,direction.x)-phi; PoO = Base::Vector3d(center.x+majord*cosh(tapprox)*cos(phi)-minord*sinh(tapprox)*sin(phi), center.y+majord*cosh(tapprox)*sin(phi)+minord*sinh(tapprox)*cos(phi), 0); @@ -4101,7 +4101,7 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) selection[0].getFeatName(),GeoId1,GeoId2); commitCommand(); tryAutoRecompute(Obj); - + getSelection().clearSelection(); return; } @@ -4126,7 +4126,7 @@ void CmdSketcherConstrainPerpendicular::applyConstraint(std::vector & showNoConstraintBetweenFixedGeometry(); return; } - + switch (seqIndex) { case 0: // {SelEdge, SelEdgeOrAxis} case 1: // {SelEdgeOrAxis, SelEdge} @@ -4437,8 +4437,6 @@ void CmdSketcherConstrainTangent::activated(int iMsg) return; } - - int GeoId1, GeoId2, GeoId3; Sketcher::PointPos PosId1, PosId2, PosId3; @@ -4500,7 +4498,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg) commitCommand(); tryAutoRecompute(Obj); - + getSelection().clearSelection(); return; @@ -4539,9 +4537,9 @@ void CmdSketcherConstrainTangent::activated(int iMsg) QObject::tr("Cannot add a tangency constraint at an unconnected point!")); return; } - + const Part::Geometry *geom2 = Obj->getGeometry(GeoId2); - + if( geom2 && geom2->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() ){ // unsupported until tangent to B-spline at any point implemented. QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), @@ -4555,7 +4553,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg) selection[0].getFeatName(),GeoId1,PosId1,GeoId2); commitCommand(); tryAutoRecompute(Obj); - + getSelection().clearSelection(); return; } @@ -4567,7 +4565,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg) if( geom1 && geom2 && ( geom1->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() || geom2->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() )){ - + // unsupported until tangent to B-spline at any point implemented. QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Tangency to B-spline edge currently unsupported.")); @@ -4598,7 +4596,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg) tryAutoRecomputeIfNotSolve(Obj); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General"); - + if(hGrp->GetBool("NotifyConstraintSubstitutions", true)) { QMessageBox::information(Gui::getMainWindow(), QObject::tr("Constraint Substitution"), QObject::tr("Endpoint to endpoint tangency was applied. The coincident constraint was deleted.")); @@ -4642,6 +4640,35 @@ void CmdSketcherConstrainTangent::activated(int iMsg) return; } } + else if( geom1 && geom2 && + ( geom1->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() || + geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() )){ + + if(geom1->getTypeId() != Part::GeomArcOfEllipse::getClassTypeId()) + std::swap(GeoId1,GeoId2); + + // GeoId1 is the arc of ellipse + geom1 = Obj->getGeometry(GeoId1); + geom2 = Obj->getGeometry(GeoId2); + + if( geom2->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() || + geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() || + geom2->getTypeId() == Part::GeomCircle::getClassTypeId() || + geom2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() || + geom2->getTypeId() == Part::GeomLineSegment::getClassTypeId() ) { + + Gui::Command::openCommand("add tangent constraint point"); + makeTangentToArcOfEllipseviaNewPoint(Obj,geom1,geom2,GeoId1,GeoId2); + getSelection().clearSelection(); + return; + } + else if( geom2->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() ) { + Gui::Command::openCommand("add tangent constraint point"); + makeTangentToArcOfParabolaviaNewPoint(Obj,geom2,geom1,GeoId2,GeoId1); + getSelection().clearSelection(); + return; + } + } else if( geom1 && geom2 && ( geom1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() || geom2->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() )){ @@ -4669,7 +4696,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg) makeTangentToArcOfParabolaviaNewPoint(Obj,geom2,geom1,GeoId2,GeoId1); getSelection().clearSelection(); return; - } + } } else if( geom1 && geom2 && @@ -4727,10 +4754,10 @@ void CmdSketcherConstrainTangent::applyConstraint(std::vector &selSeq // check if the edge has already a Block constraint if ( areBothPointsOrSegmentsFixed(Obj,GeoId1,GeoId2) ) { - showNoConstraintBetweenFixedGeometry(); + showNoConstraintBetweenFixedGeometry(); return; } - + switch (seqIndex) { case 0: // {SelEdge, SelEdgeOrAxis} case 1: // {SelEdgeOrAxis, SelEdge} @@ -5030,7 +5057,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg) // check for which selected geometry the constraint can be applied std::vector< std::pair > geoIdRadiusMap; std::vector< std::pair > externalGeoIdRadiusMap; - + for (std::vector::const_iterator it = SubNames.begin(); it != SubNames.end(); ++it) { bool issegmentfixed = false; int GeoId; @@ -5076,11 +5103,11 @@ void CmdSketcherConstrainRadius::activated(int iMsg) QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select one or more arcs or circles from the sketch.")); } - + bool commitNeeded=false; bool updateNeeded=false; bool commandopened=false; - + if(!externalGeoIdRadiusMap.empty()) { // Create the non-driving radius constraints now openCommand("Add radius constraint"); @@ -5093,11 +5120,11 @@ void CmdSketcherConstrainRadius::activated(int iMsg) selection[0].getFeatName(),it->first,it->second); const std::vector &ConStr = Obj->Constraints.getValues(); - + constrSize=ConStr.size(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", - selection[0].getFeatName(),constrSize-1,"False"); + selection[0].getFeatName(),constrSize-1,"False"); } const std::vector &ConStr = Obj->Constraints.getValues(); @@ -5117,11 +5144,11 @@ void CmdSketcherConstrainRadius::activated(int iMsg) } vp->draw(false,false); // Redraw } - + commitNeeded=true; updateNeeded=true; } - + if(!geoIdRadiusMap.empty()) { bool constrainEqual = false; @@ -5143,14 +5170,14 @@ void CmdSketcherConstrainRadius::activated(int iMsg) // Create the one radius constraint now int refGeoId = geoIdRadiusMap.front().first; double radius = geoIdRadiusMap.front().second; - + if(!commandopened) openCommand("Add radius constraint"); - + Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", selection[0].getFeatName(),refGeoId,radius); - + // Add the equality constraints for (std::vector< std::pair >::iterator it = geoIdRadiusMap.begin()+1; it != geoIdRadiusMap.end(); ++it) { Gui::Command::doCommand( @@ -5170,12 +5197,12 @@ void CmdSketcherConstrainRadius::activated(int iMsg) if(constraintCreationMode==Reference) { const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", - selection[0].getFeatName(),ConStr.size()-1,"False"); - + selection[0].getFeatName(),ConStr.size()-1,"False"); + } - + } } @@ -5243,35 +5270,35 @@ void CmdSketcherConstrainRadius::activated(int iMsg) } commitCommand(); - + if (Obj->noRecomputes && Obj->ExpressionEngine.depsAreTouched()) { Obj->ExpressionEngine.execute(); Obj->solve(); } tryAutoRecompute(Obj); - + commitNeeded=false; updateNeeded=false; } catch (const Base::Exception& e) { QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what())); abortCommand(); - + tryAutoRecomputeIfNotSolve(Obj); // we have to update the solver after this aborted addition. } } else { // command canceled abortCommand(); - + updateNeeded=true; } } else { // now dialog was shown so commit the command commitCommand(); - commitNeeded=false; + commitNeeded=false; } //updateActive(); getSelection().clearSelection(); @@ -5460,7 +5487,7 @@ CmdSketcherConstrainDiameter::CmdSketcherConstrainDiameter() sPixmap = "Constraint_Diameter"; sAccel = ""; eType = ForEdit; - + allowedSelSequences = {{SelEdge}, {SelExternalEdge}}; constraintCursor = cursor_genericconstraint; } @@ -5470,12 +5497,12 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) Q_UNUSED(iMsg); // get the selection std::vector selection = getSelection().getSelectionEx(); - + // only one sketch with its subelements are allowed to be selected if (selection.size() != 1 || !selection[0].isObjectTypeOf(Sketcher::SketchObject::getClassTypeId())) { ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); - + if (constraintMode) { ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(constraintCursor, this)); @@ -5487,25 +5514,25 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) } return; } - + // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - + if (SubNames.empty()) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select one or more arcs or circles from the sketch.")); return; } - + // check for which selected geometry the constraint can be applied std::vector< std::pair > geoIdDiameterMap; std::vector< std::pair > externalGeoIdDiameterMap; - + for (std::vector::const_iterator it = SubNames.begin(); it != SubNames.end(); ++it) { bool issegmentfixed = false; int GeoId; - + if (it->size() > 4 && it->substr(0,4) == "Edge") { GeoId = std::atoi(it->substr(4,4000).c_str()) - 1; issegmentfixed = isPointOrSegmentFixed(Obj,GeoId); @@ -5516,13 +5543,13 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) } else continue; - + const Part::Geometry *geom = Obj->getGeometry(GeoId); if (geom && geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { const Part::GeomArcOfCircle *arc = static_cast(geom); double radius = arc->getRadius(); - + if(issegmentfixed) { externalGeoIdDiameterMap.push_back(std::make_pair(GeoId, 2*radius)); } @@ -5533,7 +5560,7 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) else if (geom && geom->getTypeId() == Part::GeomCircle::getClassTypeId()) { const Part::GeomCircle *circle = static_cast(geom); double radius = circle->getRadius(); - + if(issegmentfixed) { externalGeoIdDiameterMap.push_back(std::make_pair(GeoId, 2*radius)); } @@ -5542,57 +5569,57 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) } } } - + if (geoIdDiameterMap.empty() && externalGeoIdDiameterMap.empty()) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select one or more arcs or circles from the sketch.")); } - + bool commitNeeded=false; bool updateNeeded=false; bool commandopened=false; - + if(!externalGeoIdDiameterMap.empty()) { // Create the non-driving radius constraints now openCommand("Add diameter constraint"); commandopened=true; unsigned int constrSize = 0; - + for (std::vector< std::pair >::iterator it = externalGeoIdDiameterMap.begin(); it != externalGeoIdDiameterMap.end(); ++it) { Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", selection[0].getFeatName(),it->first,it->second); - + const std::vector &ConStr = Obj->Constraints.getValues(); - + constrSize=ConStr.size(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", - selection[0].getFeatName(),constrSize-1,"False"); + selection[0].getFeatName(),constrSize-1,"False"); } - + const std::vector &ConStr = Obj->Constraints.getValues(); - + std::size_t indexConstr = constrSize - externalGeoIdDiameterMap.size(); - + // Guess some reasonable distance for placing the datum text Gui::Document *doc = getActiveGuiDocument(); float sf = 1.f; if (doc && doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) { SketcherGui::ViewProviderSketch *vp = static_cast(doc->getInEdit()); sf = vp->getScaleFactor(); - + for (std::size_t i=0; iLabelDistance = 2. * sf; } vp->draw(false,false); // Redraw } - + commitNeeded=true; updateNeeded=true; } - + if(!geoIdDiameterMap.empty()) { bool constrainEqual = false; @@ -5609,19 +5636,19 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) return; } } - + if (constrainEqual) { // Create the one radius constraint now int refGeoId = geoIdDiameterMap.front().first; double diameter = geoIdDiameterMap.front().second; - + if(!commandopened) openCommand("Add diameter constraint"); - + Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", selection[0].getFeatName(),refGeoId,diameter); - + // Add the equality constraints for (std::vector< std::pair >::iterator it = geoIdDiameterMap.begin()+1; it != geoIdDiameterMap.end(); ++it) { Gui::Command::doCommand( @@ -5637,36 +5664,36 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", selection[0].getFeatName(),it->first,it->second); - + if(constraintCreationMode==Reference) { - + const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", - selection[0].getFeatName(),ConStr.size()-1,"False"); - + selection[0].getFeatName(),ConStr.size()-1,"False"); + } - + } } - + const std::vector &ConStr = Obj->Constraints.getValues(); std::size_t indexConstr = ConStr.size() - geoIdDiameterMap.size(); - + // Guess some reasonable distance for placing the datum text Gui::Document *doc = getActiveGuiDocument(); float sf = 1.f; if (doc && doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) { SketcherGui::ViewProviderSketch *vp = static_cast(doc->getInEdit()); sf = vp->getScaleFactor(); - + for (std::size_t i=0; iLabelDistance = 2. * sf; } vp->draw(false,false); // Redraw } - + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); bool show = hGrp->GetBool("ShowDialogOnDistanceConstraint", true); // Ask for the value of the diameter immediately @@ -5679,24 +5706,24 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) Base::Quantity init_val; init_val.setUnit(Base::Unit::Length); init_val.setValue(geoIdDiameterMap.front().second); - + ui_Datum.labelEdit->setValue(init_val); ui_Datum.labelEdit->selectNumber(); if (constrainEqual || geoIdDiameterMap.size() == 1) ui_Datum.labelEdit->bind(Obj->Constraints.createPath(indexConstr)); else ui_Datum.name->setDisabled(true); - + if (dlg.exec() == QDialog::Accepted) { Base::Quantity newQuant = ui_Datum.labelEdit->value(); double newDiameter = newQuant.getValue(); - + try { if (constrainEqual || geoIdDiameterMap.size() == 1) { doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setDatum(%i,App.Units.Quantity('%f %s'))", Obj->getNameInDocument(), indexConstr, newDiameter, (const char*)newQuant.getUnit().getString().toUtf8()); - + QString constraintName = ui_Datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != Obj->Constraints[indexConstr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); @@ -5712,45 +5739,45 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) indexConstr+i, newDiameter, (const char*)newQuant.getUnit().getString().toUtf8()); } } - + commitCommand(); - + if (Obj->noRecomputes && Obj->ExpressionEngine.depsAreTouched()) { Obj->ExpressionEngine.execute(); Obj->solve(); } - + tryAutoRecompute(Obj); - + commitNeeded=false; updateNeeded=false; } catch (const Base::Exception& e) { QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what())); abortCommand(); - + tryAutoRecomputeIfNotSolve(Obj); // we have to update the solver after this aborted addition. } } else { // command canceled abortCommand(); - + updateNeeded=true; } } else { // now dialog was shown so commit the command commitCommand(); - commitNeeded=false; + commitNeeded=false; } //updateActive(); getSelection().clearSelection(); } - + if (commitNeeded) commitCommand(); - + if(updateNeeded) { tryAutoRecomputeIfNotSolve(Obj); // we have to update the solver after this aborted addition. } @@ -5760,13 +5787,13 @@ void CmdSketcherConstrainDiameter::applyConstraint(std::vector &selSe { SketcherGui::ViewProviderSketch* sketchgui = static_cast(getActiveGuiDocument()->getInEdit()); Sketcher::SketchObject* Obj = sketchgui->getSketchObject(); - + int GeoId = selSeq.at(0).GeoId; double diameter = 0.0; - + bool commitNeeded=false; bool updateNeeded=false; - + switch (seqIndex) { case 0: // {SelEdge} case 1: // {SelExternalEdge} @@ -5785,33 +5812,33 @@ void CmdSketcherConstrainDiameter::applyConstraint(std::vector &selSe QObject::tr("Constraint only applies to arcs or circles.")); return; } - + // Create the diameter constraint now openCommand("Add diameter constraint"); Gui::Command::doCommand(Doc, "App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", Obj->getNameInDocument(), GeoId, diameter); - + const std::vector &ConStr = Obj->Constraints.getValues(); - + int indexConstr = ConStr.size() - 1; bool fixed = isPointOrSegmentFixed(Obj,GeoId); if(fixed || constraintCreationMode==Reference) { Gui::Command::doCommand(Doc, "App.ActiveDocument.%s.setDriving(%i,%s)", Obj->getNameInDocument(), ConStr.size()-1, "False"); } - + // Guess some reasonable distance for placing the datum text Gui::Document *doc = getActiveGuiDocument(); float sf = 1.f; if (doc && doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) { SketcherGui::ViewProviderSketch *vp = static_cast(doc->getInEdit()); sf = vp->getScaleFactor(); - + Sketcher::Constraint *constr = ConStr[ConStr.size()-1]; constr->LabelDistance = 2. * sf; vp->draw(); // Redraw } - + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); bool show = hGrp->GetBool("ShowDialogOnDistanceConstraint", true); // Ask for the value of the diameter immediately @@ -5824,20 +5851,20 @@ void CmdSketcherConstrainDiameter::applyConstraint(std::vector &selSe Base::Quantity init_val; init_val.setUnit(Base::Unit::Length); init_val.setValue(diameter); - + ui_Datum.labelEdit->setValue(init_val); ui_Datum.labelEdit->selectNumber(); ui_Datum.labelEdit->bind(Obj->Constraints.createPath(indexConstr)); - + if (dlg.exec() == QDialog::Accepted) { Base::Quantity newQuant = ui_Datum.labelEdit->value(); double newDiameter = newQuant.getValue(); - + try { doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setDatum(%i,App.Units.Quantity('%f %s'))", Obj->getNameInDocument(), indexConstr, newDiameter, (const char*)newQuant.getUnit().getString().toUtf8()); - + QString constraintName = ui_Datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != Obj->Constraints[indexConstr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); @@ -5845,30 +5872,30 @@ void CmdSketcherConstrainDiameter::applyConstraint(std::vector &selSe Obj->getNameInDocument(), indexConstr, escapedstr.c_str()); } - + commitCommand(); - + if (Obj->noRecomputes && Obj->ExpressionEngine.depsAreTouched()) { Obj->ExpressionEngine.execute(); Obj->solve(); } - + tryAutoRecompute(Obj); - + commitNeeded=false; updateNeeded=false; } catch (const Base::Exception& e) { QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what())); abortCommand(); - + tryAutoRecomputeIfNotSolve(Obj); // we have to update the solver after this aborted addition. } } else { // command canceled abortCommand(); - + updateNeeded=true; } } @@ -5879,10 +5906,10 @@ void CmdSketcherConstrainDiameter::applyConstraint(std::vector &selSe } //updateActive(); getSelection().clearSelection(); - + if(commitNeeded) commitCommand(); - + if(updateNeeded) { tryAutoRecomputeIfNotSolve(Obj); // we have to update the solver after this aborted addition. } @@ -5932,12 +5959,12 @@ void CmdSketcherCompConstrainRadDia::activated(int iMsg) } else return; - + // Since the default icon is reset when enabing/disabling the command we have // to explicitly set the icon of the used command. Gui::ActionGroup* pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); - + assert(iMsg < a.size()); pcAction->setIcon(a[iMsg]->icon()); } @@ -5959,7 +5986,7 @@ Gui::Action * CmdSketcherCompConstrainRadDia::createAction(void) pcAction->setIcon(arc1->icon()); int defaultId = 0; pcAction->setProperty("defaultAction", QVariant(defaultId)); - + pcAction->setShortcut(QString::fromLatin1(sAccel)); return pcAction; @@ -5970,7 +5997,7 @@ void CmdSketcherCompConstrainRadDia::updateAction(int mode) Gui::ActionGroup* pcAction = qobject_cast(getAction()); if (!pcAction) return; - + QList a = pcAction->actions(); int index = pcAction->property("defaultAction").toInt(); switch (mode) { @@ -5990,12 +6017,12 @@ void CmdSketcherCompConstrainRadDia::updateAction(int mode) void CmdSketcherCompConstrainRadDia::languageChange() { Command::languageChange(); - + if (!_pcAction) return; Gui::ActionGroup* pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); - + QAction* arc1 = a[0]; arc1->setText(QApplication::translate("CmdSketcherCompConstrainRadDia", "Constrain radius")); arc1->setToolTip(QApplication::translate("Sketcher_ConstrainRadius", "Fix the radius of a circle or an arc")); @@ -6150,24 +6177,24 @@ void CmdSketcherConstrainAngle::activated(int iMsg) Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('AngleViaPoint',%d,%d,%d,%d,%f)) ", selection[0].getFeatName(),GeoId1,GeoId2,GeoId3,PosId3,ActAngle); - + if (bothexternal || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else finishDistanceConstraint(this, Obj,true); - + return; }; } else if (SubNames.size() < 3) { bool bothexternal = areBothPointsOrSegmentsFixed(Obj, GeoId1, GeoId2); - + if (isVertex(GeoId1,PosId1) && isEdge(GeoId2,PosId2)) { std::swap(GeoId1,GeoId2); std::swap(PosId1,PosId2); @@ -6253,14 +6280,14 @@ void CmdSketcherConstrainAngle::activated(int iMsg) if (bothexternal || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else finishDistanceConstraint(this, Obj,true); - + return; } } else if (isEdge(GeoId1,PosId1)) { // line angle @@ -6284,14 +6311,14 @@ void CmdSketcherConstrainAngle::activated(int iMsg) if (GeoId1 <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else finishDistanceConstraint(this, Obj,true); - + return; } else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { @@ -6308,14 +6335,14 @@ void CmdSketcherConstrainAngle::activated(int iMsg) if (GeoId1 <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else finishDistanceConstraint(this, Obj,true); - + return; } } @@ -6621,29 +6648,29 @@ void CmdSketcherConstrainEqual::activated(int iMsg) hasAlreadyExternal = true; } } - + const Part::Geometry *geo = Obj->getGeometry(GeoId); - + if(geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { // unsupported as they are generally hereogeneus shapes QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Equality for B-spline edge currently unsupported.")); return; } - + if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) lineSel = true; else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) arcSel = true; - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) + else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) circSel = true; - else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) + else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) ellipsSel = true; - else if (geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) + else if (geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) arcEllipsSel = true; - else if (geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) + else if (geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) hyperbSel = true; - else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) + else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) parabSel = true; else { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), @@ -6659,7 +6686,7 @@ void CmdSketcherConstrainEqual::activated(int iMsg) ((arcSel || circSel) && ((ellipsSel || arcEllipsSel) || hyperbSel || parabSel)) || ((ellipsSel || arcEllipsSel) && (hyperbSel || parabSel)) || (hyperbSel && parabSel) ) { - + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select two or more edges of similar type")); return; @@ -6846,7 +6873,7 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg) } if ( areAllPointsOrSegmentsFixed(Obj, GeoId1, GeoId2, GeoId3) ) { - showNoConstraintBetweenFixedGeometry(); + showNoConstraintBetweenFixedGeometry(); return; } @@ -6919,7 +6946,7 @@ void CmdSketcherConstrainSymmetric::applyConstraint(std::vector &selS QObject::tr("Cannot add a symmetry constraint between a line and its end points!")); return; } - + if ( areBothPointsOrSegmentsFixed(Obj, GeoId1, GeoId2) ) { showNoConstraintBetweenFixedGeometry(); return; @@ -6964,7 +6991,7 @@ void CmdSketcherConstrainSymmetric::applyConstraint(std::vector &selS } return; - } + } case 7: // {SelVertex, SelVertexOrRoot, SelVertex} case 8: // {SelVertex, SelVertex, SelVertexOrRoot} case 9: // {SelVertexOrRoot, SelVertex, SelVertex} @@ -7063,7 +7090,7 @@ void CmdSketcherConstrainSnellsLaw::activated(int iMsg) std::swap(PosId2,PosId3); } - //a bunch of validity checks + //a bunch of validity checks if (areAllPointsOrSegmentsFixed(Obj, GeoId1, GeoId2, GeoId3) ) { strError = QObject::tr("Can not create constraint with external geometry only!!", dmbg); throw Base::ValueError(""); @@ -7075,9 +7102,9 @@ void CmdSketcherConstrainSnellsLaw::activated(int iMsg) strError = QObject::tr("Incompatible geometry is selected!", dmbg); throw Base::ValueError(""); }; - + const Part::Geometry *geo = Obj->getGeometry(GeoId3); - + if( geo && geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() ){ // unsupported until normal to B-spline at any point implemented. QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), @@ -7086,7 +7113,7 @@ void CmdSketcherConstrainSnellsLaw::activated(int iMsg) } double n2divn1=0; - + //the essence. //Unlike other constraints, we'll ask for a value immediately. QDialog dlg(Gui::getMainWindow()); @@ -7129,11 +7156,11 @@ void CmdSketcherConstrainSnellsLaw::activated(int iMsg) /*if (allexternal || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.setDriving(%i,%s)", selection[0].getFeatName(),ConStr.size()-1,"False"); - }*/ - + }*/ + commitCommand(); tryAutoRecompute(Obj); @@ -7197,7 +7224,7 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) std::vector lineids; std::vector ellipseids; std::vector arcsofellipseids; - + bool hasAlreadyExternal = false; for (std::vector::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) { @@ -7205,7 +7232,7 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) int GeoId; Sketcher::PointPos PosId; getIdsFromName(*it, Obj, GeoId, PosId); - + if (isPointOrSegmentFixed(Obj,GeoId)) { if (GeoId == Sketcher::GeoEnum::HAxis || GeoId == Sketcher::GeoEnum::VAxis) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), @@ -7221,7 +7248,7 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) } const Part::Geometry *geo = Obj->getGeometry(GeoId); - + if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()) pointids.push_back(GeoId); else if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) @@ -7236,49 +7263,49 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) return; } } - + int GeoId; Sketcher::PointPos PosId; getIdsFromName(SubNames[SubNames.size()-1], Obj, GeoId, PosId); // last selected element - + const Part::Geometry *geo = Obj->getGeometry(GeoId); - + // Currently it is only supported for ellipses if(geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { - + // Priority list // EllipseMajorDiameter = 1, // EllipseMinorDiameter = 2, // EllipseFocus1 = 3, // EllipseFocus2 = 4 - + if(ellipseids.size()>1){ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("You can not internally constraint an ellipse on other ellipse. Select only one ellipse.")); - return; + return; } - + if (pointids.size()>2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Maximum 2 points are supported.")); return; } - + if (lineids.size()>2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Maximum 2 lines are supported.")); return; } - + // look for which internal constraints are already applied bool major=false; bool minor=false; bool focus1=false; bool focus2=false; bool extra_elements=false; - + const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues(); - + for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); it != vals.end(); ++it) { if((*it)->Type == Sketcher::InternalAlignment && (*it)->Second == GeoId) @@ -7290,10 +7317,10 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) case Sketcher::EllipseMinorDiameter: minor=true; break; - case Sketcher::EllipseFocus1: + case Sketcher::EllipseFocus1: focus1=true; break; - case Sketcher::EllipseFocus2: + case Sketcher::EllipseFocus2: focus2=true; break; default: @@ -7301,18 +7328,18 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) } } } - + if(major && minor && focus1 && focus2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Nothing to constraint"), - QObject::tr("Currently all internal geometry of the ellipse is already exposed.")); + QObject::tr("Currently all internal geometry of the ellipse is already exposed.")); return; } - + if((!(focus1 && focus2) && pointids.size()>=1) || // if some element is missing and we are adding an element of that type (!(major && minor) && lineids.size()>=1) ){ - + openCommand("add internal alignment constraint"); - + if(pointids.size()>=1) { if(!focus1) { @@ -7321,44 +7348,44 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) } else if(!focus2) { Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", - selection[0].getFeatName(),pointids[0],Sketcher::start,ellipseids[0]); + selection[0].getFeatName(),pointids[0],Sketcher::start,ellipseids[0]); focus2=true; } else extra_elements=true; } - + if(pointids.size()==2) { if(!focus2) { Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", - selection[0].getFeatName(),pointids[1],Sketcher::start,ellipseids[0]); + selection[0].getFeatName(),pointids[1],Sketcher::start,ellipseids[0]); } else extra_elements=true; } - + if(lineids.size()>=1) { if(!major) { Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMajorDiameter',%d,%d)) ", selection[0].getFeatName(),lineids[0],ellipseids[0]); - + const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[0])); - - if(!geo->Construction) + + if(!geo->Construction) Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",selection[0].getFeatName(),lineids[0]); - + } else if(!minor) { Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", - selection[0].getFeatName(),lineids[0],ellipseids[0]); - + selection[0].getFeatName(),lineids[0],ellipseids[0]); + const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[0])); - + if(!geo->Construction) Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",selection[0].getFeatName(),lineids[0]); - + minor=true; } else @@ -7369,9 +7396,9 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) if(!minor){ Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", selection[0].getFeatName(),lineids[1],ellipseids[0]); - + const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[1])); - + if(!geo->Construction) Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",selection[0].getFeatName(),lineids[1]); } @@ -7398,46 +7425,46 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) } } else if(geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { - + // Priority list // EllipseMajorDiameter = 1, // EllipseMinorDiameter = 2, // EllipseFocus1 = 3, // EllipseFocus2 = 4 - + if(arcsofellipseids.size()>1){ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("You can not internally constraint an arc of ellipse on other arc of ellipse. Select only one arc of ellipse.")); - return; + return; } - + if(ellipseids.size()>0){ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("You can not internally constraint an ellipse on an arc of ellipse. Select only one ellipse or arc of ellipse.")); - return; + return; } - + if (pointids.size()>2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Maximum 2 points are supported.")); return; } - + if (lineids.size()>2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Maximum 2 lines are supported.")); return; } - + // look for which internal constraints are already applied bool major=false; bool minor=false; bool focus1=false; bool focus2=false; bool extra_elements=false; - + const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues(); - + for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); it != vals.end(); ++it) { if((*it)->Type == Sketcher::InternalAlignment && (*it)->First == GeoId) @@ -7449,10 +7476,10 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) case Sketcher::EllipseMinorDiameter: minor=true; break; - case Sketcher::EllipseFocus1: + case Sketcher::EllipseFocus1: focus1=true; break; - case Sketcher::EllipseFocus2: + case Sketcher::EllipseFocus2: focus2=true; break; default: @@ -7460,18 +7487,18 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) } } } - + if(major && minor && focus1 && focus2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Nothing to constraint"), - QObject::tr("Currently all internal geometry of the arc of ellipse is already exposed.")); + QObject::tr("Currently all internal geometry of the arc of ellipse is already exposed.")); return; } - + if((!(focus1 && focus2) && pointids.size()>=1) || // if some element is missing and we are adding an element of that type (!(major && minor) && lineids.size()>=1) ){ - + openCommand("add internal alignment constraint"); - + if(pointids.size()>=1) { if(!focus1) { @@ -7480,44 +7507,44 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) } else if(!focus2) { Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", - selection[0].getFeatName(),pointids[0],Sketcher::start,arcsofellipseids[0]); + selection[0].getFeatName(),pointids[0],Sketcher::start,arcsofellipseids[0]); focus2=true; } else extra_elements=true; } - + if(pointids.size()==2) { if(!focus2) { Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", - selection[0].getFeatName(),pointids[1],Sketcher::start,arcsofellipseids[0]); + selection[0].getFeatName(),pointids[1],Sketcher::start,arcsofellipseids[0]); } else extra_elements=true; } - + if(lineids.size()>=1) { if(!major) { Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMajorDiameter',%d,%d)) ", selection[0].getFeatName(),lineids[0],arcsofellipseids[0]); - + const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[0])); - - if(!geo->Construction) + + if(!geo->Construction) Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",selection[0].getFeatName(),lineids[0]); - + } else if(!minor) { Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", - selection[0].getFeatName(),lineids[0],arcsofellipseids[0]); - + selection[0].getFeatName(),lineids[0],arcsofellipseids[0]); + const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[0])); - + if(!geo->Construction) Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",selection[0].getFeatName(),lineids[0]); - + minor=true; } else @@ -7528,9 +7555,9 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) if(!minor){ Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", selection[0].getFeatName(),lineids[1],arcsofellipseids[0]); - + const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[1])); - + if(!geo->Construction) Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",selection[0].getFeatName(),lineids[1]); } @@ -7606,7 +7633,7 @@ void CmdSketcherToggleDrivingConstraint::activated(int iMsg) if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) > 0){ // Now we check whether we have a constraint selected or not. - + // get the selection selection = getSelection().getSelectionEx(); @@ -7633,7 +7660,7 @@ void CmdSketcherToggleDrivingConstraint::activated(int iMsg) } if (modeChange) { - // Here starts the code for mode change + // Here starts the code for mode change Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); if (constraintCreationMode == Driving) { @@ -7648,7 +7675,7 @@ void CmdSketcherToggleDrivingConstraint::activated(int iMsg) else // toggle the selected constraint(s) { Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - + // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); if (SubNames.empty()) {