diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp index 3fd782d06..a0e44ecbb 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp @@ -72,12 +72,9 @@ ViewProviderFemConstraint::ViewProviderFemConstraint() pTextColor = new SoBaseColor(); pTextColor->ref(); - pMaterials = new SoMaterial(); + pMaterials = new SoBaseColor(); pMaterials->ref(); - pMaterials->diffuseColor.setValue(1.0f, 0.0f, 0.2f); - pMaterials->transparency.setValue(0.1f); - //pMaterials->ambientColor.setValue(0.8f, 0.8f, 0.8f); - //pMaterials->shininess.setValue(1.0); + pMaterials->rgb.setValue(1.0f, 0.0f, 0.2f); pShapeSep = new SoSeparator(); pShapeSep->ref(); @@ -157,7 +154,7 @@ void ViewProviderFemConstraint::onChanged(const App::Property* prop) } else if (prop == &FaceColor) { const App::Color& c = FaceColor.getValue(); - pMaterials->diffuseColor.setValue(c.r,c.g,c.b); + pMaterials->rgb.setValue(c.r,c.g,c.b); } else if (prop == &FontSize) { pFont->size = FontSize.getValue(); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.h b/src/Mod/Fem/Gui/ViewProviderFemConstraint.h index 82e1803d5..7d370a70d 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.h @@ -102,7 +102,7 @@ private: SoFontStyle * pFont; SoText2 * pLabel; SoBaseColor * pTextColor; - SoMaterial * pMaterials; + SoBaseColor * pMaterials; protected: SoSeparator * pShapeSep; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp index c4358dfa3..1a803d1df 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp @@ -107,24 +107,22 @@ bool ViewProviderFemConstraintFixed::setEdit(int ModNum) #define HEIGHT 4 #define WIDTH (1.5*HEIGHT) +#define USE_MULTIPLE_COPY void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes Fem::ConstraintFixed* pcConstraint = static_cast(this->getObject()); - /* - // This has a HUGE performance penalty as opposed to separate nodes for every symbol - // The problem seems to be SoCone +#ifdef USE_MULTIPLE_COPY if (pShapeSep->getNumChildren() == 0) { // Set up the nodes SoMultipleCopy* cp = new SoMultipleCopy(); - cp->ref(); cp->matrix.setNum(0); cp->addChild((SoNode*)createFixed(HEIGHT, WIDTH)); pShapeSep->addChild(cp); } - */ +#endif if (strcmp(prop->getName(),"Points") == 0) { const std::vector& points = pcConstraint->Points.getValues(); @@ -133,32 +131,36 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) return; std::vector::const_iterator n = normals.begin(); - // Note: Points and Normals are always updated together - pShapeSep->removeAllChildren(); - - /* +#ifdef USE_MULTIPLE_COPY SoMultipleCopy* cp = static_cast(pShapeSep->getChild(0)); cp->matrix.setNum(points.size()); + SbMatrix* matrices = cp->matrix.startEditing(); int idx = 0; - */ +#else + // Note: Points and Normals are always updated together + pShapeSep->removeAllChildren(); +#endif 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); - /* +#ifdef USE_MULTIPLE_COPY SbMatrix m; m.setTransform(base, rot, SbVec3f(1,1,1)); - cp->matrix.set1Value(idx, m); - idx++ - */ + matrices[idx] = m; + idx++; +#else SoSeparator* sep = new SoSeparator(); createPlacement(sep, base, rot); createFixed(sep, HEIGHT, WIDTH); pShapeSep->addChild(sep); - +#endif n++; } +#ifdef USE_MULTIPLE_COPY + cp->matrix.finishEditing(); +#endif } ViewProviderFemConstraint::updateData(prop); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp index b3f2727b3..d9466e5b9 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp @@ -106,15 +106,14 @@ bool ViewProviderFemConstraintForce::setEdit(int ModNum) #define ARROWLENGTH 9 #define ARROWHEADRADIUS (ARROWLENGTH/3) +#define USE_MULTIPLE_COPY void ViewProviderFemConstraintForce::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes Fem::ConstraintForce* pcConstraint = static_cast(this->getObject()); - /* - // This has a HUGE performance penalty as opposed to separate nodes for every symbol - // The problem seems to be SoCone +#ifdef USE_MULTIPLE_COPY if (pShapeSep->getNumChildren() == 0) { // Set up the nodes SoMultipleCopy* cp = new SoMultipleCopy(); @@ -123,12 +122,20 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) cp->addChild((SoNode*)createArrow(ARROWLENGTH, ARROWHEADRADIUS)); pShapeSep->addChild(cp); } - */ +#endif if (strcmp(prop->getName(),"Points") == 0) { + const std::vector& points = pcConstraint->Points.getValues(); + +#ifdef USE_MULTIPLE_COPY + SoMultipleCopy* cp = static_cast(pShapeSep->getChild(0)); + cp->matrix.setNum(points.size()); + SbMatrix* matrices = cp->matrix.startEditing(); + int idx = 0; +#else // Redraw all arrows pShapeSep->removeAllChildren(); - +#endif // This should always point outside of the solid Base::Vector3d normal = pcConstraint->NormalDirection.getValue(); @@ -140,29 +147,27 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z); SbRotation rot(SbVec3f(0,1,0), dir); - const std::vector& points = pcConstraint->Points.getValues(); - - /* - SoMultipleCopy* cp = static_cast(pShapeSep->getChild(0)); - cp->matrix.setNum(points.size()); - int idx = 0;*/ - 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 * ARROWLENGTH; - /* +#ifdef USE_MULTIPLE_COPY SbMatrix m; m.setTransform(base, rot, SbVec3f(1,1,1)); - cp->matrix.set1Value(idx, m); + matrices[idx] = m; idx++; - */ +#else SoSeparator* sep = new SoSeparator(); createPlacement(sep, base, rot); createArrow(sep, ARROWLENGTH, ARROWHEADRADIUS); pShapeSep->addChild(sep); +#endif } - } else if (strcmp(prop->getName(),"DirectionVector") == 0) { // Note: "Reversed" also triggers "DirectionVector" +#ifdef USE_MULTIPLE_COPY + cp->matrix.finishEditing(); +#endif + } + else if (strcmp(prop->getName(),"DirectionVector") == 0) { // Note: "Reversed" also triggers "DirectionVector" // Re-orient all arrows Base::Vector3d normal = pcConstraint->NormalDirection.getValue(); Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue(); @@ -174,26 +179,31 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) const std::vector& points = pcConstraint->Points.getValues(); - /* +#ifdef USE_MULTIPLE_COPY SoMultipleCopy* cp = static_cast(pShapeSep->getChild(0)); cp->matrix.setNum(points.size()); - */ + SbMatrix* matrices = cp->matrix.startEditing(); +#endif int idx = 0; 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 * ARROWLENGTH; - /* +#ifdef USE_MULTIPLE_COPY SbMatrix m; m.setTransform(base, rot, SbVec3f(1,1,1)); - cp->matrix.set1Value(idx, m);*/ - + matrices[idx] = m; +#else SoSeparator* sep = static_cast(pShapeSep->getChild(idx)); updatePlacement(sep, 0, base, rot); updateArrow(sep, 2, ARROWLENGTH, ARROWHEADRADIUS); +#endif idx++; } +#ifdef USE_MULTIPLE_COPY + cp->matrix.finishEditing(); +#endif } ViewProviderFemConstraint::updateData(prop);