diff --git a/src/Mod/Fem/Gui/AbaqusHighlighter.cpp b/src/Mod/Fem/Gui/AbaqusHighlighter.cpp index 159dbbf68a..3465c6e766 100644 --- a/src/Mod/Fem/Gui/AbaqusHighlighter.cpp +++ b/src/Mod/Fem/Gui/AbaqusHighlighter.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include "AbaqusHighlighter.h" @@ -35,8 +35,7 @@ using namespace FemGui; */ AbaqusHighlighter::AbaqusHighlighter(QObject* parent) : SyntaxHighlighter(parent) -{ -} +{} /** Destroys this object. */ AbaqusHighlighter::~AbaqusHighlighter() = default; @@ -46,16 +45,26 @@ void AbaqusHighlighter::highlightBlock(const QString& text) // Find a syntax file for the Abaqus format here // http://notepad-plus.sourceforge.net/commun/userDefinedLang/userDefineLang_Abaqus.xml // - enum { NormalState = -1, Definition, BeforeKey, InideKey, BeforeValue, InsideValue, Text, Number }; + enum + { + NormalState = -1, + Definition, + BeforeKey, + InideKey, + BeforeValue, + InsideValue, + Text, + Number + }; int state = NormalState; int start = 0; - QColor keywordColor(102, 0, 227); // this->colorByType(SyntaxHighlighter::Keyword) - QColor defnameColor(0, 119, 255); // this->colorByType(SyntaxHighlighter::Defname) - QColor operateColor(153, 0, 102); // this->colorByType(SyntaxHighlighter::Operator) - QColor valueColor(0, 0, 0); // this->colorByType(SyntaxHighlighter::String) - QColor numberColor(0, 127, 127); // this->colorByType(SyntaxHighlighter::Number) + QColor keywordColor(102, 0, 227); // this->colorByType(SyntaxHighlighter::Keyword) + QColor defnameColor(0, 119, 255); // this->colorByType(SyntaxHighlighter::Defname) + QColor operateColor(153, 0, 102); // this->colorByType(SyntaxHighlighter::Operator) + QColor valueColor(0, 0, 0); // this->colorByType(SyntaxHighlighter::String) + QColor numberColor(0, 127, 127); // this->colorByType(SyntaxHighlighter::Number) QColor commentColor = this->colorByType(SyntaxHighlighter::Comment); for (int i = 0; i < text.length(); ++i) { diff --git a/src/Mod/Fem/Gui/AbaqusHighlighter.h b/src/Mod/Fem/Gui/AbaqusHighlighter.h index 38311646f5..26e7d6b4a1 100644 --- a/src/Mod/Fem/Gui/AbaqusHighlighter.h +++ b/src/Mod/Fem/Gui/AbaqusHighlighter.h @@ -26,22 +26,23 @@ #include -namespace FemGui { +namespace FemGui +{ /** * Syntax highlighter for Abaqus. * @author Werner Mayer */ -class AbaqusHighlighter : public Gui::SyntaxHighlighter +class AbaqusHighlighter: public Gui::SyntaxHighlighter { public: explicit AbaqusHighlighter(QObject* parent); ~AbaqusHighlighter() override; protected: - void highlightBlock(const QString &text) override; + void highlightBlock(const QString& text) override; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_ABAQUSHIGHLIGHTER_H +#endif // FEMGUI_ABAQUSHIGHLIGHTER_H diff --git a/src/Mod/Fem/Gui/ActiveAnalysisObserver.cpp b/src/Mod/Fem/Gui/ActiveAnalysisObserver.cpp index 221bf456f5..f91a693d5a 100644 --- a/src/Mod/Fem/Gui/ActiveAnalysisObserver.cpp +++ b/src/Mod/Fem/Gui/ActiveAnalysisObserver.cpp @@ -36,8 +36,9 @@ ActiveAnalysisObserver* ActiveAnalysisObserver::inst = nullptr; ActiveAnalysisObserver* ActiveAnalysisObserver::instance() { - if (!inst) + if (!inst) { inst = new ActiveAnalysisObserver(); + } return inst; } @@ -51,7 +52,8 @@ void ActiveAnalysisObserver::setActiveObject(Fem::FemAnalysis* fem) activeObject = fem; App::Document* doc = fem->getDocument(); activeDocument = Gui::Application::Instance->getDocument(doc); - activeView = static_cast(activeDocument->getViewProvider(activeObject)); + activeView = static_cast( + activeDocument->getViewProvider(activeObject)); attachDocument(doc); } else { @@ -72,8 +74,9 @@ bool ActiveAnalysisObserver::hasActiveObject() const void ActiveAnalysisObserver::highlightActiveObject(const Gui::HighlightMode& mode, bool on) { - if (activeDocument && activeView) + if (activeDocument && activeView) { activeDocument->signalHighlightObject(*activeView, mode, on, 0, 0); + } } void ActiveAnalysisObserver::slotDeletedDocument(const App::Document& Doc) diff --git a/src/Mod/Fem/Gui/ActiveAnalysisObserver.h b/src/Mod/Fem/Gui/ActiveAnalysisObserver.h index 99e7cd740d..8715cf1112 100644 --- a/src/Mod/Fem/Gui/ActiveAnalysisObserver.h +++ b/src/Mod/Fem/Gui/ActiveAnalysisObserver.h @@ -27,16 +27,21 @@ #include #include -namespace Gui { - class Document; - class ViewProviderDocumentObject; +namespace Gui +{ +class Document; +class ViewProviderDocumentObject; +} // namespace Gui + +namespace Fem +{ +class FemAnalysis; } -namespace Fem { class FemAnalysis; } +namespace FemGui +{ -namespace FemGui { - -class ActiveAnalysisObserver : public App::DocumentObserver +class ActiveAnalysisObserver: public App::DocumentObserver { public: static ActiveAnalysisObserver* instance(); @@ -55,11 +60,11 @@ private: private: static ActiveAnalysisObserver* inst; - Fem::FemAnalysis* activeObject{nullptr}; - Gui::ViewProviderDocumentObject* activeView{nullptr}; - Gui::Document* activeDocument{nullptr}; + Fem::FemAnalysis* activeObject {nullptr}; + Gui::ViewProviderDocumentObject* activeView {nullptr}; + Gui::Document* activeDocument {nullptr}; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEMGUI_ACTIVEANALYSISOBSERVER_H +#endif // FEMGUI_ACTIVEANALYSISOBSERVER_H diff --git a/src/Mod/Fem/Gui/AppFemGui.cpp b/src/Mod/Fem/Gui/AppFemGui.cpp index b78b69da81..d1dd8acf3f 100644 --- a/src/Mod/Fem/Gui/AppFemGui.cpp +++ b/src/Mod/Fem/Gui/AppFemGui.cpp @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include "DlgSettingsFemCcxImp.h" #include "DlgSettingsFemElmerImp.h" @@ -39,21 +39,13 @@ #include "DlgSettingsFemZ88Imp.h" #include "PropertyFemMeshItem.h" #include "ViewProviderAnalysis.h" -#include "ViewProviderFemMesh.h" -#include "ViewProviderFemMeshShape.h" -#include "ViewProviderFemMeshShapeNetgen.h" -#include "ViewProviderSetElements.h" -#include "ViewProviderSetFaces.h" -#include "ViewProviderSetGeometry.h" -#include "ViewProviderSetNodes.h" -#include "ViewProviderSolver.h" #include "ViewProviderFemConstraint.h" #include "ViewProviderFemConstraintBearing.h" #include "ViewProviderFemConstraintContact.h" #include "ViewProviderFemConstraintDisplacement.h" #include "ViewProviderFemConstraintFixed.h" -#include "ViewProviderFemConstraintForce.h" #include "ViewProviderFemConstraintFluidBoundary.h" +#include "ViewProviderFemConstraintForce.h" #include "ViewProviderFemConstraintGear.h" #include "ViewProviderFemConstraintHeatflux.h" #include "ViewProviderFemConstraintInitialTemperature.h" @@ -64,7 +56,15 @@ #include "ViewProviderFemConstraintSpring.h" #include "ViewProviderFemConstraintTemperature.h" #include "ViewProviderFemConstraintTransform.h" +#include "ViewProviderFemMesh.h" +#include "ViewProviderFemMeshShape.h" +#include "ViewProviderFemMeshShapeNetgen.h" #include "ViewProviderResult.h" +#include "ViewProviderSetElements.h" +#include "ViewProviderSetFaces.h" +#include "ViewProviderSetGeometry.h" +#include "ViewProviderSetNodes.h" +#include "ViewProviderSolver.h" #include "Workbench.h" #ifdef FC_USE_VTK @@ -75,7 +75,7 @@ #endif - // use a different name to CreateCommand() +// use a different name to CreateCommand() void CreateFemCommands(); void loadFemResource() @@ -86,8 +86,9 @@ void loadFemResource() Gui::Translator::instance()->refresh(); } -namespace FemGui { - extern PyObject* initModule(); +namespace FemGui +{ +extern PyObject* initModule(); } @@ -105,6 +106,7 @@ PyMOD_INIT_FUNC(FemGui) // instantiating the commands CreateFemCommands(); + // clang-format off // addition objects FemGui::Workbench ::init(); @@ -184,6 +186,7 @@ PyMOD_INIT_FUNC(FemGui) // add resources and reloads the translators loadFemResource(); + // clang-format on PyMOD_Return(mod); } diff --git a/src/Mod/Fem/Gui/AppFemGuiPy.cpp b/src/Mod/Fem/Gui/AppFemGuiPy.cpp old mode 100755 new mode 100644 index 4f0382a446..045f222064 --- a/src/Mod/Fem/Gui/AppFemGuiPy.cpp +++ b/src/Mod/Fem/Gui/AppFemGuiPy.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -37,25 +37,27 @@ #include "ActiveAnalysisObserver.h" -namespace FemGui { -class Module : public Py::ExtensionModule +namespace FemGui +{ +class Module: public Py::ExtensionModule { public: - Module() : Py::ExtensionModule("FemGui") + Module() + : Py::ExtensionModule("FemGui") { - add_varargs_method("setActiveAnalysis", &Module::setActiveAnalysis, - "setActiveAnalysis(AnalysisObject) -- Set the Analysis object in work." - ); - add_varargs_method("getActiveAnalysis", &Module::getActiveAnalysis, - "getActiveAnalysis() -- Returns the Analysis object in work." - ); - add_varargs_method("open", &Module::open, - "open(string) -- Opens an Abaqus file in a text editor." - ); - add_varargs_method("insert", &Module::open, - "insert(string,string) -- Opens an Abaqus file in a text editor." - ); - initialize("This module is the FemGui module."); // register with Python + add_varargs_method("setActiveAnalysis", + &Module::setActiveAnalysis, + "setActiveAnalysis(AnalysisObject) -- Set the Analysis object in work."); + add_varargs_method("getActiveAnalysis", + &Module::getActiveAnalysis, + "getActiveAnalysis() -- Returns the Analysis object in work."); + add_varargs_method("open", + &Module::open, + "open(string) -- Opens an Abaqus file in a text editor."); + add_varargs_method("insert", + &Module::open, + "insert(string,string) -- Opens an Abaqus file in a text editor."); + initialize("This module is the FemGui module."); // register with Python } private: @@ -74,30 +76,40 @@ private: Py::Object setActiveAnalysis(const Py::Tuple& args) { if (FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) { - FemGui::ActiveAnalysisObserver::instance()->highlightActiveObject(Gui::HighlightMode::Blue, false); + FemGui::ActiveAnalysisObserver::instance()->highlightActiveObject( + Gui::HighlightMode::Blue, + false); FemGui::ActiveAnalysisObserver::instance()->setActiveObject(nullptr); } PyObject* object = nullptr; - if (PyArg_ParseTuple(args.ptr(), "|O!", &(App::DocumentObjectPy::Type), &object) && object) { - App::DocumentObject* obj = static_cast(object)->getDocumentObjectPtr(); + if (PyArg_ParseTuple(args.ptr(), "|O!", &(App::DocumentObjectPy::Type), &object) + && object) { + App::DocumentObject* obj = + static_cast(object)->getDocumentObjectPtr(); if (!obj || !obj->getTypeId().isDerivedFrom(Fem::FemAnalysis::getClassTypeId())) { - throw Py::Exception(Base::PyExc_FC_GeneralError, "Active Analysis object have to be of type Fem::FemAnalysis!"); + throw Py::Exception(Base::PyExc_FC_GeneralError, + "Active Analysis object have to be of type Fem::FemAnalysis!"); } // get the gui document of the Analysis Item - FemGui::ActiveAnalysisObserver::instance()->setActiveObject(static_cast(obj)); - FemGui::ActiveAnalysisObserver::instance()->highlightActiveObject(Gui::HighlightMode::Blue, true); + FemGui::ActiveAnalysisObserver::instance()->setActiveObject( + static_cast(obj)); + FemGui::ActiveAnalysisObserver::instance()->highlightActiveObject( + Gui::HighlightMode::Blue, + true); } return Py::None(); } Py::Object getActiveAnalysis(const Py::Tuple& args) { - if (!PyArg_ParseTuple(args.ptr(), "")) + if (!PyArg_ParseTuple(args.ptr(), "")) { throw Py::Exception(); + } if (FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) { - return Py::asObject(FemGui::ActiveAnalysisObserver::instance()->getActiveObject()->getPyObject()); + return Py::asObject( + FemGui::ActiveAnalysisObserver::instance()->getActiveObject()->getPyObject()); } return Py::None(); } @@ -105,8 +117,9 @@ private: { char* Name; const char* DocName; - if (!PyArg_ParseTuple(args.ptr(), "et|s", "utf-8", &Name, &DocName)) + if (!PyArg_ParseTuple(args.ptr(), "et|s", "utf-8", &Name, &DocName)) { throw Py::Exception(); + } std::string EncodedName = std::string(Name); PyMem_Free(Name); @@ -123,14 +136,14 @@ private: } } - if ( (ext == QLatin1String("inp")) - || (ext == QLatin1String("sif")) - || (ext == QLatin1String("txt")) ) { + if ((ext == QLatin1String("inp")) || (ext == QLatin1String("sif")) + || (ext == QLatin1String("txt"))) { Gui::TextEditor* editor = new Gui::TextEditor(); editor->setWindowIcon(Gui::BitmapFactory().pixmap(":/icons/fem-solver-inp-editor.svg")); Gui::EditorView* edit = new Gui::EditorView(editor, Gui::getMainWindow()); - if (ext == QLatin1String("inp")) + if (ext == QLatin1String("inp")) { editor->setSyntaxHighlighter(new FemGui::AbaqusHighlighter(editor)); + } edit->setDisplayName(Gui::EditorView::FileName); edit->open(fileName); edit->resize(400, 300); @@ -150,4 +163,4 @@ PyObject* initModule() return Base::Interpreter().addModule(new Module); } -} // namespace FemGui +} // namespace FemGui diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index 35cfaca076..2643fbeff0 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -22,14 +22,14 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include #endif #include @@ -81,11 +81,12 @@ bool getConstraintPrerequisits(Fem::FemAnalysis** Analysis) return false; } -//OvG: Visibility automation show parts and hide meshes on activation of a constraint +// OvG: Visibility automation show parts and hide meshes on activation of a constraint std::string gethideMeshShowPartStr(std::string showConstr = "") { return "for amesh in App.activeDocument().Objects:\n\ - if \"" + showConstr + "\" == amesh.Name:\n\ + if \"" + + showConstr + "\" == amesh.Name:\n\ amesh.ViewObject.Visibility = True\n\ elif \"Mesh\" in amesh.TypeId:\n\ aparttoshow = amesh.Name.replace(\"_Mesh\",\"\")\n\ @@ -141,12 +142,14 @@ void CmdFemAddPart::activated(int) Part::Feature *base = static_cast(selection[0].getObject()); std::string AnalysisName = getUniqueObjectName("FemAnalysis"); - std::string MeshName = getUniqueObjectName((std::string(base->getNameInDocument()) +"_Mesh").c_str()); + std::string MeshName = getUniqueObjectName((std::string(base->getNameInDocument()) ++"_Mesh").c_str()); openCommand(QT_TRANSLATE_NOOP("Command", "Create FEM analysis")); doCommand(Doc,"App.activeDocument().addObject('Fem::FemAnalysis','%s')",AnalysisName.c_str()); doCommand(Doc,"App.activeDocument().addObject('Fem::FemMeshShapeNetgenObject','%s')",MeshName.c_str()); - doCommand(Doc,"App.activeDocument().ActiveObject.Shape = App.activeDocument().%s",base->getNameInDocument()); + doCommand(Doc,"App.activeDocument().ActiveObject.Shape = +App.activeDocument().%s",base->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",AnalysisName.c_str(),MeshName.c_str()); addModule(Gui,"FemGui"); doCommand(Gui,"FemGui.setActiveAnalysis(App.activeDocument().%s)",AnalysisName.c_str()); @@ -175,33 +178,36 @@ DEF_STD_CMD_A(CmdFemConstraintBearing) CmdFemConstraintBearing::CmdFemConstraintBearing() : Command("FEM_ConstraintBearing") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Bearing constraint"); - sToolTipText = QT_TR_NOOP("Creates a bearing constraint"); - sWhatsThis = "FEM_ConstraintBearing"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintBearing"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Bearing constraint"); + sToolTipText = QT_TR_NOOP("Creates a bearing constraint"); + sWhatsThis = "FEM_ConstraintBearing"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintBearing"; } void CmdFemConstraintBearing::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintBearing"); openCommand(QT_TRANSLATE_NOOP("Command", "Make bearing constraint")); - doCommand( - Doc, "App.activeDocument().addObject(\"Fem::ConstraintBearing\",\"%s\")", FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Fem::ConstraintBearing\",\"%s\")", + FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -220,41 +226,45 @@ DEF_STD_CMD_A(CmdFemConstraintContact) CmdFemConstraintContact::CmdFemConstraintContact() : Command("FEM_ConstraintContact") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Contact constraint"); - sToolTipText = QT_TR_NOOP("Creates a contact constraint between faces"); - sWhatsThis = "FEM_ConstraintContact"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintContact"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Contact constraint"); + sToolTipText = QT_TR_NOOP("Creates a contact constraint between faces"); + sWhatsThis = "FEM_ConstraintContact"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintContact"; } void CmdFemConstraintContact::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintContact"); openCommand(QT_TRANSLATE_NOOP("Command", "Make contact constraint on a face")); - doCommand( - Doc, "App.activeDocument().addObject(\"Fem::ConstraintContact\",\"%s\")", FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Fem::ConstraintContact\",\"%s\")", + FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.Slope = 1000000.00", - FeatName.c_str());//OvG: set default not equal to 0 + FeatName.c_str()); // OvG: set default not equal to 0 doCommand(Doc, "App.activeDocument().%s.Friction = 0.0", - FeatName.c_str());//OvG: set default not equal to 0 - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + FeatName.c_str()); // OvG: set default not equal to 0 + doCommand(Doc, + "App.activeDocument().%s.Scale = 1", + FeatName.c_str()); // OvG: set initial scale to 1 doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -276,8 +286,7 @@ CmdFemConstraintDisplacement::CmdFemConstraintDisplacement() sAppModule = "Fem"; sGroup = QT_TR_NOOP("Fem"); sMenuText = QT_TR_NOOP("Displacement boundary condition"); - sToolTipText = - QT_TR_NOOP("Creates a displacement boundary condition for a geometric entity"); + sToolTipText = QT_TR_NOOP("Creates a displacement boundary condition for a geometric entity"); sWhatsThis = "FEM_ConstraintDisplacement"; sStatusTip = sToolTipText; sPixmap = "FEM_ConstraintDisplacement"; @@ -287,8 +296,9 @@ void CmdFemConstraintDisplacement::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintDisplacement"); @@ -296,14 +306,15 @@ void CmdFemConstraintDisplacement::activated(int) doCommand(Doc, "App.activeDocument().addObject(\"Fem::ConstraintDisplacement\",\"%s\")", FeatName.c_str()); - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + // OvG: set initial scale to 1 + doCommand(Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -322,35 +333,38 @@ DEF_STD_CMD_A(CmdFemConstraintFixed) CmdFemConstraintFixed::CmdFemConstraintFixed() : Command("FEM_ConstraintFixed") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Fixed boundary condition"); - sToolTipText = QT_TR_NOOP("Creates a fixed boundary condition for a geometric entity"); - sWhatsThis = "FEM_ConstraintFixed"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintFixed"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Fixed boundary condition"); + sToolTipText = QT_TR_NOOP("Creates a fixed boundary condition for a geometric entity"); + sWhatsThis = "FEM_ConstraintFixed"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintFixed"; } void CmdFemConstraintFixed::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintFixed"); openCommand(QT_TRANSLATE_NOOP("Command", "Make fixed boundary condition for geometry")); - doCommand( - Doc, "App.activeDocument().addObject(\"Fem::ConstraintFixed\",\"%s\")", FeatName.c_str()); - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + doCommand(Doc, + "App.activeDocument().addObject(\"Fem::ConstraintFixed\",\"%s\")", + FeatName.c_str()); + // OvG: set initial scale to 1 + doCommand(Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -383,8 +397,9 @@ void CmdFemConstraintFluidBoundary::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintFluidBoundary"); @@ -392,15 +407,17 @@ void CmdFemConstraintFluidBoundary::activated(int) doCommand(Doc, "App.activeDocument().addObject(\"Fem::ConstraintFluidBoundary\",\"%s\")", FeatName.c_str()); - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 - //BoundaryValue is already the default value, zero is acceptable + doCommand(Doc, + "App.activeDocument().%s.Scale = 1", + FeatName.c_str()); // OvG: set initial scale to 1 + // BoundaryValue is already the default value, zero is acceptable doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); doCommand(Gui, "Gui.activeDocument().setEdit('%s')", FeatName.c_str()); @@ -431,28 +448,32 @@ void CmdFemConstraintForce::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintForce"); openCommand(QT_TRANSLATE_NOOP("Command", "Make force load on geometry")); - doCommand( - Doc, "App.activeDocument().addObject(\"Fem::ConstraintForce\",\"%s\")", FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Fem::ConstraintForce\",\"%s\")", + FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.Force = 1.0", - FeatName.c_str());//OvG: set default not equal to 0 + FeatName.c_str()); // OvG: set default not equal to 0 doCommand(Doc, "App.activeDocument().%s.Reversed = False", - FeatName.c_str());//OvG: set default to False - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + FeatName.c_str()); // OvG: set default to False + doCommand(Doc, + "App.activeDocument().%s.Scale = 1", + FeatName.c_str()); // OvG: set initial scale to 1 doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -471,33 +492,36 @@ DEF_STD_CMD_A(CmdFemConstraintGear) CmdFemConstraintGear::CmdFemConstraintGear() : Command("FEM_ConstraintGear") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Gear constraint"); - sToolTipText = QT_TR_NOOP("Creates a gear constraint"); - sWhatsThis = "FEM_ConstraintGear"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintGear"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Gear constraint"); + sToolTipText = QT_TR_NOOP("Creates a gear constraint"); + sWhatsThis = "FEM_ConstraintGear"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintGear"; } void CmdFemConstraintGear::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintGear"); openCommand(QT_TRANSLATE_NOOP("Command", "Make gear constraint")); - doCommand( - Doc, "App.activeDocument().addObject(\"Fem::ConstraintGear\",\"%s\")", FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Fem::ConstraintGear\",\"%s\")", + FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.Diameter = 100.0", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -516,21 +540,22 @@ DEF_STD_CMD_A(CmdFemConstraintHeatflux) CmdFemConstraintHeatflux::CmdFemConstraintHeatflux() : Command("FEM_ConstraintHeatflux") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Heat flux load"); - sToolTipText = QT_TR_NOOP("Creates a heat flux load acting on a face"); - sWhatsThis = "FEM_ConstraintHeatflux"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintHeatflux"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Heat flux load"); + sToolTipText = QT_TR_NOOP("Creates a heat flux load acting on a face"); + sWhatsThis = "FEM_ConstraintHeatflux"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintHeatflux"; } void CmdFemConstraintHeatflux::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintHeatflux"); @@ -540,18 +565,20 @@ void CmdFemConstraintHeatflux::activated(int) FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.AmbientTemp = 300.0", - FeatName.c_str());//OvG: set default not equal to 0 + FeatName.c_str()); // OvG: set default not equal to 0 doCommand(Doc, "App.activeDocument().%s.FilmCoef = 10.0", - FeatName.c_str());//OvG: set default not equal to 0 - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + FeatName.c_str()); // OvG: set default not equal to 0 + doCommand(Doc, + "App.activeDocument().%s.Scale = 1", + FeatName.c_str()); // OvG: set initial scale to 1 doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr().c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr().c_str()); updateActive(); @@ -583,8 +610,9 @@ void CmdFemConstraintInitialTemperature::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintInitialTemperature"); @@ -592,14 +620,16 @@ void CmdFemConstraintInitialTemperature::activated(int) doCommand(Doc, "App.activeDocument().addObject(\"Fem::ConstraintInitialTemperature\",\"%s\")", FeatName.c_str()); - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + doCommand(Doc, + "App.activeDocument().%s.Scale = 1", + FeatName.c_str()); // OvG: set initial scale to 1 doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr().c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr().c_str()); updateActive(); @@ -618,21 +648,22 @@ DEF_STD_CMD_A(CmdFemConstraintPlaneRotation) CmdFemConstraintPlaneRotation::CmdFemConstraintPlaneRotation() : Command("FEM_ConstraintPlaneRotation") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Plane multi-point constraint"); - sToolTipText = QT_TR_NOOP("Creates a plane multi-point constraint for a face"); - sWhatsThis = "FEM_ConstraintPlaneRotation"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintPlaneRotation"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Plane multi-point constraint"); + sToolTipText = QT_TR_NOOP("Creates a plane multi-point constraint for a face"); + sWhatsThis = "FEM_ConstraintPlaneRotation"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintPlaneRotation"; } void CmdFemConstraintPlaneRotation::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintPlaneRotation"); @@ -640,14 +671,16 @@ void CmdFemConstraintPlaneRotation::activated(int) doCommand(Doc, "App.activeDocument().addObject(\"Fem::ConstraintPlaneRotation\",\"%s\")", FeatName.c_str()); - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + doCommand(Doc, + "App.activeDocument().%s.Scale = 1", + FeatName.c_str()); // OvG: set initial scale to 1 doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -666,21 +699,22 @@ DEF_STD_CMD_A(CmdFemConstraintPressure) CmdFemConstraintPressure::CmdFemConstraintPressure() : Command("FEM_ConstraintPressure") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Pressure load"); - sToolTipText = QT_TR_NOOP("Creates a pressure load acting on a face"); - sWhatsThis = "FEM_ConstraintPressure"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintPressure"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Pressure load"); + sToolTipText = QT_TR_NOOP("Creates a pressure load acting on a face"); + sWhatsThis = "FEM_ConstraintPressure"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintPressure"; } void CmdFemConstraintPressure::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintPressure"); @@ -690,18 +724,19 @@ void CmdFemConstraintPressure::activated(int) FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.Pressure = 0.1", - FeatName.c_str());//OvG: set default not equal to 0 + FeatName.c_str()); // OvG: set default not equal to 0 doCommand(Doc, "App.activeDocument().%s.Reversed = False", - FeatName.c_str());//OvG: set default to False - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + FeatName.c_str()); // OvG: set default to False + // OvG: set initial scale to 1 + doCommand(Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -720,41 +755,43 @@ DEF_STD_CMD_A(CmdFemConstraintSpring) CmdFemConstraintSpring::CmdFemConstraintSpring() : Command("FEM_ConstraintSpring") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Spring"); - sToolTipText = QT_TR_NOOP("Creates a spring acting on a face"); - sWhatsThis = "FEM_ConstraintSpring"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintSpring"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Spring"); + sToolTipText = QT_TR_NOOP("Creates a spring acting on a face"); + sWhatsThis = "FEM_ConstraintSpring"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintSpring"; } void CmdFemConstraintSpring::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintSpring"); openCommand(QT_TRANSLATE_NOOP("Command", "Make spring on face")); - doCommand( - Doc, "App.activeDocument().addObject(\"Fem::ConstraintSpring\",\"%s\")", FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Fem::ConstraintSpring\",\"%s\")", + FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.NormalStiffness = 1.0", - FeatName.c_str());//OvG: set default not equal to 0 + FeatName.c_str()); // OvG: set default not equal to 0 doCommand(Doc, "App.activeDocument().%s.TangentialStiffness = 0.0", - FeatName.c_str());//OvG: set default to False - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + FeatName.c_str()); // OvG: set default to False + // OvG: set initial scale to 1 + doCommand(Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -773,27 +810,29 @@ DEF_STD_CMD_A(CmdFemConstraintPulley) CmdFemConstraintPulley::CmdFemConstraintPulley() : Command("FEM_ConstraintPulley") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Pulley constraint"); - sToolTipText = QT_TR_NOOP("Creates a pulley constraint"); - sWhatsThis = "FEM_ConstraintPulley"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintPulley"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Pulley constraint"); + sToolTipText = QT_TR_NOOP("Creates a pulley constraint"); + sWhatsThis = "FEM_ConstraintPulley"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintPulley"; } void CmdFemConstraintPulley::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintPulley"); openCommand(QT_TRANSLATE_NOOP("Command", "Make pulley constraint")); - doCommand( - Doc, "App.activeDocument().addObject(\"Fem::ConstraintPulley\",\"%s\")", FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Fem::ConstraintPulley\",\"%s\")", + FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.Diameter = 300.0", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.OtherDiameter = 100.0", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.CenterDistance = 500.0", FeatName.c_str()); @@ -804,7 +843,8 @@ void CmdFemConstraintPulley::activated(int) Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -826,8 +866,7 @@ CmdFemConstraintTemperature::CmdFemConstraintTemperature() sAppModule = "Fem"; sGroup = QT_TR_NOOP("Fem"); sMenuText = QT_TR_NOOP("Temperature boundary condition"); - sToolTipText = QT_TR_NOOP( - "Creates a temperature/concentrated heat flux load acting on a face"); + sToolTipText = QT_TR_NOOP("Creates a temperature/concentrated heat flux load acting on a face"); sWhatsThis = "FEM_ConstraintTemperature"; sStatusTip = sToolTipText; sPixmap = "FEM_ConstraintTemperature"; @@ -837,8 +876,9 @@ void CmdFemConstraintTemperature::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintTemperature"); @@ -846,14 +886,16 @@ void CmdFemConstraintTemperature::activated(int) doCommand(Doc, "App.activeDocument().addObject(\"Fem::ConstraintTemperature\",\"%s\")", FeatName.c_str()); - doCommand( - Doc, "App.activeDocument().%s.Scale = 1", FeatName.c_str());//OvG: set initial scale to 1 + doCommand(Doc, + "App.activeDocument().%s.Scale = 1", + FeatName.c_str()); // OvG: set initial scale to 1 doCommand(Doc, "App.activeDocument().%s.addObject(App.activeDocument().%s)", Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr().c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr().c_str()); updateActive(); @@ -872,21 +914,22 @@ DEF_STD_CMD_A(CmdFemConstraintTransform) CmdFemConstraintTransform::CmdFemConstraintTransform() : Command("FEM_ConstraintTransform") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Local coordinate system"); - sToolTipText = QT_TR_NOOP("Create a local coordinate system on a face"); - sWhatsThis = "FEM_ConstraintTransform"; - sStatusTip = sToolTipText; - sPixmap = "FEM_ConstraintTransform"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Local coordinate system"); + sToolTipText = QT_TR_NOOP("Create a local coordinate system on a face"); + sWhatsThis = "FEM_ConstraintTransform"; + sStatusTip = sToolTipText; + sPixmap = "FEM_ConstraintTransform"; } void CmdFemConstraintTransform::activated(int) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } std::string FeatName = getUniqueObjectName("ConstraintTransform"); @@ -903,7 +946,8 @@ void CmdFemConstraintTransform::activated(int) Analysis->getNameInDocument(), FeatName.c_str()); - doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str());//OvG: Hide meshes and show parts + // OvG: Hide meshes and show parts + doCommand(Doc, "%s", gethideMeshShowPartStr(FeatName).c_str()); updateActive(); @@ -927,8 +971,9 @@ void DefineNodesCallback(void* ud, SoEventCallback* n) { Fem::FemAnalysis* Analysis; - if (getConstraintPrerequisits(&Analysis)) + if (getConstraintPrerequisits(&Analysis)) { return; + } // show the wait cursor because this could take quite some time Gui::WaitCursor wc; @@ -941,23 +986,27 @@ void DefineNodesCallback(void* ud, SoEventCallback* n) Gui::SelectionRole role; std::vector clPoly = view->getGLPolygon(&role); - if (clPoly.size() < 3) + if (clPoly.size() < 3) { return; - if (clPoly.front() != clPoly.back()) + } + if (clPoly.front() != clPoly.back()) { clPoly.push_back(clPoly.front()); + } SoCamera* cam = view->getSoRenderManager()->getCamera(); SbViewVolume vv = cam->getViewVolume(); Gui::ViewVolumeProjection proj(vv); Base::Polygon2d polygon; - for (auto it : clPoly) + for (auto it : clPoly) { polygon.Add(Base::Vector2d(it[0], it[1])); + } std::vector docObj = Gui::Selection().getObjectsOfType(Fem::FemMeshObject::getClassTypeId()); - if (docObj.size() != 1) + if (docObj.size() != 1) { return; + } const SMESHDS_Mesh* data = static_cast(docObj[0])->FemMesh.getValue().getSMesh()->GetMeshDS(); @@ -970,42 +1019,48 @@ void DefineNodesCallback(void* ud, SoEventCallback* n) const SMDS_MeshNode* aNode = aNodeIter->next(); Base::Vector3f vec(aNode->X(), aNode->Y(), aNode->Z()); pt2d = proj(vec); - if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) + if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) { IntSet.insert(aNode->GetID()); + } } - std::stringstream set; + std::stringstream set; set << "["; - for (std::set::const_iterator it = IntSet.begin(); it != IntSet.end(); ++it) - if (it == IntSet.begin()) + for (std::set::const_iterator it = IntSet.begin(); it != IntSet.end(); ++it) { + if (it == IntSet.begin()) { set << *it; - else + } + else { set << "," << *it; + } + } set << "]"; Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Place robot")); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.addObject('Fem::FemSetNodesObject','NodeSet')"); - Gui::Command::doCommand( - Gui::Command::Doc, "App.ActiveDocument.ActiveObject.Nodes = %s", set.str().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.ActiveObject.Nodes = %s", + set.str().c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.addObject(App.activeDocument().NodeSet)", Analysis->getNameInDocument()); // Gui::Command::updateActive(); Gui::Command::commitCommand(); - //std::vector views = view->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); - //if (!views.empty()) { - // Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Cut")); - // for (std::vector::iterator it = views.begin(); it != views.end(); ++it) { - // ViewProviderMesh* that = static_cast(*it); - // if (that->getEditingMode() > -1) { - // that->finishEditing(); - // that->cutMesh(clPoly, *view, clip_inner); - // } - // } + // std::vector views = + // view->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); if (!views.empty()) { + // Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", + // "Cut")); for (std::vector::iterator it = views.begin(); it != + // views.end(); ++it) { + // ViewProviderMesh* that = static_cast(*it); + // if (that->getEditingMode() > -1) { + // that->finishEditing(); + // that->cutMesh(clPoly, *view, clip_inner); + // } + // } // Gui::Application::Instance->activeDocument()->commitCommand(); @@ -1014,17 +1069,16 @@ void DefineNodesCallback(void* ud, SoEventCallback* n) } - CmdFemDefineNodesSet::CmdFemDefineNodesSet() : Command("FEM_DefineNodesSet") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Node set by poly"); - sToolTipText = QT_TR_NOOP("Create node set by Poly"); - sWhatsThis = "FEM_DefineNodesSet"; - sStatusTip = QT_TR_NOOP("Create node set by Poly"); - sPixmap = "FEM_CreateNodesSet"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Node set by poly"); + sToolTipText = QT_TR_NOOP("Create node set by Poly"); + sWhatsThis = "FEM_DefineNodesSet"; + sStatusTip = QT_TR_NOOP("Create node set by Poly"); + sPixmap = "FEM_CreateNodesSet"; } void CmdFemDefineNodesSet::activated(int) @@ -1048,17 +1102,18 @@ void CmdFemDefineNodesSet::activated(int) } } - //Gui::ViewProvider* pVP = getActiveGuiDocument()->getViewProvider(*it); - //if (pVP->isVisible()) - // pVP->startEditing(); + // Gui::ViewProvider* pVP = getActiveGuiDocument()->getViewProvider(*it); + // if (pVP->isVisible()) + // pVP->startEditing(); } } bool CmdFemDefineNodesSet::isActive() { // Check for the selected mesh feature (all Mesh types) - if (getSelection().countObjectsOfType(Fem::FemMeshObject::getClassTypeId()) != 1) + if (getSelection().countObjectsOfType(Fem::FemMeshObject::getClassTypeId()) != 1) { return false; + } Gui::MDIView* view = Gui::getMainWindow()->activeWindow(); if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { @@ -1076,13 +1131,13 @@ DEF_STD_CMD_A(CmdFemCreateNodesSet) CmdFemCreateNodesSet::CmdFemCreateNodesSet() : Command("FEM_CreateNodesSet") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Nodes set"); - sToolTipText = QT_TR_NOOP("Creates a FEM mesh nodes set"); - sWhatsThis = "FEM_CreateNodesSet"; - sStatusTip = sToolTipText; - sPixmap = "FEM_CreateNodesSet"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Nodes set"); + sToolTipText = QT_TR_NOOP("Creates a FEM mesh nodes set"); + sWhatsThis = "FEM_CreateNodesSet"; + sStatusTip = sToolTipText; + sPixmap = "FEM_CreateNodesSet"; } void CmdFemCreateNodesSet::activated(int) @@ -1103,8 +1158,9 @@ void CmdFemCreateNodesSet::activated(int) std::string FeatName = getUniqueObjectName("NodesSet"); openCommand(QT_TRANSLATE_NOOP("Command", "Create nodes set")); - doCommand( - Doc, "App.activeDocument().addObject('Fem::FemSetNodesObject','%s')", FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject('Fem::FemSetNodesObject','%s')", + FeatName.c_str()); doCommand(Gui, "App.activeDocument().%s.FemMesh = App.activeDocument().%s", FeatName.c_str(), @@ -1145,14 +1201,18 @@ CmdFemCompEmConstraints::CmdFemCompEmConstraints() void CmdFemCompEmConstraints::activated(int iMsg) { Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); - if (iMsg == 0) + if (iMsg == 0) { rcCmdMgr.runCommandByName("FEM_ConstraintElectrostaticPotential"); - else if (iMsg == 1) + } + else if (iMsg == 1) { rcCmdMgr.runCommandByName("FEM_ConstraintCurrentDensity"); - else if (iMsg == 2) + } + else if (iMsg == 2) { rcCmdMgr.runCommandByName("FEM_ConstraintMagnetization"); - else + } + else { return; + } // Since the default icon is reset when enabling/disabling the command we have // to explicitly set the icon of the used command. @@ -1190,8 +1250,9 @@ void CmdFemCompEmConstraints::languageChange() { Command::languageChange(); - if (!_pcAction) + if (!_pcAction) { return; + } Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); @@ -1204,9 +1265,11 @@ void CmdFemCompEmConstraints::languageChange() QAction* cmd0 = a[0]; cmd0->setText(QApplication::translate("FEM_ConstraintElectrostaticPotential", ConstraintElectrostaticPotential->getMenuText())); - cmd0->setToolTip(QApplication::translate("FEM_ConstraintElectrostaticPotential", + cmd0->setToolTip( + QApplication::translate("FEM_ConstraintElectrostaticPotential", ConstraintElectrostaticPotential->getToolTipText())); - cmd0->setStatusTip(QApplication::translate("FEM_ConstraintElectrostaticPotential", + cmd0->setStatusTip( + QApplication::translate("FEM_ConstraintElectrostaticPotential", ConstraintElectrostaticPotential->getStatusTip())); } @@ -1254,8 +1317,7 @@ CmdFemCompEmEquations::CmdFemCompEmEquations() sAppModule = "Fem"; sGroup = QT_TR_NOOP("Fem"); sMenuText = QT_TR_NOOP("Electromagnetic equations"); - sToolTipText = QT_TR_NOOP( - "Electromagnetic equations for the Elmer solver"); + sToolTipText = QT_TR_NOOP("Electromagnetic equations for the Elmer solver"); sWhatsThis = "FEM_CompEmEquations"; sStatusTip = sToolTipText; } @@ -1263,16 +1325,21 @@ CmdFemCompEmEquations::CmdFemCompEmEquations() void CmdFemCompEmEquations::activated(int iMsg) { Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); - if (iMsg == 0) + if (iMsg == 0) { rcCmdMgr.runCommandByName("FEM_EquationElectrostatic"); - else if (iMsg == 1) + } + else if (iMsg == 1) { rcCmdMgr.runCommandByName("FEM_EquationElectricforce"); - else if (iMsg == 2) + } + else if (iMsg == 2) { rcCmdMgr.runCommandByName("FEM_EquationMagnetodynamic"); - else if (iMsg == 3) + } + else if (iMsg == 3) { rcCmdMgr.runCommandByName("FEM_EquationMagnetodynamic2D"); - else + } + else { return; + } // Since the default icon is reset when enabling/disabling the command we have // to explicitly set the icon of the used command. @@ -1312,8 +1379,9 @@ void CmdFemCompEmEquations::languageChange() { Command::languageChange(); - if (!_pcAction) + if (!_pcAction) { return; + } Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); @@ -1342,8 +1410,7 @@ void CmdFemCompEmEquations::languageChange() EquationElectricforce->getStatusTip())); } - Gui::Command* EquationMagnetodynamic = - rcCmdMgr.getCommandByName("FEM_EquationMagnetodynamic"); + Gui::Command* EquationMagnetodynamic = rcCmdMgr.getCommandByName("FEM_EquationMagnetodynamic"); if (EquationMagnetodynamic) { QAction* cmd2 = a[2]; cmd2->setText(QApplication::translate("FEM_EquationMagnetodynamic", @@ -1370,18 +1437,21 @@ void CmdFemCompEmEquations::languageChange() bool CmdFemCompEmEquations::isActive() { // only if there is an active analysis - if (!FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) + if (!FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) { return false; + } // only activate if a single Elmer object is selected - auto results = getSelection().getSelectionEx( - nullptr, App::DocumentObject::getClassTypeId(), Gui::ResolveMode::FollowLink); + auto results = getSelection().getSelectionEx(nullptr, + App::DocumentObject::getClassTypeId(), + Gui::ResolveMode::FollowLink); if (results.size() == 1) { auto object = results.begin()->getObject(); // FIXME: this is not unique since the Ccx solver object has the same type std::string Type = "Fem::FemSolverObjectPython"; - if (Type.compare(object->getTypeId().getName()) == 0) + if (Type.compare(object->getTypeId().getName()) == 0) { return true; + } } return false; } @@ -1407,12 +1477,15 @@ CmdFemCompMechEquations::CmdFemCompMechEquations() void CmdFemCompMechEquations::activated(int iMsg) { Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); - if (iMsg == 0) + if (iMsg == 0) { rcCmdMgr.runCommandByName("FEM_EquationElasticity"); - else if (iMsg == 1) + } + else if (iMsg == 1) { rcCmdMgr.runCommandByName("FEM_EquationDeformation"); - else + } + else { return; + } // Since the default icon is reset when enabling/disabling the command we have // to explicitly set the icon of the used command. @@ -1448,8 +1521,9 @@ void CmdFemCompMechEquations::languageChange() { Command::languageChange(); - if (!_pcAction) + if (!_pcAction) { return; + } Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); @@ -1459,12 +1533,12 @@ void CmdFemCompMechEquations::languageChange() Gui::Command* EquationElasticity = rcCmdMgr.getCommandByName("FEM_EquationElasticity"); if (EquationElasticity) { QAction* cmd1 = a[0]; - cmd1->setText(QApplication::translate("FEM_EquationElasticity", - EquationElasticity->getMenuText())); + cmd1->setText( + QApplication::translate("FEM_EquationElasticity", EquationElasticity->getMenuText())); cmd1->setToolTip(QApplication::translate("FEM_EquationElasticity", EquationElasticity->getToolTipText())); - cmd1->setStatusTip(QApplication::translate("FEM_EquationElasticity", - EquationElasticity->getStatusTip())); + cmd1->setStatusTip( + QApplication::translate("FEM_EquationElasticity", EquationElasticity->getStatusTip())); } Gui::Command* EquationDeformation = rcCmdMgr.getCommandByName("FEM_EquationDeformation"); @@ -1482,18 +1556,21 @@ void CmdFemCompMechEquations::languageChange() bool CmdFemCompMechEquations::isActive() { // only if there is an active analysis - if (!FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) + if (!FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) { return false; + } // only activate if a single Elmer object is selected - auto results = getSelection().getSelectionEx( - nullptr, App::DocumentObject::getClassTypeId(), Gui::ResolveMode::FollowLink); + auto results = getSelection().getSelectionEx(nullptr, + App::DocumentObject::getClassTypeId(), + Gui::ResolveMode::FollowLink); if (results.size() == 1) { auto object = results.begin()->getObject(); // FIXME: this is not unique since the Ccx solver object has the same type std::string Type = "Fem::FemSolverObjectPython"; - if (Type.compare(object->getTypeId().getName()) == 0) + if (Type.compare(object->getTypeId().getName()) == 0) { return true; + } } return false; } @@ -1508,7 +1585,8 @@ bool CmdFemCompMechEquations::isActive() //================================================================================================ // helper vtk post processing -void setupFilter(Gui::Command* cmd, std::string Name) { +void setupFilter(Gui::Command* cmd, std::string Name) +{ // In the isActive() functions it is already assured that the filters are // only active on allowed objects // For the case the clip filter is set by Python code, we check that the input @@ -1562,7 +1640,8 @@ void setupFilter(Gui::Command* cmd, std::string Name) { } if (!pipeline) { - QMessageBox::warning(Gui::getMainWindow(), + QMessageBox::warning( + Gui::getMainWindow(), qApp->translate("setupFilter", "Error: no post processing object selected."), qApp->translate("setupFilter", "The filter could not be set up.")); return; @@ -1570,25 +1649,35 @@ void setupFilter(Gui::Command* cmd, std::string Name) { // create the object and add it to the pipeline cmd->openCommand(QT_TRANSLATE_NOOP("Command", "Create filter")); - cmd->doCommand(Gui::Command::Doc, "App.activeDocument().addObject('Fem::FemPost%sFilter','%s')", Name.c_str(), FeatName.c_str()); + cmd->doCommand(Gui::Command::Doc, + "App.activeDocument().addObject('Fem::FemPost%sFilter','%s')", + Name.c_str(), + FeatName.c_str()); // add it as subobject to the pipeline - cmd->doCommand(Gui::Command::Doc, "__list__ = App.ActiveDocument.%s.Filter", pipeline->getNameInDocument()); + cmd->doCommand(Gui::Command::Doc, + "__list__ = App.ActiveDocument.%s.Filter", + pipeline->getNameInDocument()); cmd->doCommand(Gui::Command::Doc, "__list__.append(App.ActiveDocument.%s)", FeatName.c_str()); - cmd->doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Filter = __list__", pipeline->getNameInDocument()); + cmd->doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Filter = __list__", + pipeline->getNameInDocument()); cmd->doCommand(Gui::Command::Doc, "del __list__"); // set display to assure the user sees the new object - cmd->doCommand(Gui::Command::Doc, "App.activeDocument().ActiveObject.ViewObject.DisplayMode = \"Surface\""); + cmd->doCommand(Gui::Command::Doc, + "App.activeDocument().ActiveObject.ViewObject.DisplayMode = \"Surface\""); // Set SelectionStyle to BoundBox because the idea is that the user gets the useful result // from the colors. The default would be to highlight the shape but then the colors are changed // by every highlighting leading to confusions for the user. - cmd->doCommand(Gui::Command::Doc, "App.activeDocument().ActiveObject.ViewObject.SelectionStyle = \"BoundBox\""); + cmd->doCommand(Gui::Command::Doc, + "App.activeDocument().ActiveObject.ViewObject.SelectionStyle = \"BoundBox\""); // in case selObject is no pipeline we must set it as input object auto objFilter = App::GetApplication().getActiveDocument()->getActiveObject(); auto femFilter = static_cast(objFilter); - if (!selectionIsPipeline) + if (!selectionIsPipeline) { femFilter->Input.setValue(selObject); + } cmd->updateActive(); // open the dialog to edit the filter @@ -1602,11 +1691,13 @@ std::string Plot() "Thickness [mm]", "Plot X-Axis Label") .toStdString(); - auto yAxisLabel = QCoreApplication::translate( - "CmdFemPostLinearizedStressesFilter", "Stress [MPa]", "Plot Y-Axis Label") + auto yAxisLabel = QCoreApplication::translate("CmdFemPostLinearizedStressesFilter", + "Stress [MPa]", + "Plot Y-Axis Label") .toStdString(); - auto titleLabel = QCoreApplication::translate( - "CmdFemPostLinearizedStressesFilter", "Linearized Stresses", "Plot title") + auto titleLabel = QCoreApplication::translate("CmdFemPostLinearizedStressesFilter", + "Linearized Stresses", + "Plot title") .toStdString(); auto legendEntryA = QCoreApplication::translate("CmdFemPostLinearizedStressesFilter", "Membrane", @@ -1616,8 +1707,9 @@ std::string Plot() "Membrane and Bending", "Plot legend item label") .toStdString(); - auto legendEntryC = QCoreApplication::translate( - "CmdFemPostLinearizedStressesFilter", "Total", "Plot legend item label") + auto legendEntryC = QCoreApplication::translate("CmdFemPostLinearizedStressesFilter", + "Total", + "Plot legend item label") .toStdString(); std::ostringstream oss; @@ -1713,25 +1805,32 @@ void CmdFemPostClipFilter::activated(int) bool CmdFemPostClipFilter::isActive() { // only allow one object - if (getSelection().getSelection().size() > 1) + if (getSelection().getSelection().size() > 1) { return false; + } // only activate if a result is either a post pipeline or a possible filter - if (getSelection().getObjectsOfType().size() == 1) + if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else - return false; + } + return false; } @@ -1741,13 +1840,13 @@ DEF_STD_CMD_A(CmdFemPostCutFilter) CmdFemPostCutFilter::CmdFemPostCutFilter() : Command("FEM_PostFilterCutFunction") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Function cut filter"); - sToolTipText = QT_TR_NOOP("Cut the data along an implicit function"); - sWhatsThis = "FEM_PostFilterCutFunction"; - sStatusTip = sToolTipText; - sPixmap = "FEM_PostFilterCutFunction"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Function cut filter"); + sToolTipText = QT_TR_NOOP("Cut the data along an implicit function"); + sWhatsThis = "FEM_PostFilterCutFunction"; + sStatusTip = sToolTipText; + sPixmap = "FEM_PostFilterCutFunction"; } void CmdFemPostCutFilter::activated(int) @@ -1758,25 +1857,32 @@ void CmdFemPostCutFilter::activated(int) bool CmdFemPostCutFilter::isActive() { // only allow one object - if (getSelection().getSelection().size() > 1) + if (getSelection().getSelection().size() > 1) { return false; + } // only activate if a result is either a post pipeline or a possible filter - if (getSelection().getObjectsOfType().size() == 1) + if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else - return false; + } + return false; } @@ -1786,13 +1892,13 @@ DEF_STD_CMD_A(CmdFemPostDataAlongLineFilter) CmdFemPostDataAlongLineFilter::CmdFemPostDataAlongLineFilter() : Command("FEM_PostFilterDataAlongLine") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Line clip filter"); - sToolTipText = QT_TR_NOOP("Define/create a clip filter which clips a field along a line"); - sWhatsThis = "FEM_PostFilterDataAlongLine"; - sStatusTip = sToolTipText; - sPixmap = "FEM_PostFilterDataAlongLine"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Line clip filter"); + sToolTipText = QT_TR_NOOP("Define/create a clip filter which clips a field along a line"); + sWhatsThis = "FEM_PostFilterDataAlongLine"; + sStatusTip = sToolTipText; + sPixmap = "FEM_PostFilterDataAlongLine"; } void CmdFemPostDataAlongLineFilter::activated(int) @@ -1803,23 +1909,29 @@ void CmdFemPostDataAlongLineFilter::activated(int) bool CmdFemPostDataAlongLineFilter::isActive() { // only allow one object - if (getSelection().getSelection().size() > 1) + if (getSelection().getSelection().size() > 1) { return false; + } // only activate if a result is either a post pipeline or a possible filter - if (getSelection().getObjectsOfType().size() == 1) + if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else - return false; + } + return false; } @@ -1829,42 +1941,47 @@ DEF_STD_CMD_A(CmdFemPostDataAtPointFilter) CmdFemPostDataAtPointFilter::CmdFemPostDataAtPointFilter() : Command("FEM_PostFilterDataAtPoint") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Data at point clip filter"); - sToolTipText = QT_TR_NOOP("Define/create a clip filter which clips a field data at point"); - sWhatsThis = "FEM_PostFilterDataAtPoint"; - sStatusTip = sToolTipText; - sPixmap = "FEM_PostFilterDataAtPoint"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Data at point clip filter"); + sToolTipText = QT_TR_NOOP("Define/create a clip filter which clips a field data at point"); + sWhatsThis = "FEM_PostFilterDataAtPoint"; + sStatusTip = sToolTipText; + sPixmap = "FEM_PostFilterDataAtPoint"; } void CmdFemPostDataAtPointFilter::activated(int) { setupFilter(this, "DataAtPoint"); - } bool CmdFemPostDataAtPointFilter::isActive() { // only allow one object - if (getSelection().getSelection().size() > 1) + if (getSelection().getSelection().size() > 1) { return false; + } // only activate if a result is either a post pipeline or a possible filter - if (getSelection().getObjectsOfType().size() == 1) + if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else - return false; + } + return false; } @@ -1874,13 +1991,13 @@ DEF_STD_CMD_A(CmdFemPostLinearizedStressesFilter) CmdFemPostLinearizedStressesFilter::CmdFemPostLinearizedStressesFilter() : Command("FEM_PostFilterLinearizedStresses") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Stress linearization plot"); - sToolTipText = QT_TR_NOOP("Define/create stress linearization plots"); - sWhatsThis = "FEM_PostFilterLinearizedStresses"; - sStatusTip = sToolTipText; - sPixmap = "FEM_PostFilterLinearizedStresses"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Stress linearization plot"); + sToolTipText = QT_TR_NOOP("Define/create stress linearization plots"); + sWhatsThis = "FEM_PostFilterLinearizedStresses"; + sStatusTip = sToolTipText; + sPixmap = "FEM_PostFilterLinearizedStresses"; } void CmdFemPostLinearizedStressesFilter::activated(int) @@ -1893,15 +2010,13 @@ void CmdFemPostLinearizedStressesFilter::activated(int) static_cast( DataAlongLineFilter.Result[0][0].getObject()); std::string FieldName = DataAlongLine->PlotData.getValue(); - if ( - (FieldName == "Tresca Stress") - || (FieldName == "von Mises Stress") + if ((FieldName == "Tresca Stress") || (FieldName == "von Mises Stress") || (FieldName == "Major Principal Stress") || (FieldName == "Intermediate Principal Stress") || (FieldName == "Minor Principal Stress") // names need to match with names in FemVTKTools.cpp, this is not failsafe, // but at the moment there is no better way for test on a stress result in vtk pipeline - ) { + ) { // TODO FIXME only works if the data along the line object has the name DataAlongLine // we should get the selected data along the line object App::DocumentObjectT objT(DataAlongLine); @@ -1932,8 +2047,9 @@ void CmdFemPostLinearizedStressesFilter::activated(int) bool CmdFemPostLinearizedStressesFilter::isActive() { // only allow one object - if (getSelection().getSelection().size() > 1) + if (getSelection().getSelection().size() > 1) { return false; + } // we purposely allow it also not non-along line filters because we issue an error message that // also explains what the feature is for and how it is set up @@ -1965,23 +2081,29 @@ void CmdFemPostScalarClipFilter::activated(int) bool CmdFemPostScalarClipFilter::isActive() { // only allow one object - if (getSelection().getSelection().size() > 1) + if (getSelection().getSelection().size() > 1) { return false; + } // only activate if a result is either a post pipeline or a possible other filter - if (getSelection().getObjectsOfType().size() == 1) + if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else - return false; + } + return false; } @@ -1991,13 +2113,13 @@ DEF_STD_CMD_A(CmdFemPostWarpVectorFilter) CmdFemPostWarpVectorFilter::CmdFemPostWarpVectorFilter() : Command("FEM_PostFilterWarp") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Warp filter"); - sToolTipText = QT_TR_NOOP("Warp the geometry along a vector field by a certain factor"); - sWhatsThis = "FEM_PostFilterWarp"; - sStatusTip = sToolTipText; - sPixmap = "FEM_PostFilterWarp"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Warp filter"); + sToolTipText = QT_TR_NOOP("Warp the geometry along a vector field by a certain factor"); + sWhatsThis = "FEM_PostFilterWarp"; + sStatusTip = sToolTipText; + sPixmap = "FEM_PostFilterWarp"; } void CmdFemPostWarpVectorFilter::activated(int) @@ -2008,23 +2130,29 @@ void CmdFemPostWarpVectorFilter::activated(int) bool CmdFemPostWarpVectorFilter::isActive() { // only allow one object - if (getSelection().getSelection().size() > 1) + if (getSelection().getSelection().size() > 1) { return false; + } // only activate if a result is either a post pipeline or a possible other filter - if (getSelection().getObjectsOfType().size() == 1) + if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else - return false; + } + return false; } @@ -2037,8 +2165,7 @@ CmdFemPostContoursFilter::CmdFemPostContoursFilter() sAppModule = "Fem"; sGroup = QT_TR_NOOP("Fem"); sMenuText = QT_TR_NOOP("Contours filter"); - sToolTipText = - QT_TR_NOOP("Define/create a contours filter which displays iso contours"); + sToolTipText = QT_TR_NOOP("Define/create a contours filter which displays iso contours"); sWhatsThis = "FEM_PostFilterContours"; sStatusTip = sToolTipText; sPixmap = "FEM_PostFilterContours"; @@ -2052,23 +2179,29 @@ void CmdFemPostContoursFilter::activated(int) bool CmdFemPostContoursFilter::isActive() { // only allow one object - if (getSelection().getSelection().size() > 1) + if (getSelection().getSelection().size() > 1) { return false; + } // only activate if a result is either a post pipeline or a possible other filter - if (getSelection().getObjectsOfType().size() == 1) + if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else if (getSelection().getObjectsOfType().size() == 1) + } + else if (getSelection().getObjectsOfType().size() == 1) { return true; - else - return false; + } + return false; } @@ -2078,29 +2211,34 @@ DEF_STD_CMD_ACL(CmdFemPostFunctions) CmdFemPostFunctions::CmdFemPostFunctions() : Command("FEM_PostCreateFunctions") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Filter functions"); - sToolTipText = QT_TR_NOOP("Functions for use in postprocessing filter..."); - sWhatsThis = "FEM_PostCreateFunctions"; - sStatusTip = sToolTipText; - eType = eType|ForEdit; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Filter functions"); + sToolTipText = QT_TR_NOOP("Functions for use in postprocessing filter..."); + sWhatsThis = "FEM_PostCreateFunctions"; + sStatusTip = sToolTipText; + eType = eType | ForEdit; } void CmdFemPostFunctions::activated(int iMsg) { std::string name; - if (iMsg == 0) + if (iMsg == 0) { name = "Plane"; - else if (iMsg == 1) + } + else if (iMsg == 1) { name = "Sphere"; - else if (iMsg == 2) + } + else if (iMsg == 2) { name = "Cylinder"; - else if (iMsg == 3) + } + else if (iMsg == 3) { name = "Box"; - else + } + else { return; + } // create the object std::vector pipelines = @@ -2126,8 +2264,9 @@ void CmdFemPostFunctions::activated(int iMsg) provider = static_cast( getDocument()->getObject(FuncName.c_str())); } - else + else { provider = static_cast(pipeline->Functions.getValue()); + } // build the object std::string FeatName = getUniqueObjectName(name.c_str()); @@ -2140,13 +2279,13 @@ void CmdFemPostFunctions::activated(int iMsg) doCommand(Doc, "App.ActiveDocument.%s.Functions = __list__", provider->getNameInDocument()); doCommand(Doc, "del __list__"); - //set the default values, for this get the bounding box + // set the default values, for this get the bounding box vtkBoundingBox box = pipeline->getBoundingBox(); double center[3]; box.GetCenter(center); - if (iMsg == 0) { // Plane + if (iMsg == 0) { // Plane doCommand(Doc, "App.ActiveDocument.%s.Origin = App.Vector(%f, %f, %f)", FeatName.c_str(), @@ -2154,7 +2293,7 @@ void CmdFemPostFunctions::activated(int iMsg) center[1], center[2]); } - else if (iMsg == 1) { // Sphere + else if (iMsg == 1) { // Sphere doCommand(Doc, "App.ActiveDocument.%s.Center = App.Vector(%f, %f, %f)", FeatName.c_str(), @@ -2166,7 +2305,7 @@ void CmdFemPostFunctions::activated(int iMsg) FeatName.c_str(), box.GetDiagonalLength() / 2); } - else if (iMsg == 2) { // Cylinder + else if (iMsg == 2) { // Cylinder doCommand(Doc, "App.ActiveDocument.%s.Center = App.Vector(%f, %f, %f)", FeatName.c_str(), @@ -2176,23 +2315,17 @@ void CmdFemPostFunctions::activated(int iMsg) doCommand(Doc, "App.ActiveDocument.%s.Radius = %f", FeatName.c_str(), - box.GetDiagonalLength() / 3.6); // make cylinder a bit higher than the box + box.GetDiagonalLength() / 3.6); // make cylinder a bit higher than the box } - else if (iMsg == 3) { // Box + else if (iMsg == 3) { // Box doCommand(Doc, "App.ActiveDocument.%s.Center = App.Vector(%f, %f, %f)", FeatName.c_str(), center[0] + box.GetLength(0) / 2, center[1] + box.GetLength(1) / 2, center[2]); - doCommand(Doc, - "App.ActiveDocument.%s.Length = %f", - FeatName.c_str(), - box.GetLength(0)); - doCommand(Doc, - "App.ActiveDocument.%s.Width = %f", - FeatName.c_str(), - box.GetLength(1)); + doCommand(Doc, "App.ActiveDocument.%s.Length = %f", FeatName.c_str(), box.GetLength(0)); + doCommand(Doc, "App.ActiveDocument.%s.Width = %f", FeatName.c_str(), box.GetLength(1)); doCommand(Doc, "App.ActiveDocument.%s.Height = %f", FeatName.c_str(), @@ -2201,14 +2334,15 @@ void CmdFemPostFunctions::activated(int iMsg) } this->updateActive(); - //most of the times functions are added inside of a filter, make sure this still works - if (!Gui::Application::Instance->activeDocument()->getInEdit()) + // most of the times functions are added inside of a filter, make sure this still works + if (!Gui::Application::Instance->activeDocument()->getInEdit()) { doCommand(Gui, "Gui.activeDocument().setEdit('%s')", FeatName.c_str()); + } } else { QMessageBox::warning(Gui::getMainWindow(), - qApp->translate("CmdFemPostClipFilter", "Wrong selection"), - qApp->translate("CmdFemPostClipFilter", "Select a pipeline, please.")); + qApp->translate("CmdFemPostClipFilter", "Wrong selection"), + qApp->translate("CmdFemPostClipFilter", "Select a pipeline, please.")); } // Since the default icon is reset when enabling/disabling the command we have @@ -2252,42 +2386,49 @@ void CmdFemPostFunctions::languageChange() { Command::languageChange(); - if (!_pcAction) + if (!_pcAction) { return; + } Gui::ActionGroup* pcAction = qobject_cast(_pcAction); QList a = pcAction->actions(); QAction* cmd = a[0]; cmd->setText(QApplication::translate("CmdFemPostFunctions", "Plane")); - cmd->setToolTip(QApplication::translate( - "FEM_PostCreateFunctions", "Create a plane function, defined by its origin and normal")); + cmd->setToolTip( + QApplication::translate("FEM_PostCreateFunctions", + "Create a plane function, defined by its origin and normal")); cmd->setStatusTip(cmd->toolTip()); cmd = a[1]; cmd->setText(QApplication::translate("CmdFemPostFunctions", "Sphere")); - cmd->setToolTip(QApplication::translate( - "FEM_PostCreateFunctions", "Create a sphere function, defined by its center and radius")); + cmd->setToolTip( + QApplication::translate("FEM_PostCreateFunctions", + "Create a sphere function, defined by its center and radius")); cmd->setStatusTip(cmd->toolTip()); cmd = a[2]; cmd->setText(QApplication::translate("CmdFemPostFunctions", "Cylinder")); cmd->setToolTip(QApplication::translate( - "FEM_PostCreateFunctions", "Create a cylinder function, defined by its center, axis and radius")); + "FEM_PostCreateFunctions", + "Create a cylinder function, defined by its center, axis and radius")); cmd->setStatusTip(cmd->toolTip()); cmd = a[3]; cmd->setText(QApplication::translate("CmdFemPostFunctions", "Box")); cmd->setToolTip(QApplication::translate( - "FEM_PostCreateFunctions", "Create a box function, defined by its center, length, width and height")); + "FEM_PostCreateFunctions", + "Create a box function, defined by its center, length, width and height")); cmd->setStatusTip(cmd->toolTip()); } bool CmdFemPostFunctions::isActive() { - if (getActiveGuiDocument()) + if (getActiveGuiDocument()) { return true; - else + } + else { return false; + } } @@ -2314,10 +2455,12 @@ void CmdFemPostApllyChanges::activated(int iMsg) bool CmdFemPostApllyChanges::isActive() { - if (getActiveGuiDocument()) + if (getActiveGuiDocument()) { return true; - else + } + else { return false; + } } Gui::Action* CmdFemPostApllyChanges::createAction() @@ -2336,13 +2479,13 @@ DEF_STD_CMD_A(CmdFemPostPipelineFromResult) CmdFemPostPipelineFromResult::CmdFemPostPipelineFromResult() : Command("FEM_PostPipelineFromResult") { - sAppModule = "Fem"; - sGroup = QT_TR_NOOP("Fem"); - sMenuText = QT_TR_NOOP("Post pipeline from result"); - sToolTipText = QT_TR_NOOP("Creates a post processing pipeline from a result object"); - sWhatsThis = "FEM_PostPipelineFromResult"; - sStatusTip = sToolTipText; - sPixmap = "FEM_PostPipelineFromResult"; + sAppModule = "Fem"; + sGroup = QT_TR_NOOP("Fem"); + sMenuText = QT_TR_NOOP("Post pipeline from result"); + sToolTipText = QT_TR_NOOP("Creates a post processing pipeline from a result object"); + sWhatsThis = "FEM_PostPipelineFromResult"; + sStatusTip = sToolTipText; + sPixmap = "FEM_PostPipelineFromResult"; } void CmdFemPostPipelineFromResult::activated(int) @@ -2390,15 +2533,19 @@ void CmdFemPostPipelineFromResult::activated(int) } // create the pipeline object openCommand(QT_TRANSLATE_NOOP("Command", "Create pipeline from result")); - if (foundAnalysis) + if (foundAnalysis) { pcAnalysis->addObject("Fem::FemPostPipeline", FeatName.c_str()); - else + } + else { doCommand(Doc, "App.activeDocument().addObject('Fem::FemPostPipeline','%s')", FeatName.c_str()); + } // load the contents of the result object to the pipeline - doCommand(Doc, "App.activeDocument().ActiveObject.load(" - "App.activeDocument().getObject(\"%s\"))", results[0]->getNameInDocument()); + doCommand(Doc, + "App.activeDocument().ActiveObject.load(" + "App.activeDocument().getObject(\"%s\"))", + results[0]->getNameInDocument()); // set display to assure the user sees the new object doCommand(Doc, "App.activeDocument().ActiveObject.ViewObject.DisplayMode = \"Surface\""); // Set SelectionStyle to BoundBox because the idea is that the user gets the useful result @@ -2409,10 +2556,10 @@ void CmdFemPostPipelineFromResult::activated(int) commitCommand(); this->updateActive(); - } else { - QMessageBox::warning(Gui::getMainWindow(), + QMessageBox::warning( + Gui::getMainWindow(), qApp->translate("CmdFemPostPipelineFromResult", "Wrong selection type"), qApp->translate("CmdFemPostPipelineFromResult", "Select a result object, please.")); } @@ -2436,10 +2583,10 @@ void CreateFemCommands() Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); // part, analysis, solver - //rcCmdMgr.addCommand(new CmdFemAddPart()); // not implemented as GUI menu or click icon - //rcCmdMgr.addCommand(new CmdFemCreateAnalysis()); // Analysis is created in python - //rcCmdMgr.addCommand(new CmdFemCreateSolver()); // Solver will be extended and created - // in python + // rcCmdMgr.addCommand(new CmdFemAddPart()); // not implemented as GUI menu or click icon + // rcCmdMgr.addCommand(new CmdFemCreateAnalysis()); // Analysis is created in python + // rcCmdMgr.addCommand(new CmdFemCreateSolver()); // Solver will be extended and created + // in python // constraints rcCmdMgr.addCommand(new CmdFemConstraintBearing()); diff --git a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp index 4db1e0d727..92c4dce2d8 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp @@ -25,8 +25,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include #endif #include @@ -49,8 +49,10 @@ DlgSettingsFemCcxImp::DlgSettingsFemCcxImp(QWidget* parent) int processor_count = QThread::idealThreadCount(); ui->sb_ccx_numcpu->setMaximum(processor_count); - connect(ui->fc_ccx_binary_path, &Gui::PrefFileChooser::fileNameChanged, - this, &DlgSettingsFemCcxImp::onfileNameChanged); + connect(ui->fc_ccx_binary_path, + &Gui::PrefFileChooser::fileNameChanged, + this, + &DlgSettingsFemCcxImp::onfileNameChanged); } DlgSettingsFemCcxImp::~DlgSettingsFemCcxImp() = default; @@ -62,18 +64,18 @@ void DlgSettingsFemCcxImp::saveSettings() hGrp->SetInt("Solver", ui->cmb_solver->currentIndex()); hGrp->SetInt("AnalysisType", ui->cb_analysis_type->currentIndex()); - ui->sb_ccx_numcpu->onSave(); //Number of CPUs + ui->sb_ccx_numcpu->onSave(); // Number of CPUs ui->cmb_solver->onSave(); ui->cb_ccx_non_lin_geom->onSave(); ui->cb_use_iterations_param->onSave(); ui->cb_static->onSave(); - ui->sb_ccx_max_iterations->onSave(); //Max number of iterations - ui->dsb_ccx_initial_time_step->onSave(); //Initial time step - ui->dsb_ccx_analysis_time->onSave(); //Analysis time + ui->sb_ccx_max_iterations->onSave(); // Max number of iterations + ui->dsb_ccx_initial_time_step->onSave(); // Initial time step + ui->dsb_ccx_analysis_time->onSave(); // Analysis time ui->cb_analysis_type->onSave(); - ui->cb_BeamShellOutput->onSave(); //Beam shell output 3d or 2d + ui->cb_BeamShellOutput->onSave(); // Beam shell output 3d or 2d ui->sb_eigenmode_number->onSave(); ui->dsb_eigenmode_high_limit->onSave(); ui->dsb_eigenmode_low_limit->onSave(); @@ -87,18 +89,18 @@ void DlgSettingsFemCcxImp::saveSettings() void DlgSettingsFemCcxImp::loadSettings() { - ui->sb_ccx_numcpu->onRestore(); //Number of CPUs + ui->sb_ccx_numcpu->onRestore(); // Number of CPUs ui->cmb_solver->onRestore(); ui->cb_ccx_non_lin_geom->onRestore(); ui->cb_use_iterations_param->onRestore(); ui->cb_static->onRestore(); - ui->sb_ccx_max_iterations->onRestore(); //Max number of iterations - ui->dsb_ccx_initial_time_step->onRestore(); //Initial time step - ui->dsb_ccx_analysis_time->onRestore(); //Analysis time + ui->sb_ccx_max_iterations->onRestore(); // Max number of iterations + ui->dsb_ccx_initial_time_step->onRestore(); // Initial time step + ui->dsb_ccx_analysis_time->onRestore(); // Analysis time ui->cb_analysis_type->onRestore(); - ui->cb_BeamShellOutput->onRestore(); //Beam shell output 3d or 2d + ui->cb_BeamShellOutput->onRestore(); // Beam shell output 3d or 2d ui->sb_eigenmode_number->onRestore(); ui->dsb_eigenmode_high_limit->onRestore(); ui->dsb_eigenmode_low_limit->onRestore(); @@ -112,11 +114,13 @@ void DlgSettingsFemCcxImp::loadSettings() ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/Mod/Fem/Ccx"); int index = hGrp->GetInt("Solver", 0); - if (index > -1) + if (index > -1) { ui->cmb_solver->setCurrentIndex(index); + } index = hGrp->GetInt("AnalysisType", 0); - if (index > -1) + if (index > -1) { ui->cb_analysis_type->setCurrentIndex(index); + } } /** @@ -137,9 +141,11 @@ void DlgSettingsFemCcxImp::changeEvent(QEvent* e) void DlgSettingsFemCcxImp::onfileNameChanged(QString FileName) { if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, tr("File does not exist"), + QMessageBox::critical(this, + tr("File does not exist"), tr("The specified executable \n'%1'\n does not exist!\n" - "Specify another file please.").arg(FileName)); + "Specify another file please.") + .arg(FileName)); } } diff --git a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.h b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.h index 5d53a0c6b2..792602a75a 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.h @@ -1,4 +1,4 @@ - /************************************************************************** +/************************************************************************** * Copyright (c) 2015 FreeCAD Developers * * Author: Przemo Firszt * * Author: Bernd Hahnebach * @@ -26,18 +26,19 @@ #ifndef FEMGUI_DLGSETTINGSFEMCCXIMP_H #define FEMGUI_DLGSETTINGSFEMCCXIMP_H -#include #include +#include -namespace FemGui { +namespace FemGui +{ class Ui_DlgSettingsFemCcxImp; -class DlgSettingsFemCcxImp : public Gui::Dialog::PreferencePage +class DlgSettingsFemCcxImp: public Gui::Dialog::PreferencePage { Q_OBJECT public: - explicit DlgSettingsFemCcxImp( QWidget* parent = nullptr ); + explicit DlgSettingsFemCcxImp(QWidget* parent = nullptr); ~DlgSettingsFemCcxImp() override; protected Q_SLOTS: @@ -46,12 +47,12 @@ protected Q_SLOTS: protected: void saveSettings() override; void loadSettings() override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_DLGSETTINGSFEMCCXIMP_H +#endif // FEMGUI_DLGSETTINGSFEMCCXIMP_H diff --git a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp index 0eca7982bb..475d0ffa0a 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp @@ -24,8 +24,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include #endif #include "DlgSettingsFemElmerImp.h" @@ -44,14 +44,22 @@ DlgSettingsFemElmerImp::DlgSettingsFemElmerImp(QWidget* parent) processor_count = QThread::idealThreadCount(); ui->sb_elmer_num_cores->setMaximum(processor_count); - connect(ui->fc_grid_binary_path, &Gui::PrefFileChooser::fileNameChanged, - this, &DlgSettingsFemElmerImp::onfileNameChanged); - connect(ui->fc_elmer_binary_path, &Gui::PrefFileChooser::fileNameChanged, - this, &DlgSettingsFemElmerImp::onfileNameChanged); - connect(ui->fc_elmer_binary_path, &Gui::PrefFileChooser::fileNameChanged, - this, &DlgSettingsFemElmerImp::onfileNameChangedMT); - connect(ui->sb_elmer_num_cores, qOverload(&Gui::PrefSpinBox::valueChanged), - this, &DlgSettingsFemElmerImp::onCoresValueChanged); + connect(ui->fc_grid_binary_path, + &Gui::PrefFileChooser::fileNameChanged, + this, + &DlgSettingsFemElmerImp::onfileNameChanged); + connect(ui->fc_elmer_binary_path, + &Gui::PrefFileChooser::fileNameChanged, + this, + &DlgSettingsFemElmerImp::onfileNameChanged); + connect(ui->fc_elmer_binary_path, + &Gui::PrefFileChooser::fileNameChanged, + this, + &DlgSettingsFemElmerImp::onfileNameChangedMT); + connect(ui->sb_elmer_num_cores, + qOverload(&Gui::PrefSpinBox::valueChanged), + this, + &DlgSettingsFemElmerImp::onCoresValueChanged); } DlgSettingsFemElmerImp::~DlgSettingsFemElmerImp() = default; @@ -96,9 +104,11 @@ void DlgSettingsFemElmerImp::changeEvent(QEvent* e) void DlgSettingsFemElmerImp::onfileNameChanged(QString FileName) { if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, tr("File does not exist"), + QMessageBox::critical(this, + tr("File does not exist"), tr("The specified executable \n'%1'\n does not exist!\n" - "Specify another file please.").arg(FileName)); + "Specify another file please.") + .arg(FileName)); } } @@ -106,15 +116,17 @@ void DlgSettingsFemElmerImp::onfileNameChangedMT(QString FileName) { ui->sb_elmer_num_cores->setMaximum(processor_count); - if (ui->sb_elmer_num_cores->value() == 1) + if (ui->sb_elmer_num_cores->value() == 1) { return; + } #if defined(FC_OS_WIN32) // name ends with "_mpi.exe" if (!FileName.endsWith(QLatin1String("_mpi.exe"))) { - QMessageBox::warning(this, tr("FEM Elmer: Not suitable for multithreading"), - tr("Wrong Elmer setting: You use more than one CPU core.\n" - "Therefore an executable with the suffix '_mpi.exe' is required.")); + QMessageBox::warning(this, + tr("FEM Elmer: Not suitable for multithreading"), + tr("Wrong Elmer setting: You use more than one CPU core.\n" + "Therefore an executable with the suffix '_mpi.exe' is required.")); ui->sb_elmer_num_cores->setValue(1); ui->sb_elmer_num_cores->setMaximum(1); return; @@ -122,9 +134,10 @@ void DlgSettingsFemElmerImp::onfileNameChangedMT(QString FileName) #elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD) // name ends with "_mpi" if (!FileName.endsWith(QLatin1String("_mpi"))) { - QMessageBox::warning(this, tr("FEM Elmer: Not suitable for multithreading"), - tr("Wrong Elmer setting: You use more than one CPU core.\n" - "Therefore an executable with the suffix '_mpi' is required.")); + QMessageBox::warning(this, + tr("FEM Elmer: Not suitable for multithreading"), + tr("Wrong Elmer setting: You use more than one CPU core.\n" + "Therefore an executable with the suffix '_mpi' is required.")); ui->sb_elmer_num_cores->setValue(1); ui->sb_elmer_num_cores->setMaximum(1); return; diff --git a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.h b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.h index ed089d3ffe..a5b5e11a9b 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.h @@ -1,4 +1,4 @@ - /************************************************************************** +/************************************************************************** * Copyright (c) 2016 FreeCAD Developers * * Author: Bernd Hahnebach * * Based on src/Mod/Fem/Gui/DlgSettingsFemCcx.h * @@ -25,18 +25,19 @@ #ifndef FEMGUI_DLGSETTINGSFEMELMERIMP_H #define FEMGUI_DLGSETTINGSFEMELMERIMP_H -#include #include +#include -namespace FemGui { +namespace FemGui +{ class Ui_DlgSettingsFemElmerImp; -class DlgSettingsFemElmerImp : public Gui::Dialog::PreferencePage +class DlgSettingsFemElmerImp: public Gui::Dialog::PreferencePage { Q_OBJECT public: - explicit DlgSettingsFemElmerImp( QWidget* parent = nullptr ); + explicit DlgSettingsFemElmerImp(QWidget* parent = nullptr); ~DlgSettingsFemElmerImp() override; protected Q_SLOTS: @@ -47,13 +48,13 @@ protected Q_SLOTS: protected: void saveSettings() override; void loadSettings() override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; int processor_count; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_DLGSETTINGSFEMELMERIMP_H +#endif // FEMGUI_DLGSETTINGSFEMELMERIMP_H diff --git a/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.cpp index 56f549faad..fe290d2baf 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.cpp @@ -33,8 +33,8 @@ using namespace FemGui; DlgSettingsFemExportAbaqusImp::DlgSettingsFemExportAbaqusImp(QWidget* parent) - : PreferencePage(parent), - ui(new Ui_DlgSettingsFemExportAbaqus) + : PreferencePage(parent) + , ui(new Ui_DlgSettingsFemExportAbaqus) { ui->setupUi(this); } @@ -46,8 +46,8 @@ DlgSettingsFemExportAbaqusImp::~DlgSettingsFemExportAbaqusImp() = default; void DlgSettingsFemExportAbaqusImp::saveSettings() { - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/Mod/Fem/Abaqus"); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Fem/Abaqus"); hGrp->SetInt("AbaqusElementChoice", ui->comboBoxElemChoiceParam->currentIndex()); ui->comboBoxElemChoiceParam->onSave(); @@ -59,16 +59,18 @@ void DlgSettingsFemExportAbaqusImp::loadSettings() ui->comboBoxElemChoiceParam->onRestore(); ui->checkBoxWriteGroups->onRestore(); - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/Mod/Fem/Abaqus"); - int index = hGrp->GetInt("AbaqusElementChoice", 0); - if (index > -1) ui->comboBoxElemChoiceParam->setCurrentIndex(index); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Fem/Abaqus"); + int index = hGrp->GetInt("AbaqusElementChoice", 0); + if (index > -1) { + ui->comboBoxElemChoiceParam->setCurrentIndex(index); + } } /** * Sets the strings of the subwidgets using the current language. */ -void DlgSettingsFemExportAbaqusImp::changeEvent(QEvent *e) +void DlgSettingsFemExportAbaqusImp::changeEvent(QEvent* e) { if (e->type() == QEvent::LanguageChange) { int c_index = ui->comboBoxElemChoiceParam->currentIndex(); diff --git a/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.h b/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.h index 60330bd774..7a70486224 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.h @@ -30,26 +30,27 @@ #include -namespace FemGui { +namespace FemGui +{ class Ui_DlgSettingsFemExportAbaqus; -class DlgSettingsFemExportAbaqusImp : public Gui::Dialog::PreferencePage +class DlgSettingsFemExportAbaqusImp: public Gui::Dialog::PreferencePage { Q_OBJECT public: - explicit DlgSettingsFemExportAbaqusImp( QWidget* parent = nullptr ); + explicit DlgSettingsFemExportAbaqusImp(QWidget* parent = nullptr); ~DlgSettingsFemExportAbaqusImp() override; protected: void saveSettings() override; void loadSettings() override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_DLGSETTINGSFEMEXPORTABAQUSIMP_H +#endif // FEMGUI_DLGSETTINGSFEMEXPORTABAQUSIMP_H diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.cpp index 0aa8b80c33..1cf03d90bf 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.cpp @@ -43,17 +43,22 @@ DlgSettingsFemGeneralImp::DlgSettingsFemGeneralImp(QWidget* parent) ui->cmb_def_solver->clear(); std::vector Solvers = {"None"}; - if (!Fem::Tools::checkIfBinaryExists("CCX", "ccx", "ccx").empty()) + if (!Fem::Tools::checkIfBinaryExists("CCX", "ccx", "ccx").empty()) { Solvers.emplace_back("CalculiX"); - if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver").empty()) + } + if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver").empty()) { Solvers.emplace_back("Elmer"); + } // also check the multi-CPU Elmer build - else if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver_mpi").empty()) + else if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver_mpi").empty()) { Solvers.emplace_back("Elmer"); - if (!Fem::Tools::checkIfBinaryExists("Mystran", "mystran", "mystran").empty()) + } + if (!Fem::Tools::checkIfBinaryExists("Mystran", "mystran", "mystran").empty()) { Solvers.emplace_back("Mystran"); - if (!Fem::Tools::checkIfBinaryExists("Z88", "z88", "z88r").empty()) + } + if (!Fem::Tools::checkIfBinaryExists("Z88", "z88", "z88r").empty()) { Solvers.emplace_back("Z88"); + } QStringList solversList; for (auto item : Solvers) { @@ -66,8 +71,9 @@ DlgSettingsFemGeneralImp::DlgSettingsFemGeneralImp(QWidget* parent) ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/Mod/Fem/General"); auto DefaultSolver = hGrp->GetInt("DefaultSolver", 0); - if (!DefaultSolver && ui->cmb_def_solver->count() == 2) + if (!DefaultSolver && ui->cmb_def_solver->count() == 2) { ui->cmb_def_solver->setCurrentIndex(1); + } } DlgSettingsFemGeneralImp::~DlgSettingsFemGeneralImp() = default; diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.h b/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.h index 23f5d57b85..df5fc3678a 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.h @@ -1,4 +1,4 @@ - /************************************************************************** +/************************************************************************** * Copyright (c) 2015 FreeCAD Developers * * Author: Przemo Firszt * * Based on src/Mod/Raytracing/Gui/DlgSettingsRayImp.h * @@ -25,29 +25,30 @@ #ifndef FEMGUI_DLGSETTINGSFEMGENERALIMP_H #define FEMGUI_DLGSETTINGSFEMGENERALIMP_H -#include #include +#include -namespace FemGui { +namespace FemGui +{ class Ui_DlgSettingsFemGeneralImp; -class DlgSettingsFemGeneralImp : public Gui::Dialog::PreferencePage +class DlgSettingsFemGeneralImp: public Gui::Dialog::PreferencePage { Q_OBJECT public: - explicit DlgSettingsFemGeneralImp( QWidget* parent = nullptr ); + explicit DlgSettingsFemGeneralImp(QWidget* parent = nullptr); ~DlgSettingsFemGeneralImp() override; protected: void saveSettings() override; void loadSettings() override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_DLGSETTINGSFEMGENERALIMP_H +#endif // FEMGUI_DLGSETTINGSFEMGENERALIMP_H diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp index a22faac6bb..7c93279f11 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp @@ -24,7 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include "DlgSettingsFemGmshImp.h" @@ -39,8 +39,10 @@ DlgSettingsFemGmshImp::DlgSettingsFemGmshImp(QWidget* parent) { ui->setupUi(this); - connect(ui->fc_gmsh_binary_path, &Gui::PrefFileChooser::fileNameChanged, - this, &DlgSettingsFemGmshImp::onfileNameChanged); + connect(ui->fc_gmsh_binary_path, + &Gui::PrefFileChooser::fileNameChanged, + this, + &DlgSettingsFemGmshImp::onfileNameChanged); } DlgSettingsFemGmshImp::~DlgSettingsFemGmshImp() = default; @@ -73,9 +75,11 @@ void DlgSettingsFemGmshImp::changeEvent(QEvent* e) void DlgSettingsFemGmshImp::onfileNameChanged(QString FileName) { if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, tr("File does not exist"), + QMessageBox::critical(this, + tr("File does not exist"), tr("The specified executable \n'%1'\n does not exist!\n" - "Specify another file please.").arg(FileName)); + "Specify another file please.") + .arg(FileName)); } } diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.h b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.h index 7d9b6cf1a5..18a04590cc 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.h @@ -1,4 +1,4 @@ - /************************************************************************** +/************************************************************************** * Copyright (c) 2016 FreeCAD Developers * * Author: Bernd Hahnebach * * Based on src/Mod/Fem/Gui/DlgSettingsFemCcx.h * @@ -25,18 +25,19 @@ #ifndef FEMGUI_DLGSETTINGSFEMGMSHIMP_H #define FEMGUI_DLGSETTINGSFEMGMSHIMP_H -#include #include +#include -namespace FemGui { +namespace FemGui +{ class Ui_DlgSettingsFemGmshImp; -class DlgSettingsFemGmshImp : public Gui::Dialog::PreferencePage +class DlgSettingsFemGmshImp: public Gui::Dialog::PreferencePage { Q_OBJECT public: - explicit DlgSettingsFemGmshImp( QWidget* parent = nullptr ); + explicit DlgSettingsFemGmshImp(QWidget* parent = nullptr); ~DlgSettingsFemGmshImp() override; protected Q_SLOTS: @@ -45,12 +46,12 @@ protected Q_SLOTS: protected: void saveSettings() override; void loadSettings() override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_DLGSETTINGSFEMGMSHIMP_H +#endif // FEMGUI_DLGSETTINGSFEMGMSHIMP_H diff --git a/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.cpp index 9c4ee914a5..fb23e50f71 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.cpp @@ -33,8 +33,8 @@ using namespace FemGui; DlgSettingsFemInOutVtkImp::DlgSettingsFemInOutVtkImp(QWidget* parent) - : PreferencePage(parent), - ui(new Ui_DlgSettingsFemInOutVtk) + : PreferencePage(parent) + , ui(new Ui_DlgSettingsFemInOutVtk) { ui->setupUi(this); } @@ -61,7 +61,9 @@ void DlgSettingsFemInOutVtkImp::loadSettings() "User parameter:BaseApp/Preferences/Mod/Fem/InOutVtk"); int index = hGrp->GetInt("ImportObject", 0); // 0 is standard on first initialize, 0 .. vtk res obj, 1 .. FEM mesh obj, 2 .. FreeCAD res obj - if (index > -1) ui->comboBoxVtkImportObject->setCurrentIndex(index); + if (index > -1) { + ui->comboBoxVtkImportObject->setCurrentIndex(index); + } } /** diff --git a/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.h b/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.h index 897cd9837a..316c68327c 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.h @@ -30,26 +30,27 @@ #include -namespace FemGui { +namespace FemGui +{ class Ui_DlgSettingsFemInOutVtk; -class DlgSettingsFemInOutVtkImp : public Gui::Dialog::PreferencePage +class DlgSettingsFemInOutVtkImp: public Gui::Dialog::PreferencePage { Q_OBJECT public: - explicit DlgSettingsFemInOutVtkImp( QWidget* parent = nullptr ); + explicit DlgSettingsFemInOutVtkImp(QWidget* parent = nullptr); ~DlgSettingsFemInOutVtkImp() override; protected: void saveSettings() override; void loadSettings() override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_DLGSETTINGSFEMINOUTVTKIMP_H +#endif // FEMGUI_DLGSETTINGSFEMINOUTVTKIMP_H diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h b/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h index 829901fa84..9a72a3eca0 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h @@ -1,4 +1,4 @@ - /************************************************************************** +/************************************************************************** * Copyright (c) 2018 FreeCAD Developers * * Author: Bernd Hahnebach * * Based on src/Mod/Fem/Gui/DlgSettingsFemElmer.h * @@ -25,30 +25,31 @@ #ifndef FEMGUI_DLGSETTINGSFEMMATERIALIMP_H #define FEMGUI_DLGSETTINGSFEMMATERIALIMP_H -#include #include +#include -namespace FemGui { +namespace FemGui +{ class Ui_DlgSettingsFemMaterialImp; -class DlgSettingsFemMaterialImp : public Gui::Dialog::PreferencePage +class DlgSettingsFemMaterialImp: public Gui::Dialog::PreferencePage { Q_OBJECT public: - explicit DlgSettingsFemMaterialImp( QWidget* parent = nullptr ); + explicit DlgSettingsFemMaterialImp(QWidget* parent = nullptr); ~DlgSettingsFemMaterialImp() override; protected: void saveSettings() override; void loadSettings() override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_DLGSETTINGSFEMMATERIALIMP_H +#endif // FEMGUI_DLGSETTINGSFEMMATERIALIMP_H diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp index 0d8ec13ae4..c91730ecee 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp @@ -24,7 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include "DlgSettingsFemMystranImp.h" @@ -39,8 +39,10 @@ DlgSettingsFemMystranImp::DlgSettingsFemMystranImp(QWidget* parent) { ui->setupUi(this); - connect(ui->fc_mystran_binary_path, &Gui::PrefFileChooser::fileNameChanged, - this, &DlgSettingsFemMystranImp::onfileNameChanged); + connect(ui->fc_mystran_binary_path, + &Gui::PrefFileChooser::fileNameChanged, + this, + &DlgSettingsFemMystranImp::onfileNameChanged); } DlgSettingsFemMystranImp::~DlgSettingsFemMystranImp() = default; @@ -75,9 +77,11 @@ void DlgSettingsFemMystranImp::changeEvent(QEvent* e) void DlgSettingsFemMystranImp::onfileNameChanged(QString FileName) { if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, tr("File does not exist"), + QMessageBox::critical(this, + tr("File does not exist"), tr("The specified executable \n'%1'\n does not exist!\n" - "Specify another file please.").arg(FileName)); + "Specify another file please.") + .arg(FileName)); } } diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h index 5aa0c53d9b..e00f3f6bdb 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h @@ -1,4 +1,4 @@ - /************************************************************************** +/************************************************************************** * Copyright (c) 2021 FreeCAD Developers * * Author: Bernd Hahnebach * * Based on src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.h * @@ -25,19 +25,20 @@ #ifndef FEMGUI_DLGSETTINGSFEMMYSTRANIMP_H #define FEMGUI_DLGSETTINGSFEMMYSTRANIMP_H -#include #include +#include -namespace FemGui { +namespace FemGui +{ class Ui_DlgSettingsFemMystranImp; -class DlgSettingsFemMystranImp : public Gui::Dialog::PreferencePage +class DlgSettingsFemMystranImp: public Gui::Dialog::PreferencePage { Q_OBJECT public: - explicit DlgSettingsFemMystranImp( QWidget* parent = nullptr ); + explicit DlgSettingsFemMystranImp(QWidget* parent = nullptr); ~DlgSettingsFemMystranImp() override; protected Q_SLOTS: @@ -46,12 +47,12 @@ protected Q_SLOTS: protected: void saveSettings() override; void loadSettings() override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_DLGSETTINGSFEMMYSTRANIMP_H +#endif // FEMGUI_DLGSETTINGSFEMMYSTRANIMP_H diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp index c16f8bfcac..39375d468e 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp @@ -24,7 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -41,8 +41,10 @@ DlgSettingsFemZ88Imp::DlgSettingsFemZ88Imp(QWidget* parent) { ui->setupUi(this); - connect(ui->fc_z88_binary_path, &Gui::PrefFileChooser::fileNameChanged, - this, &DlgSettingsFemZ88Imp::onfileNameChanged); + connect(ui->fc_z88_binary_path, + &Gui::PrefFileChooser::fileNameChanged, + this, + &DlgSettingsFemZ88Imp::onfileNameChanged); } DlgSettingsFemZ88Imp::~DlgSettingsFemZ88Imp() = default; @@ -72,14 +74,17 @@ void DlgSettingsFemZ88Imp::loadSettings() ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/Mod/Fem/Z88"); int index = hGrp->GetInt("Solver", 0); - if (index > -1) + if (index > -1) { ui->cmb_solver->setCurrentIndex(index); + } int places = hGrp->GetInt("MaxGS", 100000000); - if (places > -1) + if (places > -1) { ui->sb_Z88_MaxGS->setValue(places); + } places = hGrp->GetInt("MaxKOI", 2800000); - if (places > -1) + if (places > -1) { ui->sb_Z88_MaxKOI->setValue(places); + } } /** @@ -98,7 +103,8 @@ void DlgSettingsFemZ88Imp::changeEvent(QEvent* e) void DlgSettingsFemZ88Imp::onfileNameChanged(QString FileName) { if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, tr("File does not exist"), + QMessageBox::critical(this, + tr("File does not exist"), tr("The specified z88r executable \n'%1'\n does not exist!\n" "Specify another file please.") .arg(FileName)); @@ -110,14 +116,14 @@ void DlgSettingsFemZ88Imp::onfileNameChanged(QString FileName) auto strName = FileName.toStdString(); #if defined(FC_OS_WIN32) if (strName.substr(strName.length() - 8) != "z88r.exe") { - QMessageBox::critical(this, tr("Wrong file"), - tr("You must specify the path to the z88r.exe!")); + QMessageBox::critical(this, + tr("Wrong file"), + tr("You must specify the path to the z88r.exe!")); return; } #elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD) if (strName.substr(strName.length() - 4) != "z88r") { - QMessageBox::critical(this, tr("Wrong file"), - tr("You must specify the path to the z88r!")); + QMessageBox::critical(this, tr("Wrong file"), tr("You must specify the path to the z88r!")); return; } #endif diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h index 1b82c033e8..9097756226 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h @@ -1,4 +1,4 @@ - /************************************************************************** +/************************************************************************** * Copyright (c) 2016 FreeCAD Developers * * Author: Bernd Hahnebach * * Based on src/Mod/Fem/Gui/DlgSettingsFemCcx.h * @@ -25,19 +25,20 @@ #ifndef FEMGUI_DLGSETTINGSFEMZ88IMP_H #define FEMGUI_DLGSETTINGSFEMZ88IMP_H -#include #include +#include -namespace FemGui { +namespace FemGui +{ class Ui_DlgSettingsFemZ88Imp; -class DlgSettingsFemZ88Imp : public Gui::Dialog::PreferencePage +class DlgSettingsFemZ88Imp: public Gui::Dialog::PreferencePage { Q_OBJECT public: - explicit DlgSettingsFemZ88Imp( QWidget* parent = nullptr ); + explicit DlgSettingsFemZ88Imp(QWidget* parent = nullptr); ~DlgSettingsFemZ88Imp() override; protected Q_SLOTS: @@ -46,12 +47,12 @@ protected Q_SLOTS: protected: void saveSettings() override; void loadSettings() override; - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_DLGSETTINGSFEMZ88IMP_H +#endif // FEMGUI_DLGSETTINGSFEMZ88IMP_H diff --git a/src/Mod/Fem/Gui/FemSelectionGate.cpp b/src/Mod/Fem/Gui/FemSelectionGate.cpp index 0f8ce2411b..06c5730ca9 100644 --- a/src/Mod/Fem/Gui/FemSelectionGate.cpp +++ b/src/Mod/Fem/Gui/FemSelectionGate.cpp @@ -28,23 +28,22 @@ using namespace FemGui; using namespace Gui; -bool FemSelectionGate::allow(App::Document* /*pDoc*/, App::DocumentObject* /*pObj*/, const char* sSubName) +bool FemSelectionGate::allow(App::Document* /*pDoc*/, + App::DocumentObject* /*pObj*/, + const char* sSubName) { - if (!sSubName || sSubName[0] == '\0') + if (!sSubName || sSubName[0] == '\0') { return false; + } - if (sSubName[0] == 'E' && - sSubName[1] == 'l' && - sSubName[2] == 'e' && - sSubName[3] == 'm' && - (Type == Element || Type == NodeElement)) + if (sSubName[0] == 'E' && sSubName[1] == 'l' && sSubName[2] == 'e' && sSubName[3] == 'm' + && (Type == Element || Type == NodeElement)) { return true; - if (sSubName[0] == 'N' && - sSubName[1] == 'o' && - sSubName[2] == 'd' && - sSubName[3] == 'e' && - (Type == Node || Type == NodeElement)) + } + if (sSubName[0] == 'N' && sSubName[1] == 'o' && sSubName[2] == 'd' && sSubName[3] == 'e' + && (Type == Node || Type == NodeElement)) { return true; + } return false; } diff --git a/src/Mod/Fem/Gui/FemSelectionGate.h b/src/Mod/Fem/Gui/FemSelectionGate.h index 1c39f47117..08f874978a 100644 --- a/src/Mod/Fem/Gui/FemSelectionGate.h +++ b/src/Mod/Fem/Gui/FemSelectionGate.h @@ -25,22 +25,24 @@ #include -namespace FemGui { - -class FemSelectionGate : public Gui::SelectionFilterGate +namespace FemGui { - public: - enum ElemType { - Nothing , - Node , - Element , + +class FemSelectionGate: public Gui::SelectionFilterGate +{ +public: + enum ElemType + { + Nothing, + Node, + Element, NodeElement }; explicit FemSelectionGate(ElemType type) - : Gui::SelectionFilterGate(nullPointer()),Type(type) - { - } + : Gui::SelectionFilterGate(nullPointer()) + , Type(type) + {} ElemType Type; @@ -48,6 +50,6 @@ class FemSelectionGate : public Gui::SelectionFilterGate bool allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_FemSelectionGate_H +#endif // GUI_FemSelectionGate_H diff --git a/src/Mod/Fem/Gui/FemSettings.cpp b/src/Mod/Fem/Gui/FemSettings.cpp index 61d83144a8..a8f6fb350f 100644 --- a/src/Mod/Fem/Gui/FemSettings.cpp +++ b/src/Mod/Fem/Gui/FemSettings.cpp @@ -32,7 +32,8 @@ using namespace FemGui; FemSettings::FemSettings() { - pGroup = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Fem"); + pGroup = + App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Fem"); } void FemSettings::setPostAutoRecompute(bool on) diff --git a/src/Mod/Fem/Gui/FemSettings.h b/src/Mod/Fem/Gui/FemSettings.h index 03da65edb0..ffa0498c29 100644 --- a/src/Mod/Fem/Gui/FemSettings.h +++ b/src/Mod/Fem/Gui/FemSettings.h @@ -26,7 +26,8 @@ #include -namespace FemGui { +namespace FemGui +{ class FemSettings { @@ -39,6 +40,6 @@ private: ParameterGrp::handle pGroup; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEMGUI_SETTINGS_H +#endif // FEMGUI_SETTINGS_H diff --git a/src/Mod/Fem/Gui/PreCompiled.h b/src/Mod/Fem/Gui/PreCompiled.h index d8132644f4..423ea9eb4c 100644 --- a/src/Mod/Fem/Gui/PreCompiled.h +++ b/src/Mod/Fem/Gui/PreCompiled.h @@ -26,8 +26,8 @@ #include #ifdef _MSC_VER -# pragma warning(disable : 4005) -# pragma warning(disable : 4290) +#pragma warning(disable : 4005) +#pragma warning(disable : 4290) #endif #ifdef _PreComp_ @@ -54,9 +54,9 @@ #include #ifdef FC_OS_WIN32 -# define WIN32_LEAN_AND_MEAN -# define NOMINMAX -# include +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#include #endif // OCC @@ -66,7 +66,6 @@ #include #include -#include #include #include #include @@ -78,12 +77,13 @@ #include #include #include -#include #include +#include #include #include #include #include +#include // inventor #include @@ -95,10 +95,10 @@ #include #include #include -#include -#include #include #include +#include +#include #include #include #include @@ -106,8 +106,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -148,8 +148,8 @@ // Salomesh #include -#include #include +#include // VTK #include @@ -158,6 +158,6 @@ #include #include -#endif //_PreComp_ +#endif //_PreComp_ -#endif // FEMGUI_PRECOMPILED_H +#endif // FEMGUI_PRECOMPILED_H diff --git a/src/Mod/Fem/Gui/PropertyFemMeshItem.cpp b/src/Mod/Fem/Gui/PropertyFemMeshItem.cpp index b7a70b96bd..71f1228ce5 100644 --- a/src/Mod/Fem/Gui/PropertyFemMeshItem.cpp +++ b/src/Mod/Fem/Gui/PropertyFemMeshItem.cpp @@ -23,8 +23,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include #endif #include @@ -39,38 +39,38 @@ PROPERTYITEM_SOURCE(FemGui::PropertyFemMeshItem) PropertyFemMeshItem::PropertyFemMeshItem() { - m_n = static_cast - (Gui::PropertyEditor::PropertyIntegerItem::create()); + m_n = static_cast( + Gui::PropertyEditor::PropertyIntegerItem::create()); m_n->setParent(this); m_n->setPropertyName(QLatin1String("Nodes")); this->appendChild(m_n); - m_e = static_cast - (Gui::PropertyEditor::PropertyIntegerItem::create()); + m_e = static_cast( + Gui::PropertyEditor::PropertyIntegerItem::create()); m_e->setParent(this); m_e->setPropertyName(QLatin1String("Edges")); this->appendChild(m_e); - m_f = static_cast - (Gui::PropertyEditor::PropertyIntegerItem::create()); + m_f = static_cast( + Gui::PropertyEditor::PropertyIntegerItem::create()); m_f->setParent(this); m_f->setPropertyName(QLatin1String("Faces")); this->appendChild(m_f); - m_p = static_cast - (Gui::PropertyEditor::PropertyIntegerItem::create()); + m_p = static_cast( + Gui::PropertyEditor::PropertyIntegerItem::create()); m_p->setParent(this); m_p->setPropertyName(QLatin1String("Polygons")); this->appendChild(m_p); - m_v = static_cast - (Gui::PropertyEditor::PropertyIntegerItem::create()); + m_v = static_cast( + Gui::PropertyEditor::PropertyIntegerItem::create()); m_v->setParent(this); m_v->setPropertyName(QLatin1String("Volumes")); this->appendChild(m_v); - m_h = static_cast - (Gui::PropertyEditor::PropertyIntegerItem::create()); + m_h = static_cast( + Gui::PropertyEditor::PropertyIntegerItem::create()); m_h->setParent(this); m_h->setPropertyName(QLatin1String("Polyhedrons")); this->appendChild(m_h); - m_g = static_cast - (Gui::PropertyEditor::PropertyIntegerItem::create()); + m_g = static_cast( + Gui::PropertyEditor::PropertyIntegerItem::create()); m_g->setParent(this); m_g->setPropertyName(QLatin1String("Groups")); this->appendChild(m_g); @@ -128,7 +128,9 @@ void PropertyFemMeshItem::setValue(const QVariant& value) Q_UNUSED(value); } -QWidget* PropertyFemMeshItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const +QWidget* PropertyFemMeshItem::createEditor(QWidget* parent, + const QObject* receiver, + const char* method) const { Q_UNUSED(parent); Q_UNUSED(receiver); diff --git a/src/Mod/Fem/Gui/PropertyFemMeshItem.h b/src/Mod/Fem/Gui/PropertyFemMeshItem.h index 2609c634bf..e90fcb86c8 100644 --- a/src/Mod/Fem/Gui/PropertyFemMeshItem.h +++ b/src/Mod/Fem/Gui/PropertyFemMeshItem.h @@ -25,13 +25,14 @@ #include -namespace FemGui { +namespace FemGui +{ /** * Display data of an FEM mesh. * \author Werner Mayer */ -class PropertyFemMeshItem : public Gui::PropertyEditor::PropertyItem +class PropertyFemMeshItem: public Gui::PropertyEditor::PropertyItem { Q_OBJECT Q_PROPERTY(int Nodes READ countNodes CONSTANT) @@ -43,9 +44,10 @@ class PropertyFemMeshItem : public Gui::PropertyEditor::PropertyItem Q_PROPERTY(int Groups READ countGroups CONSTANT) PROPERTYITEM_HEADER - QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const override; - void setEditorData(QWidget *editor, const QVariant& data) const override; - QVariant editorData(QWidget *editor) const override; + QWidget* + createEditor(QWidget* parent, const QObject* receiver, const char* method) const override; + void setEditorData(QWidget* editor, const QVariant& data) const override; + QVariant editorData(QWidget* editor) const override; int countNodes() const; int countEdges() const; @@ -74,8 +76,7 @@ private: Gui::PropertyEditor::PropertyIntegerItem* m_g; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEMGUI_PROPERTY_FEMMESH_ITEM_H - +#endif // FEMGUI_PROPERTY_FEMMESH_ITEM_H diff --git a/src/Mod/Fem/Gui/TaskAnalysisInfo.cpp b/src/Mod/Fem/Gui/TaskAnalysisInfo.cpp index e5a8260965..f702628af2 100644 --- a/src/Mod/Fem/Gui/TaskAnalysisInfo.cpp +++ b/src/Mod/Fem/Gui/TaskAnalysisInfo.cpp @@ -32,9 +32,9 @@ using namespace FemGui; using namespace Gui; TaskAnalysisInfo::TaskAnalysisInfo(Fem::FemAnalysis* pcObject, QWidget* parent) - : TaskBox(Gui::BitmapFactory().pixmap("FEM_Analysis"), tr("Nodes set"), true, parent), - pcObject(pcObject), - ui(new Ui_TaskAnalysisInfo) + : TaskBox(Gui::BitmapFactory().pixmap("FEM_Analysis"), tr("Nodes set"), true, parent) + , pcObject(pcObject) + , ui(new Ui_TaskAnalysisInfo) { // we need a separate container widget to add all controls to proxy = new QWidget(this); diff --git a/src/Mod/Fem/Gui/TaskAnalysisInfo.h b/src/Mod/Fem/Gui/TaskAnalysisInfo.h index c127315c7c..485ae0dc6f 100644 --- a/src/Mod/Fem/Gui/TaskAnalysisInfo.h +++ b/src/Mod/Fem/Gui/TaskAnalysisInfo.h @@ -29,43 +29,48 @@ class Ui_TaskAnalysisInfo; class SoEventCallback; -namespace Base { - class Polygon2d; +namespace Base +{ +class Polygon2d; } -namespace App { - class Property; +namespace App +{ +class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; class ViewVolumeProjection; +} // namespace Gui + +namespace Fem +{ +class FemAnalysis; } -namespace Fem{ - class FemAnalysis; -} - -namespace FemGui { +namespace FemGui +{ class ViewProviderFemMesh; -class TaskAnalysisInfo : public Gui::TaskView::TaskBox +class TaskAnalysisInfo: public Gui::TaskView::TaskBox { Q_OBJECT public: - explicit TaskAnalysisInfo(Fem::FemAnalysis *pcObject,QWidget *parent = nullptr); + explicit TaskAnalysisInfo(Fem::FemAnalysis* pcObject, QWidget* parent = nullptr); ~TaskAnalysisInfo() override; protected: - Fem::FemAnalysis *pcObject; + Fem::FemAnalysis* pcObject; private: QWidget* proxy; std::unique_ptr ui; }; -} //namespace FEMGUI_TaskAnalysisInfo_H +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskAnalysisInfo_H +#endif // GUI_TASKVIEW_TaskAnalysisInfo_H diff --git a/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp b/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp index 650d7aaeba..1cd9a2af14 100644 --- a/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp +++ b/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp @@ -22,13 +22,13 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include -# include -# include -# include +#include +#include +#include #endif #include @@ -43,10 +43,10 @@ #include #include -#include "TaskCreateNodeSet.h" -#include "ui_TaskCreateNodeSet.h" #include "FemSelectionGate.h" +#include "TaskCreateNodeSet.h" #include "ViewProviderFemMesh.h" +#include "ui_TaskCreateNodeSet.h" using namespace FemGui; @@ -54,10 +54,10 @@ using namespace Gui; TaskCreateNodeSet::TaskCreateNodeSet(Fem::FemSetNodesObject* pcObject, QWidget* parent) - : TaskBox(Gui::BitmapFactory().pixmap("FEM_CreateNodesSet"), tr("Nodes set"), true, parent), - pcObject(pcObject), - selectionMode(none), - ui(new Ui_TaskCreateNodeSet) + : TaskBox(Gui::BitmapFactory().pixmap("FEM_CreateNodesSet"), tr("Nodes set"), true, parent) + , pcObject(pcObject) + , selectionMode(none) + , ui(new Ui_TaskCreateNodeSet) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -85,7 +85,6 @@ TaskCreateNodeSet::TaskCreateNodeSet(Fem::FemSetNodesObject* pcObject, QWidget* MeshViewProvider->setHighlightNodes(tempSet); ui->groupBox_AngleSearch->setEnabled(false); - } void TaskCreateNodeSet::Poly() @@ -139,23 +138,27 @@ void TaskCreateNodeSet::DefineNodesCallback(void* ud, SoEventCallback* n) Gui::SelectionRole role; std::vector clPoly = view->getGLPolygon(&role); - if (clPoly.size() < 3) + if (clPoly.size() < 3) { return; - if (clPoly.front() != clPoly.back()) + } + if (clPoly.front() != clPoly.back()) { clPoly.push_back(clPoly.front()); + } SoCamera* cam = view->getSoRenderManager()->getCamera(); SbViewVolume vv = cam->getViewVolume(); Gui::ViewVolumeProjection proj(vv); Base::Polygon2d polygon; - for (auto it : clPoly) + for (auto it : clPoly) { polygon.Add(Base::Vector2d(it[0], it[1])); + } taskBox->DefineNodes(polygon, proj, role == Gui::SelectionRole::Inner ? true : false); } void TaskCreateNodeSet::DefineNodes(const Base::Polygon2d& polygon, - const Gui::ViewVolumeProjection& proj, bool inner) + const Gui::ViewVolumeProjection& proj, + bool inner) { const SMESHDS_Mesh* data = pcObject->FemMesh.getValue() ->FemMesh.getValue() @@ -165,15 +168,17 @@ void TaskCreateNodeSet::DefineNodes(const Base::Polygon2d& polygon, SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator(); Base::Vector3f pt2d; - if (!ui->checkBox_Add->isChecked()) + if (!ui->checkBox_Add->isChecked()) { tempSet.clear(); + } while (aNodeIter->more()) { const SMDS_MeshNode* aNode = aNodeIter->next(); Base::Vector3f vec(aNode->X(), aNode->Y(), aNode->Z()); pt2d = proj(vec); - if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y)) == inner) + if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y)) == inner) { tempSet.insert(aNode->GetID()); + } } MeshViewProvider->setHighlightNodes(tempSet); @@ -181,8 +186,9 @@ void TaskCreateNodeSet::DefineNodes(const Base::Polygon2d& polygon, void TaskCreateNodeSet::onSelectionChanged(const Gui::SelectionChanges& msg) { - if (selectionMode == none) + if (selectionMode == none) { return; + } if (msg.Type == Gui::SelectionChanges::AddSelection) { std::string subName(msg.pSubName); diff --git a/src/Mod/Fem/Gui/TaskCreateNodeSet.h b/src/Mod/Fem/Gui/TaskCreateNodeSet.h index 16c24f3e95..c1057fd9b5 100644 --- a/src/Mod/Fem/Gui/TaskCreateNodeSet.h +++ b/src/Mod/Fem/Gui/TaskCreateNodeSet.h @@ -30,33 +30,37 @@ class Ui_TaskCreateNodeSet; class SoEventCallback; -namespace Base { +namespace Base +{ class Polygon2d; } -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; class ViewVolumeProjection; -} +} // namespace Gui -namespace FemGui { +namespace FemGui +{ class ViewProviderFemMesh; -class TaskCreateNodeSet : public Gui::TaskView::TaskBox, public Gui::SelectionObserver +class TaskCreateNodeSet: public Gui::TaskView::TaskBox, public Gui::SelectionObserver { Q_OBJECT public: - explicit TaskCreateNodeSet(Fem::FemSetNodesObject *pcObject,QWidget *parent = nullptr); + explicit TaskCreateNodeSet(Fem::FemSetNodesObject* pcObject, QWidget* parent = nullptr); ~TaskCreateNodeSet() override; std::set tempSet; - ViewProviderFemMesh * MeshViewProvider; + ViewProviderFemMesh* MeshViewProvider; private Q_SLOTS: void Poly(); @@ -64,19 +68,23 @@ private Q_SLOTS: void SwitchMethod(int Value); protected: - Fem::FemSetNodesObject *pcObject; - static void DefineNodesCallback(void * ud, SoEventCallback * n); - void DefineNodes(const Base::Polygon2d &polygon,const Gui::ViewVolumeProjection &proj,bool); + Fem::FemSetNodesObject* pcObject; + static void DefineNodesCallback(void* ud, SoEventCallback* n); + void DefineNodes(const Base::Polygon2d& polygon, const Gui::ViewVolumeProjection& proj, bool); protected: void onSelectionChanged(const Gui::SelectionChanges& msg) override; - enum selectionModes { none, PickElement} selectionMode; + enum selectionModes + { + none, + PickElement + } selectionMode; private: QWidget* proxy; std::unique_ptr ui; }; -} //namespace PartDesignGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskCreateNodeSet_H +#endif // GUI_TASKVIEW_TaskCreateNodeSet_H diff --git a/src/Mod/Fem/Gui/TaskDlgAnalysis.cpp b/src/Mod/Fem/Gui/TaskDlgAnalysis.cpp index 351f14dcda..a1f8d6a8f0 100644 --- a/src/Mod/Fem/Gui/TaskDlgAnalysis.cpp +++ b/src/Mod/Fem/Gui/TaskDlgAnalysis.cpp @@ -29,8 +29,8 @@ #include #include -#include "TaskDlgAnalysis.h" #include "TaskAnalysisInfo.h" +#include "TaskDlgAnalysis.h" #include "TaskDriver.h" @@ -42,10 +42,11 @@ using namespace FemGui; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TaskDlgAnalysis::TaskDlgAnalysis(Fem::FemAnalysis* obj) - : TaskDialog(), FemAnalysis(obj) + : TaskDialog() + , FemAnalysis(obj) { - driver = new TaskDriver(obj); - info = new TaskAnalysisInfo(obj); + driver = new TaskDriver(obj); + info = new TaskAnalysisInfo(obj); Content.push_back(driver); Content.push_back(info); @@ -58,27 +59,26 @@ TaskDlgAnalysis::~TaskDlgAnalysis() = default; void TaskDlgAnalysis::open() { - //select->activate(); - //Edge2TaskObject->execute(); - //param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges,Edge2TaskObject->NbrOfCluster); - + // select->activate(); + // Edge2TaskObject->execute(); + // param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges,Edge2TaskObject->NbrOfCluster); } bool TaskDlgAnalysis::accept() { - //try { - // FemSetNodesObject->Nodes.setValues(param->tempSet); - // FemSetNodesObject->recompute(); - // //Gui::Document* doc = Gui::Application::Instance->activeDocument(); - // //if(doc) - // // doc->resetEdit(); - // param->MeshViewProvider->resetHighlightNodes(); - // FemSetNodesObject->Label.setValue(name->name); - // Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + // try { + // FemSetNodesObject->Nodes.setValues(param->tempSet); + // FemSetNodesObject->recompute(); + // //Gui::Document* doc = Gui::Application::Instance->activeDocument(); + // //if(doc) + // // doc->resetEdit(); + // param->MeshViewProvider->resetHighlightNodes(); + // FemSetNodesObject->Label.setValue(name->name); + // Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); // return true; //} - //catch (const Base::Exception& e) { + // catch (const Base::Exception& e) { // Base::Console().Warning("TaskDlgAnalysis::accept(): %s\n", e.what()); //} @@ -87,20 +87,18 @@ bool TaskDlgAnalysis::accept() bool TaskDlgAnalysis::reject() { - //FemSetNodesObject->execute(); - // //Gui::Document* doc = Gui::Application::Instance->activeDocument(); - // //if(doc) - // // doc->resetEdit(); - //param->MeshViewProvider->resetHighlightNodes(); - //Gui::Command::abortCommand(); - //Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + // FemSetNodesObject->execute(); + // //Gui::Document* doc = Gui::Application::Instance->activeDocument(); + // //if(doc) + // // doc->resetEdit(); + // param->MeshViewProvider->resetHighlightNodes(); + // Gui::Command::abortCommand(); + // Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); return true; } void TaskDlgAnalysis::helpRequested() -{ - -} +{} #include "moc_TaskDlgAnalysis.cpp" diff --git a/src/Mod/Fem/Gui/TaskDlgAnalysis.h b/src/Mod/Fem/Gui/TaskDlgAnalysis.h index 57852c1493..cc8eb0f697 100644 --- a/src/Mod/Fem/Gui/TaskDlgAnalysis.h +++ b/src/Mod/Fem/Gui/TaskDlgAnalysis.h @@ -27,21 +27,23 @@ #include -namespace Fem{ - class FemAnalysis; +namespace Fem +{ +class FemAnalysis; } -namespace FemGui { - class TaskAnalysisInfo ; - class TaskDriver; +namespace FemGui +{ +class TaskAnalysisInfo; +class TaskDriver; /// simulation dialog for the TaskView -class TaskDlgAnalysis : public Gui::TaskView::TaskDialog +class TaskDlgAnalysis: public Gui::TaskView::TaskDialog { Q_OBJECT public: - explicit TaskDlgAnalysis(Fem::FemAnalysis *); + explicit TaskDlgAnalysis(Fem::FemAnalysis*); ~TaskDlgAnalysis() override; public: @@ -56,17 +58,18 @@ public: /// returns for Close and Help button QDialogButtonBox::StandardButtons getStandardButtons() const override - { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Apply; } + { + return QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply; + } protected: - TaskAnalysisInfo *info; - TaskDriver *driver; + TaskAnalysisInfo* info; + TaskDriver* driver; - Fem::FemAnalysis *FemAnalysis; + Fem::FemAnalysis* FemAnalysis; }; +} // namespace FemGui -} //namespace FemGui - -#endif // FEMGUI_TaskDlgAnalysis_H +#endif // FEMGUI_TaskDlgAnalysis_H diff --git a/src/Mod/Fem/Gui/TaskDlgCreateNodeSet.cpp b/src/Mod/Fem/Gui/TaskDlgCreateNodeSet.cpp index 382a48a32e..ac507e7198 100644 --- a/src/Mod/Fem/Gui/TaskDlgCreateNodeSet.cpp +++ b/src/Mod/Fem/Gui/TaskDlgCreateNodeSet.cpp @@ -41,10 +41,11 @@ using namespace FemGui; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TaskDlgCreateNodeSet::TaskDlgCreateNodeSet(Fem::FemSetNodesObject* obj) - : TaskDialog(), FemSetNodesObject(obj) + : TaskDialog() + , FemSetNodesObject(obj) { - name = new TaskObjectName(obj); - param = new TaskCreateNodeSet(obj); + name = new TaskObjectName(obj); + param = new TaskCreateNodeSet(obj); Content.push_back(name); Content.push_back(param); @@ -57,10 +58,9 @@ TaskDlgCreateNodeSet::~TaskDlgCreateNodeSet() = default; void TaskDlgCreateNodeSet::open() { - //select->activate(); - //Edge2TaskObject->execute(); - //param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges,Edge2TaskObject->NbrOfCluster); - + // select->activate(); + // Edge2TaskObject->execute(); + // param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges,Edge2TaskObject->NbrOfCluster); } bool TaskDlgCreateNodeSet::accept() @@ -68,9 +68,9 @@ bool TaskDlgCreateNodeSet::accept() try { FemSetNodesObject->Nodes.setValues(param->tempSet); FemSetNodesObject->recomputeFeature(); - //Gui::Document* doc = Gui::Application::Instance->activeDocument(); - //if(doc) - // doc->resetEdit(); + // Gui::Document* doc = Gui::Application::Instance->activeDocument(); + // if(doc) + // doc->resetEdit(); param->MeshViewProvider->resetHighlightNodes(); FemSetNodesObject->Label.setValue(name->name); Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); @@ -87,9 +87,9 @@ bool TaskDlgCreateNodeSet::accept() bool TaskDlgCreateNodeSet::reject() { FemSetNodesObject->execute(); - //Gui::Document* doc = Gui::Application::Instance->activeDocument(); - //if(doc) - // doc->resetEdit(); + // Gui::Document* doc = Gui::Application::Instance->activeDocument(); + // if(doc) + // doc->resetEdit(); param->MeshViewProvider->resetHighlightNodes(); Gui::Command::abortCommand(); Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); @@ -98,8 +98,6 @@ bool TaskDlgCreateNodeSet::reject() } void TaskDlgCreateNodeSet::helpRequested() -{ - -} +{} #include "moc_TaskDlgCreateNodeSet.cpp" diff --git a/src/Mod/Fem/Gui/TaskDlgCreateNodeSet.h b/src/Mod/Fem/Gui/TaskDlgCreateNodeSet.h index 3f4d34cc76..9a01e222ec 100644 --- a/src/Mod/Fem/Gui/TaskDlgCreateNodeSet.h +++ b/src/Mod/Fem/Gui/TaskDlgCreateNodeSet.h @@ -31,19 +31,26 @@ // forward -namespace Gui { namespace TaskView { class TaskSelectLinkProperty;}} +namespace Gui +{ +namespace TaskView +{ +class TaskSelectLinkProperty; +} +} // namespace Gui -namespace FemGui { +namespace FemGui +{ /// simulation dialog for the TaskView -class TaskDlgCreateNodeSet : public Gui::TaskView::TaskDialog +class TaskDlgCreateNodeSet: public Gui::TaskView::TaskDialog { Q_OBJECT public: - explicit TaskDlgCreateNodeSet(Fem::FemSetNodesObject *); + explicit TaskDlgCreateNodeSet(Fem::FemSetNodesObject*); ~TaskDlgCreateNodeSet() override; public: @@ -58,17 +65,18 @@ public: /// returns for Close and Help button QDialogButtonBox::StandardButtons getStandardButtons() const override - { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; } + { + return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; + } protected: - TaskCreateNodeSet *param; - TaskObjectName *name; + TaskCreateNodeSet* param; + TaskObjectName* name; - Fem::FemSetNodesObject *FemSetNodesObject; + Fem::FemSetNodesObject* FemSetNodesObject; }; +} // namespace FemGui -} //namespace RobotGui - -#endif // ROBOTGUI_TASKDLGSIMULATE_H +#endif // ROBOTGUI_TASKDLGSIMULATE_H diff --git a/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.cpp b/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.cpp index f0a0046078..ead81c60ee 100644 --- a/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.cpp +++ b/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.cpp @@ -23,14 +23,14 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include #include #include -#include #include +#include #include #include #include @@ -48,7 +48,9 @@ using namespace FemGui; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TaskDlgMeshShapeNetgen::TaskDlgMeshShapeNetgen(FemGui::ViewProviderFemMeshShapeNetgen* obj) - : TaskDialog(), param(nullptr), ViewProviderFemMeshShapeNetgen(obj) + : TaskDialog() + , param(nullptr) + , ViewProviderFemMeshShapeNetgen(obj) { FemMeshShapeNetgenObject = dynamic_cast(obj->getObject()); if (FemMeshShapeNetgenObject) { @@ -74,8 +76,7 @@ void TaskDlgMeshShapeNetgen::open() void TaskDlgMeshShapeNetgen::clicked(int button) { try { - if (QDialogButtonBox::Apply == button && param->touched) - { + if (QDialogButtonBox::Apply == button && param->touched) { Gui::WaitCursor wc; // May throw an exception which we must handle here FemMeshShapeNetgenObject->execute(); @@ -91,13 +92,14 @@ void TaskDlgMeshShapeNetgen::clicked(int button) bool TaskDlgMeshShapeNetgen::accept() { try { - if (param->touched) - { + if (param->touched) { Gui::WaitCursor wc; bool ret = FemMeshShapeNetgenObject->recomputeFeature(); if (!ret) { wc.restoreCursor(); - QMessageBox::critical(Gui::getMainWindow(), tr("Meshing failure"), + QMessageBox::critical( + Gui::getMainWindow(), + tr("Meshing failure"), QString::fromStdString(FemMeshShapeNetgenObject->getStatusString())); return true; } @@ -109,7 +111,7 @@ bool TaskDlgMeshShapeNetgen::accept() Gui::Application::Instance->hideViewProvider(obj); } - //FemSetNodesObject->Label.setValue(name->name); + // FemSetNodesObject->Label.setValue(name->name); Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); Gui::Command::commitCommand(); @@ -124,11 +126,11 @@ bool TaskDlgMeshShapeNetgen::accept() bool TaskDlgMeshShapeNetgen::reject() { - //FemSetNodesObject->execute(); - // //Gui::Document* doc = Gui::Application::Instance->activeDocument(); - // //if(doc) - // // doc->resetEdit(); - //param->MeshViewProvider->resetHighlightNodes(); + // FemSetNodesObject->execute(); + // //Gui::Document* doc = Gui::Application::Instance->activeDocument(); + // //if(doc) + // // doc->resetEdit(); + // param->MeshViewProvider->resetHighlightNodes(); Gui::Command::abortCommand(); Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); @@ -136,8 +138,6 @@ bool TaskDlgMeshShapeNetgen::reject() } void TaskDlgMeshShapeNetgen::helpRequested() -{ - -} +{} #include "moc_TaskDlgMeshShapeNetgen.cpp" diff --git a/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.h b/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.h index 792b4ee461..58be0b6211 100644 --- a/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.h +++ b/src/Mod/Fem/Gui/TaskDlgMeshShapeNetgen.h @@ -26,23 +26,25 @@ #include -namespace Fem { - class FemMeshShapeNetgenObject; +namespace Fem +{ +class FemMeshShapeNetgenObject; } -namespace FemGui { +namespace FemGui +{ class TaskTetParameter; class ViewProviderFemMeshShapeNetgen; /// simulation dialog for the TaskView -class TaskDlgMeshShapeNetgen : public Gui::TaskView::TaskDialog +class TaskDlgMeshShapeNetgen: public Gui::TaskView::TaskDialog { Q_OBJECT public: - explicit TaskDlgMeshShapeNetgen(FemGui::ViewProviderFemMeshShapeNetgen *); + explicit TaskDlgMeshShapeNetgen(FemGui::ViewProviderFemMeshShapeNetgen*); ~TaskDlgMeshShapeNetgen() override; public: @@ -59,17 +61,18 @@ public: /// returns for Close and Help button QDialogButtonBox::StandardButtons getStandardButtons() const override - { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Apply; } + { + return QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply; + } protected: - TaskTetParameter *param; + TaskTetParameter* param; - Fem::FemMeshShapeNetgenObject *FemMeshShapeNetgenObject; - FemGui::ViewProviderFemMeshShapeNetgen *ViewProviderFemMeshShapeNetgen; + Fem::FemMeshShapeNetgenObject* FemMeshShapeNetgenObject; + FemGui::ViewProviderFemMeshShapeNetgen* ViewProviderFemMeshShapeNetgen; }; +} // namespace FemGui -} //namespace FemGui - -#endif // FEMGUI_TaskDlgMeshShapeNetgen_H +#endif // FEMGUI_TaskDlgMeshShapeNetgen_H diff --git a/src/Mod/Fem/Gui/TaskDriver.cpp b/src/Mod/Fem/Gui/TaskDriver.cpp index eed9c8ef52..5b05e3c655 100644 --- a/src/Mod/Fem/Gui/TaskDriver.cpp +++ b/src/Mod/Fem/Gui/TaskDriver.cpp @@ -32,9 +32,9 @@ using namespace FemGui; using namespace Gui; TaskDriver::TaskDriver(Fem::FemAnalysis* pcObject, QWidget* parent) - : TaskBox(Gui::BitmapFactory().pixmap("FEM_CreateNodesSet"), tr("Nodes set"), true, parent), - pcObject(pcObject), - ui(new Ui_TaskDriver) + : TaskBox(Gui::BitmapFactory().pixmap("FEM_CreateNodesSet"), tr("Nodes set"), true, parent) + , pcObject(pcObject) + , ui(new Ui_TaskDriver) { // we need a separate container widget to add all controls to proxy = new QWidget(this); diff --git a/src/Mod/Fem/Gui/TaskDriver.h b/src/Mod/Fem/Gui/TaskDriver.h index 58fc8435ff..cdcb8e03ca 100644 --- a/src/Mod/Fem/Gui/TaskDriver.h +++ b/src/Mod/Fem/Gui/TaskDriver.h @@ -28,43 +28,47 @@ class Ui_TaskDriver; class SoEventCallback; -namespace Base { +namespace Base +{ class Polygon2d; } -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; class ViewVolumeProjection; -} +} // namespace Gui -namespace Fem{ - class FemAnalysis; +namespace Fem +{ +class FemAnalysis; } - -namespace FemGui { +namespace FemGui +{ -class TaskDriver : public Gui::TaskView::TaskBox +class TaskDriver: public Gui::TaskView::TaskBox { Q_OBJECT public: - explicit TaskDriver(Fem::FemAnalysis *pcObject,QWidget *parent = nullptr); + explicit TaskDriver(Fem::FemAnalysis* pcObject, QWidget* parent = nullptr); ~TaskDriver() override; protected: - Fem::FemAnalysis *pcObject; + Fem::FemAnalysis* pcObject; private: QWidget* proxy; std::unique_ptr ui; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEMGUI_TaskDriver_H +#endif // FEMGUI_TaskDriver_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.cpp b/src/Mod/Fem/Gui/TaskFemConstraint.cpp index fbc94b2445..9b1e3ddac3 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraint.cpp @@ -24,12 +24,12 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include // OvG conversion between string and int etc. +#include +#include +#include +#include +#include // OvG conversion between string and int etc. +#include #endif #include @@ -50,8 +50,13 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraint */ -TaskFemConstraint::TaskFemConstraint(ViewProviderFemConstraint *ConstraintView,QWidget *parent,const char* pixmapname) - : TaskBox(Gui::BitmapFactory().pixmap(pixmapname),tr("Analysis feature parameters"),true, parent) +TaskFemConstraint::TaskFemConstraint(ViewProviderFemConstraint* ConstraintView, + QWidget* parent, + const char* pixmapname) + : TaskBox(Gui::BitmapFactory().pixmap(pixmapname), + tr("Analysis feature parameters"), + true, + parent) , proxy(nullptr) , deleteAction(nullptr) , ConstraintView(ConstraintView) @@ -66,8 +71,9 @@ TaskFemConstraint::TaskFemConstraint(ViewProviderFemConstraint *ConstraintView,Q // Hide the shaft wizard table widget to make more space ConstraintView->wizardSubLayout->itemAt(0)->widget()->hide(); QGridLayout* buttons = ConstraintView->wizardSubLayout->findChild(); - for (int b = 0; b < buttons->count(); b++) + for (int b = 0; b < buttons->count(); b++) { buttons->itemAt(b)->widget()->hide(); + } // Show this dialog for the FEM constraint ConstraintView->wizardWidget->addWidget(this); @@ -79,18 +85,24 @@ TaskFemConstraint::TaskFemConstraint(ViewProviderFemConstraint *ConstraintView,Q buttonBox->addButton(okButton, QDialogButtonBox::AcceptRole); buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole); QObject::connect(okButton, &QPushButton::clicked, this, &TaskFemConstraint::onButtonWizOk); - QObject::connect(cancelButton, &QPushButton::clicked, this, &TaskFemConstraint::onButtonWizCancel); + QObject::connect(cancelButton, + &QPushButton::clicked, + this, + &TaskFemConstraint::onButtonWizCancel); ConstraintView->wizardWidget->addWidget(buttonBox); } } -void TaskFemConstraint::keyPressEvent(QKeyEvent *ke) +void TaskFemConstraint::keyPressEvent(QKeyEvent* ke) { - if ((ConstraintView->wizardWidget) && (ConstraintView->wizardSubLayout)) + if ((ConstraintView->wizardWidget) && (ConstraintView->wizardSubLayout)) { // Prevent from closing this dialog AND the shaft wizard dialog - // TODO: This should trigger an update in the shaft wizard but its difficult to access a python dialog from here... - if (ke->key() == Qt::Key_Return) + // TODO: This should trigger an update in the shaft wizard but its difficult to access a + // python dialog from here... + if (ke->key() == Qt::Key_Return) { return; + } + } TaskBox::keyPressEvent(ke); } @@ -101,14 +113,15 @@ const std::string TaskFemConstraint::getReferences(const std::vector::const_iterator i = items.begin(); i != items.end(); i++) { int pos = i->find_last_of(":"); std::string objStr = "App.ActiveDocument." + i->substr(0, pos); - std::string refStr = "\"" + i->substr(pos+1) + "\""; + std::string refStr = "\"" + i->substr(pos + 1) + "\""; result = result + (i != items.begin() ? ", " : "") + "(" + objStr + "," + refStr + ")"; } return result; } -const std::string TaskFemConstraint::getScale() const //OvG: Return pre-calculated scale for constraint display +const std::string +TaskFemConstraint::getScale() const // OvG: Return pre-calculated scale for constraint display { std::string result; Fem::Constraint* pcConstraint = static_cast(ConstraintView->getObject()); @@ -116,7 +129,8 @@ const std::string TaskFemConstraint::getScale() const //OvG: Return pre-calculat return result; } -void TaskFemConstraint::setSelection(QListWidgetItem* item) { +void TaskFemConstraint::setSelection(QListWidgetItem* item) +{ // highlights the list item in the model // get the document name @@ -136,7 +150,8 @@ void TaskFemConstraint::setSelection(QListWidgetItem* item) { Gui::Selection().addSelection(docName.c_str(), objName.c_str(), ItemName.c_str(), 0, 0, 0); } -void TaskFemConstraint::onReferenceDeleted(const int row) { +void TaskFemConstraint::onReferenceDeleted(const int row) +{ Fem::Constraint* pcConstraint = static_cast(ConstraintView->getObject()); std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); @@ -146,11 +161,14 @@ void TaskFemConstraint::onReferenceDeleted(const int row) { pcConstraint->References.setValues(Objects, SubElements); } -void TaskFemConstraint::onButtonReference(const bool pressed) { - if (pressed) +void TaskFemConstraint::onButtonReference(const bool pressed) +{ + if (pressed) { selectionMode = selref; - else + } + else { selectionMode = selnone; + } Gui::Selection().clearSelection(); } @@ -168,26 +186,31 @@ void TaskFemConstraint::onButtonWizOk() // Show the wizard shaft dialog again ConstraintView->wizardSubLayout->itemAt(0)->widget()->show(); QGridLayout* buttons = ConstraintView->wizardSubLayout->findChild(); - for (int b = 0; b < buttons->count(); b++) + for (int b = 0; b < buttons->count(); b++) { buttons->itemAt(b)->widget()->show(); + } - Gui::Application::Instance->activeDocument()->resetEdit(); // Reaches ViewProviderFemConstraint::unsetEdit() eventually + Gui::Application::Instance->activeDocument() + ->resetEdit(); // Reaches ViewProviderFemConstraint::unsetEdit() eventually } void TaskFemConstraint::onButtonWizCancel() { Fem::Constraint* pcConstraint = static_cast(ConstraintView->getObject()); - if (pcConstraint) + if (pcConstraint) { pcConstraint->getDocument()->removeObject(pcConstraint->getNameInDocument()); + } onButtonWizOk(); } -const QString TaskFemConstraint::makeRefText(const std::string& objName, const std::string& subName) const +const QString TaskFemConstraint::makeRefText(const std::string& objName, + const std::string& subName) const { return QString::fromUtf8((objName + ":" + subName).c_str()); } -const QString TaskFemConstraint::makeRefText(const App::DocumentObject* obj, const std::string& subName) const +const QString TaskFemConstraint::makeRefText(const App::DocumentObject* obj, + const std::string& subName) const { return QString::fromUtf8((std::string(obj->getNameInDocument()) + ":" + subName).c_str()); } @@ -206,11 +229,11 @@ void TaskFemConstraint::createDeleteAction(QListWidget* parentList) parentList->setContextMenuPolicy(Qt::ActionsContextMenu); } -bool TaskFemConstraint::KeyEvent(QEvent *e) +bool TaskFemConstraint::KeyEvent(QEvent* e) { // in case another instance takes key events, accept the overridden key even if (e && e->type() == QEvent::ShortcutOverride) { - QKeyEvent * kevent = static_cast(e); + QKeyEvent* kevent = static_cast(e); if (kevent->modifiers() == Qt::NoModifier) { if (deleteAction && kevent->key() == Qt::Key_Delete) { kevent->accept(); @@ -220,10 +243,11 @@ bool TaskFemConstraint::KeyEvent(QEvent *e) } // if we have a Del key, trigger the deleteAction else if (e && e->type() == QEvent::KeyPress) { - QKeyEvent * kevent = static_cast(e); + QKeyEvent* kevent = static_cast(e); if (kevent->key() == Qt::Key_Delete) { - if (deleteAction && deleteAction->isEnabled()) + if (deleteAction && deleteAction->isEnabled()) { deleteAction->trigger(); + } return true; } } @@ -241,7 +265,11 @@ bool TaskFemConstraint::KeyEvent(QEvent *e) void TaskDlgFemConstraint::open() { ConstraintView->setVisible(true); - Gui::Command::runCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts + Gui::Command::runCommand( + Gui::Command::Doc, + ViewProviderFemConstraint::gethideMeshShowPartStr( + (static_cast(ConstraintView->getObject()))->getNameInDocument()) + .c_str()); // OvG: Hide meshes and show parts } bool TaskDlgFemConstraint::accept() @@ -252,16 +280,23 @@ bool TaskDlgFemConstraint::accept() std::string refs = parameter->getReferences(); if (!refs.empty()) { - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.References = [%s]", name.c_str(), refs.c_str()); - } else { - QMessageBox::warning(parameter, tr("Input error"), tr("You must specify at least one reference")); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.References = [%s]", + name.c_str(), + refs.c_str()); + } + else { + QMessageBox::warning(parameter, + tr("Input error"), + tr("You must specify at least one reference")); return false; } - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - if (!ConstraintView->getObject()->isValid()) + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()"); + if (!ConstraintView->getObject()->isValid()) { throw Base::RuntimeError(ConstraintView->getObject()->getStatusString()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + } + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); Gui::Command::commitCommand(); } catch (const Base::Exception& e) { @@ -276,7 +311,7 @@ bool TaskDlgFemConstraint::reject() { // roll back the changes Gui::Command::abortCommand(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); return true; } diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.h b/src/Mod/Fem/Gui/TaskFemConstraint.h index a3e9064b82..cbe061647e 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.h +++ b/src/Mod/Fem/Gui/TaskFemConstraint.h @@ -37,17 +37,23 @@ class QAction; class QListWidget; class QListWidgetItem; -namespace FemGui { +namespace FemGui +{ -class TaskFemConstraint : public Gui::TaskView::TaskBox, public Gui::SelectionObserver +class TaskFemConstraint: public Gui::TaskView::TaskBox, public Gui::SelectionObserver { Q_OBJECT public: - explicit TaskFemConstraint(ViewProviderFemConstraint *ConstraintView,QWidget *parent = nullptr,const char* pixmapname = ""); + explicit TaskFemConstraint(ViewProviderFemConstraint* ConstraintView, + QWidget* parent = nullptr, + const char* pixmapname = ""); ~TaskFemConstraint() override = default; - virtual const std::string getReferences() const {return std::string();} + virtual const std::string getReferences() const + { + return std::string(); + } const std::string getReferences(const std::vector& items) const; const std::string getScale() const; @@ -60,34 +66,44 @@ protected Q_SLOTS: void onButtonWizCancel(); protected: - void changeEvent(QEvent *e) override { TaskBox::changeEvent(e); } + void changeEvent(QEvent* e) override + { + TaskBox::changeEvent(e); + } const QString makeRefText(const std::string& objName, const std::string& subName) const; const QString makeRefText(const App::DocumentObject* obj, const std::string& subName) const; - void keyPressEvent(QKeyEvent * ke) override; + void keyPressEvent(QKeyEvent* ke) override; void createDeleteAction(QListWidget* parentList); - bool KeyEvent(QEvent *e); - void onSelectionChanged(const Gui::SelectionChanges&) override {} + bool KeyEvent(QEvent* e); + void onSelectionChanged(const Gui::SelectionChanges&) override + {} protected: QWidget* proxy; QAction* deleteAction; Gui::WeakPtrT ConstraintView; - enum {seldir, selref, selloc, selnone} selectionMode; + enum + { + seldir, + selref, + selloc, + selnone + } selectionMode; private: - // This seems to be the only way to access the widgets again in order to remove them from the dialog + // This seems to be the only way to access the widgets again in order to remove them from the + // dialog QDialogButtonBox* buttonBox; QPushButton* okButton; QPushButton* cancelButton; }; /// simulation dialog for the TaskView -class TaskDlgFemConstraint : public Gui::TaskView::TaskDialog +class TaskDlgFemConstraint: public Gui::TaskView::TaskDialog { Q_OBJECT public: - /// is called the TaskView when the dialog is opened void open() override; /* @@ -99,20 +115,26 @@ public: /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; bool isAllowedAlterDocument() const override - { return false; } + { + return false; + } /// returns for Close and Help button QDialogButtonBox::StandardButtons getStandardButtons() const override - { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; } + { + return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; + } ViewProviderFemConstraint* getConstraintView() const - { return ConstraintView; } + { + return ConstraintView; + } protected: - ViewProviderFemConstraint *ConstraintView; - TaskFemConstraint *parameter; + ViewProviderFemConstraint* ConstraintView; + TaskFemConstraint* parameter; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraint_H +#endif // GUI_TASKVIEW_TaskFemConstraint_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp index 114f2e8c5d..deedc32b87 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp @@ -24,11 +24,11 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include #endif #include @@ -39,8 +39,8 @@ #include #include -#include "ui_TaskFemConstraintBearing.h" #include "TaskFemConstraintBearing.h" +#include "ui_TaskFemConstraintBearing.h" using namespace FemGui; @@ -49,9 +49,10 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintBearing */ TaskFemConstraintBearing::TaskFemConstraintBearing(ViewProviderFemConstraint* ConstraintView, - QWidget* parent, const char* pixmapname) - : TaskFemConstraint(ConstraintView, parent, pixmapname), - ui(new Ui_TaskFemConstraintBearing) + QWidget* parent, + const char* pixmapname) + : TaskFemConstraint(ConstraintView, parent, pixmapname) + , ui(new Ui_TaskFemConstraintBearing) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -86,28 +87,34 @@ TaskFemConstraintBearing::TaskFemConstraintBearing(ViewProviderFemConstraint* Co std::vector SubElements = pcConstraint->References.getSubValues(); std::vector locStrings = pcConstraint->Location.getSubValues(); QString loc; - if (!locStrings.empty()) + if (!locStrings.empty()) { loc = makeRefText(pcConstraint->Location.getValue(), locStrings.front()); + } bool axialfree = pcConstraint->AxialFree.getValue(); // Fill data into dialog elements ui->spinDistance->setValue(distance); ui->listReferences->clear(); - for (std::size_t i = 0; i < Objects.size(); i++) + for (std::size_t i = 0; i < Objects.size(); i++) { ui->listReferences->addItem(makeRefText(Objects[i], SubElements[i])); - if (!Objects.empty()) + } + if (!Objects.empty()) { ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); + } ui->lineLocation->setText(loc); ui->checkAxial->setChecked(axialfree); - connect(ui->spinDistance, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintBearing::onDistanceChanged); - connect(ui->buttonReference, &QPushButton::pressed, - this, [=]{onButtonReference(true);}); - connect(ui->buttonLocation, &QPushButton::pressed, - this, [=]{onButtonLocation(true);}); - connect(ui->checkAxial, &QCheckBox::toggled, - this, &TaskFemConstraintBearing::onCheckAxial); + connect(ui->spinDistance, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskFemConstraintBearing::onDistanceChanged); + connect(ui->buttonReference, &QPushButton::pressed, this, [=] { + onButtonReference(true); + }); + connect(ui->buttonLocation, &QPushButton::pressed, this, [=] { + onButtonLocation(true); + }); + connect(ui->checkAxial, &QCheckBox::toggled, this, &TaskFemConstraintBearing::onCheckAxial); // Hide unwanted ui elements ui->labelDiameter->setVisible(false); @@ -134,15 +141,18 @@ void TaskFemConstraintBearing::onSelectionChanged(const Gui::SelectionChanges& m { if (msg.Type == Gui::SelectionChanges::AddSelection) { // Don't allow selection in other document - if (strcmp(msg.pDocName, ConstraintView->getObject()->getDocument()->getName()) != 0) + if (strcmp(msg.pDocName, ConstraintView->getObject()->getDocument()->getName()) != 0) { return; + } - if (!msg.pSubName || msg.pSubName[0] == '\0') + if (!msg.pSubName || msg.pSubName[0] == '\0') { return; + } std::string subName(msg.pSubName); - if (selectionMode == selnone) + if (selectionMode == selnone) { return; + } Fem::ConstraintBearing* pcConstraint = static_cast(ConstraintView->getObject()); @@ -170,8 +180,9 @@ void TaskFemConstraintBearing::onSelectionChanged(const Gui::SelectionChanges& m // Only cylindrical faces allowed BRepAdaptor_Surface surface(TopoDS::Face(ref)); if (surface.GetType() != GeomAbs_Cylinder) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only cylindrical faces can be picked")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only cylindrical faces can be picked")); return; } @@ -187,21 +198,24 @@ void TaskFemConstraintBearing::onSelectionChanged(const Gui::SelectionChanges& m else if (selectionMode == selloc) { if (subName.substr(0, 4) == "Face") { if (!Fem::Tools::isPlanar(TopoDS::Face(ref))) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only planar faces can be picked")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only planar faces can be picked")); return; } } else if (subName.substr(0, 4) == "Edge") { if (!Fem::Tools::isLinear(TopoDS::Edge(ref))) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only linear edges can be picked")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only linear edges can be picked")); return; } } else { - QMessageBox::warning( - this, tr("Selection error"), tr("Only faces and edges can be picked")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only faces and edges can be picked")); return; } std::vector references(1, subName); @@ -223,17 +237,20 @@ void TaskFemConstraintBearing::onDistanceChanged(double l) pcConstraint->Dist.setValue(l); } -void TaskFemConstraintBearing::onReferenceDeleted() { +void TaskFemConstraintBearing::onReferenceDeleted() +{ int row = ui->listReferences->currentIndex().row(); TaskFemConstraint::onReferenceDeleted(row); ui->listReferences->model()->removeRow(row); ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); } -void TaskFemConstraintBearing::onButtonLocation(const bool pressed) { +void TaskFemConstraintBearing::onButtonLocation(const bool pressed) +{ if (pressed) { selectionMode = selloc; - } else { + } + else { selectionMode = selnone; } ui->buttonLocation->setChecked(pressed); @@ -257,16 +274,18 @@ const std::string TaskFemConstraintBearing::getReferences() const int rows = ui->listReferences->model()->rowCount(); std::vector items; - for (int r = 0; r < rows; r++) + for (int r = 0; r < rows; r++) { items.push_back(ui->listReferences->item(r)->text().toStdString()); + } return TaskFemConstraint::getReferences(items); } const std::string TaskFemConstraintBearing::getLocationName() const { std::string loc = ui->lineLocation->text().toStdString(); - if (loc.empty()) + if (loc.empty()) { return ""; + } int pos = loc.find_last_of(":"); return loc.substr(0, pos).c_str(); @@ -275,11 +294,12 @@ const std::string TaskFemConstraintBearing::getLocationName() const const std::string TaskFemConstraintBearing::getLocationObject() const { std::string loc = ui->lineLocation->text().toStdString(); - if (loc.empty()) + if (loc.empty()) { return ""; + } int pos = loc.find_last_of(":"); - return loc.substr(pos+1).c_str(); + return loc.substr(pos + 1).c_str(); } bool TaskFemConstraintBearing::getAxial() const @@ -289,12 +309,12 @@ bool TaskFemConstraintBearing::getAxial() const TaskFemConstraintBearing::~TaskFemConstraintBearing() = default; -bool TaskFemConstraintBearing::event(QEvent *e) +bool TaskFemConstraintBearing::event(QEvent* e) { return TaskFemConstraint::KeyEvent(e); } -void TaskFemConstraintBearing::changeEvent(QEvent *e) +void TaskFemConstraintBearing::changeEvent(QEvent* e) { TaskBox::changeEvent(e); if (e->type() == QEvent::LanguageChange) { @@ -347,8 +367,9 @@ bool TaskDlgFemConstraintBearing::accept() buf.toStdString().c_str()); } else { - Gui::Command::doCommand( - Gui::Command::Doc, "App.ActiveDocument.%s.Location = None", name.c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Location = None", + name.c_str()); } Gui::Command::doCommand(Gui::Command::Doc, diff --git a/src/Mod/Fem/Gui/TaskFemConstraintBearing.h b/src/Mod/Fem/Gui/TaskFemConstraintBearing.h index ffa0f9094b..61d6c65f69 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintBearing.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintBearing.h @@ -24,8 +24,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintBearing_H #define GUI_TASKVIEW_TaskFemConstraintBearing_H -#include #include +#include #include "TaskFemConstraint.h" #include "ViewProviderFemConstraintBearing.h" @@ -33,17 +33,20 @@ class Ui_TaskFemConstraintBearing; -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; } -namespace FemGui { +namespace FemGui +{ -class TaskFemConstraintBearing : public TaskFemConstraint +class TaskFemConstraintBearing: public TaskFemConstraint { Q_OBJECT @@ -66,8 +69,8 @@ private Q_SLOTS: void onCheckAxial(bool); protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void onSelectionChanged(const Gui::SelectionChanges& msg) override; protected: @@ -75,18 +78,18 @@ protected: }; /// simulation dialog for the TaskView -class TaskDlgFemConstraintBearing : public TaskDlgFemConstraint +class TaskDlgFemConstraintBearing: public TaskDlgFemConstraint { Q_OBJECT public: TaskDlgFemConstraintBearing() = default; - explicit TaskDlgFemConstraintBearing(ViewProviderFemConstraintBearing *ConstraintView); + explicit TaskDlgFemConstraintBearing(ViewProviderFemConstraintBearing* ConstraintView); /// is called by the framework if the dialog is accepted (Ok) bool accept() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintBearing_H +#endif // GUI_TASKVIEW_TaskFemConstraintBearing_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp b/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp index 13c4dd6842..cc15da6dbb 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp @@ -26,14 +26,14 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif +#include "Mod/Fem/App/FemConstraintContact.h" #include #include -#include "Mod/Fem/App/FemConstraintContact.h" #include #include "TaskFemConstraintContact.h" @@ -47,36 +47,44 @@ using namespace Gui; TaskFemConstraintContact::TaskFemConstraintContact(ViewProviderFemConstraintContact* ConstraintView, QWidget* parent) - : TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintContact"), - ui(new Ui_TaskFemConstraintContact) + : TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintContact") + , ui(new Ui_TaskFemConstraintContact) { proxy = new QWidget(this); ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); QAction* actionSlave = new QAction(tr("Delete"), ui->lw_referencesSlave); - connect(actionSlave, &QAction::triggered, - this, &TaskFemConstraintContact::onReferenceDeletedSlave); + connect(actionSlave, + &QAction::triggered, + this, + &TaskFemConstraintContact::onReferenceDeletedSlave); QAction* actionMaster = new QAction(tr("Delete"), ui->lw_referencesMaster); - connect(actionMaster, &QAction::triggered, - this, &TaskFemConstraintContact::onReferenceDeletedMaster); + connect(actionMaster, + &QAction::triggered, + this, + &TaskFemConstraintContact::onReferenceDeletedMaster); ui->lw_referencesSlave->addAction(actionSlave); ui->lw_referencesSlave->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(ui->lw_referencesSlave, &QListWidget::currentItemChanged, - this, &TaskFemConstraintContact::setSelection); + connect(ui->lw_referencesSlave, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintContact::setSelection); ui->lw_referencesMaster->addAction(actionMaster); ui->lw_referencesMaster->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(ui->lw_referencesMaster, &QListWidget::currentItemChanged, - this, &TaskFemConstraintContact::setSelection); + connect(ui->lw_referencesMaster, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintContact::setSelection); this->groupLayout()->addWidget(proxy); -/* Note: */ + /* Note: */ // Get the feature data Fem::ConstraintContact* pcConstraint = static_cast(ConstraintView->getObject()); @@ -91,33 +99,42 @@ TaskFemConstraintContact::TaskFemConstraintContact(ViewProviderFemConstraintCont ui->spSlope->setValue(slope); ui->spFriction->setValue(friction); -/* */ + /* */ ui->lw_referencesMaster->clear(); ui->lw_referencesSlave->clear(); // QMessageBox::warning(this, tr("Objects.size"), QString::number(Objects.size())); if (Objects.size() == 1) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only one face in object! - moved to master face")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only one face in object! - moved to master face")); ui->lw_referencesMaster->addItem(makeRefText(Objects[0], SubElements[0])); } - if (Objects.size() == 2 ) { + if (Objects.size() == 2) { ui->lw_referencesMaster->addItem(makeRefText(Objects[1], SubElements[1])); ui->lw_referencesSlave->addItem(makeRefText(Objects[0], SubElements[0])); } // Selection buttons - connect(ui->btnAddSlave, &QToolButton::clicked, - this, &TaskFemConstraintContact::addToSelectionSlave); - connect(ui->btnRemoveSlave, &QToolButton::clicked, - this, &TaskFemConstraintContact::removeFromSelectionSlave); + connect(ui->btnAddSlave, + &QToolButton::clicked, + this, + &TaskFemConstraintContact::addToSelectionSlave); + connect(ui->btnRemoveSlave, + &QToolButton::clicked, + this, + &TaskFemConstraintContact::removeFromSelectionSlave); - connect(ui->btnAddMaster, &QToolButton::clicked, - this, &TaskFemConstraintContact::addToSelectionMaster); - connect(ui->btnRemoveMaster, &QToolButton::clicked, - this, &TaskFemConstraintContact::removeFromSelectionMaster); + connect(ui->btnAddMaster, + &QToolButton::clicked, + this, + &TaskFemConstraintContact::addToSelectionMaster); + connect(ui->btnRemoveMaster, + &QToolButton::clicked, + this, + &TaskFemConstraintContact::removeFromSelectionMaster); updateUI(); } @@ -141,7 +158,8 @@ void TaskFemConstraintContact::updateUI() void TaskFemConstraintContact::addToSelectionSlave() { int rows = ui->lw_referencesSlave->model()->rowCount(); - std::vector selection = Gui::Selection().getSelectionEx();//gets vector of selected objects of active document + std::vector selection = + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (rows == 1) { QMessageBox::warning( this, @@ -150,13 +168,14 @@ void TaskFemConstraintContact::addToSelectionSlave() Gui::Selection().clearSelection(); return; } - if (selection.empty()){ + if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; } if ((rows == 0) && (selection.size() >= 2)) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only one slave face for a contact constraint!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only one slave face for a contact constraint!")); Gui::Selection().clearSelection(); return; } @@ -165,7 +184,7 @@ void TaskFemConstraintContact::addToSelectionSlave() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -174,12 +193,13 @@ void TaskFemConstraintContact::addToSelectionSlave() App::DocumentObject* obj = it.getObject(); if (subNames.size() != 1) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only one slave face for a contact constraint!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only one slave face for a contact constraint!")); Gui::Selection().clearSelection(); return; } - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); @@ -190,13 +210,13 @@ void TaskFemConstraintContact::addToSelectionSlave() itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } @@ -226,7 +246,7 @@ void TaskFemConstraintContact::removeFromSelectionSlave() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -234,19 +254,19 @@ void TaskFemConstraintContact::removeFromSelectionSlave() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -271,7 +291,7 @@ void TaskFemConstraintContact::addToSelectionMaster() { int rows = ui->lw_referencesMaster->model()->rowCount(); std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (rows == 1) { QMessageBox::warning( this, @@ -285,8 +305,9 @@ void TaskFemConstraintContact::addToSelectionMaster() return; } if ((rows == 0) && (selection.size() >= 2)) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only one master for a contact constraint!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only one master for a contact constraint!")); Gui::Selection().clearSelection(); return; } @@ -295,7 +316,7 @@ void TaskFemConstraintContact::addToSelectionMaster() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -303,12 +324,13 @@ void TaskFemConstraintContact::addToSelectionMaster() const std::vector& subNames = it.getSubNames(); App::DocumentObject* obj = it.getObject(); if (subNames.size() != 1) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only one master face for a contact constraint!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only one master face for a contact constraint!")); Gui::Selection().clearSelection(); return; } - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); @@ -319,13 +341,13 @@ void TaskFemConstraintContact::addToSelectionMaster() itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } @@ -345,7 +367,7 @@ void TaskFemConstraintContact::addToSelectionMaster() void TaskFemConstraintContact::removeFromSelectionMaster() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -355,7 +377,7 @@ void TaskFemConstraintContact::removeFromSelectionMaster() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -363,19 +385,19 @@ void TaskFemConstraintContact::removeFromSelectionMaster() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -396,11 +418,13 @@ void TaskFemConstraintContact::removeFromSelectionMaster() updateUI(); } -void TaskFemConstraintContact::onReferenceDeletedSlave() { +void TaskFemConstraintContact::onReferenceDeletedSlave() +{ TaskFemConstraintContact::removeFromSelectionSlave(); } -void TaskFemConstraintContact::onReferenceDeletedMaster() { +void TaskFemConstraintContact::onReferenceDeletedMaster() +{ TaskFemConstraintContact::removeFromSelectionMaster(); } @@ -430,9 +454,8 @@ double TaskFemConstraintContact::get_Friction() const return ui->spFriction->value(); } -void TaskFemConstraintContact::changeEvent(QEvent *) -{ -} +void TaskFemConstraintContact::changeEvent(QEvent*) +{} //************************************************************************** // TaskDialog @@ -461,7 +484,7 @@ void TaskDlgFemConstraintContact::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -481,11 +504,11 @@ bool TaskDlgFemConstraintContact::accept() "App.ActiveDocument.%s.Friction = %f", name.c_str(), parameterContact->get_Friction()); - std::string scale = parameterContact->getScale();// OvG: determine modified scale + std::string scale = parameterContact->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); @@ -498,7 +521,7 @@ bool TaskDlgFemConstraintContact::accept() bool TaskDlgFemConstraintContact::reject() { Gui::Command::abortCommand(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); Gui::Command::updateActive(); return true; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintContact.h b/src/Mod/Fem/Gui/TaskFemConstraintContact.h index 96319c4e46..cc7891a667 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintContact.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintContact.h @@ -26,8 +26,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintContact_H #define GUI_TASKVIEW_TaskFemConstraintContact_H -#include #include +#include #include "TaskFemConstraint.h" #include "ViewProviderFemConstraintContact.h" @@ -35,8 +35,9 @@ class Ui_TaskFemConstraintContact; -namespace FemGui { -class TaskFemConstraintContact : public TaskFemConstraint +namespace FemGui +{ +class TaskFemConstraintContact: public TaskFemConstraint { Q_OBJECT @@ -45,8 +46,8 @@ public: QWidget* parent = nullptr); ~TaskFemConstraintContact() override; const std::string getReferences() const override; - double get_Slope()const; - double get_Friction()const; + double get_Slope() const; + double get_Friction() const; private Q_SLOTS: void onReferenceDeletedSlave(); @@ -57,25 +58,25 @@ private Q_SLOTS: void removeFromSelectionMaster(); protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: - //void onSelectionChanged(const Gui::SelectionChanges& msg); + // void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(); std::unique_ptr ui; }; -class TaskDlgFemConstraintContact : public TaskDlgFemConstraint +class TaskDlgFemConstraintContact: public TaskDlgFemConstraint { Q_OBJECT public: - explicit TaskDlgFemConstraintContact(ViewProviderFemConstraintContact *ConstraintView); + explicit TaskDlgFemConstraintContact(ViewProviderFemConstraintContact* ConstraintView); void open() override; bool accept() override; bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintContact_H +#endif // GUI_TASKVIEW_TaskFemConstraintContact_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp index eb636db99f..7dc9a18368 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp @@ -26,9 +26,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif #include @@ -45,9 +45,10 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintDisplacement */ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement( - ViewProviderFemConstraintDisplacement* ConstraintView, QWidget* parent) - : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintDisplacement"), - ui(new Ui_TaskFemConstraintDisplacement) + ViewProviderFemConstraintDisplacement* ConstraintView, + QWidget* parent) + : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintDisplacement") + , ui(new Ui_TaskFemConstraintDisplacement) { proxy = new QWidget(this); ui->setupUi(proxy); @@ -55,13 +56,19 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement( // create a context menu for the listview of the references createDeleteAction(ui->lw_references); - connect(deleteAction, &QAction::triggered, - this, &TaskFemConstraintDisplacement::onReferenceDeleted); + connect(deleteAction, + &QAction::triggered, + this, + &TaskFemConstraintDisplacement::onReferenceDeleted); - connect(ui->lw_references, &QListWidget::currentItemChanged, - this, &TaskFemConstraintDisplacement::setSelection); - connect(ui->lw_references, &QListWidget::itemClicked, - this, &TaskFemConstraintDisplacement::setSelection); + connect(ui->lw_references, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintDisplacement::setSelection); + connect(ui->lw_references, + &QListWidget::itemClicked, + this, + &TaskFemConstraintDisplacement::setSelection); this->groupLayout()->addWidget(proxy); @@ -124,16 +131,21 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement( // Connect check box values displacements connect(ui->dispxfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::fixx); - connect(ui->DisplacementXFormulaCB, &QCheckBox::toggled, - this, &TaskFemConstraintDisplacement::formulaX); + connect(ui->DisplacementXFormulaCB, + &QCheckBox::toggled, + this, + &TaskFemConstraintDisplacement::formulaX); connect(ui->dispyfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::fixy); - connect(ui->DisplacementYFormulaCB, &QCheckBox::toggled, - this, &TaskFemConstraintDisplacement::formulaY); + connect(ui->DisplacementYFormulaCB, + &QCheckBox::toggled, + this, + &TaskFemConstraintDisplacement::formulaY); connect(ui->dispzfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::fixz); - connect(ui->DisplacementZFormulaCB, &QCheckBox::toggled, - this, &TaskFemConstraintDisplacement::formulaZ); - connect(ui->FlowForceCB, &QCheckBox::toggled, - this, &TaskFemConstraintDisplacement::flowForce); + connect(ui->DisplacementZFormulaCB, + &QCheckBox::toggled, + this, + &TaskFemConstraintDisplacement::formulaZ); + connect(ui->FlowForceCB, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::flowForce); // Connect to check box values for rotations connect(ui->rotxfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::rotfixx); connect(ui->rotyfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::rotfixy); @@ -257,8 +269,9 @@ void TaskFemConstraintDisplacement::flowForce(bool state) void TaskFemConstraintDisplacement::rotfixx(bool state) { - if (state) + if (state) { ui->spinxRotation->setValue(0); + } ui->spinxRotation->setEnabled(!state); } @@ -270,8 +283,9 @@ void TaskFemConstraintDisplacement::formulaRotx(bool state) void TaskFemConstraintDisplacement::rotfixy(bool state) { - if (state) + if (state) { ui->spinyRotation->setValue(0); + } ui->spinyRotation->setEnabled(!state); } @@ -283,8 +297,9 @@ void TaskFemConstraintDisplacement::formulaRoty(bool state) void TaskFemConstraintDisplacement::rotfixz(bool state) { - if (state) + if (state) { ui->spinzRotation->setValue(0); + } ui->spinzRotation->setEnabled(!state); } @@ -297,7 +312,7 @@ void TaskFemConstraintDisplacement::formulaRotz(bool state) void TaskFemConstraintDisplacement::addToSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -307,43 +322,46 @@ void TaskFemConstraintDisplacement::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } const std::vector& subNames = it.getSubNames(); App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } // limit constraint such that only vertexes or faces or edges can be used depending on // what was selected first std::string searchStr; - if (subName.find("Vertex") != std::string::npos) + if (subName.find("Vertex") != std::string::npos) { searchStr = "Vertex"; - else if (subName.find("Edge") != std::string::npos) + } + else if (subName.find("Edge") != std::string::npos) { searchStr = "Edge"; - else + } + else { searchStr = "Face"; - for (const auto & SubElement : SubElements) { + } + for (const auto& SubElement : SubElements) { if (SubElement.find(searchStr) == std::string::npos) { - QString msg = tr( - "Only one type of selection (vertex,face or edge) per analysis feature allowed!"); + QString msg = tr("Only one type of selection (vertex,face or edge) per " + "analysis feature allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); addMe = false; break; @@ -365,7 +383,7 @@ void TaskFemConstraintDisplacement::addToSelection() void TaskFemConstraintDisplacement::removeFromSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -375,7 +393,7 @@ void TaskFemConstraintDisplacement::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -383,19 +401,19 @@ void TaskFemConstraintDisplacement::removeFromSelection() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -421,8 +439,8 @@ void TaskFemConstraintDisplacement::removeFromSelection() void TaskFemConstraintDisplacement::onReferenceDeleted() { - TaskFemConstraintDisplacement::removeFromSelection();// OvG: On right-click face is - // automatically selected, so just remove + TaskFemConstraintDisplacement::removeFromSelection(); // OvG: On right-click face is + // automatically selected, so just remove } const std::string TaskFemConstraintDisplacement::getReferences() const @@ -583,10 +601,12 @@ void TaskFemConstraintDisplacement::changeEvent(QEvent*) void TaskFemConstraintDisplacement::clearButtons(const SelectionChangeModes notThis) { - if (notThis != SelectionChangeModes::refAdd) + if (notThis != SelectionChangeModes::refAdd) { ui->btnAdd->setChecked(false); - if (notThis != SelectionChangeModes::refRemove) + } + if (notThis != SelectionChangeModes::refRemove) { ui->btnRemove->setChecked(false); + } } //************************************************************************** @@ -616,7 +636,7 @@ void TaskDlgFemConstraintDisplacement::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -627,74 +647,100 @@ bool TaskDlgFemConstraintDisplacement::accept() static_cast(parameter); try { - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xDisplacement = \"%s\"", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.xDisplacement = \"%s\"", name.c_str(), parameterDisplacement->get_spinxDisplacement().c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xDisplacementFormula = \"%s\"", - name.c_str(), parameterDisplacement->get_xFormula().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yDisplacement = \"%s\"", + name.c_str(), + parameterDisplacement->get_xFormula().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.yDisplacement = \"%s\"", name.c_str(), parameterDisplacement->get_spinyDisplacement().c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yDisplacementFormula = \"%s\"", - name.c_str(), parameterDisplacement->get_yFormula().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zDisplacement = \"%s\"", + name.c_str(), + parameterDisplacement->get_yFormula().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.zDisplacement = \"%s\"", name.c_str(), parameterDisplacement->get_spinzDisplacement().c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zDisplacementFormula = \"%s\"", - name.c_str(), parameterDisplacement->get_zFormula().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xRotation = \"%s\"", - name.c_str(), parameterDisplacement->get_spinxRotation().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yRotation = \"%s\"", - name.c_str(), parameterDisplacement->get_spinyRotation().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zRotation = \"%s\"", + name.c_str(), + parameterDisplacement->get_zFormula().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.xRotation = \"%s\"", + name.c_str(), + parameterDisplacement->get_spinxRotation().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.yRotation = \"%s\"", + name.c_str(), + parameterDisplacement->get_spinyRotation().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.zRotation = \"%s\"", name.c_str(), parameterDisplacement->get_spinzRotation().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.xFree = %s", name.c_str(), parameterDisplacement->get_dispxfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.xFix = %s", name.c_str(), parameterDisplacement->get_dispxfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.hasXFormula = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.hasXFormula = %s", name.c_str(), parameterDisplacement->get_hasDispXFormula() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.yFree = %s", name.c_str(), parameterDisplacement->get_dispyfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.yFix = %s", name.c_str(), parameterDisplacement->get_dispyfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.hasYFormula = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.hasYFormula = %s", name.c_str(), parameterDisplacement->get_hasDispYFormula() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.zFree = %s", name.c_str(), parameterDisplacement->get_dispzfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.zFix = %s", name.c_str(), parameterDisplacement->get_dispzfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.hasZFormula = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.hasZFormula = %s", name.c_str(), parameterDisplacement->get_hasDispZFormula() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotxFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.rotxFree = %s", name.c_str(), parameterDisplacement->get_rotxfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotxFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.rotxFix = %s", name.c_str(), parameterDisplacement->get_rotxfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotyFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.rotyFree = %s", name.c_str(), parameterDisplacement->get_rotyfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotyFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.rotyFix = %s", name.c_str(), parameterDisplacement->get_rotyfix() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotzFree = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.rotzFree = %s", name.c_str(), parameterDisplacement->get_rotzfree() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotzFix = %s", + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.rotzFix = %s", name.c_str(), parameterDisplacement->get_rotzfix() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, @@ -703,11 +749,11 @@ bool TaskDlgFemConstraintDisplacement::accept() parameterDisplacement->get_useFlowSurfaceForce() ? "True" : "False"); - std::string scale = parameterDisplacement->getScale();// OvG: determine modified scale + std::string scale = parameterDisplacement->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h index e62b123c2e..d5b07a09cc 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h @@ -26,8 +26,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintDisplacement_H #define GUI_TASKVIEW_TaskFemConstraintDisplacement_H -#include #include +#include #include #include @@ -39,8 +39,9 @@ class Ui_TaskFemConstraintDisplacement; -namespace FemGui { -class TaskFemConstraintDisplacement : public TaskFemConstraintOnBoundary +namespace FemGui +{ +class TaskFemConstraintDisplacement: public TaskFemConstraintOnBoundary { Q_OBJECT @@ -96,8 +97,8 @@ private Q_SLOTS: void removeFromSelection() override; protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void clearButtons(const SelectionChangeModes notThis) override; private: @@ -105,7 +106,7 @@ private: std::unique_ptr ui; }; -class TaskDlgFemConstraintDisplacement : public TaskDlgFemConstraint +class TaskDlgFemConstraintDisplacement: public TaskDlgFemConstraint { Q_OBJECT @@ -117,6 +118,6 @@ public: bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintDisplacement_H +#endif // GUI_TASKVIEW_TaskFemConstraintDisplacement_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp index 30d2466248..76c0bb1f76 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp @@ -24,9 +24,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif #include @@ -45,21 +45,24 @@ using namespace Gui; TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed* ConstraintView, QWidget* parent) - : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFixed"), - ui(new Ui_TaskFemConstraintFixed) -{ //Note change "Fixed" in line above to new constraint name + : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFixed") + , ui(new Ui_TaskFemConstraintFixed) +{ // Note change "Fixed" in line above to new constraint name proxy = new QWidget(this); ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); // create a context menu for the listview of the references createDeleteAction(ui->lw_references); - connect(deleteAction, &QAction::triggered, - this, &TaskFemConstraintFixed::onReferenceDeleted); - connect(ui->lw_references, &QListWidget::currentItemChanged, - this, &TaskFemConstraintFixed::setSelection); - connect(ui->lw_references, &QListWidget::itemClicked, - this, &TaskFemConstraintFixed::setSelection); + connect(deleteAction, &QAction::triggered, this, &TaskFemConstraintFixed::onReferenceDeleted); + connect(ui->lw_references, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintFixed::setSelection); + connect(ui->lw_references, + &QListWidget::itemClicked, + this, + &TaskFemConstraintFixed::setSelection); this->groupLayout()->addWidget(proxy); @@ -81,7 +84,7 @@ TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed* C ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); } - //Selection buttons + // Selection buttons buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd); buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove); @@ -112,7 +115,7 @@ void TaskFemConstraintFixed::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -120,36 +123,39 @@ void TaskFemConstraintFixed::addToSelection() std::vector subNames = it.getSubNames(); App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it.getFeatName()); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } // limit constraint such that only vertexes or faces or edges can be used depending // on what was selected first std::string searchStr; - if (subName.find("Vertex") != std::string::npos) + if (subName.find("Vertex") != std::string::npos) { searchStr = "Vertex"; - else if (subName.find("Edge") != std::string::npos) + } + else if (subName.find("Edge") != std::string::npos) { searchStr = "Edge"; - else + } + else { searchStr = "Face"; - for (const auto & SubElement : SubElements) { + } + for (const auto& SubElement : SubElements) { if (SubElement.find(searchStr) == std::string::npos) { - QString msg = tr( - "Only one type of selection (vertex, face or edge) per analysis feature allowed!"); + QString msg = tr("Only one type of selection (vertex, face or edge) per " + "analysis feature allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); addMe = false; break; @@ -181,7 +187,7 @@ void TaskFemConstraintFixed::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -189,19 +195,19 @@ void TaskFemConstraintFixed::removeFromSelection() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -213,7 +219,7 @@ void TaskFemConstraintFixed::removeFromSelection() SubElements.erase(SubElements.begin() + itemsToDel.back()); itemsToDel.pop_back(); } - //Update UI + // Update UI { QSignalBlocker block(ui->lw_references); ui->lw_references->clear(); @@ -225,7 +231,8 @@ void TaskFemConstraintFixed::removeFromSelection() updateUI(); } -void TaskFemConstraintFixed::onReferenceDeleted() { +void TaskFemConstraintFixed::onReferenceDeleted() +{ TaskFemConstraintFixed::removeFromSelection(); } @@ -245,15 +252,16 @@ bool TaskFemConstraintFixed::event(QEvent* e) } void TaskFemConstraintFixed::changeEvent(QEvent*) -{ -} +{} void TaskFemConstraintFixed::clearButtons(const SelectionChangeModes notThis) { - if (notThis != SelectionChangeModes::refAdd) + if (notThis != SelectionChangeModes::refAdd) { ui->btnAdd->setChecked(false); - if (notThis != SelectionChangeModes::refRemove) + } + if (notThis != SelectionChangeModes::refRemove) { ui->btnRemove->setChecked(false); + } } //************************************************************************** @@ -282,7 +290,7 @@ void TaskDlgFemConstraintFixed::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -291,11 +299,11 @@ bool TaskDlgFemConstraintFixed::accept() std::string name = ConstraintView->getObject()->getNameInDocument(); const TaskFemConstraintFixed* parameters = static_cast(parameter); - std::string scale = parameters->getScale(); //OvG: determine modified scale + std::string scale = parameters->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale return TaskDlgFemConstraint::accept(); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFixed.h b/src/Mod/Fem/Gui/TaskFemConstraintFixed.h index 8bc939b842..80b939e0c5 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFixed.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintFixed.h @@ -24,8 +24,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintFixed_H #define GUI_TASKVIEW_TaskFemConstraintFixed_H -#include #include +#include #include "TaskFemConstraintOnBoundary.h" #include "ViewProviderFemConstraintFixed.h" @@ -33,8 +33,9 @@ class Ui_TaskFemConstraintFixed; -namespace FemGui { -class TaskFemConstraintFixed : public TaskFemConstraintOnBoundary +namespace FemGui +{ +class TaskFemConstraintFixed: public TaskFemConstraintOnBoundary { Q_OBJECT @@ -50,8 +51,8 @@ private Q_SLOTS: void removeFromSelection() override; protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void clearButtons(const SelectionChangeModes notThis) override; private: @@ -59,17 +60,17 @@ private: std::unique_ptr ui; }; -class TaskDlgFemConstraintFixed : public TaskDlgFemConstraint +class TaskDlgFemConstraintFixed: public TaskDlgFemConstraint { Q_OBJECT public: - explicit TaskDlgFemConstraintFixed(ViewProviderFemConstraintFixed *ConstraintView); + explicit TaskDlgFemConstraintFixed(ViewProviderFemConstraintFixed* ConstraintView); void open() override; bool accept() override; bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintFixed_H +#endif // GUI_TASKVIEW_TaskFemConstraintFixed_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp index fe8b0c1703..8caed56810 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp @@ -25,11 +25,11 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include #endif #include @@ -39,15 +39,15 @@ #include #include #include -#include #include +#include #include #include #include +#include "ActiveAnalysisObserver.h" #include "TaskFemConstraintFluidBoundary.h" #include "ui_TaskFemConstraintFluidBoundary.h" -#include "ActiveAnalysisObserver.h" using namespace FemGui; @@ -57,18 +57,18 @@ using namespace Fem; // also defined in FemConstrainFluidBoundary and foamcasebuilder/basicbuilder.py, please update // simultaneously the second (index 1) is the default enum, as index 0 causes compiling error static // const char* BoundaryTypes[] = {"inlet","wall","outlet","freestream", "interface", NULL}; -static const char* WallSubtypes[] = { - "unspecific", "fixed", "slip", "partialSlip", "moving", "rough", nullptr}; +static const char* WallSubtypes[] = + {"unspecific", "fixed", "slip", "partialSlip", "moving", "rough", nullptr}; static const char* InletSubtypes[] = {"unspecific", "totalPressure", "uniformVelocity", "volumetricFlowRate", "massFlowRate", nullptr}; -static const char* OutletSubtypes[] = { - "unspecific", "totalPressure", "staticPressure", "uniformVelocity", "outFlow", nullptr}; -static const char* InterfaceSubtypes[] = { - "unspecific", "symmetry", "wedge", "cyclic", "empty", "coupled", nullptr}; +static const char* OutletSubtypes[] = + {"unspecific", "totalPressure", "staticPressure", "uniformVelocity", "outFlow", nullptr}; +static const char* InterfaceSubtypes[] = + {"unspecific", "symmetry", "wedge", "cyclic", "empty", "coupled", nullptr}; static const char* FreestreamSubtypes[] = {"unspecific", "freestream", nullptr}; static const char* InterfaceSubtypeHelpTexts[] = { @@ -105,17 +105,19 @@ static const char* ThermalBoundaryHelpTexts[] = {"fixed Temperature [K]", // enable & disable quantityUI once valueType is selected // internal function not declared in header file -void initComboBox(QComboBox* combo, const std::vector& textItems, +void initComboBox(QComboBox* combo, + const std::vector& textItems, const std::string& sItem) { combo->blockSignals(true); - int iItem = 1;// the first one is "unspecific" (index 0) + int iItem = 1; // the first one is "unspecific" (index 0) combo->clear(); for (unsigned int it = 0; it < textItems.size(); it++) { combo->insertItem(it, Base::Tools::fromStdString(textItems[it])); - if (sItem == textItems[it]) + if (sItem == textItems[it]) { iItem = it; + } } combo->setCurrentIndex(iItem); combo->blockSignals(false); @@ -123,10 +125,11 @@ void initComboBox(QComboBox* combo, const std::vector& textItems, /* TRANSLATOR FemGui::TaskFemConstraintFluidBoundary */ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( - ViewProviderFemConstraintFluidBoundary* ConstraintView, QWidget* parent) - : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFluidBoundary"), - ui(new Ui_TaskFemConstraintFluidBoundary), - dimension(-1) + ViewProviderFemConstraintFluidBoundary* ConstraintView, + QWidget* parent) + : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFluidBoundary") + , ui(new Ui_TaskFemConstraintFluidBoundary) + , dimension(-1) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -135,8 +138,10 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( // create a context menu for the listview of the references createDeleteAction(ui->listReferences); - connect(deleteAction, &QAction::triggered, - this, &TaskFemConstraintFluidBoundary::onReferenceDeleted); + connect(deleteAction, + &QAction::triggered, + this, + &TaskFemConstraintFluidBoundary::onReferenceDeleted); // setup ranges ui->spinBoundaryValue->setMinimum(-FLOAT_MAX); @@ -152,25 +157,40 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( ui->spinHTCoeffValue->setMinimum(0.0); ui->spinHTCoeffValue->setMaximum(FLOAT_MAX); - connect(ui->comboBoundaryType, qOverload(&QComboBox::currentIndexChanged), - this, &TaskFemConstraintFluidBoundary::onBoundaryTypeChanged); - connect(ui->comboSubtype, qOverload(&QComboBox::currentIndexChanged), - this, &TaskFemConstraintFluidBoundary::onSubtypeChanged); - connect(ui->spinBoundaryValue, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintFluidBoundary::onBoundaryValueChanged); + connect(ui->comboBoundaryType, + qOverload(&QComboBox::currentIndexChanged), + this, + &TaskFemConstraintFluidBoundary::onBoundaryTypeChanged); + connect(ui->comboSubtype, + qOverload(&QComboBox::currentIndexChanged), + this, + &TaskFemConstraintFluidBoundary::onSubtypeChanged); + connect(ui->spinBoundaryValue, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskFemConstraintFluidBoundary::onBoundaryValueChanged); - connect(ui->comboTurbulenceSpecification, qOverload(&QComboBox::currentIndexChanged), - this, &TaskFemConstraintFluidBoundary::onTurbulenceSpecificationChanged); - connect(ui->comboThermalBoundaryType, qOverload(&QComboBox::currentIndexChanged), - this, &TaskFemConstraintFluidBoundary::onThermalBoundaryTypeChanged); + connect(ui->comboTurbulenceSpecification, + qOverload(&QComboBox::currentIndexChanged), + this, + &TaskFemConstraintFluidBoundary::onTurbulenceSpecificationChanged); + connect(ui->comboThermalBoundaryType, + qOverload(&QComboBox::currentIndexChanged), + this, + &TaskFemConstraintFluidBoundary::onThermalBoundaryTypeChanged); - connect(ui->buttonDirection, &QPushButton::pressed, - this, [=]{onButtonDirection(true);}); - connect(ui->checkReverse, &QCheckBox::toggled, - this, &TaskFemConstraintFluidBoundary::onCheckReverse); + connect(ui->buttonDirection, &QPushButton::pressed, this, [=] { + onButtonDirection(true); + }); + connect(ui->checkReverse, + &QCheckBox::toggled, + this, + &TaskFemConstraintFluidBoundary::onCheckReverse); - connect(ui->listReferences, &QListWidget::itemClicked, - this, &TaskFemConstraintFluidBoundary::setSelection); + connect(ui->listReferences, + &QListWidget::itemClicked, + this, + &TaskFemConstraintFluidBoundary::setSelection); this->groupLayout()->addWidget(proxy); @@ -181,7 +201,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( ui->buttonDirection->blockSignals(true); ui->checkReverse->blockSignals(true); - //Selection buttons + // Selection buttons buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd); buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove); @@ -198,7 +218,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( std::vector fem = aDoc->getObjectsOfType(Fem::FemAnalysis::getClassTypeId()); if (!fem.empty()) { - pcAnalysis = static_cast(fem[0]);// get the first + pcAnalysis = static_cast(fem[0]); // get the first } } @@ -206,34 +226,39 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( if (pcAnalysis) { std::vector fem = pcAnalysis->Group.getValues(); for (auto it : fem) { - if (it->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) + if (it->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) { pcMesh = static_cast(it); + } } } else { Base::Console().Log("FemAnalysis object is not activated or no FemAnalysis in the active " "document, mesh dimension is unknown\n"); - dimension = -1;// unknown dimension of mesh + dimension = -1; // unknown dimension of mesh } if (pcMesh) { - App::Property* prop = pcMesh->getPropertyByName("Shape");// PropertyLink + App::Property* prop = pcMesh->getPropertyByName("Shape"); // PropertyLink if (prop && prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) { App::PropertyLink* pcLink = static_cast(prop); Part::Feature* pcPart = dynamic_cast(pcLink->getValue()); - if (pcPart) {// deduct dimension from part_obj.Shape.ShapeType + if (pcPart) { // deduct dimension from part_obj.Shape.ShapeType const TopoDS_Shape& pShape = pcPart->Shape.getShape().getShape(); const TopAbs_ShapeEnum shapeType = pShape.IsNull() ? TopAbs_SHAPE : pShape.ShapeType(); if (shapeType == TopAbs_SOLID - || shapeType == TopAbs_COMPSOLID)// COMPSOLID is solids connected by faces + || shapeType == TopAbs_COMPSOLID) { // COMPSOLID is solids connected by faces dimension = 3; - else if (shapeType == TopAbs_FACE || shapeType == TopAbs_SHELL) + } + else if (shapeType == TopAbs_FACE || shapeType == TopAbs_SHELL) { dimension = 2; - else if (shapeType == TopAbs_EDGE || shapeType == TopAbs_WIRE) + } + else if (shapeType == TopAbs_EDGE || shapeType == TopAbs_WIRE) { dimension = 1; - else + } + else { dimension = - -1;// Vertex (0D) can not make mesh, Compound type might contain any types + -1; // Vertex (0D) can not make mesh, Compound type might contain any types + } } } } @@ -242,8 +267,9 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( if (pcAnalysis) { std::vector fem = pcAnalysis->Group.getValues(); for (auto it : fem) { - if (it->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) + if (it->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) { pcSolver = static_cast(it); + } } } @@ -266,7 +292,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( updateThermalBoundaryUI(); } else { - ui->tabThermalBoundary->setEnabled(false);// could be hidden + ui->tabThermalBoundary->setEnabled(false); // could be hidden // Base::Console().Message("retrieve solver property HeatTransferring as false\n"); } } @@ -307,7 +333,8 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( ui->tabWidget->setCurrentIndex(0); ui->labelHelpText->setText(tr("select boundary type, faces and set value")); - initComboBox(ui->comboBoundaryType, pcConstraint->BoundaryType.getEnumVector(), + initComboBox(ui->comboBoundaryType, + pcConstraint->BoundaryType.getEnumVector(), pcConstraint->BoundaryType.getValueAsString()); updateBoundaryTypeUI(); std::vector subtypes = pcConstraint->Subtype.getEnumVector(); @@ -318,8 +345,9 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( std::vector SubElements = pcConstraint->References.getSubValues(); std::vector dirStrings = pcConstraint->Direction.getSubValues(); QString dir; - if (!dirStrings.empty()) + if (!dirStrings.empty()) { dir = makeRefText(pcConstraint->Direction.getValue(), dirStrings.front()); + } // Fill data into dialog elements double f = pcConstraint->BoundaryValue.getValue(); @@ -327,12 +355,14 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( ui->spinBoundaryValue->setMaximum(FLOAT_MAX); ui->spinBoundaryValue->setValue(f); ui->listReferences->clear(); - for (std::size_t i = 0; i < Objects.size(); i++) + for (std::size_t i = 0; i < Objects.size(); i++) { ui->listReferences->addItem(makeRefText(Objects[i], SubElements[i])); - if (!Objects.empty()) + } + if (!Objects.empty()) { ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); + } ui->lineDirection->setText(dir.isEmpty() ? tr("") : dir); - ui->checkReverse->setVisible(true); // it is still useful to swap direction of an edge + ui->checkReverse->setVisible(true); // it is still useful to swap direction of an edge ui->listReferences->blockSignals(false); ui->spinBoundaryValue->blockSignals(false); @@ -374,27 +404,26 @@ void TaskFemConstraintFluidBoundary::updateBoundaryTypeUI() else if (boundaryType == "inlet") { ui->tabBasicBoundary->setEnabled(true); pcConstraint->Subtype.setEnums(InletSubtypes); - ui->labelBoundaryValue->setText(QString::fromUtf8("Pressure [Pa]")); // default to pressure - pcConstraint->Reversed.setValue(true); // inlet must point into volume + ui->labelBoundaryValue->setText(QString::fromUtf8("Pressure [Pa]")); // default to pressure + pcConstraint->Reversed.setValue(true); // inlet must point into volume } else if (boundaryType == "outlet") { ui->tabBasicBoundary->setEnabled(true); pcConstraint->Subtype.setEnums(OutletSubtypes); ui->labelBoundaryValue->setText(QString::fromUtf8("Pressure [Pa]")); - pcConstraint->Reversed.setValue(false); // outlet must point outward + pcConstraint->Reversed.setValue(false); // outlet must point outward } else { Base::Console().Error("Error: Fluid boundary type `%s` is not defined\n", boundaryType.c_str()); } - //std::string subtypeLabel = boundaryType + std::string(" type"); - //ui->labelSubtype->setText(QString::fromUtf8(subtypeLabel)); // too long to show in UI + // std::string subtypeLabel = boundaryType + std::string(" type"); + // ui->labelSubtype->setText(QString::fromUtf8(subtypeLabel)); // too long to show in UI ui->tabWidget->setCurrentIndex(0); // activate the basic pressure-momentum setting tab std::vector subtypes = pcConstraint->Subtype.getEnumVector(); initComboBox(ui->comboSubtype, subtypes, "default to the second subtype"); updateSubtypeUI(); - } @@ -435,7 +464,7 @@ void TaskFemConstraintFluidBoundary::updateSubtypeUI() if (subtype == "moving") { ui->labelBoundaryValue->setText(QString::fromUtf8("moving speed (m/s)")); ui->tabBasicBoundary->setEnabled(true); - ui->buttonDirection->setEnabled(false); // moving speed must be parallel to wall + ui->buttonDirection->setEnabled(false); // moving speed must be parallel to wall ui->lineDirection->setEnabled(false); } else if (subtype == "slip") { @@ -455,7 +484,7 @@ void TaskFemConstraintFluidBoundary::updateSubtypeUI() } else if (boundaryType == "interface") { ui->tabBasicBoundary->setEnabled(false); - //show help text + // show help text int iInterface = ui->comboSubtype->currentIndex(); ui->labelHelpText->setText(tr(InterfaceSubtypeHelpTexts[iInterface])); } @@ -544,7 +573,7 @@ void TaskFemConstraintFluidBoundary::onBoundaryTypeChanged() pcConstraint->BoundaryType.setValue(ui->comboBoundaryType->currentIndex()); updateBoundaryTypeUI(); - ConstraintView->updateData(&pcConstraint->BoundaryType);// force a 3D redraw + ConstraintView->updateData(&pcConstraint->BoundaryType); // force a 3D redraw // update view provider once BoundaryType changed, updateData() may be just enough // FreeCAD.getDocument(pcConstraint->Document.getName()).recompute(); @@ -558,13 +587,13 @@ void TaskFemConstraintFluidBoundary::onBoundaryTypeChanged() void TaskFemConstraintFluidBoundary::onSubtypeChanged() { - updateSubtypeUI();// todo: change color for different kind of subtype, - // Fem::ConstraintFluidBoundary::onChanged() and viewProvider + updateSubtypeUI(); // todo: change color for different kind of subtype, + // Fem::ConstraintFluidBoundary::onChanged() and viewProvider } void TaskFemConstraintFluidBoundary::onBoundaryValueChanged(double) { - //left empty for future extension + // left empty for future extension } void TaskFemConstraintFluidBoundary::onTurbulenceSpecificationChanged() { @@ -585,8 +614,8 @@ void TaskFemConstraintFluidBoundary::onThermalBoundaryTypeChanged() void TaskFemConstraintFluidBoundary::onReferenceDeleted() { - TaskFemConstraintFluidBoundary::removeFromSelection();// On right-click face is automatically - // selected, so just remove + TaskFemConstraintFluidBoundary::removeFromSelection(); // On right-click face is automatically + // selected, so just remove } void TaskFemConstraintFluidBoundary::onButtonDirection(const bool pressed) @@ -611,16 +640,18 @@ void TaskFemConstraintFluidBoundary::onButtonDirection(const bool pressed) // we can only handle part objects if (!selectionElement.isObjectTypeOf(Part::Feature::getClassTypeId())) { - QMessageBox::warning( - this, tr("Wrong selection"), tr("Selected object is not a part object!")); + QMessageBox::warning(this, + tr("Wrong selection"), + tr("Selected object is not a part object!")); return; } // get the names of the subobjects const std::vector& subNames = selectionElement.getSubNames(); if (subNames.size() != 1) { - QMessageBox::warning( - this, tr("Wrong selection"), tr("Only one planar face or edge can be selected!")); + QMessageBox::warning(this, + tr("Wrong selection"), + tr("Only one planar face or edge can be selected!")); return; } @@ -634,15 +665,17 @@ void TaskFemConstraintFluidBoundary::onButtonDirection(const bool pressed) if (subNamesElement.substr(0, 4) == "Face") { if (!Fem::Tools::isPlanar(TopoDS::Face(ref))) { - QMessageBox::warning( - this, tr("Wrong selection"), tr("Only planar faces can be picked for 3D")); + QMessageBox::warning(this, + tr("Wrong selection"), + tr("Only planar faces can be picked for 3D")); return; } } - else if (subNamesElement.substr(0, 4) == "Edge") {// 2D or 3D can use edge as direction vector + else if (subNamesElement.substr(0, 4) == "Edge") { // 2D or 3D can use edge as direction vector if (!Fem::Tools::isLinear(TopoDS::Edge(ref))) { - QMessageBox::warning( - this, tr("Wrong selection"), tr("Only planar edges can be picked for 2D")); + QMessageBox::warning(this, + tr("Wrong selection"), + tr("Only planar edges can be picked for 2D")); return; } } @@ -744,16 +777,18 @@ const std::string TaskFemConstraintFluidBoundary::getReferences() const int rows = ui->listReferences->model()->rowCount(); std::vector items; - for (int r = 0; r < rows; r++) + for (int r = 0; r < rows; r++) { items.push_back(ui->listReferences->item(r)->text().toStdString()); + } return TaskFemConstraint::getReferences(items); } const std::string TaskFemConstraintFluidBoundary::getDirectionName() const { std::string dir = ui->lineDirection->text().toStdString(); - if (dir.empty()) + if (dir.empty()) { return ""; + } int pos = dir.find_last_of(":"); return dir.substr(0, pos).c_str(); @@ -762,8 +797,9 @@ const std::string TaskFemConstraintFluidBoundary::getDirectionName() const const std::string TaskFemConstraintFluidBoundary::getDirectionObject() const { std::string dir = ui->lineDirection->text().toStdString(); - if (dir.empty()) + if (dir.empty()) { return ""; + } int pos = dir.find_last_of(":"); return dir.substr(pos + 1).c_str(); @@ -779,7 +815,7 @@ TaskFemConstraintFluidBoundary::~TaskFemConstraintFluidBoundary() = default; void TaskFemConstraintFluidBoundary::addToSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -789,44 +825,47 @@ void TaskFemConstraintFluidBoundary::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } const std::vector& subNames = it.getSubNames(); App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } // limit constraint such that only vertexes or faces or edges can be used depending on // what was selected first std::string searchStr; - if (subName.find("Vertex") != std::string::npos) + if (subName.find("Vertex") != std::string::npos) { searchStr = "Vertex"; - else if (subName.find("Edge") != std::string::npos) + } + else if (subName.find("Edge") != std::string::npos) { searchStr = "Edge"; - else + } + else { searchStr = "Face"; + } - for (const auto & SubElement : SubElements) { + for (const auto& SubElement : SubElements) { if (SubElement.find(searchStr) == std::string::npos) { - QString msg = tr( - "Only one type of selection (vertex, face or edge) per analysis feature allowed!"); + QString msg = tr("Only one type of selection (vertex, face or edge) per " + "analysis feature allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); addMe = false; break; @@ -848,7 +887,7 @@ void TaskFemConstraintFluidBoundary::addToSelection() void TaskFemConstraintFluidBoundary::removeFromSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -858,7 +897,7 @@ void TaskFemConstraintFluidBoundary::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -866,19 +905,19 @@ void TaskFemConstraintFluidBoundary::removeFromSelection() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -921,7 +960,7 @@ void TaskFemConstraintFluidBoundary::changeEvent(QEvent* e) TaskBox::changeEvent(e); if (e->type() == QEvent::LanguageChange) { ui->spinBoundaryValue->blockSignals(true); - //more ui widget? those UI are does not support tr yet! + // more ui widget? those UI are does not support tr yet! ui->retranslateUi(proxy); ui->spinBoundaryValue->blockSignals(false); @@ -930,10 +969,12 @@ void TaskFemConstraintFluidBoundary::changeEvent(QEvent* e) void TaskFemConstraintFluidBoundary::clearButtons(const SelectionChangeModes notThis) { - if (notThis != SelectionChangeModes::refAdd) + if (notThis != SelectionChangeModes::refAdd) { ui->btnAdd->setChecked(false); - if (notThis != SelectionChangeModes::refRemove) + } + if (notThis != SelectionChangeModes::refRemove) { ui->btnRemove->setChecked(false); + } } //************************************************************************** @@ -999,18 +1040,19 @@ bool TaskDlgFemConstraintFluidBoundary::accept() buf.toStdString().c_str()); } else { - Gui::Command::doCommand( - Gui::Command::Doc, "App.ActiveDocument.%s.Direction = None", name.c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Direction = None", + name.c_str()); } // Reverse control is done at BoundaryType selection, this UI is hidden from user // Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %s", // name.c_str(), boundary->getReverse() ? "True" : "False"); - std::string scale = boundary->getScale();// OvG: determine modified scale + std::string scale = boundary->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale // solver specific setting, physical model selection const Fem::FemSolverObject* pcSolver = boundary->getFemSolver(); @@ -1043,7 +1085,7 @@ bool TaskDlgFemConstraintFluidBoundary::accept() } if (pTurbulenceModel && std::string(pTurbulenceModel->getValueAsString()) - != "laminar") {// Invisic and DNS flow also does not need this + != "laminar") { // Invisic and DNS flow also does not need this // update turbulence and thermal boundary settings, only if those models are // activated Gui::Command::doCommand(Gui::Command::Doc, diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.h b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.h index 24135a80b1..66141fb441 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.h @@ -23,8 +23,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintFluidBoundary_H #define GUI_TASKVIEW_TaskFemConstraintFluidBoundary_H -#include #include +#include #include @@ -34,17 +34,20 @@ class Ui_TaskFemConstraintFluidBoundary; -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; } -namespace FemGui { +namespace FemGui +{ -class TaskFemConstraintFluidBoundary : public TaskFemConstraintOnBoundary +class TaskFemConstraintFluidBoundary: public TaskFemConstraintOnBoundary { Q_OBJECT @@ -83,13 +86,13 @@ private Q_SLOTS: void onThermalBoundaryTypeChanged(); void onReferenceDeleted(); void onButtonDirection(const bool pressed = true); - void onCheckReverse(bool); // consider removing this slot as the UI is hidden + void onCheckReverse(bool); // consider removing this slot as the UI is hidden void addToSelection() override; void removeFromSelection() override; protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void clearButtons(const SelectionChangeModes notThis) override; private: @@ -108,7 +111,7 @@ private: }; /// simulation dialog for the TaskView -class TaskDlgFemConstraintFluidBoundary : public TaskDlgFemConstraint +class TaskDlgFemConstraintFluidBoundary: public TaskDlgFemConstraint { Q_OBJECT @@ -122,6 +125,6 @@ public: bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintFluidBoundary_H +#endif // GUI_TASKVIEW_TaskFemConstraintFluidBoundary_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp index d8c3097231..da3a74d901 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp @@ -24,10 +24,10 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include #endif #include @@ -49,8 +49,8 @@ using namespace Gui; TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce* ConstraintView, QWidget* parent) - : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintForce"), - ui(new Ui_TaskFemConstraintForce) + : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintForce") + , ui(new Ui_TaskFemConstraintForce) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -59,16 +59,20 @@ TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce* C // create a context menu for the listview of the references createDeleteAction(ui->listReferences); - connect(deleteAction, &QAction::triggered, - this, &TaskFemConstraintForce::onReferenceDeleted); - connect(ui->spinForce, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &TaskFemConstraintForce::onForceChanged); - connect(ui->buttonDirection, &QToolButton::clicked, - this, &TaskFemConstraintForce::onButtonDirection); - connect(ui->checkReverse, &QCheckBox::toggled, - this, &TaskFemConstraintForce::onCheckReverse); - connect(ui->listReferences, &QListWidget::itemClicked, - this, &TaskFemConstraintForce::setSelection); + connect(deleteAction, &QAction::triggered, this, &TaskFemConstraintForce::onReferenceDeleted); + connect(ui->spinForce, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &TaskFemConstraintForce::onForceChanged); + connect(ui->buttonDirection, + &QToolButton::clicked, + this, + &TaskFemConstraintForce::onButtonDirection); + connect(ui->checkReverse, &QCheckBox::toggled, this, &TaskFemConstraintForce::onCheckReverse); + connect(ui->listReferences, + &QListWidget::itemClicked, + this, + &TaskFemConstraintForce::setSelection); this->groupLayout()->addWidget(proxy); @@ -86,8 +90,9 @@ TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce* C std::vector SubElements = pcConstraint->References.getSubValues(); std::vector dirStrings = pcConstraint->Direction.getSubValues(); QString dir; - if (!dirStrings.empty()) + if (!dirStrings.empty()) { dir = makeRefText(pcConstraint->Direction.getValue(), dirStrings.front()); + } bool reversed = pcConstraint->Reversed.getValue(); // Fill data into dialog elements @@ -95,10 +100,12 @@ TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce* C ui->spinForce->setMaximum(FLOAT_MAX); ui->spinForce->setValue(f); ui->listReferences->clear(); - for (std::size_t i = 0; i < Objects.size(); i++) + for (std::size_t i = 0; i < Objects.size(); i++) { ui->listReferences->addItem(makeRefText(Objects[i], SubElements[i])); - if (!Objects.empty()) + } + if (!Objects.empty()) { ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); + } ui->lineDirection->setText(dir.isEmpty() ? QString() : dir); ui->checkReverse->setChecked(reversed); @@ -107,7 +114,7 @@ TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce* C ui->buttonDirection->blockSignals(false); ui->checkReverse->blockSignals(false); - //Selection buttons + // Selection buttons buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd); buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove); @@ -126,7 +133,7 @@ void TaskFemConstraintForce::updateUI() void TaskFemConstraintForce::addToSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -136,44 +143,47 @@ void TaskFemConstraintForce::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } const std::vector& subNames = it.getSubNames(); App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } // limit constraint such that only vertexes or faces or edges can be used depending on // what was selected first std::string searchStr; - if (subName.find("Vertex") != std::string::npos) + if (subName.find("Vertex") != std::string::npos) { searchStr = "Vertex"; - else if (subName.find("Edge") != std::string::npos) + } + else if (subName.find("Edge") != std::string::npos) { searchStr = "Edge"; - else + } + else { searchStr = "Face"; + } - for (const auto & SubElement : SubElements) { + for (const auto& SubElement : SubElements) { if (SubElement.find(searchStr) == std::string::npos) { - QString msg = tr( - "Only one type of selection (vertex, face or edge) per analysis feature allowed!"); + QString msg = tr("Only one type of selection (vertex, face or edge) per " + "analysis feature allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); addMe = false; break; @@ -195,7 +205,7 @@ void TaskFemConstraintForce::addToSelection() void TaskFemConstraintForce::removeFromSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -205,7 +215,7 @@ void TaskFemConstraintForce::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -213,19 +223,19 @@ void TaskFemConstraintForce::removeFromSelection() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -258,8 +268,8 @@ void TaskFemConstraintForce::onForceChanged(double f) void TaskFemConstraintForce::onReferenceDeleted() { - TaskFemConstraintForce::removeFromSelection();// OvG: On right-click face is automatically - // selected, so just remove + TaskFemConstraintForce::removeFromSelection(); // OvG: On right-click face is automatically + // selected, so just remove } std::pair @@ -276,8 +286,8 @@ TaskFemConstraintForce::getDirection(const std::vector& se // Line or Plane Base::Type line = Base::Type::fromName("PartDesign::Line"); Base::Type plane = Base::Type::fromName("PartDesign::Plane"); - if (selectionElement.isObjectTypeOf(App::Line::getClassTypeId()) || - selectionElement.isObjectTypeOf(App::Plane::getClassTypeId())) { + if (selectionElement.isObjectTypeOf(App::Line::getClassTypeId()) + || selectionElement.isObjectTypeOf(App::Plane::getClassTypeId())) { link = std::make_pair(selectionElement.getObject(), std::string()); } else if (selectionElement.isObjectTypeOf(line)) { @@ -359,16 +369,18 @@ const std::string TaskFemConstraintForce::getReferences() const int rows = ui->listReferences->model()->rowCount(); std::vector items; - for (int r = 0; r < rows; r++) + for (int r = 0; r < rows; r++) { items.push_back(ui->listReferences->item(r)->text().toStdString()); + } return TaskFemConstraint::getReferences(items); } const std::string TaskFemConstraintForce::getDirectionName() const { std::string dir = ui->lineDirection->text().toStdString(); - if (dir.empty()) + if (dir.empty()) { return ""; + } int pos = dir.find_last_of(":"); return dir.substr(0, pos).c_str(); @@ -377,8 +389,9 @@ const std::string TaskFemConstraintForce::getDirectionName() const const std::string TaskFemConstraintForce::getDirectionObject() const { std::string dir = ui->lineDirection->text().toStdString(); - if (dir.empty()) + if (dir.empty()) { return ""; + } int pos = dir.find_last_of(":"); return dir.substr(pos + 1).c_str(); @@ -408,10 +421,12 @@ void TaskFemConstraintForce::changeEvent(QEvent* e) void TaskFemConstraintForce::clearButtons(const SelectionChangeModes notThis) { - if (notThis != SelectionChangeModes::refAdd) + if (notThis != SelectionChangeModes::refAdd) { ui->btnAdd->setChecked(false); - if (notThis != SelectionChangeModes::refRemove) + } + if (notThis != SelectionChangeModes::refRemove) { ui->btnRemove->setChecked(false); + } } //************************************************************************** @@ -441,7 +456,7 @@ void TaskDlgFemConstraintForce::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -455,14 +470,17 @@ bool TaskDlgFemConstraintForce::accept() // Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "FEM force constraint changed")); if (parameterForce->getForce() <= 0) { - QMessageBox::warning( - parameter, tr("Input error"), tr("Please specify a force greater than 0")); + QMessageBox::warning(parameter, + tr("Input error"), + tr("Please specify a force greater than 0")); return false; } else { QByteArray num = QByteArray::number(parameterForce->getForce()); - Gui::Command::doCommand( - Gui::Command::Doc, "App.ActiveDocument.%s.Force = %s", name.c_str(), num.data()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Force = %s", + name.c_str(), + num.data()); } std::string dirname = parameterForce->getDirectionName().data(); @@ -479,8 +497,9 @@ bool TaskDlgFemConstraintForce::accept() buf.toStdString().c_str()); } else { - Gui::Command::doCommand( - Gui::Command::Doc, "App.ActiveDocument.%s.Direction = None", name.c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Direction = None", + name.c_str()); } Gui::Command::doCommand(Gui::Command::Doc, @@ -488,11 +507,11 @@ bool TaskDlgFemConstraintForce::accept() name.c_str(), parameterForce->getReverse() ? "True" : "False"); - scale = parameterForce->getScale();// OvG: determine modified scale + scale = parameterForce->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintForce.h b/src/Mod/Fem/Gui/TaskFemConstraintForce.h index e48efba508..1791766e3a 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintForce.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintForce.h @@ -24,8 +24,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintForce_H #define GUI_TASKVIEW_TaskFemConstraintForce_H -#include #include +#include #include "TaskFemConstraintOnBoundary.h" #include "ViewProviderFemConstraintForce.h" @@ -33,18 +33,21 @@ class Ui_TaskFemConstraintForce; -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class SelectionObject; class ViewProvider; -} +} // namespace Gui -namespace FemGui { +namespace FemGui +{ -class TaskFemConstraintForce : public TaskFemConstraintOnBoundary +class TaskFemConstraintForce: public TaskFemConstraintOnBoundary { Q_OBJECT @@ -67,8 +70,8 @@ private Q_SLOTS: void removeFromSelection() override; protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void clearButtons(const SelectionChangeModes notThis) override; private: @@ -81,12 +84,12 @@ private: }; /// simulation dialog for the TaskView -class TaskDlgFemConstraintForce : public TaskDlgFemConstraint +class TaskDlgFemConstraintForce: public TaskDlgFemConstraint { Q_OBJECT public: - explicit TaskDlgFemConstraintForce(ViewProviderFemConstraintForce *ConstraintView); + explicit TaskDlgFemConstraintForce(ViewProviderFemConstraintForce* ConstraintView); /// is called by the framework if the dialog is accepted (Ok) void open() override; @@ -94,6 +97,6 @@ public: bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintForce_H +#endif // GUI_TASKVIEW_TaskFemConstraintForce_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp b/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp index b9c1c23554..f815e5d994 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp @@ -24,8 +24,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include #endif #include @@ -45,19 +45,27 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintGear */ -TaskFemConstraintGear::TaskFemConstraintGear(ViewProviderFemConstraint *ConstraintView,QWidget *parent, const char *pixmapname) +TaskFemConstraintGear::TaskFemConstraintGear(ViewProviderFemConstraint* ConstraintView, + QWidget* parent, + const char* pixmapname) : TaskFemConstraintBearing(ConstraintView, parent, pixmapname) { - connect(ui->spinDiameter, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintGear::onDiameterChanged); - connect(ui->spinForce, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintGear::onForceChanged); - connect(ui->spinForceAngle, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintGear::onForceAngleChanged); - connect(ui->buttonDirection, &QPushButton::pressed, - this, [=]{onButtonDirection(true);}); - connect(ui->checkReversed, &QCheckBox::toggled, - this, &TaskFemConstraintGear::onCheckReversed); + connect(ui->spinDiameter, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskFemConstraintGear::onDiameterChanged); + connect(ui->spinForce, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskFemConstraintGear::onForceChanged); + connect(ui->spinForceAngle, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskFemConstraintGear::onForceAngleChanged); + connect(ui->buttonDirection, &QPushButton::pressed, this, [=] { + onButtonDirection(true); + }); + connect(ui->checkReversed, &QCheckBox::toggled, this, &TaskFemConstraintGear::onCheckReversed); // Temporarily prevent unnecessary feature recomputes ui->spinDiameter->blockSignals(true); @@ -66,14 +74,16 @@ TaskFemConstraintGear::TaskFemConstraintGear(ViewProviderFemConstraint *Constrai ui->checkReversed->blockSignals(true); // Get the feature data - Fem::ConstraintGear* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintGear* pcConstraint = + static_cast(ConstraintView->getObject()); double dia = pcConstraint->Diameter.getValue(); double force = pcConstraint->Force.getValue(); double angle = pcConstraint->ForceAngle.getValue(); std::vector dirStrings = pcConstraint->Direction.getSubValues(); QString dir; - if (!dirStrings.empty()) + if (!dirStrings.empty()) { dir = makeRefText(pcConstraint->Direction.getValue(), dirStrings.front()); + } bool reversed = pcConstraint->Reversed.getValue(); // Fill data into dialog elements @@ -113,37 +123,48 @@ void TaskFemConstraintGear::onSelectionChanged(const Gui::SelectionChanges& msg) if (msg.Type == Gui::SelectionChanges::AddSelection) { // Don't allow selection in other document - if (strcmp(msg.pDocName, ConstraintView->getObject()->getDocument()->getName()) != 0) + if (strcmp(msg.pDocName, ConstraintView->getObject()->getDocument()->getName()) != 0) { return; + } - if (!msg.pSubName || msg.pSubName[0] == '\0') + if (!msg.pSubName || msg.pSubName[0] == '\0') { return; + } std::string subName(msg.pSubName); - if (selectionMode == selnone) + if (selectionMode == selnone) { return; + } - std::vector references(1,subName); - Fem::ConstraintGear* pcConstraint = static_cast(ConstraintView->getObject()); - App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(msg.pObjectName); + std::vector references(1, subName); + Fem::ConstraintGear* pcConstraint = + static_cast(ConstraintView->getObject()); + App::DocumentObject* obj = + ConstraintView->getObject()->getDocument()->getObject(msg.pObjectName); Part::Feature* feat = static_cast(obj); TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subName.c_str()); if (selectionMode == seldir) { - if (subName.substr(0,4) == "Face") { + if (subName.substr(0, 4) == "Face") { if (!Fem::Tools::isPlanar(TopoDS::Face(ref))) { - QMessageBox::warning(this, tr("Selection error"), tr("Only planar faces can be picked")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only planar faces can be picked")); return; } } - else if (subName.substr(0,4) == "Edge") { + else if (subName.substr(0, 4) == "Edge") { if (!Fem::Tools::isLinear(TopoDS::Edge(ref))) { - QMessageBox::warning(this, tr("Selection error"), tr("Only linear edges can be picked")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only linear edges can be picked")); return; } } else { - QMessageBox::warning(this, tr("Selection error"), tr("Only faces and edges can be picked")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only faces and edges can be picked")); return; } pcConstraint->Direction.setValue(obj, references); @@ -159,26 +180,31 @@ void TaskFemConstraintGear::onSelectionChanged(const Gui::SelectionChanges& msg) void TaskFemConstraintGear::onDiameterChanged(double l) { - Fem::ConstraintGear* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintGear* pcConstraint = + static_cast(ConstraintView->getObject()); pcConstraint->Diameter.setValue(l); } void TaskFemConstraintGear::onForceChanged(double f) { - Fem::ConstraintGear* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintGear* pcConstraint = + static_cast(ConstraintView->getObject()); pcConstraint->Force.setValue(f); } void TaskFemConstraintGear::onForceAngleChanged(double a) { - Fem::ConstraintGear* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintGear* pcConstraint = + static_cast(ConstraintView->getObject()); pcConstraint->ForceAngle.setValue(a); } -void TaskFemConstraintGear::onButtonDirection(const bool pressed) { +void TaskFemConstraintGear::onButtonDirection(const bool pressed) +{ if (pressed) { selectionMode = seldir; - } else { + } + else { selectionMode = selnone; } ui->buttonDirection->setChecked(pressed); @@ -187,7 +213,8 @@ void TaskFemConstraintGear::onButtonDirection(const bool pressed) { void TaskFemConstraintGear::onCheckReversed(const bool pressed) { - Fem::ConstraintGear* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintGear* pcConstraint = + static_cast(ConstraintView->getObject()); pcConstraint->Reversed.setValue(pressed); } @@ -204,8 +231,9 @@ double TaskFemConstraintGear::getForceAngle() const const std::string TaskFemConstraintGear::getDirectionName() const { std::string dir = ui->lineDirection->text().toStdString(); - if (dir.empty()) + if (dir.empty()) { return ""; + } int pos = dir.find_last_of(":"); return dir.substr(0, pos).c_str(); @@ -214,11 +242,12 @@ const std::string TaskFemConstraintGear::getDirectionName() const const std::string TaskFemConstraintGear::getDirectionObject() const { std::string dir = ui->lineDirection->text().toStdString(); - if (dir.empty()) + if (dir.empty()) { return ""; + } int pos = dir.find_last_of(":"); - return dir.substr(pos+1).c_str(); + return dir.substr(pos + 1).c_str(); } bool TaskFemConstraintGear::getReverse() const @@ -231,7 +260,7 @@ double TaskFemConstraintGear::getDiameter() const return ui->spinDiameter->value(); } -void TaskFemConstraintGear::changeEvent(QEvent *e) +void TaskFemConstraintGear::changeEvent(QEvent* e) { TaskBox::changeEvent(e); if (e->type() == QEvent::LanguageChange) { @@ -252,7 +281,7 @@ void TaskFemConstraintGear::changeEvent(QEvent *e) // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgFemConstraintGear::TaskDlgFemConstraintGear(ViewProviderFemConstraintGear *ConstraintView) +TaskDlgFemConstraintGear::TaskDlgFemConstraintGear(ViewProviderFemConstraintGear* ConstraintView) { this->ConstraintView = ConstraintView; assert(ConstraintView); @@ -266,10 +295,11 @@ TaskDlgFemConstraintGear::TaskDlgFemConstraintGear(ViewProviderFemConstraintGear bool TaskDlgFemConstraintGear::accept() { std::string name = ConstraintView->getObject()->getNameInDocument(); - const TaskFemConstraintGear* parameterGear = static_cast(parameter); + const TaskFemConstraintGear* parameterGear = + static_cast(parameter); try { - //Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "FEM force constraint changed")); + // Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "FEM force constraint changed")); std::string dirname = parameterGear->getDirectionName().data(); std::string dirobj = parameterGear->getDirectionObject().data(); @@ -277,15 +307,33 @@ bool TaskDlgFemConstraintGear::accept() QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); buf = buf.arg(QString::fromStdString(dirname)); buf = buf.arg(QString::fromStdString(dirobj)); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str()); - } else { - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Direction = %s", + name.c_str(), + buf.toStdString().c_str()); + } + else { + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Direction = None", + name.c_str()); } - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %s", name.c_str(), parameterGear->getReverse() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Diameter = %f",name.c_str(), parameterGear->getDiameter()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Force = %f",name.c_str(), parameterGear->getForce()); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ForceAngle = %f",name.c_str(), parameterGear->getForceAngle()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Reversed = %s", + name.c_str(), + parameterGear->getReverse() ? "True" : "False"); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Diameter = %f", + name.c_str(), + parameterGear->getDiameter()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Force = %f", + name.c_str(), + parameterGear->getForce()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.ForceAngle = %f", + name.c_str(), + parameterGear->getForceAngle()); } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintGear.h b/src/Mod/Fem/Gui/TaskFemConstraintGear.h index c8f12ad7d8..6b2f205cd1 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintGear.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintGear.h @@ -27,15 +27,17 @@ #include "TaskFemConstraintBearing.h" #include "ViewProviderFemConstraintGear.h" -namespace FemGui { +namespace FemGui +{ -class TaskFemConstraintGear : public TaskFemConstraintBearing +class TaskFemConstraintGear: public TaskFemConstraintBearing { Q_OBJECT public: - explicit TaskFemConstraintGear(ViewProviderFemConstraint *ConstraintView,QWidget *parent = nullptr, - const char* pixmapname = "FEM_ConstraintGear"); + explicit TaskFemConstraintGear(ViewProviderFemConstraint* ConstraintView, + QWidget* parent = nullptr, + const char* pixmapname = "FEM_ConstraintGear"); double getDiameter() const; double getForce() const; @@ -52,24 +54,23 @@ private Q_SLOTS: void onCheckReversed(bool); protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; void onSelectionChanged(const Gui::SelectionChanges& msg) override; }; /// simulation dialog for the TaskView -class TaskDlgFemConstraintGear : public TaskDlgFemConstraintBearing +class TaskDlgFemConstraintGear: public TaskDlgFemConstraintBearing { Q_OBJECT public: TaskDlgFemConstraintGear() = default; - explicit TaskDlgFemConstraintGear(ViewProviderFemConstraintGear *ConstraintView); + explicit TaskDlgFemConstraintGear(ViewProviderFemConstraintGear* ConstraintView); /// is called by the framework if the dialog is accepted (Ok) bool accept() override; - }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintGear_H +#endif // GUI_TASKVIEW_TaskFemConstraintGear_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp index 9f05ca7f64..5a5cb9aa47 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp @@ -26,9 +26,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif #include @@ -45,9 +45,10 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintHeatflux */ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux( - ViewProviderFemConstraintHeatflux* ConstraintView, QWidget* parent) - : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintHeatflux"), - ui(new Ui_TaskFemConstraintHeatflux) + ViewProviderFemConstraintHeatflux* ConstraintView, + QWidget* parent) + : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintHeatflux") + , ui(new Ui_TaskFemConstraintHeatflux) { proxy = new QWidget(this); ui->setupUi(proxy); @@ -55,28 +56,36 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux( // create a context menu for the listview of the references createDeleteAction(ui->lw_references); - connect(deleteAction, &QAction::triggered, - this, &TaskFemConstraintHeatflux::onReferenceDeleted); + connect(deleteAction, + &QAction::triggered, + this, + &TaskFemConstraintHeatflux::onReferenceDeleted); - connect(ui->rb_convection, &QRadioButton::clicked, - this, &TaskFemConstraintHeatflux::Conv); - connect(ui->rb_dflux, &QRadioButton::clicked, - this, &TaskFemConstraintHeatflux::Flux); + connect(ui->rb_convection, &QRadioButton::clicked, this, &TaskFemConstraintHeatflux::Conv); + connect(ui->rb_dflux, &QRadioButton::clicked, this, &TaskFemConstraintHeatflux::Flux); - connect(ui->if_heatflux, qOverload(&InputField::valueChanged), - this, &TaskFemConstraintHeatflux::onHeatFluxChanged); - connect(ui->if_ambienttemp, qOverload(&InputField::valueChanged), - this, &TaskFemConstraintHeatflux::onAmbientTempChanged); - connect(ui->if_filmcoef, qOverload(&InputField::valueChanged), - this, &TaskFemConstraintHeatflux::onFilmCoefChanged); - connect(ui->lw_references, &QListWidget::itemClicked, - this, &TaskFemConstraintHeatflux::setSelection); + connect(ui->if_heatflux, + qOverload(&InputField::valueChanged), + this, + &TaskFemConstraintHeatflux::onHeatFluxChanged); + connect(ui->if_ambienttemp, + qOverload(&InputField::valueChanged), + this, + &TaskFemConstraintHeatflux::onAmbientTempChanged); + connect(ui->if_filmcoef, + qOverload(&InputField::valueChanged), + this, + &TaskFemConstraintHeatflux::onFilmCoefChanged); + connect(ui->lw_references, + &QListWidget::itemClicked, + this, + &TaskFemConstraintHeatflux::setSelection); this->groupLayout()->addWidget(proxy); // Temporarily prevent unnecessary feature recomputes ui->if_ambienttemp->blockSignals(true); - //ui->if_facetemp->blockSignals(true); + // ui->if_facetemp->blockSignals(true); ui->if_filmcoef->blockSignals(true); ui->lw_references->blockSignals(true); ui->btnAdd->blockSignals(true); @@ -121,12 +130,12 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux( ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); } - //Selection buttons + // Selection buttons buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd); buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove); ui->if_ambienttemp->blockSignals(false); - //ui->if_facetemp->blockSignals(false); + // ui->if_facetemp->blockSignals(false); ui->if_filmcoef->blockSignals(false); ui->lw_references->blockSignals(false); ui->btnAdd->blockSignals(false); @@ -150,14 +159,14 @@ void TaskFemConstraintHeatflux::onAmbientTempChanged(double val) { Fem::ConstraintHeatflux* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->AmbientTemp.setValue(val);//[K] + pcConstraint->AmbientTemp.setValue(val); //[K] } void TaskFemConstraintHeatflux::onFilmCoefChanged(double val) { Fem::ConstraintHeatflux* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->FilmCoef.setValue(val);// [W]/[[m^2]/[K]] + pcConstraint->FilmCoef.setValue(val); // [W]/[[m^2]/[K]] } void TaskFemConstraintHeatflux::onHeatFluxChanged(double val) @@ -203,7 +212,7 @@ void TaskFemConstraintHeatflux::Flux() void TaskFemConstraintHeatflux::addToSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -213,7 +222,7 @@ void TaskFemConstraintHeatflux::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -222,10 +231,11 @@ void TaskFemConstraintHeatflux::addToSelection() App::DocumentObject* obj = it.getObject(); if (!subNames.empty()) { - for (const auto & subName : subNames) { + for (const auto& subName : subNames) { if (subName.substr(0, 4) != "Face") { - QMessageBox::warning( - this, tr("Selection error"), tr("Selection must only consist of faces!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Selection must only consist of faces!")); return; } } @@ -234,20 +244,20 @@ void TaskFemConstraintHeatflux::addToSelection() // fix me, if an object is selected completely, getSelectionEx does not return any // SubElements } - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } @@ -267,7 +277,7 @@ void TaskFemConstraintHeatflux::addToSelection() void TaskFemConstraintHeatflux::removeFromSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -278,7 +288,7 @@ void TaskFemConstraintHeatflux::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -287,10 +297,11 @@ void TaskFemConstraintHeatflux::removeFromSelection() const App::DocumentObject* obj = it.getObject(); if (!subNames.empty()) { - for (const auto & subName : subNames) { + for (const auto& subName : subNames) { if (subName.substr(0, 4) != "Face") { - QMessageBox::warning( - this, tr("Selection error"), tr("Selection must only consist of faces!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Selection must only consist of faces!")); return; } } @@ -299,19 +310,19 @@ void TaskFemConstraintHeatflux::removeFromSelection() // fix me, if an object is selected completely, getSelectionEx does not return any // SubElements } - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -365,7 +376,8 @@ double TaskFemConstraintHeatflux::getFilmCoef() const return filmcoef_in_units; } -std::string TaskFemConstraintHeatflux::get_constraint_type() const { +std::string TaskFemConstraintHeatflux::get_constraint_type() const +{ std::string type; if (ui->rb_convection->isChecked()) { type = "\"Convection\""; @@ -395,10 +407,12 @@ void TaskFemConstraintHeatflux::changeEvent(QEvent* e) void TaskFemConstraintHeatflux::clearButtons(const SelectionChangeModes notThis) { - if (notThis != SelectionChangeModes::refAdd) + if (notThis != SelectionChangeModes::refAdd) { ui->btnAdd->setChecked(false); - if (notThis != SelectionChangeModes::refRemove) + } + if (notThis != SelectionChangeModes::refRemove) { ui->btnRemove->setChecked(false); + } } //************************************************************************** @@ -428,7 +442,7 @@ void TaskDlgFemConstraintHeatflux::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -451,11 +465,11 @@ bool TaskDlgFemConstraintHeatflux::accept() name.c_str(), parameterHeatflux->getFilmCoef()); - scale = parameterHeatflux->getScale();// OvG: determine modified scale + scale = parameterHeatflux->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.h b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.h index e83786ea93..3d50623086 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.h @@ -26,8 +26,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintHeatflux_H #define GUI_TASKVIEW_TaskFemConstraintHeatflux_H -#include #include +#include #include "TaskFemConstraintOnBoundary.h" #include "ViewProviderFemConstraintHeatflux.h" @@ -35,8 +35,9 @@ class Ui_TaskFemConstraintHeatflux; -namespace FemGui { -class TaskFemConstraintHeatflux : public TaskFemConstraintOnBoundary +namespace FemGui +{ +class TaskFemConstraintHeatflux: public TaskFemConstraintOnBoundary { Q_OBJECT @@ -62,8 +63,8 @@ private Q_SLOTS: void removeFromSelection() override; protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void clearButtons(const SelectionChangeModes notThis) override; private: @@ -71,17 +72,17 @@ private: std::unique_ptr ui; }; -class TaskDlgFemConstraintHeatflux : public TaskDlgFemConstraint +class TaskDlgFemConstraintHeatflux: public TaskDlgFemConstraint { Q_OBJECT public: - explicit TaskDlgFemConstraintHeatflux(ViewProviderFemConstraintHeatflux *ConstraintView); + explicit TaskDlgFemConstraintHeatflux(ViewProviderFemConstraintHeatflux* ConstraintView); void open() override; bool accept() override; bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintHeatflux_H +#endif // GUI_TASKVIEW_TaskFemConstraintHeatflux_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.cpp b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.cpp index 3c0b56a688..640b86cd32 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.cpp @@ -26,8 +26,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include #endif #include @@ -43,9 +43,10 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintInitialTemperature */ TaskFemConstraintInitialTemperature::TaskFemConstraintInitialTemperature( - ViewProviderFemConstraintInitialTemperature* ConstraintView, QWidget* parent) - : TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintInitialTemperature"), - ui(new Ui_TaskFemConstraintInitialTemperature) + ViewProviderFemConstraintInitialTemperature* ConstraintView, + QWidget* parent) + : TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintInitialTemperature") + , ui(new Ui_TaskFemConstraintInitialTemperature) { proxy = new QWidget(this); ui->setupUi(proxy); @@ -102,7 +103,7 @@ void TaskDlgFemConstraintInitialTemperature::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -118,11 +119,11 @@ bool TaskDlgFemConstraintInitialTemperature::accept() name.c_str(), parameterTemperature->get_temperature().c_str()); - std::string scale = parameterTemperature->getScale();// OvG: determine modified scale + std::string scale = parameterTemperature->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); @@ -131,8 +132,9 @@ bool TaskDlgFemConstraintInitialTemperature::accept() try { Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()"); - if (!ConstraintView->getObject()->isValid()) + if (!ConstraintView->getObject()->isValid()) { throw Base::RuntimeError(ConstraintView->getObject()->getStatusString()); + } Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); Gui::Command::commitCommand(); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.h b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.h index 459ab7d718..ce5b554021 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.h @@ -26,8 +26,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintInitialTemperature_H #define GUI_TASKVIEW_TaskFemConstraintInitialTemperature_H -#include #include +#include #include "TaskFemConstraint.h" #include "ViewProviderFemConstraintInitialTemperature.h" @@ -35,25 +35,27 @@ class Ui_TaskFemConstraintInitialTemperature; -namespace FemGui { -class TaskFemConstraintInitialTemperature : public TaskFemConstraint +namespace FemGui +{ +class TaskFemConstraintInitialTemperature: public TaskFemConstraint { Q_OBJECT public: explicit TaskFemConstraintInitialTemperature( - ViewProviderFemConstraintInitialTemperature* ConstraintView, QWidget* parent = nullptr); + ViewProviderFemConstraintInitialTemperature* ConstraintView, + QWidget* parent = nullptr); ~TaskFemConstraintInitialTemperature() override; std::string get_temperature() const; protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; private: std::unique_ptr ui; }; -class TaskDlgFemConstraintInitialTemperature : public TaskDlgFemConstraint +class TaskDlgFemConstraintInitialTemperature: public TaskDlgFemConstraint { Q_OBJECT @@ -65,6 +67,6 @@ public: bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintInitialTemperature_H +#endif // GUI_TASKVIEW_TaskFemConstraintInitialTemperature_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.cpp index c8c880e8ca..ebc93875c2 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.cpp @@ -30,7 +30,9 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintOnBoundary */ -TaskFemConstraintOnBoundary::TaskFemConstraintOnBoundary(ViewProviderFemConstraint* ConstraintView, QWidget* parent, const char* pixmapname) +TaskFemConstraintOnBoundary::TaskFemConstraintOnBoundary(ViewProviderFemConstraint* ConstraintView, + QWidget* parent, + const char* pixmapname) : TaskFemConstraint(ConstraintView, parent, pixmapname) , selChangeMode(SelectionChangeModes::none) { @@ -39,29 +41,32 @@ TaskFemConstraintOnBoundary::TaskFemConstraintOnBoundary(ViewProviderFemConstrai buttonGroup = new ButtonGroup(this); buttonGroup->setExclusive(true); - connect(buttonGroup, qOverload(&QButtonGroup::buttonToggled), - this, &TaskFemConstraintOnBoundary::onButtonToggled); + connect(buttonGroup, + qOverload(&QButtonGroup::buttonToggled), + this, + &TaskFemConstraintOnBoundary::onButtonToggled); } TaskFemConstraintOnBoundary::~TaskFemConstraintOnBoundary() { - if (!ConstraintView.expired()) + if (!ConstraintView.expired()) { ConstraintView->highlightReferences(false); + } } -void TaskFemConstraintOnBoundary::onButtonToggled(QAbstractButton *button, bool checked) +void TaskFemConstraintOnBoundary::onButtonToggled(QAbstractButton* button, bool checked) { auto mode = static_cast(buttonGroup->id(button)); Gui::Selection().clearSelection(); - if (checked) - { + if (checked) { selChangeMode = mode; ConstraintView->highlightReferences(true); } else { - if (selChangeMode == mode) + if (selChangeMode == mode) { selChangeMode = SelectionChangeModes::none; + } } } @@ -69,18 +74,19 @@ void TaskFemConstraintOnBoundary::onSelectionChanged(const Gui::SelectionChanges { if (msg.Type == Gui::SelectionChanges::AddSelection) { switch (selChangeMode) { - case SelectionChangeModes::refAdd: - // TODO: Optimize to just perform actions on the newly selected item. Suggestion from PartDesign: - // ui->lw_references->addItem(makeRefText(msg.pObjectName, msg.pSubName)); - this->addToSelection(); - break; - case SelectionChangeModes::refRemove: - this->removeFromSelection(); - break; - case SelectionChangeModes::none: - return; - default: - return; + case SelectionChangeModes::refAdd: + // TODO: Optimize to just perform actions on the newly selected item. Suggestion + // from PartDesign: ui->lw_references->addItem(makeRefText(msg.pObjectName, + // msg.pSubName)); + this->addToSelection(); + break; + case SelectionChangeModes::refRemove: + this->removeFromSelection(); + break; + case SelectionChangeModes::none: + return; + default: + return; } ConstraintView->highlightReferences(true); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.h b/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.h index 6367fa9ba7..e369bced23 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintOnBoundary.h @@ -27,14 +27,15 @@ #include #include -#include #include +#include #include #include "TaskFemConstraint.h" -namespace FemGui { +namespace FemGui +{ /** @brief Taskbox for FEM constraints that apply on subsets of the domain boundary * @@ -42,29 +43,36 @@ namespace FemGui { * that apply on subsets of the boundary (faces/edges/vertices), where one or * more boundary entities need to be selected. */ -class TaskFemConstraintOnBoundary : public TaskFemConstraint +class TaskFemConstraintOnBoundary: public TaskFemConstraint { Q_OBJECT public: - explicit TaskFemConstraintOnBoundary(ViewProviderFemConstraint *ConstraintView, QWidget *parent = nullptr, const char* pixmapname = ""); + explicit TaskFemConstraintOnBoundary(ViewProviderFemConstraint* ConstraintView, + QWidget* parent = nullptr, + const char* pixmapname = ""); ~TaskFemConstraintOnBoundary() override; protected Q_SLOTS: - void onButtonToggled(QAbstractButton *button, bool checked); + void onButtonToggled(QAbstractButton* button, bool checked); virtual void addToSelection() = 0; virtual void removeFromSelection() = 0; protected: - enum class SelectionChangeModes {none, refAdd, refRemove}; + enum class SelectionChangeModes + { + none, + refAdd, + refRemove + }; void onSelectionChanged(const Gui::SelectionChanges&) override; virtual void clearButtons(const SelectionChangeModes notThis) = 0; protected: enum SelectionChangeModes selChangeMode; - Gui::ButtonGroup *buttonGroup; + Gui::ButtonGroup* buttonGroup; }; -} // namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintOnBoundary_H +#endif // GUI_TASKVIEW_TaskFemConstraintOnBoundary_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp index c8608e1c8c..a5419a4049 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp @@ -26,10 +26,10 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include #endif #include @@ -50,22 +50,29 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintPlaneRotation */ TaskFemConstraintPlaneRotation::TaskFemConstraintPlaneRotation( - ViewProviderFemConstraintPlaneRotation* ConstraintView, QWidget* parent) - : TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintPlaneRotation"), - ui(new Ui_TaskFemConstraintPlaneRotation) -{ //Note change "planerotation" in line above to new constraint name + ViewProviderFemConstraintPlaneRotation* ConstraintView, + QWidget* parent) + : TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintPlaneRotation") + , ui(new Ui_TaskFemConstraintPlaneRotation) +{ // Note change "planerotation" in line above to new constraint name proxy = new QWidget(this); ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); // create a context menu for the listview of the references createDeleteAction(ui->lw_references); - connect(deleteAction, &QAction::triggered, - this, &TaskFemConstraintPlaneRotation::onReferenceDeleted); - connect(ui->lw_references, &QListWidget::currentItemChanged, - this, &TaskFemConstraintPlaneRotation::setSelection); - connect(ui->lw_references, &QListWidget::itemClicked, - this, &TaskFemConstraintPlaneRotation::setSelection); + connect(deleteAction, + &QAction::triggered, + this, + &TaskFemConstraintPlaneRotation::onReferenceDeleted); + connect(ui->lw_references, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintPlaneRotation::setSelection); + connect(ui->lw_references, + &QListWidget::itemClicked, + this, + &TaskFemConstraintPlaneRotation::setSelection); this->groupLayout()->addWidget(proxy); @@ -88,10 +95,14 @@ TaskFemConstraintPlaneRotation::TaskFemConstraintPlaneRotation( } // Selection buttons - connect(ui->btnAdd, &QToolButton::clicked, - this, &TaskFemConstraintPlaneRotation::addToSelection); - connect(ui->btnRemove, &QToolButton::clicked, - this, &TaskFemConstraintPlaneRotation::removeFromSelection); + connect(ui->btnAdd, + &QToolButton::clicked, + this, + &TaskFemConstraintPlaneRotation::addToSelection); + connect(ui->btnRemove, + &QToolButton::clicked, + this, + &TaskFemConstraintPlaneRotation::removeFromSelection); updateUI(); } @@ -111,15 +122,17 @@ void TaskFemConstraintPlaneRotation::addToSelection() { int rows = ui->lw_references->model()->rowCount(); if (rows == 1) { - QMessageBox::warning(this, - tr("Selection error"), - tr("Only one face can be selected for a plane multi-point constraint!")); + QMessageBox::warning( + this, + tr("Selection error"), + tr("Only one face can be selected for a plane multi-point constraint!")); Gui::Selection().clearSelection(); return; } else { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection() + .getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -129,29 +142,32 @@ void TaskFemConstraintPlaneRotation::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { - QMessageBox::warning( - this, tr("Selection error"), tr("Selected object is not a part!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Selected object is not a part!")); return; } const std::vector& subNames = it.getSubNames(); App::DocumentObject* obj = it.getObject(); if (subNames.size() == 1) { - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; if ((subName.substr(0, 4) != "Face")) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only faces can be picked")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only faces can be picked")); return; } Part::Feature* feat = static_cast(obj); TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subName.c_str()); if ((subName.substr(0, 4) == "Face")) { if (!Fem::Tools::isPlanar(TopoDS::Face(ref))) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only planar faces can be picked")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only planar faces can be picked")); return; } } @@ -160,13 +176,13 @@ void TaskFemConstraintPlaneRotation::addToSelection() itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection - // that matches one in old list + subName)) { // for every sub element in selection + // that matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old - // list then it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old + // list then it was added before so don't add addMe = false; } } @@ -196,7 +212,7 @@ void TaskFemConstraintPlaneRotation::addToSelection() void TaskFemConstraintPlaneRotation::removeFromSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -206,7 +222,7 @@ void TaskFemConstraintPlaneRotation::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -214,19 +230,19 @@ void TaskFemConstraintPlaneRotation::removeFromSelection() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -250,7 +266,8 @@ void TaskFemConstraintPlaneRotation::removeFromSelection() updateUI(); } -void TaskFemConstraintPlaneRotation::onReferenceDeleted() { +void TaskFemConstraintPlaneRotation::onReferenceDeleted() +{ TaskFemConstraintPlaneRotation::removeFromSelection(); } @@ -270,8 +287,7 @@ bool TaskFemConstraintPlaneRotation::event(QEvent* e) } void TaskFemConstraintPlaneRotation::changeEvent(QEvent*) -{ -} +{} //************************************************************************** // TaskDialog @@ -300,7 +316,7 @@ void TaskDlgFemConstraintPlaneRotation::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -309,11 +325,11 @@ bool TaskDlgFemConstraintPlaneRotation::accept() std::string name = ConstraintView->getObject()->getNameInDocument(); const TaskFemConstraintPlaneRotation* parameters = static_cast(parameter); - std::string scale = parameters->getScale();// OvG: determine modified scale + std::string scale = parameters->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale return TaskDlgFemConstraint::accept(); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.h b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.h index 1ad2707fcb..1a55a0e27e 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.h @@ -26,8 +26,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintPlaneRotation_H #define GUI_TASKVIEW_TaskFemConstraintPlaneRotation_H -#include #include +#include #include "TaskFemConstraint.h" #include "ViewProviderFemConstraintPlaneRotation.h" @@ -35,8 +35,9 @@ class Ui_TaskFemConstraintPlaneRotation; -namespace FemGui { -class TaskFemConstraintPlaneRotation : public TaskFemConstraint +namespace FemGui +{ +class TaskFemConstraintPlaneRotation: public TaskFemConstraint { Q_OBJECT @@ -52,15 +53,15 @@ private Q_SLOTS: void removeFromSelection(); protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; private: void updateUI(); std::unique_ptr ui; }; -class TaskDlgFemConstraintPlaneRotation : public TaskDlgFemConstraint +class TaskDlgFemConstraintPlaneRotation: public TaskDlgFemConstraint { Q_OBJECT @@ -72,6 +73,6 @@ public: bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintPlaneRotation_H +#endif // GUI_TASKVIEW_TaskFemConstraintPlaneRotation_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp index c17312ae44..dec2df4f65 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp @@ -24,9 +24,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif #include @@ -43,25 +43,34 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintPressure */ TaskFemConstraintPressure::TaskFemConstraintPressure( - ViewProviderFemConstraintPressure* ConstraintView, QWidget* parent) - : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintPressure"), - ui(new Ui_TaskFemConstraintPressure) -{ //Note change "pressure" in line above to new constraint name + ViewProviderFemConstraintPressure* ConstraintView, + QWidget* parent) + : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintPressure") + , ui(new Ui_TaskFemConstraintPressure) +{ // Note change "pressure" in line above to new constraint name proxy = new QWidget(this); ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); // create a context menu for the listview of the references createDeleteAction(ui->lw_references); - connect(deleteAction, &QAction::triggered, - this, &TaskFemConstraintPressure::onReferenceDeleted); - connect(ui->lw_references, &QListWidget::currentItemChanged, - this, &TaskFemConstraintPressure::setSelection); - connect(ui->lw_references, &QListWidget::itemClicked, - this, &TaskFemConstraintPressure::setSelection); + connect(deleteAction, + &QAction::triggered, + this, + &TaskFemConstraintPressure::onReferenceDeleted); + connect(ui->lw_references, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintPressure::setSelection); + connect(ui->lw_references, + &QListWidget::itemClicked, + this, + &TaskFemConstraintPressure::setSelection); - connect(ui->checkBoxReverse, &QCheckBox::toggled, - this, &TaskFemConstraintPressure::onCheckReverse); + connect(ui->checkBoxReverse, + &QCheckBox::toggled, + this, + &TaskFemConstraintPressure::onCheckReverse); this->groupLayout()->addWidget(proxy); @@ -91,7 +100,7 @@ TaskFemConstraintPressure::TaskFemConstraintPressure( ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); } - //Selection buttons + // Selection buttons buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd); buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove); @@ -119,7 +128,7 @@ void TaskFemConstraintPressure::onCheckReverse(const bool pressed) void TaskFemConstraintPressure::addToSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -129,7 +138,7 @@ void TaskFemConstraintPressure::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -137,7 +146,7 @@ void TaskFemConstraintPressure::addToSelection() const std::vector& subNames = it.getSubNames(); App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); @@ -148,13 +157,13 @@ void TaskFemConstraintPressure::addToSelection() itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } @@ -174,7 +183,7 @@ void TaskFemConstraintPressure::addToSelection() void TaskFemConstraintPressure::removeFromSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -184,7 +193,7 @@ void TaskFemConstraintPressure::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -192,19 +201,19 @@ void TaskFemConstraintPressure::removeFromSelection() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -228,7 +237,8 @@ void TaskFemConstraintPressure::removeFromSelection() updateUI(); } -void TaskFemConstraintPressure::onReferenceDeleted() { +void TaskFemConstraintPressure::onReferenceDeleted() +{ TaskFemConstraintPressure::removeFromSelection(); } @@ -261,15 +271,16 @@ bool TaskFemConstraintPressure::event(QEvent* e) } void TaskFemConstraintPressure::changeEvent(QEvent*) -{ -} +{} void TaskFemConstraintPressure::clearButtons(const SelectionChangeModes notThis) { - if (notThis != SelectionChangeModes::refAdd) + if (notThis != SelectionChangeModes::refAdd) { ui->btnAdd->setChecked(false); - if (notThis != SelectionChangeModes::refRemove) + } + if (notThis != SelectionChangeModes::refRemove) { ui->btnRemove->setChecked(false); + } } //************************************************************************** @@ -299,7 +310,7 @@ void TaskDlgFemConstraintPressure::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -319,11 +330,11 @@ bool TaskDlgFemConstraintPressure::accept() "App.ActiveDocument.%s.Reversed = %s", name.c_str(), parameterPressure->get_Reverse() ? "True" : "False"); - std::string scale = parameterPressure->getScale();// OvG: determine modified scale + std::string scale = parameterPressure->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPressure.h b/src/Mod/Fem/Gui/TaskFemConstraintPressure.h index fd27a34fa0..d540829388 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPressure.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintPressure.h @@ -26,8 +26,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintPressure_H #define GUI_TASKVIEW_TaskFemConstraintPressure_H -#include #include +#include #include "TaskFemConstraintOnBoundary.h" #include "ViewProviderFemConstraintPressure.h" @@ -35,8 +35,9 @@ class Ui_TaskFemConstraintPressure; -namespace FemGui { -class TaskFemConstraintPressure : public TaskFemConstraintOnBoundary +namespace FemGui +{ +class TaskFemConstraintPressure: public TaskFemConstraintOnBoundary { Q_OBJECT @@ -45,8 +46,8 @@ public: QWidget* parent = nullptr); ~TaskFemConstraintPressure() override; const std::string getReferences() const override; - double get_Pressure()const; - bool get_Reverse()const; + double get_Pressure() const; + bool get_Reverse() const; private Q_SLOTS: void onReferenceDeleted(); @@ -55,8 +56,8 @@ private Q_SLOTS: void removeFromSelection() override; protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void clearButtons(const SelectionChangeModes notThis) override; private: @@ -64,17 +65,17 @@ private: std::unique_ptr ui; }; -class TaskDlgFemConstraintPressure : public TaskDlgFemConstraint +class TaskDlgFemConstraintPressure: public TaskDlgFemConstraint { Q_OBJECT public: - explicit TaskDlgFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView); + explicit TaskDlgFemConstraintPressure(ViewProviderFemConstraintPressure* ConstraintView); void open() override; bool accept() override; bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintPressure_H +#endif // GUI_TASKVIEW_TaskFemConstraintPressure_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp index ec0d9b6d8d..a15cf6b11d 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp @@ -24,7 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -40,17 +40,26 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintPulley */ -TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley* ConstraintView, QWidget* parent) +TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley* ConstraintView, + QWidget* parent) : TaskFemConstraintGear(ConstraintView, parent, "FEM_ConstraintPulley") { - connect(ui->spinOtherDiameter, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintPulley::onOtherDiameterChanged); - connect(ui->spinCenterDistance, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintPulley::onCenterDistanceChanged); - connect(ui->checkIsDriven, &QCheckBox::toggled, - this, &TaskFemConstraintPulley::onCheckIsDriven); - connect(ui->spinTensionForce, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintPulley::onTensionForceChanged); + connect(ui->spinOtherDiameter, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskFemConstraintPulley::onOtherDiameterChanged); + connect(ui->spinCenterDistance, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskFemConstraintPulley::onCenterDistanceChanged); + connect(ui->checkIsDriven, + &QCheckBox::toggled, + this, + &TaskFemConstraintPulley::onCheckIsDriven); + connect(ui->spinTensionForce, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskFemConstraintPulley::onTensionForceChanged); // Temporarily prevent unnecessary feature recomputes ui->spinOtherDiameter->blockSignals(true); @@ -59,7 +68,8 @@ TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley ui->spinTensionForce->blockSignals(true); // Get the feature data - Fem::ConstraintPulley* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintPulley* pcConstraint = + static_cast(ConstraintView->getObject()); double otherdia = pcConstraint->OtherDiameter.getValue(); double centerdist = pcConstraint->CenterDistance.getValue(); bool isdriven = pcConstraint->IsDriven.getValue(); @@ -100,25 +110,29 @@ TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley void TaskFemConstraintPulley::onOtherDiameterChanged(double l) { - Fem::ConstraintPulley* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintPulley* pcConstraint = + static_cast(ConstraintView->getObject()); pcConstraint->OtherDiameter.setValue(l); } void TaskFemConstraintPulley::onCenterDistanceChanged(double l) { - Fem::ConstraintPulley* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintPulley* pcConstraint = + static_cast(ConstraintView->getObject()); pcConstraint->CenterDistance.setValue(l); } void TaskFemConstraintPulley::onTensionForceChanged(double force) { - Fem::ConstraintPulley* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintPulley* pcConstraint = + static_cast(ConstraintView->getObject()); pcConstraint->TensionForce.setValue(force); } void TaskFemConstraintPulley::onCheckIsDriven(const bool pressed) { - Fem::ConstraintPulley* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintPulley* pcConstraint = + static_cast(ConstraintView->getObject()); pcConstraint->IsDriven.setValue(pressed); } @@ -168,7 +182,8 @@ void TaskFemConstraintPulley::changeEvent(QEvent* e) // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgFemConstraintPulley::TaskDlgFemConstraintPulley(ViewProviderFemConstraintPulley* ConstraintView) +TaskDlgFemConstraintPulley::TaskDlgFemConstraintPulley( + ViewProviderFemConstraintPulley* ConstraintView) { this->ConstraintView = ConstraintView; assert(ConstraintView); @@ -186,21 +201,38 @@ void TaskDlgFemConstraintPulley::open() QString msg = QObject::tr("Constraint pulley"); Gui::Command::openCommand((const char*)msg.toUtf8()); ConstraintView->setVisible(true); - Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts + Gui::Command::doCommand( + Gui::Command::Doc, + ViewProviderFemConstraint::gethideMeshShowPartStr( + (static_cast(ConstraintView->getObject()))->getNameInDocument()) + .c_str()); // OvG: Hide meshes and show parts } } bool TaskDlgFemConstraintPulley::accept() { std::string name = ConstraintView->getObject()->getNameInDocument(); - const TaskFemConstraintPulley* parameterPulley = static_cast(parameter); + const TaskFemConstraintPulley* parameterPulley = + static_cast(parameter); try { - //Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "FEM pulley constraint changed")); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.OtherDiameter = %f", name.c_str(), parameterPulley->getOtherDiameter()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.CenterDistance = %f", name.c_str(), parameterPulley->getCenterDistance()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.IsDriven = %s", name.c_str(), parameterPulley->getIsDriven() ? "True" : "False"); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TensionForce = %f", name.c_str(), parameterPulley->getTensionForce()); + // Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "FEM pulley constraint changed")); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.OtherDiameter = %f", + name.c_str(), + parameterPulley->getOtherDiameter()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.CenterDistance = %f", + name.c_str(), + parameterPulley->getCenterDistance()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.IsDriven = %s", + name.c_str(), + parameterPulley->getIsDriven() ? "True" : "False"); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.TensionForce = %f", + name.c_str(), + parameterPulley->getTensionForce()); } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPulley.h b/src/Mod/Fem/Gui/TaskFemConstraintPulley.h index 7ca20d7e0d..c7ac7b0685 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPulley.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintPulley.h @@ -27,14 +27,16 @@ #include "TaskFemConstraintGear.h" #include "ViewProviderFemConstraintPulley.h" -namespace FemGui { +namespace FemGui +{ -class TaskFemConstraintPulley : public TaskFemConstraintGear +class TaskFemConstraintPulley: public TaskFemConstraintGear { Q_OBJECT public: - explicit TaskFemConstraintPulley(ViewProviderFemConstraintPulley *ConstraintView,QWidget *parent = nullptr); + explicit TaskFemConstraintPulley(ViewProviderFemConstraintPulley* ConstraintView, + QWidget* parent = nullptr); double getOtherDiameter() const; double getCenterDistance() const; @@ -49,22 +51,22 @@ private Q_SLOTS: void onCheckIsDriven(bool); protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent* e) override; }; /// simulation dialog for the TaskView -class TaskDlgFemConstraintPulley : public TaskDlgFemConstraintGear +class TaskDlgFemConstraintPulley: public TaskDlgFemConstraintGear { Q_OBJECT public: - explicit TaskDlgFemConstraintPulley(ViewProviderFemConstraintPulley *ConstraintView); + explicit TaskDlgFemConstraintPulley(ViewProviderFemConstraintPulley* ConstraintView); /// is called by the framework if the dialog is accepted (Ok) bool accept() override; void open() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintPulley_H +#endif // GUI_TASKVIEW_TaskFemConstraintPulley_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp b/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp index c3e4264db2..85eee0271a 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp @@ -24,9 +24,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif #include @@ -45,8 +45,8 @@ using namespace Gui; TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring* ConstraintView, QWidget* parent) - : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintSpring"), - ui(new Ui_TaskFemConstraintSpring) + : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintSpring") + , ui(new Ui_TaskFemConstraintSpring) { proxy = new QWidget(this); ui->setupUi(proxy); @@ -56,10 +56,14 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring createDeleteAction(ui->lw_references); connect(deleteAction, &QAction::triggered, this, &TaskFemConstraintSpring::onReferenceDeleted); - connect(ui->lw_references, &QListWidget::currentItemChanged, - this, &TaskFemConstraintSpring::setSelection); - connect(ui->lw_references, &QListWidget::itemClicked, - this, &TaskFemConstraintSpring::setSelection); + connect(ui->lw_references, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintSpring::setSelection); + connect(ui->lw_references, + &QListWidget::itemClicked, + this, + &TaskFemConstraintSpring::setSelection); this->groupLayout()->addWidget(proxy); @@ -74,7 +78,7 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring // Fill data into dialog elements ui->if_norm->setUnit(pcConstraint->NormalStiffness.getUnit()); ui->if_norm->setMinimum( - 0);// TODO fix this ------------------------------------------------------------------- + 0); // TODO fix this ------------------------------------------------------------------- ui->if_norm->setMaximum(FLOAT_MAX); Base::Quantity ns = Base::Quantity((pcConstraint->NormalStiffness.getValue()), Base::Unit::Stiffness); @@ -82,7 +86,7 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring ui->if_tan->setUnit(pcConstraint->TangentialStiffness.getUnit()); ui->if_tan->setMinimum( - 0);// TODO fix this ------------------------------------------------------------------- + 0); // TODO fix this ------------------------------------------------------------------- ui->if_tan->setMaximum(FLOAT_MAX); Base::Quantity ts = Base::Quantity((pcConstraint->TangentialStiffness.getValue()), Base::Unit::Stiffness); @@ -126,7 +130,7 @@ void TaskFemConstraintSpring::updateUI() void TaskFemConstraintSpring::addToSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -136,7 +140,7 @@ void TaskFemConstraintSpring::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -144,7 +148,7 @@ void TaskFemConstraintSpring::addToSelection() const std::vector& subNames = it.getSubNames(); App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); @@ -155,13 +159,13 @@ void TaskFemConstraintSpring::addToSelection() itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } @@ -181,7 +185,7 @@ void TaskFemConstraintSpring::addToSelection() void TaskFemConstraintSpring::removeFromSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -191,7 +195,7 @@ void TaskFemConstraintSpring::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -199,19 +203,19 @@ void TaskFemConstraintSpring::removeFromSelection() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -235,7 +239,8 @@ void TaskFemConstraintSpring::removeFromSelection() updateUI(); } -void TaskFemConstraintSpring::onReferenceDeleted() { +void TaskFemConstraintSpring::onReferenceDeleted() +{ TaskFemConstraintSpring::removeFromSelection(); } @@ -270,15 +275,16 @@ bool TaskFemConstraintSpring::event(QEvent* e) } void TaskFemConstraintSpring::changeEvent(QEvent*) -{ -} +{} void TaskFemConstraintSpring::clearButtons(const SelectionChangeModes notThis) { - if (notThis != SelectionChangeModes::refAdd) + if (notThis != SelectionChangeModes::refAdd) { ui->btnAdd->setChecked(false); - if (notThis != SelectionChangeModes::refRemove) + } + if (notThis != SelectionChangeModes::refRemove) { ui->btnRemove->setChecked(false); + } } //************************************************************************** @@ -308,7 +314,7 @@ void TaskDlgFemConstraintSpring::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -334,11 +340,11 @@ bool TaskDlgFemConstraintSpring::accept() "App.ActiveDocument.%s.ElmerStiffness = '%s'", name.c_str(), parameterStiffness->getElmerStiffness().c_str()); - std::string scale = parameterStiffness->getScale();// OvG: determine modified scale + std::string scale = parameterStiffness->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintSpring.h b/src/Mod/Fem/Gui/TaskFemConstraintSpring.h index 2bd95d68d2..9802c10d66 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintSpring.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintSpring.h @@ -24,8 +24,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintSpring_H #define GUI_TASKVIEW_TaskFemConstraintSpring_H -#include #include +#include #include "TaskFemConstraintOnBoundary.h" #include "ViewProviderFemConstraintSpring.h" @@ -33,8 +33,9 @@ class Ui_TaskFemConstraintSpring; -namespace FemGui { -class TaskFemConstraintSpring : public TaskFemConstraintOnBoundary +namespace FemGui +{ +class TaskFemConstraintSpring: public TaskFemConstraintOnBoundary { Q_OBJECT @@ -53,8 +54,8 @@ private Q_SLOTS: void removeFromSelection() override; protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void clearButtons(const SelectionChangeModes notThis) override; private: @@ -62,17 +63,17 @@ private: std::unique_ptr ui; }; -class TaskDlgFemConstraintSpring : public TaskDlgFemConstraint +class TaskDlgFemConstraintSpring: public TaskDlgFemConstraint { Q_OBJECT public: - explicit TaskDlgFemConstraintSpring(ViewProviderFemConstraintSpring *ConstraintView); + explicit TaskDlgFemConstraintSpring(ViewProviderFemConstraintSpring* ConstraintView); void open() override; bool accept() override; bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintSpring_H +#endif // GUI_TASKVIEW_TaskFemConstraintSpring_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp index cd87620454..7538833a80 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp @@ -26,9 +26,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif #include @@ -47,9 +47,10 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintTemperature */ TaskFemConstraintTemperature::TaskFemConstraintTemperature( - ViewProviderFemConstraintTemperature* ConstraintView, QWidget* parent) - : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintTemperature"), - ui(new Ui_TaskFemConstraintTemperature) + ViewProviderFemConstraintTemperature* ConstraintView, + QWidget* parent) + : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintTemperature") + , ui(new Ui_TaskFemConstraintTemperature) { proxy = new QWidget(this); ui->setupUi(proxy); @@ -94,8 +95,10 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature( // create a context menu for the listview of the references createDeleteAction(ui->lw_references); - connect( - deleteAction, &QAction::triggered, this, &TaskFemConstraintTemperature::onReferenceDeleted); + connect(deleteAction, + &QAction::triggered, + this, + &TaskFemConstraintTemperature::onReferenceDeleted); connect(ui->lw_references, &QListWidget::currentItemChanged, @@ -145,7 +148,7 @@ void TaskFemConstraintTemperature::Flux() void TaskFemConstraintTemperature::addToSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -155,7 +158,7 @@ void TaskFemConstraintTemperature::addToSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -163,20 +166,20 @@ void TaskFemConstraintTemperature::addToSelection() std::vector subNames = it.getSubNames(); App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it.getFeatName()); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } @@ -196,7 +199,7 @@ void TaskFemConstraintTemperature::addToSelection() void TaskFemConstraintTemperature::removeFromSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -206,7 +209,7 @@ void TaskFemConstraintTemperature::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -214,19 +217,19 @@ void TaskFemConstraintTemperature::removeFromSelection() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -250,7 +253,8 @@ void TaskFemConstraintTemperature::removeFromSelection() updateUI(); } -void TaskFemConstraintTemperature::onReferenceDeleted() { +void TaskFemConstraintTemperature::onReferenceDeleted() +{ TaskFemConstraintTemperature::removeFromSelection(); } @@ -304,10 +308,12 @@ void TaskFemConstraintTemperature::changeEvent(QEvent*) void TaskFemConstraintTemperature::clearButtons(const SelectionChangeModes notThis) { - if (notThis != SelectionChangeModes::refAdd) + if (notThis != SelectionChangeModes::refAdd) { ui->btnAdd->setChecked(false); - if (notThis != SelectionChangeModes::refRemove) + } + if (notThis != SelectionChangeModes::refRemove) { ui->btnRemove->setChecked(false); + } } //************************************************************************** @@ -337,7 +343,7 @@ void TaskDlgFemConstraintTemperature::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -351,24 +357,26 @@ bool TaskDlgFemConstraintTemperature::accept() try { Gui::Command::doCommand(Gui::Command::Doc, - "App.ActiveDocument.%s.ConstraintType = %s", - name.c_str(), - parameterTemperature->get_constraint_type().c_str()); - if (type == "Temperature") + "App.ActiveDocument.%s.ConstraintType = %s", + name.c_str(), + parameterTemperature->get_constraint_type().c_str()); + if (type == "Temperature") { Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Temperature = \"%s\"", name.c_str(), parameterTemperature->get_temperature().c_str()); - else if (type == "CFlux") + } + else if (type == "CFlux") { Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.CFlux = \"%s\"", name.c_str(), parameterTemperature->get_cflux().c_str()); - std::string scale = parameterTemperature->getScale();// OvG: determine modified scale + } + std::string scale = parameterTemperature->getScale(); // OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), - scale.c_str());// OvG: implement modified scale + scale.c_str()); // OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h index 6eb642d78d..fe57160456 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h @@ -26,8 +26,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintTemperature_H #define GUI_TASKVIEW_TaskFemConstraintTemperature_H -#include #include +#include #include #include @@ -38,13 +38,15 @@ class Ui_TaskFemConstraintTemperature; -namespace FemGui { -class TaskFemConstraintTemperature : public TaskFemConstraintOnBoundary +namespace FemGui +{ +class TaskFemConstraintTemperature: public TaskFemConstraintOnBoundary { Q_OBJECT public: - explicit TaskFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView,QWidget *parent = nullptr); + explicit TaskFemConstraintTemperature(ViewProviderFemConstraintTemperature* ConstraintView, + QWidget* parent = nullptr); ~TaskFemConstraintTemperature() override; const std::string getReferences() const override; std::string get_temperature() const; @@ -59,8 +61,8 @@ private Q_SLOTS: void removeFromSelection() override; protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void clearButtons(const SelectionChangeModes notThis) override; private: @@ -68,17 +70,17 @@ private: std::unique_ptr ui; }; -class TaskDlgFemConstraintTemperature : public TaskDlgFemConstraint +class TaskDlgFemConstraintTemperature: public TaskDlgFemConstraint { Q_OBJECT public: - explicit TaskDlgFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView); + explicit TaskDlgFemConstraintTemperature(ViewProviderFemConstraintTemperature* ConstraintView); void open() override; bool accept() override; bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintTemperature_H +#endif // GUI_TASKVIEW_TaskFemConstraintTemperature_H diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp b/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp index 6ff3e9bf65..08a0b49824 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp @@ -27,11 +27,11 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include #endif #include @@ -49,9 +49,10 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintTransform */ TaskFemConstraintTransform::TaskFemConstraintTransform( - ViewProviderFemConstraintTransform* ConstraintView, QWidget* parent) - : TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintTransform"), - ui(new Ui_TaskFemConstraintTransform) + ViewProviderFemConstraintTransform* ConstraintView, + QWidget* parent) + : TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintTransform") + , ui(new Ui_TaskFemConstraintTransform) { proxy = new QWidget(this); ui->setupUi(proxy); @@ -59,30 +60,46 @@ TaskFemConstraintTransform::TaskFemConstraintTransform( // create a context menu for the listview of the references createDeleteAction(ui->lw_Rect); - connect(deleteAction, &QAction::triggered, - this, &TaskFemConstraintTransform::onReferenceDeleted); + connect(deleteAction, + &QAction::triggered, + this, + &TaskFemConstraintTransform::onReferenceDeleted); // highlight seletcted list items in the model - connect(ui->lw_Rect, &QListWidget::currentItemChanged, - this, &TaskFemConstraintTransform::setSelection); - connect(ui->lw_Rect, &QListWidget::itemClicked, - this, &TaskFemConstraintTransform::setSelection); - connect(ui->lw_displobj_rect, &QListWidget::currentItemChanged, - this, &TaskFemConstraintTransform::setSelection); - connect(ui->lw_displobj_rect, &QListWidget::itemClicked, - this, &TaskFemConstraintTransform::setSelection); + connect(ui->lw_Rect, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintTransform::setSelection); + connect(ui->lw_Rect, + &QListWidget::itemClicked, + this, + &TaskFemConstraintTransform::setSelection); + connect(ui->lw_displobj_rect, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintTransform::setSelection); + connect(ui->lw_displobj_rect, + &QListWidget::itemClicked, + this, + &TaskFemConstraintTransform::setSelection); this->groupLayout()->addWidget(proxy); connect(ui->rb_rect, &QRadioButton::clicked, this, &TaskFemConstraintTransform::Rect); connect(ui->rb_cylin, &QRadioButton::clicked, this, &TaskFemConstraintTransform::Cyl); - connect(ui->sp_X, qOverload(&QuantitySpinBox::valueChanged), - this, &TaskFemConstraintTransform::x_Changed); - connect(ui->sp_Y, qOverload(&QuantitySpinBox::valueChanged), - this, &TaskFemConstraintTransform::y_Changed); - connect(ui->sp_Z, qOverload(&QuantitySpinBox::valueChanged), - this, &TaskFemConstraintTransform::z_Changed); + connect(ui->sp_X, + qOverload(&QuantitySpinBox::valueChanged), + this, + &TaskFemConstraintTransform::x_Changed); + connect(ui->sp_Y, + qOverload(&QuantitySpinBox::valueChanged), + this, + &TaskFemConstraintTransform::y_Changed); + connect(ui->sp_Z, + qOverload(&QuantitySpinBox::valueChanged), + this, + &TaskFemConstraintTransform::z_Changed); // Get the feature data Fem::ConstraintTransform* pcConstraint = @@ -262,22 +279,24 @@ void TaskFemConstraintTransform::addToSelection() { int rows = ui->lw_Rect->model()->rowCount(); std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; } if (rows == 1) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only one face for rectangular local coordinate system!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only one face for rectangular local coordinate system!")); Gui::Selection().clearSelection(); return; } if ((rows == 0) && (selection.size() >= 2)) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only one face for rectangular local coordinate system!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only one face for rectangular local coordinate system!")); Gui::Selection().clearSelection(); return; } @@ -289,7 +308,7 @@ void TaskFemConstraintTransform::addToSelection() std::vector ObjDispl = pcConstraint->RefDispl.getValues(); std::vector SubElemDispl = pcConstraint->RefDispl.getSubValues(); - for (auto & it : selection) {// for every selected object + for (auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -297,12 +316,13 @@ void TaskFemConstraintTransform::addToSelection() const std::vector& subNames = it.getSubNames(); App::DocumentObject* obj = it.getObject(); if (subNames.size() != 1) { - QMessageBox::warning( - this, tr("Selection error"), tr("Only one face for local coordinate system!")); + QMessageBox::warning(this, + tr("Selection error"), + tr("Only one face for local coordinate system!")); Gui::Selection().clearSelection(); return; } - for (const auto & subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element bool addMe = true; if (subName.substr(0, 4) != "Face") { QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked")); @@ -326,13 +346,13 @@ void TaskFemConstraintTransform::addToSelection() itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so don't add + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so don't add addMe = false; } } @@ -358,7 +378,8 @@ void TaskFemConstraintTransform::addToSelection() this, tr("Selection error"), tr("Only transformable faces can be selected! Apply displacement boundary " - "condition to surface first then apply local coordinate system to surface")); + "condition to surface first then apply local coordinate system to " + "surface")); Gui::Selection().clearSelection(); return; } @@ -375,7 +396,7 @@ void TaskFemConstraintTransform::addToSelection() double l = normal.z; // about Z-axis double about_z; - double mag_norm_z = sqrt(n * n + m * m);// normal vector mapped onto XY plane + double mag_norm_z = sqrt(n * n + m * m); // normal vector mapped onto XY plane if (mag_norm_z == 0) { about_z = 0; } @@ -395,7 +416,7 @@ void TaskFemConstraintTransform::addToSelection() about_x = 0; } else { - about_x = -(acos(l_p / mag_norm_x) * 180 / M_PI);// rotation to the Z axis + about_x = -(acos(l_p / mag_norm_x) * 180 / M_PI); // rotation to the Z axis } ui->sp_X->setValue(round(about_x)); ui->sp_Z->setValue(round(about_z)); @@ -405,7 +426,7 @@ void TaskFemConstraintTransform::addToSelection() void TaskFemConstraintTransform::removeFromSelection() { std::vector selection = - Gui::Selection().getSelectionEx();// gets vector of selected objects of active document + Gui::Selection().getSelectionEx(); // gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; @@ -415,7 +436,7 @@ void TaskFemConstraintTransform::removeFromSelection() std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (const auto & it : selection) {// for every selected object + for (const auto& it : selection) { // for every selected object if (!it.isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -423,19 +444,19 @@ void TaskFemConstraintTransform::removeFromSelection() const std::vector& subNames = it.getSubNames(); const App::DocumentObject* obj = it.getObject(); - for (const auto& subName : subNames) {// for every selected sub element + for (const auto& subName : subNames) { // for every selected sub element for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subName); itr != SubElements.end(); itr = std::find(++itr, SubElements.end(), - subName)) {// for every sub element in selection that - // matches one in old list + subName)) { // for every sub element in selection that + // matches one in old list if (obj == Objects[std::distance( SubElements.begin(), - itr)]) {// if selected sub element's object equals the one in old list then - // it was added before so mark for deletion + itr)]) { // if selected sub element's object equals the one in old list + // then it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -469,7 +490,8 @@ const std::string TaskFemConstraintTransform::getReferences() const return TaskFemConstraint::getReferences(items); } -void TaskFemConstraintTransform::onReferenceDeleted() { +void TaskFemConstraintTransform::onReferenceDeleted() +{ TaskFemConstraintTransform::removeFromSelection(); } @@ -480,7 +502,8 @@ std::string TaskFemConstraintTransform::getSurfaceReferences(std::string showCon doc = FreeCAD.ActiveDocument\n\ for obj in doc.Objects:\n\ if obj.isDerivedFrom(\"Fem::FemAnalysis\"):\n\ - if doc." + showConstr + " in obj.Group:\n\ + if doc." + + showConstr + " in obj.Group:\n\ analysis = obj\n\ A = []\n\ i = 0\n\ @@ -501,11 +524,15 @@ for member in analysis.Group:\n\ ss.append(member)\n\ i = i+1\n\ if i>0:\n\ - doc." + showConstr + ".RefDispl = [x]\n\ - doc." + showConstr + ".NameDispl = ss\n\ + doc." + + showConstr + ".RefDispl = [x]\n\ + doc." + + showConstr + ".NameDispl = ss\n\ else:\n\ - doc." + showConstr + ".RefDispl = None\n\ - doc." + showConstr + ".NameDispl = []\n"; + doc." + + showConstr + ".RefDispl = None\n\ + doc." + + showConstr + ".NameDispl = []\n"; } std::string TaskFemConstraintTransform::get_X_rot() const @@ -521,7 +548,8 @@ std::string TaskFemConstraintTransform::get_Z_rot() const return ui->sp_Z->value().getSafeUserString().toStdString(); } -std::string TaskFemConstraintTransform::get_transform_type() const { +std::string TaskFemConstraintTransform::get_transform_type() const +{ std::string transform; if (ui->rb_rect->isChecked()) { transform = "\"Rectangular\""; @@ -537,8 +565,8 @@ bool TaskFemConstraintTransform::event(QEvent* e) return TaskFemConstraint::KeyEvent(e); } -void TaskFemConstraintTransform::changeEvent(QEvent*) { -} +void TaskFemConstraintTransform::changeEvent(QEvent*) +{} //************************************************************************** // TaskDialog @@ -567,7 +595,7 @@ void TaskDlgFemConstraintTransform::open() Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr( (static_cast(ConstraintView->getObject()))->getNameInDocument()) - .c_str());// OvG: Hide meshes and show parts + .c_str()); // OvG: Hide meshes and show parts } } @@ -579,17 +607,27 @@ bool TaskDlgFemConstraintTransform::accept() static_cast(parameter); try { - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.X_rot = \"%s\"", - name.c_str(), parameters->get_X_rot().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Y_rot = \"%s\"", - name.c_str(), parameters->get_Y_rot().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Z_rot = \"%s\"", - name.c_str(), parameters->get_Z_rot().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TransformType = %s", - name.c_str(), parameters->get_transform_type().c_str()); - std::string scale = parameters->getScale();// OvG: determine modified scale - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", - name.c_str(), scale.c_str());// OvG: implement modified scale + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.X_rot = \"%s\"", + name.c_str(), + parameters->get_X_rot().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Y_rot = \"%s\"", + name.c_str(), + parameters->get_Y_rot().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Z_rot = \"%s\"", + name.c_str(), + parameters->get_Z_rot().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.TransformType = %s", + name.c_str(), + parameters->get_transform_type().c_str()); + std::string scale = parameters->getScale(); // OvG: determine modified scale + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Scale = %s", + name.c_str(), + scale.c_str()); // OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTransform.h b/src/Mod/Fem/Gui/TaskFemConstraintTransform.h index 504da18f31..a570128e9d 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTransform.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintTransform.h @@ -27,8 +27,8 @@ #ifndef GUI_TASKVIEW_TaskFemConstraintTransform_H #define GUI_TASKVIEW_TaskFemConstraintTransform_H -#include #include +#include #include "TaskFemConstraint.h" #include "ViewProviderFemConstraintTransform.h" @@ -36,8 +36,9 @@ class Ui_TaskFemConstraintTransform; -namespace FemGui { -class TaskFemConstraintTransform : public TaskFemConstraint +namespace FemGui +{ +class TaskFemConstraintTransform: public TaskFemConstraint { Q_OBJECT @@ -63,8 +64,8 @@ private Q_SLOTS: void z_Changed(int z); protected: - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; const QString makeText(const App::DocumentObject* obj) const; private: @@ -72,17 +73,17 @@ private: std::unique_ptr ui; }; -class TaskDlgFemConstraintTransform : public TaskDlgFemConstraint +class TaskDlgFemConstraintTransform: public TaskDlgFemConstraint { Q_OBJECT public: - explicit TaskDlgFemConstraintTransform(ViewProviderFemConstraintTransform *ConstraintView); + explicit TaskDlgFemConstraintTransform(ViewProviderFemConstraintTransform* ConstraintView); void open() override; bool accept() override; bool reject() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskFemConstraintTransform_H +#endif // GUI_TASKVIEW_TaskFemConstraintTransform_H diff --git a/src/Mod/Fem/Gui/TaskObjectName.cpp b/src/Mod/Fem/Gui/TaskObjectName.cpp index 8c725cab19..91560721f6 100644 --- a/src/Mod/Fem/Gui/TaskObjectName.cpp +++ b/src/Mod/Fem/Gui/TaskObjectName.cpp @@ -23,7 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -37,13 +37,10 @@ using namespace FemGui; using namespace Gui; -TaskObjectName::TaskObjectName(App::DocumentObject *pcObject,QWidget *parent) - : TaskBox(Gui::BitmapFactory().pixmap("FEM_CreateNodesSet"), - tr("TaskObjectName"), - true, - parent), - pcObject(pcObject), - ui(new Ui_TaskObjectName) +TaskObjectName::TaskObjectName(App::DocumentObject* pcObject, QWidget* parent) + : TaskBox(Gui::BitmapFactory().pixmap("FEM_CreateNodesSet"), tr("TaskObjectName"), true, parent) + , pcObject(pcObject) + , ui(new Ui_TaskObjectName) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -52,20 +49,23 @@ TaskObjectName::TaskObjectName(App::DocumentObject *pcObject,QWidget *parent) this->groupLayout()->addWidget(proxy); - QObject::connect( - ui->lineEdit_ObjectName, &QLineEdit::textChanged, this, &TaskObjectName::TextChanged); + QObject::connect(ui->lineEdit_ObjectName, + &QLineEdit::textChanged, + this, + &TaskObjectName::TextChanged); - if (strcmp(pcObject->Label.getValue(),"") != 0) + if (strcmp(pcObject->Label.getValue(), "") != 0) { ui->lineEdit_ObjectName->setText(QString::fromUtf8(pcObject->Label.getValue())); - else + } + else { ui->lineEdit_ObjectName->setText(QString::fromLatin1(pcObject->getNameInDocument())); - + } } -void TaskObjectName::TextChanged (const QString & text) +void TaskObjectName::TextChanged(const QString& text) { name = text.toUtf8().constData(); - //pcObject->Label.setValue(text.toUtf8()); + // pcObject->Label.setValue(text.toUtf8()); } TaskObjectName::~TaskObjectName() = default; diff --git a/src/Mod/Fem/Gui/TaskObjectName.h b/src/Mod/Fem/Gui/TaskObjectName.h index c812798745..17b087dc54 100644 --- a/src/Mod/Fem/Gui/TaskObjectName.h +++ b/src/Mod/Fem/Gui/TaskObjectName.h @@ -28,43 +28,44 @@ class Ui_TaskObjectName; -namespace App { +namespace App +{ class Property; class DocumentObject; -} +} // namespace App -namespace Gui { +namespace Gui +{ class ViewProvider; } -namespace FemGui { +namespace FemGui +{ - -class TaskObjectName : public Gui::TaskView::TaskBox +class TaskObjectName: public Gui::TaskView::TaskBox { Q_OBJECT public: - explicit TaskObjectName(App::DocumentObject *pcObject,QWidget *parent = nullptr); + explicit TaskObjectName(App::DocumentObject* pcObject, QWidget* parent = nullptr); ~TaskObjectName() override; std::string name; private Q_SLOTS: - void TextChanged ( const QString &); + void TextChanged(const QString&); protected: - App::DocumentObject *pcObject; + App::DocumentObject* pcObject; private: - private: QWidget* proxy; std::unique_ptr ui; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskObjectName_H +#endif // GUI_TASKVIEW_TaskObjectName_H diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index e1851748a5..caab82b88c 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -23,17 +23,17 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include -# include +#include -# include -# include -# include -# include +#include +#include +#include +#include #endif #include @@ -44,23 +44,23 @@ #include #include #include +#include #include #include #include -#include #include #include "ui_TaskPostClip.h" +#include "ui_TaskPostContours.h" #include "ui_TaskPostCut.h" #include "ui_TaskPostDataAlongLine.h" #include "ui_TaskPostDataAtPoint.h" #include "ui_TaskPostDisplay.h" #include "ui_TaskPostScalarClip.h" -#include "ui_TaskPostContours.h" #include "ui_TaskPostWarpVector.h" -#include "TaskPostBoxes.h" #include "FemSettings.h" +#include "TaskPostBoxes.h" #include "ViewProviderFemPostFilter.h" #include "ViewProviderFemPostFunction.h" #include "ViewProviderFemPostObject.h" @@ -71,8 +71,9 @@ using namespace Gui; // *************************************************************************** // point marker -PointMarker::PointMarker(Gui::View3DInventorViewer* iv, std::string ObjName) : view(iv), - vp(new ViewProviderPointMarker) +PointMarker::PointMarker(Gui::View3DInventorViewer* iv, std::string ObjName) + : view(iv) + , vp(new ViewProviderPointMarker) { view->addViewProvider(vp); m_name = ObjName; @@ -150,8 +151,9 @@ ViewProviderPointMarker::~ViewProviderPointMarker() // *************************************************************************** // data marker -DataMarker::DataMarker(Gui::View3DInventorViewer* iv, std::string ObjName) : view(iv), - vp(new ViewProviderDataMarker) +DataMarker::DataMarker(Gui::View3DInventorViewer* iv, std::string ObjName) + : view(iv) + , vp(new ViewProviderDataMarker) { view->addViewProvider(vp); m_name = ObjName; @@ -168,7 +170,6 @@ void DataMarker::addPoint(const SbVec3f& pt) int ct = countPoints(); vp->pCoords->point.set1Value(ct, pt); vp->pMarker->numPoints = ct + 1; - } int DataMarker::countPoints() const @@ -234,11 +235,13 @@ ViewProviderDataMarker::~ViewProviderDataMarker() // *************************************************************************** // main task dialog -TaskPostBox::TaskPostBox(Gui::ViewProviderDocumentObject* view, const QPixmap& icon, - const QString& title, QWidget* parent) - : TaskBox(icon, title, true, parent), - m_object(view->getObject()), - m_view(view) +TaskPostBox::TaskPostBox(Gui::ViewProviderDocumentObject* view, + const QPixmap& icon, + const QString& title, + QWidget* parent) + : TaskBox(icon, title, true, parent) + , m_object(view->getObject()) + , m_view(view) {} TaskPostBox::~TaskPostBox() = default; @@ -258,8 +261,9 @@ void TaskPostBox::recompute() { if (autoApply()) { App::Document* doc = getDocument(); - if (doc) + if (doc) { doc->recompute(); + } } } @@ -284,8 +288,8 @@ void TaskPostBox::updateEnumerationList(App::PropertyEnumeration& prop, QComboBo // *************************************************************************** // simulation dialog for the TaskView TaskDlgPost::TaskDlgPost(Gui::ViewProviderDocumentObject* view) - : TaskDialog(), - m_view(view) + : TaskDialog() + , m_view(view) { assert(view); } @@ -295,15 +299,18 @@ TaskDlgPost::~TaskDlgPost() = default; QDialogButtonBox::StandardButtons TaskDlgPost::getStandardButtons() const { - //check if we only have gui task boxes + // check if we only have gui task boxes bool guionly = true; - for (auto it : m_boxes) + for (auto it : m_boxes) { guionly = guionly && it->isGuiTaskOnly(); + } - if (!guionly) + if (!guionly) { return QDialogButtonBox::Apply | QDialogButtonBox::Ok | QDialogButtonBox::Cancel; - else + } + else { return QDialogButtonBox::Ok; + } } void TaskDlgPost::connectSlots() @@ -325,8 +332,10 @@ void TaskDlgPost::connectSlots() int indexSlot = dlg->metaObject()->indexOfSlot( QMetaObject::normalizedSignature("slotAddedFunction()")); if (indexSlot >= 0) { - connect(sender, sender->metaObject()->method(indexSignal), - dlg, dlg->metaObject()->method(indexSlot)); + connect(sender, + sender->metaObject()->method(indexSignal), + dlg, + dlg->metaObject()->method(indexSlot)); } } } @@ -347,16 +356,18 @@ void TaskDlgPost::open() void TaskDlgPost::clicked(int button) { - if (button == QDialogButtonBox::Apply) + if (button == QDialogButtonBox::Apply) { recompute(); + } } bool TaskDlgPost::accept() { try { std::vector::iterator it = m_boxes.begin(); - for (; it != m_boxes.end(); ++it) + for (; it != m_boxes.end(); ++it) { (*it)->applyPythonCode(); + } } catch (const Base::Exception& e) { QMessageBox::warning(nullptr, tr("Input error"), QString::fromLatin1(e.what())); @@ -384,19 +395,23 @@ void TaskDlgPost::recompute() } } -void TaskDlgPost::modifyStandardButtons(QDialogButtonBox* box) { +void TaskDlgPost::modifyStandardButtons(QDialogButtonBox* box) +{ - if (box->button(QDialogButtonBox::Apply)) + if (box->button(QDialogButtonBox::Apply)) { box->button(QDialogButtonBox::Apply)->setDefault(true); + } } // *************************************************************************** // box to set the coloring TaskPostDisplay::TaskPostDisplay(Gui::ViewProviderDocumentObject* view, QWidget* parent) - : TaskPostBox(view, Gui::BitmapFactory().pixmap("FEM_ResultShow"), tr("Result display options"), - parent), - ui(new Ui_TaskPostDisplay) + : TaskPostBox(view, + Gui::BitmapFactory().pixmap("FEM_ResultShow"), + tr("Result display options"), + parent) + , ui(new Ui_TaskPostDisplay) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -423,14 +438,22 @@ TaskPostDisplay::~TaskPostDisplay() = default; void TaskPostDisplay::setupConnections() { - connect(ui->Representation, qOverload(&QComboBox::activated), - this, &TaskPostDisplay::onRepresentationActivated); - connect(ui->Field, qOverload(&QComboBox::activated), - this, &TaskPostDisplay::onFieldActivated); - connect(ui->VectorMode, qOverload(&QComboBox::activated), - this, &TaskPostDisplay::onVectorModeActivated); - connect(ui->Transparency, &QSlider::valueChanged, - this, &TaskPostDisplay::onTransparencyValueChanged); + connect(ui->Representation, + qOverload(&QComboBox::activated), + this, + &TaskPostDisplay::onRepresentationActivated); + connect(ui->Field, + qOverload(&QComboBox::activated), + this, + &TaskPostDisplay::onFieldActivated); + connect(ui->VectorMode, + qOverload(&QComboBox::activated), + this, + &TaskPostDisplay::onVectorModeActivated); + connect(ui->Transparency, + &QSlider::valueChanged, + this, + &TaskPostDisplay::onTransparencyValueChanged); } void TaskPostDisplay::slotAddedFunction() @@ -456,7 +479,8 @@ void TaskPostDisplay::onVectorModeActivated(int i) getTypedView()->VectorMode.setValue(i); } -void TaskPostDisplay::onTransparencyValueChanged(int i) { +void TaskPostDisplay::onTransparencyValueChanged(int i) +{ getTypedView()->Transparency.setValue(i); ui->Transparency->setToolTip(QString::number(i) + QString::fromLatin1(" %")); @@ -471,12 +495,14 @@ void TaskPostDisplay::applyPythonCode() // *************************************************************************** // functions TaskPostFunction::TaskPostFunction(ViewProviderDocumentObject* view, QWidget* parent) - : TaskPostBox(view, Gui::BitmapFactory().pixmap("fem-post-geo-plane"), tr("Implicit function"), + : TaskPostBox(view, + Gui::BitmapFactory().pixmap("fem-post-geo-plane"), + tr("Implicit function"), parent) { assert(view->isDerivedFrom(ViewProviderFemPostFunction::getClassTypeId())); - //we load the views widget + // we load the views widget FunctionWidget* w = getTypedView()->createControlWidget(); w->setParent(this); w->setViewProvider(getTypedView()); @@ -487,7 +513,7 @@ TaskPostFunction::~TaskPostFunction() = default; void TaskPostFunction::applyPythonCode() { - //we apply the views widgets python code + // we apply the views widgets python code } @@ -499,13 +525,15 @@ void TaskPostFunction::applyPythonCode() // *************************************************************************** // data along line filter TaskPostDataAlongLine::TaskPostDataAlongLine(ViewProviderDocumentObject* view, QWidget* parent) - : TaskPostBox(view, Gui::BitmapFactory().pixmap("FEM_PostFilterDataAlongLine"), - tr("Data along a line options"), parent), - ui(new Ui_TaskPostDataAlongLine) + : TaskPostBox(view, + Gui::BitmapFactory().pixmap("FEM_PostFilterDataAlongLine"), + tr("Data along a line options"), + parent) + , ui(new Ui_TaskPostDataAlongLine) { assert(view->isDerivedFrom(ViewProviderFemPostDataAlongLine::getClassTypeId())); - //we load the views widget + // we load the views widget proxy = new QWidget(this); ui->setupUi(proxy); @@ -556,7 +584,7 @@ TaskPostDataAlongLine::TaskPostDataAlongLine(ViewProviderDocumentObject* view, Q setupConnectionsStep2(); - //update all fields + // update all fields updateEnumerationList(getTypedView()->DisplayMode, ui->Representation); updateEnumerationList(getTypedView()->Field, ui->Field); @@ -689,7 +717,11 @@ void TaskPostDataAlongLine::onCreatePlotClicked() recompute(); } -void TaskPostDataAlongLine::onChange(double x1, double y1, double z1, double x2, double y2, +void TaskPostDataAlongLine::onChange(double x1, + double y1, + double z1, + double x2, + double y2, double z2) { // call point1Changed only once @@ -859,13 +891,15 @@ plt.show()\n"; // *************************************************************************** // data at point filter TaskPostDataAtPoint::TaskPostDataAtPoint(ViewProviderDocumentObject* view, QWidget* parent) - : TaskPostBox(view, Gui::BitmapFactory().pixmap("FEM_PostFilterDataAtPoint"), - tr("Data at point options"), parent), - ui(new Ui_TaskPostDataAtPoint) + : TaskPostBox(view, + Gui::BitmapFactory().pixmap("FEM_PostFilterDataAtPoint"), + tr("Data at point options"), + parent) + , ui(new Ui_TaskPostDataAtPoint) { assert(view->isDerivedFrom(ViewProviderFemPostDataAtPoint::getClassTypeId())); - //we load the views widget + // we load the views widget proxy = new QWidget(this); ui->setupUi(proxy); setupConnections(); @@ -924,8 +958,9 @@ TaskPostDataAtPoint::TaskPostDataAtPoint(ViewProviderDocumentObject* view, QWidg TaskPostDataAtPoint::~TaskPostDataAtPoint() { App::Document* doc = getDocument(); - if (doc) + if (doc) { doc->recompute(); + } } void TaskPostDataAtPoint::setupConnections() @@ -1110,7 +1145,7 @@ void TaskPostDataAtPoint::onFieldActivated(int i) static_cast(getObject())->Unit.setValue("A/m^2"); } else if ((FieldName == "Displacement") || (FieldName == "Displacement Magnitude") - || (FieldName.find("displacement", 0) == 0)) {// Elmer name + || (FieldName.find("displacement", 0) == 0)) { // Elmer name static_cast(getObject())->Unit.setValue("m"); } else if (FieldName == "electric energy density") { @@ -1223,11 +1258,14 @@ std::string TaskPostDataAtPoint::toString(double val) const // *************************************************************************** // clip filter -TaskPostClip::TaskPostClip(ViewProviderDocumentObject* view, App::PropertyLink* function, +TaskPostClip::TaskPostClip(ViewProviderDocumentObject* view, + App::PropertyLink* function, QWidget* parent) - : TaskPostBox(view, Gui::BitmapFactory().pixmap("FEM_PostFilterClipRegion"), - tr("Clip region, choose implicit function"), parent), - ui(new Ui_TaskPostClip) + : TaskPostBox(view, + Gui::BitmapFactory().pixmap("FEM_PostFilterClipRegion"), + tr("Clip region, choose implicit function"), + parent) + , ui(new Ui_TaskPostClip) { assert(view->isDerivedFrom(ViewProviderFemPostClip::getClassTypeId())); assert(function); @@ -1235,27 +1273,28 @@ TaskPostClip::TaskPostClip(ViewProviderDocumentObject* view, App::PropertyLink* fwidget = nullptr; - //we load the views widget + // we load the views widget proxy = new QWidget(this); ui->setupUi(proxy); setupConnections(); this->groupLayout()->addWidget(proxy); - //the layout for the container widget + // the layout for the container widget QVBoxLayout* layout = new QVBoxLayout(); ui->Container->setLayout(layout); - //fill up the combo box with possible functions + // fill up the combo box with possible functions collectImplicitFunctions(); - //add the function creation command + // add the function creation command Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); Gui::Command* cmd = rcCmdMgr.getCommandByName("FEM_PostCreateFunctions"); - if (cmd && cmd->getAction()) + if (cmd && cmd->getAction()) { cmd->getAction()->addTo(ui->CreateButton); + } ui->CreateButton->setPopupMode(QToolButton::InstantPopup); - //load the default values + // load the default values ui->CutCells->setChecked( static_cast(getObject())->CutCells.getValue()); ui->InsideOut->setChecked( @@ -1274,14 +1313,8 @@ void TaskPostClip::setupConnections() qOverload(&QComboBox::currentIndexChanged), this, &TaskPostClip::onFunctionBoxCurrentIndexChanged); - connect(ui->InsideOut, - &QCheckBox::toggled, - this, - &TaskPostClip::onInsideOutToggled); - connect(ui->CutCells, - &QCheckBox::toggled, - this, - &TaskPostClip::onCutCellsToggled); + connect(ui->InsideOut, &QCheckBox::toggled, this, &TaskPostClip::onInsideOutToggled); + connect(ui->CutCells, &QCheckBox::toggled, this, &TaskPostClip::onCutCellsToggled); } void TaskPostClip::applyPythonCode() @@ -1293,7 +1326,8 @@ void TaskPostClip::collectImplicitFunctions() pipelines = getDocument()->getObjectsOfType(); if (!pipelines.empty()) { Fem::FemPostPipeline* pipeline = pipelines.front(); - if (pipeline->Functions.getValue() && pipeline->Functions.getValue()->getTypeId() + if (pipeline->Functions.getValue() + && pipeline->Functions.getValue()->getTypeId() == Fem::FemPostFunctionProvider::getClassTypeId()) { ui->FunctionBox->clear(); @@ -1306,8 +1340,9 @@ void TaskPostClip::collectImplicitFunctions() ->Functions.getValues(); for (std::size_t i = 0; i < funcs.size(); ++i) { items.push_back(QString::fromLatin1(funcs[i]->getNameInDocument())); - if (currentFunction == funcs[i]) + if (currentFunction == funcs[i]) { currentItem = i; + } } ui->FunctionBox->addItems(items); ui->FunctionBox->setCurrentIndex(currentItem); @@ -1323,8 +1358,9 @@ void TaskPostClip::onCreateButtonTriggered(QAction*) // if a new function was successfully added use it int indexCount = ui->FunctionBox->count(); - if (indexCount > currentItem + 1) + if (indexCount > currentItem + 1) { ui->FunctionBox->setCurrentIndex(indexCount - 1); + } // When the first function ever was added, a signal must be emitted if (numFuncs == 0) { @@ -1336,33 +1372,38 @@ void TaskPostClip::onCreateButtonTriggered(QAction*) void TaskPostClip::onFunctionBoxCurrentIndexChanged(int idx) { - //set the correct property + // set the correct property std::vector pipelines; pipelines = getDocument()->getObjectsOfType(); if (!pipelines.empty()) { Fem::FemPostPipeline* pipeline = pipelines.front(); - if (pipeline->Functions.getValue() && pipeline->Functions.getValue()->getTypeId() + if (pipeline->Functions.getValue() + && pipeline->Functions.getValue()->getTypeId() == Fem::FemPostFunctionProvider::getClassTypeId()) { const std::vector& funcs = static_cast(pipeline->Functions.getValue()) ->Functions.getValues(); - if (idx >= 0) + if (idx >= 0) { static_cast(getObject())->Function.setValue(funcs[idx]); - else + } + else { static_cast(getObject())->Function.setValue(nullptr); + } } } - //load the correct view + // load the correct view Fem::FemPostFunction* fobj = static_cast( static_cast(getObject())->Function.getValue()); Gui::ViewProvider* view = nullptr; - if (fobj) + if (fobj) { view = Gui::Application::Instance->getViewProvider(fobj); + } - if (fwidget) + if (fwidget) { fwidget->deleteLater(); + } if (view) { fwidget = static_cast(view)->createControlWidget(); @@ -1389,9 +1430,11 @@ void TaskPostClip::onInsideOutToggled(bool val) // *************************************************************************** // contours filter TaskPostContours::TaskPostContours(ViewProviderDocumentObject* view, QWidget* parent) - : TaskPostBox(view, Gui::BitmapFactory().pixmap("FEM_PostFilterContours"), - tr("Contours filter options"), parent), - ui(new Ui_TaskPostContours) + : TaskPostBox(view, + Gui::BitmapFactory().pixmap("FEM_PostFilterContours"), + tr("Contours filter options"), + parent) + , ui(new Ui_TaskPostContours) { assert(view->isDerivedFrom(ViewProviderFemPostContours::getClassTypeId())); @@ -1447,7 +1490,6 @@ void TaskPostContours::updateFields() else { getTypedView()->Field.setValue("None"); } - } void TaskPostContours::onFieldsChanged(int idx) @@ -1482,8 +1524,9 @@ void TaskPostContours::onVectorModeChanged(int idx) // first to get the possible VectorModes of that field updateFields(); // now we can set the VectorMode - if (!static_cast(getObject())->NoColor.getValue()) + if (!static_cast(getObject())->NoColor.getValue()) { getTypedView()->VectorMode.setValue(idx); + } } } @@ -1516,11 +1559,14 @@ void TaskPostContours::onNoColorChanged(bool state) // *************************************************************************** // cut filter -TaskPostCut::TaskPostCut(ViewProviderDocumentObject* view, App::PropertyLink* function, +TaskPostCut::TaskPostCut(ViewProviderDocumentObject* view, + App::PropertyLink* function, QWidget* parent) - : TaskPostBox(view, Gui::BitmapFactory().pixmap("FEM_PostFilterCutFunction"), - tr("Function cut, choose implicit function"), parent), - ui(new Ui_TaskPostCut) + : TaskPostBox(view, + Gui::BitmapFactory().pixmap("FEM_PostFilterCutFunction"), + tr("Function cut, choose implicit function"), + parent) + , ui(new Ui_TaskPostCut) { assert(view->isDerivedFrom(ViewProviderFemPostCut::getClassTypeId())); assert(function); @@ -1528,24 +1574,25 @@ TaskPostCut::TaskPostCut(ViewProviderDocumentObject* view, App::PropertyLink* fu fwidget = nullptr; - //we load the views widget + // we load the views widget proxy = new QWidget(this); ui->setupUi(proxy); setupConnections(); this->groupLayout()->addWidget(proxy); - //the layout for the container widget + // the layout for the container widget QVBoxLayout* layout = new QVBoxLayout(); ui->Container->setLayout(layout); - //fill up the combo box with possible functions + // fill up the combo box with possible functions collectImplicitFunctions(); - //add the function creation command + // add the function creation command Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); Gui::Command* cmd = rcCmdMgr.getCommandByName("FEM_PostCreateFunctions"); - if (cmd && cmd->getAction()) + if (cmd && cmd->getAction()) { cmd->getAction()->addTo(ui->CreateButton); + } ui->CreateButton->setPopupMode(QToolButton::InstantPopup); } @@ -1553,10 +1600,7 @@ TaskPostCut::~TaskPostCut() = default; void TaskPostCut::setupConnections() { - connect(ui->CreateButton, - &QToolButton::triggered, - this, - &TaskPostCut::onCreateButtonTriggered); + connect(ui->CreateButton, &QToolButton::triggered, this, &TaskPostCut::onCreateButtonTriggered); connect(ui->FunctionBox, qOverload(&QComboBox::currentIndexChanged), this, @@ -1586,8 +1630,9 @@ void TaskPostCut::collectImplicitFunctions() ->Functions.getValues(); for (std::size_t i = 0; i < funcs.size(); ++i) { items.push_back(QString::fromLatin1(funcs[i]->getNameInDocument())); - if (currentFunction == funcs[i]) + if (currentFunction == funcs[i]) { currentItem = i; + } } ui->FunctionBox->addItems(items); ui->FunctionBox->setCurrentIndex(currentItem); @@ -1603,8 +1648,9 @@ void TaskPostCut::onCreateButtonTriggered(QAction*) // if a new function was successfully added use it int indexCount = ui->FunctionBox->count(); - if (indexCount > currentItem + 1) + if (indexCount > currentItem + 1) { ui->FunctionBox->setCurrentIndex(indexCount - 1); + } // When the first function ever was added, a signal must be emitted if (numFuncs == 0) { @@ -1616,7 +1662,7 @@ void TaskPostCut::onCreateButtonTriggered(QAction*) void TaskPostCut::onFunctionBoxCurrentIndexChanged(int idx) { - //set the correct property + // set the correct property std::vector pipelines; pipelines = getDocument()->getObjectsOfType(); if (!pipelines.empty()) { @@ -1628,22 +1674,26 @@ void TaskPostCut::onFunctionBoxCurrentIndexChanged(int idx) const std::vector& funcs = static_cast(pipeline->Functions.getValue()) ->Functions.getValues(); - if (idx >= 0) + if (idx >= 0) { static_cast(getObject())->Function.setValue(funcs[idx]); - else + } + else { static_cast(getObject())->Function.setValue(nullptr); + } } } - //load the correct view + // load the correct view Fem::FemPostFunction* fobj = static_cast( static_cast(getObject())->Function.getValue()); Gui::ViewProvider* view = nullptr; - if (fobj) + if (fobj) { view = Gui::Application::Instance->getViewProvider(fobj); + } - if (fwidget) + if (fwidget) { fwidget->deleteLater(); + } if (view) { fwidget = static_cast(view)->createControlWidget(); @@ -1658,19 +1708,21 @@ void TaskPostCut::onFunctionBoxCurrentIndexChanged(int idx) // *************************************************************************** // scalar clip filter TaskPostScalarClip::TaskPostScalarClip(ViewProviderDocumentObject* view, QWidget* parent) - : TaskPostBox(view, Gui::BitmapFactory().pixmap("FEM_PostFilterClipScalar"), - tr("Scalar clip options"), parent), - ui(new Ui_TaskPostScalarClip) + : TaskPostBox(view, + Gui::BitmapFactory().pixmap("FEM_PostFilterClipScalar"), + tr("Scalar clip options"), + parent) + , ui(new Ui_TaskPostScalarClip) { assert(view->isDerivedFrom(ViewProviderFemPostScalarClip::getClassTypeId())); - //we load the views widget + // we load the views widget proxy = new QWidget(this); ui->setupUi(proxy); setupConnections(); this->groupLayout()->addWidget(proxy); - //load the default values + // load the default values updateEnumerationList(getTypedObject()->Scalars, ui->Scalar); ui->InsideOut->setChecked( static_cast(getObject())->InsideOut.getValue()); @@ -1695,18 +1747,16 @@ TaskPostScalarClip::TaskPostScalarClip(ViewProviderDocumentObject* view, QWidget ui->Slider->blockSignals(true); ui->Slider->setValue(slider_value); ui->Slider->blockSignals(false); - Base::Console().Log( - "init: scalar_factor, slider_value: %f, %i: \n", scalar_factor, slider_value); + Base::Console().Log("init: scalar_factor, slider_value: %f, %i: \n", + scalar_factor, + slider_value); } TaskPostScalarClip::~TaskPostScalarClip() = default; void TaskPostScalarClip::setupConnections() { - connect(ui->Slider, - &QSlider::valueChanged, - this, - &TaskPostScalarClip::onSliderValueChanged); + connect(ui->Slider, &QSlider::valueChanged, this, &TaskPostScalarClip::onSliderValueChanged); connect(ui->Value, qOverload(&QDoubleSpinBox::valueChanged), this, @@ -1715,10 +1765,7 @@ void TaskPostScalarClip::setupConnections() qOverload(&QComboBox::currentIndexChanged), this, &TaskPostScalarClip::onScalarCurrentIndexChanged); - connect(ui->InsideOut, - &QCheckBox::toggled, - this, - &TaskPostScalarClip::onInsideOutToggled); + connect(ui->InsideOut, &QCheckBox::toggled, this, &TaskPostScalarClip::onInsideOutToggled); } void TaskPostScalarClip::applyPythonCode() @@ -1761,7 +1808,7 @@ void TaskPostScalarClip::onSliderValueChanged(int v) value.setValue(val); recompute(); - //don't forget to sync the spinbox + // don't forget to sync the spinbox ui->Value->blockSignals(true); ui->Value->setValue(val); ui->Value->blockSignals(false); @@ -1774,7 +1821,7 @@ void TaskPostScalarClip::onValueValueChanged(double v) value.setValue(v); recompute(); - //don't forget to sync the slider + // don't forget to sync the slider ui->Slider->blockSignals(true); ui->Slider->setValue( int(((v - value.getConstraints()->LowerBound) @@ -1793,9 +1840,11 @@ void TaskPostScalarClip::onInsideOutToggled(bool val) // *************************************************************************** // warp vector filter TaskPostWarpVector::TaskPostWarpVector(ViewProviderDocumentObject* view, QWidget* parent) - : TaskPostBox(view, Gui::BitmapFactory().pixmap("FEM_PostFilterWarp"), tr("Warp options"), - parent), - ui(new Ui_TaskPostWarpVector) + : TaskPostBox(view, + Gui::BitmapFactory().pixmap("FEM_PostFilterWarp"), + tr("Warp options"), + parent) + , ui(new Ui_TaskPostWarpVector) { assert(view->isDerivedFrom(ViewProviderFemPostWarpVector::getClassTypeId())); @@ -1808,7 +1857,7 @@ TaskPostWarpVector::TaskPostWarpVector(ViewProviderDocumentObject* view, QWidget // load the default values for warp display updateEnumerationList(getTypedObject()->Vector, ui->Vector); double warp_factor = static_cast(getObject()) - ->Factor.getValue();// get the standard warp factor + ->Factor.getValue(); // get the standard warp factor // set spinbox warp_factor, don't forget to sync the slider ui->Value->blockSignals(true); @@ -1844,10 +1893,7 @@ TaskPostWarpVector::~TaskPostWarpVector() = default; void TaskPostWarpVector::setupConnections() { - connect(ui->Slider, - &QSlider::valueChanged, - this, - &TaskPostWarpVector::onSliderValueChanged); + connect(ui->Slider, &QSlider::valueChanged, this, &TaskPostWarpVector::onSliderValueChanged); connect(ui->Value, qOverload(&QDoubleSpinBox::valueChanged), this, diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.h b/src/Mod/Fem/Gui/TaskPostBoxes.h index 8ab3fc0b17..b4c6e1baae 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.h +++ b/src/Mod/Fem/Gui/TaskPostBoxes.h @@ -24,9 +24,9 @@ #define GUI_TASKVIEW_TaskPostDisplay_H #include -#include #include #include +#include #include "ViewProviderFemPostFunction.h" @@ -57,7 +57,7 @@ namespace FemGui // *************************************************************************** // point marker class ViewProviderPointMarker; -class PointMarker : public QObject +class PointMarker: public QObject { Q_OBJECT @@ -75,13 +75,13 @@ protected: void customEvent(QEvent* e) override; private: - Gui::View3DInventorViewer *view; - ViewProviderPointMarker *vp; + Gui::View3DInventorViewer* view; + ViewProviderPointMarker* vp; std::string m_name; std::string ObjectInvisible(); }; -class FemGuiExport ViewProviderPointMarker : public Gui::ViewProviderDocumentObject +class FemGuiExport ViewProviderPointMarker: public Gui::ViewProviderDocumentObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderPointMarker); @@ -90,7 +90,7 @@ public: ~ViewProviderPointMarker() override; protected: - SoCoordinate3 * pCoords; + SoCoordinate3* pCoords; friend class PointMarker; }; @@ -98,7 +98,7 @@ protected: // *************************************************************************** // data marker class ViewProviderDataMarker; -class DataMarker : public QObject +class DataMarker: public QObject { Q_OBJECT @@ -116,14 +116,14 @@ protected: void customEvent(QEvent* e) override; private: - Gui::View3DInventorViewer *view; - ViewProviderDataMarker *vp; + Gui::View3DInventorViewer* view; + ViewProviderDataMarker* vp; std::string m_name; std::string ObjectInvisible(); }; -class FemGuiExport ViewProviderDataMarker : public Gui::ViewProviderDocumentObject +class FemGuiExport ViewProviderDataMarker: public Gui::ViewProviderDocumentObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderDataMarker); @@ -132,41 +132,48 @@ public: ~ViewProviderDataMarker() override; protected: - SoCoordinate3 * pCoords; - SoMarkerSet * pMarker; + SoCoordinate3* pCoords; + SoMarkerSet* pMarker; friend class DataMarker; }; // *************************************************************************** // main task dialog -class TaskPostBox : public Gui::TaskView::TaskBox +class TaskPostBox: public Gui::TaskView::TaskBox { Q_OBJECT public: - TaskPostBox(Gui::ViewProviderDocumentObject* view, const QPixmap& icon, const QString& title, + TaskPostBox(Gui::ViewProviderDocumentObject* view, + const QPixmap& icon, + const QString& title, QWidget* parent = nullptr); ~TaskPostBox() override; virtual void applyPythonCode() = 0; - virtual bool isGuiTaskOnly() { + virtual bool isGuiTaskOnly() + { return false; - } // return true if only gui properties are manipulated + } // return true if only gui properties are manipulated protected: - App::DocumentObject* getObject() const { + App::DocumentObject* getObject() const + { return *m_object; } template - T* getTypedObject() const { + T* getTypedObject() const + { return m_object.get(); } - Gui::ViewProviderDocumentObject* getView() const { + Gui::ViewProviderDocumentObject* getView() const + { return *m_view; } template - T* getTypedView() const { + T* getTypedView() const + { return m_view.get(); } @@ -179,23 +186,24 @@ protected: private: App::DocumentObjectWeakPtrT m_object; - Gui::ViewProviderWeakPtrT m_view; + Gui::ViewProviderWeakPtrT m_view; }; // *************************************************************************** // simulation dialog for the TaskView -class TaskDlgPost : public Gui::TaskView::TaskDialog +class TaskDlgPost: public Gui::TaskView::TaskDialog { Q_OBJECT public: - explicit TaskDlgPost(Gui::ViewProviderDocumentObject *view); + explicit TaskDlgPost(Gui::ViewProviderDocumentObject* view); ~TaskDlgPost() override; void connectSlots(); void appendBox(TaskPostBox* box); - Gui::ViewProviderDocumentObject* getView() const { + Gui::ViewProviderDocumentObject* getView() const + { return *m_view; } @@ -210,7 +218,9 @@ public: bool reject() override; /// is called by the framework if the user presses the help button bool isAllowedAlterDocument() const override - { return false; } + { + return false; + } void modifyStandardButtons(QDialogButtonBox*) override; /// returns for Close and Help button @@ -220,23 +230,26 @@ protected: void recompute(); protected: - Gui::ViewProviderWeakPtrT m_view; - std::vector m_boxes; + Gui::ViewProviderWeakPtrT m_view; + std::vector m_boxes; }; // *************************************************************************** // box to set the coloring -class TaskPostDisplay : public TaskPostBox +class TaskPostDisplay: public TaskPostBox { Q_OBJECT public: - explicit TaskPostDisplay(Gui::ViewProviderDocumentObject* view, QWidget *parent = nullptr); + explicit TaskPostDisplay(Gui::ViewProviderDocumentObject* view, QWidget* parent = nullptr); ~TaskPostDisplay() override; void applyPythonCode() override; - bool isGuiTaskOnly() override {return true;} + bool isGuiTaskOnly() override + { + return true; + } private: void setupConnections(); @@ -254,7 +267,7 @@ private: // *************************************************************************** // functions -class TaskPostFunction : public TaskPostBox +class TaskPostFunction: public TaskPostBox { Q_OBJECT @@ -337,12 +350,13 @@ private: // *************************************************************************** // clip filter -class TaskPostClip : public TaskPostBox +class TaskPostClip: public TaskPostBox { Q_OBJECT public: - TaskPostClip(Gui::ViewProviderDocumentObject* view, App::PropertyLink* function, + TaskPostClip(Gui::ViewProviderDocumentObject* view, + App::PropertyLink* function, QWidget* parent = nullptr); ~TaskPostClip() override; @@ -361,7 +375,7 @@ Q_SIGNALS: private: void collectImplicitFunctions(); - //App::PropertyLink* m_functionProperty; + // App::PropertyLink* m_functionProperty; QWidget* proxy; std::unique_ptr ui; FunctionWidget* fwidget; @@ -401,7 +415,8 @@ class TaskPostCut: public TaskPostBox Q_OBJECT public: - TaskPostCut(Gui::ViewProviderDocumentObject* view, App::PropertyLink* function, + TaskPostCut(Gui::ViewProviderDocumentObject* view, + App::PropertyLink* function, QWidget* parent = nullptr); ~TaskPostCut() override; @@ -418,7 +433,7 @@ Q_SIGNALS: private: void collectImplicitFunctions(); - //App::PropertyLink* m_functionProperty; + // App::PropertyLink* m_functionProperty; QWidget* proxy; std::unique_ptr ui; FunctionWidget* fwidget; @@ -427,7 +442,7 @@ private: // *************************************************************************** // scalar clip filter -class TaskPostScalarClip : public TaskPostBox +class TaskPostScalarClip: public TaskPostBox { Q_OBJECT @@ -452,7 +467,7 @@ private: // *************************************************************************** // warp vector filter -class TaskPostWarpVector : public TaskPostBox +class TaskPostWarpVector: public TaskPostBox { Q_OBJECT @@ -475,6 +490,6 @@ private: std::unique_ptr ui; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_TASKVIEW_TaskPostDisplay_H +#endif // GUI_TASKVIEW_TaskPostDisplay_H diff --git a/src/Mod/Fem/Gui/TaskTetParameter.cpp b/src/Mod/Fem/Gui/TaskTetParameter.cpp index 3451a5f0fc..52b06a233c 100644 --- a/src/Mod/Fem/Gui/TaskTetParameter.cpp +++ b/src/Mod/Fem/Gui/TaskTetParameter.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -37,9 +37,9 @@ using namespace FemGui; using namespace Gui; TaskTetParameter::TaskTetParameter(Fem::FemMeshShapeNetgenObject* pcObject, QWidget* parent) - : TaskBox(Gui::BitmapFactory().pixmap("FEM_CreateNodesSet"), tr("Tet Parameter"), true, parent), - pcObject(pcObject), - ui(new Ui_TaskTetParameter) + : TaskBox(Gui::BitmapFactory().pixmap("FEM_CreateNodesSet"), tr("Tet Parameter"), true, parent) + , pcObject(pcObject) + , ui(new Ui_TaskTetParameter) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -56,25 +56,41 @@ TaskTetParameter::TaskTetParameter(Fem::FemMeshShapeNetgenObject* pcObject, QWid ui->spinBox_SegsPerRadius->setValue(pcObject->NbSegsPerRadius.getValue()); ui->checkBox_Optimize->setChecked(pcObject->Optimize.getValue()); - QObject::connect(ui->doubleSpinBox_MaxSize, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskTetParameter::maxSizeValueChanged); - QObject::connect(ui->comboBox_Fineness, qOverload(&QComboBox::activated), - this, &TaskTetParameter::SwitchMethod); - QObject::connect(ui->checkBox_SecondOrder, &QCheckBox::stateChanged, - this, &TaskTetParameter::setQuadric); - QObject::connect(ui->doubleSpinBox_GrowthRate, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskTetParameter::setGrowthRate); - QObject::connect(ui->spinBox_SegsPerEdge, qOverload(&QSpinBox::valueChanged), - this, &TaskTetParameter::setSegsPerEdge); - QObject::connect(ui->spinBox_SegsPerRadius, qOverload(&QSpinBox::valueChanged), - this, &TaskTetParameter::setSegsPerRadius); - QObject::connect(ui->checkBox_Optimize, &QCheckBox::stateChanged, - this, &TaskTetParameter::setOptimize); + QObject::connect(ui->doubleSpinBox_MaxSize, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskTetParameter::maxSizeValueChanged); + QObject::connect(ui->comboBox_Fineness, + qOverload(&QComboBox::activated), + this, + &TaskTetParameter::SwitchMethod); + QObject::connect(ui->checkBox_SecondOrder, + &QCheckBox::stateChanged, + this, + &TaskTetParameter::setQuadric); + QObject::connect(ui->doubleSpinBox_GrowthRate, + qOverload(&QDoubleSpinBox::valueChanged), + this, + &TaskTetParameter::setGrowthRate); + QObject::connect(ui->spinBox_SegsPerEdge, + qOverload(&QSpinBox::valueChanged), + this, + &TaskTetParameter::setSegsPerEdge); + QObject::connect(ui->spinBox_SegsPerRadius, + qOverload(&QSpinBox::valueChanged), + this, + &TaskTetParameter::setSegsPerRadius); + QObject::connect(ui->checkBox_Optimize, + &QCheckBox::stateChanged, + this, + &TaskTetParameter::setOptimize); - if(pcObject->FemMesh.getValue().getInfo().numNode == 0) + if (pcObject->FemMesh.getValue().getInfo().numNode == 0) { touched = true; - else + } + else { touched = false; + } setInfo(); } @@ -106,7 +122,7 @@ void TaskTetParameter::maxSizeValueChanged(double Value) void TaskTetParameter::setQuadric(int s) { - pcObject->SecondOrder.setValue(s!=0); + pcObject->SecondOrder.setValue(s != 0); touched = true; } @@ -114,14 +130,12 @@ void TaskTetParameter::setGrowthRate(double v) { pcObject->GrowthRate.setValue(v); touched = true; - } void TaskTetParameter::setSegsPerEdge(int v) { pcObject->NbSegsPerEdge.setValue(v); touched = true; - } void TaskTetParameter::setSegsPerRadius(int v) @@ -132,7 +146,7 @@ void TaskTetParameter::setSegsPerRadius(int v) void TaskTetParameter::setOptimize(int v) { - pcObject->Optimize.setValue(v!=0); + pcObject->Optimize.setValue(v != 0); touched = true; } @@ -140,10 +154,10 @@ void TaskTetParameter::setOptimize(int v) void TaskTetParameter::setInfo() { Fem::FemMesh::FemMeshInfo info = pcObject->FemMesh.getValue().getInfo(); - //Base::BoundBox3d bndBox = pcObject->FemMesh.getValue().getBoundBox(); - ui->lineEdit_InfoNodes ->setText(QString::number(info.numNode)); - ui->lineEdit_InfoTriangle ->setText(QString::number(info.numFaces)); - ui->lineEdit_InfoTet ->setText(QString::number(info.numTetr)); + // Base::BoundBox3d bndBox = pcObject->FemMesh.getValue().getBoundBox(); + ui->lineEdit_InfoNodes->setText(QString::number(info.numNode)); + ui->lineEdit_InfoTriangle->setText(QString::number(info.numFaces)); + ui->lineEdit_InfoTet->setText(QString::number(info.numTetr)); } diff --git a/src/Mod/Fem/Gui/TaskTetParameter.h b/src/Mod/Fem/Gui/TaskTetParameter.h index 9de4878727..08809f6543 100644 --- a/src/Mod/Fem/Gui/TaskTetParameter.h +++ b/src/Mod/Fem/Gui/TaskTetParameter.h @@ -30,32 +30,37 @@ class Ui_TaskTetParameter; class SoEventCallback; -namespace Base { +namespace Base +{ class Polygon2d; } -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; class ViewVolumeProjection; -} -namespace Fem{ - class FemMeshShapeNetgenObject; +} // namespace Gui +namespace Fem +{ +class FemMeshShapeNetgenObject; } -namespace FemGui { +namespace FemGui +{ class ViewProviderFemMeshShapeNetgen; -class TaskTetParameter : public Gui::TaskView::TaskBox +class TaskTetParameter: public Gui::TaskView::TaskBox { Q_OBJECT public: - explicit TaskTetParameter(Fem::FemMeshShapeNetgenObject *pcObject,QWidget *parent = nullptr); + explicit TaskTetParameter(Fem::FemMeshShapeNetgenObject* pcObject, QWidget* parent = nullptr); ~TaskTetParameter() override; void setInfo(); @@ -71,13 +76,13 @@ private Q_SLOTS: void setOptimize(int v); protected: - Fem::FemMeshShapeNetgenObject *pcObject; + Fem::FemMeshShapeNetgenObject* pcObject; private: QWidget* proxy; std::unique_ptr ui; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEMGUI_TaskTetParameter_H +#endif // FEMGUI_TaskTetParameter_H diff --git a/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp b/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp index 8833bc0c36..b1b9c051e2 100644 --- a/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp +++ b/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp @@ -23,12 +23,12 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include #endif #include @@ -50,11 +50,11 @@ #include #include #ifdef FC_USE_VTK -# include +#include #endif -#include "ViewProviderAnalysis.h" #include "TaskDlgAnalysis.h" +#include "ViewProviderAnalysis.h" using namespace FemGui; @@ -70,13 +70,13 @@ ViewProviderFemHighlighter::~ViewProviderFemHighlighter() annotate->unref(); } -void ViewProviderFemHighlighter::attach(ViewProviderFemAnalysis *view) +void ViewProviderFemHighlighter::attach(ViewProviderFemAnalysis* view) { - SoGroup *root = view->getRoot(); + SoGroup* root = view->getRoot(); root->addChild(annotate); } -void ViewProviderFemHighlighter::highlightView(Gui::ViewProviderDocumentObject *view) +void ViewProviderFemHighlighter::highlightView(Gui::ViewProviderDocumentObject* view) { annotate->removeAllChildren(); @@ -99,18 +99,18 @@ ViewProviderFemAnalysis::ViewProviderFemAnalysis() ViewProviderFemAnalysis::~ViewProviderFemAnalysis() = default; -void ViewProviderFemAnalysis::attach(App::DocumentObject *obj) +void ViewProviderFemAnalysis::attach(App::DocumentObject* obj) { Gui::ViewProviderDocumentObjectGroup::attach(obj); extension.attach(this); // activate analysis if currently active workbench is FEM - auto *workbench = Gui::WorkbenchManager::instance()->active(); + auto* workbench = Gui::WorkbenchManager::instance()->active(); if (workbench->name() == "FemWorkbench") { doubleClicked(); } } -void ViewProviderFemAnalysis::highlightView(Gui::ViewProviderDocumentObject *view) +void ViewProviderFemAnalysis::highlightView(Gui::ViewProviderDocumentObject* view) { extension.highlightView(view); } @@ -130,12 +130,12 @@ bool ViewProviderFemAnalysis::doubleClicked() // necessary for the workflow with new files to add a solver as next object std::vector selVector {}; selVector.push_back(this->getObject()); - auto *docName = this->getObject()->getDocument()->getName(); + auto* docName = this->getObject()->getDocument()->getName(); Gui::Selection().setSelection(docName, selVector); return true; } -std::vector ViewProviderFemAnalysis::claimChildren() const +std::vector ViewProviderFemAnalysis::claimChildren() const { return Gui::ViewProviderDocumentObjectGroup::claimChildren(); } @@ -155,46 +155,46 @@ void ViewProviderFemAnalysis::show() Gui::ViewProviderDocumentObjectGroup::show(); } -void ViewProviderFemAnalysis::setupContextMenu(QMenu *menu, QObject *, const char *) +void ViewProviderFemAnalysis::setupContextMenu(QMenu* menu, QObject*, const char*) { - Gui::ActionFunction *func = new Gui::ActionFunction(menu); - QAction *act = menu->addAction(tr("Activate analysis")); - func->trigger(act, [this](){ + Gui::ActionFunction* func = new Gui::ActionFunction(menu); + QAction* act = menu->addAction(tr("Activate analysis")); + func->trigger(act, [this]() { this->doubleClicked(); }); } bool ViewProviderFemAnalysis::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { + if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this pad the object // unsets and sets its edit mode without closing the task panel - //Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - //TaskDlgAnalysis *anaDlg = qobject_cast(dlg); - //if (padDlg && anaDlg->getPadView() != this) - // padDlg = 0; // another pad left open its task panel - //if (dlg && !padDlg) { - // QMessageBox msgBox; - // msgBox.setText(QObject::tr("A dialog is already open in the task panel")); - // msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); - // msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - // msgBox.setDefaultButton(QMessageBox::Yes); - // int ret = msgBox.exec(); - // if (ret == QMessageBox::Yes) - // Gui::Control().closeDialog(); - // else - // return false; - //} + // Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + // TaskDlgAnalysis *anaDlg = qobject_cast(dlg); + // if (padDlg && anaDlg->getPadView() != this) + // padDlg = 0; // another pad left open its task panel + // if (dlg && !padDlg) { + // QMessageBox msgBox; + // msgBox.setText(QObject::tr("A dialog is already open in the task panel")); + // msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); + // msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + // msgBox.setDefaultButton(QMessageBox::Yes); + // int ret = msgBox.exec(); + // if (ret == QMessageBox::Yes) + // Gui::Control().closeDialog(); + // else + // return false; + // } // start the edit dialog -// if (padDlg) -// Gui::Control().showDialog(padDlg); -// else + // if (padDlg) + // Gui::Control().showDialog(padDlg); + // else - //Fem::FemAnalysis* pcAna = static_cast(this->getObject()); - //Gui::Control().showDialog(new TaskDlgAnalysis(pcAna)); - //return true; + // Fem::FemAnalysis* pcAna = static_cast(this->getObject()); + // Gui::Control().showDialog(new TaskDlgAnalysis(pcAna)); + // return true; return false; } else { @@ -218,35 +218,46 @@ bool ViewProviderFemAnalysis::canDragObjects() const return true; } -bool ViewProviderFemAnalysis::canDragObject(App::DocumentObject *obj) const +bool ViewProviderFemAnalysis::canDragObject(App::DocumentObject* obj) const { - if (!obj) + if (!obj) { return false; - if (obj->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) + } + if (obj->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) { return true; - else if (obj->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) + } + else if (obj->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) { return true; - else if (obj->getTypeId().isDerivedFrom(Fem::FemResultObject::getClassTypeId())) + } + else if (obj->getTypeId().isDerivedFrom(Fem::FemResultObject::getClassTypeId())) { return true; - else if (obj->getTypeId().isDerivedFrom(Fem::Constraint::getClassTypeId())) + } + else if (obj->getTypeId().isDerivedFrom(Fem::Constraint::getClassTypeId())) { return true; - else if (obj->getTypeId().isDerivedFrom(Fem::FemSetObject::getClassTypeId())) + } + else if (obj->getTypeId().isDerivedFrom(Fem::FemSetObject::getClassTypeId())) { return true; - else if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FeaturePython"))) + } + else if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FeaturePython"))) { return true; - else if (obj->getTypeId().isDerivedFrom(App::MaterialObject::getClassTypeId())) + } + else if (obj->getTypeId().isDerivedFrom(App::MaterialObject::getClassTypeId())) { return true; - else if (obj->getTypeId().isDerivedFrom(App::TextDocument::getClassTypeId())) + } + else if (obj->getTypeId().isDerivedFrom(App::TextDocument::getClassTypeId())) { return true; + } #ifdef FC_USE_VTK - else if (obj->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) + else if (obj->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { return true; + } #endif - else + else { return false; + } } -void ViewProviderFemAnalysis::dragObject(App::DocumentObject *obj) +void ViewProviderFemAnalysis::dragObject(App::DocumentObject* obj) { ViewProviderDocumentObjectGroup::dragObject(obj); } @@ -256,17 +267,17 @@ bool ViewProviderFemAnalysis::canDropObjects() const return true; } -bool ViewProviderFemAnalysis::canDropObject(App::DocumentObject *obj) const +bool ViewProviderFemAnalysis::canDropObject(App::DocumentObject* obj) const { return canDragObject(obj); } -void ViewProviderFemAnalysis::dropObject(App::DocumentObject *obj) +void ViewProviderFemAnalysis::dropObject(App::DocumentObject* obj) { ViewProviderDocumentObjectGroup::dropObject(obj); } -bool ViewProviderFemAnalysis::onDelete(const std::vector &) +bool ViewProviderFemAnalysis::onDelete(const std::vector&) { // warn the user if the object has unselected children auto objs = claimChildren(); @@ -274,7 +285,8 @@ bool ViewProviderFemAnalysis::onDelete(const std::vector &) } bool ViewProviderFemAnalysis::checkSelectedChildren(const std::vector objs, - Gui::Document* docGui, std::string objectName) + Gui::Document* docGui, + std::string objectName) { // warn the user if the object has unselected children if (!objs.empty()) { @@ -290,37 +302,47 @@ bool ViewProviderFemAnalysis::checkSelectedChildren(const std::vectortranslate("Std_Delete", - ("The " + objectName + " is not empty, therefore the\nfollowing " - "referencing objects might be lost:").c_str()); + ("The " + objectName + + " is not empty, therefore the\nfollowing " + "referencing objects might be lost:") + .c_str()); bodyMessageStream << '\n'; - for (auto ObjIterator : objs) + for (auto ObjIterator : objs) { bodyMessageStream << '\n' << QString::fromUtf8(ObjIterator->Label.getValue()); + } bodyMessageStream << "\n\n" << QObject::tr("Are you sure you want to continue?"); // show and evaluate the dialog - int DialogResult = QMessageBox::warning(Gui::getMainWindow(), - qApp->translate("Std_Delete", "Object dependencies"), bodyMessage, - QMessageBox::Yes, QMessageBox::No); - if (DialogResult == QMessageBox::Yes) + int DialogResult = + QMessageBox::warning(Gui::getMainWindow(), + qApp->translate("Std_Delete", "Object dependencies"), + bodyMessage, + QMessageBox::Yes, + QMessageBox::No); + if (DialogResult == QMessageBox::Yes) { return true; - else + } + else { return false; + } } else { return true; } } -bool ViewProviderFemAnalysis::canDelete(App::DocumentObject *obj) const +bool ViewProviderFemAnalysis::canDelete(App::DocumentObject* obj) const { // deletions of objects from a FemAnalysis don't necessarily destroy anything // thus we can pass this action @@ -339,4 +361,4 @@ PROPERTY_SOURCE_TEMPLATE(FemGui::ViewProviderFemAnalysisPython, FemGui::ViewProv // explicit template instantiation template class FemGuiExport ViewProviderPythonFeatureT; -} // namespace Gui +} // namespace Gui diff --git a/src/Mod/Fem/Gui/ViewProviderAnalysis.h b/src/Mod/Fem/Gui/ViewProviderAnalysis.h index 4f62db2a8d..011d0ad903 100644 --- a/src/Mod/Fem/Gui/ViewProviderAnalysis.h +++ b/src/Mod/Fem/Gui/ViewProviderAnalysis.h @@ -37,7 +37,7 @@ class ViewProviderFemHighlighter public: /// Constructor ViewProviderFemHighlighter(); - ~ViewProviderFemHighlighter(); + ~ViewProviderFemHighlighter(); void attach(ViewProviderFemAnalysis*); void highlightView(Gui::ViewProviderDocumentObject*); @@ -46,7 +46,7 @@ private: SoSeparator* annotate; }; -class FemGuiExport ViewProviderFemAnalysis : public Gui::ViewProviderDocumentObjectGroup +class FemGuiExport ViewProviderFemAnalysis: public Gui::ViewProviderDocumentObjectGroup { Q_DECLARE_TR_FUNCTIONS(FemGui::ViewProviderFemAnalysis) PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderAnalysis); @@ -61,13 +61,14 @@ public: void attach(App::DocumentObject*) override; bool doubleClicked() override; - std::vector claimChildren()const override; + std::vector claimChildren() const override; /// handling when object is deleted bool onDelete(const std::vector&) override; /// warning on deletion when there are children static bool checkSelectedChildren(const std::vector objs, - Gui::Document* docGui, std::string objectName); + Gui::Document* docGui, + std::string objectName); /// asks the view provider if the given object can be deleted bool canDelete(App::DocumentObject* obj) const override; @@ -76,7 +77,8 @@ public: /// list of all possible display modes std::vector getDisplayModes() const override; /// shows solid in the tree - bool isShow() const override { + bool isShow() const override + { return Visibility.getValue(); } /// Hide the object in the view @@ -112,7 +114,7 @@ private: using ViewProviderFemAnalysisPython = Gui::ViewProviderPythonFeatureT; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_ViewProviderAnalysis_H +#endif // FEM_ViewProviderAnalysis_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp index 18fd18e0f1..82fee78652 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp @@ -24,20 +24,20 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif #include "Gui/Command.h" @@ -45,8 +45,8 @@ #include "Gui/Document.h" #include "Gui/MainWindow.h" -#include "ViewProviderFemConstraint.h" #include "TaskFemConstraint.h" +#include "ViewProviderFemConstraint.h" using namespace FemGui; @@ -123,23 +123,25 @@ std::vector ViewProviderFemConstraint::getDisplayModes() const void ViewProviderFemConstraint::setDisplayMode(const char* ModeName) { - if (strcmp(ModeName, "Base") == 0) + if (strcmp(ModeName, "Base") == 0) { setDisplayMaskMode("Base"); + } ViewProviderDocumentObject::setDisplayMode(ModeName); } -std::vector ViewProviderFemConstraint::claimChildren()const +std::vector ViewProviderFemConstraint::claimChildren() const { return {}; } -void ViewProviderFemConstraint::setupContextMenu(QMenu *menu, QObject *receiver, const char *member) +void ViewProviderFemConstraint::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { - QAction *act; + QAction* act; act = menu->addAction(QObject::tr("Edit analysis feature"), receiver, member); act->setData(QVariant((int)ViewProvider::Default)); - ViewProviderDocumentObject::setupContextMenu(menu, receiver, - member);// clazy:exclude=skipped-base-method + ViewProviderDocumentObject::setupContextMenu(menu, + receiver, + member); // clazy:exclude=skipped-base-method } void ViewProviderFemConstraint::onChanged(const App::Property* prop) @@ -148,26 +150,27 @@ void ViewProviderFemConstraint::onChanged(const App::Property* prop) updateData(prop); } else if (prop == &TextColor) { - const App::Color &c = TextColor.getValue(); + const App::Color& c = TextColor.getValue(); pTextColor->rgb.setValue(c.r, c.g, c.b); } else if (prop == &FaceColor) { - const App::Color &c = FaceColor.getValue(); + const App::Color& c = FaceColor.getValue(); pMaterials->rgb.setValue(c.r, c.g, c.b); } else if (prop == &FontSize) { pFont->size = FontSize.getValue(); } else { - ViewProviderDocumentObject::onChanged(prop);// clazy:exclude=skipped-base-method + ViewProviderDocumentObject::onChanged(prop); // clazy:exclude=skipped-base-method } } -//OvG: Visibility automation show parts and hide meshes on activation of a constraint +// OvG: Visibility automation show parts and hide meshes on activation of a constraint std::string ViewProviderFemConstraint::gethideMeshShowPartStr(const std::string showConstr) { return "for amesh in App.activeDocument().Objects:\n\ - if \""+showConstr+"\" == amesh.Name:\n\ + if \"" + + showConstr + "\" == amesh.Name:\n\ amesh.ViewObject.Visibility = True\n\ elif \"Mesh\" in amesh.TypeId:\n\ amesh.ViewObject.Visibility = False\n"; @@ -180,7 +183,8 @@ std::string ViewProviderFemConstraint::gethideMeshShowPartStr() bool ViewProviderFemConstraint::setEdit(int ModNum) { - Gui::Command::doCommand(Gui::Command::Doc, "%s", + Gui::Command::doCommand(Gui::Command::Doc, + "%s", ViewProviderFemConstraint::gethideMeshShowPartStr().c_str()); return Gui::ViewProviderGeometryObject::setEdit(ModNum); } @@ -261,29 +265,34 @@ void getLocalCoordinateSystem(const SbVec3f& z, SbVec3f& y, SbVec3f& x) */ #define PLACEMENT_CHILDREN 2 -void ViewProviderFemConstraint::createPlacement(SoSeparator *sep, const SbVec3f &base, - const SbRotation &r) +void ViewProviderFemConstraint::createPlacement(SoSeparator* sep, + const SbVec3f& base, + const SbRotation& r) { - SoTranslation *trans = new SoTranslation(); + SoTranslation* trans = new SoTranslation(); trans->translation.setValue(base); sep->addChild(trans); - SoRotation *rot = new SoRotation(); + SoRotation* rot = new SoRotation(); rot->rotation.setValue(r); sep->addChild(rot); } -void ViewProviderFemConstraint::updatePlacement(const SoSeparator *sep, const int idx, - const SbVec3f &base, const SbRotation &r) +void ViewProviderFemConstraint::updatePlacement(const SoSeparator* sep, + const int idx, + const SbVec3f& base, + const SbRotation& r) { - SoTranslation *trans = static_cast(sep->getChild(idx)); + SoTranslation* trans = static_cast(sep->getChild(idx)); trans->translation.setValue(base); - SoRotation *rot = static_cast(sep->getChild(idx + 1)); + SoRotation* rot = static_cast(sep->getChild(idx + 1)); rot->rotation.setValue(r); } #define CONE_CHILDREN 2 -void ViewProviderFemConstraint::createCone(SoSeparator* sep, const double height, const double radius) +void ViewProviderFemConstraint::createCone(SoSeparator* sep, + const double height, + const double radius) { // Adjust cone so that the tip is on base SoTranslation* trans = new SoTranslation(); @@ -303,23 +312,26 @@ SoSeparator* ViewProviderFemConstraint::createCone(const double height, const do return sep; } -void ViewProviderFemConstraint::updateCone(const SoNode *node, const int idx, const double height, +void ViewProviderFemConstraint::updateCone(const SoNode* node, + const int idx, + const double height, const double radius) { - const SoSeparator *sep = static_cast(node); - SoTranslation *trans = static_cast(sep->getChild(idx)); + const SoSeparator* sep = static_cast(node); + SoTranslation* trans = static_cast(sep->getChild(idx)); trans->translation.setValue(SbVec3f(0, -height / 2, 0)); - SoCone *cone = static_cast(sep->getChild(idx + 1)); + SoCone* cone = static_cast(sep->getChild(idx + 1)); cone->height.setValue(height); cone->bottomRadius.setValue(radius); } #define CYLINDER_CHILDREN 1 -void ViewProviderFemConstraint::createCylinder(SoSeparator *sep, const double height, +void ViewProviderFemConstraint::createCylinder(SoSeparator* sep, + const double height, const double radius) { - SoCylinder *cyl = new SoCylinder(); + SoCylinder* cyl = new SoCylinder(); cyl->height.setValue(height); cyl->radius.setValue(radius); sep->addChild(cyl); @@ -333,40 +345,47 @@ SoSeparator* ViewProviderFemConstraint::createCylinder(const double height, cons return sep; } -void ViewProviderFemConstraint::updateCylinder(const SoNode *node, const int idx, - const double height, const double radius) +void ViewProviderFemConstraint::updateCylinder(const SoNode* node, + const int idx, + const double height, + const double radius) { - const SoSeparator *sep = static_cast(node); - SoCylinder *cyl = static_cast(sep->getChild(idx)); + const SoSeparator* sep = static_cast(node); + SoCylinder* cyl = static_cast(sep->getChild(idx)); cyl->height.setValue(height); cyl->radius.setValue(radius); } #define CUBE_CHILDREN 1 -void ViewProviderFemConstraint::createCube(SoSeparator *sep, const double width, - const double length, const double height) +void ViewProviderFemConstraint::createCube(SoSeparator* sep, + const double width, + const double length, + const double height) { - SoCube *cube = new SoCube(); + SoCube* cube = new SoCube(); cube->width.setValue(width); cube->depth.setValue(length); cube->height.setValue(height); sep->addChild(cube); } -SoSeparator *ViewProviderFemConstraint::createCube(const double width, const double length, - const double height) +SoSeparator* +ViewProviderFemConstraint::createCube(const double width, const double length, const double height) { - SoSeparator *sep = new SoSeparator(); + SoSeparator* sep = new SoSeparator(); createCube(sep, width, length, height); return sep; } -void ViewProviderFemConstraint::updateCube(const SoNode *node, const int idx, const double width, - const double length, const double height) +void ViewProviderFemConstraint::updateCube(const SoNode* node, + const int idx, + const double width, + const double length, + const double height) { - const SoSeparator *sep = static_cast(node); - SoCube *cube = static_cast(sep->getChild(idx)); + const SoSeparator* sep = static_cast(node); + SoCube* cube = static_cast(sep->getChild(idx)); cube->width.setValue(width); cube->depth.setValue(length); cube->height.setValue(height); @@ -374,7 +393,9 @@ void ViewProviderFemConstraint::updateCube(const SoNode *node, const int idx, co #define ARROW_CHILDREN (CONE_CHILDREN + PLACEMENT_CHILDREN + CYLINDER_CHILDREN) -void ViewProviderFemConstraint::createArrow(SoSeparator* sep, const double length, const double radius) +void ViewProviderFemConstraint::createArrow(SoSeparator* sep, + const double length, + const double radius) { createCone(sep, radius, radius / 2); createPlacement(sep, SbVec3f(0, -radius / 2 - (length - radius) / 2, 0), SbRotation()); @@ -388,19 +409,25 @@ SoSeparator* ViewProviderFemConstraint::createArrow(const double length, const d return sep; } -void ViewProviderFemConstraint::updateArrow(const SoNode *node, const int idx, const double length, +void ViewProviderFemConstraint::updateArrow(const SoNode* node, + const int idx, + const double length, const double radius) { - const SoSeparator *sep = static_cast(node); + const SoSeparator* sep = static_cast(node); updateCone(sep, idx, radius, radius / 2); - updatePlacement(sep, idx + CONE_CHILDREN, SbVec3f(0, -radius / 2 - (length - radius) / 2, 0), + updatePlacement(sep, + idx + CONE_CHILDREN, + SbVec3f(0, -radius / 2 - (length - radius) / 2, 0), SbRotation()); updateCylinder(sep, idx + CONE_CHILDREN + PLACEMENT_CHILDREN, length - radius, radius / 5); } #define SPRING_CHILDREN (CUBE_CHILDREN + PLACEMENT_CHILDREN + CYLINDER_CHILDREN) -void ViewProviderFemConstraint::createSpring(SoSeparator* sep, const double length, const double width) +void ViewProviderFemConstraint::createSpring(SoSeparator* sep, + const double length, + const double width) { createCube(sep, width, width, length / 2); createPlacement(sep, SbVec3f(0, -length / 2, 0), SbRotation()); @@ -414,10 +441,12 @@ SoSeparator* ViewProviderFemConstraint::createSpring(const double length, const return sep; } -void ViewProviderFemConstraint::updateSpring(const SoNode *node, const int idx, const double length, +void ViewProviderFemConstraint::updateSpring(const SoNode* node, + const int idx, + const double length, const double width) { - const SoSeparator *sep = static_cast(node); + const SoSeparator* sep = static_cast(node); updateCube(sep, idx, width, width, length / 2); updatePlacement(sep, idx + CUBE_CHILDREN, SbVec3f(0, -length / 2, 0), SbRotation()); updateCylinder(sep, idx + CUBE_CHILDREN + PLACEMENT_CHILDREN, length / 2, width / 4); @@ -425,99 +454,121 @@ void ViewProviderFemConstraint::updateSpring(const SoNode *node, const int idx, #define FIXED_CHILDREN (CONE_CHILDREN + PLACEMENT_CHILDREN + CUBE_CHILDREN) -void ViewProviderFemConstraint::createFixed(SoSeparator *sep, const double height, - const double width, const bool gap) +void ViewProviderFemConstraint::createFixed(SoSeparator* sep, + const double height, + const double width, + const bool gap) { createCone(sep, height - width / 4, height - width / 4); createPlacement( - sep, SbVec3f(0, -(height - width / 4) / 2 - width / 8 - (gap ? 1.0 : 0.1) * width / 8, 0), + sep, + SbVec3f(0, -(height - width / 4) / 2 - width / 8 - (gap ? 1.0 : 0.1) * width / 8, 0), SbRotation()); createCube(sep, width, width, width / 4); } -SoSeparator *ViewProviderFemConstraint::createFixed(const double height, const double width, - const bool gap) +SoSeparator* +ViewProviderFemConstraint::createFixed(const double height, const double width, const bool gap) { - SoSeparator *sep = new SoSeparator(); + SoSeparator* sep = new SoSeparator(); createFixed(sep, height, width, gap); return sep; } -void ViewProviderFemConstraint::updateFixed(const SoNode *node, const int idx, const double height, - const double width, const bool gap) +void ViewProviderFemConstraint::updateFixed(const SoNode* node, + const int idx, + const double height, + const double width, + const bool gap) { - const SoSeparator *sep = static_cast(node); + const SoSeparator* sep = static_cast(node); updateCone(sep, idx, height - width / 4, height - width / 4); updatePlacement( - sep, idx + CONE_CHILDREN, + sep, + idx + CONE_CHILDREN, SbVec3f(0, -(height - width / 4) / 2 - width / 8 - (gap ? 1.0 : 0.0) * width / 8, 0), SbRotation()); updateCube(sep, idx + CONE_CHILDREN + PLACEMENT_CHILDREN, width, width, width / 4); } -void ViewProviderFemConstraint::createDisplacement(SoSeparator *sep, const double height, - const double width, const bool gap) +void ViewProviderFemConstraint::createDisplacement(SoSeparator* sep, + const double height, + const double width, + const bool gap) { createCone(sep, height, width); - createPlacement(sep, SbVec3f(0, -(height) / 2 - width / 8 - (gap ? 1.0 : 0.1) * width / 8, 0), + createPlacement(sep, + SbVec3f(0, -(height) / 2 - width / 8 - (gap ? 1.0 : 0.1) * width / 8, 0), SbRotation()); } -SoSeparator *ViewProviderFemConstraint::createDisplacement(const double height, const double width, +SoSeparator* ViewProviderFemConstraint::createDisplacement(const double height, + const double width, const bool gap) { - SoSeparator *sep = new SoSeparator(); + SoSeparator* sep = new SoSeparator(); createDisplacement(sep, height, width, gap); return sep; } -void ViewProviderFemConstraint::updateDisplacement(const SoNode *node, const int idx, - const double height, const double width, +void ViewProviderFemConstraint::updateDisplacement(const SoNode* node, + const int idx, + const double height, + const double width, const bool gap) { - const SoSeparator *sep = static_cast(node); + const SoSeparator* sep = static_cast(node); updateCone(sep, idx, height, width); - updatePlacement(sep, idx + CONE_CHILDREN, + updatePlacement(sep, + idx + CONE_CHILDREN, SbVec3f(0, -(height) / 2 - width / 8 - (gap ? 1.0 : 0.0) * width / 8, 0), SbRotation()); } -void ViewProviderFemConstraint::createRotation(SoSeparator *sep, const double height, - const double width, const bool gap) +void ViewProviderFemConstraint::createRotation(SoSeparator* sep, + const double height, + const double width, + const bool gap) { createCylinder(sep, width / 2, height / 2); - createPlacement(sep, SbVec3f(0, -(height)*2 - width / 8 - (gap ? 1.0 : 0.1) * width / 8, 0), + createPlacement(sep, + SbVec3f(0, -(height)*2 - width / 8 - (gap ? 1.0 : 0.1) * width / 8, 0), SbRotation()); } -SoSeparator *ViewProviderFemConstraint::createRotation(const double height, const double width, - const bool gap) +SoSeparator* +ViewProviderFemConstraint::createRotation(const double height, const double width, const bool gap) { - SoSeparator *sep = new SoSeparator(); + SoSeparator* sep = new SoSeparator(); createRotation(sep, height, width, gap); return sep; } -void ViewProviderFemConstraint::updateRotation(const SoNode *node, const int idx, - const double height, const double width, +void ViewProviderFemConstraint::updateRotation(const SoNode* node, + const int idx, + const double height, + const double width, const bool gap) { - const SoSeparator *sep = static_cast(node); + const SoSeparator* sep = static_cast(node); updateCylinder(sep, idx, height / 2, width / 2); - updatePlacement(sep, idx + CYLINDER_CHILDREN, + updatePlacement(sep, + idx + CYLINDER_CHILDREN, SbVec3f(0, -(height)*2 - width / 8 - (gap ? 1.0 : 0.0) * width / 8, 0), SbRotation()); } -QObject *ViewProviderFemConstraint::findChildByName(const QObject *parent, const QString &name) +QObject* ViewProviderFemConstraint::findChildByName(const QObject* parent, const QString& name) { for (auto o : parent->children()) { - if (o->objectName() == name) + if (o->objectName() == name) { return o; + } if (!o->children().empty()) { - QObject *result = findChildByName(o, name); - if (result) + QObject* result = findChildByName(o, name); + if (result) { return result; + } } } @@ -526,30 +577,38 @@ QObject *ViewProviderFemConstraint::findChildByName(const QObject *parent, const void ViewProviderFemConstraint::checkForWizard() { - wizardWidget= nullptr; + wizardWidget = nullptr; wizardSubLayout = nullptr; Gui::MainWindow* mw = Gui::getMainWindow(); - if (!mw) + if (!mw) { return; + } QDockWidget* dw = mw->findChild(QString::fromLatin1("Combo View")); - if (!dw) + if (!dw) { return; + } QWidget* cw = dw->findChild(QString::fromLatin1("Combo View")); - if (!cw) + if (!cw) { return; + } QTabWidget* tw = cw->findChild(QString::fromLatin1("combiTab")); - if (!tw) + if (!tw) { return; - QStackedWidget *sw = - tw->findChild(QString::fromLatin1("qt_tabwidget_stackedwidget")); - if (!sw) + } + QStackedWidget* sw = + tw->findChild(QString::fromLatin1("qt_tabwidget_stackedwidget")); + if (!sw) { return; + } QScrollArea* sa = sw->findChild(); - if (!sa) + if (!sa) { return; - QWidget* wd = sa->widget(); // This is the reason why we cannot use findChildByName() right away!!! - if (!wd) + } + QWidget* wd = + sa->widget(); // This is the reason why we cannot use findChildByName() right away!!! + if (!wd) { return; + } QObject* wiz = findChildByName(wd, QString::fromLatin1("ShaftWizard")); if (wiz) { wizardWidget = static_cast(wiz); @@ -560,11 +619,12 @@ void ViewProviderFemConstraint::checkForWizard() // Python feature ----------------------------------------------------------------------- -namespace Gui { +namespace Gui +{ /// @cond DOXERR PROPERTY_SOURCE_TEMPLATE(FemGui::ViewProviderFemConstraintPython, FemGui::ViewProviderFemConstraint) /// @endcond // explicit template instantiation template class FemGuiExport ViewProviderPythonFeatureT; -} +} // namespace Gui diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.h b/src/Mod/Fem/Gui/ViewProviderFemConstraint.h index 9d485b25e6..e3843fb0fe 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.h @@ -44,7 +44,7 @@ namespace FemGui class TaskFemConstraint; -class FemGuiExport ViewProviderFemConstraint : public Gui::ViewProviderGeometryObject +class FemGuiExport ViewProviderFemConstraint: public Gui::ViewProviderGeometryObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraint); @@ -54,26 +54,27 @@ public: ~ViewProviderFemConstraint() override; // Display properties - App::PropertyColor TextColor; - App::PropertyColor FaceColor; - App::PropertyColor ShapeColor; - App::PropertyInteger FontSize; - App::PropertyFloat DistFactor; - App::PropertyBool Mirror; + App::PropertyColor TextColor; + App::PropertyColor FaceColor; + App::PropertyColor ShapeColor; + App::PropertyInteger FontSize; + App::PropertyFloat DistFactor; + App::PropertyBool Mirror; - void attach(App::DocumentObject *) override; - void updateData(const App::Property *prop) override + void attach(App::DocumentObject*) override; + void updateData(const App::Property* prop) override { Gui::ViewProviderGeometryObject::updateData(prop); } std::vector getDisplayModes() const override; - void setDisplayMode(const char *ModeName) override; + void setDisplayMode(const char* ModeName) override; - std::vector claimChildren()const override; + std::vector claimChildren() const override; void setupContextMenu(QMenu*, QObject*, const char*) override; /// Highlight the references that have been selected - virtual void highlightReferences(const bool /* on */) {} + virtual void highlightReferences(const bool /* on */) + {} static std::string gethideMeshShowPartStr(); static std::string gethideMeshShowPartStr(const std::string showConstr); @@ -83,57 +84,75 @@ protected: bool setEdit(int ModNum) override; void unsetEdit(int ModNum) override; - static void createPlacement(SoSeparator *sep, const SbVec3f &base, const SbRotation &r); - static void updatePlacement(const SoSeparator *sep, const int idx, const SbVec3f &base, - const SbRotation &r); - static void createCone(SoSeparator *sep, const double height, const double radius); - static SoSeparator *createCone(const double height, const double radius); - static void updateCone(const SoNode *node, const int idx, const double height, - const double radius); - static void createCylinder(SoSeparator *sep, const double height, const double radius); - static SoSeparator *createCylinder(const double height, const double radius); - static void updateCylinder(const SoNode *node, const int idx, const double height, - const double radius); - static void createCube(SoSeparator *sep, const double width, const double length, + static void createPlacement(SoSeparator* sep, const SbVec3f& base, const SbRotation& r); + static void updatePlacement(const SoSeparator* sep, + const int idx, + const SbVec3f& base, + const SbRotation& r); + static void createCone(SoSeparator* sep, const double height, const double radius); + static SoSeparator* createCone(const double height, const double radius); + static void + updateCone(const SoNode* node, const int idx, const double height, const double radius); + static void createCylinder(SoSeparator* sep, const double height, const double radius); + static SoSeparator* createCylinder(const double height, const double radius); + static void + updateCylinder(const SoNode* node, const int idx, const double height, const double radius); + static void + createCube(SoSeparator* sep, const double width, const double length, const double height); + static SoSeparator* createCube(const double width, const double length, const double height); + static void updateCube(const SoNode* node, + const int idx, + const double width, + const double length, const double height); - static SoSeparator *createCube(const double width, const double length, const double height); - static void updateCube(const SoNode *node, const int idx, const double width, - const double length, const double height); - static void createArrow(SoSeparator *sep, const double length, const double radius); - static SoSeparator *createArrow(const double length, const double radius); - static void updateArrow(const SoNode *node, const int idx, const double length, - const double radius); - static void createSpring(SoSeparator *sep, const double length, const double width); - static SoSeparator *createSpring(const double length, const double width); - static void updateSpring(const SoNode *node, const int idx, const double length, - const double width); - static void createFixed(SoSeparator *sep, const double height, const double width, + static void createArrow(SoSeparator* sep, const double length, const double radius); + static SoSeparator* createArrow(const double length, const double radius); + static void + updateArrow(const SoNode* node, const int idx, const double length, const double radius); + static void createSpring(SoSeparator* sep, const double length, const double width); + static SoSeparator* createSpring(const double length, const double width); + static void + updateSpring(const SoNode* node, const int idx, const double length, const double width); + static void + createFixed(SoSeparator* sep, const double height, const double width, const bool gap = false); + static SoSeparator* + createFixed(const double height, const double width, const bool gap = false); + static void updateFixed(const SoNode* node, + const int idx, + const double height, + const double width, const bool gap = false); - static SoSeparator *createFixed(const double height, const double width, - const bool gap = false); - static void updateFixed(const SoNode *node, const int idx, const double height, - const double width, const bool gap = false); - static void createDisplacement(SoSeparator *sep, const double height, const double width, + static void createDisplacement(SoSeparator* sep, + const double height, + const double width, const bool gap = false); - static SoSeparator *createDisplacement(const double height, const double width, - const bool gap = false); - static void updateDisplacement(const SoNode *node, const int idx, const double height, - const double width, const bool gap = false); - static void createRotation(SoSeparator *sep, const double height, const double width, + static SoSeparator* + createDisplacement(const double height, const double width, const bool gap = false); + static void updateDisplacement(const SoNode* node, + const int idx, + const double height, + const double width, + const bool gap = false); + static void createRotation(SoSeparator* sep, + const double height, + const double width, + const bool gap = false); + static SoSeparator* + createRotation(const double height, const double width, const bool gap = false); + static void updateRotation(const SoNode* node, + const int idx, + const double height, + const double width, const bool gap = false); - static SoSeparator *createRotation(const double height, const double width, - const bool gap = false); - static void updateRotation(const SoNode *node, const int idx, const double height, - const double width, const bool gap = false); private: - SoFontStyle * pFont; - SoText2 * pLabel; - SoBaseColor * pTextColor; - SoBaseColor * pMaterials; + SoFontStyle* pFont; + SoText2* pLabel; + SoBaseColor* pTextColor; + SoBaseColor* pMaterials; protected: - SoSeparator * pShapeSep; + SoSeparator* pShapeSep; // Shaft design wizard integration protected: @@ -149,7 +168,7 @@ protected: using ViewProviderFemConstraintPython = Gui::ViewProviderPythonFeatureT; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINT_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINT_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp index 0a25230f65..4da4bbcfe9 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp @@ -24,17 +24,17 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include #endif -#include #include "Gui/Control.h" -#include -#include "ViewProviderFemConstraintBearing.h" #include "TaskFemConstraintBearing.h" +#include "ViewProviderFemConstraintBearing.h" +#include +#include using namespace FemGui; @@ -52,14 +52,15 @@ ViewProviderFemConstraintBearing::~ViewProviderFemConstraintBearing() = default; bool ViewProviderFemConstraintBearing::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { + if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintBearing *constrDlg = qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintBearing* constrDlg = qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { // This case will occur in the ShaftWizard application checkForWizard(); @@ -71,15 +72,19 @@ bool ViewProviderFemConstraintBearing::setEdit(int ModNum) msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) + if (ret == QMessageBox::Yes) { Gui::Control().reject(); - else + } + else { return false; - } else if (constraintDialog) { + } + } + else if (constraintDialog) { // Another FemConstraint* dialog is already open inside the Shaft Wizard // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintBearing(this); return true; } @@ -89,25 +94,28 @@ bool ViewProviderFemConstraintBearing::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintBearing(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } void ViewProviderFemConstraintBearing::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintBearing *pcConstraint = static_cast(this->getObject()); + Fem::ConstraintBearing* pcConstraint = static_cast(this->getObject()); - if (prop == &pcConstraint->References) - Base::Console().Error("\n"); // enable a breakpoint here + if (prop == &pcConstraint->References) { + Base::Console().Error("\n"); // enable a breakpoint here + } if (prop == &pcConstraint->BasePoint) { // Remove and recreate the symbol @@ -126,7 +134,8 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop) createPlacement(pShapeSep, b, rot); pShapeSep->addChild( createFixed(radius / 2, radius / 2 * 1.5, pcConstraint->AxialFree.getValue())); - } else if (prop == &pcConstraint->AxialFree) { + } + else if (prop == &pcConstraint->AxialFree) { if (pShapeSep->getNumChildren() > 0) { // Change the symbol Base::Vector3d normal = pcConstraint->NormalDirection.getValue(); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.h index 345bc114b5..6ee1753bc0 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.h @@ -30,7 +30,7 @@ namespace FemGui { -class FemGuiExport ViewProviderFemConstraintBearing : public FemGui::ViewProviderFemConstraint +class FemGuiExport ViewProviderFemConstraintBearing: public FemGui::ViewProviderFemConstraint { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintBearing); @@ -45,7 +45,7 @@ protected: bool setEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTBEARING_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTBEARING_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp index d305504169..44dd3cff81 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp @@ -26,17 +26,17 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include #endif #include "Mod/Fem/App/FemConstraintContact.h" -#include -#include "ViewProviderFemConstraintContact.h" #include "TaskFemConstraintContact.h" +#include "ViewProviderFemConstraintContact.h" +#include using namespace FemGui; @@ -46,28 +46,31 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintContact, FemGui::ViewProviderFe ViewProviderFemConstraintContact::ViewProviderFemConstraintContact() { sPixmap = "FEM_ConstraintContact"; - //Note change "Contact" in line above to new constraint name, make sure it is the same as in taskFem* cpp file + // Note change "Contact" in line above to new constraint name, make sure it is the same as in + // taskFem* cpp file ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f)); } ViewProviderFemConstraintContact::~ViewProviderFemConstraintContact() = default; -//FIXME setEdit needs a careful review +// FIXME setEdit needs a careful review bool ViewProviderFemConstraintContact::setEdit(int ModNum) { if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintContact *constrDlg = qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintContact* constrDlg = qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { if (constraintDialog) { // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintContact(this); return true; } @@ -77,14 +80,16 @@ bool ViewProviderFemConstraintContact::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintContact(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } @@ -92,60 +97,64 @@ bool ViewProviderFemConstraintContact::setEdit(int ModNum) #define LENGTH (1.5) #define WIDTH (0.5) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable +// #define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - +// so disable void ViewProviderFemConstraintContact::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes Fem::ConstraintContact* pcConstraint = static_cast(this->getObject()); - float scaledlength = LENGTH * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + float scaledlength = + LENGTH * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); if (prop == &pcConstraint->Points) { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); - if (points.size() != normals.size()) + if (points.size() != normals.size()) { return; + } std::vector::const_iterator n = normals.begin(); // Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (const auto & point : points) { - //Define base and normal directions + for (const auto& point : points) { + // Define base and normal directions SbVec3f base(point.x, point.y, point.z); - SbVec3f dir(n->x, n->y, n->z);//normal + SbVec3f dir(n->x, n->y, n->z); // normal - ///Visual indication - //define separator + /// Visual indication + // define separator SoSeparator* sep = new SoSeparator(); - //first move to correct position + // first move to correct position SoTranslation* trans = new SoTranslation(); SbVec3f newPos = base + scaledheight * dir * 0.12f; trans->translation.setValue(newPos); sep->addChild(trans); - //adjust orientation - SoRotation *rot = new SoRotation(); + // adjust orientation + SoRotation* rot = new SoRotation(); rot->rotation.setValue(SbRotation(SbVec3f(0, 1, 0), dir)); sep->addChild(rot); - //define color of shape - SoMaterial *myMaterial = new SoMaterial; - myMaterial->diffuseColor.set1Value(0, SbColor(1, 1, 1));//RGB - //myMaterial->diffuseColor.set1Value(1,SbColor(0,0,1));//possible to adjust sides separately + // define color of shape + SoMaterial* myMaterial = new SoMaterial; + myMaterial->diffuseColor.set1Value(0, SbColor(1, 1, 1)); // RGB + // myMaterial->diffuseColor.set1Value(1,SbColor(0,0,1));//possible to adjust sides + // separately sep->addChild(myMaterial); - //draw a cube - SoCube *cbe = new SoCube(); + // draw a cube + SoCube* cbe = new SoCube(); cbe->depth.setValue(scaledlength * 0.5); cbe->height.setValue(scaledheight * 0.25); cbe->width.setValue(scaledwidth * 0.75); sep->addChild(cbe); - //translate position - SoTranslation *trans2 = new SoTranslation(); + // translate position + SoTranslation* trans2 = new SoTranslation(); trans2->translation.setValue(SbVec3f(0, 0, 0)); sep->addChild(trans2); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.h index b64ebba804..abc4669af3 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.h @@ -28,9 +28,10 @@ #include "ViewProviderFemConstraint.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintContact : public FemGui::ViewProviderFemConstraint +class FemGuiExport ViewProviderFemConstraintContact: public FemGui::ViewProviderFemConstraint { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintContact); @@ -42,6 +43,6 @@ public: protected: bool setEdit(int ModNum) override; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTContact_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTContact_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp index fa4af6f115..0a4a8449ad 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp @@ -26,16 +26,16 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include #endif #include "Mod/Fem/App/FemConstraintDisplacement.h" -#include -#include "ViewProviderFemConstraintDisplacement.h" #include "TaskFemConstraintDisplacement.h" +#include "ViewProviderFemConstraintDisplacement.h" +#include using namespace FemGui; @@ -58,16 +58,18 @@ bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum) // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintDisplacement *constrDlg = - qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintDisplacement* constrDlg = + qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { if (constraintDialog) { // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintDisplacement(this); return true; } @@ -77,27 +79,29 @@ bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintDisplacement(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } #define HEIGHT (4) #define WIDTH (0.3) -//#define USE_MULTIPLE_COPY -//OvG: MULTICOPY fails to update scaled display on initial drawing - so disable +// #define USE_MULTIPLE_COPY +// OvG: MULTICOPY fails to update scaled display on initial drawing - so disable void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintDisplacement *pcConstraint = - static_cast(this->getObject()); + Fem::ConstraintDisplacement* pcConstraint = + static_cast(this->getObject()); // OvG: Calculate scaled values once only float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); @@ -109,7 +113,7 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop bool rotzFree = pcConstraint->rotzFree.getValue(); #ifdef USE_MULTIPLE_COPY - //OvG: always need access to cp for scaling + // OvG: always need access to cp for scaling SoMultipleCopy* cpx = new SoMultipleCopy(); SoMultipleCopy* cpy = new SoMultipleCopy(); SoMultipleCopy* cpz = new SoMultipleCopy(); @@ -119,22 +123,22 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop if (pShapeSep->getNumChildren() == 0) { // Set up the nodes cpx->matrix.setNum(0); - cpx->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); //OvG: Scaling + cpx->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); // OvG: Scaling cpy->matrix.setNum(0); - cpy->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); //OvG: Scaling + cpy->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); // OvG: Scaling cpz->matrix.setNum(0); - cpz->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); //OvG: Scaling + cpz->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); // OvG: Scaling cprotx->matrix.setNum(0); - cprotx->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); //OvG: Scaling + cprotx->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); // OvG: Scaling cproty->matrix.setNum(0); - cproty->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); //OvG: Scaling + cproty->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); // OvG: Scaling cprotz->matrix.setNum(0); - cprotz->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); //OvG: Scaling + cprotz->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); // OvG: Scaling pShapeSep->addChild(cpx); pShapeSep->addChild(cpy); @@ -148,8 +152,9 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop if (prop == &pcConstraint->Points) { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); - if (points.size() != normals.size()) + if (points.size() != normals.size()) { return; + } std::vector::const_iterator n = normals.begin(); #ifdef USE_MULTIPLE_COPY @@ -188,19 +193,19 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop Gui::coinRemoveAllChildren(pShapeSep); #endif - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); - SbVec3f dirx(1, 0, 0); //OvG: Make relevant to global axes - SbVec3f diry(0, 1, 0); //OvG: Make relevant to global axes - SbVec3f dirz(0, 0, 1); //OvG: Make relevant to global axes - SbRotation rotx(SbVec3f(0, -1, 0), dirx);//OvG Tri-cones + SbVec3f dirx(1, 0, 0); // OvG: Make relevant to global axes + SbVec3f diry(0, 1, 0); // OvG: Make relevant to global axes + SbVec3f dirz(0, 0, 1); // OvG: Make relevant to global axes + SbRotation rotx(SbVec3f(0, -1, 0), dirx); // OvG Tri-cones SbRotation roty(SbVec3f(0, -1, 0), diry); SbRotation rotz(SbVec3f(0, -1, 0), dirz); #ifdef USE_MULTIPLE_COPY SbMatrix mx; SbMatrix my; SbMatrix mz; - //OvG: Translation indication + // OvG: Translation indication if (!xFree) { SbMatrix mx; mx.setTransform(base, rotx, SbVec3f(1, 1, 1)); @@ -220,7 +225,7 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop idz++; } - //OvG: Rotation indication + // OvG: Rotation indication if (!rotxFree) { SbMatrix mrotx; mrotx.setTransform(base, rotx, SbVec3f(1, 1, 1)); @@ -240,43 +245,43 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop idrotz++; } #else - //OvG: Translation indication + // OvG: Translation indication if (!xFree) { - SoSeparator *sepx = new SoSeparator(); + SoSeparator* sepx = new SoSeparator(); createPlacement(sepx, base, rotx); - createDisplacement(sepx, scaledheight, scaledwidth);//OvG: Scaling + createDisplacement(sepx, scaledheight, scaledwidth); // OvG: Scaling pShapeSep->addChild(sepx); } if (!yFree) { - SoSeparator *sepy = new SoSeparator(); + SoSeparator* sepy = new SoSeparator(); createPlacement(sepy, base, roty); - createDisplacement(sepy, scaledheight, scaledwidth);//OvG: Scaling + createDisplacement(sepy, scaledheight, scaledwidth); // OvG: Scaling pShapeSep->addChild(sepy); } if (!zFree) { - SoSeparator *sepz = new SoSeparator(); + SoSeparator* sepz = new SoSeparator(); createPlacement(sepz, base, rotz); - createDisplacement(sepz, scaledheight, scaledwidth);//OvG: Scaling + createDisplacement(sepz, scaledheight, scaledwidth); // OvG: Scaling pShapeSep->addChild(sepz); } - //OvG: Rotation indication + // OvG: Rotation indication if (!rotxFree) { - SoSeparator *sepx = new SoSeparator(); + SoSeparator* sepx = new SoSeparator(); createPlacement(sepx, base, rotx); - createRotation(sepx, scaledheight, scaledwidth);//OvG: Scaling + createRotation(sepx, scaledheight, scaledwidth); // OvG: Scaling pShapeSep->addChild(sepx); } if (!rotyFree) { - SoSeparator *sepy = new SoSeparator(); + SoSeparator* sepy = new SoSeparator(); createPlacement(sepy, base, roty); - createRotation(sepy, scaledheight, scaledwidth);//OvG: Scaling + createRotation(sepy, scaledheight, scaledwidth); // OvG: Scaling pShapeSep->addChild(sepy); } if (!rotzFree) { - SoSeparator *sepz = new SoSeparator(); + SoSeparator* sepz = new SoSeparator(); createPlacement(sepz, base, rotz); - createRotation(sepz, scaledheight, scaledwidth);//OvG: Scaling + createRotation(sepz, scaledheight, scaledwidth); // OvG: Scaling pShapeSep->addChild(sepz); } #endif diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.h index f2935093c6..4d02516a96 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.h @@ -28,9 +28,11 @@ #include "ViewProviderFemConstraintOnBoundary.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintDisplacement : public FemGui::ViewProviderFemConstraintOnBoundary +class FemGuiExport ViewProviderFemConstraintDisplacement + : public FemGui::ViewProviderFemConstraintOnBoundary { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintDisplacement); @@ -43,6 +45,6 @@ protected: bool setEdit(int ModNum) override; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTDISPLACEMENT_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTDISPLACEMENT_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp index 3b661afb86..3a3ebcaa11 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp @@ -24,18 +24,18 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include #endif -#include #include "Gui/Control.h" +#include -#include "ViewProviderFemConstraintFixed.h" #include "TaskFemConstraintFixed.h" +#include "ViewProviderFemConstraintFixed.h" using namespace FemGui; @@ -52,14 +52,15 @@ ViewProviderFemConstraintFixed::~ViewProviderFemConstraintFixed() = default; bool ViewProviderFemConstraintFixed::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { + if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintFixed *constrDlg = qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintFixed* constrDlg = qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { // This case will occur in the ShaftWizard application checkForWizard(); @@ -71,15 +72,19 @@ bool ViewProviderFemConstraintFixed::setEdit(int ModNum) msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) + if (ret == QMessageBox::Yes) { Gui::Control().reject(); - else + } + else { return false; - } else if (constraintDialog) { + } + } + else if (constraintDialog) { // Another FemConstraint* dialog is already open inside the Shaft Wizard // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintFixed(this); return true; } @@ -89,35 +94,40 @@ bool ViewProviderFemConstraintFixed::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintFixed(this)); + } return true; - } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + } + else { + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } #define WIDTH (2) #define HEIGHT (1) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable +// #define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - +// so disable void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintFixed *pcConstraint = static_cast(this->getObject()); - float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + Fem::ConstraintFixed* pcConstraint = static_cast(this->getObject()); + float scaledwidth = + WIDTH * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); #ifdef USE_MULTIPLE_COPY - //OvG: always need access to cp for scaling + // OvG: always need access to cp for scaling SoMultipleCopy* cp = new SoMultipleCopy(); if (pShapeSep->getNumChildren() == 0) { // Set up the nodes cp->matrix.setNum(0); - cp->addChild((SoNode*)createFixed(scaledheight, scaledwidth)); //OvG: Scaling + cp->addChild((SoNode*)createFixed(scaledheight, scaledwidth)); // OvG: Scaling pShapeSep->addChild(cp); } #endif @@ -125,8 +135,9 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) if (prop == &pcConstraint->Points) { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); - if (points.size() != normals.size()) + if (points.size() != normals.size()) { return; + } std::vector::const_iterator n = normals.begin(); #ifdef USE_MULTIPLE_COPY @@ -139,7 +150,7 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) Gui::coinRemoveAllChildren(pShapeSep); #endif - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); SbRotation rot(SbVec3f(0, -1, 0), dir); @@ -151,7 +162,7 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) #else SoSeparator* sep = new SoSeparator(); createPlacement(sep, base, rot); - createFixed(sep, scaledheight, scaledwidth); //OvG: Scaling + createFixed(sep, scaledheight, scaledwidth); // OvG: Scaling pShapeSep->addChild(sep); #endif n++; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.h index ad32899fc3..9eafbcdafb 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.h @@ -30,7 +30,8 @@ namespace FemGui { -class FemGuiExport ViewProviderFemConstraintFixed : public FemGui::ViewProviderFemConstraintOnBoundary +class FemGuiExport ViewProviderFemConstraintFixed + : public FemGui::ViewProviderFemConstraintOnBoundary { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintFixed); @@ -45,7 +46,7 @@ protected: bool setEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTFIXED_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTFIXED_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp index c3035cc3b6..dc8fe2dd2a 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp @@ -24,24 +24,25 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include #endif -#include #include "Gui/Control.h" +#include -#include "ViewProviderFemConstraintFluidBoundary.h" #include "TaskFemConstraintFluidBoundary.h" +#include "ViewProviderFemConstraintFluidBoundary.h" using namespace FemGui; -PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintFluidBoundary, FemGui::ViewProviderFemConstraintOnBoundary) +PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintFluidBoundary, + FemGui::ViewProviderFemConstraintOnBoundary) ViewProviderFemConstraintFluidBoundary::ViewProviderFemConstraintFluidBoundary() @@ -53,14 +54,15 @@ ViewProviderFemConstraintFluidBoundary::~ViewProviderFemConstraintFluidBoundary( bool ViewProviderFemConstraintFluidBoundary::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { + if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint, // object unsets and sets its edit mode without closing the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintFluidBoundary *constrDlg = - qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintFluidBoundary* constrDlg = + qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { // This case will occur in the ShaftWizard application checkForWizard(); @@ -72,15 +74,19 @@ bool ViewProviderFemConstraintFluidBoundary::setEdit(int ModNum) msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) + if (ret == QMessageBox::Yes) { Gui::Control().reject(); - else + } + else { return false; - } else if (constraintDialog) { + } + } + else if (constraintDialog) { // Another FemConstraint* dialog is already open inside the Shaft Wizard // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintFluidBoundary(this); return true; } @@ -90,57 +96,68 @@ bool ViewProviderFemConstraintFluidBoundary::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintFluidBoundary(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } -//Rendering: Combination of ConstraintFixed and ConstraintForce +// Rendering: Combination of ConstraintFixed and ConstraintForce #define ARROWLENGTH (4) #define ARROWHEADRADIUS (ARROWLENGTH / 3.0f) #define WIDTH (2) #define HEIGHT (1) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable +// #define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - +// so disable void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintFluidBoundary* pcConstraint = static_cast(this->getObject()); - float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + Fem::ConstraintFluidBoundary* pcConstraint = + static_cast(this->getObject()); + float scaledwidth = + WIDTH * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); - float scaledheadradius = ARROWHEADRADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + float scaledheadradius = + ARROWHEADRADIUS * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledlength = ARROWLENGTH * pcConstraint->Scale.getValue(); std::string boundaryType = pcConstraint->BoundaryType.getValueAsString(); if (prop == &pcConstraint->BoundaryType) { - if (boundaryType == "wall") + if (boundaryType == "wall") { FaceColor.setValue(0.0, 1.0, 1.0); - else if (boundaryType == "interface") + } + else if (boundaryType == "interface") { FaceColor.setValue(0.0, 1.0, 0.0); - else if (boundaryType == "freestream") + } + else if (boundaryType == "freestream") { FaceColor.setValue(1.0, 1.0, 0.0); - else if (boundaryType == "inlet") + } + else if (boundaryType == "inlet") { FaceColor.setValue(1.0, 0.0, 0.0); - else //(boundaryType == "outlet") + } + else { //(boundaryType == "outlet") FaceColor.setValue(0.0, 0.0, 1.0); + } } - if (boundaryType == "inlet" || boundaryType == "outlet"){ + if (boundaryType == "inlet" || boundaryType == "outlet") { #ifdef USE_MULTIPLE_COPY - //OvG: need access to cp for scaling + // OvG: need access to cp for scaling SoMultipleCopy* cp = new SoMultipleCopy(); if (pShapeSep->getNumChildren() == 0) { // Set up the nodes cp->matrix.setNum(0); - cp->addChild((SoNode*)createArrow(scaledlength , scaledheadradius)); //OvG: Scaling + cp->addChild((SoNode*)createArrow(scaledlength, scaledheadradius)); // OvG: Scaling pShapeSep->addChild(cp); } #endif @@ -162,25 +179,28 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro // Get default direction (on first call to method) Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue(); - if (forceDirection.Length() < Precision::Confusion()) + if (forceDirection.Length() < Precision::Confusion()) { forceDirection = normal; + } SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); SbRotation rot(SbVec3f(0, 1, 0), dir); - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); - if (forceDirection.GetAngle(normal) < M_PI_2) // Move arrow so it doesn't disappear inside the solid - base = base + dir * scaledlength; //OvG: Scaling + if (forceDirection.GetAngle(normal) + < M_PI_2) { // Move arrow so it doesn't disappear inside the solid + base = base + dir * scaledlength; // OvG: Scaling + } #ifdef USE_MULTIPLE_COPY SbMatrix m; - m.setTransform(base, rot, SbVec3f(1,1,1)); + m.setTransform(base, rot, SbVec3f(1, 1, 1)); matrices[idx] = m; idx++; #else SoSeparator* sep = new SoSeparator(); createPlacement(sep, base, rot); - createArrow(sep, scaledlength, scaledheadradius); //OvG: Scaling + createArrow(sep, scaledlength, scaledheadradius); // OvG: Scaling pShapeSep->addChild(sep); #endif } @@ -195,8 +215,9 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue(); if (forceDirection.Length() < Precision::Confusion()) { forceDirection = normal; - if (boundaryType == "inlet") - forceDirection = - normal; + if (boundaryType == "inlet") { + forceDirection = -normal; + } } SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); @@ -211,10 +232,11 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro #endif int idx = 0; - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); - if (forceDirection.GetAngle(normal) < M_PI_2) - base = base + dir * scaledlength; //OvG: Scaling + if (forceDirection.GetAngle(normal) < M_PI_2) { + base = base + dir * scaledlength; // OvG: Scaling + } #ifdef USE_MULTIPLE_COPY SbMatrix m; m.setTransform(base, rot, SbVec3f(1, 1, 1)); @@ -222,7 +244,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro #else SoSeparator* sep = static_cast(pShapeSep->getChild(idx)); updatePlacement(sep, 0, base, rot); - updateArrow(sep, 2, scaledlength, scaledheadradius); //OvG: Scaling + updateArrow(sep, 2, scaledlength, scaledheadradius); // OvG: Scaling #endif idx++; } @@ -231,15 +253,15 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro #endif } } - else{// not inlet or outlet boundary type + else { // not inlet or outlet boundary type #ifdef USE_MULTIPLE_COPY - //OvG: always need access to cp for scaling + // OvG: always need access to cp for scaling SoMultipleCopy* cp = new SoMultipleCopy(); if (pShapeSep->getNumChildren() == 0) { // Set up the nodes cp->matrix.setNum(0); - cp->addChild((SoNode*)createFixed(scaledheight, scaledwidth)); //OvG: Scaling + cp->addChild((SoNode*)createFixed(scaledheight, scaledwidth)); // OvG: Scaling pShapeSep->addChild(cp); } #endif @@ -247,8 +269,9 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro if (prop == &pcConstraint->Points) { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); - if (points.size() != normals.size()) + if (points.size() != normals.size()) { return; + } std::vector::const_iterator n = normals.begin(); #ifdef USE_MULTIPLE_COPY @@ -261,19 +284,19 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro Gui::coinRemoveAllChildren(pShapeSep); #endif - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); SbRotation rot(SbVec3f(0, -1, 0), dir); #ifdef USE_MULTIPLE_COPY SbMatrix m; - m.setTransform(base, rot, SbVec3f(1,1,1)); + m.setTransform(base, rot, SbVec3f(1, 1, 1)); matrices[idx] = m; idx++; #else SoSeparator* sep = new SoSeparator(); createPlacement(sep, base, rot); - createFixed(sep, scaledheight, scaledwidth); //OvG: Scaling + createFixed(sep, scaledheight, scaledwidth); // OvG: Scaling pShapeSep->addChild(sep); #endif n++; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.h index b33f3439bf..31e4100bb6 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.h @@ -30,7 +30,8 @@ namespace FemGui { -class FemGuiExport ViewProviderFemConstraintFluidBoundary : public FemGui::ViewProviderFemConstraintOnBoundary +class FemGuiExport ViewProviderFemConstraintFluidBoundary + : public FemGui::ViewProviderFemConstraintOnBoundary { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintFluidBoundary); @@ -40,12 +41,12 @@ public: ~ViewProviderFemConstraintFluidBoundary() override; void updateData(const App::Property*) override; - //virtual void onChanged(const App::Property*); //no further property for viewProvider + // virtual void onChanged(const App::Property*); //no further property for viewProvider protected: bool setEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMConstraintFluidBoundary_H +#endif // GUI_VIEWPROVIDERFEMConstraintFluidBoundary_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp index 7749c039e2..d6614dbbc0 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp @@ -24,19 +24,19 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include #endif -#include #include "Gui/Control.h" +#include -#include "ViewProviderFemConstraintForce.h" #include "TaskFemConstraintForce.h" +#include "ViewProviderFemConstraintForce.h" using namespace FemGui; @@ -53,14 +53,15 @@ ViewProviderFemConstraintForce::~ViewProviderFemConstraintForce() = default; bool ViewProviderFemConstraintForce::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { + if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintForce *constrDlg = qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintForce* constrDlg = qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { // This case will occur in the ShaftWizard application checkForWizard(); @@ -72,15 +73,19 @@ bool ViewProviderFemConstraintForce::setEdit(int ModNum) msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) + if (ret == QMessageBox::Yes) { Gui::Control().reject(); - else + } + else { return false; - } else if (constraintDialog) { + } + } + else if (constraintDialog) { // Another FemConstraint* dialog is already open inside the Shaft Wizard // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintForce(this); return true; } @@ -90,36 +95,40 @@ bool ViewProviderFemConstraintForce::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintForce(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } #define ARROWLENGTH (4) #define ARROWHEADRADIUS (ARROWLENGTH / 3.0f) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so disable +// #define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so +// disable void ViewProviderFemConstraintForce::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes Fem::ConstraintForce* pcConstraint = static_cast(this->getObject()); - float scaledheadradius = ARROWHEADRADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + float scaledheadradius = + ARROWHEADRADIUS * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledlength = ARROWLENGTH * pcConstraint->Scale.getValue(); #ifdef USE_MULTIPLE_COPY - //OvG: need access to cp for scaling + // OvG: need access to cp for scaling SoMultipleCopy* cp = new SoMultipleCopy(); if (pShapeSep->getNumChildren() == 0) { // Set up the nodes cp->matrix.setNum(0); - cp->addChild((SoNode*)createArrow(scaledlength , scaledheadradius)); //OvG: Scaling + cp->addChild((SoNode*)createArrow(scaledlength, scaledheadradius)); // OvG: Scaling pShapeSep->addChild(cp); } #endif @@ -141,17 +150,19 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) // Get default direction (on first call to method) Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue(); - if (forceDirection.Length() < Precision::Confusion()) + if (forceDirection.Length() < Precision::Confusion()) { forceDirection = normal; + } SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); - SbRotation rot(SbVec3f(0,1,0), dir); + SbRotation rot(SbVec3f(0, 1, 0), dir); - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); if (forceDirection.GetAngle(normal) - < M_PI_2)// Move arrow so it doesn't disappear inside the solid - base = base + dir * scaledlength; //OvG: Scaling + < M_PI_2) { // Move arrow so it doesn't disappear inside the solid + base = base + dir * scaledlength; // OvG: Scaling + } #ifdef USE_MULTIPLE_COPY SbMatrix m; m.setTransform(base, rot, SbVec3f(1, 1, 1)); @@ -160,7 +171,7 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) #else SoSeparator* sep = new SoSeparator(); createPlacement(sep, base, rot); - createArrow(sep, scaledlength, scaledheadradius); //OvG: Scaling + createArrow(sep, scaledlength, scaledheadradius); // OvG: Scaling pShapeSep->addChild(sep); #endif } @@ -173,8 +184,9 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) // Re-orient all arrows Base::Vector3d normal = pcConstraint->NormalDirection.getValue(); Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue(); - if (forceDirection.Length() < Precision::Confusion()) + if (forceDirection.Length() < Precision::Confusion()) { forceDirection = normal; + } SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); SbRotation rot(SbVec3f(0, 1, 0), dir); @@ -188,10 +200,11 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) #endif int idx = 0; - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); - if (forceDirection.GetAngle(normal) < M_PI_2) - base = base + dir * scaledlength; //OvG: Scaling + if (forceDirection.GetAngle(normal) < M_PI_2) { + base = base + dir * scaledlength; // OvG: Scaling + } #ifdef USE_MULTIPLE_COPY SbMatrix m; m.setTransform(base, rot, SbVec3f(1, 1, 1)); @@ -199,7 +212,7 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) #else SoSeparator* sep = static_cast(pShapeSep->getChild(idx)); updatePlacement(sep, 0, base, rot); - updateArrow(sep, 2, scaledlength, scaledheadradius); //OvG: Scaling + updateArrow(sep, 2, scaledlength, scaledheadradius); // OvG: Scaling #endif idx++; } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.h index da72e2c6c5..8008780a93 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.h @@ -30,7 +30,8 @@ namespace FemGui { -class FemGuiExport ViewProviderFemConstraintForce : public FemGui::ViewProviderFemConstraintOnBoundary +class FemGuiExport ViewProviderFemConstraintForce + : public FemGui::ViewProviderFemConstraintOnBoundary { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintForce); @@ -49,7 +50,7 @@ private: Base::Vector3f forceDirection; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTFORCE_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTFORCE_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp index 48624fa391..e0f860f73f 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp @@ -24,20 +24,20 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include #endif -#include #include "Gui/Control.h" +#include #include -#include "ViewProviderFemConstraintGear.h" #include "TaskFemConstraintGear.h" +#include "ViewProviderFemConstraintGear.h" using namespace FemGui; @@ -54,14 +54,15 @@ ViewProviderFemConstraintGear::~ViewProviderFemConstraintGear() = default; bool ViewProviderFemConstraintGear::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { + if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintGear *constrDlg = qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintGear* constrDlg = qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { // This case will occur in the ShaftWizard application checkForWizard(); @@ -73,15 +74,19 @@ bool ViewProviderFemConstraintGear::setEdit(int ModNum) msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) + if (ret == QMessageBox::Yes) { Gui::Control().reject(); - else + } + else { return false; - } else if (constraintDialog) { + } + } + else if (constraintDialog) { // Another FemConstraint* dialog is already open inside the Shaft Wizard // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintGear(this); return true; } @@ -91,15 +96,17 @@ bool ViewProviderFemConstraintGear::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintGear(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } @@ -116,54 +123,67 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) Base::Vector3d base = pcConstraint->BasePoint.getValue(); Base::Vector3d axis = pcConstraint->Axis.getValue(); Base::Vector3d direction = pcConstraint->DirectionVector.getValue(); - if (direction.Length() < Precision::Confusion()) + if (direction.Length() < Precision::Confusion()) { direction = Base::Vector3d(0, 1, 0); + } double radius = pcConstraint->Radius.getValue(); double dia = pcConstraint->Diameter.getValue(); - if (dia < 2 * radius) + if (dia < 2 * radius) { dia = 2 * radius; + } double angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI; SbVec3f b(base.x, base.y, base.z); SbVec3f ax(axis.x, axis.y, axis.z); SbVec3f dir(direction.x, direction.y, direction.z); - //Base::Console().Error("DirectionVector: %f, %f, %f\n", direction.x, direction.y, direction.z); + // Base::Console().Error("DirectionVector: %f, %f, %f\n", direction.x, direction.y, + // direction.z); - createPlacement(pShapeSep, b, SbRotation(SbVec3f(0,1,0), ax)); - pShapeSep->addChild(createCylinder(pcConstraint->Height.getValue() * 0.8, dia/2)); - createPlacement(pShapeSep, SbVec3f(dia/2 * sin(angle), 0, dia/2 * cos(angle)), SbRotation(ax, dir)); - pShapeSep->addChild(createArrow(dia/2, dia/8)); + createPlacement(pShapeSep, b, SbRotation(SbVec3f(0, 1, 0), ax)); + pShapeSep->addChild(createCylinder(pcConstraint->Height.getValue() * 0.8, dia / 2)); + createPlacement(pShapeSep, + SbVec3f(dia / 2 * sin(angle), 0, dia / 2 * cos(angle)), + SbRotation(ax, dir)); + pShapeSep->addChild(createArrow(dia / 2, dia / 8)); } - } else if (prop == &pcConstraint->Diameter) { + } + else if (prop == &pcConstraint->Diameter) { if (pShapeSep->getNumChildren() > 0) { // Change the symbol Base::Vector3d axis = pcConstraint->Axis.getValue(); Base::Vector3d direction = pcConstraint->DirectionVector.getValue(); - if (direction.Length() < Precision::Confusion()) + if (direction.Length() < Precision::Confusion()) { direction = Base::Vector3d(0, 1, 0); + } double dia = pcConstraint->Diameter.getValue(); double radius = pcConstraint->Radius.getValue(); - if (dia < 2 * radius) + if (dia < 2 * radius) { dia = 2 * radius; + } double angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI; SbVec3f ax(axis.x, axis.y, axis.z); SbVec3f dir(direction.x, direction.y, direction.z); const SoSeparator* sep = static_cast(pShapeSep->getChild(2)); - updateCylinder(sep, 0, pcConstraint->Height.getValue() * 0.8, dia/2); - updatePlacement(pShapeSep, 3, SbVec3f(dia/2 * sin(angle), 0, dia/2 * cos(angle)), SbRotation(ax, dir)); + updateCylinder(sep, 0, pcConstraint->Height.getValue() * 0.8, dia / 2); + updatePlacement(pShapeSep, + 3, + SbVec3f(dia / 2 * sin(angle), 0, dia / 2 * cos(angle)), + SbRotation(ax, dir)); sep = static_cast(pShapeSep->getChild(5)); - updateArrow(sep, 0, dia/2, dia/8); + updateArrow(sep, 0, dia / 2, dia / 8); } - } else if ((prop == &pcConstraint->DirectionVector) || (prop == &pcConstraint->ForceAngle)) { + } + else if ((prop == &pcConstraint->DirectionVector) || (prop == &pcConstraint->ForceAngle)) { // Note: "Reversed" also triggers "DirectionVector" if (pShapeSep->getNumChildren() > 0) { // Re-orient the symbol Base::Vector3d axis = pcConstraint->Axis.getValue(); Base::Vector3d direction = pcConstraint->DirectionVector.getValue(); - if (direction.Length() < Precision::Confusion()) - direction = Base::Vector3d(0,1,0); + if (direction.Length() < Precision::Confusion()) { + direction = Base::Vector3d(0, 1, 0); + } double dia = pcConstraint->Diameter.getValue(); double angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI; @@ -179,10 +199,14 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) Base::Console().Error("Matrix: %f, %f, %f, %f\n", m[0][0], m[1][0], m[2][0], m[3][0]); // Note: In spite of the fact that the rotation matrix takes on 3 different values if 3 // normal directions are chosen, the resulting arrow will only point in two different - // directions when ax = (1,0,0) (but for ax=(0,1,0) it points in 3 different directions!) + // directions when ax = (1,0,0) (but for ax=(0,1,0) it points in 3 different + directions!) */ - updatePlacement(pShapeSep, 3, SbVec3f(dia/2 * sin(angle), 0, dia/2 * cos(angle)), SbRotation(ax, dir)); + updatePlacement(pShapeSep, + 3, + SbVec3f(dia / 2 * sin(angle), 0, dia / 2 * cos(angle)), + SbRotation(ax, dir)); } } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.h index 1656034bcd..d5ee8f8f62 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.h @@ -30,7 +30,7 @@ namespace FemGui { -class FemGuiExport ViewProviderFemConstraintGear : public FemGui::ViewProviderFemConstraint +class FemGuiExport ViewProviderFemConstraintGear: public FemGui::ViewProviderFemConstraint { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintGear); @@ -45,7 +45,7 @@ protected: bool setEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTGear_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTGear_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp index f4592da203..f876fc5e82 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp @@ -26,24 +26,25 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include #endif -#include #include "Mod/Fem/App/FemConstraintHeatflux.h" +#include -#include "ViewProviderFemConstraintHeatflux.h" #include "TaskFemConstraintHeatflux.h" +#include "ViewProviderFemConstraintHeatflux.h" using namespace FemGui; -PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintHeatflux, FemGui::ViewProviderFemConstraintOnBoundary) +PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintHeatflux, + FemGui::ViewProviderFemConstraintOnBoundary) ViewProviderFemConstraintHeatflux::ViewProviderFemConstraintHeatflux() { @@ -53,22 +54,24 @@ ViewProviderFemConstraintHeatflux::ViewProviderFemConstraintHeatflux() ViewProviderFemConstraintHeatflux::~ViewProviderFemConstraintHeatflux() = default; -//FIXME setEdit needs a careful review +// FIXME setEdit needs a careful review bool ViewProviderFemConstraintHeatflux::setEdit(int ModNum) { if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintHeatflux *constrDlg = qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintHeatflux* constrDlg = qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { if (constraintDialog) { // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintHeatflux(this); return true; } @@ -78,100 +81,107 @@ bool ViewProviderFemConstraintHeatflux::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintHeatflux(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } #define HEIGHT (1.5) #define RADIUS (0.3) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable +// #define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - +// so disable void ViewProviderFemConstraintHeatflux::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintHeatflux* pcConstraint = static_cast(this->getObject()); - float scaledradius = RADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + Fem::ConstraintHeatflux* pcConstraint = + static_cast(this->getObject()); + float scaledradius = + RADIUS * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); - //float ambienttemp = pcConstraint->AmbientTemp.getValue(); - // //float facetemp = pcConstraint->FaceTemp.getValue(); - //float filmcoef = pcConstraint->FilmCoef.getValue(); + // float ambienttemp = pcConstraint->AmbientTemp.getValue(); + // //float facetemp = pcConstraint->FaceTemp.getValue(); + // float filmcoef = pcConstraint->FilmCoef.getValue(); if (prop == &pcConstraint->Points) { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); - if (points.size() != normals.size()) + if (points.size() != normals.size()) { return; + } std::vector::const_iterator n = normals.begin(); // Note: Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (const auto & point : points) { - //Define base and normal directions + for (const auto& point : points) { + // Define base and normal directions SbVec3f base(point.x, point.y, point.z); - SbVec3f dir(n->x, n->y, n->z);//normal + SbVec3f dir(n->x, n->y, n->z); // normal - ///Temperature indication - //define separator + /// Temperature indication + // define separator SoSeparator* sep = new SoSeparator(); - ///draw a temp gauge,with sphere and a cylinder - //first move to correct position - SoTranslation *trans = new SoTranslation(); + /// draw a temp gauge,with sphere and a cylinder + // first move to correct position + SoTranslation* trans = new SoTranslation(); SbVec3f newPos = base + scaledradius * dir * 0.7f; trans->translation.setValue(newPos); sep->addChild(trans); - //adjust orientation - SoRotation *rot = new SoRotation(); + // adjust orientation + SoRotation* rot = new SoRotation(); rot->rotation.setValue(SbRotation(SbVec3f(0, 1, 0), dir)); sep->addChild(rot); - //define color of shape - SoMaterial *myMaterial = new SoMaterial; - myMaterial->diffuseColor.set1Value(0, SbColor(0.65f, 0.1f, 0.25f));//RGB - //myMaterial->diffuseColor.set1Value(1,SbColor(.1,.1,.1));//possible to adjust sides separately + // define color of shape + SoMaterial* myMaterial = new SoMaterial; + myMaterial->diffuseColor.set1Value(0, SbColor(0.65f, 0.1f, 0.25f)); // RGB + // myMaterial->diffuseColor.set1Value(1,SbColor(.1,.1,.1));//possible to adjust sides + // separately sep->addChild(myMaterial); - //draw a sphere - SoSphere *sph = new SoSphere(); + // draw a sphere + SoSphere* sph = new SoSphere(); sph->radius.setValue(scaledradius * 0.75); sep->addChild(sph); - //translate position - SoTranslation *trans2 = new SoTranslation(); + // translate position + SoTranslation* trans2 = new SoTranslation(); trans2->translation.setValue(SbVec3f(0, scaledheight * 0.375, 0)); sep->addChild(trans2); - //draw a cylinder - SoCylinder *cyl = new SoCylinder(); + // draw a cylinder + SoCylinder* cyl = new SoCylinder(); cyl->height.setValue(scaledheight * 0.5); cyl->radius.setValue(scaledradius * 0.375); sep->addChild(cyl); - //translate position - SoTranslation *trans3 = new SoTranslation(); + // translate position + SoTranslation* trans3 = new SoTranslation(); trans3->translation.setValue(SbVec3f(0, scaledheight * 0.375, 0)); sep->addChild(trans3); - //define color of shape - SoMaterial *myMaterial2 = new SoMaterial; - myMaterial2->diffuseColor.set1Value(0, SbColor(1, 1, 1));//RGB + // define color of shape + SoMaterial* myMaterial2 = new SoMaterial; + myMaterial2->diffuseColor.set1Value(0, SbColor(1, 1, 1)); // RGB sep->addChild(myMaterial2); - //draw a cylinder - SoCylinder *cyl2 = new SoCylinder(); + // draw a cylinder + SoCylinder* cyl2 = new SoCylinder(); cyl2->height.setValue(scaledheight * 0.25); cyl2->radius.setValue(scaledradius * 0.375); sep->addChild(cyl2); - //translate position - SoTranslation *trans4 = new SoTranslation(); + // translate position + SoTranslation* trans4 = new SoTranslation(); trans4->translation.setValue(SbVec3f(0, -scaledheight * 0.375, 0)); sep->addChild(trans4); - //draw a cylinder - SoCylinder *cyl3 = new SoCylinder(); + // draw a cylinder + SoCylinder* cyl3 = new SoCylinder(); cyl3->height.setValue(scaledheight * 0.05); cyl3->radius.setValue(scaledradius * 1); sep->addChild(cyl3); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.h index cf8bb01742..2dc2724638 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.h @@ -28,9 +28,11 @@ #include "ViewProviderFemConstraintOnBoundary.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintHeatflux : public FemGui::ViewProviderFemConstraintOnBoundary +class FemGuiExport ViewProviderFemConstraintHeatflux + : public FemGui::ViewProviderFemConstraintOnBoundary { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintHeatflux); @@ -43,6 +45,6 @@ protected: bool setEdit(int ModNum) override; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTHEATFLUX_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTHEATFLUX_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp index d5a9a072d5..46018961e3 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp @@ -25,16 +25,17 @@ #include "PreCompiled.h" -#include #include "Mod/Fem/App/FemConstraintInitialTemperature.h" +#include -#include "ViewProviderFemConstraintInitialTemperature.h" #include "TaskFemConstraintInitialTemperature.h" +#include "ViewProviderFemConstraintInitialTemperature.h" using namespace FemGui; -PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintInitialTemperature, FemGui::ViewProviderFemConstraint) +PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintInitialTemperature, + FemGui::ViewProviderFemConstraint) ViewProviderFemConstraintInitialTemperature::ViewProviderFemConstraintInitialTemperature() { @@ -42,25 +43,28 @@ ViewProviderFemConstraintInitialTemperature::ViewProviderFemConstraintInitialTem ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f)); } -ViewProviderFemConstraintInitialTemperature::~ViewProviderFemConstraintInitialTemperature() = default; +ViewProviderFemConstraintInitialTemperature::~ViewProviderFemConstraintInitialTemperature() = + default; -//FIXME setEdit needs a careful review +// FIXME setEdit needs a careful review bool ViewProviderFemConstraintInitialTemperature::setEdit(int ModNum) { if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintInitialTemperature *constrDlg = - qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintInitialTemperature* constrDlg = + qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { if (constraintDialog) { // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintInitialTemperature(this); return true; } @@ -70,14 +74,16 @@ bool ViewProviderFemConstraintInitialTemperature::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintInitialTemperature(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.h index b80a2b3097..f30a62666e 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.h @@ -28,9 +28,11 @@ #include "ViewProviderFemConstraint.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintInitialTemperature : public FemGui::ViewProviderFemConstraint +class FemGuiExport ViewProviderFemConstraintInitialTemperature + : public FemGui::ViewProviderFemConstraint { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintInitialTemperature); @@ -43,6 +45,6 @@ protected: bool setEdit(int ModNum) override; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTInitialTemperature_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTInitialTemperature_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintOnBoundary.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintOnBoundary.cpp index 90bf634ce6..30a09fb79d 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintOnBoundary.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintOnBoundary.cpp @@ -23,13 +23,13 @@ #include "PreCompiled.h" -#include #include "Mod/Fem/App/FemConstraint.h" +#include #include #include -#include "ViewProviderFemConstraintOnBoundary.h" #include "TaskFemConstraintOnBoundary.h" +#include "ViewProviderFemConstraintOnBoundary.h" using namespace FemGui; @@ -47,10 +47,14 @@ void ViewProviderFemConstraintOnBoundary::highlightReferences(const bool on) for (auto& subSet : subSets) { Part::Feature* base = dynamic_cast(subSet.first); - if (!base) continue; + if (!base) { + continue; + } PartGui::ViewProviderPart* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(base)); - if (!vp) continue; + if (!vp) { + continue; + } // if somehow the subnames are empty, clear any existing colors if (on && !subSet.second.empty()) { @@ -59,40 +63,46 @@ void ViewProviderFemConstraintOnBoundary::highlightReferences(const bool on) // It is a requirement but we should keep safeguards. if (subSet.second[0].find("Vertex") != std::string::npos) { // make sure original colors are remembered - if (originalPointColors[base].empty()) + if (originalPointColors[base].empty()) { originalPointColors[base] = vp->PointColorArray.getValues(); + } std::vector colors = originalPointColors[base]; // go through the subelements with constraint and recolor them // TODO: Replace `ShapeColor` with anything more appropriate - PartGui::ReferenceHighlighter highlighter( - base->Shape.getValue(), colors.empty() ? ShapeColor.getValue() : colors[0]); + PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), + colors.empty() ? ShapeColor.getValue() + : colors[0]); highlighter.getVertexColors(subSet.second, colors); vp->PointColorArray.setValues(colors); } else if (subSet.second[0].find("Edge") != std::string::npos) { // make sure original colors are remembered - if (originalLineColors[base].empty()) + if (originalLineColors[base].empty()) { originalLineColors[base] = vp->LineColorArray.getValues(); + } std::vector colors = originalLineColors[base]; // go through the subelements with constraint and recolor them // TODO: Replace `ShapeColor` with anything more appropriate - PartGui::ReferenceHighlighter highlighter( - base->Shape.getValue(), colors.empty() ? ShapeColor.getValue() : colors[0]); + PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), + colors.empty() ? ShapeColor.getValue() + : colors[0]); highlighter.getEdgeColors(subSet.second, colors); vp->LineColorArray.setValues(colors); } else if (subSet.second[0].find("Face") != std::string::npos) { // make sure original colors are remembered - if (originalFaceColors[base].empty()) + if (originalFaceColors[base].empty()) { originalFaceColors[base] = vp->DiffuseColor.getValues(); + } std::vector colors = originalFaceColors[base]; // go through the subelements with constraint and recolor them // TODO: Replace `FaceColor` with anything more appropriate - PartGui::ReferenceHighlighter highlighter( - base->Shape.getValue(), colors.empty() ? FaceColor.getValue() : colors[0]); + PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), + colors.empty() ? FaceColor.getValue() + : colors[0]); highlighter.getFaceColors(subSet.second, colors); vp->DiffuseColor.setValues(colors); } @@ -117,34 +127,45 @@ void ViewProviderFemConstraintOnBoundary::highlightReferences(const bool on) // there is nothing selected but previous selection may have highlighting // reset that highlighting here for (auto& ogPair : originalPointColors) { - if (ogPair.second.empty()) continue; + if (ogPair.second.empty()) { + continue; + } PartGui::ViewProviderPart* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(ogPair.first)); - if (!vp) continue; + if (!vp) { + continue; + } vp->PointColorArray.setValues(ogPair.second); ogPair.second.clear(); } for (auto& ogPair : originalLineColors) { - if (ogPair.second.empty()) continue; + if (ogPair.second.empty()) { + continue; + } PartGui::ViewProviderPart* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(ogPair.first)); - if (!vp) continue; + if (!vp) { + continue; + } vp->LineColorArray.setValues(ogPair.second); ogPair.second.clear(); } for (auto& ogPair : originalFaceColors) { - if (ogPair.second.empty()) continue; + if (ogPair.second.empty()) { + continue; + } PartGui::ViewProviderPart* vp = dynamic_cast( Gui::Application::Instance->getViewProvider(ogPair.first)); - if (!vp) continue; + if (!vp) { + continue; + } vp->DiffuseColor.setValues(ogPair.second); ogPair.second.clear(); } } } - diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintOnBoundary.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintOnBoundary.h index f4ac82f8c5..004e0e81ad 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintOnBoundary.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintOnBoundary.h @@ -28,9 +28,10 @@ #include "ViewProviderFemConstraint.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintOnBoundary : public FemGui::ViewProviderFemConstraint +class FemGuiExport ViewProviderFemConstraintOnBoundary: public FemGui::ViewProviderFemConstraint { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintOnBoundary); @@ -41,11 +42,11 @@ public: void highlightReferences(const bool on) override; private: - std::map< Part::Feature*, std::vector > originalPointColors; - std::map< Part::Feature*, std::vector > originalLineColors; - std::map< Part::Feature*, std::vector > originalFaceColors; + std::map> originalPointColors; + std::map> originalLineColors; + std::map> originalFaceColors; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTONBOUNDARY_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTONBOUNDARY_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp index 9e0effc171..ea2cf874ae 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp @@ -26,19 +26,19 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include #endif -#include #include "Mod/Fem/App/FemConstraintPlaneRotation.h" +#include -#include "ViewProviderFemConstraintPlaneRotation.h" #include "TaskFemConstraintPlaneRotation.h" +#include "ViewProviderFemConstraintPlaneRotation.h" using namespace FemGui; @@ -48,29 +48,32 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintPlaneRotation, FemGui::ViewProv ViewProviderFemConstraintPlaneRotation::ViewProviderFemConstraintPlaneRotation() { sPixmap = "FEM_ConstraintPlaneRotation"; - //Note change "planerotation" in line above to new constraint name, make sure it is the same as in taskFem* cpp file + // Note change "planerotation" in line above to new constraint name, make sure it is the same as + // in taskFem* cpp file ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f)); } ViewProviderFemConstraintPlaneRotation::~ViewProviderFemConstraintPlaneRotation() = default; -//FIXME setEdit needs a careful review +// FIXME setEdit needs a careful review bool ViewProviderFemConstraintPlaneRotation::setEdit(int ModNum) { if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintPlaneRotation *constrDlg = - qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintPlaneRotation* constrDlg = + qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { if (constraintDialog) { // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintPlaneRotation(this); return true; } @@ -80,99 +83,105 @@ bool ViewProviderFemConstraintPlaneRotation::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintPlaneRotation(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } #define HEIGHT (0.5) #define RADIUS (5) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable +// #define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - +// so disable void ViewProviderFemConstraintPlaneRotation::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintPlaneRotation *pcConstraint = - static_cast(this->getObject()); - float scaledradius = RADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + Fem::ConstraintPlaneRotation* pcConstraint = + static_cast(this->getObject()); + float scaledradius = + RADIUS * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); if (prop == &pcConstraint->Points) { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); - if (points.size() != normals.size()) + if (points.size() != normals.size()) { return; + } std::vector::const_iterator n = normals.begin(); // Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (const auto & point : points) { - //Define base and normal directions + for (const auto& point : points) { + // Define base and normal directions SbVec3f base(point.x, point.y, point.z); - SbVec3f dir(n->x, n->y, n->z);//normal + SbVec3f dir(n->x, n->y, n->z); // normal - /* Note: - * This next part draws a temperature gauge in 3D to indicate the constraint visually. - * This serves as an example. Change or remove as needs be. - * It is possible to draw almost any basic 3D shape. See inventor's documentation - * This gets drawn at every point. - * */ + /* Note: + * This next part draws a temperature gauge in 3D to indicate the constraint visually. + * This serves as an example. Change or remove as needs be. + * It is possible to draw almost any basic 3D shape. See inventor's documentation + * This gets drawn at every point. + * */ - ///Visual indication - //define separator + /// Visual indication + // define separator SoSeparator* sep = new SoSeparator(); - ///draw a temp gauge,with sphere and a cylinder - //first move to correct position - SoTranslation *trans = new SoTranslation(); + /// draw a temp gauge,with sphere and a cylinder + // first move to correct position + SoTranslation* trans = new SoTranslation(); SbVec3f newPos = base + scaledradius * dir * 0.08f; trans->translation.setValue(newPos); sep->addChild(trans); - //adjust orientation - SoRotation *rot = new SoRotation(); + // adjust orientation + SoRotation* rot = new SoRotation(); rot->rotation.setValue(SbRotation(SbVec3f(1, 0, 0), dir)); sep->addChild(rot); - //define color of shape - SoMaterial *myMaterial = new SoMaterial; - myMaterial->diffuseColor.set1Value(0, SbColor(0, 1, 0)); //RGB - //myMaterial->diffuseColor.set1Value(1,SbColor(0,0,1));//possible to adjust sides separately + // define color of shape + SoMaterial* myMaterial = new SoMaterial; + myMaterial->diffuseColor.set1Value(0, SbColor(0, 1, 0)); // RGB + // myMaterial->diffuseColor.set1Value(1,SbColor(0,0,1));//possible to adjust sides + // separately sep->addChild(myMaterial); - //draw a sphere - //SoSphere* sph = new SoSphere(); - //sph->radius.setValue(scaledradius*0.75); - //sep->addChild(sph); - //translate position - //SoTranslation* trans2 = new SoTranslation(); - //trans2->translation.setValue(SbVec3f(0,scaledheight*0.375,0)); - //sep->addChild(trans2); - //draw a cylinder - SoCylinder *cyl = new SoCylinder(); + // draw a sphere + // SoSphere* sph = new SoSphere(); + // sph->radius.setValue(scaledradius*0.75); + // sep->addChild(sph); + // translate position + // SoTranslation* trans2 = new SoTranslation(); + // trans2->translation.setValue(SbVec3f(0,scaledheight*0.375,0)); + // sep->addChild(trans2); + // draw a cylinder + SoCylinder* cyl = new SoCylinder(); cyl->height.setValue(scaledheight * 0.5); cyl->radius.setValue(scaledradius * 0.375); sep->addChild(cyl); - //translate position - //SoTranslation* trans3 = new SoTranslation(); - //trans3->translation.setValue(SbVec3f(0,scaledheight*0.05,0)); - //sep->addChild(trans3); - //define color of shape - SoMaterial *myMaterial2 = new SoMaterial; - myMaterial2->diffuseColor.set1Value(0, SbColor(1, 1, 1)); //RGB + // translate position + // SoTranslation* trans3 = new SoTranslation(); + // trans3->translation.setValue(SbVec3f(0,scaledheight*0.05,0)); + // sep->addChild(trans3); + // define color of shape + SoMaterial* myMaterial2 = new SoMaterial; + myMaterial2->diffuseColor.set1Value(0, SbColor(1, 1, 1)); // RGB sep->addChild(myMaterial2); - //draw a cylinder - //SoCylinder* cyl2 = new SoCylinder(); - //cyl2->height.setValue(scaledheight*0.25); - //cyl2->radius.setValue(scaledradius*0.375); - //sep->addChild(cyl2); + // draw a cylinder + // SoCylinder* cyl2 = new SoCylinder(); + // cyl2->height.setValue(scaledheight*0.25); + // cyl2->radius.setValue(scaledradius*0.375); + // sep->addChild(cyl2); pShapeSep->addChild(sep); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.h index 9a6579c537..e86d8472c1 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.h @@ -28,9 +28,10 @@ #include "ViewProviderFemConstraint.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintPlaneRotation : public FemGui::ViewProviderFemConstraint +class FemGuiExport ViewProviderFemConstraintPlaneRotation: public FemGui::ViewProviderFemConstraint { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintPlaneRotation); @@ -43,6 +44,6 @@ protected: bool setEdit(int ModNum) override; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTPLANEROTATION_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTPLANEROTATION_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp index 8595a4f9a3..089edd28af 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp @@ -24,22 +24,23 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include #endif -#include #include "Mod/Fem/App/FemConstraintPressure.h" +#include -#include "ViewProviderFemConstraintPressure.h" #include "TaskFemConstraintPressure.h" +#include "ViewProviderFemConstraintPressure.h" using namespace FemGui; -PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintPressure, FemGui::ViewProviderFemConstraintOnBoundary) +PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintPressure, + FemGui::ViewProviderFemConstraintOnBoundary) ViewProviderFemConstraintPressure::ViewProviderFemConstraintPressure() { @@ -49,22 +50,24 @@ ViewProviderFemConstraintPressure::ViewProviderFemConstraintPressure() ViewProviderFemConstraintPressure::~ViewProviderFemConstraintPressure() = default; -//FIXME setEdit needs a careful review +// FIXME setEdit needs a careful review bool ViewProviderFemConstraintPressure::setEdit(int ModNum) { if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintPressure *constrDlg = qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintPressure* constrDlg = qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { if (constraintDialog) { // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintPressure(this); return true; } @@ -74,36 +77,40 @@ bool ViewProviderFemConstraintPressure::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintPressure(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } #define ARROWLENGTH (4) -#define ARROWHEADRADIUS (ARROWLENGTH/3.0f) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so disable +#define ARROWHEADRADIUS (ARROWLENGTH / 3.0f) +// #define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so +// disable void ViewProviderFemConstraintPressure::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintPressure *pcConstraint = - static_cast(this->getObject()); - float scaledheadradius = ARROWHEADRADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + Fem::ConstraintPressure* pcConstraint = + static_cast(this->getObject()); + float scaledheadradius = + ARROWHEADRADIUS * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledlength = ARROWLENGTH * pcConstraint->Scale.getValue(); #ifdef USE_MULTIPLE_COPY - //OvG: always need access to cp for scaling + // OvG: always need access to cp for scaling SoMultipleCopy* cp = new SoMultipleCopy(); if (pShapeSep->getNumChildren() == 0) { // Set up the nodes cp->matrix.setNum(0); - cp->addChild((SoNode*)createArrow(scaledlength , scaledheadradius)); //OvG: Scaling + cp->addChild((SoNode*)createArrow(scaledlength, scaledheadradius)); // OvG: Scaling pShapeSep->addChild(cp); } #endif @@ -117,7 +124,7 @@ void ViewProviderFemConstraintPressure::updateData(const App::Property* prop) std::vector::const_iterator n = normals.begin(); #ifdef USE_MULTIPLE_COPY - cp = static_cast(pShapeSep->getChild(0)); //OvG: Use top cp + cp = static_cast(pShapeSep->getChild(0)); // OvG: Use top cp cp->matrix.setNum(points.size()); SbMatrix* matrices = cp->matrix.startEditing(); int idx = 0; @@ -126,14 +133,15 @@ void ViewProviderFemConstraintPressure::updateData(const App::Property* prop) Gui::coinRemoveAllChildren(pShapeSep); #endif - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); double rev; if (pcConstraint->Reversed.getValue()) { - base = base + dir * scaledlength; //OvG: Scaling + base = base + dir * scaledlength; // OvG: Scaling rev = 1; - } else { + } + else { rev = -1; } SbRotation rot(SbVec3f(0, rev, 0), dir); @@ -145,7 +153,7 @@ void ViewProviderFemConstraintPressure::updateData(const App::Property* prop) #else SoSeparator* sep = new SoSeparator(); createPlacement(sep, base, rot); - createArrow(sep, scaledlength , scaledheadradius); //OvG: Scaling + createArrow(sep, scaledlength, scaledheadradius); // OvG: Scaling pShapeSep->addChild(sep); #endif n++; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.h index 870b45eebf..6b1c9ebcc3 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.h @@ -26,9 +26,11 @@ #include "ViewProviderFemConstraintOnBoundary.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintPressure : public FemGui::ViewProviderFemConstraintOnBoundary +class FemGuiExport ViewProviderFemConstraintPressure + : public FemGui::ViewProviderFemConstraintOnBoundary { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintPressure); @@ -41,6 +43,6 @@ protected: bool setEdit(int ModNum) override; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTPRESSURE_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTPRESSURE_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp index 5ce1c629d6..dc206ebc22 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp @@ -24,17 +24,17 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include #endif #include "Gui/Control.h" -#include -#include "ViewProviderFemConstraintPulley.h" #include "TaskFemConstraintPulley.h" +#include "ViewProviderFemConstraintPulley.h" +#include using namespace FemGui; @@ -51,14 +51,15 @@ ViewProviderFemConstraintPulley::~ViewProviderFemConstraintPulley() = default; bool ViewProviderFemConstraintPulley::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { + if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintPulley *constrDlg = qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintPulley* constrDlg = qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { // This case will occur in the ShaftWizard application checkForWizard(); @@ -70,15 +71,19 @@ bool ViewProviderFemConstraintPulley::setEdit(int ModNum) msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) + if (ret == QMessageBox::Yes) { Gui::Control().reject(); - else + } + else { return false; - } else if (constraintDialog) { + } + } + else if (constraintDialog) { // Another FemConstraint* dialog is already open inside the Shaft Wizard // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintPulley(this); return true; } @@ -88,15 +93,17 @@ bool ViewProviderFemConstraintPulley::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintPulley(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } @@ -115,8 +122,9 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) Base::Vector3d axis = pcConstraint->Axis.getValue(); double radius = pcConstraint->Radius.getValue(); double dia = pcConstraint->Diameter.getValue(); - if (dia < 2 * radius) + if (dia < 2 * radius) { dia = 2 * radius; + } double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI; double beltAngle = pcConstraint->BeltAngle.getValue(); double rat1 = 0.8, rat2 = 0.2; @@ -130,29 +138,33 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) SbVec3f b(base.x, base.y, base.z); SbVec3f ax(axis.x, axis.y, axis.z); - createPlacement(pShapeSep, b, SbRotation(SbVec3f(0, 1, 0), ax));// child 0 and 1 + createPlacement(pShapeSep, b, SbRotation(SbVec3f(0, 1, 0), ax)); // child 0 and 1 pShapeSep->addChild( - createCylinder(pcConstraint->Height.getValue() * 0.8, dia / 2));// child 2 - SoSeparator *sep = new SoSeparator(); + createCylinder(pcConstraint->Height.getValue() * 0.8, dia / 2)); // child 2 + SoSeparator* sep = new SoSeparator(); createPlacement(sep, - SbVec3f(dia / 2 * sin(forceAngle + beltAngle), 0, + SbVec3f(dia / 2 * sin(forceAngle + beltAngle), + 0, dia / 2 * cos(forceAngle + beltAngle)), SbRotation(SbVec3f(0, 1, 0), - SbVec3f(sin(forceAngle + beltAngle + M_PI_2), 0, + SbVec3f(sin(forceAngle + beltAngle + M_PI_2), + 0, cos(forceAngle + beltAngle + M_PI_2)))); createPlacement(sep, SbVec3f(0, dia / 8 + dia / 2 * rat1, 0), SbRotation()); sep->addChild(createArrow(dia / 8 + dia / 2 * rat1, dia / 8)); - pShapeSep->addChild(sep);// child 3 + pShapeSep->addChild(sep); // child 3 sep = new SoSeparator(); createPlacement(sep, - SbVec3f(-dia / 2 * sin(forceAngle - beltAngle), 0, + SbVec3f(-dia / 2 * sin(forceAngle - beltAngle), + 0, -dia / 2 * cos(forceAngle - beltAngle)), SbRotation(SbVec3f(0, 1, 0), - SbVec3f(-sin(forceAngle - beltAngle - M_PI_2), 0, + SbVec3f(-sin(forceAngle - beltAngle - M_PI_2), + 0, -cos(forceAngle - beltAngle - M_PI_2)))); createPlacement(sep, SbVec3f(0, dia / 8 + dia / 2 * rat2, 0), SbRotation()); sep->addChild(createArrow(dia / 8 + dia / 2 * rat2, dia / 8)); - pShapeSep->addChild(sep);// child 4 + pShapeSep->addChild(sep); // child 4 } } else if (prop == &pcConstraint->Diameter) { @@ -160,8 +172,9 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) // Change the symbol double radius = pcConstraint->Radius.getValue(); double dia = pcConstraint->Diameter.getValue(); - if (dia < 2 * radius) + if (dia < 2 * radius) { dia = 2 * radius; + } double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI; double beltAngle = pcConstraint->BeltAngle.getValue(); double rat1 = 0.8, rat2 = 0.2; @@ -172,27 +185,33 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) rat2 = f2 / (f1 + f2); } - const SoSeparator *sep = static_cast(pShapeSep->getChild(2)); + const SoSeparator* sep = static_cast(pShapeSep->getChild(2)); updateCylinder(sep, 0, pcConstraint->Height.getValue() * 0.8, dia / 2); - sep = static_cast(pShapeSep->getChild(3)); - updatePlacement(sep, 0, - SbVec3f(dia / 2 * sin(forceAngle + beltAngle), 0, + sep = static_cast(pShapeSep->getChild(3)); + updatePlacement(sep, + 0, + SbVec3f(dia / 2 * sin(forceAngle + beltAngle), + 0, dia / 2 * cos(forceAngle + beltAngle)), SbRotation(SbVec3f(0, 1, 0), - SbVec3f(sin(forceAngle + beltAngle + M_PI_2), 0, + SbVec3f(sin(forceAngle + beltAngle + M_PI_2), + 0, cos(forceAngle + beltAngle + M_PI_2)))); updatePlacement(sep, 2, SbVec3f(0, dia / 8 + dia / 2 * rat1, 0), SbRotation()); - const SoSeparator *subsep = static_cast(sep->getChild(4)); + const SoSeparator* subsep = static_cast(sep->getChild(4)); updateArrow(subsep, 0, dia / 8 + dia / 2 * rat1, dia / 8); - sep = static_cast(pShapeSep->getChild(4)); - updatePlacement(sep, 0, - SbVec3f(-dia / 2 * sin(forceAngle - beltAngle), 0, + sep = static_cast(pShapeSep->getChild(4)); + updatePlacement(sep, + 0, + SbVec3f(-dia / 2 * sin(forceAngle - beltAngle), + 0, -dia / 2 * cos(forceAngle - beltAngle)), SbRotation(SbVec3f(0, 1, 0), - SbVec3f(-sin(forceAngle - beltAngle - M_PI_2), 0, + SbVec3f(-sin(forceAngle - beltAngle - M_PI_2), + 0, -cos(forceAngle - beltAngle - M_PI_2)))); updatePlacement(sep, 2, SbVec3f(0, dia / 8 + dia / 2 * rat2, 0), SbRotation()); - subsep = static_cast(sep->getChild(4)); + subsep = static_cast(sep->getChild(4)); updateArrow(subsep, 0, dia / 8 + dia / 2 * rat2, dia / 8); } } @@ -200,24 +219,31 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) if (pShapeSep->getNumChildren() > 0) { double radius = pcConstraint->Radius.getValue(); double dia = pcConstraint->Diameter.getValue(); - if (dia < 2 * radius) + if (dia < 2 * radius) { dia = 2 * radius; + } double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI; double beltAngle = pcConstraint->BeltAngle.getValue(); - const SoSeparator *sep = static_cast(pShapeSep->getChild(3)); - updatePlacement(sep, 0, - SbVec3f(dia / 2 * sin(forceAngle + beltAngle), 0, + const SoSeparator* sep = static_cast(pShapeSep->getChild(3)); + updatePlacement(sep, + 0, + SbVec3f(dia / 2 * sin(forceAngle + beltAngle), + 0, dia / 2 * cos(forceAngle + beltAngle)), SbRotation(SbVec3f(0, 1, 0), - SbVec3f(sin(forceAngle + beltAngle + M_PI_2), 0, + SbVec3f(sin(forceAngle + beltAngle + M_PI_2), + 0, cos(forceAngle + beltAngle + M_PI_2)))); - sep = static_cast(pShapeSep->getChild(4)); - updatePlacement(sep, 0, - SbVec3f(-dia / 2 * sin(forceAngle - beltAngle), 0, + sep = static_cast(pShapeSep->getChild(4)); + updatePlacement(sep, + 0, + SbVec3f(-dia / 2 * sin(forceAngle - beltAngle), + 0, -dia / 2 * cos(forceAngle - beltAngle)), SbRotation(SbVec3f(0, 1, 0), - SbVec3f(-sin(forceAngle - beltAngle - M_PI_2), 0, + SbVec3f(-sin(forceAngle - beltAngle - M_PI_2), + 0, -cos(forceAngle - beltAngle - M_PI_2)))); } } @@ -225,8 +251,9 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) if (pShapeSep->getNumChildren() > 0) { double radius = pcConstraint->Radius.getValue(); double dia = pcConstraint->Diameter.getValue(); - if (dia < 2 * radius) + if (dia < 2 * radius) { dia = 2 * radius; + } double rat1 = 0.8, rat2 = 0.2; double f1 = pcConstraint->BeltForce1.getValue(); double f2 = pcConstraint->BeltForce2.getValue(); @@ -235,13 +262,13 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) rat2 = f2 / (f1 + f2); } - const SoSeparator *sep = static_cast(pShapeSep->getChild(3)); + const SoSeparator* sep = static_cast(pShapeSep->getChild(3)); updatePlacement(sep, 2, SbVec3f(0, dia / 8 + dia / 2 * rat1, 0), SbRotation()); - const SoSeparator *subsep = static_cast(sep->getChild(4)); + const SoSeparator* subsep = static_cast(sep->getChild(4)); updateArrow(subsep, 0, dia / 8 + dia / 2 * rat1, dia / 8); - sep = static_cast(pShapeSep->getChild(4)); + sep = static_cast(pShapeSep->getChild(4)); updatePlacement(sep, 2, SbVec3f(0, dia / 8 + dia / 2 * rat2, 0), SbRotation()); - subsep = static_cast(sep->getChild(4)); + subsep = static_cast(sep->getChild(4)); updateArrow(subsep, 0, dia / 8 + dia / 2 * rat2, dia / 8); } } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.h index 9749eafb56..9e1e5f373d 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.h @@ -30,7 +30,7 @@ namespace FemGui { -class FemGuiExport ViewProviderFemConstraintPulley : public FemGui::ViewProviderFemConstraint +class FemGuiExport ViewProviderFemConstraintPulley: public FemGui::ViewProviderFemConstraint { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintPulley); @@ -45,7 +45,7 @@ protected: bool setEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTPulley_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTPulley_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp index eda0792dae..33fca41ec0 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp @@ -24,22 +24,23 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include #endif -#include #include "Mod/Fem/App/FemConstraintSpring.h" +#include +#include "TaskFemConstraintSpring.h" //TODO do next #include "ViewProviderFemConstraintSpring.h" -#include "TaskFemConstraintSpring.h" //TODO do next using namespace FemGui; -PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintSpring, FemGui::ViewProviderFemConstraintOnBoundary) +PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintSpring, + FemGui::ViewProviderFemConstraintOnBoundary) ViewProviderFemConstraintSpring::ViewProviderFemConstraintSpring() { @@ -49,23 +50,25 @@ ViewProviderFemConstraintSpring::ViewProviderFemConstraintSpring() ViewProviderFemConstraintSpring::~ViewProviderFemConstraintSpring() = default; -//FIXME setEdit needs a careful review +// FIXME setEdit needs a careful review bool ViewProviderFemConstraintSpring::setEdit(int ModNum) { if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintSpring *constrDlg = - qobject_cast(dlg);// check this out too - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintSpring* constrDlg = + qobject_cast(dlg); // check this out too + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { if (constraintDialog) { // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintSpring(this); return true; } @@ -75,35 +78,39 @@ bool ViewProviderFemConstraintSpring::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintSpring(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } #define WIDTH (1) #define LENGTH (2) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so disable +// #define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so +// disable void ViewProviderFemConstraintSpring::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintSpring *pcConstraint = static_cast(this->getObject()); - float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + Fem::ConstraintSpring* pcConstraint = static_cast(this->getObject()); + float scaledwidth = + WIDTH * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledlength = LENGTH * pcConstraint->Scale.getValue(); #ifdef USE_MULTIPLE_COPY - //OvG: always need access to cp for scaling + // OvG: always need access to cp for scaling SoMultipleCopy* cp = new SoMultipleCopy(); if (pShapeSep->getNumChildren() == 0) { // Set up the nodes cp->matrix.setNum(0); - cp->addChild((SoNode*)createSpring(scaledlength, scaledwidth)); //OvG: Scaling + cp->addChild((SoNode*)createSpring(scaledlength, scaledwidth)); // OvG: Scaling pShapeSep->addChild(cp); } #endif @@ -117,7 +124,7 @@ void ViewProviderFemConstraintSpring::updateData(const App::Property* prop) std::vector::const_iterator n = normals.begin(); #ifdef USE_MULTIPLE_COPY - cp = static_cast(pShapeSep->getChild(0)); //OvG: Use top cp + cp = static_cast(pShapeSep->getChild(0)); // OvG: Use top cp cp->matrix.setNum(points.size()); SbMatrix* matrices = cp->matrix.startEditing(); int idx = 0; @@ -126,19 +133,19 @@ void ViewProviderFemConstraintSpring::updateData(const App::Property* prop) Gui::coinRemoveAllChildren(pShapeSep); #endif - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); SbRotation rot(SbVec3f(0, -1.0, 0), dir); #ifdef USE_MULTIPLE_COPY SbMatrix m; - m.setTransform(base, rot, SbVec3f(1,1,1)); + m.setTransform(base, rot, SbVec3f(1, 1, 1)); matrices[idx] = m; idx++; #else SoSeparator* sep = new SoSeparator(); createPlacement(sep, base, rot); - createSpring(sep, scaledlength , scaledwidth); //OvG: Scaling + createSpring(sep, scaledlength, scaledwidth); // OvG: Scaling pShapeSep->addChild(sep); #endif n++; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.h index 4b72d705d4..aeff53484b 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.h @@ -26,9 +26,11 @@ #include "ViewProviderFemConstraintOnBoundary.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintSpring : public FemGui::ViewProviderFemConstraintOnBoundary +class FemGuiExport ViewProviderFemConstraintSpring + : public FemGui::ViewProviderFemConstraintOnBoundary { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintSpring); @@ -41,6 +43,6 @@ protected: bool setEdit(int ModNum) override; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTSPRING_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTSPRING_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp index 505162f0cb..bc538feb68 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp @@ -26,23 +26,24 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include #endif -#include #include "Mod/Fem/App/FemConstraintTemperature.h" -#include "ViewProviderFemConstraintTemperature.h" #include "TaskFemConstraintTemperature.h" +#include "ViewProviderFemConstraintTemperature.h" +#include using namespace FemGui; -PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintTemperature, FemGui::ViewProviderFemConstraintOnBoundary) +PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintTemperature, + FemGui::ViewProviderFemConstraintOnBoundary) ViewProviderFemConstraintTemperature::ViewProviderFemConstraintTemperature() { @@ -52,23 +53,25 @@ ViewProviderFemConstraintTemperature::ViewProviderFemConstraintTemperature() ViewProviderFemConstraintTemperature::~ViewProviderFemConstraintTemperature() = default; -//FIXME setEdit needs a careful review +// FIXME setEdit needs a careful review bool ViewProviderFemConstraintTemperature::setEdit(int ModNum) { if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintTemperature *constrDlg = - qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintTemperature* constrDlg = + qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { if (constraintDialog) { // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintTemperature(this); return true; } @@ -78,90 +81,96 @@ bool ViewProviderFemConstraintTemperature::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintTemperature(this)); + } return true; } else { - return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method + return ViewProviderDocumentObject::setEdit(ModNum); // clazy:exclude=skipped-base-method } } #define HEIGHT (1.5) #define RADIUS (0.3) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable +// #define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - +// so disable void ViewProviderFemConstraintTemperature::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintTemperature *pcConstraint = - static_cast(this->getObject()); - float scaledradius = RADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + Fem::ConstraintTemperature* pcConstraint = + static_cast(this->getObject()); + float scaledradius = + RADIUS * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); - //float temperature = pcConstraint->temperature.getValue(); + // float temperature = pcConstraint->temperature.getValue(); if (prop == &pcConstraint->Points) { const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); - if (points.size() != normals.size()) + if (points.size() != normals.size()) { return; + } std::vector::const_iterator n = normals.begin(); // Note: Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (const auto & point : points) { - //Define base and normal directions + for (const auto& point : points) { + // Define base and normal directions SbVec3f base(point.x, point.y, point.z); - SbVec3f dir(n->x, n->y, n->z);//normal + SbVec3f dir(n->x, n->y, n->z); // normal - ///Temperature indication - //define separator - SoSeparator *sep = new SoSeparator(); + /// Temperature indication + // define separator + SoSeparator* sep = new SoSeparator(); - ///draw a temp gauge,with sphere and a cylinder - //first move to correct position - SoTranslation *trans = new SoTranslation(); + /// draw a temp gauge,with sphere and a cylinder + // first move to correct position + SoTranslation* trans = new SoTranslation(); SbVec3f newPos = base + scaledradius * dir * 0.7f; trans->translation.setValue(newPos); sep->addChild(trans); - //adjust orientation - SoRotation *rot = new SoRotation(); + // adjust orientation + SoRotation* rot = new SoRotation(); rot->rotation.setValue(SbRotation(SbVec3f(0, 1, 0), dir)); sep->addChild(rot); - //define color of shape - SoMaterial *myMaterial = new SoMaterial; - myMaterial->diffuseColor.set1Value(0, SbColor(1, 0, 0)); //RGB - //myMaterial->diffuseColor.set1Value(1,SbColor(.1,.1,.1));//possible to adjust sides separately + // define color of shape + SoMaterial* myMaterial = new SoMaterial; + myMaterial->diffuseColor.set1Value(0, SbColor(1, 0, 0)); // RGB + // myMaterial->diffuseColor.set1Value(1,SbColor(.1,.1,.1));//possible to adjust sides + // separately sep->addChild(myMaterial); - //draw a sphere - SoSphere *sph = new SoSphere(); + // draw a sphere + SoSphere* sph = new SoSphere(); sph->radius.setValue(scaledradius * 0.75); sep->addChild(sph); - //translate position - SoTranslation *trans2 = new SoTranslation(); + // translate position + SoTranslation* trans2 = new SoTranslation(); trans2->translation.setValue(SbVec3f(0, scaledheight * 0.375, 0)); sep->addChild(trans2); - //draw a cylinder - SoCylinder *cyl = new SoCylinder(); + // draw a cylinder + SoCylinder* cyl = new SoCylinder(); cyl->height.setValue(scaledheight * 0.5); cyl->radius.setValue(scaledradius * 0.375); sep->addChild(cyl); - //translate position - SoTranslation *trans3 = new SoTranslation(); + // translate position + SoTranslation* trans3 = new SoTranslation(); trans3->translation.setValue(SbVec3f(0, scaledheight * 0.375, 0)); sep->addChild(trans3); - //define color of shape - SoMaterial *myMaterial2 = new SoMaterial; - myMaterial2->diffuseColor.set1Value(0, SbColor(1, 1, 1)); //RGB + // define color of shape + SoMaterial* myMaterial2 = new SoMaterial; + myMaterial2->diffuseColor.set1Value(0, SbColor(1, 1, 1)); // RGB sep->addChild(myMaterial2); - //draw a cylinder - SoCylinder *cyl2 = new SoCylinder(); + // draw a cylinder + SoCylinder* cyl2 = new SoCylinder(); cyl2->height.setValue(scaledheight * 0.25); cyl2->radius.setValue(scaledradius * 0.375); sep->addChild(cyl2); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.h index 1dea8d6668..888d10b907 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.h @@ -28,9 +28,11 @@ #include "ViewProviderFemConstraintOnBoundary.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintTemperature : public FemGui::ViewProviderFemConstraintOnBoundary +class FemGuiExport ViewProviderFemConstraintTemperature + : public FemGui::ViewProviderFemConstraintOnBoundary { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintTemperature); @@ -43,6 +45,6 @@ protected: bool setEdit(int ModNum) override; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTTemperature_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTTemperature_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp index ec47c6a238..ad903451f9 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp @@ -27,16 +27,16 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include #endif -#include #include "Mod/Fem/App/FemConstraintTransform.h" -#include "ViewProviderFemConstraintTransform.h" #include "TaskFemConstraintTransform.h" +#include "ViewProviderFemConstraintTransform.h" +#include using namespace FemGui; @@ -50,23 +50,25 @@ ViewProviderFemConstraintTransform::ViewProviderFemConstraintTransform() ViewProviderFemConstraintTransform::~ViewProviderFemConstraintTransform() = default; -//FIXME setEdit needs a careful review +// FIXME setEdit needs a careful review bool ViewProviderFemConstraintTransform::setEdit(int ModNum) { if (ModNum == ViewProvider::Default) { // When double-clicking on the item for this constraint the // object unsets and sets its edit mode without closing // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintTransform *constrDlg = - qobject_cast(dlg); - if (constrDlg && constrDlg->getConstraintView() != this) - constrDlg = nullptr; // another constraint left open its task panel + Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); + TaskDlgFemConstraintTransform* constrDlg = + qobject_cast(dlg); + if (constrDlg && constrDlg->getConstraintView() != this) { + constrDlg = nullptr; // another constraint left open its task panel + } if (dlg && !constrDlg) { if (constraintDialog) { // Ignore the request to open another dialog return false; - } else { + } + else { constraintDialog = new TaskFemConstraintTransform(this); return true; } @@ -76,10 +78,12 @@ bool ViewProviderFemConstraintTransform::setEdit(int ModNum) Gui::Selection().clearSelection(); // start the edit dialog - if (constrDlg) + if (constrDlg) { Gui::Control().showDialog(constrDlg); - else + } + else { Gui::Control().showDialog(new TaskDlgFemConstraintTransform(this)); + } return true; } else { @@ -97,157 +101,158 @@ bool ViewProviderFemConstraintTransform::setEdit(int ModNum) void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintTransform *pcConstraint = - static_cast(this->getObject()); + Fem::ConstraintTransform* pcConstraint = + static_cast(this->getObject()); float scaledradiusaxis = - RADIUSAXIS * pcConstraint->Scale.getValue();//OvG: Calculate scaled values once only + RADIUSAXIS * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledheightaxis = HEIGHTAXIS * pcConstraint->Scale.getValue(); float scaledheadradiusA = - ARROWHEADRADIUS * pcConstraint->Scale.getValue();//OvG: Calculate scaled values once only + ARROWHEADRADIUS * pcConstraint->Scale.getValue(); // OvG: Calculate scaled values once only float scaledlengthA = ARROWLENGTH * pcConstraint->Scale.getValue(); std::string transform_type = pcConstraint->TransformType.getValueAsString(); if (transform_type == "Rectangular") { - if (prop == &pcConstraint->Points) { - const std::vector& points = pcConstraint->Points.getValues(); - const std::vector& normals = pcConstraint->Normals.getValues(); - if (points.size() != normals.size()) - return; - std::vector::const_iterator n = normals.begin(); - - // Points and Normals are always updated together - Gui::coinRemoveAllChildren(pShapeSep); - - for (const auto & point : points) { - SbVec3f base(point.x, point.y, point.z); - SbVec3f basex(point.x, point.y, point.z); - SbVec3f basey(point.x, point.y, point.z); - - double x_axis_x = 1; - double x_axis_y = 0; - double x_axis_z = 0; - - double y_axis_x = 0; - double y_axis_y = 1; - double y_axis_z = 0; - - double z_axis_x = 0; - double z_axis_y = 0; - double z_axis_z = 1; - - double rot_x = (pcConstraint->X_rot.getValue() * (M_PI /180)); - double rot_y = (pcConstraint->Y_rot.getValue() * (M_PI /180)); - double rot_z = (pcConstraint->Z_rot.getValue() * (M_PI /180)); - - double x_axis_x_p; - double x_axis_y_p; - double x_axis_z_p; - - double y_axis_x_p; - double y_axis_y_p; - double y_axis_z_p; - - double z_axis_x_p; - double z_axis_y_p; - double z_axis_z_p; - - if (rot_x != 0) { - x_axis_z_p = x_axis_z * cos(rot_x) - x_axis_y * sin(rot_x); - x_axis_y_p = x_axis_y * cos(rot_x) + x_axis_z * sin(rot_x); - x_axis_z = x_axis_z_p; - x_axis_y = x_axis_y_p; - - y_axis_z_p = y_axis_z * cos(rot_x) - y_axis_y * sin(rot_x); - y_axis_y_p = y_axis_y * cos(rot_x) + y_axis_z * sin(rot_x); - y_axis_z = y_axis_z_p; - y_axis_y = y_axis_y_p; - - z_axis_z_p = z_axis_z * cos(rot_x) - z_axis_y * sin(rot_x); - z_axis_y_p = z_axis_y * cos(rot_x) + z_axis_z * sin(rot_x); - z_axis_z = z_axis_z_p; - z_axis_y = z_axis_y_p; + if (prop == &pcConstraint->Points) { + const std::vector& points = pcConstraint->Points.getValues(); + const std::vector& normals = pcConstraint->Normals.getValues(); + if (points.size() != normals.size()) { + return; } - if (rot_y != 0) { - x_axis_z_p = x_axis_z * cos(rot_y) + x_axis_x * sin(rot_y); - x_axis_x_p = x_axis_x * cos(rot_y) - x_axis_z * sin(rot_y); - x_axis_z = x_axis_z_p; - x_axis_x = x_axis_x_p; + std::vector::const_iterator n = normals.begin(); - y_axis_z_p = y_axis_z * cos(rot_y) + y_axis_x * sin(rot_y); - y_axis_x_p = y_axis_x * cos(rot_y) - y_axis_z * sin(rot_y); - y_axis_z = y_axis_z_p; - y_axis_x = y_axis_x_p; + // Points and Normals are always updated together + Gui::coinRemoveAllChildren(pShapeSep); - z_axis_z_p = z_axis_z * cos(rot_y) + z_axis_x * sin(rot_y); - z_axis_x_p = z_axis_x * cos(rot_y) - z_axis_z * sin(rot_y); - z_axis_z = z_axis_z_p; - z_axis_x = z_axis_x_p; + for (const auto& point : points) { + SbVec3f base(point.x, point.y, point.z); + SbVec3f basex(point.x, point.y, point.z); + SbVec3f basey(point.x, point.y, point.z); + + double x_axis_x = 1; + double x_axis_y = 0; + double x_axis_z = 0; + + double y_axis_x = 0; + double y_axis_y = 1; + double y_axis_z = 0; + + double z_axis_x = 0; + double z_axis_y = 0; + double z_axis_z = 1; + + double rot_x = (pcConstraint->X_rot.getValue() * (M_PI / 180)); + double rot_y = (pcConstraint->Y_rot.getValue() * (M_PI / 180)); + double rot_z = (pcConstraint->Z_rot.getValue() * (M_PI / 180)); + + double x_axis_x_p; + double x_axis_y_p; + double x_axis_z_p; + + double y_axis_x_p; + double y_axis_y_p; + double y_axis_z_p; + + double z_axis_x_p; + double z_axis_y_p; + double z_axis_z_p; + + if (rot_x != 0) { + x_axis_z_p = x_axis_z * cos(rot_x) - x_axis_y * sin(rot_x); + x_axis_y_p = x_axis_y * cos(rot_x) + x_axis_z * sin(rot_x); + x_axis_z = x_axis_z_p; + x_axis_y = x_axis_y_p; + + y_axis_z_p = y_axis_z * cos(rot_x) - y_axis_y * sin(rot_x); + y_axis_y_p = y_axis_y * cos(rot_x) + y_axis_z * sin(rot_x); + y_axis_z = y_axis_z_p; + y_axis_y = y_axis_y_p; + + z_axis_z_p = z_axis_z * cos(rot_x) - z_axis_y * sin(rot_x); + z_axis_y_p = z_axis_y * cos(rot_x) + z_axis_z * sin(rot_x); + z_axis_z = z_axis_z_p; + z_axis_y = z_axis_y_p; + } + if (rot_y != 0) { + x_axis_z_p = x_axis_z * cos(rot_y) + x_axis_x * sin(rot_y); + x_axis_x_p = x_axis_x * cos(rot_y) - x_axis_z * sin(rot_y); + x_axis_z = x_axis_z_p; + x_axis_x = x_axis_x_p; + + y_axis_z_p = y_axis_z * cos(rot_y) + y_axis_x * sin(rot_y); + y_axis_x_p = y_axis_x * cos(rot_y) - y_axis_z * sin(rot_y); + y_axis_z = y_axis_z_p; + y_axis_x = y_axis_x_p; + + z_axis_z_p = z_axis_z * cos(rot_y) + z_axis_x * sin(rot_y); + z_axis_x_p = z_axis_x * cos(rot_y) - z_axis_z * sin(rot_y); + z_axis_z = z_axis_z_p; + z_axis_x = z_axis_x_p; + } + if (rot_z != 0) { + x_axis_x_p = x_axis_x * cos(rot_z) + x_axis_y * sin(rot_z); + x_axis_y_p = x_axis_y * cos(rot_z) - x_axis_x * sin(rot_z); + x_axis_x = x_axis_x_p; + x_axis_y = x_axis_y_p; + + y_axis_x_p = y_axis_x * cos(rot_z) + y_axis_y * sin(rot_z); + y_axis_y_p = y_axis_y * cos(rot_z) - y_axis_x * sin(rot_z); + y_axis_x = y_axis_x_p; + y_axis_y = y_axis_y_p; + + z_axis_x_p = z_axis_x * cos(rot_z) + z_axis_y * sin(rot_z); + z_axis_y_p = z_axis_y * cos(rot_z) - z_axis_x * sin(rot_z); + z_axis_x = z_axis_x_p; + z_axis_y = z_axis_y_p; + } + + SbVec3f dirz(z_axis_x, z_axis_y, z_axis_z); + SbRotation rot(SbVec3f(0, 1, 0), dirz); + + SbVec3f dirx(x_axis_x, x_axis_y, x_axis_z); + SbRotation rotx(SbVec3f(0, 1, 0), dirx); + + SbVec3f diry(y_axis_x, y_axis_y, y_axis_z); + SbRotation roty(SbVec3f(0, 1, 0), diry); + + base = base + dirz * scaledlengthA * 0.75f; + basex = basex + dirx * scaledlengthA * 0.65f; + basey = basey + diry * scaledlengthA * 0.65f; + + SoSeparator* sep = new SoSeparator(); + + SoMaterial* myMaterial = new SoMaterial; + myMaterial->diffuseColor.set1Value(0, SbColor(0, 0, 1)); // RGB + sep->addChild(myMaterial); + + createPlacement(sep, base, rot); + createArrow(sep, scaledlengthA * 0.75, scaledheadradiusA * 0.9); // OvG: Scaling + pShapeSep->addChild(sep); + + SoSeparator* sepx = new SoSeparator(); + + SoMaterial* myMaterialx = new SoMaterial; + myMaterialx->diffuseColor.set1Value(0, SbColor(1, 0, 0)); // RGB + sepx->addChild(myMaterialx); + + createPlacement(sepx, basex, rotx); + createArrow(sepx, scaledlengthA * 0.65, scaledheadradiusA * 0.65); // OvG: Scaling + pShapeSep->addChild(sepx); + + SoSeparator* sepy = new SoSeparator(); + + SoMaterial* myMaterialy = new SoMaterial; + myMaterialy->diffuseColor.set1Value(0, SbColor(0, 1, 0)); // RGB + sepy->addChild(myMaterialy); + + createPlacement(sepy, basey, roty); + createArrow(sepy, scaledlengthA * 0.65, scaledheadradiusA * 0.65); // OvG: Scaling + pShapeSep->addChild(sepy); + + n++; } - if (rot_z != 0) { - x_axis_x_p = x_axis_x * cos(rot_z) + x_axis_y * sin(rot_z); - x_axis_y_p = x_axis_y * cos(rot_z) - x_axis_x * sin(rot_z); - x_axis_x = x_axis_x_p; - x_axis_y = x_axis_y_p; - - y_axis_x_p = y_axis_x * cos(rot_z) + y_axis_y * sin(rot_z); - y_axis_y_p = y_axis_y * cos(rot_z) - y_axis_x * sin(rot_z); - y_axis_x = y_axis_x_p; - y_axis_y = y_axis_y_p; - - z_axis_x_p = z_axis_x * cos(rot_z) + z_axis_y * sin(rot_z); - z_axis_y_p = z_axis_y * cos(rot_z) - z_axis_x * sin(rot_z); - z_axis_x = z_axis_x_p; - z_axis_y = z_axis_y_p; - } - - SbVec3f dirz(z_axis_x, z_axis_y ,z_axis_z); - SbRotation rot(SbVec3f(0, 1, 0), dirz); - - SbVec3f dirx(x_axis_x, x_axis_y ,x_axis_z); - SbRotation rotx(SbVec3f(0, 1, 0), dirx); - - SbVec3f diry(y_axis_x, y_axis_y ,y_axis_z); - SbRotation roty(SbVec3f(0, 1, 0), diry); - - base = base + dirz * scaledlengthA * 0.75f; - basex = basex + dirx * scaledlengthA * 0.65f; - basey = basey + diry * scaledlengthA * 0.65f; - - SoSeparator* sep = new SoSeparator(); - - SoMaterial* myMaterial = new SoMaterial; - myMaterial->diffuseColor.set1Value(0, SbColor(0, 0, 1)); //RGB - sep->addChild(myMaterial); - - createPlacement(sep, base, rot); - createArrow(sep, scaledlengthA * 0.75, scaledheadradiusA * 0.9); //OvG: Scaling - pShapeSep->addChild(sep); - - SoSeparator* sepx = new SoSeparator(); - - SoMaterial* myMaterialx = new SoMaterial; - myMaterialx->diffuseColor.set1Value(0, SbColor(1, 0, 0)); //RGB - sepx->addChild(myMaterialx); - - createPlacement(sepx, basex, rotx); - createArrow(sepx, scaledlengthA*0.65 , scaledheadradiusA*0.65); //OvG: Scaling - pShapeSep->addChild(sepx); - - SoSeparator* sepy = new SoSeparator(); - - SoMaterial* myMaterialy = new SoMaterial; - myMaterialy->diffuseColor.set1Value(0, SbColor(0, 1, 0)); //RGB - sepy->addChild(myMaterialy); - - createPlacement(sepy, basey, roty); - createArrow(sepy, scaledlengthA * 0.65, scaledheadradiusA * 0.65); //OvG: Scaling - pShapeSep->addChild(sepy); - - n++; } - } - } else if (transform_type == "Cylindrical") { + else if (transform_type == "Cylindrical") { // Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); @@ -255,8 +260,9 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) const std::vector& points = pcConstraint->Points.getValues(); const std::vector& normals = pcConstraint->Normals.getValues(); - if (points.size() != normals.size()) + if (points.size() != normals.size()) { return; + } std::vector::const_iterator n = normals.begin(); if (!points.empty()) { @@ -265,30 +271,30 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) SbVec3f b(base.x, base.y, base.z); SbVec3f ax(axis.x, axis.y, axis.z); - SbRotation rots(SbVec3f(0,-1,0), ax); + SbRotation rots(SbVec3f(0, -1, 0), ax); - b = b - ax * scaledheightaxis/2; + b = b - ax * scaledheightaxis / 2; SoSeparator* sepAx = new SoSeparator(); SoMaterial* myMaterial = new SoMaterial; - myMaterial->diffuseColor.set1Value(0, SbColor(0, 0, 1));//RGB + myMaterial->diffuseColor.set1Value(0, SbColor(0, 0, 1)); // RGB sepAx->addChild(myMaterial); createPlacement(sepAx, b, rots); createArrow(sepAx, scaledheightaxis, scaledradiusaxis); pShapeSep->addChild(sepAx); } - for (const auto & point : points) { + for (const auto& point : points) { SbVec3f base(point.x, point.y, point.z); SbVec3f dir(n->x, n->y, n->z); - base = base + dir * scaledlengthA; //OvG: Scaling + base = base + dir * scaledlengthA; // OvG: Scaling SbRotation rot(SbVec3f(0, 1, 0), dir); SoSeparator* sep = new SoSeparator(); SoMaterial* myMaterials = new SoMaterial; - myMaterials->diffuseColor.set1Value(0, SbColor(1, 0, 0)); //RGB + myMaterials->diffuseColor.set1Value(0, SbColor(1, 0, 0)); // RGB sep->addChild(myMaterials); createPlacement(sep, base, rot); - createArrow(sep, scaledlengthA , scaledheadradiusA); //OvG: Scaling + createArrow(sep, scaledlengthA, scaledheadradiusA); // OvG: Scaling pShapeSep->addChild(sep); n++; } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.h b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.h index 5a66fc91ed..42beaeb1b0 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.h @@ -29,9 +29,10 @@ #include "ViewProviderFemConstraint.h" -namespace FemGui { +namespace FemGui +{ -class FemGuiExport ViewProviderFemConstraintTransform : public FemGui::ViewProviderFemConstraint +class FemGuiExport ViewProviderFemConstraintTransform: public FemGui::ViewProviderFemConstraint { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemConstraintTransform); @@ -44,6 +45,6 @@ protected: bool setEdit(int ModNum) override; }; -} +} // namespace FemGui -#endif // GUI_VIEWPROVIDERFEMCONSTRAINTTransform_H +#endif // GUI_VIEWPROVIDERFEMCONSTRAINTTransform_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp index 729b8cfd0e..0f02402c89 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp @@ -23,27 +23,27 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -# include +#include -# include -# include +#include +#include #endif #include @@ -60,26 +60,45 @@ using namespace FemGui; struct FemFace { - const SMDS_MeshNode *Nodes[8]; - unsigned long ElementNumber; + const SMDS_MeshNode* Nodes[8]; + unsigned long ElementNumber; const SMDS_MeshElement* Element; unsigned short Size; unsigned short FaceNo; bool hide; - Base::Vector3d getFirstNodePoint() { - return Base::Vector3d(Nodes[0]->X(),Nodes[0]->Y(),Nodes[0]->Z()); + Base::Vector3d getFirstNodePoint() + { + return Base::Vector3d(Nodes[0]->X(), Nodes[0]->Y(), Nodes[0]->Z()); } - Base::Vector3d set(short size,const SMDS_MeshElement* element,unsigned short id, short faceNo, - const SMDS_MeshNode* n1,const SMDS_MeshNode* n2,const SMDS_MeshNode* n3,const SMDS_MeshNode* n4=nullptr, - const SMDS_MeshNode* n5=nullptr,const SMDS_MeshNode* n6=nullptr,const SMDS_MeshNode* n7=nullptr,const SMDS_MeshNode* n8=nullptr); + Base::Vector3d set(short size, + const SMDS_MeshElement* element, + unsigned short id, + short faceNo, + const SMDS_MeshNode* n1, + const SMDS_MeshNode* n2, + const SMDS_MeshNode* n3, + const SMDS_MeshNode* n4 = nullptr, + const SMDS_MeshNode* n5 = nullptr, + const SMDS_MeshNode* n6 = nullptr, + const SMDS_MeshNode* n7 = nullptr, + const SMDS_MeshNode* n8 = nullptr); - bool isSameFace (FemFace &face); + bool isSameFace(FemFace& face); }; -Base::Vector3d FemFace::set(short size,const SMDS_MeshElement* element,unsigned short id,short faceNo, - const SMDS_MeshNode* n1,const SMDS_MeshNode* n2,const SMDS_MeshNode* n3,const SMDS_MeshNode* n4, - const SMDS_MeshNode* n5,const SMDS_MeshNode* n6,const SMDS_MeshNode* n7,const SMDS_MeshNode* n8) +Base::Vector3d FemFace::set(short size, + const SMDS_MeshElement* element, + unsigned short id, + short faceNo, + const SMDS_MeshNode* n1, + const SMDS_MeshNode* n2, + const SMDS_MeshNode* n3, + const SMDS_MeshNode* n4, + const SMDS_MeshNode* n5, + const SMDS_MeshNode* n6, + const SMDS_MeshNode* n7, + const SMDS_MeshNode* n8) { Nodes[0] = n1; Nodes[1] = n2; @@ -90,58 +109,54 @@ Base::Vector3d FemFace::set(short size,const SMDS_MeshElement* element,unsigned Nodes[6] = n7; Nodes[7] = n8; - Element = element; - ElementNumber = id; - Size = size; - FaceNo = faceNo; - hide = false; + Element = element; + ElementNumber = id; + Size = size; + FaceNo = faceNo; + hide = false; // sorting the nodes for later easier comparison (bubble sort) - int i, j, flag = 1; // set flag to 1 to start first pass - const SMDS_MeshNode* temp; // holding variable + int i, j, flag = 1; // set flag to 1 to start first pass + const SMDS_MeshNode* temp; // holding variable - for(i = 1; (i <= size) && flag; i++) - { + for (i = 1; (i <= size) && flag; i++) { flag = 0; - for (j=0; j < (size -1); j++) - { - if (Nodes[j+1] > Nodes[j]) // ascending order simply changes to < + for (j = 0; j < (size - 1); j++) { + if (Nodes[j + 1] > Nodes[j]) // ascending order simply changes to < { - temp = Nodes[j]; // swap elements - Nodes[j] = Nodes[j+1]; - Nodes[j+1] = temp; - flag = 1; // indicates that a swap occurred. + temp = Nodes[j]; // swap elements + Nodes[j] = Nodes[j + 1]; + Nodes[j + 1] = temp; + flag = 1; // indicates that a swap occurred. } } } - return Base::Vector3d(Nodes[0]->X(),Nodes[0]->Y(),Nodes[0]->Z()); + return Base::Vector3d(Nodes[0]->X(), Nodes[0]->Y(), Nodes[0]->Z()); } -class FemFaceGridItem : public std::vector{ +class FemFaceGridItem: public std::vector +{ public: - //FemFaceGridItem(void){reserve(200);} + // FemFaceGridItem(void){reserve(200);} }; -bool FemFace::isSameFace (FemFace &face) +bool FemFace::isSameFace(FemFace& face) { // the same element can not have the same face - if(face.ElementNumber == ElementNumber) + if (face.ElementNumber == ElementNumber) { return false; - if(face.Size != Size) + } + if (face.Size != Size) { return false; + } // if the same face size just compare if the sorted nodes are the same - if( Nodes[0] == face.Nodes[0] && - Nodes[1] == face.Nodes[1] && - Nodes[2] == face.Nodes[2] && - Nodes[3] == face.Nodes[3] && - Nodes[4] == face.Nodes[4] && - Nodes[5] == face.Nodes[5] && - Nodes[6] == face.Nodes[6] && - Nodes[7] == face.Nodes[7] ){ - hide = true; - face.hide = true; - return true; + if (Nodes[0] == face.Nodes[0] && Nodes[1] == face.Nodes[1] && Nodes[2] == face.Nodes[2] + && Nodes[3] == face.Nodes[3] && Nodes[4] == face.Nodes[4] && Nodes[5] == face.Nodes[5] + && Nodes[6] == face.Nodes[6] && Nodes[7] == face.Nodes[7]) { + hide = true; + face.hide = true; + return true; } return false; @@ -152,39 +167,39 @@ bool FemFace::isSameFace (FemFace &face) class ViewProviderFemMesh::Private { public: - static const char *dm_face_wire; - static const char *dm_wire_node; - static const char *dm_face_wire_node; - static const char *dm_face; - static const char *dm_node; - static const char *dm_wire; + static const char* dm_face_wire; + static const char* dm_wire_node; + static const char* dm_face_wire_node; + static const char* dm_face; + static const char* dm_node; + static const char* dm_wire; }; -const char * ViewProviderFemMesh::Private::dm_face_wire = "Faces & Wireframe"; -const char * ViewProviderFemMesh::Private::dm_wire_node = "Wireframe & Nodes"; -const char * ViewProviderFemMesh::Private::dm_face_wire_node = "Faces, Wireframe & Nodes"; -const char * ViewProviderFemMesh::Private::dm_face = "Faces"; -const char * ViewProviderFemMesh::Private::dm_node = "Nodes"; -const char * ViewProviderFemMesh::Private::dm_wire = "Wireframe"; +const char* ViewProviderFemMesh::Private::dm_face_wire = "Faces & Wireframe"; +const char* ViewProviderFemMesh::Private::dm_wire_node = "Wireframe & Nodes"; +const char* ViewProviderFemMesh::Private::dm_face_wire_node = "Faces, Wireframe & Nodes"; +const char* ViewProviderFemMesh::Private::dm_face = "Faces"; +const char* ViewProviderFemMesh::Private::dm_node = "Nodes"; +const char* ViewProviderFemMesh::Private::dm_wire = "Wireframe"; PROPERTY_SOURCE(FemGui::ViewProviderFemMesh, Gui::ViewProviderGeometryObject) -App::PropertyFloatConstraint::Constraints ViewProviderFemMesh::floatRange = {1.0,64.0,1.0}; +App::PropertyFloatConstraint::Constraints ViewProviderFemMesh::floatRange = {1.0, 64.0, 1.0}; ViewProviderFemMesh::ViewProviderFemMesh() { sPixmap = "fem-femmesh-from-shape"; - ADD_PROPERTY(PointColor,(App::Color(0.7f,0.7f,0.7f))); - ADD_PROPERTY(PointSize,(5.0f)); + ADD_PROPERTY(PointColor, (App::Color(0.7f, 0.7f, 0.7f))); + ADD_PROPERTY(PointSize, (5.0f)); PointSize.setConstraints(&floatRange); - ADD_PROPERTY(LineWidth,(2.0f)); + ADD_PROPERTY(LineWidth, (2.0f)); LineWidth.setConstraints(&floatRange); - ShapeColor.setValue(App::Color(1.0f,0.7f,0.0f)); - ADD_PROPERTY(BackfaceCulling,(true)); + ShapeColor.setValue(App::Color(1.0f, 0.7f, 0.0f)); + ADD_PROPERTY(BackfaceCulling, (true)); ADD_PROPERTY(ShowInner, (false)); - ADD_PROPERTY(MaxFacesShowInner,(50000)); + ADD_PROPERTY(MaxFacesShowInner, (50000)); onlyEdges = false; @@ -222,7 +237,7 @@ ViewProviderFemMesh::ViewProviderFemMesh() pcPointMaterial = new SoMaterial; pcPointMaterial->ref(); - //PointMaterial.touch(); + // PointMaterial.touch(); DisplacementFactor = 0; } @@ -240,27 +255,27 @@ ViewProviderFemMesh::~ViewProviderFemMesh() pcAnoCoords->unref(); } -void ViewProviderFemMesh::attach(App::DocumentObject *pcObj) +void ViewProviderFemMesh::attach(App::DocumentObject* pcObj) { ViewProviderGeometryObject::attach(pcObj); // Move 'coords' before the switch - //pcRoot->insertChild(pcCoords,pcRoot->findChild(static_cast(pcModeSwitch))); + // pcRoot->insertChild(pcCoords,pcRoot->findChild(static_cast(pcModeSwitch))); // Annotation sets SoGroup* pcAnotRoot = new SoAnnotation(); - SoDrawStyle *pcAnoStyle = new SoDrawStyle(); + SoDrawStyle* pcAnoStyle = new SoDrawStyle(); pcAnoStyle->style = SoDrawStyle::POINTS; pcAnoStyle->pointSize = 5; - SoMaterial *pcAnoMaterial = new SoMaterial; - pcAnoMaterial->diffuseColor.setValue(0,1,0); - pcAnoMaterial->emissiveColor.setValue(0,1,0); + SoMaterial* pcAnoMaterial = new SoMaterial; + pcAnoMaterial->diffuseColor.setValue(0, 1, 0); + pcAnoMaterial->emissiveColor.setValue(0, 1, 0); pcAnotRoot->addChild(pcAnoMaterial); pcAnotRoot->addChild(pcAnoStyle); pcAnotRoot->addChild(pcAnoCoords); - SoPointSet *pointset = new SoPointSet; + SoPointSet* pointset = new SoPointSet; pcAnotRoot->addChild(pointset); // Faces @@ -281,7 +296,7 @@ void ViewProviderFemMesh::attach(App::DocumentObject *pcObj) pcWireRoot->addChild(pcDrawStyle); pcWireRoot->addChild(pcLightModel); SoBaseColor* color = new SoBaseColor(); - color->rgb.setValue(0.0f,0.0f,0.0f); + color->rgb.setValue(0.0f, 0.0f, 0.0f); pcWireRoot->addChild(color); pcWireRoot->addChild(pcLines); addDisplayMaskMode(pcWireRoot, Private::dm_wire); @@ -299,14 +314,14 @@ void ViewProviderFemMesh::attach(App::DocumentObject *pcObj) // because the group affects nodes that are rendered afterwards (#0003769) // Faces + Wireframe (Elements) - //SoPolygonOffset* offset = new SoPolygonOffset(); - //offset->styles = SoPolygonOffset::FILLED; - //offset->factor = 2.0f; - //offset->units = 1.0f; + // SoPolygonOffset* offset = new SoPolygonOffset(); + // offset->styles = SoPolygonOffset::FILLED; + // offset->factor = 2.0f; + // offset->units = 1.0f; SoGroup* pcFlatWireRoot = new SoGroup(); pcFlatWireRoot->addChild(pcWireRoot); - //pcFlatWireRoot->addChild(offset); + // pcFlatWireRoot->addChild(offset); pcFlatWireRoot->addChild(pcFlatRoot); addDisplayMaskMode(pcFlatWireRoot, Private::dm_face_wire); @@ -314,7 +329,7 @@ void ViewProviderFemMesh::attach(App::DocumentObject *pcObj) SoGroup* pcElemNodesRoot = new SoGroup(); pcElemNodesRoot->addChild(pcPointsRoot); pcElemNodesRoot->addChild(pcWireRoot); - //pcElemNodesRoot->addChild(offset); + // pcElemNodesRoot->addChild(offset); pcElemNodesRoot->addChild(pcFlatRoot); addDisplayMaskMode(pcElemNodesRoot, Private::dm_face_wire_node); @@ -349,7 +364,15 @@ void ViewProviderFemMesh::updateData(const App::Property* prop) ViewProviderFEMMeshBuilder builder; resetColorByNodeId(); resetDisplacementByNodeId(); - builder.createMesh(prop, pcCoords, pcFaces, pcLines, vFaceElementIdx, vNodeElementIdx, onlyEdges, ShowInner.getValue(), MaxFacesShowInner.getValue()); + builder.createMesh(prop, + pcCoords, + pcFaces, + pcLines, + vFaceElementIdx, + vNodeElementIdx, + onlyEdges, + ShowInner.getValue(), + MaxFacesShowInner.getValue()); } Gui::ViewProviderGeometryObject::updateData(prop); } @@ -361,23 +384,30 @@ void ViewProviderFemMesh::onChanged(const App::Property* prop) } else if (prop == &PointColor) { const App::Color& c = PointColor.getValue(); - pcPointMaterial->diffuseColor.setValue(c.r,c.g,c.b); + pcPointMaterial->diffuseColor.setValue(c.r, c.g, c.b); } else if (prop == &BackfaceCulling) { - if(BackfaceCulling.getValue()){ + if (BackfaceCulling.getValue()) { pShapeHints->shapeType = SoShapeHints::SOLID; - //pShapeHints->vertexOrdering = SoShapeHints::CLOCKWISE; - }else{ + // pShapeHints->vertexOrdering = SoShapeHints::CLOCKWISE; + } + else { pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE; - //pShapeHints->vertexOrdering = SoShapeHints::CLOCKWISE; + // pShapeHints->vertexOrdering = SoShapeHints::CLOCKWISE; } } - else if (prop == &ShowInner ) { + else if (prop == &ShowInner) { // recalc mesh with new settings ViewProviderFEMMeshBuilder builder; builder.createMesh(&(static_cast(this->pcObject)->FemMesh), - pcCoords, pcFaces, pcLines, vFaceElementIdx, vNodeElementIdx, - onlyEdges, ShowInner.getValue(), MaxFacesShowInner.getValue()); + pcCoords, + pcFaces, + pcLines, + vFaceElementIdx, + vNodeElementIdx, + onlyEdges, + ShowInner.getValue(), + MaxFacesShowInner.getValue()); } else if (prop == &LineWidth) { pcDrawStyle->lineWidth = LineWidth.getValue(); @@ -395,7 +425,7 @@ std::string ViewProviderFemMesh::getElement(const SoDetail* detail) const const SoFaceDetail* face_detail = static_cast(detail); unsigned long edx = vFaceElementIdx[face_detail->getFaceIndex()]; - str << "Elem" << (edx>>3) << "F"<< (edx&7)+1; + str << "Elem" << (edx >> 3) << "F" << (edx & 7) + 1; } // trigger on edges only if edge only mesh, otherwise you only hit edges and never faces.... else if (onlyEdges && detail->getTypeId() == SoLineDetail::getClassTypeId()) { @@ -431,24 +461,26 @@ SoDetail* ViewProviderFemMesh::getDetail(const char* subelement) const int index = -1; if (pos != std::string::npos) { index = std::atoi(element.substr(pos).c_str()); - element = element.substr(0,pos); + element = element.substr(0, pos); } SoDetail* detail = nullptr; - if (index < 0) + if (index < 0) { return detail; + } if (element == "Elem") { detail = new SoFaceDetail(); static_cast(detail)->setPartIndex(index - 1); } - //else if (element == "Edge") { - // detail = new SoLineDetail(); - // static_cast(detail)->setLineIndex(index - 1); - //} - //else if (element == "Vertex") { - // detail = new SoPointDetail(); - // static_cast(detail)->setCoordinateIndex(index + nodeset->startIndex.getValue() - 1); - //} + // else if (element == "Edge") { + // detail = new SoLineDetail(); + // static_cast(detail)->setLineIndex(index - 1); + // } + // else if (element == "Vertex") { + // detail = new SoPointDetail(); + // static_cast(detail)->setCoordinateIndex(index + + // nodeset->startIndex.getValue() - 1); + // } return detail; } @@ -468,24 +500,32 @@ std::set ViewProviderFemMesh::getHighlightNodes() const void ViewProviderFemMesh::setHighlightNodes(const std::set& HighlightedNodes) { if (!HighlightedNodes.empty()) { - const SMESHDS_Mesh* data = static_cast(this->pcObject)->FemMesh.getValue().getSMesh()->GetMeshDS(); + const SMESHDS_Mesh* data = static_cast(this->pcObject) + ->FemMesh.getValue() + .getSMesh() + ->GetMeshDS(); pcAnoCoords->point.setNum(HighlightedNodes.size()); SbVec3f* verts = pcAnoCoords->point.startEditing(); - int i=0; - for (std::set::const_iterator it=HighlightedNodes.begin();it!=HighlightedNodes.end();++it,i++){ - const SMDS_MeshNode *Node = data->FindNode(*it); - if (Node) - verts[i].setValue((float)Node->X(),(float)Node->Y(),(float)Node->Z()); - else - verts[i].setValue(0,0,0); + int i = 0; + for (std::set::const_iterator it = HighlightedNodes.begin(); + it != HighlightedNodes.end(); + ++it, i++) { + const SMDS_MeshNode* Node = data->FindNode(*it); + if (Node) { + verts[i].setValue((float)Node->X(), (float)Node->Y(), (float)Node->Z()); + } + else { + verts[i].setValue(0, 0, 0); + } } pcAnoCoords->point.finishEditing(); // save the node ids vHighlightedIdx.clear(); vHighlightedIdx.insert(vHighlightedIdx.end(), - HighlightedNodes.begin(), HighlightedNodes.end()); + HighlightedNodes.begin(), + HighlightedNodes.end()); } else { pcAnoCoords->point.setNum(0); @@ -499,41 +539,42 @@ void ViewProviderFemMesh::resetHighlightNodes() vHighlightedIdx.clear(); } -PyObject * ViewProviderFemMesh::getPyObject() +PyObject* ViewProviderFemMesh::getPyObject() { - if (PythonObject.is(Py::_None())){ + if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new ViewProviderFemMeshPy(this),true); + PythonObject = Py::Object(new ViewProviderFemMeshPy(this), true); } return Py::new_reference_to(PythonObject); } -void ViewProviderFemMesh::setColorByNodeId(const std::map &NodeColorMap) +void ViewProviderFemMesh::setColorByNodeId(const std::map& NodeColorMap) { long endId = (--NodeColorMap.end())->first; - std::vector colorVec(endId+1,App::Color(0,1,0)); - for(const auto & it : NodeColorMap) + std::vector colorVec(endId + 1, App::Color(0, 1, 0)); + for (const auto& it : NodeColorMap) { colorVec[it.first] = it.second; + } setColorByNodeIdHelper(colorVec); - } -void ViewProviderFemMesh::setColorByNodeId(const std::vector &NodeIds,const std::vector &NodeColors) +void ViewProviderFemMesh::setColorByNodeId(const std::vector& NodeIds, + const std::vector& NodeColors) { long endId = *(std::max_element(NodeIds.begin(), NodeIds.end())); - std::vector colorVec(endId+1,App::Color(0,1,0)); - long i=0; - for(std::vector::const_iterator it=NodeIds.begin();it!=NodeIds.end();++it,i++) + std::vector colorVec(endId + 1, App::Color(0, 1, 0)); + long i = 0; + for (std::vector::const_iterator it = NodeIds.begin(); it != NodeIds.end(); ++it, i++) { colorVec[*it] = NodeColors[i]; + } setColorByNodeIdHelper(colorVec); - } -void ViewProviderFemMesh::setColorByNodeIdHelper(const std::vector &colorVec) +void ViewProviderFemMesh::setColorByNodeIdHelper(const std::vector& colorVec) { pcMatBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED; @@ -541,11 +582,12 @@ void ViewProviderFemMesh::setColorByNodeIdHelper(const std::vector & pcShapeMaterial->diffuseColor.setNum(vNodeElementIdx.size()); SbColor* colors = pcShapeMaterial->diffuseColor.startEditing(); - long i=0; - for(std::vector::const_iterator it=vNodeElementIdx.begin() - ;it!=vNodeElementIdx.end() - ;++it,i++) - colors[i] = SbColor(colorVec[*it].r,colorVec[*it].g,colorVec[*it].b); + long i = 0; + for (std::vector::const_iterator it = vNodeElementIdx.begin(); + it != vNodeElementIdx.end(); + ++it, i++) { + colors[i] = SbColor(colorVec[*it].r, colorVec[*it].g, colorVec[*it].b); + } pcShapeMaterial->diffuseColor.finishEditing(); } @@ -555,45 +597,51 @@ void ViewProviderFemMesh::resetColorByNodeId() pcMatBinding->value = SoMaterialBinding::OVERALL; pcShapeMaterial->diffuseColor.setNum(0); const App::Color& c = ShapeColor.getValue(); - pcShapeMaterial->diffuseColor.setValue(c.r,c.g,c.b); - + pcShapeMaterial->diffuseColor.setValue(c.r, c.g, c.b); } -void ViewProviderFemMesh::setDisplacementByNodeId(const std::map &NodeDispMap) +void ViewProviderFemMesh::setDisplacementByNodeId(const std::map& NodeDispMap) { long startId = NodeDispMap.begin()->first; long endId = (--NodeDispMap.end())->first; - std::vector vecVec(endId-startId+2,Base::Vector3d()); + std::vector vecVec(endId - startId + 2, Base::Vector3d()); - for(const auto & it : NodeDispMap) - vecVec[it.first-startId] = it.second; + for (const auto& it : NodeDispMap) { + vecVec[it.first - startId] = it.second; + } - setDisplacementByNodeIdHelper(vecVec,startId); + setDisplacementByNodeIdHelper(vecVec, startId); } -void ViewProviderFemMesh::setDisplacementByNodeId(const std::vector &NodeIds,const std::vector &NodeDisps) +void ViewProviderFemMesh::setDisplacementByNodeId(const std::vector& NodeIds, + const std::vector& NodeDisps) { long startId = *(std::min_element(NodeIds.begin(), NodeIds.end())); - long endId = *(std::max_element(NodeIds.begin(), NodeIds.end())); + long endId = *(std::max_element(NodeIds.begin(), NodeIds.end())); - std::vector vecVec(endId-startId+2,Base::Vector3d()); + std::vector vecVec(endId - startId + 2, Base::Vector3d()); - long i=0; - for(std::vector::const_iterator it=NodeIds.begin();it!=NodeIds.end();++it,i++) - vecVec[*it-startId] = NodeDisps[i]; + long i = 0; + for (std::vector::const_iterator it = NodeIds.begin(); it != NodeIds.end(); ++it, i++) { + vecVec[*it - startId] = NodeDisps[i]; + } - setDisplacementByNodeIdHelper(vecVec,startId); + setDisplacementByNodeIdHelper(vecVec, startId); } -void ViewProviderFemMesh::setDisplacementByNodeIdHelper(const std::vector& DispVector,long startId) +void ViewProviderFemMesh::setDisplacementByNodeIdHelper( + const std::vector& DispVector, + long startId) { DisplacementVector.resize(vNodeElementIdx.size()); - int i=0; - for(std::vector::const_iterator it=vNodeElementIdx.begin();it!=vNodeElementIdx.end();++it,i++) - DisplacementVector[i] = DispVector[*it-startId]; + int i = 0; + for (std::vector::const_iterator it = vNodeElementIdx.begin(); + it != vNodeElementIdx.end(); + ++it, i++) { + DisplacementVector[i] = DispVector[*it - startId]; + } applyDisplacementToNodes(1.0); - } void ViewProviderFemMesh::resetDisplacementByNodeId() @@ -604,15 +652,16 @@ void ViewProviderFemMesh::resetDisplacementByNodeId() /// reaply the node displacement with a certain factor and do a redraw void ViewProviderFemMesh::applyDisplacementToNodes(double factor) { - if(DisplacementVector.empty()) + if (DisplacementVector.empty()) { return; + } - float x,y,z; + float x, y, z; // set the point coordinates long sz = pcCoords->point.getNum(); SbVec3f* verts = pcCoords->point.startEditing(); - for (long i=0;i < sz ;i++) { - verts[i].getValue(x,y,z); + for (long i = 0; i < sz; i++) { + verts[i].getValue(x, y, z); // undo old factor# Base::Vector3d oldDisp = DisplacementVector[i] * DisplacementFactor; x -= oldDisp.x; @@ -624,31 +673,33 @@ void ViewProviderFemMesh::applyDisplacementToNodes(double factor) y += newDisp.y; z += newDisp.z; // set the new value - verts[i].setValue(x,y,z); + verts[i].setValue(x, y, z); } pcCoords->point.finishEditing(); DisplacementFactor = factor; } -void ViewProviderFemMesh::setColorByElementId(const std::map &ElementColorMap) +void ViewProviderFemMesh::setColorByElementId(const std::map& ElementColorMap) { - pcMatBinding->value = SoMaterialBinding::PER_FACE ; + pcMatBinding->value = SoMaterialBinding::PER_FACE; // resizing and writing the color vector: pcShapeMaterial->diffuseColor.setNum(vFaceElementIdx.size()); SbColor* colors = pcShapeMaterial->diffuseColor.startEditing(); - int i=0; - for(std::vector::const_iterator it=vFaceElementIdx.begin() - ;it!=vFaceElementIdx.end() - ;++it,i++){ - unsigned long ElemIdx = ((*it)>>3); - const std::map::const_iterator pos = ElementColorMap.find(ElemIdx); - if(pos == ElementColorMap.end()) - colors[i] = SbColor(0,1,0); - else - colors[i] = SbColor(pos->second.r,pos->second.g,pos->second.b); + int i = 0; + for (std::vector::const_iterator it = vFaceElementIdx.begin(); + it != vFaceElementIdx.end(); + ++it, i++) { + unsigned long ElemIdx = ((*it) >> 3); + const std::map::const_iterator pos = ElementColorMap.find(ElemIdx); + if (pos == ElementColorMap.end()) { + colors[i] = SbColor(0, 1, 0); + } + else { + colors[i] = SbColor(pos->second.r, pos->second.g, pos->second.b); + } } pcShapeMaterial->diffuseColor.finishEditing(); @@ -659,17 +710,17 @@ void ViewProviderFemMesh::resetColorByElementId() pcMatBinding->value = SoMaterialBinding::OVERALL; pcShapeMaterial->diffuseColor.setNum(0); const App::Color& c = ShapeColor.getValue(); - pcShapeMaterial->diffuseColor.setValue(c.r,c.g,c.b); - + pcShapeMaterial->diffuseColor.setValue(c.r, c.g, c.b); } // ---------------------------------------------------------------------------- -void ViewProviderFEMMeshBuilder::buildNodes(const App::Property* prop, std::vector& nodes) const +void ViewProviderFEMMeshBuilder::buildNodes(const App::Property* prop, + std::vector& nodes) const { - SoCoordinate3 *pcPointsCoord=nullptr; - SoIndexedFaceSet *pcFaces=nullptr; - SoIndexedLineSet *pcLines=nullptr; + SoCoordinate3* pcPointsCoord = nullptr; + SoIndexedFaceSet* pcFaces = nullptr; + SoIndexedLineSet* pcLines = nullptr; if (nodes.empty()) { pcPointsCoord = new SoCoordinate3(); @@ -679,43 +730,53 @@ void ViewProviderFEMMeshBuilder::buildNodes(const App::Property* prop, std::vect nodes.push_back(pcFaces); } else if (nodes.size() == 2) { - if (nodes[0]->getTypeId() == SoCoordinate3::getClassTypeId()) + if (nodes[0]->getTypeId() == SoCoordinate3::getClassTypeId()) { pcPointsCoord = static_cast(nodes[0]); - if (nodes[1]->getTypeId() == SoIndexedFaceSet::getClassTypeId()) + } + if (nodes[1]->getTypeId() == SoIndexedFaceSet::getClassTypeId()) { pcFaces = static_cast(nodes[1]); + } } - if (pcPointsCoord && pcFaces && pcLines){ + if (pcPointsCoord && pcFaces && pcLines) { std::vector vFaceElementIdx; std::vector vNodeElementIdx; bool onlyEdges; - createMesh(prop, pcPointsCoord, pcFaces,pcLines,vFaceElementIdx,vNodeElementIdx,onlyEdges,false,0); + createMesh(prop, + pcPointsCoord, + pcFaces, + pcLines, + vFaceElementIdx, + vNodeElementIdx, + onlyEdges, + false, + 0); } } -inline void insEdgeVec(std::map > &map, int n1, int n2) +inline void insEdgeVec(std::map>& map, int n1, int n2) { - //FIXME: The if-else distinction doesn't make sense - //if (n1 &vFaceElementIdx, - std::vector &vNodeElementIdx, - bool &onlyEdges, + std::vector& vFaceElementIdx, + std::vector& vNodeElementIdx, + bool& onlyEdges, bool ShowInner, int MaxFacesShowInner) const { @@ -728,14 +789,15 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, int numNodes = data->NbNodes(); int numEdges = data->NbEdges(); - if (numFaces+numNodes+numEdges == 0) { + if (numFaces + numNodes + numEdges == 0) { coords->point.setNum(0); faces->coordIndex.setNum(0); lines->coordIndex.setNum(0); return; } Base::TimeInfo Start; - Base::Console().Log("Start: ViewProviderFEMMeshBuilder::createMesh() =================================\n"); + Base::Console().Log( + "Start: ViewProviderFEMMeshBuilder::createMesh() =================================\n"); const SMDS_MeshInfo& info = data->GetMeshInfo(); int numTria = info.NbTriangles(); @@ -748,59 +810,99 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, int numPris = info.NbPrisms(); - bool ShowFaces = (numFaces >0 && numVolu == 0); + bool ShowFaces = (numFaces > 0 && numVolu == 0); int numTries; - if(ShowFaces) - numTries = numTria+numQuad/*+numPoly*/+numTetr*4+numHexa*6+numPyrd*5+numPris*5; - else - numTries = numTetr*4+numHexa*6+numPyrd*5+numPris*5; - // It is not 100% sure that a prism in smesh is a pentahedron in any case, but it will be in most cases! - // See http://forum.freecad.org/viewtopic.php?f=18&t=13583#p109707 + if (ShowFaces) { + numTries = + numTria + numQuad /*+numPoly*/ + numTetr * 4 + numHexa * 6 + numPyrd * 5 + numPris * 5; + } + else { + numTries = numTetr * 4 + numHexa * 6 + numPyrd * 5 + numPris * 5; + } + // It is not 100% sure that a prism in smesh is a pentahedron in any case, but it will be in + // most cases! See http://forum.freecad.org/viewtopic.php?f=18&t=13583#p109707 - // corner case only edges (Beams) in the mesh. This need some special cases in building up visual + // corner case only edges (Beams) in the mesh. This need some special cases in building up + // visual onlyEdges = false; - if (numFaces <= 0 && numVolu <= 0 && numEdges > 0){ + if (numFaces <= 0 && numVolu <= 0 && numEdges > 0) { onlyEdges = true; } std::vector facesHelper(numTries); - Base::Console().Log(" %f: Start build up %i face helper\n",Base::TimeInfo::diffTimeF(Start,Base::TimeInfo()),facesHelper.size()); + Base::Console().Log(" %f: Start build up %i face helper\n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo()), + facesHelper.size()); Base::BoundBox3d BndBox; - int i=0; + int i = 0; - if (ShowFaces){ + if (ShowFaces) { SMDS_FaceIteratorPtr aFaceIter = data->facesIterator(); - for (;aFaceIter->more();) { + for (; aFaceIter->more();) { const SMDS_MeshFace* aFace = aFaceIter->next(); int num = aFace->NbNodes(); - switch(num){ - case 3: - //tria3 face = N1, N2, N3 - BndBox.Add(facesHelper[i++].set(3, aFace, aFace->GetID(), 0, aFace->GetNode(0), aFace->GetNode(1), aFace->GetNode(2))); - break; - case 4: - //quad4 face = N1, N2, N3, N4 - BndBox.Add(facesHelper[i++].set(4, aFace, aFace->GetID(), 0, aFace->GetNode(0), aFace->GetNode(1), aFace->GetNode(2), aFace->GetNode(3))); - break; - case 6: - //tria6 face = N1, N4, N2, N5, N3, N6 - BndBox.Add(facesHelper[i++].set(6, aFace, aFace->GetID(), 0, aFace->GetNode(0), aFace->GetNode(3), aFace->GetNode(1), aFace->GetNode(4), aFace->GetNode(2), aFace->GetNode(5))); - break; - case 8: - //quad8 face = N1, N5, N2, N6, N3, N7, N4, N8 - BndBox.Add(facesHelper[i++].set(8, aFace, aFace->GetID(), 0, aFace->GetNode(0), aFace->GetNode(4), aFace->GetNode(1), aFace->GetNode(5), aFace->GetNode(2), aFace->GetNode(6), aFace->GetNode(3), aFace->GetNode(7))); - break; - default: - //unknown face type - throw std::runtime_error("Node count not supported by ViewProviderFemMesh, [3|4|6|8] are allowed"); + switch (num) { + case 3: + // tria3 face = N1, N2, N3 + BndBox.Add(facesHelper[i++].set(3, + aFace, + aFace->GetID(), + 0, + aFace->GetNode(0), + aFace->GetNode(1), + aFace->GetNode(2))); + break; + case 4: + // quad4 face = N1, N2, N3, N4 + BndBox.Add(facesHelper[i++].set(4, + aFace, + aFace->GetID(), + 0, + aFace->GetNode(0), + aFace->GetNode(1), + aFace->GetNode(2), + aFace->GetNode(3))); + break; + case 6: + // tria6 face = N1, N4, N2, N5, N3, N6 + BndBox.Add(facesHelper[i++].set(6, + aFace, + aFace->GetID(), + 0, + aFace->GetNode(0), + aFace->GetNode(3), + aFace->GetNode(1), + aFace->GetNode(4), + aFace->GetNode(2), + aFace->GetNode(5))); + break; + case 8: + // quad8 face = N1, N5, N2, N6, N3, N7, N4, N8 + BndBox.Add(facesHelper[i++].set(8, + aFace, + aFace->GetID(), + 0, + aFace->GetNode(0), + aFace->GetNode(4), + aFace->GetNode(1), + aFace->GetNode(5), + aFace->GetNode(2), + aFace->GetNode(6), + aFace->GetNode(3), + aFace->GetNode(7))); + break; + default: + // unknown face type + throw std::runtime_error( + "Node count not supported by ViewProviderFemMesh, [3|4|6|8] are allowed"); } } } - else{ + else { // iterate all volumes SMDS_VolumeIteratorPtr aVolIter = data->volumesIterator(); @@ -809,164 +911,498 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, int num = aVol->NbNodes(); - switch (num){ - //tetra4 volume - case 4: - // face 1 = N1, N2, N3 - // face 2 = N1, N4, N2 - // face 3 = N2, N4, N3 - // face 4 = N3, N4, N1 - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 1, aVol->GetNode(0), aVol->GetNode(1), aVol->GetNode(2))); - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 2, aVol->GetNode(0), aVol->GetNode(3), aVol->GetNode(1))); - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 3, aVol->GetNode(1), aVol->GetNode(3), aVol->GetNode(2))); - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 4, aVol->GetNode(2), aVol->GetNode(3), aVol->GetNode(0))); - break; - //pyra5 volume - case 5: - // face 1 = N1, N2, N3, N4 - // face 2 = N1, N5, N2 - // face 3 = N2, N5, N3 - // face 4 = N3, N5, N4 - // face 5 = N4, N5, N1 - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 1, aVol->GetNode(0), aVol->GetNode(1), aVol->GetNode(2), aVol->GetNode(3))); - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 2, aVol->GetNode(0), aVol->GetNode(4), aVol->GetNode(1))); - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 3, aVol->GetNode(1), aVol->GetNode(4), aVol->GetNode(2))); - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 4, aVol->GetNode(2), aVol->GetNode(4), aVol->GetNode(3))); - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 5, aVol->GetNode(3), aVol->GetNode(4), aVol->GetNode(0))); - break; - //penta6 volume - case 6: - // face 1 = N1, N2, N3 - // face 2 = N4, N6, N5 - // face 3 = N1, N4, N5, N2 - // face 4 = N2, N5, N6, N3 - // face 5 = N3, N6, N4, N1 - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 1, aVol->GetNode(0), aVol->GetNode(1), aVol->GetNode(2))); - BndBox.Add(facesHelper[i++].set(3, aVol, aVol->GetID(), 2, aVol->GetNode(3), aVol->GetNode(5), aVol->GetNode(4))); - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 3, aVol->GetNode(0), aVol->GetNode(3), aVol->GetNode(4), aVol->GetNode(1))); - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 4, aVol->GetNode(1), aVol->GetNode(4), aVol->GetNode(5), aVol->GetNode(2))); - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 5, aVol->GetNode(2), aVol->GetNode(5), aVol->GetNode(3), aVol->GetNode(0))); - break; - //hexa8 volume - case 8: - // face 1 = N1, N2, N3, N4 - // face 2 = N5, N8, N7, N6 - // face 3 = N1, N5, N6, N2 - // face 4 = N2, N6, N7, N3 - // face 5 = N3, N7, N8, N4 - // face 6 = N4, N8, N5, N1 - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 1, aVol->GetNode(0), aVol->GetNode(1), aVol->GetNode(2), aVol->GetNode(3))); - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 2, aVol->GetNode(4), aVol->GetNode(7), aVol->GetNode(6), aVol->GetNode(5))); - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 3, aVol->GetNode(0), aVol->GetNode(4), aVol->GetNode(5), aVol->GetNode(1))); - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 4, aVol->GetNode(1), aVol->GetNode(5), aVol->GetNode(6), aVol->GetNode(2))); - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 5, aVol->GetNode(2), aVol->GetNode(6), aVol->GetNode(7), aVol->GetNode(3))); - BndBox.Add(facesHelper[i++].set(4, aVol, aVol->GetID(), 6, aVol->GetNode(3), aVol->GetNode(7), aVol->GetNode(4), aVol->GetNode(0))); - break; - //tetra10 volume - case 10: - // face 1 = N1, N5, N2, N6, N3, N7 - // face 2 = N1, N8, N4, N9, N2, N5 - // face 3 = N2, N9, N4, N10, N3, N6 - // face 4 = N3, N10, N4, N8, N1, N7 - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 1, aVol->GetNode(0), aVol->GetNode(4), aVol->GetNode(1), aVol->GetNode(5), aVol->GetNode(2), aVol->GetNode(6))); - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 2, aVol->GetNode(0), aVol->GetNode(7), aVol->GetNode(3), aVol->GetNode(8), aVol->GetNode(1), aVol->GetNode(4))); - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 3, aVol->GetNode(1), aVol->GetNode(8), aVol->GetNode(3), aVol->GetNode(9), aVol->GetNode(2), aVol->GetNode(5))); - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 4, aVol->GetNode(2), aVol->GetNode(9), aVol->GetNode(3), aVol->GetNode(7), aVol->GetNode(0), aVol->GetNode(6))); - break; - //pyra13 volume - case 13: - // face 1 = N1, N6, N2, N7, N3, N8, N4, N9 - // face 2 = N1, N10, N5, N11, N2, N6 - // face 3 = N2, N11, N5, N12, N3, N7 - // face 4 = N3, N12, N5, N13, N4, N8 - // face 5 = N4, N13, N5, N10, N1, N9 - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 1, aVol->GetNode(0), aVol->GetNode(5), aVol->GetNode(1), aVol->GetNode(6), aVol->GetNode(2), aVol->GetNode(7), aVol->GetNode(3), aVol->GetNode(8))); - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 2, aVol->GetNode(0), aVol->GetNode(9), aVol->GetNode(4), aVol->GetNode(10), aVol->GetNode(1), aVol->GetNode(5))); - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 3, aVol->GetNode(1), aVol->GetNode(10), aVol->GetNode(4), aVol->GetNode(11), aVol->GetNode(2), aVol->GetNode(6))); - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 4, aVol->GetNode(2), aVol->GetNode(11), aVol->GetNode(4), aVol->GetNode(12), aVol->GetNode(3), aVol->GetNode(7))); - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 5, aVol->GetNode(3), aVol->GetNode(12), aVol->GetNode(4), aVol->GetNode(9), aVol->GetNode(0), aVol->GetNode(8))); - break; - //penta15 volume - case 15: - // face 1 = N1, N7, N2, N8, N3, N9 - // face 2 = N4, N12, N6, N11, N5, N10 - // face 3 = N1, N13, N4, N10, N5, N14, N2, N7 - // face 4 = N2, N14, N5, N11, N6, N15, N3, N8 - // face 5 = N3, N15, N6, N12, N4, N13, N1, N9 - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 1, aVol->GetNode(0), aVol->GetNode(6), aVol->GetNode(1), aVol->GetNode(7), aVol->GetNode(2), aVol->GetNode(8))); - BndBox.Add(facesHelper[i++].set(6, aVol, aVol->GetID(), 2, aVol->GetNode(3), aVol->GetNode(11), aVol->GetNode(5), aVol->GetNode(10), aVol->GetNode(4), aVol->GetNode(9))); - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 3, aVol->GetNode(0), aVol->GetNode(12), aVol->GetNode(3), aVol->GetNode(9), aVol->GetNode(4), aVol->GetNode(13), aVol->GetNode(1), aVol->GetNode(6))); - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 4, aVol->GetNode(1), aVol->GetNode(13), aVol->GetNode(4), aVol->GetNode(10), aVol->GetNode(5), aVol->GetNode(14), aVol->GetNode(2), aVol->GetNode(7))); - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 5, aVol->GetNode(2), aVol->GetNode(14), aVol->GetNode(5), aVol->GetNode(11), aVol->GetNode(3), aVol->GetNode(12), aVol->GetNode(0), aVol->GetNode(8))); - break; - //hexa20 volume - case 20: - // face 1 = N1, N9, N2, N10, N3, N11, N4, N12 - // face 2 = N5, N16, N8, N15, N7, N14, N6, N13 - // face 3 = N1, N17, N5, N13, N6, N18, N2, N9 - // face 4 = N2, N18, N6, N14, N7, N19, N3, N10 - // face 5 = N3, N19, N7, N15, N8, N20, N4, N11 - // face 6 = N4, N20, N8, N16, N5, N17, N1, N12 - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 1, aVol->GetNode(0), aVol->GetNode(8), aVol->GetNode(1), aVol->GetNode(9), aVol->GetNode(2), aVol->GetNode(10), aVol->GetNode(3), aVol->GetNode(11))); - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 2, aVol->GetNode(4), aVol->GetNode(15), aVol->GetNode(7), aVol->GetNode(14), aVol->GetNode(6), aVol->GetNode(13), aVol->GetNode(5), aVol->GetNode(12))); - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 3, aVol->GetNode(0), aVol->GetNode(16), aVol->GetNode(4), aVol->GetNode(12), aVol->GetNode(5), aVol->GetNode(17), aVol->GetNode(1), aVol->GetNode(8))); - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 4, aVol->GetNode(1), aVol->GetNode(17), aVol->GetNode(5), aVol->GetNode(13), aVol->GetNode(6), aVol->GetNode(18), aVol->GetNode(2), aVol->GetNode(9))); - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 5, aVol->GetNode(2), aVol->GetNode(18), aVol->GetNode(6), aVol->GetNode(14), aVol->GetNode(7), aVol->GetNode(19), aVol->GetNode(3), aVol->GetNode(10))); - BndBox.Add(facesHelper[i++].set(8, aVol, aVol->GetID(), 6, aVol->GetNode(3), aVol->GetNode(19), aVol->GetNode(7), aVol->GetNode(15), aVol->GetNode(4), aVol->GetNode(16), aVol->GetNode(0), aVol->GetNode(11))); - break; - //unknown volume type - default: - throw std::runtime_error("Node count not supported by ViewProviderFemMesh, [4|5|6|8|10|13|15|20] are allowed"); + switch (num) { + // tetra4 volume + case 4: + // face 1 = N1, N2, N3 + // face 2 = N1, N4, N2 + // face 3 = N2, N4, N3 + // face 4 = N3, N4, N1 + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 1, + aVol->GetNode(0), + aVol->GetNode(1), + aVol->GetNode(2))); + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 2, + aVol->GetNode(0), + aVol->GetNode(3), + aVol->GetNode(1))); + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 3, + aVol->GetNode(1), + aVol->GetNode(3), + aVol->GetNode(2))); + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 4, + aVol->GetNode(2), + aVol->GetNode(3), + aVol->GetNode(0))); + break; + // pyra5 volume + case 5: + // face 1 = N1, N2, N3, N4 + // face 2 = N1, N5, N2 + // face 3 = N2, N5, N3 + // face 4 = N3, N5, N4 + // face 5 = N4, N5, N1 + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 1, + aVol->GetNode(0), + aVol->GetNode(1), + aVol->GetNode(2), + aVol->GetNode(3))); + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 2, + aVol->GetNode(0), + aVol->GetNode(4), + aVol->GetNode(1))); + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 3, + aVol->GetNode(1), + aVol->GetNode(4), + aVol->GetNode(2))); + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 4, + aVol->GetNode(2), + aVol->GetNode(4), + aVol->GetNode(3))); + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 5, + aVol->GetNode(3), + aVol->GetNode(4), + aVol->GetNode(0))); + break; + // penta6 volume + case 6: + // face 1 = N1, N2, N3 + // face 2 = N4, N6, N5 + // face 3 = N1, N4, N5, N2 + // face 4 = N2, N5, N6, N3 + // face 5 = N3, N6, N4, N1 + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 1, + aVol->GetNode(0), + aVol->GetNode(1), + aVol->GetNode(2))); + BndBox.Add(facesHelper[i++].set(3, + aVol, + aVol->GetID(), + 2, + aVol->GetNode(3), + aVol->GetNode(5), + aVol->GetNode(4))); + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 3, + aVol->GetNode(0), + aVol->GetNode(3), + aVol->GetNode(4), + aVol->GetNode(1))); + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 4, + aVol->GetNode(1), + aVol->GetNode(4), + aVol->GetNode(5), + aVol->GetNode(2))); + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 5, + aVol->GetNode(2), + aVol->GetNode(5), + aVol->GetNode(3), + aVol->GetNode(0))); + break; + // hexa8 volume + case 8: + // face 1 = N1, N2, N3, N4 + // face 2 = N5, N8, N7, N6 + // face 3 = N1, N5, N6, N2 + // face 4 = N2, N6, N7, N3 + // face 5 = N3, N7, N8, N4 + // face 6 = N4, N8, N5, N1 + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 1, + aVol->GetNode(0), + aVol->GetNode(1), + aVol->GetNode(2), + aVol->GetNode(3))); + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 2, + aVol->GetNode(4), + aVol->GetNode(7), + aVol->GetNode(6), + aVol->GetNode(5))); + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 3, + aVol->GetNode(0), + aVol->GetNode(4), + aVol->GetNode(5), + aVol->GetNode(1))); + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 4, + aVol->GetNode(1), + aVol->GetNode(5), + aVol->GetNode(6), + aVol->GetNode(2))); + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 5, + aVol->GetNode(2), + aVol->GetNode(6), + aVol->GetNode(7), + aVol->GetNode(3))); + BndBox.Add(facesHelper[i++].set(4, + aVol, + aVol->GetID(), + 6, + aVol->GetNode(3), + aVol->GetNode(7), + aVol->GetNode(4), + aVol->GetNode(0))); + break; + // tetra10 volume + case 10: + // face 1 = N1, N5, N2, N6, N3, N7 + // face 2 = N1, N8, N4, N9, N2, N5 + // face 3 = N2, N9, N4, N10, N3, N6 + // face 4 = N3, N10, N4, N8, N1, N7 + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 1, + aVol->GetNode(0), + aVol->GetNode(4), + aVol->GetNode(1), + aVol->GetNode(5), + aVol->GetNode(2), + aVol->GetNode(6))); + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 2, + aVol->GetNode(0), + aVol->GetNode(7), + aVol->GetNode(3), + aVol->GetNode(8), + aVol->GetNode(1), + aVol->GetNode(4))); + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 3, + aVol->GetNode(1), + aVol->GetNode(8), + aVol->GetNode(3), + aVol->GetNode(9), + aVol->GetNode(2), + aVol->GetNode(5))); + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 4, + aVol->GetNode(2), + aVol->GetNode(9), + aVol->GetNode(3), + aVol->GetNode(7), + aVol->GetNode(0), + aVol->GetNode(6))); + break; + // pyra13 volume + case 13: + // face 1 = N1, N6, N2, N7, N3, N8, N4, N9 + // face 2 = N1, N10, N5, N11, N2, N6 + // face 3 = N2, N11, N5, N12, N3, N7 + // face 4 = N3, N12, N5, N13, N4, N8 + // face 5 = N4, N13, N5, N10, N1, N9 + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 1, + aVol->GetNode(0), + aVol->GetNode(5), + aVol->GetNode(1), + aVol->GetNode(6), + aVol->GetNode(2), + aVol->GetNode(7), + aVol->GetNode(3), + aVol->GetNode(8))); + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 2, + aVol->GetNode(0), + aVol->GetNode(9), + aVol->GetNode(4), + aVol->GetNode(10), + aVol->GetNode(1), + aVol->GetNode(5))); + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 3, + aVol->GetNode(1), + aVol->GetNode(10), + aVol->GetNode(4), + aVol->GetNode(11), + aVol->GetNode(2), + aVol->GetNode(6))); + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 4, + aVol->GetNode(2), + aVol->GetNode(11), + aVol->GetNode(4), + aVol->GetNode(12), + aVol->GetNode(3), + aVol->GetNode(7))); + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 5, + aVol->GetNode(3), + aVol->GetNode(12), + aVol->GetNode(4), + aVol->GetNode(9), + aVol->GetNode(0), + aVol->GetNode(8))); + break; + // penta15 volume + case 15: + // face 1 = N1, N7, N2, N8, N3, N9 + // face 2 = N4, N12, N6, N11, N5, N10 + // face 3 = N1, N13, N4, N10, N5, N14, N2, N7 + // face 4 = N2, N14, N5, N11, N6, N15, N3, N8 + // face 5 = N3, N15, N6, N12, N4, N13, N1, N9 + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 1, + aVol->GetNode(0), + aVol->GetNode(6), + aVol->GetNode(1), + aVol->GetNode(7), + aVol->GetNode(2), + aVol->GetNode(8))); + BndBox.Add(facesHelper[i++].set(6, + aVol, + aVol->GetID(), + 2, + aVol->GetNode(3), + aVol->GetNode(11), + aVol->GetNode(5), + aVol->GetNode(10), + aVol->GetNode(4), + aVol->GetNode(9))); + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 3, + aVol->GetNode(0), + aVol->GetNode(12), + aVol->GetNode(3), + aVol->GetNode(9), + aVol->GetNode(4), + aVol->GetNode(13), + aVol->GetNode(1), + aVol->GetNode(6))); + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 4, + aVol->GetNode(1), + aVol->GetNode(13), + aVol->GetNode(4), + aVol->GetNode(10), + aVol->GetNode(5), + aVol->GetNode(14), + aVol->GetNode(2), + aVol->GetNode(7))); + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 5, + aVol->GetNode(2), + aVol->GetNode(14), + aVol->GetNode(5), + aVol->GetNode(11), + aVol->GetNode(3), + aVol->GetNode(12), + aVol->GetNode(0), + aVol->GetNode(8))); + break; + // hexa20 volume + case 20: + // face 1 = N1, N9, N2, N10, N3, N11, N4, N12 + // face 2 = N5, N16, N8, N15, N7, N14, N6, N13 + // face 3 = N1, N17, N5, N13, N6, N18, N2, N9 + // face 4 = N2, N18, N6, N14, N7, N19, N3, N10 + // face 5 = N3, N19, N7, N15, N8, N20, N4, N11 + // face 6 = N4, N20, N8, N16, N5, N17, N1, N12 + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 1, + aVol->GetNode(0), + aVol->GetNode(8), + aVol->GetNode(1), + aVol->GetNode(9), + aVol->GetNode(2), + aVol->GetNode(10), + aVol->GetNode(3), + aVol->GetNode(11))); + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 2, + aVol->GetNode(4), + aVol->GetNode(15), + aVol->GetNode(7), + aVol->GetNode(14), + aVol->GetNode(6), + aVol->GetNode(13), + aVol->GetNode(5), + aVol->GetNode(12))); + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 3, + aVol->GetNode(0), + aVol->GetNode(16), + aVol->GetNode(4), + aVol->GetNode(12), + aVol->GetNode(5), + aVol->GetNode(17), + aVol->GetNode(1), + aVol->GetNode(8))); + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 4, + aVol->GetNode(1), + aVol->GetNode(17), + aVol->GetNode(5), + aVol->GetNode(13), + aVol->GetNode(6), + aVol->GetNode(18), + aVol->GetNode(2), + aVol->GetNode(9))); + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 5, + aVol->GetNode(2), + aVol->GetNode(18), + aVol->GetNode(6), + aVol->GetNode(14), + aVol->GetNode(7), + aVol->GetNode(19), + aVol->GetNode(3), + aVol->GetNode(10))); + BndBox.Add(facesHelper[i++].set(8, + aVol, + aVol->GetID(), + 6, + aVol->GetNode(3), + aVol->GetNode(19), + aVol->GetNode(7), + aVol->GetNode(15), + aVol->GetNode(4), + aVol->GetNode(16), + aVol->GetNode(0), + aVol->GetNode(11))); + break; + // unknown volume type + default: + throw std::runtime_error("Node count not supported by ViewProviderFemMesh, " + "[4|5|6|8|10|13|15|20] are allowed"); } } } int FaceSize = facesHelper.size(); - if( FaceSize < MaxFacesShowInner){ - Base::Console().Log(" %f: Start eliminate internal faces SIMPLE\n",Base::TimeInfo::diffTimeF(Start,Base::TimeInfo())); + if (FaceSize < MaxFacesShowInner) { + Base::Console().Log(" %f: Start eliminate internal faces SIMPLE\n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); // search for double (inside) faces and hide them - if(!ShowInner){ - for(int l=0; l< FaceSize;l++){ - if(! facesHelper[l].hide){ - for(int i=l+1; i Grid(NbrX*NbrY*NbrZ); + std::vector Grid(NbrX * NbrY * NbrZ); unsigned int iX = 0; unsigned int iY = 0; unsigned int iZ = 0; - for(int l=0; l< FaceSize;l++){ + for (int l = 0; l < FaceSize; l++) { Base::Vector3d point(facesHelper[l].getFirstNodePoint()); double x = (point.x - Xmin) / Xln; double y = (point.y - Ymin) / Yln; @@ -976,40 +1412,44 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, iY = y; iZ = z; - if(iX >= NbrX || iY >= NbrY || iZ >= NbrZ) + if (iX >= NbrX || iY >= NbrY || iZ >= NbrZ) { Base::Console().Log(" Outof range!\n"); + } - Grid[iX + iY*NbrX + iZ*NbrX*NbrY].push_back(&facesHelper[l]); + Grid[iX + iY * NbrX + iZ * NbrX * NbrY].push_back(&facesHelper[l]); } - unsigned int max =0, avg = 0; - for(const auto& it : Grid){ - for(size_t l=0; l< it.size();l++){ - if(! it[l]->hide){ - for(size_t i=l+1; iisSameFace(*(it[i])) ){ + unsigned int max = 0, avg = 0; + for (const auto& it : Grid) { + for (size_t l = 0; l < it.size(); l++) { + if (!it[l]->hide) { + for (size_t i = l + 1; i < it.size(); i++) { + if (it[l]->isSameFace(*(it[i]))) { break; } } } } - if(it.size() > max)max=it.size(); + if (it.size() > max) { + max = it.size(); + } avg += it.size(); } - avg = avg/Grid.size(); + avg = avg / Grid.size(); - Base::Console().Log(" VoxelSize: Max:%i ,Average:%i\n",max,avg); + Base::Console().Log(" VoxelSize: Max:%i ,Average:%i\n", max, avg); - } //if( FaceSize < 1000) + } // if( FaceSize < 1000) - Base::Console().Log(" %f: Start build up node map\n",Base::TimeInfo::diffTimeF(Start,Base::TimeInfo())); + Base::Console().Log(" %f: Start build up node map\n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); // sort out double nodes and build up index map std::map mapNodeIndex; // handling the corner case beams only, means no faces/triangles only nodes and edges - if (onlyEdges){ + if (onlyEdges) { SMDS_EdgeIteratorPtr aEdgeIte = data->edgesIterator(); for (; aEdgeIte->more();) { @@ -1017,31 +1457,34 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, int num = aEdge->NbNodes(); for (int i = 0; i < num; i++) { mapNodeIndex[aEdge->GetNode(i)] = 0; - } } - }else{ + } + else { for (int l = 0; l < FaceSize; l++) { if (!facesHelper[l].hide) { for (auto Node : facesHelper[l].Nodes) { - if (Node) + if (Node) { mapNodeIndex[Node] = 0; - else + } + else { break; + } } } } } - Base::Console().Log(" %f: Start set point vector\n",Base::TimeInfo::diffTimeF(Start,Base::TimeInfo())); + Base::Console().Log(" %f: Start set point vector\n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); // set the point coordinates coords->point.setNum(mapNodeIndex.size()); - vNodeElementIdx.resize(mapNodeIndex.size() ); - std::map::iterator it= mapNodeIndex.begin(); + vNodeElementIdx.resize(mapNodeIndex.size()); + std::map::iterator it = mapNodeIndex.begin(); SbVec3f* verts = coords->point.startEditing(); - for (int i=0;it != mapNodeIndex.end() ;++it,i++) { - verts[i].setValue((float)it->first->X(),(float)it->first->Y(),(float)it->first->Z()); + for (int i = 0; it != mapNodeIndex.end(); ++it, i++) { + verts[i].setValue((float)it->first->X(), (float)it->first->Y(), (float)it->first->Z()); it->second = i; // set selection idx vNodeElementIdx[i] = it->first->GetID(); @@ -1049,72 +1492,87 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, coords->point.finishEditing(); - // count triangle size - Base::Console().Log(" %f: Start count triangle size\n",Base::TimeInfo::diffTimeF(Start,Base::TimeInfo())); - int triangleCount=0; - for (int l = 0; l < FaceSize; l++){ - if (!facesHelper[l].hide) - switch (facesHelper[l].Size){ - case 3:triangleCount++; break; // 3-node triangle face --> 1 triangle - case 4:triangleCount += 2; break; // 4-node quadrangle face --> 2 triangles - case 6:triangleCount += 4; break; // 6-node triangle face --> 4 triangles - case 8:triangleCount += 6; break; // 8-node quadrangle face --> 6 triangles - default: throw std::runtime_error("Face with unknown node count found, only display mode nodes is supported for this element (tiangleCount)"); + Base::Console().Log(" %f: Start count triangle size\n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); + int triangleCount = 0; + for (int l = 0; l < FaceSize; l++) { + if (!facesHelper[l].hide) { + switch (facesHelper[l].Size) { + case 3: + triangleCount++; + break; // 3-node triangle face --> 1 triangle + case 4: + triangleCount += 2; + break; // 4-node quadrangle face --> 2 triangles + case 6: + triangleCount += 4; + break; // 6-node triangle face --> 4 triangles + case 8: + triangleCount += 6; + break; // 8-node quadrangle face --> 6 triangles + default: + throw std::runtime_error( + "Face with unknown node count found, only display mode nodes is supported " + "for this element (tiangleCount)"); + } } } - Base::Console().Log(" NumTriangles:%i\n",triangleCount); + Base::Console().Log(" NumTriangles:%i\n", triangleCount); // edge map collect and sort edges of the faces to be shown. - std::map > EdgeMap; + std::map> EdgeMap; // handling the corner case beams only, means no faces/triangles only nodes and edges - if (onlyEdges){ + if (onlyEdges) { SMDS_EdgeIteratorPtr aEdgeIte = data->edgesIterator(); for (; aEdgeIte->more();) { const SMDS_MeshEdge* aEdge = aEdgeIte->next(); int num = aEdge->NbNodes(); - switch (num){ - case 2: { // Seg2: N1, N2 - int nIdx0 = mapNodeIndex[aEdge->GetNode(0)]; - int nIdx1 = mapNodeIndex[aEdge->GetNode(1)]; - insEdgeVec(EdgeMap, nIdx0, nIdx1); - break; - } + switch (num) { + case 2: { // Seg2: N1, N2 + int nIdx0 = mapNodeIndex[aEdge->GetNode(0)]; + int nIdx1 = mapNodeIndex[aEdge->GetNode(1)]; + insEdgeVec(EdgeMap, nIdx0, nIdx1); + break; + } - case 3: { // Seg3: N1, N2, N3 (N3 is middle Node) - int nIdx0 = mapNodeIndex[aEdge->GetNode(0)]; - int nIdx1 = mapNodeIndex[aEdge->GetNode(1)]; - int nIdx2 = mapNodeIndex[aEdge->GetNode(2)]; - insEdgeVec(EdgeMap, nIdx0, nIdx2); - insEdgeVec(EdgeMap, nIdx2, nIdx1); - break; - } + case 3: { // Seg3: N1, N2, N3 (N3 is middle Node) + int nIdx0 = mapNodeIndex[aEdge->GetNode(0)]; + int nIdx1 = mapNodeIndex[aEdge->GetNode(1)]; + int nIdx2 = mapNodeIndex[aEdge->GetNode(2)]; + insEdgeVec(EdgeMap, nIdx0, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx1); + break; + } } } } - Base::Console().Log(" %f: Start build up triangle vector\n",Base::TimeInfo::diffTimeF(Start,Base::TimeInfo())); + Base::Console().Log(" %f: Start build up triangle vector\n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); // set the triangle face indices - faces->coordIndex.setNum(4*triangleCount); + faces->coordIndex.setNum(4 * triangleCount); vFaceElementIdx.resize(triangleCount); - int index=0,indexIdx=0; + int index = 0, indexIdx = 0; int32_t* indices = faces->coordIndex.startEditing(); - // iterate all non-hidden element faces, always assure CLOCKWISE triangle ordering to allow backface culling - for(int l=0; l< FaceSize;l++){ - if(! facesHelper[l].hide){ - switch( facesHelper[l].Element->NbNodes()){ + // iterate all non-hidden element faces, always assure CLOCKWISE triangle ordering to allow + // backface culling + for (int l = 0; l < FaceSize; l++) { + if (!facesHelper[l].hide) { + switch (facesHelper[l].Element->NbNodes()) { // 3 nodes case 3: // tria3 face - switch (facesHelper[l].FaceNo){ - case 0: { // tria3 face, 3-node triangle + switch (facesHelper[l].FaceNo) { + case 0: { // tria3 face, 3-node triangle // prefeche all node indexes of this face int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; - // create triangle number 1 ---------------------------------------------- - // fill in the node indexes in CLOCKWISE order + // create triangle number 1 + // ---------------------------------------------- fill in the node + // indexes in CLOCKWISE order indices[index++] = nIdx0; indices[index++] = nIdx1; indices[index++] = nIdx2; @@ -1124,24 +1582,27 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx0); // remember the element and face number for that triangle - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - break; } - default: assert(0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + break; + } + default: + assert(0); } break; // 4 nodes case 4: // quad4 face // tetra4 volume, four 3-node triangles - switch (facesHelper[l].FaceNo){ - case 0: { // quad4 face, 4-node quadrangle + switch (facesHelper[l].FaceNo) { + case 0: { // quad4 face, 4-node quadrangle // prefeche all node indexes of this face int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx3 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; - // create triangle number 1 ---------------------------------------------- - // fill in the node indexes in CLOCKWISE order + // create triangle number 1 + // ---------------------------------------------- fill in the node + // indexes in CLOCKWISE order indices[index++] = nIdx0; indices[index++] = nIdx1; indices[index++] = nIdx2; @@ -1150,17 +1611,19 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, insEdgeVec(EdgeMap, nIdx0, nIdx1); insEdgeVec(EdgeMap, nIdx1, nIdx2); // remember the element and face number for that triangle - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - // create triangle number 2 ---------------------------------------------- + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + // create triangle number 2 + // ---------------------------------------------- indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx2, nIdx3); insEdgeVec(EdgeMap, nIdx3, nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - break; } - case 1: { // tetra4 volume: face 1, 3-node triangle + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + break; + } + case 1: { // tetra4 volume: face 1, 3-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; @@ -1168,12 +1631,13 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - insEdgeVec(EdgeMap,nIdx2,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - break; } - case 2: { // tetra4 volume: face 2, 3-node triangle + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + break; + } + case 2: { // tetra4 volume: face 2, 3-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; @@ -1181,12 +1645,13 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - insEdgeVec(EdgeMap,nIdx2,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); - break; } - case 3: { // tetra4 volume: face 3, 3-node triangle + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); + break; + } + case 3: { // tetra4 volume: face 3, 3-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; @@ -1194,12 +1659,13 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - insEdgeVec(EdgeMap,nIdx2,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); - break; } - case 4: { // tetra4 volume: face 4, 3-node triangle + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); + break; + } + case 4: { // tetra4 volume: face 4, 3-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; @@ -1207,19 +1673,21 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - insEdgeVec(EdgeMap,nIdx2,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); - break; } - default: assert(0); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); + break; + } + default: + assert(0); } break; // 5 nodes case 5: // pyra5 volume, one 4-node quadrangle and four 3-node triangles - switch (facesHelper[l].FaceNo){ - case 1: { // pyra5 volume: face 1, 4-node quadrangle + switch (facesHelper[l].FaceNo) { + case 1: { // pyra5 volume: face 1, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; @@ -1228,18 +1696,19 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - break; } - case 2: { // pyra5 volume: face 2, 3-node triangle + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + break; + } + case 2: { // pyra5 volume: face 2, 3-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; @@ -1247,12 +1716,13 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - insEdgeVec(EdgeMap,nIdx2,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); - break; } - case 3: { // pyra5 volume: face 3, 3-node triangle + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); + break; + } + case 3: { // pyra5 volume: face 3, 3-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; @@ -1260,12 +1730,13 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - insEdgeVec(EdgeMap,nIdx2,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); - break; } - case 4: { // pyra5 volume: face 4, 3-node triangle + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); + break; + } + case 4: { // pyra5 volume: face 4, 3-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; @@ -1273,12 +1744,13 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - insEdgeVec(EdgeMap,nIdx2,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); - break; } - case 5: { // pyra5 volume: face 5, 3-node triangle + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); + break; + } + case 5: { // pyra5 volume: face 5, 3-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; @@ -1286,20 +1758,22 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - insEdgeVec(EdgeMap,nIdx2,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); - break; } - default: assert(0); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); + break; + } + default: + assert(0); } break; // 6 nodes case 6: // tria6 face // penta6 volume, two 3-node triangle and three 4-node quadrangles - switch (facesHelper[l].FaceNo){ - case 0: { // tria6 face, 6-node triangle + switch (facesHelper[l].FaceNo) { + case 0: { // tria6 face, 6-node triangle // prefeche all node indexes of this face int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; @@ -1307,8 +1781,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, int nIdx3 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx4 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx5 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; - // create triangle number 1 ---------------------------------------------- - // fill in the node indexes in CLOCKWISE order + // create triangle number 1 + // ---------------------------------------------- fill in the node + // indexes in CLOCKWISE order indices[index++] = nIdx5; indices[index++] = nIdx0; indices[index++] = nIdx1; @@ -1317,31 +1792,35 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); // remember the element and face number for that triangle - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - // create triangle number 2 ---------------------------------------------- + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + // create triangle number 2 + // ---------------------------------------------- indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - // create triangle number 3 ---------------------------------------------- + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + // create triangle number 3 + // ---------------------------------------------- indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - // create triangle number 4 ---------------------------------------------- + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + // create triangle number 4 + // ---------------------------------------------- indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; // this triangle has no edge (inner triangle). - break; } - case 1: { // penta6 volume: face 1, 3-node triangle + break; + } + case 1: { // penta6 volume: face 1, 3-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; @@ -1349,12 +1828,13 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - insEdgeVec(EdgeMap,nIdx2,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - break; } - case 2: { // penta6 volume: face 2, 3-node triangle + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + insEdgeVec(EdgeMap, nIdx2, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + break; + } + case 2: { // penta6 volume: face 2, 3-node triangle int nIdx3 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx5 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; int nIdx4 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -1362,12 +1842,13 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx4; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx3,nIdx5); - insEdgeVec(EdgeMap,nIdx5,nIdx4); - insEdgeVec(EdgeMap,nIdx4,nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); - break; } - case 3: { // penta6 volume: face 3, 4-node quadrangle + insEdgeVec(EdgeMap, nIdx3, nIdx5); + insEdgeVec(EdgeMap, nIdx5, nIdx4); + insEdgeVec(EdgeMap, nIdx4, nIdx3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); + break; + } + case 3: { // penta6 volume: face 3, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -1376,18 +1857,19 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); - break; } - case 4: { // penta6 volume: face 4, 4-node quadrangle + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); + break; + } + case 4: { // penta6 volume: face 4, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; @@ -1396,18 +1878,19 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); - break; } - case 5: { // penta6 volume: face 5, 4-node quadrangle + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); + break; + } + case 5: { // penta6 volume: face 5, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; @@ -1416,26 +1899,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); - break; } - default: assert(0); + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); + break; + } + default: + assert(0); } break; // 8 nodes case 8: // quad8 face // hexa8 volume, six 4-node quadrangles - switch(facesHelper[l].FaceNo){ - case 0: { // quad8 face, 8-node quadrangle + switch (facesHelper[l].FaceNo) { + case 0: { // quad8 face, 8-node quadrangle // prefeche all node indexes of this face int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -1445,8 +1930,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, int nIdx5 = mapNodeIndex[facesHelper[l].Element->GetNode(6)]; int nIdx6 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx7 = mapNodeIndex[facesHelper[l].Element->GetNode(7)]; - // create triangle number 1 ---------------------------------------------- - // fill in the node indexes in CLOCKWISE order + // create triangle number 1 + // ---------------------------------------------- fill in the node + // indexes in CLOCKWISE order indices[index++] = nIdx7; indices[index++] = nIdx0; indices[index++] = nIdx1; @@ -1455,45 +1941,51 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); // remember the element and face number for that triangle - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - // create triangle number 2 ---------------------------------------------- + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + // create triangle number 2 + // ---------------------------------------------- indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - // create triangle number 3 ---------------------------------------------- + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + // create triangle number 3 + // ---------------------------------------------- indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - // create triangle number 4 ---------------------------------------------- + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + // create triangle number 4 + // ---------------------------------------------- indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - // create triangle number 5 ---------------------------------------------- + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + // create triangle number 5 + // ---------------------------------------------- indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; // this triangle has no edge (inner triangle) - // create triangle number 6 ---------------------------------------------- + // create triangle number 6 + // ---------------------------------------------- indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; // this triangle has no edge (inner triangle) - break; } - case 1: { // hexa8 volume: face 1, 4-node quadrangle + break; + } + case 1: { // hexa8 volume: face 1, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; @@ -1502,18 +1994,19 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); - break; } - case 2: { // hexa8 volume: face 2, 4-node quadrangle + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); + break; + } + case 2: { // hexa8 volume: face 2, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(7)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(6)]; @@ -1522,18 +2015,19 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); - break; } - case 3: { // hexa8 volume: face 3, 4-node quadrangle + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); + break; + } + case 3: { // hexa8 volume: face 3, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; @@ -1542,18 +2036,19 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); - break; } - case 4: { // hexa8 volume: face 4, 4-node quadrangle + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); + break; + } + case 4: { // hexa8 volume: face 4, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(6)]; @@ -1562,18 +2057,19 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); - break; } - case 5: { // hexa8 volume: face 5, 4-node quadrangle + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); + break; + } + case 5: { // hexa8 volume: face 5, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(6)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(7)]; @@ -1582,18 +2078,19 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); - break; } - case 6: { // hexa8 volume: face 6, 4-node quadrangle + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); + break; + } + case 6: { // hexa8 volume: face 6, 4-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(7)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -1602,25 +2099,27 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx0,nIdx1); - insEdgeVec(EdgeMap,nIdx1,nIdx2); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,5); + insEdgeVec(EdgeMap, nIdx0, nIdx1); + insEdgeVec(EdgeMap, nIdx1, nIdx2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 5); indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = nIdx0; indices[index++] = SO_END_FACE_INDEX; - insEdgeVec(EdgeMap,nIdx2,nIdx3); - insEdgeVec(EdgeMap,nIdx3,nIdx0); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,5); - break; } - default: assert(0); + insEdgeVec(EdgeMap, nIdx2, nIdx3); + insEdgeVec(EdgeMap, nIdx3, nIdx0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 5); + break; + } + default: + assert(0); } break; // 10 nodes case 10: // tetra10 volume, four 6-node triangles - switch(facesHelper[l].FaceNo){ - case 1: { // tetra10 volume: face 1, 6-node triangle + switch (facesHelper[l].FaceNo) { + case 1: { // tetra10 volume: face 1, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; @@ -1633,27 +2132,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - case 2: { // tetra10 volume: face 2, 6-node triangle + break; + } + case 2: { // tetra10 volume: face 2, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(7)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; @@ -1666,27 +2166,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - case 3: { // tetra10 volume: face 3, 6-node triangle + break; + } + case 3: { // tetra10 volume: face 3, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(8)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; @@ -1699,27 +2200,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - case 4: { // tetra10 volume: face 4, 6-node triangle + break; + } + case 4: { // tetra10 volume: face 4, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(9)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; @@ -1732,34 +2234,36 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - default: assert(0); + break; + } + default: + assert(0); } break; // 13 nodes case 13: // pyra13 volume, four 6-node triangle and one 8-node quadrangles - switch(facesHelper[l].FaceNo){ - case 1: { // pyra13 volume: face 1, 8-node quadrangles + switch (facesHelper[l].FaceNo) { + case 1: { // pyra13 volume: face 1, 8-node quadrangles int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; @@ -1804,8 +2308,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - case 2: { // pyra13 volume: face 2, 6-node triangle + break; + } + case 2: { // pyra13 volume: face 2, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(9)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -1818,27 +2323,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - case 3: { // pyra13 volume: face 3, 6-node triangle + break; + } + case 3: { // pyra13 volume: face 3, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(10)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -1851,27 +2357,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - case 4: { // pyra13 volume: face 4, 6-node triangle + break; + } + case 4: { // pyra13 volume: face 4, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(11)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -1884,27 +2391,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - case 5: { // pyra13 volume: face 5, 6-node triangle + break; + } + case 5: { // pyra13 volume: face 5, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(12)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -1917,34 +2425,36 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - default: assert(0); + break; + } + default: + assert(0); } break; // 15 nodes case 15: // penta15 volume, two 6-node triangles and three 8-node quadrangles - switch(facesHelper[l].FaceNo){ - case 1: { // penta15 volume: face 1, 6-node triangle + switch (facesHelper[l].FaceNo) { + case 1: { // penta15 volume: face 1, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(6)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; @@ -1957,27 +2467,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - case 2: { // penta15 volume: face 2, 6-node triangle + break; + } + case 2: { // penta15 volume: face 2, 6-node triangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(11)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; @@ -1990,27 +2501,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx1; indices[index++] = nIdx3; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; - break; } - case 3: { // penta15 volume: face 3, 8-node quadrangle + break; + } + case 3: { // penta15 volume: face 3, 8-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(12)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; @@ -2025,28 +2537,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; @@ -2055,8 +2567,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - case 4: { // penta15 volume: face 4, 8-node quadrangle + break; + } + case 4: { // penta15 volume: face 4, 8-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(13)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -2071,28 +2584,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; @@ -2101,8 +2614,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - case 5: { // penta15 volume: face 5, 8-node quadrangle + break; + } + case 5: { // penta15 volume: face 5, 8-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(14)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; @@ -2117,28 +2631,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; @@ -2147,15 +2661,17 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - default: assert(0); + break; + } + default: + assert(0); } break; // 20 nodes case 20: // hexa20 volume, six 8-node quadrangles - switch(facesHelper[l].FaceNo){ - case 1: { // hexa20 volume: face 1 + switch (facesHelper[l].FaceNo) { + case 1: { // hexa20 volume: face 1 int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(8)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; @@ -2170,28 +2686,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,0); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 0); indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; @@ -2200,8 +2716,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - case 2: { // hexa20 volume: face 2, 8-node quadrangle + break; + } + case 2: { // hexa20 volume: face 2, 8-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(15)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(7)]; @@ -2216,28 +2733,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,1); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 1); indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; @@ -2246,8 +2763,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - case 3: { // hexa20 volume: face 3, 8-node quadrangle + break; + } + case 3: { // hexa20 volume: face 3, 8-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(0)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(16)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(4)]; @@ -2262,28 +2780,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,2); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 2); indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; @@ -2292,8 +2810,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - case 4: { // hexa20 volume: face 4, 8-node quadrangle + break; + } + case 4: { // hexa20 volume: face 4, 8-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(1)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(17)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(5)]; @@ -2308,28 +2827,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,3); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 3); indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; @@ -2338,8 +2857,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - case 5: { // hexa20 volume: face 5, 8-node quadrangle + break; + } + case 5: { // hexa20 volume: face 5, 8-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(2)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(18)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(6)]; @@ -2354,28 +2874,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,4); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 4); indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; @@ -2384,8 +2904,9 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - case 6: { // hexa20 volume: face 6, 8-node quadrangle + break; + } + case 6: { // hexa20 volume: face 6, 8-node quadrangle int nIdx0 = mapNodeIndex[facesHelper[l].Element->GetNode(3)]; int nIdx1 = mapNodeIndex[facesHelper[l].Element->GetNode(19)]; int nIdx2 = mapNodeIndex[facesHelper[l].Element->GetNode(7)]; @@ -2400,28 +2921,28 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx7, nIdx0); insEdgeVec(EdgeMap, nIdx0, nIdx1); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,5); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 5); indices[index++] = nIdx1; indices[index++] = nIdx2; indices[index++] = nIdx3; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx1, nIdx2); insEdgeVec(EdgeMap, nIdx2, nIdx3); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,5); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 5); indices[index++] = nIdx3; indices[index++] = nIdx4; indices[index++] = nIdx5; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx3, nIdx4); insEdgeVec(EdgeMap, nIdx4, nIdx5); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,5); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 5); indices[index++] = nIdx5; indices[index++] = nIdx6; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; insEdgeVec(EdgeMap, nIdx5, nIdx6); insEdgeVec(EdgeMap, nIdx6, nIdx7); - vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber,5); + vFaceElementIdx[indexIdx++] = ElemFold(facesHelper[l].ElementNumber, 5); indices[index++] = nIdx7; indices[index++] = nIdx1; indices[index++] = nIdx3; @@ -2430,33 +2951,43 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, indices[index++] = nIdx5; indices[index++] = nIdx7; indices[index++] = SO_END_FACE_INDEX; - break; } - default: assert(0); + break; + } + default: + assert(0); } break; // not implemented elements - default: throw std::runtime_error("Element with unknown node count found (may be not implemented), only display mode nodes is supported for this element (NodeCount)"); + default: + throw std::runtime_error( + "Element with unknown node count found (may be not implemented), only " + "display mode nodes is supported for this element (NodeCount)"); } } } faces->coordIndex.finishEditing(); - Base::Console().Log(" %f: Start build up edge vector\n",Base::TimeInfo::diffTimeF(Start,Base::TimeInfo())); + Base::Console().Log(" %f: Start build up edge vector\n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); // std::map > EdgeMap; // count edges int EdgeSize = 0; - for(std::map >::const_iterator it= EdgeMap.begin();it!= EdgeMap.end();++it) + for (std::map>::const_iterator it = EdgeMap.begin(); it != EdgeMap.end(); + ++it) { EdgeSize += it->second.size(); + } // set the triangle face indices - lines->coordIndex.setNum(3*EdgeSize); - index=0; + lines->coordIndex.setNum(3 * EdgeSize); + index = 0; indices = lines->coordIndex.startEditing(); - for(std::map >::const_iterator it= EdgeMap.begin();it!= EdgeMap.end();++it){ - for(std::set::const_iterator it2=it->second.begin();it2!=it->second.end();++it2){ + for (std::map>::const_iterator it = EdgeMap.begin(); it != EdgeMap.end(); + ++it) { + for (std::set::const_iterator it2 = it->second.begin(); it2 != it->second.end(); + ++it2) { indices[index++] = it->first; indices[index++] = *it2; indices[index++] = -1; @@ -2464,21 +2995,22 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, } lines->coordIndex.finishEditing(); - Base::Console().Log(" NumEdges:%i\n",EdgeSize); - - Base::Console().Log(" %f: Finish =========================================================\n",Base::TimeInfo::diffTimeF(Start,Base::TimeInfo())); - + Base::Console().Log(" NumEdges:%i\n", EdgeSize); + Base::Console().Log( + " %f: Finish =========================================================\n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); } // Python feature ----------------------------------------------------------------------- -namespace Gui { +namespace Gui +{ /// @cond DOXERR PROPERTY_SOURCE_TEMPLATE(FemGui::ViewProviderFemMeshPython, FemGui::ViewProviderFemMesh) /// @endcond // explicit template instantiation template class FemGuiExport ViewProviderPythonFeatureT; -} +} // namespace Gui diff --git a/src/Mod/Fem/Gui/ViewProviderFemMesh.h b/src/Mod/Fem/Gui/ViewProviderFemMesh.h index 31e76fed8f..cca87ee6c4 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMesh.h +++ b/src/Mod/Fem/Gui/ViewProviderFemMesh.h @@ -38,11 +38,11 @@ class SoMaterialBinding; namespace FemGui { -class ViewProviderFEMMeshBuilder : public Gui::ViewProviderBuilder +class ViewProviderFEMMeshBuilder: public Gui::ViewProviderBuilder { public: - ViewProviderFEMMeshBuilder()= default; - ~ViewProviderFEMMeshBuilder() override= default; + ViewProviderFEMMeshBuilder() = default; + ~ViewProviderFEMMeshBuilder() override = default; void buildNodes(const App::Property*, std::vector&) const override; void createMesh(const App::Property*, SoCoordinate3*, @@ -50,13 +50,12 @@ public: SoIndexedLineSet*, std::vector&, std::vector&, - bool &edgeOnly, + bool& edgeOnly, bool ShowInner, - int MaxFacesShowInner - ) const; + int MaxFacesShowInner) const; }; -class FemGuiExport ViewProviderFemMesh : public Gui::ViewProviderGeometryObject +class FemGuiExport ViewProviderFemMesh: public Gui::ViewProviderGeometryObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemMesh); @@ -71,23 +70,26 @@ public: App::PropertyColor PointColor; App::PropertyFloatConstraint PointSize; App::PropertyFloatConstraint LineWidth; - App::PropertyBool BackfaceCulling; - App::PropertyBool ShowInner; - App::PropertyInteger MaxFacesShowInner; + App::PropertyBool BackfaceCulling; + App::PropertyBool ShowInner; + App::PropertyInteger MaxFacesShowInner; - void attach(App::DocumentObject *pcObject) override; + void attach(App::DocumentObject* pcObject) override; void setDisplayMode(const char* ModeName) override; std::vector getDisplayModes() const override; void updateData(const App::Property*) override; - /** @name Selection handling - * This group of methods do the selection handling. - * Here you can define how the selection for your ViewProvider - * works. + /** @name Selection handling + * This group of methods do the selection handling. + * Here you can define how the selection for your ViewProvider + * works. */ //@{ /// indicates if the ViewProvider use the new Selection model - bool useNewSelectionModel() const override {return true;} + bool useNewSelectionModel() const override + { + return true; + } /// return a hit element to the selection path or 0 std::string getElement(const SoDetail*) const override; SoDetail* getDetail(const char*) const override; @@ -101,34 +103,39 @@ public: void resetHighlightNodes(); /** @name Postprocessing - * this interfaces apply post processing stuff to the View- - * Provider. They can override the positioning and the color - * color or certain elements. + * this interfaces apply post processing stuff to the View- + * Provider. They can override the positioning and the color + * color or certain elements. */ //@{ /// set the color for each node - void setColorByNodeId(const std::map &NodeColorMap); - void setColorByNodeId(const std::vector &NodeIds,const std::vector &NodeColors); + void setColorByNodeId(const std::map& NodeColorMap); + void setColorByNodeId(const std::vector& NodeIds, + const std::vector& NodeColors); /// reset the view of the node colors void resetColorByNodeId(); /// set the displacement for each node - void setDisplacementByNodeId(const std::map &NodeDispMap); - void setDisplacementByNodeId(const std::vector &NodeIds,const std::vector &NodeDisps); + void setDisplacementByNodeId(const std::map& NodeDispMap); + void setDisplacementByNodeId(const std::vector& NodeIds, + const std::vector& NodeDisps); /// reset the view of the node displacement void resetDisplacementByNodeId(); /// reaply the node displacement with a certain factor and do a redraw void applyDisplacementToNodes(double factor); /// set the color for each element - void setColorByElementId(const std::map &ElementColorMap); + void setColorByElementId(const std::map& ElementColorMap); /// reset the view of the element colors void resetColorByElementId(); //@} - const std::vector &getVisibleElementFaces()const{return vFaceElementIdx;} + const std::vector& getVisibleElementFaces() const + { + return vFaceElementIdx; + } - PyObject *getPyObject() override; + PyObject* getPyObject() override; private: static App::PropertyFloatConstraint::Constraints floatRange; @@ -139,26 +146,26 @@ protected: /// get called by the container whenever a property has been changed void onChanged(const App::Property* prop) override; - void setColorByNodeIdHelper(const std::vector &); - void setDisplacementByNodeIdHelper(const std::vector& DispVector,long startId); + void setColorByNodeIdHelper(const std::vector&); + void setDisplacementByNodeIdHelper(const std::vector& DispVector, long startId); /// index of elements to their triangles std::vector vFaceElementIdx; std::vector vNodeElementIdx; std::vector vHighlightedIdx; std::vector DisplacementVector; - double DisplacementFactor; + double DisplacementFactor; - SoMaterial * pcPointMaterial; - SoDrawStyle * pcPointStyle; + SoMaterial* pcPointMaterial; + SoDrawStyle* pcPointStyle; - SoDrawStyle * pcDrawStyle; - SoShapeHints * pShapeHints; - SoMaterialBinding * pcMatBinding; - SoCoordinate3 * pcCoords; - SoCoordinate3 * pcAnoCoords; - SoIndexedFaceSet * pcFaces; - SoIndexedLineSet * pcLines; + SoDrawStyle* pcDrawStyle; + SoShapeHints* pShapeHints; + SoMaterialBinding* pcMatBinding; + SoCoordinate3* pcCoords; + SoCoordinate3* pcAnoCoords; + SoIndexedFaceSet* pcFaces; + SoIndexedLineSet* pcLines; bool onlyEdges; @@ -169,7 +176,7 @@ private: using ViewProviderFemMeshPython = Gui::ViewProviderPythonFeatureT; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_VIEWPROVIDERFEMMESH_H +#endif // FEM_VIEWPROVIDERFEMMESH_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp index 4a0da8c83f..030e262dee 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp @@ -2,8 +2,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include #endif #include @@ -11,9 +11,11 @@ #include #include "ViewProviderFemMesh.h" +// clang-format off // inclusion of the generated files (generated out of ViewProviderFemMeshPy.xml) #include "ViewProviderFemMeshPy.h" #include "ViewProviderFemMeshPy.cpp" +// clang-format off using namespace FemGui; @@ -28,8 +30,9 @@ std::string ViewProviderFemMeshPy::representation() const PyObject* ViewProviderFemMeshPy::applyDisplacement(PyObject* args) { double factor; - if (!PyArg_ParseTuple(args, "d", &factor)) + if (!PyArg_ParseTuple(args, "d", &factor)) { return nullptr; + } this->getViewProviderFemMeshPtr()->applyDisplacementToNodes(factor); @@ -39,23 +42,34 @@ PyObject* ViewProviderFemMeshPy::applyDisplacement(PyObject* args) App::Color calcColor(double value, double min, double max) { - if (max < 0) max = 0; - if (min > 0) min = 0; + if (max < 0) { + max = 0; + } + if (min > 0) { + min = 0; + } - if (value < min) + if (value < min) { return App::Color(0.0, 0.0, 1.0); - if (value > max) + } + if (value > max) { return App::Color(1.0, 0.0, 0.0); - if (value == 0.0) + } + if (value == 0.0) { return App::Color(0.0, 1.0, 0.0); - if (value > max / 2.0) + } + if (value > max / 2.0) { return App::Color(1.0, 1 - ((value - (max / 2.0)) / (max / 2.0)), 0.0); - if (value > 0.0) + } + if (value > 0.0) { return App::Color(value / (max / 2.0), 1.0, 0.0); - if (value < min / 2.0) + } + if (value < min / 2.0) { return App::Color(0.0, 1 - ((value - (min / 2.0)) / (min / 2.0)), 1.0); - if (value < 0.0) + } + if (value < 0.0) { return App::Color(0.0, 1.0, value / (min / 2.0)); + } return App::Color(0, 0, 0); } @@ -83,18 +97,23 @@ PyObject* ViewProviderFemMeshPy::setNodeColorByScalars(PyObject* args) PyObject* value_py = PyList_GetItem(values_py, i); double val = PyFloat_AsDouble(value_py); values.push_back(val); - if (val > max) + if (val > max) { max = val; - if (val < min) + } + if (val < min) { min = val; + } } long i = 0; - for (std::vector::const_iterator it = values.begin(); it != values.end(); ++it, i++) + for (std::vector::const_iterator it = values.begin(); it != values.end(); + ++it, i++) { node_colors[i] = calcColor(*it, min, max); + } this->getViewProviderFemMeshPtr()->setColorByNodeId(ids, node_colors); } else { - PyErr_SetString(PyExc_TypeError, "PyArg_ParseTuple failed. Invalid arguments used with setNodeByScalars"); + PyErr_SetString(PyExc_TypeError, + "PyArg_ParseTuple failed. Invalid arguments used with setNodeByScalars"); return nullptr; } Py_Return; @@ -103,8 +122,9 @@ PyObject* ViewProviderFemMeshPy::setNodeColorByScalars(PyObject* args) PyObject* ViewProviderFemMeshPy::resetNodeColor(PyObject* args) { - if (!PyArg_ParseTuple(args, "")) + if (!PyArg_ParseTuple(args, "")) { return nullptr; + } this->getViewProviderFemMeshPtr()->resetColorByNodeId(); Py_Return; } @@ -133,7 +153,9 @@ PyObject* ViewProviderFemMeshPy::setNodeDisplacementByVectors(PyObject* args) this->getViewProviderFemMeshPtr()->setDisplacementByNodeId(ids, vectors); } else { - PyErr_SetString(PyExc_TypeError, "PyArg_ParseTuple failed. Invalid arguments used with setNodeDisplacementByVectors"); + PyErr_SetString( + PyExc_TypeError, + "PyArg_ParseTuple failed. Invalid arguments used with setNodeDisplacementByVectors"); return nullptr; } Py_Return; @@ -142,8 +164,9 @@ PyObject* ViewProviderFemMeshPy::setNodeDisplacementByVectors(PyObject* args) PyObject* ViewProviderFemMeshPy::resetNodeDisplacement(PyObject* args) { - if (!PyArg_ParseTuple(args, "")) + if (!PyArg_ParseTuple(args, "")) { return nullptr; + } this->getViewProviderFemMeshPtr()->resetDisplacementByNodeId(); Py_Return; } @@ -151,7 +174,7 @@ PyObject* ViewProviderFemMeshPy::resetNodeDisplacement(PyObject* args) Py::Dict ViewProviderFemMeshPy::getNodeColor() const { - //return Py::List(); + // return Py::List(); throw Py::AttributeError("Not yet implemented"); } @@ -159,18 +182,21 @@ Py::Dict ViewProviderFemMeshPy::getNodeColor() const void ViewProviderFemMeshPy::setNodeColor(Py::Dict arg) { long size = arg.size(); - if (size == 0) + if (size == 0) { this->getViewProviderFemMeshPtr()->resetColorByNodeId(); + } else { Base::TimeInfo Start; - Base::Console().Log("Start: ViewProviderFemMeshPy::setNodeColor() =================================\n"); - //std::map NodeColorMap; + Base::Console().Log( + "Start: ViewProviderFemMeshPy::setNodeColor() =================================\n"); + // std::map NodeColorMap; - //for( Py::Dict::iterator it = arg.begin(); it!= arg.end();++it){ - // Py::Long id((*it).first); - // Py::Tuple color((*it).second); - // NodeColorMap[id] = App::Color(Py::Float(color[0]),Py::Float(color[1]),Py::Float(color[2]),0); - //} + // for( Py::Dict::iterator it = arg.begin(); it!= arg.end();++it){ + // Py::Long id((*it).first); + // Py::Tuple color((*it).second); + // NodeColorMap[id] = + // App::Color(Py::Float(color[0]),Py::Float(color[1]),Py::Float(color[2]),0); + // } std::vector NodeIds(size); std::vector NodeColors(size); @@ -179,35 +205,40 @@ void ViewProviderFemMeshPy::setNodeColor(Py::Dict arg) Py::Long id((*it).first); Py::Tuple color((*it).second); NodeIds[i] = id; - NodeColors[i] = App::Color(Py::Float(color[0]), Py::Float(color[1]), Py::Float(color[2]), 0); + NodeColors[i] = + App::Color(Py::Float(color[0]), Py::Float(color[1]), Py::Float(color[2]), 0); } - Base::Console().Log(" %f: Start ViewProviderFemMeshPy::setNodeColor() call \n", Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); + Base::Console().Log(" %f: Start ViewProviderFemMeshPy::setNodeColor() call \n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); - //this->getViewProviderFemMeshPtr()->setColorByNodeId(NodeColorMap); + // this->getViewProviderFemMeshPtr()->setColorByNodeId(NodeColorMap); this->getViewProviderFemMeshPtr()->setColorByNodeId(NodeIds, NodeColors); - Base::Console().Log(" %f: Finish ViewProviderFemMeshPy::setNodeColor() call \n", Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); + Base::Console().Log(" %f: Finish ViewProviderFemMeshPy::setNodeColor() call \n", + Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); } } Py::Dict ViewProviderFemMeshPy::getElementColor() const { - //return Py::List(); + // return Py::List(); throw Py::AttributeError("Not yet implemented"); } void ViewProviderFemMeshPy::setElementColor(Py::Dict arg) { - if (arg.size() == 0) + if (arg.size() == 0) { this->getViewProviderFemMeshPtr()->resetColorByNodeId(); + } else { std::map NodeColorMap; for (Py::Dict::iterator it = arg.begin(); it != arg.end(); ++it) { Py::Long id((*it).first); Py::Tuple color((*it).second); - NodeColorMap[id] = App::Color(Py::Float(color[0]), Py::Float(color[1]), Py::Float(color[2]), 0); + NodeColorMap[id] = + App::Color(Py::Float(color[0]), Py::Float(color[1]), Py::Float(color[2]), 0); } this->getViewProviderFemMeshPtr()->setColorByElementId(NodeColorMap); } @@ -216,15 +247,16 @@ void ViewProviderFemMeshPy::setElementColor(Py::Dict arg) Py::Dict ViewProviderFemMeshPy::getNodeDisplacement() const { - //return Py::Dict(); + // return Py::Dict(); throw Py::AttributeError("Not yet implemented"); } -void ViewProviderFemMeshPy::setNodeDisplacement(Py::Dict arg) +void ViewProviderFemMeshPy::setNodeDisplacement(Py::Dict arg) { - if (arg.size() == 0) + if (arg.size() == 0) { this->getViewProviderFemMeshPtr()->resetColorByNodeId(); + } else { std::map NodeDispMap; Py::Type vType(Base::getTypeAsObject(&Base::VectorPy::Type)); @@ -256,15 +288,18 @@ Py::List ViewProviderFemMeshPy::getHighlightedNodes() const void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg) { ViewProviderFemMesh* vp = this->getViewProviderFemMeshPtr(); - const SMESHDS_Mesh* data = static_cast - (vp->getObject())->FemMesh.getValue().getSMesh()->GetMeshDS(); + const SMESHDS_Mesh* data = static_cast(vp->getObject()) + ->FemMesh.getValue() + .getSMesh() + ->GetMeshDS(); std::set res; for (Py::List::iterator it = arg.begin(); it != arg.end(); ++it) { long id = static_cast(Py::Long(*it)); const SMDS_MeshNode* node = data->FindNode(id); - if (node) + if (node) { res.insert(id); + } } this->getViewProviderFemMeshPtr()->setHighlightNodes(res); @@ -273,8 +308,9 @@ void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg) PyObject* ViewProviderFemMeshPy::resetHighlightedNodes(PyObject* args) { - if (!PyArg_ParseTuple(args, "")) + if (!PyArg_ParseTuple(args, "")) { return nullptr; + } this->getViewProviderFemMeshPtr()->resetHighlightNodes(); Py_Return; } @@ -282,19 +318,22 @@ PyObject* ViewProviderFemMeshPy::resetHighlightedNodes(PyObject* args) Py::List ViewProviderFemMeshPy::getVisibleElementFaces() const { - const std::vector& visElmFc = this->getViewProviderFemMeshPtr()->getVisibleElementFaces(); + const std::vector& visElmFc = + this->getViewProviderFemMeshPtr()->getVisibleElementFaces(); std::vector trans; // sorting out double faces through higher order elements and null entries long elementOld = 0, faceOld = 0; for (unsigned long it : visElmFc) { - if (it == 0) + if (it == 0) { continue; + } long element = it >> 3; long face = (it & 7) + 1; - if (element == elementOld && face == faceOld) + if (element == elementOld && face == faceOld) { continue; + } trans.push_back(it); elementOld = element; @@ -303,7 +342,8 @@ Py::List ViewProviderFemMeshPy::getVisibleElementFaces() const Py::List result(trans.size()); int i = 0; - for (std::vector::const_iterator it = trans.begin(); it != trans.end(); ++it, i++) { + for (std::vector::const_iterator it = trans.begin(); it != trans.end(); + ++it, i++) { Py::Tuple tup(2); long element = *it >> 3; long face = (*it & 7) + 1; diff --git a/src/Mod/Fem/Gui/ViewProviderFemMeshShape.h b/src/Mod/Fem/Gui/ViewProviderFemMeshShape.h index 90905295f1..0cfe89e1bf 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMeshShape.h +++ b/src/Mod/Fem/Gui/ViewProviderFemMeshShape.h @@ -29,7 +29,7 @@ namespace FemGui { -class FemGuiExport ViewProviderFemMeshShape : public ViewProviderFemMesh +class FemGuiExport ViewProviderFemMeshShape: public ViewProviderFemMesh { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemMeshShape); @@ -41,7 +41,7 @@ public: ~ViewProviderFemMeshShape() override; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_ViewProviderFemMeshShape_H +#endif // FEM_ViewProviderFemMeshShape_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemMeshShapeNetgen.cpp b/src/Mod/Fem/Gui/ViewProviderFemMeshShapeNetgen.cpp index d9d0bee6b8..d687985b00 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMeshShapeNetgen.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMeshShapeNetgen.cpp @@ -23,18 +23,18 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include #endif #include #include #include -#include "ViewProviderFemMeshShapeNetgen.h" #include "TaskDlgMeshShapeNetgen.h" +#include "ViewProviderFemMeshShapeNetgen.h" using namespace FemGui; @@ -51,9 +51,11 @@ ViewProviderFemMeshShapeNetgen::ViewProviderFemMeshShapeNetgen() ViewProviderFemMeshShapeNetgen::~ViewProviderFemMeshShapeNetgen() = default; -void ViewProviderFemMeshShapeNetgen::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) +void ViewProviderFemMeshShapeNetgen::setupContextMenu(QMenu* menu, + QObject* receiver, + const char* member) { - QAction *act = menu->addAction(QObject::tr("Meshing"), receiver, member); + QAction* act = menu->addAction(QObject::tr("Meshing"), receiver, member); act->setData(QVariant((int)ViewProvider::Default)); } @@ -66,10 +68,13 @@ bool ViewProviderFemMeshShapeNetgen::setEdit(int ModNum) Gui::Control().showDialog(new TaskDlgMeshShapeNetgen(this)); return true; #else - QMessageBox::critical(Gui::getMainWindow(), - QCoreApplication::translate("FemGui::ViewProviderFemMeshShapeNetgen", "Meshing failure"), - QCoreApplication::translate("FemGui::ViewProviderFemMeshShapeNetgen", "The FEM module is built without NETGEN support. Meshing will not work!!!") - ); + QMessageBox::critical( + Gui::getMainWindow(), + QCoreApplication::translate("FemGui::ViewProviderFemMeshShapeNetgen", + "Meshing failure"), + QCoreApplication::translate( + "FemGui::ViewProviderFemMeshShapeNetgen", + "The FEM module is built without NETGEN support. Meshing will not work!!!")); return false; #endif } diff --git a/src/Mod/Fem/Gui/ViewProviderFemMeshShapeNetgen.h b/src/Mod/Fem/Gui/ViewProviderFemMeshShapeNetgen.h index 8bdf0a90ed..b41ce2dc67 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemMeshShapeNetgen.h +++ b/src/Mod/Fem/Gui/ViewProviderFemMeshShapeNetgen.h @@ -28,7 +28,7 @@ namespace FemGui { -class FemGuiExport ViewProviderFemMeshShapeNetgen : public ViewProviderFemMeshShape +class FemGuiExport ViewProviderFemMeshShapeNetgen: public ViewProviderFemMeshShape { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemMeshShapeNetgen); @@ -39,14 +39,14 @@ public: /// destructor. ~ViewProviderFemMeshShapeNetgen() override; - void updateData(const App::Property*) override; + void updateData(const App::Property*) override; protected: void setupContextMenu(QMenu* menu, QObject* receiver, const char* member) override; bool setEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_ViewProviderFemMeshShapeNetgen_H +#endif // FEM_ViewProviderFemMeshShapeNetgen_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFilter.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostFilter.cpp index 33260c409e..a12b317363 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFilter.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFilter.cpp @@ -24,8 +24,8 @@ #include -#include "ViewProviderFemPostFilter.h" #include "TaskPostBoxes.h" +#include "ViewProviderFemPostFilter.h" using namespace FemGui; @@ -48,7 +48,7 @@ ViewProviderFemPostDataAlongLine::~ViewProviderFemPostDataAlongLine() = default; void ViewProviderFemPostDataAlongLine::setupTaskDialog(TaskDlgPost* dlg) { - //add the function box + // add the function box dlg->appendBox(new TaskPostDataAlongLine(dlg->getView())); } @@ -78,7 +78,7 @@ ViewProviderFemPostDataAtPoint::~ViewProviderFemPostDataAtPoint() = default; void ViewProviderFemPostDataAtPoint::setupTaskDialog(TaskDlgPost* dlg) { - //add the function box + // add the function box dlg->appendBox(new TaskPostDataAtPoint(dlg->getView())); } @@ -87,20 +87,23 @@ void ViewProviderFemPostDataAtPoint::setupTaskDialog(TaskDlgPost* dlg) // clip filter PROPERTY_SOURCE(FemGui::ViewProviderFemPostClip, FemGui::ViewProviderFemPostObject) -ViewProviderFemPostClip::ViewProviderFemPostClip() { +ViewProviderFemPostClip::ViewProviderFemPostClip() +{ sPixmap = "FEM_PostFilterClipRegion"; } ViewProviderFemPostClip::~ViewProviderFemPostClip() = default; -void ViewProviderFemPostClip::setupTaskDialog(TaskDlgPost* dlg) { +void ViewProviderFemPostClip::setupTaskDialog(TaskDlgPost* dlg) +{ - //add the function box - dlg->appendBox(new TaskPostClip(dlg->getView(), + // add the function box + dlg->appendBox(new TaskPostClip( + dlg->getView(), &static_cast(dlg->getView()->getObject())->Function)); - //add the display options + // add the display options FemGui::ViewProviderFemPostObject::setupTaskDialog(dlg); } @@ -136,12 +139,12 @@ ViewProviderFemPostCut::~ViewProviderFemPostCut() = default; void ViewProviderFemPostCut::setupTaskDialog(TaskDlgPost* dlg) { - //add the function box + // add the function box dlg->appendBox(new TaskPostCut( dlg->getView(), &static_cast(dlg->getView()->getObject())->Function)); - //add the display options + // add the display options FemGui::ViewProviderFemPostObject::setupTaskDialog(dlg); } @@ -159,10 +162,10 @@ ViewProviderFemPostScalarClip::~ViewProviderFemPostScalarClip() = default; void ViewProviderFemPostScalarClip::setupTaskDialog(TaskDlgPost* dlg) { - //add the function box + // add the function box dlg->appendBox(new TaskPostScalarClip(dlg->getView())); - //add the display options + // add the display options FemGui::ViewProviderFemPostObject::setupTaskDialog(dlg); } @@ -180,9 +183,9 @@ ViewProviderFemPostWarpVector::~ViewProviderFemPostWarpVector() = default; void ViewProviderFemPostWarpVector::setupTaskDialog(TaskDlgPost* dlg) { - //add the function box + // add the function box dlg->appendBox(new TaskPostWarpVector(dlg->getView())); - //add the display options + // add the display options FemGui::ViewProviderFemPostObject::setupTaskDialog(dlg); } diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFilter.h b/src/Mod/Fem/Gui/ViewProviderFemPostFilter.h index 33f326a965..5a2b00fe8f 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFilter.h +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFilter.h @@ -36,7 +36,7 @@ namespace FemGui // *************************************************************************** // data along line filter -class FemGuiExport ViewProviderFemPostDataAlongLine : public ViewProviderFemPostObject +class FemGuiExport ViewProviderFemPostDataAlongLine: public ViewProviderFemPostObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostDataAlongLine); @@ -60,7 +60,7 @@ public: /// constructor. ViewProviderFemPostDataAtPoint(); void show() override; - void onSelectionChanged(const Gui::SelectionChanges &) override; + void onSelectionChanged(const Gui::SelectionChanges&) override; ~ViewProviderFemPostDataAtPoint() override; protected: @@ -134,7 +134,7 @@ protected: // *************************************************************************** // warp vector filter -class FemGuiExport ViewProviderFemPostWarpVector : public ViewProviderFemPostObject +class FemGuiExport ViewProviderFemPostWarpVector: public ViewProviderFemPostObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostWarpVector); @@ -147,7 +147,7 @@ protected: void setupTaskDialog(TaskDlgPost* dlg) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_VIEWPROVIDERFEMPOSTFILTER_H +#endif // FEM_VIEWPROVIDERFEMPOSTFILTER_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp index bd195196f9..dd69252905 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp @@ -23,24 +23,24 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -# include -# include -# include +#include +#include +#include #endif #include @@ -49,14 +49,14 @@ #include #include #include +#include #include #include -#include -#include "ViewProviderFemPostFunction.h" #include "FemSettings.h" #include "TaskPostBoxes.h" #include "ViewProviderAnalysis.h" +#include "ViewProviderFemPostFunction.h" #include "ui_BoxWidget.h" #include "ui_CylinderWidget.h" @@ -69,18 +69,20 @@ namespace sp = std::placeholders; void FunctionWidget::setViewProvider(ViewProviderFemPostFunction* view) { - //NOLINTBEGIN + // NOLINTBEGIN m_view = view; m_object = static_cast(view->getObject()); m_connection = m_object->getDocument()->signalChangedObject.connect( std::bind(&FunctionWidget::onObjectsChanged, this, sp::_1, sp::_2)); - //NOLINTEND + // NOLINTEND } -void FunctionWidget::onObjectsChanged(const App::DocumentObject& obj, const App::Property& p) { +void FunctionWidget::onObjectsChanged(const App::DocumentObject& obj, const App::Property& p) +{ - if (&obj == m_object) + if (&obj == m_object) { onChange(p); + } } @@ -90,12 +92,12 @@ ViewProviderFemPostFunctionProvider::ViewProviderFemPostFunctionProvider() = def ViewProviderFemPostFunctionProvider::~ViewProviderFemPostFunctionProvider() = default; -std::vector< App::DocumentObject* > ViewProviderFemPostFunctionProvider::claimChildren() const +std::vector ViewProviderFemPostFunctionProvider::claimChildren() const { return static_cast(getObject())->Functions.getValues(); } -std::vector< App::DocumentObject* > ViewProviderFemPostFunctionProvider::claimChildren3D() const +std::vector ViewProviderFemPostFunctionProvider::claimChildren3D() const { return claimChildren(); } @@ -120,8 +122,9 @@ void ViewProviderFemPostFunctionProvider::updateSize() { std::vector vec = claimChildren(); for (auto it : vec) { - if (!it->isDerivedFrom(Fem::FemPostFunction::getClassTypeId())) + if (!it->isDerivedFrom(Fem::FemPostFunction::getClassTypeId())) { continue; + } ViewProviderFemPostFunction* vp = static_cast( Gui::Application::Instance->getViewProvider(it)); @@ -135,8 +138,9 @@ bool ViewProviderFemPostFunctionProvider::onDelete(const std::vectorgetDocument(), "functions list"); + return ViewProviderFemAnalysis::checkSelectedChildren(objs, + this->getDocument(), + "functions list"); } bool ViewProviderFemPostFunctionProvider::canDelete(App::DocumentObject* obj) const @@ -145,7 +149,7 @@ bool ViewProviderFemPostFunctionProvider::canDelete(App::DocumentObject* obj) co // thus we can pass this action // we can warn the user if necessary in the object's ViewProvider in the onDelete() function Q_UNUSED(obj) - return true; + return true; } @@ -154,14 +158,26 @@ bool ViewProviderFemPostFunctionProvider::canDelete(App::DocumentObject* obj) co PROPERTY_SOURCE(FemGui::ViewProviderFemPostFunction, Gui::ViewProviderDocumentObject) ViewProviderFemPostFunction::ViewProviderFemPostFunction() - : m_manip(nullptr), m_autoscale(false), m_isDragging(false), m_autoRecompute(false) + : m_manip(nullptr) + , m_autoscale(false) + , m_isDragging(false) + , m_autoRecompute(false) { - ADD_PROPERTY_TYPE( - AutoScaleFactorX, (1), "AutoScale", App::Prop_Hidden, "Automatic scaling factor"); - ADD_PROPERTY_TYPE( - AutoScaleFactorY, (1), "AutoScale", App::Prop_Hidden, "Automatic scaling factor"); - ADD_PROPERTY_TYPE( - AutoScaleFactorZ, (1), "AutoScale", App::Prop_Hidden, "Automatic scaling factor"); + ADD_PROPERTY_TYPE(AutoScaleFactorX, + (1), + "AutoScale", + App::Prop_Hidden, + "Automatic scaling factor"); + ADD_PROPERTY_TYPE(AutoScaleFactorY, + (1), + "AutoScale", + App::Prop_Hidden, + "Automatic scaling factor"); + ADD_PROPERTY_TYPE(AutoScaleFactorZ, + (1), + "AutoScale", + App::Prop_Hidden, + "Automatic scaling factor"); m_geometrySeperator = new SoSeparator(); m_geometrySeperator->ref(); @@ -253,12 +269,14 @@ bool ViewProviderFemPostFunction::findScaleFactor(double& scale) const return false; } -bool ViewProviderFemPostFunction::doubleClicked() { +bool ViewProviderFemPostFunction::doubleClicked() +{ Gui::Application::Instance->activeDocument()->setEdit(this, (int)ViewProvider::Default); return true; } -SoTransformManip* ViewProviderFemPostFunction::setupManipulator() { +SoTransformManip* ViewProviderFemPostFunction::setupManipulator() +{ return new SoCenterballManip; } @@ -287,8 +305,9 @@ void ViewProviderFemPostFunction::dragFinishCallback(void* data, SoDragger*) Gui::Application::Instance->activeDocument()->commitCommand(); ViewProviderFemPostFunction* that = static_cast(data); - if (that->m_autoRecompute) + if (that->m_autoRecompute) { that->getObject()->getDocument()->recompute(); + } static_cast(data)->m_isDragging = false; } @@ -298,8 +317,9 @@ void ViewProviderFemPostFunction::dragMotionCallback(void* data, SoDragger* drag ViewProviderFemPostFunction* that = static_cast(data); that->draggerUpdate(drag); - if (that->m_autoRecompute) + if (that->m_autoRecompute) { that->getObject()->getDocument()->recompute(); + } } @@ -309,8 +329,9 @@ bool ViewProviderFemPostFunction::setEdit(int ModNum) Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); TaskDlgPost* postDlg = qobject_cast(dlg); - if (postDlg && postDlg->getView() != this) - postDlg = nullptr; // another pad left open its task panel + if (postDlg && postDlg->getView() != this) { + postDlg = nullptr; // another pad left open its task panel + } if (dlg && !postDlg) { QMessageBox msgBox; msgBox.setText(QObject::tr("A dialog is already open in the task panel")); @@ -318,15 +339,18 @@ bool ViewProviderFemPostFunction::setEdit(int ModNum) msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) + if (ret == QMessageBox::Yes) { Gui::Control().reject(); - else + } + else { return false; + } } // start the edit dialog - if (postDlg) + if (postDlg) { Gui::Control().showDialog(postDlg); + } else { postDlg = new TaskDlgPost(this); postDlg->appendBox(new TaskPostFunction(this)); @@ -355,9 +379,11 @@ void ViewProviderFemPostFunction::onChanged(const App::Property* prop) { Gui::ViewProviderDocumentObject::onChanged(prop); - if (m_autoscale) - m_scale->scaleFactor = SbVec3f( - AutoScaleFactorX.getValue(), AutoScaleFactorY.getValue(), AutoScaleFactorZ.getValue()); + if (m_autoscale) { + m_scale->scaleFactor = SbVec3f(AutoScaleFactorX.getValue(), + AutoScaleFactorY.getValue(), + AutoScaleFactorZ.getValue()); + } } @@ -394,8 +420,8 @@ void ViewProviderFemPostBoxFunction::draggerUpdate(SoDragger* m) void ViewProviderFemPostBoxFunction::updateData(const App::Property* p) { Fem::FemPostBoxFunction* func = static_cast(getObject()); - if (!isDragging() && - (p == &func->Center || p == &func->Length || p == &func->Width || p == &func->Height)) { + if (!isDragging() + && (p == &func->Center || p == &func->Length || p == &func->Width || p == &func->Height)) { const Base::Vector3d& center = func->Center.getValue(); float l = func->Length.getValue(); float w = func->Width.getValue(); @@ -441,25 +467,36 @@ BoxWidget::BoxWidget() ui->width->setDecimals(UserDecimals); ui->height->setDecimals(UserDecimals); - connect(ui->centerX, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &BoxWidget::centerChanged); - connect(ui->centerY, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &BoxWidget::centerChanged); - connect(ui->centerZ, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &BoxWidget::centerChanged); - connect(ui->length, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &BoxWidget::lengthChanged); - connect(ui->width, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &BoxWidget::widthChanged); - connect(ui->height, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &BoxWidget::heightChanged); + connect(ui->centerX, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &BoxWidget::centerChanged); + connect(ui->centerY, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &BoxWidget::centerChanged); + connect(ui->centerZ, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &BoxWidget::centerChanged); + connect(ui->length, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &BoxWidget::lengthChanged); + connect(ui->width, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &BoxWidget::widthChanged); + connect(ui->height, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &BoxWidget::heightChanged); } BoxWidget::~BoxWidget() = default; void BoxWidget::applyPythonCode() -{ -} +{} void BoxWidget::setViewProvider(ViewProviderFemPostFunction* view) { @@ -511,8 +548,9 @@ void BoxWidget::onChange(const App::Property& p) void BoxWidget::centerChanged(double) { if (!blockObjectUpdates()) { - Base::Vector3d vec(ui->centerX->value().getValue(), ui->centerY->value().getValue(), - ui->centerZ->value().getValue()); + Base::Vector3d vec(ui->centerX->value().getValue(), + ui->centerY->value().getValue(), + ui->centerZ->value().getValue()); static_cast(getObject())->Center.setValue(vec); } } @@ -580,8 +618,9 @@ void ViewProviderFemPostCylinderFunction::updateData(const App::Property* p) SbMatrix translate; SbRotation rot(SbVec3f(0.0, 0.0, 1.0), SbVec3f(axis.x, axis.y, axis.z)); - translate.setTransform( - SbVec3f(trans.x, trans.y, trans.z), rot, SbVec3f(radius, radius, radius)); + translate.setTransform(SbVec3f(trans.x, trans.y, trans.z), + rot, + SbVec3f(radius, radius, radius)); getManipulator()->setMatrix(translate); } @@ -620,27 +659,40 @@ CylinderWidget::CylinderWidget() ui->axisY->setDecimals(UserDecimals); ui->axisZ->setDecimals(UserDecimals); - connect(ui->centerX, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &CylinderWidget::centerChanged); - connect(ui->centerY, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &CylinderWidget::centerChanged); - connect(ui->centerZ, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &CylinderWidget::centerChanged); - connect(ui->axisX, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &CylinderWidget::axisChanged); - connect(ui->axisY, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &CylinderWidget::axisChanged); - connect(ui->axisZ, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &CylinderWidget::axisChanged); - connect(ui->radius, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &CylinderWidget::radiusChanged); + connect(ui->centerX, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &CylinderWidget::centerChanged); + connect(ui->centerY, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &CylinderWidget::centerChanged); + connect(ui->centerZ, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &CylinderWidget::centerChanged); + connect(ui->axisX, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &CylinderWidget::axisChanged); + connect(ui->axisY, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &CylinderWidget::axisChanged); + connect(ui->axisZ, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &CylinderWidget::axisChanged); + connect(ui->radius, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &CylinderWidget::radiusChanged); } CylinderWidget::~CylinderWidget() = default; void CylinderWidget::applyPythonCode() -{ -} +{} void CylinderWidget::setViewProvider(ViewProviderFemPostFunction* view) { @@ -685,8 +737,9 @@ void CylinderWidget::onChange(const App::Property& p) void CylinderWidget::centerChanged(double) { if (!blockObjectUpdates()) { - Base::Vector3d vec(ui->centerX->value().getValue(), ui->centerY->value().getValue(), - ui->centerZ->value().getValue()); + Base::Vector3d vec(ui->centerX->value().getValue(), + ui->centerY->value().getValue(), + ui->centerZ->value().getValue()); static_cast(getObject())->Center.setValue(vec); } } @@ -694,8 +747,9 @@ void CylinderWidget::centerChanged(double) void CylinderWidget::axisChanged(double) { if (!blockObjectUpdates()) { - Base::Vector3d vec(ui->axisX->value().getValue(), ui->axisY->value().getValue(), - ui->axisZ->value().getValue()); + Base::Vector3d vec(ui->axisX->value().getValue(), + ui->axisY->value().getValue(), + ui->axisZ->value().getValue()); static_cast(getObject())->Axis.setValue(vec); } } @@ -712,14 +766,17 @@ void CylinderWidget::radiusChanged(double) // *************************************************************************** PROPERTY_SOURCE(FemGui::ViewProviderFemPostPlaneFunction, FemGui::ViewProviderFemPostFunction) -//NOTE: The technical lower limit is at 1e-4 that the Coin3D manipulator can handle +// NOTE: The technical lower limit is at 1e-4 that the Coin3D manipulator can handle static const App::PropertyFloatConstraint::Constraints scaleConstraint = {1e-4, DBL_MAX, 1.0}; ViewProviderFemPostPlaneFunction::ViewProviderFemPostPlaneFunction() : m_detectscale(false) { - ADD_PROPERTY_TYPE( - Scale, (1000.0), "Manipulator", App::Prop_None, "Scaling factor for the manipulator"); + ADD_PROPERTY_TYPE(Scale, + (1000.0), + "Manipulator", + App::Prop_None, + "Scaling factor for the manipulator"); Scale.setConstraints(&scaleConstraint); sPixmap = "fem-post-geo-plane"; @@ -751,14 +808,16 @@ void ViewProviderFemPostPlaneFunction::onChanged(const App::Property* prop) { if (prop == &Scale) { // When loading the Scale property from a project then keep that - if (Scale.getConstraints()) + if (Scale.getConstraints()) { m_detectscale = true; + } if (!isDragging()) { // get current matrix SbVec3f t, s; SbRotation r, so; - SbMatrix matrix = - getManipulator()->getDragger()->getMotionMatrix();// clazy:exclude=rule-of-two-soft + SbMatrix matrix = getManipulator() + ->getDragger() + ->getMotionMatrix(); // clazy:exclude=rule-of-two-soft matrix.getTransform(t, r, s, so); float scale = static_cast(Scale.getValue()); @@ -832,25 +891,36 @@ PlaneWidget::PlaneWidget() ui->normalY->setDecimals(UserDecimals); ui->normalZ->setDecimals(UserDecimals); - connect(ui->originX, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &PlaneWidget::originChanged); - connect(ui->originY, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &PlaneWidget::originChanged); - connect(ui->originZ, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &PlaneWidget::originChanged); - connect(ui->normalX, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &PlaneWidget::normalChanged); - connect(ui->normalY, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &PlaneWidget::normalChanged); - connect(ui->normalZ, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &PlaneWidget::normalChanged); + connect(ui->originX, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &PlaneWidget::originChanged); + connect(ui->originY, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &PlaneWidget::originChanged); + connect(ui->originZ, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &PlaneWidget::originChanged); + connect(ui->normalX, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &PlaneWidget::normalChanged); + connect(ui->normalY, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &PlaneWidget::normalChanged); + connect(ui->normalZ, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &PlaneWidget::normalChanged); } PlaneWidget::~PlaneWidget() = default; void PlaneWidget::applyPythonCode() -{ -} +{} void PlaneWidget::setViewProvider(ViewProviderFemPostFunction* view) { @@ -890,8 +960,9 @@ void PlaneWidget::onChange(const App::Property& p) void PlaneWidget::normalChanged(double) { if (!blockObjectUpdates()) { - Base::Vector3d vec(ui->normalX->value().getValue(), ui->normalY->value().getValue(), - ui->normalZ->value().getValue()); + Base::Vector3d vec(ui->normalX->value().getValue(), + ui->normalY->value().getValue(), + ui->normalZ->value().getValue()); static_cast(getObject())->Normal.setValue(vec); } } @@ -899,8 +970,9 @@ void PlaneWidget::normalChanged(double) void PlaneWidget::originChanged(double) { if (!blockObjectUpdates()) { - Base::Vector3d vec(ui->originX->value().getValue(), ui->originY->value().getValue(), - ui->originZ->value().getValue()); + Base::Vector3d vec(ui->originX->value().getValue(), + ui->originY->value().getValue(), + ui->originZ->value().getValue()); static_cast(getObject())->Origin.setValue(vec); } } @@ -916,7 +988,7 @@ ViewProviderFemPostSphereFunction::ViewProviderFemPostSphereFunction() setAutoScale(false); - //setup the visualisation geometry + // setup the visualisation geometry getGeometryNode()->addChild(ShapeNodes::postSphere()); } @@ -994,21 +1066,28 @@ SphereWidget::SphereWidget() ui->centerY->setDecimals(UserDecimals); ui->centerZ->setDecimals(UserDecimals); - connect(ui->centerX, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &SphereWidget::centerChanged); - connect(ui->centerY, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &SphereWidget::centerChanged); - connect(ui->centerZ, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &SphereWidget::centerChanged); - connect(ui->radius, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &SphereWidget::radiusChanged); + connect(ui->centerX, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &SphereWidget::centerChanged); + connect(ui->centerY, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &SphereWidget::centerChanged); + connect(ui->centerZ, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &SphereWidget::centerChanged); + connect(ui->radius, + qOverload(&Gui::QuantitySpinBox::valueChanged), + this, + &SphereWidget::radiusChanged); } SphereWidget::~SphereWidget() = default; void SphereWidget::applyPythonCode() -{ -} +{} void SphereWidget::setViewProvider(ViewProviderFemPostFunction* view) { @@ -1046,8 +1125,9 @@ void SphereWidget::onChange(const App::Property& p) void SphereWidget::centerChanged(double) { if (!blockObjectUpdates()) { - Base::Vector3d vec(ui->centerX->value().getValue(), ui->centerY->value().getValue(), - ui->centerZ->value().getValue()); + Base::Vector3d vec(ui->centerX->value().getValue(), + ui->centerY->value().getValue(), + ui->centerZ->value().getValue()); static_cast(getObject())->Center.setValue(vec); } } @@ -1142,7 +1222,7 @@ SoGroup* postCylinder() vert[0] = nCirc + 1; vert[1] = nCirc + 1; for (int i = 0; i < nSide; ++i) { - vert[i+2] = 2; + vert[i + 2] = 2; } SoLineSet* line = new SoLineSet(); @@ -1206,8 +1286,8 @@ SoGroup* postSphere() return group; } -} //namespace ShapeNodes +} // namespace ShapeNodes -} //namespace FemGui +} // namespace FemGui #include "moc_ViewProviderFemPostFunction.cpp" diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.h b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.h index c523c5cfa1..7b69218d84 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.h +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.h @@ -23,9 +23,9 @@ #ifndef FEM_VIEWPROVIDERFEMPOSTFUNCTION_H #define FEM_VIEWPROVIDERFEMPOSTFUNCTION_H +#include #include #include -#include #include #include @@ -49,7 +49,7 @@ namespace FemGui class ViewProviderFemPostFunction; -class FemGuiExport FunctionWidget : public QWidget +class FemGuiExport FunctionWidget: public QWidget { Q_OBJECT public: @@ -61,22 +61,34 @@ public: void onObjectsChanged(const App::DocumentObject& obj, const App::Property&); protected: - ViewProviderFemPostFunction* getView() {return m_view;} - Fem::FemPostFunction* getObject(){return m_object;} + ViewProviderFemPostFunction* getView() + { + return m_view; + } + Fem::FemPostFunction* getObject() + { + return m_object; + } - bool blockObjectUpdates() {return m_block;} - void setBlockObjectUpdates(bool val) {m_block = val;} + bool blockObjectUpdates() + { + return m_block; + } + void setBlockObjectUpdates(bool val) + { + m_block = val; + } virtual void onChange(const App::Property& p) = 0; private: - bool m_block{false}; - ViewProviderFemPostFunction* m_view{nullptr}; - Fem::FemPostFunction* m_object{nullptr}; - boost::signals2::scoped_connection m_connection; + bool m_block {false}; + ViewProviderFemPostFunction* m_view {nullptr}; + Fem::FemPostFunction* m_object {nullptr}; + boost::signals2::scoped_connection m_connection; }; -class FemGuiExport ViewProviderFemPostFunctionProvider : public Gui::ViewProviderDocumentObject +class FemGuiExport ViewProviderFemPostFunctionProvider: public Gui::ViewProviderDocumentObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostFunction); @@ -94,15 +106,15 @@ public: bool canDelete(App::DocumentObject* obj) const override; protected: - std::vector< App::DocumentObject* > claimChildren() const override; - std::vector< App::DocumentObject* > claimChildren3D() const override; + std::vector claimChildren() const override; + std::vector claimChildren3D() const override; void onChanged(const App::Property* prop) override; void updateData(const App::Property*) override; void updateSize(); }; -class FemGuiExport ViewProviderFemPostFunction : public Gui::ViewProviderDocumentObject +class FemGuiExport ViewProviderFemPostFunction: public Gui::ViewProviderDocumentObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostFunction); @@ -115,45 +127,67 @@ public: App::PropertyFloat AutoScaleFactorY; App::PropertyFloat AutoScaleFactorZ; - void attach(App::DocumentObject *pcObject) override; + void attach(App::DocumentObject* pcObject) override; bool doubleClicked() override; std::vector getDisplayModes() const override; - //creates the widget used in the task dalogs, either for the function itself or for - //the filter using it - virtual FunctionWidget* createControlWidget() {return nullptr;} + // creates the widget used in the task dalogs, either for the function itself or for + // the filter using it + virtual FunctionWidget* createControlWidget() + { + return nullptr; + } protected: bool setEdit(int ModNum) override; void unsetEdit(int ModNum) override; void onChanged(const App::Property* prop) override; - void setAutoScale(bool value) {m_autoscale = value;} - bool autoScale() {return m_autoscale;} + void setAutoScale(bool value) + { + m_autoscale = value; + } + bool autoScale() + { + return m_autoscale; + } - bool isDragging() {return m_isDragging;} + bool isDragging() + { + return m_isDragging; + } SbBox3f getBoundingsOfView() const; bool findScaleFactor(double& scale) const; - virtual SoTransformManip* setupManipulator(); - virtual void draggerUpdate(SoDragger*) {} - SoTransformManip* getManipulator() {return m_manip;} - SoSeparator* getGeometryNode() {return m_geometrySeperator;} - SoScale* getScaleNode() {return m_scale;} + virtual SoTransformManip* setupManipulator(); + virtual void draggerUpdate(SoDragger*) + {} + SoTransformManip* getManipulator() + { + return m_manip; + } + SoSeparator* getGeometryNode() + { + return m_geometrySeperator; + } + SoScale* getScaleNode() + { + return m_scale; + } private: - static void dragStartCallback(void * data, SoDragger * d); - static void dragFinishCallback(void * data, SoDragger * d); - static void dragMotionCallback(void * data, SoDragger * d); + static void dragStartCallback(void* data, SoDragger* d); + static void dragFinishCallback(void* data, SoDragger* d); + static void dragMotionCallback(void* data, SoDragger* d); - SoSeparator* m_geometrySeperator; - SoTransformManip* m_manip; - SoScale* m_scale; - bool m_autoscale, m_isDragging, m_autoRecompute; + SoSeparator* m_geometrySeperator; + SoTransformManip* m_manip; + SoScale* m_scale; + bool m_autoscale, m_isDragging, m_autoRecompute; }; // *************************************************************************** -class FemGuiExport BoxWidget : public FunctionWidget +class FemGuiExport BoxWidget: public FunctionWidget { Q_OBJECT public: @@ -174,7 +208,7 @@ private: std::unique_ptr ui; }; -class FemGuiExport ViewProviderFemPostBoxFunction : public ViewProviderFemPostFunction +class FemGuiExport ViewProviderFemPostBoxFunction: public ViewProviderFemPostFunction { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostBoxFunction); @@ -192,7 +226,7 @@ protected: // *************************************************************************** -class FemGuiExport CylinderWidget : public FunctionWidget +class FemGuiExport CylinderWidget: public FunctionWidget { Q_OBJECT public: @@ -212,7 +246,7 @@ private: std::unique_ptr ui; }; -class FemGuiExport ViewProviderFemPostCylinderFunction : public ViewProviderFemPostFunction +class FemGuiExport ViewProviderFemPostCylinderFunction: public ViewProviderFemPostFunction { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostCylinderFunction); @@ -230,7 +264,7 @@ protected: // *************************************************************************** -class FemGuiExport PlaneWidget : public FunctionWidget +class FemGuiExport PlaneWidget: public FunctionWidget { Q_OBJECT public: @@ -249,7 +283,7 @@ private: std::unique_ptr ui; }; -class FemGuiExport ViewProviderFemPostPlaneFunction : public ViewProviderFemPostFunction +class FemGuiExport ViewProviderFemPostPlaneFunction: public ViewProviderFemPostFunction { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostPlaneFunction); @@ -273,7 +307,7 @@ private: // *************************************************************************** -class FemGuiExport SphereWidget : public FunctionWidget +class FemGuiExport SphereWidget: public FunctionWidget { Q_OBJECT public: @@ -292,7 +326,7 @@ private: std::unique_ptr ui; }; -class FemGuiExport ViewProviderFemPostSphereFunction : public ViewProviderFemPostFunction +class FemGuiExport ViewProviderFemPostSphereFunction: public ViewProviderFemPostFunction { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostSphereFunction); @@ -310,14 +344,14 @@ protected: namespace ShapeNodes { - SoGroup* postBox(); - SoGroup* postCylinder(); - SoGroup* postPlane(); - SoGroup* postSphere(); +SoGroup* postBox(); +SoGroup* postCylinder(); +SoGroup* postPlane(); +SoGroup* postSphere(); -} //namespace ShapeNodes +} // namespace ShapeNodes -} //namespace FemGui +} // namespace FemGui -#endif // FEM_VIEWPROVIDERFEMPOSTFUNCTION_H +#endif // FEM_VIEWPROVIDERFEMPOSTFUNCTION_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp index a5e324d3e7..4b7d5d4dd5 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp @@ -23,27 +23,27 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include -# include -# include -# include +#include +#include +#include #endif #include @@ -60,9 +60,9 @@ #include #include -#include "ViewProviderFemPostObject.h" #include "TaskPostBoxes.h" #include "ViewProviderAnalysis.h" +#include "ViewProviderFemPostObject.h" using namespace FemGui; @@ -76,7 +76,8 @@ using vtkIdTypePtr = vtkIdType*; // ---------------------------------------------------------------------------- -namespace { +namespace +{ /* * The class FemPostObjectSelectionObserver notifies a ViewProviderFemPostObject * only if its selection status has changed @@ -84,17 +85,21 @@ namespace { class FemPostObjectSelectionObserver { public: - static FemPostObjectSelectionObserver& instance() { + static FemPostObjectSelectionObserver& instance() + { static FemPostObjectSelectionObserver inst; return inst; } - void registerFemPostObject(ViewProviderFemPostObject* vp) { + void registerFemPostObject(ViewProviderFemPostObject* vp) + { views.insert(vp); } - void unregisterFemPostObject(ViewProviderFemPostObject* vp) { + void unregisterFemPostObject(ViewProviderFemPostObject* vp) + { auto it = views.find(vp); - if (it != views.end()) + if (it != views.end()) { views.erase(it); + } } void selectionChanged(const Gui::SelectionChanges& msg) @@ -110,18 +115,19 @@ public: } private: - FemPostObjectSelectionObserver() { - //NOLINTBEGIN + FemPostObjectSelectionObserver() + { + // NOLINTBEGIN this->connectSelection = Gui::Selection().signalSelectionChanged.connect( std::bind(&FemPostObjectSelectionObserver::selectionChanged, this, sp::_1)); - //NOLINTEND + // NOLINTEND } ~FemPostObjectSelectionObserver() = default; public: FemPostObjectSelectionObserver(const FemPostObjectSelectionObserver&) = delete; - FemPostObjectSelectionObserver& operator= (const FemPostObjectSelectionObserver&) = delete; + FemPostObjectSelectionObserver& operator=(const FemPostObjectSelectionObserver&) = delete; private: std::set views; @@ -129,7 +135,7 @@ private: Connection connectSelection; }; -} +} // namespace // ---------------------------------------------------------------------------- @@ -137,7 +143,7 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemPostObject, Gui::ViewProviderDocumentObje ViewProviderFemPostObject::ViewProviderFemPostObject() { - //initialize the properties + // initialize the properties ADD_PROPERTY_TYPE(Field, ((long)0), "Coloring", @@ -152,7 +158,7 @@ ViewProviderFemPostObject::ViewProviderFemPostObject() sPixmap = "fem-femmesh-from-shape"; - //create the subnodes which do the visualization work + // create the subnodes which do the visualization work m_shapeHints = new SoShapeHints(); m_shapeHints->ref(); m_shapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE; @@ -192,7 +198,7 @@ ViewProviderFemPostObject::ViewProviderFemPostObject() m_colorBar->Attach(this); m_colorBar->ref(); - //create the vtk algorithms we use for visualisation + // create the vtk algorithms we use for visualisation m_outline = vtkSmartPointer::New(); m_points = vtkSmartPointer::New(); m_pointsSurface = vtkSmartPointer::New(); @@ -266,7 +272,7 @@ void ViewProviderFemPostObject::attach(App::DocumentObject* pcObj) m_colorRoot->addChild(m_colorBar); - //all + // all addDisplayMaskMode(m_separator, "Default"); setDisplayMaskMode("Default"); @@ -280,20 +286,27 @@ SoSeparator* ViewProviderFemPostObject::getFrontRoot() const void ViewProviderFemPostObject::setDisplayMode(const char* ModeName) { - if (strcmp("Outline", ModeName) == 0) + if (strcmp("Outline", ModeName) == 0) { m_currentAlgorithm = m_outline; - else if (strcmp("Surface with Edges", ModeName) == 0) + } + else if (strcmp("Surface with Edges", ModeName) == 0) { m_currentAlgorithm = m_surfaceEdges; - else if (strcmp("Surface", ModeName) == 0) + } + else if (strcmp("Surface", ModeName) == 0) { m_currentAlgorithm = m_surface; - else if (strcmp("Wireframe", ModeName) == 0) + } + else if (strcmp("Wireframe", ModeName) == 0) { m_currentAlgorithm = m_wireframe; - else if (strcmp("Wireframe (surface only)", ModeName) == 0) + } + else if (strcmp("Wireframe (surface only)", ModeName) == 0) { m_currentAlgorithm = m_wireframeSurface; - else if (strcmp("Nodes", ModeName) == 0) + } + else if (strcmp("Nodes", ModeName) == 0) { m_currentAlgorithm = m_points; - else if (strcmp("Nodes (surface only)", ModeName) == 0) + } + else if (strcmp("Nodes (surface only)", ModeName) == 0) { m_currentAlgorithm = m_pointsSurface; + } updateVtk(); @@ -305,7 +318,7 @@ std::vector ViewProviderFemPostObject::getDisplayModes() const std::vector StrList; StrList.emplace_back("Outline"); StrList.emplace_back("Nodes"); - //StrList.emplace_back("Nodes (surface only)"); somehow this filter does not work + // StrList.emplace_back("Nodes (surface only)"); somehow this filter does not work StrList.emplace_back("Surface"); StrList.emplace_back("Surface with Edges"); StrList.emplace_back("Wireframe"); @@ -313,25 +326,29 @@ std::vector ViewProviderFemPostObject::getDisplayModes() const return StrList; } -void ViewProviderFemPostObject::updateVtk() { +void ViewProviderFemPostObject::updateVtk() +{ - if (!setupPipeline()) + if (!setupPipeline()) { return; + } m_currentAlgorithm->Update(); updateProperties(); update3D(); } -void ViewProviderFemPostObject::updateProperties() { +void ViewProviderFemPostObject::updateProperties() +{ m_blockPropertyChanges = true; vtkPolyData* poly = m_currentAlgorithm->GetOutput(); - //coloring + // coloring std::string val; - if (Field.hasEnums() && Field.getValue() >= 0) + if (Field.hasEnums() && Field.getValue() >= 0) { val = Field.getValueAsString(); + } std::vector colorArrays; colorArrays.emplace_back("None"); @@ -339,13 +356,15 @@ void ViewProviderFemPostObject::updateProperties() { vtkPointData* point = poly->GetPointData(); for (int i = 0; i < point->GetNumberOfArrays(); ++i) { std::string FieldName = point->GetArrayName(i); - if (FieldName != "Texture Coordinates") + if (FieldName != "Texture Coordinates") { colorArrays.push_back(FieldName); + } } vtkCellData* cell = poly->GetCellData(); - for (int i = 0; i < cell->GetNumberOfArrays(); ++i) + for (int i = 0; i < cell->GetNumberOfArrays(); ++i) { colorArrays.emplace_back(cell->GetArrayName(i)); + } App::Enumeration empty; Field.setValue(empty); @@ -353,34 +372,40 @@ void ViewProviderFemPostObject::updateProperties() { Field.setValue(m_coloringEnum); std::vector::iterator it = std::find(colorArrays.begin(), colorArrays.end(), val); - if (!val.empty() && it != colorArrays.end()) + if (!val.empty() && it != colorArrays.end()) { Field.setValue(val.c_str()); + } Field.purgeTouched(); - //Vector mode - if (VectorMode.hasEnums() && VectorMode.getValue() >= 0) + // Vector mode + if (VectorMode.hasEnums() && VectorMode.getValue() >= 0) { val = VectorMode.getValueAsString(); + } colorArrays.clear(); - if (Field.getValue() == 0) + if (Field.getValue() == 0) { colorArrays.emplace_back("Not a vector"); + } else { - int array = Field.getValue() - 1; //0 is none + int array = Field.getValue() - 1; // 0 is none vtkDataArray* data = point->GetArray(array); - if (!data) + if (!data) { return; + } - if (data->GetNumberOfComponents() == 1) + if (data->GetNumberOfComponents() == 1) { colorArrays.emplace_back("Not a vector"); + } else { colorArrays.emplace_back("Magnitude"); if (data->GetNumberOfComponents() >= 2) { colorArrays.emplace_back("X"); colorArrays.emplace_back("Y"); } - if (data->GetNumberOfComponents() >= 3) + if (data->GetNumberOfComponents() >= 3) { colorArrays.emplace_back("Z"); + } } } @@ -389,13 +414,15 @@ void ViewProviderFemPostObject::updateProperties() { VectorMode.setValue(m_vectorEnum); it = std::find(colorArrays.begin(), colorArrays.end(), val); - if (!val.empty() && it != colorArrays.end()) + if (!val.empty() && it != colorArrays.end()) { VectorMode.setValue(val.c_str()); + } m_blockPropertyChanges = false; } -void ViewProviderFemPostObject::update3D() { +void ViewProviderFemPostObject::update3D() +{ vtkPolyData* pd = m_currentAlgorithm->GetOutput(); @@ -424,7 +451,7 @@ void ViewProviderFemPostObject::update3D() { m_faces->coordIndex.startEditing(); int soidx = 0; cells = pd->GetPolys(); - for (cells->InitTraversal(); cells->GetNextCell(npts, indx); ) { + for (cells->InitTraversal(); cells->GetNextCell(npts, indx);) { for (int i = 0; i < npts; i++) { m_faces->coordIndex.set1Value(soidx, static_cast(indx[i])); @@ -436,8 +463,9 @@ void ViewProviderFemPostObject::update3D() { m_faces->coordIndex.setNum(soidx); m_faces->coordIndex.finishEditing(); } - else + else { m_faces->coordIndex.setNum(0); + } // write out tstrips if any if (pd->GetNumberOfStrips() > 0) { @@ -445,7 +473,7 @@ void ViewProviderFemPostObject::update3D() { int soidx = 0; cells = pd->GetStrips(); m_triangleStrips->coordIndex.startEditing(); - for (cells->InitTraversal(); cells->GetNextCell(npts, indx); ) { + for (cells->InitTraversal(); cells->GetNextCell(npts, indx);) { for (int i = 0; i < npts; i++) { m_triangleStrips->coordIndex.set1Value(soidx, static_cast(indx[i])); @@ -457,8 +485,9 @@ void ViewProviderFemPostObject::update3D() { m_triangleStrips->coordIndex.setNum(soidx); m_triangleStrips->coordIndex.finishEditing(); } - else + else { m_triangleStrips->coordIndex.setNum(0); + } // write out lines if any if (pd->GetNumberOfLines() > 0) { @@ -466,7 +495,7 @@ void ViewProviderFemPostObject::update3D() { int soidx = 0; cells = pd->GetLines(); m_lines->coordIndex.startEditing(); - for (cells->InitTraversal(); cells->GetNextCell(npts, indx); ) { + for (cells->InitTraversal(); cells->GetNextCell(npts, indx);) { for (int i = 0; i < npts; i++) { m_lines->coordIndex.set1Value(soidx, static_cast(indx[i])); ++soidx; @@ -477,8 +506,9 @@ void ViewProviderFemPostObject::update3D() { m_lines->coordIndex.setNum(soidx); m_lines->coordIndex.finishEditing(); } - else + else { m_lines->coordIndex.setNum(0); + } // write out verts if any if (pd->GetNumberOfVerts() > 0) { @@ -487,23 +517,26 @@ void ViewProviderFemPostObject::update3D() { cells = pd->GetVerts(); m_markers->coordIndex.startEditing(); m_markers->coordIndex.setNum(pd->GetNumberOfVerts()); - for (cells->InitTraversal(); cells->GetNextCell(npts, indx); ) { + for (cells->InitTraversal(); cells->GetNextCell(npts, indx);) { m_markers->coordIndex.set1Value(soidx, static_cast(indx[0])); ++soidx; } m_markers->coordIndex.finishEditing(); } - else + else { m_markers->coordIndex.setNum(0); + } } -void ViewProviderFemPostObject::WritePointData(vtkPoints* points, vtkDataArray* normals, +void ViewProviderFemPostObject::WritePointData(vtkPoints* points, + vtkDataArray* normals, vtkDataArray* tcoords) { Q_UNUSED(tcoords); - if (!points) + if (!points) { return; + } m_coordinates->point.setNum(points->GetNumberOfPoints()); SbVec3f* pnts = m_coordinates->point.startEditing(); @@ -549,8 +582,9 @@ void ViewProviderFemPostObject::updateMaterial() void ViewProviderFemPostObject::WriteColorData(bool ResetColorBarRange) { - if (!setupPipeline()) + if (!setupPipeline()) { return; + } if (Field.getEnumVector().empty() || Field.getValue() == 0) { m_material->diffuseColor.setValue(SbColor(0.8, 0.8, 0.8)); @@ -564,19 +598,21 @@ void ViewProviderFemPostObject::WriteColorData(bool ResetColorBarRange) return; }; - int array = Field.getValue() - 1; // 0 is none + int array = Field.getValue() - 1; // 0 is none vtkPolyData* pd = m_currentAlgorithm->GetOutput(); vtkDataArray* data = pd->GetPointData()->GetArray(array); - if (!data) + if (!data) { return; + } - int component = VectorMode.getValue() - 1; // 0 is either "Not a vector" or magnitude, - // for -1 is correct for magnitude. - // x y and z are one number too high - if (strcmp(VectorMode.getValueAsString(), "Not a vector") == 0) + int component = VectorMode.getValue() - 1; // 0 is either "Not a vector" or magnitude, + // for -1 is correct for magnitude. + // x y and z are one number too high + if (strcmp(VectorMode.getValueAsString(), "Not a vector") == 0) { component = 0; + } - //build the lookuptable + // build the lookuptable if (ResetColorBarRange) { double range[2]; data->GetRange(range, component); @@ -597,8 +633,9 @@ void ViewProviderFemPostObject::WriteColorData(bool ResetColorBarRange) value = data->GetComponent(i, component); } else { - for (int j = 0; j < data->GetNumberOfComponents(); ++j) + for (int j = 0; j < data->GetNumberOfComponents(); ++j) { value += std::pow(data->GetComponent(i, j), 2); + } value = std::sqrt(value); } @@ -656,8 +693,9 @@ void ViewProviderFemPostObject::filterArtifacts(vtkDataSet* dset) // since we will set the filter according to the visible bounding box // assure the object is visible bool visibility = this->Visibility.getValue(); - if (!visibility) + if (!visibility) { this->Visibility.setValue(true); + } m_blockPropertyChanges = true; Gui::Document* doc = this->getDocument(); @@ -686,10 +724,12 @@ void ViewProviderFemPostObject::filterArtifacts(vtkDataSet* dset) extractor->SetInputData(dset); extractor->Update(); auto extractorResult = extractor->GetOutputDataObject(0); - if (extractorResult) + if (extractorResult) { m_surface->SetInputData(extractorResult); - else + } + else { m_surface->SetInputData(dset); + } } else { // for the case that there are only 2D objects @@ -697,28 +737,32 @@ void ViewProviderFemPostObject::filterArtifacts(vtkDataSet* dset) } } // restore initial vsibility - if (!visibility) + if (!visibility) { this->Visibility.setValue(visibility); + } m_blockPropertyChanges = false; } bool ViewProviderFemPostObject::setupPipeline() { - if (m_blockPropertyChanges) + if (m_blockPropertyChanges) { return false; + } auto postObject = static_cast(getObject()); vtkDataObject* data = postObject->Data.getValue(); - if (!data) + if (!data) { return false; + } // check all fields if there is a real/imaginary one and if so // add a field with an absolute value vtkSmartPointer SPdata = data; vtkDataSet* dset = vtkDataSet::SafeDownCast(SPdata); - if (!dset) + if (!dset) { return false; + } std::string FieldName; auto numFields = dset->GetPointData()->GetNumberOfArrays(); for (int i = 0; i < numFields; ++i) { @@ -743,27 +787,32 @@ bool ViewProviderFemPostObject::setupPipeline() // filtering is only necessary for pipelines and warp filters if (FilterMultiCPUResults && (UseNumberOfCores > 1) && ((postObject->getTypeId() == Base::Type::fromName("Fem::FemPostPipeline")) - || (postObject->getTypeId() == Base::Type::fromName("Fem::FemPostWarpVectorFilter")))) + || (postObject->getTypeId() == Base::Type::fromName("Fem::FemPostWarpVectorFilter")))) { filterArtifacts(dset); - else + } + else { m_surface->SetInputData(dset); + } return true; } void ViewProviderFemPostObject::onChanged(const App::Property* prop) { - if (m_blockPropertyChanges) + if (m_blockPropertyChanges) { return; + } bool ResetColorBarRange; // the point filter delivers a single value thus recoloring the bar is senseless if (static_cast(getObject())->getTypeId() - == Base::Type::fromName("Fem::FemPostDataAtPointFilter")) + == Base::Type::fromName("Fem::FemPostDataAtPointFilter")) { ResetColorBarRange = false; - else + } + else { ResetColorBarRange = true; + } if (prop == &Field && setupPipeline()) { updateProperties(); @@ -789,10 +838,11 @@ bool ViewProviderFemPostObject::doubleClicked() ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); bool isBackLightEnabled = hGrp->GetBool("EnableBacklight", false); - if (!isBackLightEnabled) + if (!isBackLightEnabled) { Base::Console().Error("Backlight is not enabled. Due to a VTK implementation problem you " "really should consider to enable backlight in FreeCAD display " "preferences if you work with VTK post processing.\n"); + } // set edit Gui::Application::Instance->activeDocument()->setEdit(this, (int)ViewProvider::Default); return true; @@ -804,8 +854,9 @@ bool ViewProviderFemPostObject::setEdit(int ModNum) Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); TaskDlgPost* postDlg = qobject_cast(dlg); - if (postDlg && postDlg->getView() != this) - postDlg = nullptr; // another pad left open its task panel + if (postDlg && postDlg->getView() != this) { + postDlg = nullptr; // another pad left open its task panel + } if (dlg && !postDlg) { QMessageBox msgBox; msgBox.setText(QObject::tr("A dialog is already open in the task panel")); @@ -813,15 +864,18 @@ bool ViewProviderFemPostObject::setEdit(int ModNum) msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) + if (ret == QMessageBox::Yes) { Gui::Control().reject(); - else + } + else { return false; + } } // start the edit dialog - if (postDlg) + if (postDlg) { Gui::Control().showDialog(postDlg); + } else { postDlg = new TaskDlgPost(this); setupTaskDialog(postDlg); @@ -845,7 +899,7 @@ void ViewProviderFemPostObject::unsetEdit(int ModNum) { if (ModNum == ViewProvider::Default) { // and update the pad - //getSketchObject()->getDocument()->recompute(); + // getSketchObject()->getDocument()->recompute(); // when pressing ESC make sure to close the dialog Gui::Control().closeDialog(); @@ -867,11 +921,12 @@ void ViewProviderFemPostObject::hide() // get all objects in the document auto docGui = Gui::Application::Instance->activeDocument(); - if (!docGui) + if (!docGui) { return; + } auto doc = docGui->getDocument(); - std::vector ObjectsList = doc->getObjects(); - App::DocumentObject *firstVisiblePostObject = nullptr; + std::vector ObjectsList = doc->getObjects(); + App::DocumentObject* firstVisiblePostObject = nullptr; // step through the objects for (auto it : ObjectsList) { if (it->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { @@ -885,9 +940,10 @@ void ViewProviderFemPostObject::hide() // refresh found object if (firstVisiblePostObject) { auto viewProvider = docGui->getViewProvider(firstVisiblePostObject); - auto FEMviewProvider = static_cast(viewProvider); - if (FEMviewProvider) + auto FEMviewProvider = static_cast(viewProvider); + if (FEMviewProvider) { FEMviewProvider->WriteColorData(true); + } } } @@ -900,7 +956,7 @@ void ViewProviderFemPostObject::show() WriteColorData(true); } -void ViewProviderFemPostObject::OnChange(Base::Subject< int >& /*rCaller*/, int /*rcReason*/) +void ViewProviderFemPostObject::OnChange(Base::Subject& /*rCaller*/, int /*rcReason*/) { bool ResetColorBarRange = false; WriteColorData(ResetColorBarRange); @@ -922,15 +978,16 @@ bool ViewProviderFemPostObject::canDelete(App::DocumentObject* obj) const return true; } -void ViewProviderFemPostObject::onSelectionChanged(const Gui::SelectionChanges &sel) +void ViewProviderFemPostObject::onSelectionChanged(const Gui::SelectionChanges& sel) { // If a FemPostObject is selected in the document tree we must refresh its // color bar. // But don't do this if the object is invisible because other objects with a // color bar might be visible and the color bar is then wrong. if (sel.Type == Gui::SelectionChanges::AddSelection) { - if (this->getObject()->Visibility.getValue()) + if (this->getObject()->Visibility.getValue()) { updateMaterial(); + } } } @@ -940,25 +997,29 @@ void ViewProviderFemPostObject::addAbsoluteField(vtkDataSet* dset, std::string F // real field names have the suffix " re", given by Elmer // if the field does not have this suffix, we can return auto suffix = FieldName.substr(FieldName.size() - 3, FieldName.size() - 1); - if (strcmp(suffix.c_str(), " re") != 0) + if (strcmp(suffix.c_str(), " re") != 0) { return; + } // absolute fields might have already been created, then do nothing auto strAbsoluteFieldName = FieldName.substr(0, FieldName.size() - 2) + "abs"; vtkDataArray* testArray = dset->GetPointData()->GetArray(strAbsoluteFieldName.c_str()); - if (testArray) + if (testArray) { return; + } // safety check vtkDataArray* realDdata = dset->GetPointData()->GetArray(FieldName.c_str()); - if (!realDdata) + if (!realDdata) { return; + } // now check if the imaginary counterpart exists auto strImaginaryFieldName = FieldName.substr(0, FieldName.size() - 2) + "im"; vtkDataArray* imagDdata = dset->GetPointData()->GetArray(strImaginaryFieldName.c_str()); - if (!imagDdata) + if (!imagDdata) { return; + } // create a new array and copy over the real data // since one cannot directly access the values of a vtkDataSet diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.h b/src/Mod/Fem/Gui/ViewProviderFemPostObject.h index c981a511b1..70b455ae7d 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.h +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.h @@ -54,18 +54,19 @@ class SoIndexedFaceSet; class SoIndexedLineSet; class SoIndexedTriangleStripSet; -namespace Gui { - class SelectionChanges; - class SoFCColorBar; -} +namespace Gui +{ +class SelectionChanges; +class SoFCColorBar; +} // namespace Gui namespace FemGui { class TaskDlgPost; -class FemGuiExport ViewProviderFemPostObject : public Gui::ViewProviderDocumentObject, - public Base::Observer +class FemGuiExport ViewProviderFemPostObject: public Gui::ViewProviderDocumentObject, + public Base::Observer { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostObject); @@ -76,17 +77,17 @@ public: /// destructor. ~ViewProviderFemPostObject() override; - App::PropertyEnumeration Field; - App::PropertyEnumeration VectorMode; - App::PropertyPercent Transparency; + App::PropertyEnumeration Field; + App::PropertyEnumeration VectorMode; + App::PropertyPercent Transparency; - void attach(App::DocumentObject *pcObject) override; + void attach(App::DocumentObject* pcObject) override; void setDisplayMode(const char* ModeName) override; std::vector getDisplayModes() const override; void updateData(const App::Property*) override; void onChanged(const App::Property* prop) override; - //edit handling + // edit handling bool doubleClicked() override; bool setEdit(int ModNum) override; void unsetEdit(int ModNum) override; @@ -97,7 +98,7 @@ public: SoSeparator* getFrontRoot() const override; // observer for the color bar - void OnChange(Base::Subject< int >& rCaller, int rcReason) override; + void OnChange(Base::Subject& rCaller, int rcReason) override; // update color bar void updateMaterial(); @@ -106,20 +107,20 @@ public: bool canDelete(App::DocumentObject* obj) const override; virtual void onSelectionChanged(const Gui::SelectionChanges& sel); - /** @name Selection handling - * This group of methods do the selection handling. - * Here you can define how the selection for your ViewProvider - * works. + /** @name Selection handling + * This group of methods do the selection handling. + * Here you can define how the selection for your ViewProvider + * works. */ //@{ -// /// indicates if the ViewProvider use the new Selection model -// virtual bool useNewSelectionModel(void) const {return true;} -// /// return a hit element to the selection path or 0 -// virtual std::string getElement(const SoDetail*) const; -// virtual SoDetail* getDetail(const char*) const; -// /// return the highlight lines for a given element or the whole shape -// virtual std::vector getSelectionShape(const char* Element) const; -// //@} + // /// indicates if the ViewProvider use the new Selection model + // virtual bool useNewSelectionModel(void) const {return true;} + // /// return a hit element to the selection path or 0 + // virtual std::string getElement(const SoDetail*) const; + // virtual SoDetail* getDetail(const char*) const; + // /// return the highlight lines for a given element or the whole shape + // virtual std::vector getSelectionShape(const char* Element) const; + // //@} protected: virtual void setupTaskDialog(TaskDlgPost* dlg); @@ -127,44 +128,43 @@ protected: void updateVtk(); void setRangeOfColorBar(double min, double max); - SoCoordinate3* m_coordinates; - SoIndexedPointSet* m_markers; - SoIndexedLineSet* m_lines; - SoIndexedFaceSet* m_faces; - SoIndexedTriangleStripSet* m_triangleStrips; - SoMaterial* m_material; - SoMaterialBinding* m_materialBinding; - SoShapeHints* m_shapeHints; - SoNormalBinding* m_normalBinding; - SoNormal* m_normals; - SoDrawStyle* m_drawStyle; - SoSeparator* m_separator; - Gui::SoFCColorBar* m_colorBar; - SoSeparator* m_colorRoot; - SoDrawStyle* m_colorStyle; + SoCoordinate3* m_coordinates; + SoIndexedPointSet* m_markers; + SoIndexedLineSet* m_lines; + SoIndexedFaceSet* m_faces; + SoIndexedTriangleStripSet* m_triangleStrips; + SoMaterial* m_material; + SoMaterialBinding* m_materialBinding; + SoShapeHints* m_shapeHints; + SoNormalBinding* m_normalBinding; + SoNormal* m_normals; + SoDrawStyle* m_drawStyle; + SoSeparator* m_separator; + Gui::SoFCColorBar* m_colorBar; + SoSeparator* m_colorRoot; + SoDrawStyle* m_colorStyle; - vtkSmartPointer m_currentAlgorithm; - vtkSmartPointer m_surface; - vtkSmartPointer m_surfaceEdges; - vtkSmartPointer m_outline; - vtkSmartPointer m_wireframe, m_wireframeSurface; - vtkSmartPointer m_points, m_pointsSurface; + vtkSmartPointer m_currentAlgorithm; + vtkSmartPointer m_surface; + vtkSmartPointer m_surfaceEdges; + vtkSmartPointer m_outline; + vtkSmartPointer m_wireframe, m_wireframeSurface; + vtkSmartPointer m_points, m_pointsSurface; private: void filterArtifacts(vtkDataSet* data); void updateProperties(); void update3D(); - void WritePointData(vtkPoints *points, vtkDataArray *normals, - vtkDataArray *tcoords); + void WritePointData(vtkPoints* points, vtkDataArray* normals, vtkDataArray* tcoords); void WriteColorData(bool ResetColorBarRange); void WriteTransparency(); void addAbsoluteField(vtkDataSet* dset, std::string FieldName); App::Enumeration m_coloringEnum, m_vectorEnum; - bool m_blockPropertyChanges{false}; + bool m_blockPropertyChanges {false}; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_VIEWPROVIDERFEMPOSTOBJECT_H +#endif // FEM_VIEWPROVIDERFEMPOSTOBJECT_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp index 37c20c032f..be75b54680 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp @@ -33,10 +33,10 @@ #include #include -#include "ViewProviderFemPostPipeline.h" -#include "ViewProviderFemPostPipelinePy.h" #include "ViewProviderAnalysis.h" #include "ViewProviderFemPostFunction.h" +#include "ViewProviderFemPostPipeline.h" +#include "ViewProviderFemPostPipelinePy.h" using namespace FemGui; @@ -50,40 +50,48 @@ ViewProviderFemPostPipeline::ViewProviderFemPostPipeline() ViewProviderFemPostPipeline::~ViewProviderFemPostPipeline() = default; -std::vector< App::DocumentObject* > ViewProviderFemPostPipeline::claimChildren() const { +std::vector ViewProviderFemPostPipeline::claimChildren() const +{ Fem::FemPostPipeline* pipeline = static_cast(getObject()); std::vector children; - if (pipeline->Functions.getValue()) + if (pipeline->Functions.getValue()) { children.push_back(pipeline->Functions.getValue()); + } - children.insert(children.end(), pipeline->Filter.getValues().begin(), - pipeline->Filter.getValues().end()); + children.insert(children.end(), + pipeline->Filter.getValues().begin(), + pipeline->Filter.getValues().end()); return children; } -std::vector< App::DocumentObject* > ViewProviderFemPostPipeline::claimChildren3D() const { +std::vector ViewProviderFemPostPipeline::claimChildren3D() const +{ return claimChildren(); } -void ViewProviderFemPostPipeline::updateData(const App::Property* prop) { +void ViewProviderFemPostPipeline::updateData(const App::Property* prop) +{ FemGui::ViewProviderFemPostObject::updateData(prop); Fem::FemPostPipeline* pipeline = static_cast(getObject()); - if (prop == &pipeline->Functions) + if (prop == &pipeline->Functions) { updateFunctionSize(); + } } -void ViewProviderFemPostPipeline::updateFunctionSize() { +void ViewProviderFemPostPipeline::updateFunctionSize() +{ // we need to get the bounding box and set the function provider size Fem::FemPostPipeline* obj = static_cast(getObject()); if (!obj->Functions.getValue() || !obj->Functions.getValue()->isDerivedFrom( - Fem::FemPostFunctionProvider::getClassTypeId())) + Fem::FemPostFunctionProvider::getClassTypeId())) { return; + } // get the function provider FemGui::ViewProviderFemPostFunctionProvider* vp = @@ -99,7 +107,7 @@ void ViewProviderFemPostPipeline::updateFunctionSize() { } } -void ViewProviderFemPostPipeline::onSelectionChanged(const Gui::SelectionChanges &sel) +void ViewProviderFemPostPipeline::onSelectionChanged(const Gui::SelectionChanges& sel) { auto getAnalyzeView = [](App::DocumentObject* obj) { ViewProviderFemAnalysis* analyzeView = nullptr; @@ -116,10 +124,12 @@ void ViewProviderFemPostPipeline::onSelectionChanged(const Gui::SelectionChanges // But don't do this if the object is invisible because other objects with a // color bar might be visible and the color bar is then wrong. if (sel.Type == Gui::SelectionChanges::AddSelection) { - if (this->getObject()->Visibility.getValue()) + if (this->getObject()->Visibility.getValue()) { updateMaterial(); - else - return; // purposely nothing should be done + } + else { + return; // purposely nothing should be done + } // Access analysis object ViewProviderFemAnalysis* analyzeView = getAnalyzeView(this->getObject()); @@ -135,29 +145,33 @@ void ViewProviderFemPostPipeline::updateColorBars() auto children = claimChildren(); for (auto& child : children) { if (child->Visibility.getValue()) { - auto vpObject = dynamic_cast( + auto vpObject = dynamic_cast( Gui::Application::Instance->getViewProvider(child)); - if (vpObject) + if (vpObject) { vpObject->updateMaterial(); + } } } // if pipeline is visible, update it - if (this->isVisible()) + if (this->isVisible()) { updateMaterial(); + } } -void ViewProviderFemPostPipeline::transformField(char *FieldName, double FieldFactor) +void ViewProviderFemPostPipeline::transformField(char* FieldName, double FieldFactor) { - Fem::FemPostPipeline *obj = static_cast(getObject()); + Fem::FemPostPipeline* obj = static_cast(getObject()); vtkSmartPointer data = obj->Data.getValue(); - vtkDataSet *dset = vtkDataSet::SafeDownCast(data); - if (!dset) + vtkDataSet* dset = vtkDataSet::SafeDownCast(data); + if (!dset) { return; - vtkDataArray *pdata = dset->GetPointData()->GetArray(FieldName); - if (!pdata) + } + vtkDataArray* pdata = dset->GetPointData()->GetArray(FieldName); + if (!pdata) { return; + } auto strFieldName = std::string(FieldName); @@ -176,16 +190,19 @@ void ViewProviderFemPostPipeline::transformField(char *FieldName, double FieldFa } } } - else + else { scaleField(dset, pdata, FieldFactor); + } } -void ViewProviderFemPostPipeline::scaleField(vtkDataSet* dset, vtkDataArray* pdata, +void ViewProviderFemPostPipeline::scaleField(vtkDataSet* dset, + vtkDataArray* pdata, double FieldFactor) { // safe guard - if (!dset || !pdata) + if (!dset || !pdata) { return; + } // step through all mesh points and scale them for (int i = 0; i < dset->GetNumberOfPoints(); ++i) { @@ -204,7 +221,7 @@ void ViewProviderFemPostPipeline::scaleField(vtkDataSet* dset, vtkDataArray* pda } } -PyObject *ViewProviderFemPostPipeline::getPyObject() +PyObject* ViewProviderFemPostPipeline::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.h b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.h index d6d2dbf971..4edf71c8a4 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.h +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.h @@ -32,7 +32,8 @@ namespace FemGui { -class FemGuiExport ViewProviderFemPostPipeline : public ViewProviderFemPostObject { +class FemGuiExport ViewProviderFemPostPipeline: public ViewProviderFemPostObject +{ PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostPipeline); @@ -41,24 +42,23 @@ public: ViewProviderFemPostPipeline(); ~ViewProviderFemPostPipeline() override; - std::vector< App::DocumentObject* > claimChildren() const override; - std::vector< App::DocumentObject* > claimChildren3D() const override; + std::vector claimChildren() const override; + std::vector claimChildren3D() const override; void updateData(const App::Property* prop) override; - void onSelectionChanged(const Gui::SelectionChanges &sel) override; + void onSelectionChanged(const Gui::SelectionChanges& sel) override; void updateColorBars(); - void transformField(char *FieldName, double FieldFactor); - void scaleField(vtkDataSet *dset, vtkDataArray *pdata, double FieldFactor); - PyObject *getPyObject() override; + void transformField(char* FieldName, double FieldFactor); + void scaleField(vtkDataSet* dset, vtkDataArray* pdata, double FieldFactor); + PyObject* getPyObject() override; private: Py::Object PythonObject; protected: void updateFunctionSize(); - }; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_VIEWPROVIDERFEMPOSTPIPELINE_H +#endif // FEM_VIEWPROVIDERFEMPOSTPIPELINE_H diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePyImp.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePyImp.cpp index f0d15877c9..d206a06f1d 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePyImp.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePyImp.cpp @@ -22,10 +22,12 @@ #include "PreCompiled.h" +// clang-format off #include "ViewProviderFemPostPipeline.h" // inclusion of the generated files (generated out of ViewProviderFemPostPipelinePy.xml) #include "ViewProviderFemPostPipelinePy.h" #include "ViewProviderFemPostPipelinePy.cpp" +// clang-format on using namespace FemGui; @@ -36,35 +38,37 @@ std::string ViewProviderFemPostPipelinePy::representation() const return {""}; } -PyObject *ViewProviderFemPostPipelinePy::updateColorBars(PyObject *args) +PyObject* ViewProviderFemPostPipelinePy::updateColorBars(PyObject* args) { - if (!PyArg_ParseTuple(args, "")) + if (!PyArg_ParseTuple(args, "")) { return nullptr; + } this->getViewProviderFemPostPipelinePtr()->updateColorBars(); Py_Return; } -PyObject *ViewProviderFemPostPipelinePy::transformField(PyObject *args) +PyObject* ViewProviderFemPostPipelinePy::transformField(PyObject* args) { - char *FieldName; + char* FieldName; double FieldFactor; - if (!PyArg_ParseTuple(args, "sd", &FieldName, &FieldFactor)) + if (!PyArg_ParseTuple(args, "sd", &FieldName, &FieldFactor)) { return nullptr; + } this->getViewProviderFemPostPipelinePtr()->transformField(FieldName, FieldFactor); Py_Return; } -PyObject *ViewProviderFemPostPipelinePy::getCustomAttributes(const char * /*attr*/) const +PyObject* ViewProviderFemPostPipelinePy::getCustomAttributes(const char* /*attr*/) const { return nullptr; } -int ViewProviderFemPostPipelinePy::setCustomAttributes(const char * /*attr*/, PyObject * /*obj*/) +int ViewProviderFemPostPipelinePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) { return 0; } diff --git a/src/Mod/Fem/Gui/ViewProviderResult.cpp b/src/Mod/Fem/Gui/ViewProviderResult.cpp index cd0af53a49..27b8f8a79b 100644 --- a/src/Mod/Fem/Gui/ViewProviderResult.cpp +++ b/src/Mod/Fem/Gui/ViewProviderResult.cpp @@ -39,11 +39,12 @@ ViewProviderResult::~ViewProviderResult() = default; // Python feature ----------------------------------------------------------------------- -namespace Gui { +namespace Gui +{ /// @cond DOXERR PROPERTY_SOURCE_TEMPLATE(FemGui::ViewProviderResultPython, FemGui::ViewProviderResult) /// @endcond // explicit template instantiation template class FemGuiExport ViewProviderPythonFeatureT; -} +} // namespace Gui diff --git a/src/Mod/Fem/Gui/ViewProviderResult.h b/src/Mod/Fem/Gui/ViewProviderResult.h index e9479635e8..41792756a9 100644 --- a/src/Mod/Fem/Gui/ViewProviderResult.h +++ b/src/Mod/Fem/Gui/ViewProviderResult.h @@ -31,7 +31,7 @@ namespace FemGui { -class FemGuiExport ViewProviderResult : public Gui::ViewProviderDocumentObject +class FemGuiExport ViewProviderResult: public Gui::ViewProviderDocumentObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderResult); @@ -44,12 +44,14 @@ public: // shows solid in the tree bool isShow() const override - { return true; } + { + return true; + } }; using ViewProviderResultPython = Gui::ViewProviderPythonFeatureT; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_ViewProviderResult_H +#endif // FEM_ViewProviderResult_H diff --git a/src/Mod/Fem/Gui/ViewProviderSetElements.cpp b/src/Mod/Fem/Gui/ViewProviderSetElements.cpp index cbe605b030..3bae75eee5 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetElements.cpp +++ b/src/Mod/Fem/Gui/ViewProviderSetElements.cpp @@ -31,20 +31,18 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetElements, Gui::ViewProviderGeometryObject bool ViewProviderSetElements::doubleClicked() { - //Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); - //Gui::Control().showDialog(dlg); + // Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); Gui::Control().showDialog(dlg); return true; } bool ViewProviderSetElements::setEdit(int) { - //Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); - //Gui::Control().showDialog(dlg); + // Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); Gui::Control().showDialog(dlg); return true; } void ViewProviderSetElements::unsetEdit(int) -{ - -} +{} diff --git a/src/Mod/Fem/Gui/ViewProviderSetElements.h b/src/Mod/Fem/Gui/ViewProviderSetElements.h index 0264130c7f..ef9f003537 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetElements.h +++ b/src/Mod/Fem/Gui/ViewProviderSetElements.h @@ -29,7 +29,7 @@ namespace FemGui { -class ViewProviderSetElements : public Gui::ViewProviderGeometryObject +class ViewProviderSetElements: public Gui::ViewProviderGeometryObject { PROPERTY_HEADER_WITH_OVERRIDE(RobotGui::ViewProviderSetElements); @@ -41,7 +41,7 @@ protected: void unsetEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_ViewProviderSetElements_H +#endif // FEM_ViewProviderSetElements_H diff --git a/src/Mod/Fem/Gui/ViewProviderSetFaces.cpp b/src/Mod/Fem/Gui/ViewProviderSetFaces.cpp index a1a0f30544..080681c531 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetFaces.cpp +++ b/src/Mod/Fem/Gui/ViewProviderSetFaces.cpp @@ -31,20 +31,18 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetFaces, Gui::ViewProviderGeometryObject) bool ViewProviderSetFaces::doubleClicked() { - //Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); - //Gui::Control().showDialog(dlg); + // Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); Gui::Control().showDialog(dlg); return true; } bool ViewProviderSetFaces::setEdit(int) { - //Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); - //Gui::Control().showDialog(dlg); + // Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); Gui::Control().showDialog(dlg); return true; } void ViewProviderSetFaces::unsetEdit(int) -{ - -} +{} diff --git a/src/Mod/Fem/Gui/ViewProviderSetFaces.h b/src/Mod/Fem/Gui/ViewProviderSetFaces.h index bb3accf2b3..0c658ce13f 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetFaces.h +++ b/src/Mod/Fem/Gui/ViewProviderSetFaces.h @@ -29,7 +29,7 @@ namespace FemGui { -class ViewProviderSetFaces : public Gui::ViewProviderGeometryObject +class ViewProviderSetFaces: public Gui::ViewProviderGeometryObject { PROPERTY_HEADER_WITH_OVERRIDE(RobotGui::ViewProviderSetFaces); @@ -41,7 +41,7 @@ protected: void unsetEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_ViewProviderSetFaces_H +#endif // FEM_ViewProviderSetFaces_H diff --git a/src/Mod/Fem/Gui/ViewProviderSetGeometry.cpp b/src/Mod/Fem/Gui/ViewProviderSetGeometry.cpp index f911fe2c91..55dd28e3ec 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetGeometry.cpp +++ b/src/Mod/Fem/Gui/ViewProviderSetGeometry.cpp @@ -31,20 +31,18 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetGeometry, Gui::ViewProviderGeometryObject bool ViewProviderSetGeometry::doubleClicked() { - //Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); - //Gui::Control().showDialog(dlg); + // Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); Gui::Control().showDialog(dlg); return true; } bool ViewProviderSetGeometry::setEdit(int) { - //Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); - //Gui::Control().showDialog(dlg); + // Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast(getObject())); Gui::Control().showDialog(dlg); return true; } void ViewProviderSetGeometry::unsetEdit(int) -{ - -} +{} diff --git a/src/Mod/Fem/Gui/ViewProviderSetGeometry.h b/src/Mod/Fem/Gui/ViewProviderSetGeometry.h index 388c268a51..ed731cc1d9 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetGeometry.h +++ b/src/Mod/Fem/Gui/ViewProviderSetGeometry.h @@ -29,7 +29,7 @@ namespace FemGui { -class ViewProviderSetGeometry : public Gui::ViewProviderGeometryObject +class ViewProviderSetGeometry: public Gui::ViewProviderGeometryObject { PROPERTY_HEADER_WITH_OVERRIDE(RobotGui::ViewProviderSetGeometry); @@ -41,7 +41,7 @@ protected: void unsetEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_ViewProviderSetGeometry_H +#endif // FEM_ViewProviderSetGeometry_H diff --git a/src/Mod/Fem/Gui/ViewProviderSetNodes.cpp b/src/Mod/Fem/Gui/ViewProviderSetNodes.cpp index 49f9fcb15d..8fd2920b26 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetNodes.cpp +++ b/src/Mod/Fem/Gui/ViewProviderSetNodes.cpp @@ -35,7 +35,8 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetNodes, Gui::ViewProviderGeometryObject) bool ViewProviderSetNodes::doubleClicked() { - Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(static_cast(getObject())); + Gui::TaskView::TaskDialog* dlg = + new TaskDlgCreateNodeSet(static_cast(getObject())); Gui::Control().showDialog(dlg); return true; } @@ -43,12 +44,11 @@ bool ViewProviderSetNodes::doubleClicked() bool ViewProviderSetNodes::setEdit(int) { - Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(static_cast(getObject())); + Gui::TaskView::TaskDialog* dlg = + new TaskDlgCreateNodeSet(static_cast(getObject())); Gui::Control().showDialog(dlg); return true; } void ViewProviderSetNodes::unsetEdit(int) -{ - -} +{} diff --git a/src/Mod/Fem/Gui/ViewProviderSetNodes.h b/src/Mod/Fem/Gui/ViewProviderSetNodes.h index 697e55d32b..7ac667b073 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetNodes.h +++ b/src/Mod/Fem/Gui/ViewProviderSetNodes.h @@ -29,7 +29,7 @@ namespace FemGui { -class ViewProviderSetNodes : public Gui::ViewProviderGeometryObject +class ViewProviderSetNodes: public Gui::ViewProviderGeometryObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderSetNodes); @@ -41,7 +41,7 @@ protected: void unsetEdit(int ModNum) override; }; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_ViewProviderSetNodes_H +#endif // FEM_ViewProviderSetNodes_H diff --git a/src/Mod/Fem/Gui/ViewProviderSolver.cpp b/src/Mod/Fem/Gui/ViewProviderSolver.cpp index 1734de99d0..6b9bedd8bd 100644 --- a/src/Mod/Fem/Gui/ViewProviderSolver.cpp +++ b/src/Mod/Fem/Gui/ViewProviderSolver.cpp @@ -23,16 +23,16 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif #include #include -#include "ViewProviderSolver.h" #include "ViewProviderAnalysis.h" +#include "ViewProviderSolver.h" using namespace FemGui; @@ -48,7 +48,7 @@ ViewProviderSolver::~ViewProviderSolver() = default; std::vector ViewProviderSolver::getDisplayModes() const { - return { "Solver" }; + return {"Solver"}; } bool ViewProviderSolver::onDelete(const std::vector&) @@ -70,11 +70,12 @@ bool ViewProviderSolver::canDelete(App::DocumentObject* obj) const // Python feature ----------------------------------------------------------------------- -namespace Gui { +namespace Gui +{ /// @cond DOXERR PROPERTY_SOURCE_TEMPLATE(FemGui::ViewProviderSolverPython, FemGui::ViewProviderSolver) /// @endcond // explicit template instantiation template class FemGuiExport ViewProviderPythonFeatureT; -} +} // namespace Gui diff --git a/src/Mod/Fem/Gui/ViewProviderSolver.h b/src/Mod/Fem/Gui/ViewProviderSolver.h index 2f163a77bc..483a678b1e 100644 --- a/src/Mod/Fem/Gui/ViewProviderSolver.h +++ b/src/Mod/Fem/Gui/ViewProviderSolver.h @@ -37,7 +37,7 @@ class SoMaterialBinding; namespace FemGui { -class FemGuiExport ViewProviderSolver : public Gui::ViewProviderDocumentObject +class FemGuiExport ViewProviderSolver: public Gui::ViewProviderDocumentObject { PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderSolver); @@ -49,7 +49,8 @@ public: ~ViewProviderSolver() override; // shows solid in the tree - bool isShow() const override { + bool isShow() const override + { return Visibility.getValue(); } /// A list of all possible display modes @@ -62,7 +63,7 @@ public: using ViewProviderSolverPython = Gui::ViewProviderPythonFeatureT; -} //namespace FemGui +} // namespace FemGui -#endif // FEM_ViewProviderSolver_H +#endif // FEM_ViewProviderSolver_H diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp old mode 100755 new mode 100644 index ea948bcbf5..6d98e7e9e3 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -23,7 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -36,7 +36,7 @@ using namespace FemGui; -#if 0 // needed for Qt's lupdate utility +#if 0 // needed for Qt's lupdate utility qApp->translate("Workbench", "FEM"); qApp->translate("Workbench", "&FEM"); // @@ -88,10 +88,9 @@ Workbench::~Workbench() = default; void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) const { StdWorkbench::setupContextMenu(recipient, item); - *item - << "Separator" - << "FEM_MeshClear" - << "FEM_MeshDisplayInfo"; + *item << "Separator" + << "FEM_MeshClear" + << "FEM_MeshDisplayInfo"; } Gui::ToolBarItem* Workbench::setupToolBars() const @@ -100,130 +99,124 @@ Gui::ToolBarItem* Workbench::setupToolBars() const Gui::ToolBarItem* model = new Gui::ToolBarItem(root); model->setCommand("Model"); - *model - << "FEM_Analysis" - << "Separator" - << "FEM_MaterialSolid" - << "FEM_MaterialFluid" - << "FEM_MaterialMechanicalNonlinear" - << "FEM_MaterialReinforced" - << "FEM_MaterialEditor" - << "Separator" - << "FEM_ElementGeometry1D" - << "FEM_ElementRotation1D" - << "FEM_ElementGeometry2D" - << "FEM_ElementFluid1D"; + *model << "FEM_Analysis" + << "Separator" + << "FEM_MaterialSolid" + << "FEM_MaterialFluid" + << "FEM_MaterialMechanicalNonlinear" + << "FEM_MaterialReinforced" + << "FEM_MaterialEditor" + << "Separator" + << "FEM_ElementGeometry1D" + << "FEM_ElementRotation1D" + << "FEM_ElementGeometry2D" + << "FEM_ElementFluid1D"; Gui::ToolBarItem* electromag = new Gui::ToolBarItem(root); electromag->setCommand("Electromagnetic boundary conditions"); - *electromag - << "FEM_CompEmConstraints"; + *electromag << "FEM_CompEmConstraints"; Gui::ToolBarItem* fluid = new Gui::ToolBarItem(root); fluid->setCommand("Fluid boundary conditions"); - *fluid - << "FEM_ConstraintInitialFlowVelocity" - << "FEM_ConstraintInitialPressure" - << "Separator" - << "FEM_ConstraintFlowVelocity"; + *fluid << "FEM_ConstraintInitialFlowVelocity" + << "FEM_ConstraintInitialPressure" + << "Separator" + << "FEM_ConstraintFlowVelocity"; Gui::ToolBarItem* geom = new Gui::ToolBarItem(root); geom->setCommand("Geometrical analysis features"); - *geom - << "FEM_ConstraintPlaneRotation" - << "FEM_ConstraintSectionPrint" - << "FEM_ConstraintTransform"; + *geom << "FEM_ConstraintPlaneRotation" + << "FEM_ConstraintSectionPrint" + << "FEM_ConstraintTransform"; Gui::ToolBarItem* mech = new Gui::ToolBarItem(root); mech->setCommand("Mechanical boundary conditions and loads"); - *mech - << "FEM_ConstraintFixed" - << "FEM_ConstraintDisplacement" - << "FEM_ConstraintContact" - << "FEM_ConstraintTie" - << "FEM_ConstraintSpring" - << "Separator" - << "FEM_ConstraintForce" - << "FEM_ConstraintPressure" - << "FEM_ConstraintCentrif" - << "FEM_ConstraintSelfWeight"; + *mech << "FEM_ConstraintFixed" + << "FEM_ConstraintDisplacement" + << "FEM_ConstraintContact" + << "FEM_ConstraintTie" + << "FEM_ConstraintSpring" + << "Separator" + << "FEM_ConstraintForce" + << "FEM_ConstraintPressure" + << "FEM_ConstraintCentrif" + << "FEM_ConstraintSelfWeight"; Gui::ToolBarItem* thermal = new Gui::ToolBarItem(root); thermal->setCommand("Thermal boundary conditions and loads"); - *thermal - << "FEM_ConstraintInitialTemperature" - << "Separator" - << "FEM_ConstraintHeatflux" - << "FEM_ConstraintTemperature" - << "FEM_ConstraintBodyHeatSource"; + *thermal << "FEM_ConstraintInitialTemperature" + << "Separator" + << "FEM_ConstraintHeatflux" + << "FEM_ConstraintTemperature" + << "FEM_ConstraintBodyHeatSource"; Gui::ToolBarItem* mesh = new Gui::ToolBarItem(root); mesh->setCommand("Mesh"); #ifdef FCWithNetgen - *mesh - << "FEM_MeshNetgenFromShape"; + *mesh << "FEM_MeshNetgenFromShape"; #endif - *mesh - << "FEM_MeshGmshFromShape" - << "Separator" - << "FEM_MeshBoundaryLayer" - << "FEM_MeshRegion" - << "FEM_MeshGroup" - << "Separator" - << "FEM_FEMMesh2Mesh"; + *mesh << "FEM_MeshGmshFromShape" + << "Separator" + << "FEM_MeshBoundaryLayer" + << "FEM_MeshRegion" + << "FEM_MeshGroup" + << "Separator" + << "FEM_FEMMesh2Mesh"; Gui::ToolBarItem* solve = new Gui::ToolBarItem(root); solve->setCommand("Solve"); - if (!Fem::Tools::checkIfBinaryExists("CCX", "ccx", "ccx").empty()) + if (!Fem::Tools::checkIfBinaryExists("CCX", "ccx", "ccx").empty()) { *solve << "FEM_SolverCalculixCxxtools"; - if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver").empty()) + } + if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver").empty()) { *solve << "FEM_SolverElmer"; + } // also check the multi-CPU Elmer build - else if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver_mpi").empty()) + else if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver_mpi").empty()) { *solve << "FEM_SolverElmer"; - if (!Fem::Tools::checkIfBinaryExists("Mystran", "mystran", "mystran").empty()) + } + if (!Fem::Tools::checkIfBinaryExists("Mystran", "mystran", "mystran").empty()) { *solve << "FEM_SolverMystran"; - if (!Fem::Tools::checkIfBinaryExists("Z88", "z88", "z88r").empty()) + } + if (!Fem::Tools::checkIfBinaryExists("Z88", "z88", "z88r").empty()) { *solve << "FEM_SolverZ88"; + } *solve << "Separator" - << "FEM_CompMechEquations" - << "FEM_CompEmEquations" - << "FEM_EquationFlow" - << "FEM_EquationFlux" - << "FEM_EquationHeat" - << "Separator" - << "FEM_SolverControl" - << "FEM_SolverRun"; + << "FEM_CompMechEquations" + << "FEM_CompEmEquations" + << "FEM_EquationFlow" + << "FEM_EquationFlux" + << "FEM_EquationHeat" + << "Separator" + << "FEM_SolverControl" + << "FEM_SolverRun"; Gui::ToolBarItem* results = new Gui::ToolBarItem(root); results->setCommand("Results"); - *results - << "FEM_ResultsPurge" - << "FEM_ResultShow"; + *results << "FEM_ResultsPurge" + << "FEM_ResultShow"; #ifdef FC_USE_VTK - *results - << "Separator" - << "FEM_PostApplyChanges" - << "FEM_PostPipelineFromResult" - << "Separator" - << "FEM_PostFilterWarp" - << "FEM_PostFilterClipScalar" - << "FEM_PostFilterCutFunction" - << "FEM_PostFilterClipRegion" - << "FEM_PostFilterContours" - << "FEM_PostFilterDataAlongLine" - << "FEM_PostFilterLinearizedStresses" - << "FEM_PostFilterDataAtPoint" - << "Separator" - << "FEM_PostCreateFunctions"; + *results << "Separator" + << "FEM_PostApplyChanges" + << "FEM_PostPipelineFromResult" + << "Separator" + << "FEM_PostFilterWarp" + << "FEM_PostFilterClipScalar" + << "FEM_PostFilterCutFunction" + << "FEM_PostFilterClipRegion" + << "FEM_PostFilterContours" + << "FEM_PostFilterDataAlongLine" + << "FEM_PostFilterLinearizedStresses" + << "FEM_PostFilterDataAtPoint" + << "Separator" + << "FEM_PostCreateFunctions"; #endif Gui::ToolBarItem* utils = new Gui::ToolBarItem(root); utils->setCommand("Utilities"); - *utils - << "FEM_ClippingPlaneAdd" - << "FEM_ClippingPlaneRemoveAll" - << "FEM_Examples"; + *utils << "FEM_ClippingPlaneAdd" + << "FEM_ClippingPlaneRemoveAll" + << "FEM_Examples"; return root; } @@ -235,74 +228,67 @@ Gui::MenuItem* Workbench::setupMenuBar() const Gui::MenuItem* material = new Gui::MenuItem; material->setCommand("Materials"); - *material - << "FEM_MaterialSolid" - << "FEM_MaterialFluid" - << "FEM_MaterialMechanicalNonlinear" - << "FEM_MaterialReinforced" - << "FEM_MaterialEditor"; + *material << "FEM_MaterialSolid" + << "FEM_MaterialFluid" + << "FEM_MaterialMechanicalNonlinear" + << "FEM_MaterialReinforced" + << "FEM_MaterialEditor"; Gui::MenuItem* elegeom = new Gui::MenuItem; elegeom->setCommand("&Element Geometry"); - *elegeom - << "FEM_ElementGeometry1D" - << "FEM_ElementRotation1D" - << "FEM_ElementGeometry2D" - << "FEM_ElementFluid1D"; + *elegeom << "FEM_ElementGeometry1D" + << "FEM_ElementRotation1D" + << "FEM_ElementGeometry2D" + << "FEM_ElementFluid1D"; Gui::MenuItem* elec = new Gui::MenuItem; elec->setCommand("&Electromagnetic boundary conditions"); - *elec - << "FEM_ConstraintElectrostaticPotential" - << "FEM_ConstraintCurrentDensity" - << "FEM_ConstraintMagnetization"; + *elec << "FEM_ConstraintElectrostaticPotential" + << "FEM_ConstraintCurrentDensity" + << "FEM_ConstraintMagnetization"; Gui::MenuItem* fluid = new Gui::MenuItem; fluid->setCommand("&Fluid boundary conditions"); - *fluid - << "FEM_ConstraintInitialFlowVelocity" - << "FEM_ConstraintInitialPressure" - << "Separator" - << "FEM_ConstraintFlowVelocity"; + *fluid << "FEM_ConstraintInitialFlowVelocity" + << "FEM_ConstraintInitialPressure" + << "Separator" + << "FEM_ConstraintFlowVelocity"; Gui::MenuItem* geom = new Gui::MenuItem; geom->setCommand("&Geometrical analysis features"); - *geom - << "FEM_ConstraintPlaneRotation" - << "FEM_ConstraintSectionPrint" - << "FEM_ConstraintTransform"; + *geom << "FEM_ConstraintPlaneRotation" + << "FEM_ConstraintSectionPrint" + << "FEM_ConstraintTransform"; Gui::MenuItem* mech = new Gui::MenuItem; mech->setCommand("&Mechanical boundary conditions and loads"); - *mech - << "FEM_ConstraintFixed" - << "FEM_ConstraintDisplacement" - << "FEM_ConstraintContact" - << "FEM_ConstraintTie" - << "FEM_ConstraintSpring" - << "Separator" - << "FEM_ConstraintForce" - << "FEM_ConstraintPressure" - << "FEM_ConstraintCentrif" - << "FEM_ConstraintSelfWeight"; + *mech << "FEM_ConstraintFixed" + << "FEM_ConstraintDisplacement" + << "FEM_ConstraintContact" + << "FEM_ConstraintTie" + << "FEM_ConstraintSpring" + << "Separator" + << "FEM_ConstraintForce" + << "FEM_ConstraintPressure" + << "FEM_ConstraintCentrif" + << "FEM_ConstraintSelfWeight"; Gui::MenuItem* thermal = new Gui::MenuItem; thermal->setCommand("&Thermal boundary conditions and loads"); - *thermal - << "FEM_ConstraintInitialTemperature" - << "Separator" - << "FEM_ConstraintHeatflux" - << "FEM_ConstraintTemperature" - << "FEM_ConstraintBodyHeatSource"; + *thermal << "FEM_ConstraintInitialTemperature" + << "Separator" + << "FEM_ConstraintHeatflux" + << "FEM_ConstraintTemperature" + << "FEM_ConstraintBodyHeatSource"; -// Gui::MenuItem* nosolver = new Gui::MenuItem; -// nosolver->setCommand("&Analysis features without solver"); -// *nosolver -// << "FEM_ConstraintFluidBoundary" -// << "Separator" -// << "FEM_ConstraintBearing" -// << "FEM_ConstraintGear" -// << "FEM_ConstraintPulley"; + // Gui::MenuItem* nosolver = new Gui::MenuItem; + // nosolver->setCommand("&Analysis features without solver"); + // *nosolver + // << "FEM_ConstraintFluidBoundary" + // << "Separator" + // << "FEM_ConstraintBearing" + // << "FEM_ConstraintGear" + // << "FEM_ConstraintPulley"; Gui::MenuItem* constants = new Gui::MenuItem; constants->setCommand("&Overwrite Constants"); @@ -311,89 +297,75 @@ Gui::MenuItem* Workbench::setupMenuBar() const Gui::MenuItem* model = new Gui::MenuItem; root->insertItem(item, model); model->setCommand("M&odel"); - *model - << "FEM_Analysis" - << "Separator" - << material - << elegeom - << "Separator" - << elec - << fluid - << geom - << mech - << thermal - << "Separator" -// << nosolver -// << "Separator" - << constants; + *model << "FEM_Analysis" + << "Separator" << material << elegeom << "Separator" << elec << fluid << geom << mech + << thermal + << "Separator" + // << nosolver + // << "Separator" + << constants; Gui::MenuItem* mesh = new Gui::MenuItem; root->insertItem(item, mesh); mesh->setCommand("M&esh"); #ifdef FCWithNetgen - *mesh - << "FEM_MeshNetgenFromShape"; + *mesh << "FEM_MeshNetgenFromShape"; #endif - *mesh - << "FEM_MeshGmshFromShape" - << "Separator" - << "FEM_MeshBoundaryLayer" - << "FEM_MeshRegion" - << "FEM_MeshGroup" - << "Separator" - << "FEM_CreateNodesSet" - << "FEM_FEMMesh2Mesh"; + *mesh << "FEM_MeshGmshFromShape" + << "Separator" + << "FEM_MeshBoundaryLayer" + << "FEM_MeshRegion" + << "FEM_MeshGroup" + << "Separator" + << "FEM_CreateNodesSet" + << "FEM_FEMMesh2Mesh"; Gui::MenuItem* solve = new Gui::MenuItem; root->insertItem(item, solve); solve->setCommand("&Solve"); - *solve - << "FEM_SolverCalculixCxxtools" - << "FEM_SolverCalculiX" - << "FEM_SolverElmer" - << "FEM_SolverMystran" - << "FEM_SolverZ88" - << "Separator" - << "FEM_CompMechEquations" - << "FEM_CompEmEquations" - << "FEM_EquationFlow" - << "FEM_EquationFlux" - << "FEM_EquationHeat" - << "Separator" - << "FEM_SolverControl" - << "FEM_SolverRun"; + *solve << "FEM_SolverCalculixCxxtools" + << "FEM_SolverCalculiX" + << "FEM_SolverElmer" + << "FEM_SolverMystran" + << "FEM_SolverZ88" + << "Separator" + << "FEM_CompMechEquations" + << "FEM_CompEmEquations" + << "FEM_EquationFlow" + << "FEM_EquationFlux" + << "FEM_EquationHeat" + << "Separator" + << "FEM_SolverControl" + << "FEM_SolverRun"; Gui::MenuItem* results = new Gui::MenuItem; root->insertItem(item, results); results->setCommand("&Results"); - *results - << "FEM_ResultsPurge" - << "FEM_ResultShow"; + *results << "FEM_ResultsPurge" + << "FEM_ResultShow"; #ifdef FC_USE_VTK - *results - << "Separator" - << "FEM_PostApplyChanges" - << "FEM_PostPipelineFromResult" - << "Separator" - << "FEM_PostFilterWarp" - << "FEM_PostFilterClipScalar" - << "FEM_PostFilterCutFunction" - << "FEM_PostFilterClipRegion" - << "FEM_PostFilterContours" - << "FEM_PostFilterDataAlongLine" - << "FEM_PostFilterLinearizedStresses" - << "FEM_PostFilterDataAtPoint" - << "Separator" - << "FEM_PostCreateFunctions"; + *results << "Separator" + << "FEM_PostApplyChanges" + << "FEM_PostPipelineFromResult" + << "Separator" + << "FEM_PostFilterWarp" + << "FEM_PostFilterClipScalar" + << "FEM_PostFilterCutFunction" + << "FEM_PostFilterClipRegion" + << "FEM_PostFilterContours" + << "FEM_PostFilterDataAlongLine" + << "FEM_PostFilterLinearizedStresses" + << "FEM_PostFilterDataAtPoint" + << "Separator" + << "FEM_PostCreateFunctions"; #endif Gui::MenuItem* utils = new Gui::MenuItem; root->insertItem(item, utils); utils->setCommand("Utilities"); - *utils - << "FEM_ClippingPlaneAdd" - << "FEM_ClippingPlaneRemoveAll" - << "FEM_Examples"; + *utils << "FEM_ClippingPlaneAdd" + << "FEM_ClippingPlaneRemoveAll" + << "FEM_Examples"; return root; } diff --git a/src/Mod/Fem/Gui/Workbench.h b/src/Mod/Fem/Gui/Workbench.h old mode 100755 new mode 100644 index 59088e8886..558c0dd12f --- a/src/Mod/Fem/Gui/Workbench.h +++ b/src/Mod/Fem/Gui/Workbench.h @@ -27,26 +27,27 @@ #include #include -namespace FemGui { +namespace FemGui +{ /** * @author Werner Mayer */ -class FemGuiExport Workbench : public Gui::StdWorkbench +class FemGuiExport Workbench: public Gui::StdWorkbench { TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - Workbench(); - ~Workbench() override; - void setupContextMenu(const char* recipient, Gui::MenuItem*) const override; + Workbench(); + ~Workbench() override; + void setupContextMenu(const char* recipient, Gui::MenuItem*) const override; protected: - Gui::ToolBarItem* setupToolBars() const override; - Gui::MenuItem* setupMenuBar() const override; + Gui::ToolBarItem* setupToolBars() const override; + Gui::MenuItem* setupMenuBar() const override; }; -} // namespace FemGui +} // namespace FemGui -#endif // FEM_WORKBENCH_H +#endif // FEM_WORKBENCH_H