Fem: Add transform for extra symbol in constraints
This commit is contained in:
committed by
Chris Hennes
parent
2d26fb5426
commit
b5655c3a8a
@@ -33,6 +33,7 @@
|
||||
#include <Inventor/nodes/SoRotation.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <Inventor/nodes/SoShapeHints.h>
|
||||
#include <Inventor/nodes/SoTransform.h>
|
||||
#include <Inventor/nodes/SoTranslation.h>
|
||||
#include <QAction>
|
||||
#include <QDockWidget>
|
||||
@@ -61,6 +62,7 @@ ViewProviderFemConstraint::ViewProviderFemConstraint()
|
||||
: rotateSymbol(true)
|
||||
, pSymbol(nullptr)
|
||||
, pExtraSymbol(nullptr)
|
||||
, pExtraTrans(nullptr)
|
||||
, ivFile(nullptr)
|
||||
, wizardWidget(nullptr)
|
||||
, wizardSubLayout(nullptr)
|
||||
@@ -70,6 +72,8 @@ ViewProviderFemConstraint::ViewProviderFemConstraint()
|
||||
pShapeSep->ref();
|
||||
pMultCopy = new SoMultipleCopy();
|
||||
pMultCopy->ref();
|
||||
pExtraTrans = new SoTransform();
|
||||
pExtraTrans->ref();
|
||||
|
||||
ShapeAppearance.setDiffuseColor(1.0f, 0.0f, 0.2f);
|
||||
ShapeAppearance.setSpecularColor(0.0f, 0.0f, 0.0f);
|
||||
@@ -80,6 +84,7 @@ ViewProviderFemConstraint::ViewProviderFemConstraint()
|
||||
ViewProviderFemConstraint::~ViewProviderFemConstraint()
|
||||
{
|
||||
pMultCopy->unref();
|
||||
pExtraTrans->unref();
|
||||
pShapeSep->unref();
|
||||
}
|
||||
|
||||
@@ -129,6 +134,7 @@ void ViewProviderFemConstraint::loadSymbol(const char* fileName)
|
||||
if (nodes->getNumChildren() == 2) {
|
||||
pExtraSymbol = dynamic_cast<SoSeparator*>(nodes->getChild(1));
|
||||
if (pExtraSymbol) {
|
||||
pShapeSep->addChild(pExtraTrans);
|
||||
pShapeSep->addChild(pExtraSymbol);
|
||||
}
|
||||
}
|
||||
@@ -221,6 +227,8 @@ void ViewProviderFemConstraint::updateSymbol()
|
||||
}
|
||||
|
||||
pMultCopy->matrix.finishEditing();
|
||||
|
||||
transformExtraSymbol();
|
||||
}
|
||||
|
||||
void ViewProviderFemConstraint::transformSymbol(const Base::Vector3d& point,
|
||||
@@ -239,6 +247,17 @@ void ViewProviderFemConstraint::transformSymbol(const Base::Vector3d& point,
|
||||
mat.setTransform(tra, rot, scale);
|
||||
}
|
||||
|
||||
void ViewProviderFemConstraint::transformExtraSymbol() const
|
||||
{
|
||||
if (pExtraTrans) {
|
||||
auto obj = static_cast<const Fem::Constraint*>(this->getObject());
|
||||
float s = obj->getScaleFactor();
|
||||
SbMatrix mat;
|
||||
mat.setScale(s);
|
||||
pExtraTrans->setMatrix(mat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// OvG: Visibility automation show parts and hide meshes on activation of a constraint
|
||||
std::string ViewProviderFemConstraint::gethideMeshShowPartStr(const std::string showConstr)
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
class SbRotation;
|
||||
class SoMultipleCopy;
|
||||
class SoTransform;
|
||||
|
||||
namespace FemGui
|
||||
{
|
||||
@@ -68,6 +69,7 @@ public:
|
||||
|
||||
SoSeparator* getSymbolSeparator() const;
|
||||
SoSeparator* getExtraSymbolSeparator() const;
|
||||
SoTransform* getExtraSymbolTransform() const;
|
||||
// Apply rotation on copies of the constraint symbol
|
||||
void setRotateSymbol(bool rotate);
|
||||
bool getRotateSymbol() const;
|
||||
@@ -94,6 +96,7 @@ protected:
|
||||
void updateSymbol();
|
||||
virtual void
|
||||
transformSymbol(const Base::Vector3d& point, const Base::Vector3d& normal, SbMatrix& mat) const;
|
||||
virtual void transformExtraSymbol() const;
|
||||
|
||||
static void createPlacement(SoSeparator* sep, const SbVec3f& base, const SbRotation& r);
|
||||
static void updatePlacement(const SoSeparator* sep,
|
||||
@@ -163,6 +166,7 @@ protected:
|
||||
SoSeparator* pShapeSep;
|
||||
SoSeparator* pSymbol;
|
||||
SoSeparator* pExtraSymbol;
|
||||
SoTransform* pExtraTrans;
|
||||
SoMultipleCopy* pMultCopy;
|
||||
const char* ivFile;
|
||||
|
||||
@@ -190,6 +194,11 @@ inline SoSeparator* ViewProviderFemConstraint::getExtraSymbolSeparator() const
|
||||
return pExtraSymbol;
|
||||
}
|
||||
|
||||
inline SoTransform* ViewProviderFemConstraint::getExtraSymbolTransform() const
|
||||
{
|
||||
return pExtraTrans;
|
||||
}
|
||||
|
||||
inline bool ViewProviderFemConstraint::getRotateSymbol() const
|
||||
{
|
||||
return rotateSymbol;
|
||||
|
||||
Reference in New Issue
Block a user