diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp index 29634cb43b..84a609e406 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp @@ -21,42 +21,33 @@ * * ***************************************************************************/ - #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 #endif +#include "Gui/Command.h" +#include "Gui/Control.h" +#include "Gui/Document.h" +#include "Gui/MainWindow.h" + #include "ViewProviderFemConstraint.h" #include "TaskFemConstraint.h" -#include "Gui/Control.h" -#include "Gui/MainWindow.h" -#include "Gui/Command.h" -#include "Gui/Application.h" -#include "Gui/Document.h" - -#include using namespace FemGui; @@ -65,12 +56,12 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemConstraint, Gui::ViewProviderGeometryObje ViewProviderFemConstraint::ViewProviderFemConstraint() { - ADD_PROPERTY(TextColor,(0.0f,0.0f,0.0f)); - ADD_PROPERTY(FaceColor,(1.0f,0.0f,0.2f)); - ADD_PROPERTY(ShapeColor,(1.0f,0.0f,0.2f)); - ADD_PROPERTY(FontSize,(18)); - ADD_PROPERTY(DistFactor,(1.0)); - ADD_PROPERTY(Mirror,(false)); + ADD_PROPERTY(TextColor, (0.0f, 0.0f, 0.0f)); + ADD_PROPERTY(FaceColor, (1.0f, 0.0f, 0.2f)); + ADD_PROPERTY(ShapeColor, (1.0f, 0.0f, 0.2f)); + ADD_PROPERTY(FontSize, (18)); + ADD_PROPERTY(DistFactor, (1.0)); + ADD_PROPERTY(Mirror, (false)); pFont = new SoFontStyle(); pFont->ref(); @@ -142,12 +133,13 @@ std::vector ViewProviderFemConstraint::claimChildren()cons return std::vector(); } -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 constraint"), 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) @@ -156,18 +148,18 @@ void ViewProviderFemConstraint::onChanged(const App::Property* prop) updateData(prop); } else if (prop == &TextColor) { - const App::Color& c = TextColor.getValue(); - pTextColor->rgb.setValue(c.r,c.g,c.b); + 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(); - pMaterials->rgb.setValue(c.r,c.g,c.b); + 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 } } @@ -188,7 +180,8 @@ std::string ViewProviderFemConstraint::gethideMeshShowPartStr() bool ViewProviderFemConstraint::setEdit(int ModNum) { - Gui::Command::doCommand(Gui::Command::Doc,"%s",ViewProviderFemConstraint::gethideMeshShowPartStr().c_str()); + Gui::Command::doCommand(Gui::Command::Doc, "%s", + ViewProviderFemConstraint::gethideMeshShowPartStr().c_str()); return Gui::ViewProviderGeometryObject::setEdit(ModNum); } @@ -205,9 +198,10 @@ void ViewProviderFemConstraint::unsetEdit(int ModNum) // Notify the Shaft Wizard that we have finished editing // See WizardShaft.py on why we do it this way - Gui::Command::runCommand(Gui::Command::Doc, "Gui.runCommand('PartDesign_WizardShaftCallBack')"); - - } else { + Gui::Command::runCommand(Gui::Command::Doc, + "Gui.runCommand('PartDesign_WizardShaftCallBack')"); + } + else { if (ModNum == ViewProvider::Default) { // when pressing ESC make sure to close the dialog Gui::Control().closeDialog(); @@ -267,21 +261,23 @@ 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); } @@ -291,7 +287,7 @@ void ViewProviderFemConstraint::createCone(SoSeparator* sep, const double height { // Adjust cone so that the tip is on base SoTranslation* trans = new SoTranslation(); - trans->translation.setValue(SbVec3f(0,-height/2,0)); + trans->translation.setValue(SbVec3f(0, -height / 2, 0)); sep->addChild(trans); SoCone* cone = new SoCone(); cone->height.setValue(height); @@ -307,21 +303,23 @@ SoSeparator* ViewProviderFemConstraint::createCone(const double height, const do return sep; } -void ViewProviderFemConstraint::updateCone(const SoNode* node, const int idx, const double height, const double radius) +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)); - trans->translation.setValue(SbVec3f(0,-height/2,0)); - SoCone* cone = static_cast(sep->getChild(idx+1)); + 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)); cone->height.setValue(height); cone->bottomRadius.setValue(radius); } #define CYLINDER_CHILDREN 1 -void ViewProviderFemConstraint::createCylinder(SoSeparator* sep, const double height, const double radius) +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); @@ -335,36 +333,40 @@ 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,9 +376,9 @@ void ViewProviderFemConstraint::updateCube(const SoNode* node, const int idx, co 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()); - createCylinder(sep, length-radius, radius/5); + createCone(sep, radius, radius / 2); + createPlacement(sep, SbVec3f(0, -radius / 2 - (length - radius) / 2, 0), SbRotation()); + createCylinder(sep, length - radius, radius / 5); } SoSeparator* ViewProviderFemConstraint::createArrow(const double length, const double radius) @@ -386,21 +388,23 @@ SoSeparator* ViewProviderFemConstraint::createArrow(const double length, const d return sep; } -void ViewProviderFemConstraint::updateArrow(const SoNode* node, const int idx, const double length, const double radius) +void ViewProviderFemConstraint::updateArrow(const SoNode *node, const int idx, const double length, + const double radius) { - 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), SbRotation()); - updateCylinder(sep, idx+CONE_CHILDREN+PLACEMENT_CHILDREN, length-radius, radius/5); + 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), + 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) { - createCube(sep, width, width, length/2); - createPlacement(sep, SbVec3f(0, -length/2, 0), SbRotation()); - createCylinder(sep, length/2, width/4); + createCube(sep, width, width, length / 2); + createPlacement(sep, SbVec3f(0, -length / 2, 0), SbRotation()); + createCylinder(sep, length / 2, width / 4); } SoSeparator* ViewProviderFemConstraint::createSpring(const double length, const double width) @@ -410,85 +414,109 @@ SoSeparator* ViewProviderFemConstraint::createSpring(const double length, const return sep; } -void ViewProviderFemConstraint::updateSpring(const SoNode* node, const int idx, const double length, const double width) +void ViewProviderFemConstraint::updateSpring(const SoNode *node, const int idx, const double length, + const double width) { - 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); + 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); } #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), SbRotation()); - createCube(sep, width, width, width/4); + 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), + 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); - updateCone(sep, idx, height-width/4, height-width/4); - updatePlacement(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); + const SoSeparator *sep = static_cast(node); + updateCone(sep, idx, height - width / 4, height - width / 4); + updatePlacement( + 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), SbRotation()); + 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, const bool gap) +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, const bool gap) +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, SbVec3f(0, -(height)/2-width/8 - (gap ? 1.0 : 0.0) * width/8, 0), SbRotation()); + 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), SbRotation()); + createCylinder(sep, width / 2, height / 2); + 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, const bool gap) +void ViewProviderFemConstraint::updateRotation(const SoNode *node, const int idx, + const double height, const double width, + const bool gap) { - const SoSeparator* sep = static_cast(node); - updateCylinder(sep, idx, height/2, width/2); - updatePlacement(sep, idx+CYLINDER_CHILDREN, SbVec3f(0, -(height)*2-width/8 - (gap ? 1.0 : 0.0) * width/8, 0), SbRotation()); + const SoSeparator *sep = static_cast(node); + updateCylinder(sep, idx, height / 2, width / 2); + 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 (QObjectList::const_iterator o = parent->children().begin(); o != parent->children().end(); o++) { + for (QObjectList::const_iterator o = parent->children().begin(); o != parent->children().end(); + o++) { if ((*o)->objectName() == name) return *o; if (!(*o)->children().empty()) { - QObject* result = findChildByName(*o, name); + QObject *result = findChildByName(*o, name); if (result) return result; } @@ -513,7 +541,8 @@ void ViewProviderFemConstraint::checkForWizard() QTabWidget* tw = cw->findChild(QString::fromLatin1("combiTab")); if (!tw) return; - QStackedWidget* sw = tw->findChild(QString::fromLatin1("qt_tabwidget_stackedwidget")); + QStackedWidget *sw = + tw->findChild(QString::fromLatin1("qt_tabwidget_stackedwidget")); if (!sw) return; QScrollArea* sa = sw->findChild(); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.h b/src/Mod/Fem/Gui/ViewProviderFemConstraint.h index aa24f428b2..9d485b25e6 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.h @@ -24,11 +24,13 @@ #ifndef GUI_VIEWPROVIDERFEMCONSTRAINT_H #define GUI_VIEWPROVIDERFEMCONSTRAINT_H +#include +#include + #include #include #include -#include -#include + class SoFontStyle; class SoText2; @@ -60,9 +62,12 @@ public: App::PropertyBool Mirror; void attach(App::DocumentObject *) override; - void updateData(const App::Property* prop) override { Gui::ViewProviderGeometryObject::updateData(prop); } + 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; void setupContextMenu(QMenu*, QObject*, const char*) override; @@ -78,32 +83,48 @@ 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, 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, 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, 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, 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 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 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 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, + 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; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp index f3ecc15cc7..bb7bf6b7d0 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp @@ -21,27 +21,21 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include - -# include -# include -# include - # include +# include +# include +# include #endif -#include "ViewProviderFemConstraintBearing.h" -#include -#include "TaskFemConstraintBearing.h" -#include "Gui/Control.h" -#include "Gui/MainWindow.h" - #include +#include "Gui/Control.h" +#include +#include "ViewProviderFemConstraintBearing.h" +#include "TaskFemConstraintBearing.h" + using namespace FemGui; @@ -112,7 +106,7 @@ bool ViewProviderFemConstraintBearing::setEdit(int ModNum) 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 (strcmp(prop->getName(),"References") == 0) Base::Console().Error("\n"); // enable a breakpoint here @@ -129,10 +123,11 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop) SbVec3f b(base.x, base.y, base.z); SbVec3f dir(normal.x, normal.y, normal.z); - SbRotation rot(SbVec3f(0,-1,0), dir); + SbRotation rot(SbVec3f(0, -1, 0), dir); createPlacement(pShapeSep, b, rot); - pShapeSep->addChild(createFixed(radius/2, radius/2 * 1.5, pcConstraint->AxialFree.getValue())); + pShapeSep->addChild( + createFixed(radius / 2, radius / 2 * 1.5, pcConstraint->AxialFree.getValue())); } else if (strcmp(prop->getName(),"AxialFree") == 0) { if (pShapeSep->getNumChildren() > 0) { // Change the symbol @@ -143,11 +138,11 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop) SbVec3f b(base.x, base.y, base.z); SbVec3f dir(normal.x, normal.y, normal.z); - SbRotation rot(SbVec3f(0,-1,0), dir); + SbRotation rot(SbVec3f(0, -1, 0), dir); updatePlacement(pShapeSep, 0, b, rot); const SoSeparator* sep = static_cast(pShapeSep->getChild(2)); - updateFixed(sep, 0, radius/2, radius/2 * 1.5, pcConstraint->AxialFree.getValue()); + updateFixed(sep, 0, radius / 2, radius / 2 * 1.5, pcConstraint->AxialFree.getValue()); } } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp index 1188984884..4f18755a96 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp @@ -23,30 +23,21 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include - +# include +# include +# include # include # include -# include -# include -# include -# include -# include -# include -# include -# include #endif #include "Mod/Fem/App/FemConstraintContact.h" -#include "TaskFemConstraintContact.h" -#include "ViewProviderFemConstraintContact.h" -#include #include +#include "ViewProviderFemConstraintContact.h" +#include "TaskFemConstraintContact.h" + using namespace FemGui; @@ -56,7 +47,7 @@ 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 - ADD_PROPERTY(FaceColor,(0.2f,0.3f,0.2f)); + ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f)); } ViewProviderFemConstraintContact::~ViewProviderFemConstraintContact() @@ -134,30 +125,30 @@ void ViewProviderFemConstraintContact::updateData(const App::Property* prop) //first move to correct position SoTranslation* trans = new SoTranslation(); - SbVec3f newPos=base+scaledheight*dir*0.12f; + SbVec3f newPos = base + scaledheight * dir * 0.12f; trans->translation.setValue(newPos); sep->addChild(trans); //adjust orientation - SoRotation* rot = new SoRotation(); - rot->rotation.setValue(SbRotation(SbVec3f(0,1,0),dir)); + 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 + 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(); - cbe->depth.setValue(scaledlength*0.5); - cbe->height.setValue(scaledheight*0.25); - cbe->width.setValue(scaledwidth*0.75); + 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(); - trans2->translation.setValue(SbVec3f(0,0,0)); + SoTranslation *trans2 = new SoTranslation(); + trans2->translation.setValue(SbVec3f(0, 0, 0)); sep->addChild(trans2); pShapeSep->addChild(sep); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp index 5e92634a2d..4ee6713b58 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp @@ -23,24 +23,20 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include - -# include -# include -# include +# include +# include # include +# include #endif #include "Mod/Fem/App/FemConstraintDisplacement.h" -#include "TaskFemConstraintDisplacement.h" -#include "ViewProviderFemConstraintDisplacement.h" -#include #include +#include "ViewProviderFemConstraintDisplacement.h" +#include "TaskFemConstraintDisplacement.h" + using namespace FemGui; @@ -49,7 +45,7 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintDisplacement, FemGui::ViewProvi ViewProviderFemConstraintDisplacement::ViewProviderFemConstraintDisplacement() { sPixmap = "FEM_ConstraintDisplacement"; - ADD_PROPERTY(FaceColor,(0.2f,0.3f,0.2f)); + ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f)); } ViewProviderFemConstraintDisplacement::~ViewProviderFemConstraintDisplacement() @@ -64,7 +60,8 @@ bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum) // object unsets and sets its edit mode without closing // the task panel Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintDisplacement *constrDlg = qobject_cast(dlg); + TaskDlgFemConstraintDisplacement *constrDlg = + qobject_cast(dlg); if (constrDlg && constrDlg->getConstraintView() != this) constrDlg = nullptr; // another constraint left open its task panel if (dlg && !constrDlg) { @@ -99,7 +96,8 @@ bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum) 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()); float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); bool xFree = pcConstraint->xFree.getValue(); @@ -189,107 +187,96 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop Gui::coinRemoveAllChildren(pShapeSep); #endif - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::const_iterator p = points.begin(); p != points.end(); + p++) { SbVec3f base(p->x, p->y, p->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 - SbRotation roty(SbVec3f(0,-1,0), diry); - SbRotation rotz(SbVec3f(0,-1,0), dirz); + 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 - if(!xFree) - { + if (!xFree) { SbMatrix mx; - mx.setTransform(base, rotx, SbVec3f(1,1,1)); + mx.setTransform(base, rotx, SbVec3f(1, 1, 1)); matricesx[idx] = mx; idx++; } - if(!yFree) - { + if (!yFree) { SbMatrix my; - my.setTransform(base, roty, SbVec3f(1,1,1)); + my.setTransform(base, roty, SbVec3f(1, 1, 1)); matricesy[idy] = my; idy++; } - if(!zFree) - { + if (!zFree) { SbMatrix mz; - mz.setTransform(base, rotz, SbVec3f(1,1,1)); + mz.setTransform(base, rotz, SbVec3f(1, 1, 1)); matricesz[idz] = mz; idz++; } //OvG: Rotation indication - if(!rotxFree) - { + if (!rotxFree) { SbMatrix mrotx; - mrotx.setTransform(base, rotx, SbVec3f(1,1,1)); + mrotx.setTransform(base, rotx, SbVec3f(1, 1, 1)); matricesrotx[idrotx] = mrotx; idrotx++; } - if(!rotyFree) - { + if (!rotyFree) { SbMatrix mroty; - mroty.setTransform(base, roty, SbVec3f(1,1,1)); + mroty.setTransform(base, roty, SbVec3f(1, 1, 1)); matricesroty[idroty] = mroty; idroty++; } - if(!rotzFree) - { + if (!rotzFree) { SbMatrix mrotz; - mrotz.setTransform(base, rotz, SbVec3f(1,1,1)); + mrotz.setTransform(base, rotz, SbVec3f(1, 1, 1)); matricesrotz[idrotz] = mrotz; idrotz++; } #else //OvG: Translation indication - if(!xFree) - { - SoSeparator* sepx = new SoSeparator(); + if (!xFree) { + 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(); + if (!yFree) { + 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(); + if (!zFree) { + 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 - if(!rotxFree) - { - SoSeparator* sepx = new SoSeparator(); + if (!rotxFree) { + 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(); + if (!rotyFree) { + 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(); + if (!rotzFree) { + 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/ViewProviderFemConstraintFixed.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp index df75f5493d..b6c0b3a959 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp @@ -21,28 +21,22 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include - -# include -# include -# include -# include - # include +# include +# include +# include +# include #endif -#include "ViewProviderFemConstraintFixed.h" #include -#include "TaskFemConstraintFixed.h" - #include "Gui/Control.h" -#include +#include "ViewProviderFemConstraintFixed.h" +#include "TaskFemConstraintFixed.h" + using namespace FemGui; @@ -115,7 +109,7 @@ bool ViewProviderFemConstraintFixed::setEdit(int ModNum) void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintFixed* pcConstraint = static_cast(this->getObject()); + 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(); @@ -147,13 +141,14 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) Gui::coinRemoveAllChildren(pShapeSep); #endif - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::const_iterator p = points.begin(); p != points.end(); + p++) { SbVec3f base(p->x, p->y, p->z); SbVec3f dir(n->x, n->y, n->z); - SbRotation rot(SbVec3f(0,-1,0), dir); + 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 diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp index b8f4b7f174..3eedbb68b1 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp @@ -21,27 +21,23 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include - -# include -# include -# include -# include - # include +# include +# include +# include +# include +# include #endif -#include "ViewProviderFemConstraintFluidBoundary.h" #include -#include "TaskFemConstraintFluidBoundary.h" #include "Gui/Control.h" -#include +#include "ViewProviderFemConstraintFluidBoundary.h" +#include "TaskFemConstraintFluidBoundary.h" + using namespace FemGui; @@ -63,7 +59,8 @@ bool ViewProviderFemConstraintFluidBoundary::setEdit(int ModNum) // 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); + TaskDlgFemConstraintFluidBoundary *constrDlg = + qobject_cast(dlg); if (constrDlg && constrDlg->getConstraintView() != this) constrDlg = nullptr; // another constraint left open its task panel if (dlg && !constrDlg) { @@ -109,7 +106,7 @@ bool ViewProviderFemConstraintFluidBoundary::setEdit(int ModNum) //Rendering: Combination of ConstraintFixed and ConstraintForce #define ARROWLENGTH (4) -#define ARROWHEADRADIUS (ARROWLENGTH/3.0f) +#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 @@ -125,28 +122,17 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro float scaledlength = ARROWLENGTH * pcConstraint->Scale.getValue(); std::string boundaryType = pcConstraint->BoundaryType.getValueAsString(); - if (strcmp(prop->getName(),"BoundaryType") == 0) - { + if (strcmp(prop->getName(), "BoundaryType") == 0) { if (boundaryType == "wall") - { - FaceColor.setValue(0.0,1.0,1.0); - } + FaceColor.setValue(0.0, 1.0, 1.0); else if (boundaryType == "interface") - { - FaceColor.setValue(0.0,1.0,0.0); - } + FaceColor.setValue(0.0, 1.0, 0.0); else if (boundaryType == "freestream") - { - FaceColor.setValue(1.0,1.0,0.0); - } - else if(boundaryType == "inlet") - { - FaceColor.setValue(1.0,0.0,0.0); - } + FaceColor.setValue(1.0, 1.0, 0.0); + else if (boundaryType == "inlet") + FaceColor.setValue(1.0, 0.0, 0.0); else //(boundaryType == "outlet") - { - FaceColor.setValue(0.0,0.0,1.0); - } + FaceColor.setValue(0.0, 0.0, 1.0); } if (boundaryType == "inlet" || boundaryType == "outlet"){ @@ -182,9 +168,10 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro 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 (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::const_iterator p = points.begin(); p != points.end(); + p++) { SbVec3f base(p->x, p->y, p->z); if (forceDirection.GetAngle(normal) < M_PI_2) // Move arrow so it doesn't disappear inside the solid base = base + dir * scaledlength; //OvG: Scaling @@ -215,7 +202,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro } SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); - SbRotation rot(SbVec3f(0,1,0), dir); + SbRotation rot(SbVec3f(0, 1, 0), dir); const std::vector& points = pcConstraint->Points.getValues(); @@ -226,13 +213,14 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro #endif int idx = 0; - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::const_iterator p = points.begin(); p != points.end(); + p++) { SbVec3f base(p->x, p->y, p->z); 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)); + m.setTransform(base, rot, SbVec3f(1, 1, 1)); matrices[idx] = m; #else SoSeparator* sep = static_cast(pShapeSep->getChild(idx)); @@ -279,7 +267,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { SbVec3f base(p->x, p->y, p->z); SbVec3f dir(n->x, n->y, n->z); - SbRotation rot(SbVec3f(0,-1,0), dir); + SbRotation rot(SbVec3f(0, -1, 0), dir); #ifdef USE_MULTIPLE_COPY SbMatrix m; m.setTransform(base, rot, SbVec3f(1,1,1)); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp index 0384e77fa4..6ba0924809 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp @@ -21,27 +21,23 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include - -# include -# include -# include -# include - # include +# include +# include +# include +# include +# include #endif -#include "ViewProviderFemConstraintForce.h" #include -#include "TaskFemConstraintForce.h" #include "Gui/Control.h" -#include +#include "ViewProviderFemConstraintForce.h" +#include "TaskFemConstraintForce.h" + using namespace FemGui; @@ -109,7 +105,7 @@ bool ViewProviderFemConstraintForce::setEdit(int ModNum) } #define ARROWLENGTH (4) -#define ARROWHEADRADIUS (ARROWLENGTH/3.0f) +#define ARROWHEADRADIUS (ARROWLENGTH / 3.0f) //#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled arrows on initial drawing - so disable void ViewProviderFemConstraintForce::updateData(const App::Property* prop) @@ -153,13 +149,15 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); SbRotation rot(SbVec3f(0,1,0), dir); - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::const_iterator p = points.begin(); p != points.end(); + p++) { SbVec3f base(p->x, p->y, p->z); - if (forceDirection.GetAngle(normal) < M_PI_2) // Move arrow so it doesn't disappear inside the solid + 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 @@ -181,7 +179,7 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) forceDirection = normal; SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); - SbRotation rot(SbVec3f(0,1,0), dir); + SbRotation rot(SbVec3f(0, 1, 0), dir); const std::vector& points = pcConstraint->Points.getValues(); @@ -192,13 +190,14 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) #endif int idx = 0; - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::const_iterator p = points.begin(); p != points.end(); + p++) { SbVec3f base(p->x, p->y, p->z); 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)); + m.setTransform(base, rot, SbVec3f(1, 1, 1)); matrices[idx] = m; #else SoSeparator* sep = static_cast(pShapeSep->getChild(idx)); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp index d732023331..594804cbac 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp @@ -21,27 +21,24 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include - -# include -# include -# include -# include - # include +# include +# include +# include +# include +# include #endif -#include "ViewProviderFemConstraintGear.h" -#include -#include "TaskFemConstraintGear.h" -#include "Gui/Control.h" - #include +#include "Gui/Control.h" +#include + +#include "ViewProviderFemConstraintGear.h" +#include "TaskFemConstraintGear.h" + using namespace FemGui; @@ -122,7 +119,7 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) Base::Vector3d axis = pcConstraint->Axis.getValue(); Base::Vector3d direction = pcConstraint->DirectionVector.getValue(); if (direction.Length() < Precision::Confusion()) - direction = Base::Vector3d(0,1,0); + direction = Base::Vector3d(0, 1, 0); double radius = pcConstraint->Radius.getValue(); double dia = pcConstraint->Diameter.getValue(); if (dia < 2 * radius) @@ -145,7 +142,7 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) Base::Vector3d axis = pcConstraint->Axis.getValue(); Base::Vector3d direction = pcConstraint->DirectionVector.getValue(); if (direction.Length() < Precision::Confusion()) - direction = Base::Vector3d(0,1,0); + direction = Base::Vector3d(0, 1, 0); double dia = pcConstraint->Diameter.getValue(); double radius = pcConstraint->Radius.getValue(); if (dia < 2 * radius) diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp index 67b5901d47..e2462035f8 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp @@ -23,30 +23,23 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include - -# include -# include -# include -# include # include -# include -# include -# include # include -# include +# include +# include +# include +# include #endif -#include "Mod/Fem/App/FemConstraintHeatflux.h" -#include "TaskFemConstraintHeatflux.h" -#include "ViewProviderFemConstraintHeatflux.h" -#include #include +#include "Mod/Fem/App/FemConstraintHeatflux.h" + +#include "ViewProviderFemConstraintHeatflux.h" +#include "TaskFemConstraintHeatflux.h" + using namespace FemGui; @@ -55,7 +48,7 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintHeatflux, FemGui::ViewProviderF ViewProviderFemConstraintHeatflux::ViewProviderFemConstraintHeatflux() { sPixmap = "FEM_ConstraintHeatflux"; - ADD_PROPERTY(FaceColor,(0.2f,0.3f,0.2f)); + ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f)); } ViewProviderFemConstraintHeatflux::~ViewProviderFemConstraintHeatflux() @@ -133,56 +126,56 @@ void ViewProviderFemConstraintHeatflux::updateData(const App::Property* prop) ///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; + SoTranslation *trans = new SoTranslation(); + SbVec3f newPos = base + scaledradius * dir * 0.7f; trans->translation.setValue(newPos); sep->addChild(trans); //adjust orientation - SoRotation* rot = new SoRotation(); - rot->rotation.setValue(SbRotation(SbVec3f(0,1,0),dir)); + 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 + 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(); - sph->radius.setValue(scaledradius*0.75); + 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)); + 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); + 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.375,0)); + 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 + 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); + 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(); - trans4->translation.setValue(SbVec3f(0,-scaledheight*0.375,0)); + //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(); - cyl3->height.setValue(scaledheight*0.05); - cyl3->radius.setValue(scaledradius*1); + //draw a cylinder + SoCylinder *cyl3 = new SoCylinder(); + cyl3->height.setValue(scaledheight * 0.05); + cyl3->radius.setValue(scaledradius * 1); sep->addChild(cyl3); pShapeSep->addChild(sep); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp index 1bb17c6b0e..84c1e1ef82 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintTransform.cpp @@ -24,36 +24,19 @@ * * ***************************************************************************/ - #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 - -#include "Mod/Fem/App/FemConstraintTransform.h" -#include "TaskFemConstraintTransform.h" -#include "ViewProviderFemConstraintTransform.h" -#include #include +#include "Mod/Fem/App/FemConstraintTransform.h" +#include "ViewProviderFemConstraintTransform.h" +#include "TaskFemConstraintTransform.h" using namespace FemGui; @@ -63,8 +46,6 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintTransform, FemGui::ViewProvider ViewProviderFemConstraintTransform::ViewProviderFemConstraintTransform() { sPixmap = "FEM_ConstraintTransform"; - // - //ADD_PROPERTY(FaceColor,(0.0f,0.2f,0.8f)); } ViewProviderFemConstraintTransform::~ViewProviderFemConstraintTransform() @@ -79,7 +60,8 @@ bool ViewProviderFemConstraintTransform::setEdit(int ModNum) // object unsets and sets its edit mode without closing // the task panel Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFemConstraintTransform *constrDlg = qobject_cast(dlg); + TaskDlgFemConstraintTransform *constrDlg = + qobject_cast(dlg); if (constrDlg && constrDlg->getConstraintView() != this) constrDlg = nullptr; // another constraint left open its task panel if (dlg && !constrDlg) { @@ -110,17 +92,20 @@ bool ViewProviderFemConstraintTransform::setEdit(int ModNum) #define HEIGHTAXIS (20) #define RADIUSAXIS (0.8) #define ARROWLENGTH (3) -#define ARROWHEADRADIUS (ARROWLENGTH/3) +#define ARROWHEADRADIUS (ARROWLENGTH / 3) #define LENGTHDISC (0.25) #define RADIUSDISC (0.8) void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - Fem::ConstraintTransform* pcConstraint = static_cast(this->getObject()); - float scaledradiusaxis = RADIUSAXIS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + Fem::ConstraintTransform *pcConstraint = + static_cast(this->getObject()); + float scaledradiusaxis = + 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 + float scaledheadradiusA = + 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") { @@ -135,7 +120,8 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) // Points and Normals are always updated together Gui::coinRemoveAllChildren(pShapeSep); - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::const_iterator p = points.begin(); p != points.end(); + p++) { SbVec3f base(p->x, p->y, p->z); SbVec3f basex(p->x, p->y, p->z); SbVec3f basey(p->x, p->y, p->z); @@ -233,17 +219,17 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) SoSeparator* sep = new SoSeparator(); SoMaterial* myMaterial = new SoMaterial; - myMaterial->diffuseColor.set1Value(0,SbColor(0,0,1));//RGB + 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 + 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 + myMaterialx->diffuseColor.set1Value(0, SbColor(1, 0, 0)); //RGB sepx->addChild(myMaterialx); createPlacement(sepx, basex, rotx); @@ -253,11 +239,11 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) SoSeparator* sepy = new SoSeparator(); SoMaterial* myMaterialy = new SoMaterial; - myMaterialy->diffuseColor.set1Value(0,SbColor(0,1,0));//RGB + 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 + createArrow(sepy, scaledlengthA * 0.65, scaledheadradiusA * 0.65); //OvG: Scaling pShapeSep->addChild(sepy); n++; @@ -287,14 +273,15 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) 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 (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::const_iterator p = points.begin(); p != points.end(); + p++) { SbVec3f base(p->x, p->y, p->z); SbVec3f dir(n->x, n->y, n->z); base = base + dir * scaledlengthA; //OvG: Scaling @@ -302,7 +289,7 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop) 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