From dc32a0685b61e78620745f8960f6537a7dc210dd Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Wed, 1 May 2019 18:19:22 +0200 Subject: [PATCH] Sketcher: GUI PCH --- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 14 +- .../Sketcher/Gui/CommandSketcherBSpline.cpp | 167 +++++---- src/Mod/Sketcher/Gui/CommandSketcherTools.cpp | 339 +++++++++--------- .../Gui/CommandSketcherVirtualSpace.cpp | 9 +- src/Mod/Sketcher/Gui/EditDatumDialog.cpp | 5 +- src/Mod/Sketcher/Gui/PreCompiled.h | 52 ++- src/Mod/Sketcher/Gui/SoDatumLabel.cpp | 43 +-- src/Mod/Sketcher/Gui/SoZoomTranslation.cpp | 17 +- .../Sketcher/Gui/TaskSketcherConstrains.cpp | 16 +- src/Mod/Sketcher/Gui/TaskSketcherElements.cpp | 3 +- src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp | 11 +- .../Gui/TaskSketcherSolverAdvanced.cpp | 58 ++- .../Sketcher/Gui/TaskSketcherValidation.cpp | 23 +- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 9 +- src/Mod/Sketcher/Gui/Workbench.cpp | 8 +- 15 files changed, 405 insertions(+), 369 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 6ff2ff4aa9..e41652f884 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -25,16 +25,14 @@ #ifndef _PreComp_ # include # include +# include +# include +# include +# include +# include +# include #endif -# include - -#include -#include -#include -#include - -#include #include #include #include diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index 63ba2bd24e..c14c335719 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -28,9 +28,8 @@ # include # include # include -#endif - # include +#endif #include #include @@ -90,11 +89,11 @@ void ActivateBSplineHandler(Gui::Document *doc,DrawSketchHandler *handler) void ShowRestoreInformationLayer(SketcherGui::ViewProviderSketch* vp, char * visibleelementname) { ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General"); - + bool status = hGrp->GetBool(visibleelementname, true); - + hGrp->SetBool(visibleelementname, !status); - + vp->showRestoreInformationLayer(); } @@ -186,13 +185,13 @@ CmdSketcherBSplineComb::CmdSketcherBSplineComb() void CmdSketcherBSplineComb::activated(int iMsg) { Q_UNUSED(iMsg); - + Gui::Document * doc= getActiveGuiDocument(); - + SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); - + ShowRestoreInformationLayer(vp, "BSplineCombVisible"); - + } bool CmdSketcherBSplineComb::isActive(void) @@ -220,13 +219,13 @@ CmdSketcherBSplineKnotMultiplicity::CmdSketcherBSplineKnotMultiplicity() void CmdSketcherBSplineKnotMultiplicity::activated(int iMsg) { Q_UNUSED(iMsg); - + Gui::Document * doc= getActiveGuiDocument(); - + SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); - + ShowRestoreInformationLayer(vp, "BSplineKnotMultiplicityVisible"); - + } bool CmdSketcherBSplineKnotMultiplicity::isActive(void) @@ -254,7 +253,7 @@ void CmdSketcherCompBSplineShowHideGeometryInformation::activated(int iMsg) Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); Gui::Command * cmd; - + if (iMsg==0) cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineDegree"); else if (iMsg==1) @@ -265,14 +264,14 @@ void CmdSketcherCompBSplineShowHideGeometryInformation::activated(int iMsg) cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineKnotMultiplicity"); else return; - + cmd->invoke(0); - + // 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()); } @@ -282,7 +281,7 @@ Gui::Action * CmdSketcherCompBSplineShowHideGeometryInformation::createAction(vo Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); pcAction->setDropDownMenu(true); applyCommandData(this->className(), pcAction); - + QAction* c1 = pcAction->addAction(QString()); c1->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineDegree")); QAction* c2 = pcAction->addAction(QString()); @@ -294,23 +293,23 @@ Gui::Action * CmdSketcherCompBSplineShowHideGeometryInformation::createAction(vo _pcAction = pcAction; languageChange(); - + pcAction->setIcon(c2->icon()); int defaultId = 1; pcAction->setProperty("defaultAction", QVariant(defaultId)); - + return pcAction; } void CmdSketcherCompBSplineShowHideGeometryInformation::languageChange() { Command::languageChange(); - + if (!_pcAction) return; Gui::ActionGroup* pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); - + QAction* c1 = a[0]; c1->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation","Show/Hide B-spline degree")); c1->setToolTip(QApplication::translate("Sketcher_BSplineDegree","Switches between showing and hiding the degree for all B-splines")); @@ -373,7 +372,7 @@ void CmdSketcherConvertToNURB::activated(int iMsg) Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); bool nurbsized = false; - + openCommand("Convert to NURBS"); for (unsigned int i=0; i 12 && SubNames[i].substr(0,12) == "ExternalEdge") { - + int GeoId = - (std::atoi(SubNames[i].substr(12,4000).c_str()) + 2); - + Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.convertToNURBS(%d) ", selection[0].getFeatName(),GeoId); - + nurbsized = true; } - - + + } - + if(!nurbsized) { abortCommand(); QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), @@ -454,7 +453,7 @@ void CmdSketcherIncreaseDegree::activated(int iMsg) Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); openCommand("Increase degree"); - + bool ignored=false; for (unsigned int i=0; i selection; selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); @@ -534,10 +533,10 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) if (selection.size() != 1) { return; } - + // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); - + if(SubNames.size()>1) { // Check that only one object is selected, as we need only one object to get the new GeoId after multiplicity change QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), @@ -551,7 +550,7 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) bool applied = false; bool notaknot = true; - + boost::uuids::uuid bsplinetag; int GeoId; @@ -566,9 +565,9 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) if((*it)->Type == Sketcher::InternalAlignment && (*it)->First == GeoId && (*it)->AlignmentType == Sketcher::BSplineKnotPoint) { bsplinetag = Obj->getGeometry((*it)->Second)->getTag(); - + notaknot = false; - + try { Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.modifyBSplineKnotMultiplicity(%d,%d,%d) ", @@ -605,28 +604,28 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) } } - + if(notaknot){ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("None of the selected elements is a knot of a B-spline")); } - + if(applied) { // find new geoid for B-spline as GeoId might have changed const std::vector< Part::Geometry * > &gvals = Obj->getInternalGeometry(); - + int ngeoid = 0; bool ngfound = false; - + for (std::vector::const_iterator geo = gvals.begin(); geo != gvals.end(); geo++, ngeoid++) { if ((*geo) && (*geo)->getTag() == bsplinetag) { ngfound = true; break; } } - - + + if(ngfound) { try { // add internalalignment for new pole @@ -639,10 +638,10 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) Base::Console().Error("%s\n", e.what()); getSelection().clearSelection(); } - + } } - + if(!applied) { abortCommand(); } @@ -653,7 +652,7 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) tryAutoRecomputeIfNotSolve(Obj); getSelection().clearSelection(); - + } bool CmdSketcherIncreaseKnotMultiplicity::isActive(void) @@ -680,13 +679,13 @@ CmdSketcherDecreaseKnotMultiplicity::CmdSketcherDecreaseKnotMultiplicity() void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) { Q_UNUSED(iMsg); - + #if OCC_VERSION_HEX < 0x060900 QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong OCE/OCC version"), QObject::tr("This version of OCE/OCC does not support knot operation. You need 6.9.0 or higher")); return; #endif - + // get the selection std::vector selection; selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); @@ -695,85 +694,85 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) if (selection.size() != 1) { return; } - + // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); - + if(SubNames.size()>1) { // Check that only one object is selected, as we need only one object to get the new GeoId after multiplicity change QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("The selection comprises more than one item. Please select just one knot.")); return; } - + Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - + openCommand("Decrease knot multiplicity"); - + bool applied = false; bool notaknot = true; - + boost::uuids::uuid bsplinetag; - + int GeoId; Sketcher::PointPos PosId; getIdsFromName(SubNames[0], Obj, GeoId, PosId); - + if(isSimpleVertex(Obj, GeoId, PosId)) { - + 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 && (*it)->AlignmentType == Sketcher::BSplineKnotPoint) { bsplinetag = Obj->getGeometry((*it)->Second)->getTag(); - + notaknot = false; - + try { Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.modifyBSplineKnotMultiplicity(%d,%d,%d) ", selection[0].getFeatName(),(*it)->Second, (*it)->InternalAlignmentIndex + 1, -1); - + applied = true; - + // Warning: GeoId list might have changed as the consequence of deleting pole circles and // particularly B-spline GeoID might have changed. - + } catch (const Base::Exception& e) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Error"), QObject::tr(getStrippedPythonExceptionString(e).c_str())); getSelection().clearSelection(); } - + break; // we have already found our knot. - + } } - + } - + if(notaknot){ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("None of the selected elements is a knot of a B-spline")); - } - + } + if(applied) { // find new geoid for B-spline as GeoId might have changed const std::vector< Part::Geometry * > &gvals = Obj->getInternalGeometry(); - + int ngeoid = 0; bool ngfound = false; - + for (std::vector::const_iterator geo = gvals.begin(); geo != gvals.end(); geo++, ngeoid++) { if ((*geo) && (*geo)->getTag() == bsplinetag) { ngfound = true; break; } } - + if(ngfound) { try { @@ -790,7 +789,7 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) } } - + if(!applied) { abortCommand(); } @@ -818,7 +817,7 @@ CmdSketcherCompModifyKnotMultiplicity::CmdSketcherCompModifyKnotMultiplicity() sAppModule = "Sketcher"; sGroup = QT_TR_NOOP("Sketcher"); sMenuText = QT_TR_NOOP("Modify knot multiplicity"); - sToolTipText = QT_TR_NOOP("Modifies the multiplicity of the selected knot of a B-spline"); + sToolTipText = QT_TR_NOOP("Modifies the multiplicity of the selected knot of a B-spline"); sWhatsThis = "Sketcher_CompModifyKnotMultiplicity"; sStatusTip = sToolTipText; eType = ForEdit; @@ -826,25 +825,25 @@ CmdSketcherCompModifyKnotMultiplicity::CmdSketcherCompModifyKnotMultiplicity() void CmdSketcherCompModifyKnotMultiplicity::activated(int iMsg) { - + Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); - + Gui::Command * cmd; - + if (iMsg==0) cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineIncreaseKnotMultiplicity"); else if (iMsg==1) cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineDecreaseKnotMultiplicity"); - else + else return; - + cmd->invoke(0); - + // 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()); } @@ -873,12 +872,12 @@ Gui::Action * CmdSketcherCompModifyKnotMultiplicity::createAction(void) void CmdSketcherCompModifyKnotMultiplicity::languageChange() { Command::languageChange(); - + if (!_pcAction) return; Gui::ActionGroup* pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); - + QAction* c1 = a[0]; c1->setText(QApplication::translate("CmdSketcherCompModifyKnotMultiplicity","Increase knot multiplicity")); c1->setToolTip(QApplication::translate("Sketcher_BSplineIncreaseKnotMultiplicity","Increases the multiplicity of the selected knot of a B-spline")); diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index bd0129f445..a713b3b290 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -27,9 +27,8 @@ # include # include # include -#endif - # include +#endif #include #include @@ -80,7 +79,7 @@ void ActivateAcceleratorHandler(Gui::Document *doc,DrawSketchHandler *handler) if (doc) { if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom (SketcherGui::ViewProviderSketch::getClassTypeId())) { - + SketcherGui::ViewProviderSketch* vp = static_cast (doc->getInEdit()); vp->purgeHandler(); vp->activateHandler(handler); @@ -126,12 +125,12 @@ void CmdSketcherCloseShape::activated(int iMsg) QObject::tr("Select at least two edges from the sketch.")); return; } - + Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); int GeoIdFirst=-1; int GeoIdLast=-1; - + // undo command open openCommand("add coincident constraint"); // go through the selected subelements @@ -159,9 +158,9 @@ void CmdSketcherCloseShape::activated(int iMsg) abortCommand(); return; } - + // Check for the special case of closing a shape with two lines to avoid overlap - if (SubNames.size() == 2 && + if (SubNames.size() == 2 && geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId() ) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), @@ -179,7 +178,7 @@ void CmdSketcherCloseShape::activated(int iMsg) // Close Last Edge with First Edge Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", - selection[0].getFeatName(),GeoIdLast,Sketcher::end,GeoIdFirst,Sketcher::start); + selection[0].getFeatName(),GeoIdLast,Sketcher::end,GeoIdFirst,Sketcher::start); // finish the transaction and update commitCommand(); @@ -315,18 +314,18 @@ void CmdSketcherSelectConstraints::activated(int iMsg) const std::vector &SubNames = selection[0].getSubNames(); Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues(); - + std::string doc_name = Obj->getDocument()->getName(); std::string obj_name = Obj->getNameInDocument(); - + getSelection().clearSelection(); - + // go through the selected subelements for (std::vector::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) { // only handle edges if (it->size() > 4 && it->substr(0,4) == "Edge") { int GeoId = std::atoi(it->substr(4,4000).c_str()) - 1; - + // push all the constraints int i = 0; for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); @@ -365,21 +364,21 @@ void CmdSketcherSelectOrigin::activated(int iMsg) { Q_UNUSED(iMsg); Gui::Document * doc= getActiveGuiDocument(); - + SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); - + Sketcher::SketchObject* Obj= vp->getSketchObject(); - + // ViewProviderSketch * vp = static_cast(Gui::Application::Instance->getViewProvider(docobj)); - -// Sketcher::SketchObject* Obj = vp->getSketchObject(); - + +// Sketcher::SketchObject* Obj = vp->getSketchObject(); + std::string doc_name = Obj->getDocument()->getName(); std::string obj_name = Obj->getNameInDocument(); std::stringstream ss; - + ss << "RootPoint"; - + if(Gui::Selection().isSelected(doc_name.c_str(), obj_name.c_str(), ss.str().c_str())) Gui::Selection().rmvSelection(doc_name.c_str(), obj_name.c_str(), ss.str().c_str()); else @@ -413,17 +412,17 @@ void CmdSketcherSelectVerticalAxis::activated(int iMsg) { Q_UNUSED(iMsg); Gui::Document * doc= getActiveGuiDocument(); - + SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); - + Sketcher::SketchObject* Obj= vp->getSketchObject(); - + std::string doc_name = Obj->getDocument()->getName(); std::string obj_name = Obj->getNameInDocument(); std::stringstream ss; - + ss << "V_Axis"; - + if(Gui::Selection().isSelected(doc_name.c_str(), obj_name.c_str(), ss.str().c_str())) Gui::Selection().rmvSelection(doc_name.c_str(), obj_name.c_str(), ss.str().c_str()); else @@ -457,17 +456,17 @@ void CmdSketcherSelectHorizontalAxis::activated(int iMsg) { Q_UNUSED(iMsg); Gui::Document * doc= getActiveGuiDocument(); - + SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); - + Sketcher::SketchObject* Obj= vp->getSketchObject(); - + std::string doc_name = Obj->getDocument()->getName(); std::string obj_name = Obj->getNameInDocument(); std::stringstream ss; - + ss << "H_Axis"; - + if(Gui::Selection().isSelected(doc_name.c_str(), obj_name.c_str(), ss.str().c_str())) Gui::Selection().rmvSelection(doc_name.c_str(), obj_name.c_str(), ss.str().c_str()); else @@ -500,20 +499,20 @@ void CmdSketcherSelectRedundantConstraints::activated(int iMsg) { Q_UNUSED(iMsg); Gui::Document * doc= getActiveGuiDocument(); - + SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); - + Sketcher::SketchObject* Obj= vp->getSketchObject(); - + std::string doc_name = Obj->getDocument()->getName(); std::string obj_name = Obj->getNameInDocument(); - + // get the needed lists and objects const std::vector< int > &solverredundant = vp->getSketchObject()->getLastRedundant(); const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues(); - + getSelection().clearSelection(); - + // push the constraints int i = 0; for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin();it != vals.end(); ++it,++i) { @@ -523,8 +522,8 @@ void CmdSketcherSelectRedundantConstraints::activated(int iMsg) break; } } - - + + } } @@ -553,20 +552,20 @@ void CmdSketcherSelectConflictingConstraints::activated(int iMsg) { Q_UNUSED(iMsg); Gui::Document * doc= getActiveGuiDocument(); - + SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); - + Sketcher::SketchObject* Obj= vp->getSketchObject(); - + std::string doc_name = Obj->getDocument()->getName(); std::string obj_name = Obj->getNameInDocument(); // get the needed lists and objects const std::vector< int > &solverconflicting = vp->getSketchObject()->getLastConflicting(); const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues(); - + getSelection().clearSelection(); - + // push the constraints int i = 0; for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin();it != vals.end(); ++it,++i) { @@ -619,19 +618,19 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg) std::string doc_name = Obj->getDocument()->getName(); std::string obj_name = Obj->getNameInDocument(); std::stringstream ss; - + int selected=0; - + // go through the selected subelements for (std::vector::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) { // only handle constraints if (it->size() > 10 && it->substr(0,10) == "Constraint") { int ConstrId = Sketcher::PropertyConstraintList::getIndexFromConstraintName(*it); - + if(ConstrId < static_cast(vals.size())){ if(vals[ConstrId]->First!=Constraint::GeoUndef){ ss.str(std::string()); - + switch(vals[ConstrId]->FirstPos) { case Sketcher::none: @@ -639,20 +638,20 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg) break; case Sketcher::start: case Sketcher::end: - case Sketcher::mid: + case Sketcher::mid: int vertex = Obj->getVertexIndexGeoPos(vals[ConstrId]->First,vals[ConstrId]->FirstPos); if(vertex>-1) ss << "Vertex" << vertex + 1; - break; + break; } - + Gui::Selection().addSelection(doc_name.c_str(), obj_name.c_str(), ss.str().c_str()); selected++; } - + if(vals[ConstrId]->Second!=Constraint::GeoUndef){ ss.str(std::string()); - + switch(vals[ConstrId]->SecondPos) { case Sketcher::none: @@ -660,20 +659,20 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg) break; case Sketcher::start: case Sketcher::end: - case Sketcher::mid: + case Sketcher::mid: int vertex = Obj->getVertexIndexGeoPos(vals[ConstrId]->Second,vals[ConstrId]->SecondPos); if(vertex>-1) ss << "Vertex" << vertex + 1; - break; + break; } - + Gui::Selection().addSelection(doc_name.c_str(), obj_name.c_str(), ss.str().c_str()); selected++; } - + if(vals[ConstrId]->Third!=Constraint::GeoUndef){ ss.str(std::string()); - + switch(vals[ConstrId]->ThirdPos) { case Sketcher::none: @@ -681,20 +680,20 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg) break; case Sketcher::start: case Sketcher::end: - case Sketcher::mid: + case Sketcher::mid: int vertex = Obj->getVertexIndexGeoPos(vals[ConstrId]->Third,vals[ConstrId]->ThirdPos); if(vertex>-1) ss << "Vertex" << vertex + 1; - break; + break; } - + Gui::Selection().addSelection(doc_name.c_str(), obj_name.c_str(), ss.str().c_str()); selected++; } } } } - + if ( selected == 0 ) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No constraint selected"), QObject::tr("At least one constraint must be selected")); @@ -801,7 +800,7 @@ void CmdSketcherSelectElementsWithDoFs::activated(int iMsg) geoid++; } - + if(curQRAlg == GCS::EigenSparseQR) { Obj->getSolvedSketch().setQRAlgorithm(GCS::EigenSparseQR); } @@ -850,9 +849,9 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg) std::string doc_name = Obj->getDocument()->getName(); std::string obj_name = Obj->getNameInDocument(); std::stringstream ss; - + getSelection().clearSelection(); - + // go through the selected subelements for (std::vector::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) { // only handle edges @@ -862,9 +861,9 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg) if(it->substr(0,4) == "Edge") GeoId = std::atoi(it->substr(4,4000).c_str()) - 1; else - GeoId = -std::atoi(it->substr(12,4000).c_str()) - 2; - - const Part::Geometry *geo = Obj->getGeometry(GeoId); + GeoId = -std::atoi(it->substr(12,4000).c_str()) - 2; + + const Part::Geometry *geo = Obj->getGeometry(GeoId); // Only for supported types if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId() || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() || @@ -980,7 +979,7 @@ void CmdSketcherSymmetry::activated(int iMsg) } // reference can be external or non-external - LastGeo = Obj->getGeometry(LastGeoId); + LastGeo = Obj->getGeometry(LastGeoId); // Only for supported types if(LastGeo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) lastgeotype = line; @@ -1077,7 +1076,7 @@ void CmdSketcherSymmetry::activated(int iMsg) } else { int index = geoIdList.rfind(','); - geoIdList.resize(index); + geoIdList.resize(index); } geoIdList.insert(0,1,'['); @@ -1089,7 +1088,7 @@ void CmdSketcherSymmetry::activated(int iMsg) Gui::Command::doCommand( Gui::Command::Doc, "App.ActiveDocument.%s.addSymmetric(%s,%d,%d)", Obj->getNameInDocument(), geoIdList.c_str(), LastGeoId, LastPointPos - ); + ); Gui::Command::commitCommand(); } @@ -1108,7 +1107,7 @@ bool CmdSketcherSymmetry::isActive(void) class SketcherCopy : public Gui::Command { -public: +public: enum Op { Copy, Clone, @@ -1156,7 +1155,7 @@ static const char *cursor_createcopy[]={ "................................", "................................", "................................"}; - + class DrawSketchHandlerCopy: public DrawSketchHandler { public: @@ -1171,21 +1170,21 @@ static const char *cursor_createcopy[]={ , EditCurve(2) { } - + virtual ~DrawSketchHandlerCopy(){} /// mode table enum SelectMode { STATUS_SEEK_First, /**< enum value ----. */ STATUS_End }; - + virtual void activated(ViewProviderSketch *sketchgui) { setCursor(QPixmap(cursor_createcopy),7,7); Origin = static_cast(sketchgui->getObject())->getPoint(OriginGeoId, OriginPos); EditCurve[0] = Base::Vector2d(Origin.x,Origin.y); } - + virtual void mouseMove(Base::Vector2d onSketchPos) { if (Mode==STATUS_SEEK_First) { @@ -1194,66 +1193,66 @@ static const char *cursor_createcopy[]={ SbString text; text.sprintf(" (%.1f,%.1fdeg)", length, angle * 180 / M_PI); setPositionText(onSketchPos, text); - + EditCurve[1] = onSketchPos; sketchgui->drawEdit(EditCurve); if (seekAutoConstraint(sugConstr1, onSketchPos, Base::Vector2d(0.0,0.0),AutoConstraint::VERTEX)) { renderSuggestConstraintsCursor(sugConstr1); return; } - + } applyCursor(); } - + virtual bool pressButton(Base::Vector2d onSketchPos) { if (Mode==STATUS_SEEK_First){ EditCurve[1] = onSketchPos; - sketchgui->drawEdit(EditCurve); + sketchgui->drawEdit(EditCurve); Mode = STATUS_End; } - + return true; } - + virtual bool releaseButton(Base::Vector2d onSketchPos) { Q_UNUSED(onSketchPos); if (Mode==STATUS_End){ - + Base::Vector2d vector = EditCurve[1]-EditCurve[0]; - + unsetCursor(); resetPositionText(); - + int currentgeoid = static_cast(sketchgui->getObject())->getHighestCurveIndex(); - + Gui::Command::openCommand("Copy/clone/move geometry"); - + try{ if( Op != SketcherCopy::Move) { - + Gui::Command::doCommand( Gui::Command::Doc, "App.ActiveDocument.%s.addCopy(%s,App.Vector(%f,%f,0),%s)", - sketchgui->getObject()->getNameInDocument(), + sketchgui->getObject()->getNameInDocument(), geoIdList.c_str(), vector.x, vector.y, - (Op == SketcherCopy::Clone?"True":"False")); + (Op == SketcherCopy::Clone?"True":"False")); } - else { - Gui::Command::doCommand( + else { + Gui::Command::doCommand( Gui::Command::Doc, "App.ActiveDocument.%s.addMove(%s,App.Vector(%f,%f,0))", - sketchgui->getObject()->getNameInDocument(), + sketchgui->getObject()->getNameInDocument(), geoIdList.c_str(), vector.x, vector.y); } - + Gui::Command::commitCommand(); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); } - + if( Op != SketcherCopy::Move) { // add auto constraints for the destination copy if (sugConstr1.size() > 0) { @@ -1267,13 +1266,13 @@ static const char *cursor_createcopy[]={ sugConstr1.clear(); } } - + tryAutoRecomputeIfNotSolve(static_cast(sketchgui->getObject())); - + EditCurve.clear(); sketchgui->drawEdit(EditCurve); - - sketchgui->purgeHandler(); // no code after this line, Handler get deleted in ViewProvider + + sketchgui->purgeHandler(); // no code after this line, Handler get deleted in ViewProvider } return true; } @@ -1297,14 +1296,14 @@ void SketcherCopy::activate(SketcherCopy::Op op) { // get the selection std::vector selection = getSelection().getSelectionEx(); - + // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select elements from a single sketch.")); return; } - + // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); if (SubNames.empty()) { @@ -1312,15 +1311,15 @@ void SketcherCopy::activate(SketcherCopy::Op op) QObject::tr("Select elements from a single sketch.")); return; } - + Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - + getSelection().clearSelection(); - + int LastGeoId = 0; Sketcher::PointPos LastPointPos = Sketcher::none; const Part::Geometry *LastGeo = 0; - + // create python command with list of elements std::stringstream stream; int geoids = 0; @@ -1344,7 +1343,7 @@ void SketcherCopy::activate(SketcherCopy::Op op) Obj->getGeoVertexIndex(VtId, GeoId, PosId); if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { LastGeoId = GeoId; - LastPointPos = Sketcher::start; + LastPointPos = Sketcher::start; // points to copy if (LastGeoId>=0) { geoids++; @@ -1353,7 +1352,7 @@ void SketcherCopy::activate(SketcherCopy::Op op) } } } - + // check if last selected element is a Vertex, not being a GeomPoint if (SubNames.rbegin()->size() > 6 && SubNames.rbegin()->substr(0,6) == "Vertex"){ int VtId = std::atoi(SubNames.rbegin()->substr(6,4000).c_str()) - 1; @@ -1365,21 +1364,21 @@ void SketcherCopy::activate(SketcherCopy::Op op) LastPointPos = PosId; } } - + if (geoids < 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("A copy requires at least one selected non-external geometric element")); - return; - } - + return; + } + std::string geoIdList = stream.str(); - + // remove the last added comma and brackets to make the python list int index = geoIdList.rfind(','); - geoIdList.resize(index); + geoIdList.resize(index); geoIdList.insert(0,1,'['); geoIdList.append(1,']'); - + // if the last element is not a point serving as a reference for the copy process // then make the start point of the last element the copy reference (if it exists, if not the center point) if (LastPointPos == Sketcher::none) { @@ -1391,7 +1390,7 @@ void SketcherCopy::activate(SketcherCopy::Op op) LastPointPos = Sketcher::start; } } - + // Ask the user if he wants to clone or to simple copy /*int ret = QMessageBox::question(Gui::getMainWindow(), QObject::tr("Dimensional/Geometric constraints"), * QObject::tr("Do you want to clone the object, i.e. substitute dimensional constraints by geometric constraints?"), @@ -1404,12 +1403,12 @@ else if (ret == QMessageBox::Cancel) { // do nothing return; }*/ - - ActivateAcceleratorHandler(getActiveGuiDocument(),new DrawSketchHandlerCopy(geoIdList, LastGeoId, LastPointPos, geoids, op)); + + ActivateAcceleratorHandler(getActiveGuiDocument(),new DrawSketchHandlerCopy(geoIdList, LastGeoId, LastPointPos, geoids, op)); } - - + + class CmdSketcherCopy : public SketcherCopy { public: @@ -1418,10 +1417,10 @@ public: virtual const char* className() const { return "CmdSketcherCopy"; } virtual void activate(); -protected: +protected: virtual void activated(int iMsg); virtual bool isActive(void); -}; +}; CmdSketcherCopy::CmdSketcherCopy() :SketcherCopy("Sketcher_Copy") @@ -1453,7 +1452,7 @@ bool CmdSketcherCopy::isActive(void) { return isSketcherAcceleratorActive( getActiveGuiDocument(), true ); } - + class CmdSketcherClone : public SketcherCopy { public: @@ -1462,7 +1461,7 @@ public: virtual const char* className() const { return "CmdSketcherClone"; } virtual void activate(); -protected: +protected: virtual void activated(int iMsg); virtual bool isActive(void); }; @@ -1505,7 +1504,7 @@ public: virtual const char* className() const { return "CmdSketcherMove"; } virtual void activate(); -protected: +protected: virtual void activated(int iMsg); virtual bool isActive(void); }; @@ -1565,10 +1564,10 @@ void CmdSketcherCompCopy::activated(int iMsg) // 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()); - + if (iMsg==0){ CmdSketcherClone sc; sc.activate(); @@ -1593,35 +1592,35 @@ Gui::Action * CmdSketcherCompCopy::createAction(void) Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); pcAction->setDropDownMenu(true); applyCommandData(this->className(), pcAction); - + QAction* clone = pcAction->addAction(QString()); clone->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_Clone")); QAction* copy = pcAction->addAction(QString()); copy->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_Copy")); QAction* move = pcAction->addAction(QString()); move->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_Move")); - + _pcAction = pcAction; languageChange(); - + pcAction->setIcon(clone->icon()); int defaultId = 0; pcAction->setProperty("defaultAction", QVariant(defaultId)); - + pcAction->setShortcut(QString::fromLatin1(sAccel)); - + return pcAction; } void CmdSketcherCompCopy::languageChange() { Command::languageChange(); - + if (!_pcAction) return; Gui::ActionGroup* pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); - + QAction* clone = a[0]; clone->setText(QApplication::translate("Sketcher_CompCopy","Clone")); clone->setToolTip(QApplication::translate("Sketcher_Clone","Creates a clone of the geometry taking as reference the last selected point")); @@ -1680,7 +1679,7 @@ static const char *cursor_createrectangulararray[]={ "................................", "................................", "................................"}; - + class DrawSketchHandlerRectangularArray: public DrawSketchHandler { public: @@ -1700,21 +1699,21 @@ static const char *cursor_createrectangulararray[]={ , EditCurve(2) { } - + virtual ~DrawSketchHandlerRectangularArray(){} /// mode table enum SelectMode { STATUS_SEEK_First, /**< enum value ----. */ STATUS_End }; - + virtual void activated(ViewProviderSketch *sketchgui) { setCursor(QPixmap(cursor_createrectangulararray),7,7); Origin = static_cast(sketchgui->getObject())->getPoint(OriginGeoId, OriginPos); EditCurve[0] = Base::Vector2d(Origin.x,Origin.y); } - + virtual void mouseMove(Base::Vector2d onSketchPos) { if (Mode==STATUS_SEEK_First) { @@ -1723,58 +1722,58 @@ static const char *cursor_createrectangulararray[]={ SbString text; text.sprintf(" (%.1f,%.1fdeg)", length, angle * 180 / M_PI); setPositionText(onSketchPos, text); - + EditCurve[1] = onSketchPos; sketchgui->drawEdit(EditCurve); if (seekAutoConstraint(sugConstr1, onSketchPos, Base::Vector2d(0.0,0.0),AutoConstraint::VERTEX)) { renderSuggestConstraintsCursor(sugConstr1); return; } - + } applyCursor(); } - + virtual bool pressButton(Base::Vector2d onSketchPos) { if (Mode==STATUS_SEEK_First){ EditCurve[1] = onSketchPos; - sketchgui->drawEdit(EditCurve); + sketchgui->drawEdit(EditCurve); Mode = STATUS_End; } - + return true; } - + virtual bool releaseButton(Base::Vector2d onSketchPos) { Q_UNUSED(onSketchPos); if (Mode==STATUS_End){ - + Base::Vector2d vector = EditCurve[1]-EditCurve[0]; - + unsetCursor(); resetPositionText(); - + Gui::Command::openCommand("Create copy of geometry"); try { Gui::Command::doCommand( Gui::Command::Doc, "App.ActiveDocument.%s.addRectangularArray(%s, App.Vector(%f,%f,0),%s,%d,%d,%s,%f)", - sketchgui->getObject()->getNameInDocument(), + sketchgui->getObject()->getNameInDocument(), geoIdList.c_str(), vector.x, vector.y, (Clone?"True":"False"), Cols, Rows, (ConstraintSeparation?"True":"False"), (EqualVerticalHorizontalSpacing?1.0:0.5)); - + Gui::Command::commitCommand(); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); } - + // add auto constraints for the destination copy if (sugConstr1.size() > 0) { createAutoConstraints(sugConstr1, OriginGeoId+nElements, OriginPos); @@ -1782,12 +1781,12 @@ static const char *cursor_createrectangulararray[]={ } tryAutoRecomputeIfNotSolve(static_cast(sketchgui->getObject())); - + EditCurve.clear(); sketchgui->drawEdit(EditCurve); - - sketchgui->purgeHandler(); // no code after this line, Handler get deleted in ViewProvider + + sketchgui->purgeHandler(); // no code after this line, Handler get deleted in ViewProvider } return true; } @@ -1802,11 +1801,11 @@ static const char *cursor_createrectangulararray[]={ int Rows; int Cols; bool ConstraintSeparation; - bool EqualVerticalHorizontalSpacing; + bool EqualVerticalHorizontalSpacing; std::vector EditCurve; std::vector sugConstr1; }; - + DEF_STD_CMD_A(CmdSketcherRectangularArray); @@ -1837,7 +1836,7 @@ void CmdSketcherRectangularArray::activated(int iMsg) QObject::tr("Select elements from a single sketch.")); return; } - + // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); if (SubNames.empty()) { @@ -1847,13 +1846,13 @@ void CmdSketcherRectangularArray::activated(int iMsg) } Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - + getSelection().clearSelection(); int LastGeoId = 0; Sketcher::PointPos LastPointPos = Sketcher::none; const Part::Geometry *LastGeo = 0; - + // create python command with list of elements std::stringstream stream; int geoids = 0; @@ -1863,9 +1862,9 @@ void CmdSketcherRectangularArray::activated(int iMsg) if (it->size() > 4 && it->substr(0,4) == "Edge") { LastGeoId = std::atoi(it->substr(4,4000).c_str()) - 1; LastPointPos = Sketcher::none; - + LastGeo = Obj->getGeometry(LastGeoId); - + // lines to copy if (LastGeoId>=0) { geoids++; @@ -1889,7 +1888,7 @@ void CmdSketcherRectangularArray::activated(int iMsg) } } } - + // check if last selected element is a Vertex, not being a GeomPoint if (SubNames.rbegin()->size() > 6 && SubNames.rbegin()->substr(0,6) == "Vertex") { int VtId = std::atoi(SubNames.rbegin()->substr(6,4000).c_str()) - 1; @@ -1906,13 +1905,13 @@ void CmdSketcherRectangularArray::activated(int iMsg) QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("A copy requires at least one selected non-external geometric element")); return; - } + } std::string geoIdList = stream.str(); // remove the last added comma and brackets to make the python list int index = geoIdList.rfind(','); - geoIdList.resize(index); + geoIdList.resize(index); geoIdList.insert(0,1,'['); geoIdList.append(1,']'); @@ -2032,36 +2031,36 @@ CmdSketcherDeleteAllConstraints::CmdSketcherDeleteAllConstraints() void CmdSketcherDeleteAllConstraints::activated(int iMsg) { Q_UNUSED(iMsg); - + int ret = QMessageBox::question(Gui::getMainWindow(), QObject::tr("Delete All Constraints"), QObject::tr("Are you really sure you want to delete all the constraints?"), QMessageBox::Yes, QMessageBox::Cancel); if (ret == QMessageBox::Yes) { getSelection().clearSelection(); - + Gui::Document * doc= getActiveGuiDocument(); - + SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); - + Sketcher::SketchObject* Obj= vp->getSketchObject(); - + try { Gui::Command::openCommand("Delete All Constraints"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.deleteAllConstraints()", Obj->getNameInDocument()); - + Gui::Command::commitCommand(); } catch (const Base::Exception& e) { Base::Console().Error("Failed to delete All Constraints: %s\n", e.what()); Gui::Command::abortCommand(); } - + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); bool autoRecompute = hGrp->GetBool("AutoRecompute",false); - + if(autoRecompute) Gui::Command::updateActive(); else @@ -2071,7 +2070,7 @@ void CmdSketcherDeleteAllConstraints::activated(int iMsg) // do nothing return; } - + } bool CmdSketcherDeleteAllConstraints::isActive(void) diff --git a/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp b/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp index b21d18451d..34c8250db8 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp @@ -28,9 +28,8 @@ # include # include # include -#endif - # include +#endif #include #include @@ -155,13 +154,13 @@ void CmdSketcherSwitchVirtualSpace::activated(int iMsg) QObject::tr("Select constraint(s) from the sketch.")); return; } - + SketcherGui::ViewProviderSketch* sketchgui = static_cast(getActiveGuiDocument()->getInEdit()); Sketcher::SketchObject* Obj = sketchgui->getSketchObject(); - + // undo command open openCommand("Toggle constraints to the other virtual space"); - + int successful=SubNames.size(); // go through the selected subelements for (std::vector::const_iterator it=SubNames.begin();it!=SubNames.end();++it){ diff --git a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp index eec1b16301..a171c43bef 100644 --- a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp +++ b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp @@ -27,9 +27,8 @@ # include # include # include -#endif - # include +#endif #include #include @@ -141,7 +140,7 @@ void EditDatumDialog::exec(bool atCursor) 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(); diff --git a/src/Mod/Sketcher/Gui/PreCompiled.h b/src/Mod/Sketcher/Gui/PreCompiled.h index 8e1a525484..6d644135ea 100644 --- a/src/Mod/Sketcher/Gui/PreCompiled.h +++ b/src/Mod/Sketcher/Gui/PreCompiled.h @@ -33,11 +33,11 @@ # define PartGuiExport __declspec(dllimport) # define SketcherGuiExport __declspec(dllexport) #else // for Linux -# define SketcherExport +# define SketcherExport # define PartExport -# define PartAppExport -# define PartGuiExport -# define SketcherGuiExport +# define PartAppExport +# define PartGuiExport +# define SketcherGuiExport #endif @@ -52,6 +52,8 @@ #include #include +#include + // STL #include #include @@ -63,6 +65,11 @@ #include #include +// Boost +#include +#include +#include + #ifdef FC_OS_WIN32 # define NOMINMAX # include @@ -70,15 +77,50 @@ // OCC #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // Qt Toolkit #ifndef __Qt4All__ # include #endif + +# include +#include +#include + // all of Inventor #ifndef __InventorAll__ # include -#endif +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // Python #include diff --git a/src/Mod/Sketcher/Gui/SoDatumLabel.cpp b/src/Mod/Sketcher/Gui/SoDatumLabel.cpp index 12bfd83c0e..dffd888cf0 100644 --- a/src/Mod/Sketcher/Gui/SoDatumLabel.cpp +++ b/src/Mod/Sketcher/Gui/SoDatumLabel.cpp @@ -43,15 +43,16 @@ # include # include # include -#endif -#include -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include +# include +# include +#endif // _PreComp_ + #include "SoDatumLabel.h" #include @@ -424,7 +425,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action) if (action->handleTransparency(true)) return; - /**Remark from Stefan Tröger: + /**Remark from Stefan Tröger: * The scale calculation is based on knowledge of SbViewVolume::getWorldToScreenScale * implementation internals. The factor returned from this function is calculated from the view frustums * nearplane width, height is not taken into account, and hence we divide it with the viewport width @@ -465,7 +466,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action) this->imgHeight = scale * (float) (srch); this->imgWidth = aspectRatio * (float) this->imgHeight; } - + if (this->datumtype.getValue() == SYMMETRIC) { // For the symmetry constraint that does not have text, but does have arrows //this->imgHeight = 3.36f; @@ -474,7 +475,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action) this->imgHeight = scale*25.0f; this->imgWidth = scale*25.0f; } - + // Get the points stored in the pnt field const SbVec3f *points = this->pnts.getValues(0); @@ -694,7 +695,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action) glVertex2f(ar1[0], ar1[1]); glVertex2f(ar2[0], ar2[1]); glEnd(); - + if (this->datumtype.getValue() == DIAMETER) { // create second arrowhead SbVec3f ar0_1 = p1; @@ -849,9 +850,9 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action) ar1 = ar0 - dir * 0.866f * 2 * margin; ar2 = ar1 + normal * margin; ar1 -= normal * margin; - + glBegin(GL_LINES); - glVertex3f(p1[0], p1[1], ZCONSTR); + glVertex3f(p1[0], p1[1], ZCONSTR); glVertex3f(ar0[0], ar0[1], ZCONSTR); glVertex3f(ar0[0], ar0[1], ZCONSTR); glVertex3f(ar1[0], ar1[1], ZCONSTR); @@ -867,12 +868,12 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action) ar4 -= normal * margin; glBegin(GL_LINES); - glVertex3f(p2[0], p2[1], ZCONSTR); - glVertex3f(ar3[0], ar3[1], ZCONSTR); - glVertex3f(ar3[0], ar3[1], ZCONSTR); - glVertex3f(ar4[0], ar4[1], ZCONSTR); - glVertex3f(ar3[0], ar3[1], ZCONSTR); - glVertex3f(ar5[0], ar5[1], ZCONSTR); + glVertex3f(p2[0], p2[1], ZCONSTR); + glVertex3f(ar3[0], ar3[1], ZCONSTR); + glVertex3f(ar3[0], ar3[1], ZCONSTR); + glVertex3f(ar4[0], ar4[1], ZCONSTR); + glVertex3f(ar3[0], ar3[1], ZCONSTR); + glVertex3f(ar5[0], ar5[1], ZCONSTR); glEnd(); // BOUNDING BOX CALCULATION - IMPORTANT diff --git a/src/Mod/Sketcher/Gui/SoZoomTranslation.cpp b/src/Mod/Sketcher/Gui/SoZoomTranslation.cpp index 0a14cede20..136c1af475 100644 --- a/src/Mod/Sketcher/Gui/SoZoomTranslation.cpp +++ b/src/Mod/Sketcher/Gui/SoZoomTranslation.cpp @@ -27,17 +27,16 @@ # include # include # include +# include +# include +# include +# include +# include +# include +# include +# include #endif -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index 7eeeae6c5a..23fb7d59c6 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -33,6 +33,7 @@ # include # include # include +# include #endif #include "TaskSketcherConstrains.h" @@ -50,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -242,7 +242,7 @@ public: case Sketcher::Radius: return constraint->isDriving ? radi : radi_driven; case Sketcher::Diameter: - return constraint->isDriving ? dia : dia_driven; + return constraint->isDriving ? dia : dia_driven; case Sketcher::Angle: return constraint->isDriving ? angl : angl_driven; case Sketcher::SnellsLaw: @@ -335,7 +335,7 @@ public: return sketch->Constraints[ConstraintNbr]->isInVirtualSpace; } - + void updateVirtualSpaceStatus() { this->setCheckState((this->isInVirtualSpace() != sketchView->getIsShownVirtualSpace())?Qt::Unchecked:Qt::Checked); } @@ -478,7 +478,7 @@ CONTEXT_MEMBER_DEF("Sketcher_SelectElementsAssociatedWithConstraints",doSelectCo void ConstraintView::updateDrivingStatus() { QListWidgetItem* item = currentItem(); - + ConstraintItem *it = dynamic_cast(item); if (it) { onUpdateDrivingStatus(item, !it->isDriving()); @@ -757,7 +757,7 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte return; inEditMode = true; - + assert(sketchView); const Sketcher::SketchObject * sketch = sketchView->getSketchObject(); @@ -766,7 +766,7 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte const std::string currConstraintName = v->Name; const std::string basename = Base::Tools::toStdString(it->data(Qt::EditRole).toString()); - + std::string newName(Sketcher::PropertyConstraintList::getConstraintName(basename, it->ConstraintNbr)); // we only start a rename if we are really sure the name has changed, which is: @@ -797,13 +797,13 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte try { Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setVirtualSpace(%d, %s)", sketch->getNameInDocument(), - it->ConstraintNbr, + it->ConstraintNbr, ((item->checkState() == Qt::Checked) != sketchView->getIsShownVirtualSpace())?"False":"True"); Gui::Command::commitCommand(); } catch (const Base::Exception & e) { Gui::Command::abortCommand(); - + QMessageBox::critical(Gui::MainWindow::getInstance(), tr("Error"), QString::fromLatin1(e.what()), QMessageBox::Ok, QMessageBox::Ok); } diff --git a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp index 692a66d820..bfc6ff5eff 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp @@ -29,6 +29,7 @@ # include # include # include +# include #endif #include "TaskSketcherElements.h" @@ -48,7 +49,7 @@ #include #include #include -#include + #include using namespace SketcherGui; diff --git a/src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp b/src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp index f51f126f37..6ef662acee 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherMessages.cpp @@ -24,6 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include #endif #include "ui_TaskSketcherMessages.h" @@ -36,7 +37,7 @@ #include #include -#include + #include @@ -81,7 +82,7 @@ TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch *sketchView) QObject::connect( ui->manualUpdate, SIGNAL(clicked(bool)), this , SLOT (on_manualUpdate_clicked(bool)) - );*/ + );*/ } TaskSketcherMessages::~TaskSketcherMessages() @@ -105,13 +106,13 @@ void TaskSketcherMessages::on_labelConstrainStatus_linkActivated(const QString & { if( str == QString::fromLatin1("#conflicting")) Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectConflictingConstraints"); - + if( str == QString::fromLatin1("#redundant")) Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectRedundantConstraints"); - + if( str == QString::fromLatin1("#dofs")) Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectElementsWithDoFs"); - + } void TaskSketcherMessages::on_autoUpdate_stateChanged(int state) diff --git a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp index f30c30caa1..6a61447db5 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherSolverAdvanced.cpp @@ -24,6 +24,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include +# include #endif #include "ui_TaskSketcherSolverAdvanced.h" @@ -36,12 +38,8 @@ #include #include -#include - #include -#include - #include "ViewProviderSketch.h" #define LM_EPS 1E-10 @@ -102,12 +100,12 @@ void TaskSketcherSolverAdvanced::updateDefaultMethodParameters(void) int currentindex = ui->comboBoxDefaultSolver->currentIndex(); int redundantcurrentindex = ui->comboBoxRedundantDefaultSolver->currentIndex(); - + if(redundantcurrentindex == 2 || currentindex == 2) ui->comboBoxDogLegGaussStep->setEnabled(true); else - ui->comboBoxDogLegGaussStep->setEnabled(false); - + ui->comboBoxDogLegGaussStep->setEnabled(false); + switch(currentindex) { case 0: // BFGS @@ -128,11 +126,11 @@ void TaskSketcherSolverAdvanced::updateDefaultMethodParameters(void) ui->labelSolverParam3->setText(QString::fromLatin1("Tau")); ui->lineEditSolverParam1->setEnabled(true); ui->lineEditSolverParam2->setEnabled(true); - ui->lineEditSolverParam3->setEnabled(true); + ui->lineEditSolverParam3->setEnabled(true); double eps = ::atof(hGrp->GetASCII("LM_eps",QString::number(LM_EPS).toUtf8()).c_str()); - double eps1 = ::atof(hGrp->GetASCII("LM_eps1",QString::number(LM_EPS1).toUtf8()).c_str()); + double eps1 = ::atof(hGrp->GetASCII("LM_eps1",QString::number(LM_EPS1).toUtf8()).c_str()); double tau = ::atof(hGrp->GetASCII("LM_tau",QString::number(LM_TAU).toUtf8()).c_str()); - ui->lineEditSolverParam1->setText(QString::number(eps).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); + ui->lineEditSolverParam1->setText(QString::number(eps).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); ui->lineEditSolverParam2->setText(QString::number(eps1).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); ui->lineEditSolverParam3->setText(QString::number(tau).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); sketchView->getSketchObject()->getSolvedSketch().setLM_eps(eps); @@ -149,9 +147,9 @@ void TaskSketcherSolverAdvanced::updateDefaultMethodParameters(void) ui->lineEditSolverParam2->setEnabled(true); ui->lineEditSolverParam3->setEnabled(true); double tolg = ::atof(hGrp->GetASCII("DL_tolg",QString::number(DL_TOLG).toUtf8()).c_str()); - double tolx = ::atof(hGrp->GetASCII("DL_tolx",QString::number(DL_TOLX).toUtf8()).c_str()); + double tolx = ::atof(hGrp->GetASCII("DL_tolx",QString::number(DL_TOLX).toUtf8()).c_str()); double tolf = ::atof(hGrp->GetASCII("DL_tolf",QString::number(DL_TOLF).toUtf8()).c_str()); - ui->lineEditSolverParam1->setText(QString::number(tolg).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); + ui->lineEditSolverParam1->setText(QString::number(tolg).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); ui->lineEditSolverParam2->setText(QString::number(tolx).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); ui->lineEditSolverParam3->setText(QString::number(tolf).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); sketchView->getSketchObject()->getSolvedSketch().setDL_tolg(tolg); @@ -168,12 +166,12 @@ void TaskSketcherSolverAdvanced::updateRedundantMethodParameters(void) int currentindex = ui->comboBoxDefaultSolver->currentIndex(); int redundantcurrentindex = ui->comboBoxRedundantDefaultSolver->currentIndex(); - + if(redundantcurrentindex == 2 || currentindex == 2) ui->comboBoxDogLegGaussStep->setEnabled(true); else - ui->comboBoxDogLegGaussStep->setEnabled(false); - + ui->comboBoxDogLegGaussStep->setEnabled(false); + switch(redundantcurrentindex) { case 0: // BFGS @@ -182,7 +180,7 @@ void TaskSketcherSolverAdvanced::updateRedundantMethodParameters(void) ui->labelRedundantSolverParam3->setText(QString::fromLatin1("")); ui->lineEditRedundantSolverParam1->clear(); ui->lineEditRedundantSolverParam2->clear(); - ui->lineEditRedundantSolverParam3->clear(); + ui->lineEditRedundantSolverParam3->clear(); ui->lineEditRedundantSolverParam1->setDisabled(true); ui->lineEditRedundantSolverParam2->setDisabled(true); ui->lineEditRedundantSolverParam3->setDisabled(true); @@ -194,11 +192,11 @@ void TaskSketcherSolverAdvanced::updateRedundantMethodParameters(void) ui->labelRedundantSolverParam3->setText(QString::fromLatin1("R.Tau")); ui->lineEditRedundantSolverParam1->setEnabled(true); ui->lineEditRedundantSolverParam2->setEnabled(true); - ui->lineEditRedundantSolverParam3->setEnabled(true); + ui->lineEditRedundantSolverParam3->setEnabled(true); double eps = ::atof(hGrp->GetASCII("Redundant_LM_eps",QString::number(LM_EPS).toUtf8()).c_str()); - double eps1 = ::atof(hGrp->GetASCII("Redundant_LM_eps1",QString::number(LM_EPS1).toUtf8()).c_str()); + double eps1 = ::atof(hGrp->GetASCII("Redundant_LM_eps1",QString::number(LM_EPS1).toUtf8()).c_str()); double tau = ::atof(hGrp->GetASCII("Redundant_LM_tau",QString::number(LM_TAU).toUtf8()).c_str()); - ui->lineEditRedundantSolverParam1->setText(QString::number(eps).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); + ui->lineEditRedundantSolverParam1->setText(QString::number(eps).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); ui->lineEditRedundantSolverParam2->setText(QString::number(eps1).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); ui->lineEditRedundantSolverParam3->setText(QString::number(tau).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); sketchView->getSketchObject()->getSolvedSketch().setLM_epsRedundant(eps); @@ -215,9 +213,9 @@ void TaskSketcherSolverAdvanced::updateRedundantMethodParameters(void) ui->lineEditRedundantSolverParam2->setEnabled(true); ui->lineEditRedundantSolverParam3->setEnabled(true); double tolg = ::atof(hGrp->GetASCII("Redundant_DL_tolg",QString::number(DL_TOLG).toUtf8()).c_str()); - double tolx = ::atof(hGrp->GetASCII("Redundant_DL_tolx",QString::number(DL_TOLX).toUtf8()).c_str()); + double tolx = ::atof(hGrp->GetASCII("Redundant_DL_tolx",QString::number(DL_TOLX).toUtf8()).c_str()); double tolf = ::atof(hGrp->GetASCII("Redundant_DL_tolf",QString::number(DL_TOLF).toUtf8()).c_str()); - ui->lineEditRedundantSolverParam1->setText(QString::number(tolg).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); + ui->lineEditRedundantSolverParam1->setText(QString::number(tolg).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); ui->lineEditRedundantSolverParam2->setText(QString::number(tolx).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); ui->lineEditRedundantSolverParam3->setText(QString::number(tolf).remove(QString::fromLatin1("+").replace(QString::fromLatin1("e0"),QString::fromLatin1("E")).toUpper())); sketchView->getSketchObject()->getSolvedSketch().setDL_tolgRedundant(tolg); @@ -517,23 +515,23 @@ void TaskSketcherSolverAdvanced::on_pushButtonDefaults_clicked(bool checked/* = { Q_UNUSED(checked); // Algorithm params for default solvers - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/SolverAdvanced"); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/SolverAdvanced"); hGrp->SetASCII("LM_eps",QString::number(LM_EPS).toUtf8()); - hGrp->SetASCII("LM_eps1",QString::number(LM_EPS1).toUtf8()); + hGrp->SetASCII("LM_eps1",QString::number(LM_EPS1).toUtf8()); hGrp->SetASCII("LM_tau",QString::number(LM_TAU).toUtf8()); hGrp->SetASCII("DL_tolg",QString::number(DL_TOLG).toUtf8()); - hGrp->SetASCII("DL_tolx",QString::number(DL_TOLX).toUtf8()); + hGrp->SetASCII("DL_tolx",QString::number(DL_TOLX).toUtf8()); hGrp->SetASCII("DL_tolf",QString::number(DL_TOLF).toUtf8()); hGrp->SetASCII("Redundant_LM_eps",QString::number(LM_EPS).toUtf8()); - hGrp->SetASCII("Redundant_LM_eps1",QString::number(LM_EPS1).toUtf8()); - hGrp->SetASCII("Redundant_LM_tau",QString::number(LM_TAU).toUtf8()); - hGrp->SetASCII("Redundant_DL_tolg",QString::number(DL_TOLG).toUtf8()); - hGrp->SetASCII("Redundant_DL_tolx",QString::number(DL_TOLX).toUtf8()); - hGrp->SetASCII("Redundant_DL_tolf",QString::number(DL_TOLF).toUtf8()); + hGrp->SetASCII("Redundant_LM_eps1",QString::number(LM_EPS1).toUtf8()); + hGrp->SetASCII("Redundant_LM_tau",QString::number(LM_TAU).toUtf8()); + hGrp->SetASCII("Redundant_DL_tolg",QString::number(DL_TOLG).toUtf8()); + hGrp->SetASCII("Redundant_DL_tolx",QString::number(DL_TOLX).toUtf8()); + hGrp->SetASCII("Redundant_DL_tolf",QString::number(DL_TOLF).toUtf8()); // Set other settings hGrp->SetInt("DefaultSolver",DEFAULT_SOLVER); hGrp->SetInt("DogLegGaussStep",DEFAULT_DOGLEG_GAUSS_STEP); - + hGrp->SetInt("RedundantDefaultSolver",DEFAULT_RSOLVER); hGrp->SetInt("MaxIter",MAX_ITER); hGrp->SetInt("RedundantSolverMaxIterations",MAX_ITER); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp b/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp index ba6764e33d..7fc540ddac 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp @@ -34,20 +34,19 @@ # include # include # include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "ui_TaskSketcherValidation.h" #include "TaskSketcherValidation.h" #include diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index d3776d9c03..03bb6b81b5 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -56,6 +56,7 @@ # include # include # include +# include # include /// Qt Include Files @@ -70,14 +71,14 @@ # include # include # include -#endif -#ifndef _PreComp_ # include +# include #endif -#include -#include + + + /// Here the FreeCAD includes sorted by Base,App,Gui...... #include diff --git a/src/Mod/Sketcher/Gui/Workbench.cpp b/src/Mod/Sketcher/Gui/Workbench.cpp index 54fcf00936..132b61df4c 100644 --- a/src/Mod/Sketcher/Gui/Workbench.cpp +++ b/src/Mod/Sketcher/Gui/Workbench.cpp @@ -80,11 +80,11 @@ Gui::MenuItem* Workbench::setupMenuBar() const Gui::MenuItem* consaccel = new Gui::MenuItem(); consaccel->setCommand("Sketcher tools"); addSketcherWorkbenchTools(*consaccel); - + Gui::MenuItem* bsplines = new Gui::MenuItem(); bsplines->setCommand("Sketcher B-spline tools"); addSketcherWorkbenchBSplines(*bsplines); - + Gui::MenuItem* virtualspace = new Gui::MenuItem(); virtualspace->setCommand("Sketcher virtual space"); addSketcherWorkbenchVirtualSpace(*virtualspace); @@ -118,11 +118,11 @@ Gui::ToolBarItem* Workbench::setupToolBars() const Gui::ToolBarItem* consaccel = new Gui::ToolBarItem(root); consaccel->setCommand("Sketcher tools"); addSketcherWorkbenchTools( *consaccel ); - + Gui::ToolBarItem* bspline = new Gui::ToolBarItem(root); bspline->setCommand("Sketcher B-spline tools"); addSketcherWorkbenchBSplines( *bspline ); - + Gui::ToolBarItem* virtualspace = new Gui::ToolBarItem(root); virtualspace->setCommand("Sketcher virtual space"); addSketcherWorkbenchVirtualSpace( *virtualspace );