Fem: Constraint symbol scaling (#13274)
* Fem: Constraint symbols rescaling * Fem: Add constraint symbol .iv files * Fem: Fix contact constraint symbol rescaling * Fem: Fix displacement constraint symbol rescaling * Fem: Fix fixed constraint symbol rescaling * Fem: Fix force constraint symbol rescaling * Fem: Fix heat flux constraint symbol rescaling * Fem: Fix plane rotation constraint symbol rescaling * Fem: Fix pressure constraint symbol rescaling * Fem: Fix spring constraint symbol rescaling * Fem: Fix temperature constraint symbol rescaling * Fem: Add tie constraint symbol
This commit is contained in:
@@ -26,10 +26,8 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <Inventor/SbRotation.h>
|
||||
#include <Inventor/SbVec3f.h>
|
||||
#include <Inventor/nodes/SoMultipleCopy.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <Inventor/nodes/SoSwitch.h>
|
||||
#endif
|
||||
|
||||
#include "Mod/Fem/App/FemConstraintDisplacement.h"
|
||||
@@ -46,7 +44,11 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintDisplacement,
|
||||
ViewProviderFemConstraintDisplacement::ViewProviderFemConstraintDisplacement()
|
||||
{
|
||||
sPixmap = "FEM_ConstraintDisplacement";
|
||||
loadSymbol((resourceSymbolDir + "ConstraintDisplacement.iv").c_str());
|
||||
ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f));
|
||||
|
||||
// do not rotate symbol according to boundary normal
|
||||
setRotateSymbol(false);
|
||||
}
|
||||
|
||||
ViewProviderFemConstraintDisplacement::~ViewProviderFemConstraintDisplacement() = default;
|
||||
@@ -92,211 +94,36 @@ bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
|
||||
#define HEIGHT (4)
|
||||
#define WIDTH (0.3)
|
||||
// #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<Fem::ConstraintDisplacement*>(this->getObject());
|
||||
// OvG: Calculate scaled values once only
|
||||
float scaledwidth = WIDTH * pcConstraint->Scale.getValue();
|
||||
float scaledheight = HEIGHT * pcConstraint->Scale.getValue();
|
||||
bool xFree = pcConstraint->xFree.getValue();
|
||||
bool yFree = pcConstraint->yFree.getValue();
|
||||
bool zFree = pcConstraint->zFree.getValue();
|
||||
bool rotxFree = pcConstraint->rotxFree.getValue();
|
||||
bool rotyFree = pcConstraint->rotyFree.getValue();
|
||||
bool rotzFree = pcConstraint->rotzFree.getValue();
|
||||
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
// OvG: always need access to cp for scaling
|
||||
SoMultipleCopy* cpx = new SoMultipleCopy();
|
||||
SoMultipleCopy* cpy = new SoMultipleCopy();
|
||||
SoMultipleCopy* cpz = new SoMultipleCopy();
|
||||
SoMultipleCopy* cprotx = new SoMultipleCopy();
|
||||
SoMultipleCopy* cproty = new SoMultipleCopy();
|
||||
SoMultipleCopy* cprotz = new SoMultipleCopy();
|
||||
if (pShapeSep->getNumChildren() == 0) {
|
||||
// Set up the nodes
|
||||
cpx->matrix.setNum(0);
|
||||
cpx->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); // OvG: Scaling
|
||||
|
||||
cpy->matrix.setNum(0);
|
||||
cpy->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); // OvG: Scaling
|
||||
|
||||
cpz->matrix.setNum(0);
|
||||
cpz->addChild((SoNode*)createDisplacement(scaledheight, scaledwidth)); // OvG: Scaling
|
||||
|
||||
cprotx->matrix.setNum(0);
|
||||
cprotx->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); // OvG: Scaling
|
||||
|
||||
cproty->matrix.setNum(0);
|
||||
cproty->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); // OvG: Scaling
|
||||
|
||||
cprotz->matrix.setNum(0);
|
||||
cprotz->addChild((SoNode*)createRotation(scaledheight, scaledwidth)); // OvG: Scaling
|
||||
|
||||
pShapeSep->addChild(cpx);
|
||||
pShapeSep->addChild(cpy);
|
||||
pShapeSep->addChild(cpz);
|
||||
pShapeSep->addChild(cprotx);
|
||||
pShapeSep->addChild(cproty);
|
||||
pShapeSep->addChild(cprotz;
|
||||
if (prop == &pcConstraint->xFree) {
|
||||
auto sw = static_cast<SoSwitch*>(getSymbolSeparator()->getChild(0));
|
||||
sw->whichChild.setValue((pcConstraint->xFree.getValue() ? -1 : 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (prop == &pcConstraint->Points) {
|
||||
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
|
||||
const std::vector<Base::Vector3d>& normals = pcConstraint->Normals.getValues();
|
||||
if (points.size() != normals.size()) {
|
||||
return;
|
||||
}
|
||||
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
|
||||
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
cpx = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
|
||||
cpx->matrix.setNum(points.size());
|
||||
SbMatrix* matricesx = cpx->matrix.startEditing();
|
||||
|
||||
cpy = static_cast<SoMultipleCopy*>(pShapeSep->getChild(1));
|
||||
cpy->matrix.setNum(points.size());
|
||||
SbMatrix* matricesy = cpy->matrix.startEditing();
|
||||
|
||||
cpz = static_cast<SoMultipleCopy*>(pShapeSep->getChild(2));
|
||||
cpz->matrix.setNum(points.size());
|
||||
SbMatrix* matricesz = cpz->matrix.startEditing();
|
||||
|
||||
cprotx = static_cast<SoMultipleCopy*>(pShapeSep->getChild(3));
|
||||
cprotx->matrix.setNum(points.size());
|
||||
SbMatrix* matricesrotx = cprotx->matrix.startEditing();
|
||||
|
||||
cproty = static_cast<SoMultipleCopy*>(pShapeSep->getChild(4));
|
||||
cproty->matrix.setNum(points.size());
|
||||
SbMatrix* matricesroty = cproty->matrix.startEditing();
|
||||
|
||||
cprotz = static_cast<SoMultipleCopy*>(pShapeSep->getChild(5));
|
||||
cprotz->matrix.setNum(points.size());
|
||||
SbMatrix* matricesrotz = cprotz->matrix.startEditing();
|
||||
|
||||
int idx = 0;
|
||||
int idy = 0;
|
||||
int idz = 0;
|
||||
int idrotx = 0;
|
||||
int idroty = 0;
|
||||
int idrotz = 0;
|
||||
#else
|
||||
// Note: Points and Normals are always updated together
|
||||
Gui::coinRemoveAllChildren(pShapeSep);
|
||||
#endif
|
||||
|
||||
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
|
||||
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) {
|
||||
SbMatrix mx;
|
||||
mx.setTransform(base, rotx, SbVec3f(1, 1, 1));
|
||||
matricesx[idx] = mx;
|
||||
idx++;
|
||||
}
|
||||
if (!yFree) {
|
||||
SbMatrix my;
|
||||
my.setTransform(base, roty, SbVec3f(1, 1, 1));
|
||||
matricesy[idy] = my;
|
||||
idy++;
|
||||
}
|
||||
if (!zFree) {
|
||||
SbMatrix mz;
|
||||
mz.setTransform(base, rotz, SbVec3f(1, 1, 1));
|
||||
matricesz[idz] = mz;
|
||||
idz++;
|
||||
}
|
||||
|
||||
// OvG: Rotation indication
|
||||
if (!rotxFree) {
|
||||
SbMatrix mrotx;
|
||||
mrotx.setTransform(base, rotx, SbVec3f(1, 1, 1));
|
||||
matricesrotx[idrotx] = mrotx;
|
||||
idrotx++;
|
||||
}
|
||||
if (!rotyFree) {
|
||||
SbMatrix mroty;
|
||||
mroty.setTransform(base, roty, SbVec3f(1, 1, 1));
|
||||
matricesroty[idroty] = mroty;
|
||||
idroty++;
|
||||
}
|
||||
if (!rotzFree) {
|
||||
SbMatrix mrotz;
|
||||
mrotz.setTransform(base, rotz, SbVec3f(1, 1, 1));
|
||||
matricesrotz[idrotz] = mrotz;
|
||||
idrotz++;
|
||||
}
|
||||
#else
|
||||
// OvG: Translation indication
|
||||
if (!xFree) {
|
||||
SoSeparator* sepx = new SoSeparator();
|
||||
createPlacement(sepx, base, rotx);
|
||||
createDisplacement(sepx, scaledheight, scaledwidth); // OvG: Scaling
|
||||
pShapeSep->addChild(sepx);
|
||||
}
|
||||
if (!yFree) {
|
||||
SoSeparator* sepy = new SoSeparator();
|
||||
createPlacement(sepy, base, roty);
|
||||
createDisplacement(sepy, scaledheight, scaledwidth); // OvG: Scaling
|
||||
pShapeSep->addChild(sepy);
|
||||
}
|
||||
if (!zFree) {
|
||||
SoSeparator* sepz = new SoSeparator();
|
||||
createPlacement(sepz, base, rotz);
|
||||
createDisplacement(sepz, scaledheight, scaledwidth); // OvG: Scaling
|
||||
pShapeSep->addChild(sepz);
|
||||
}
|
||||
|
||||
// OvG: Rotation indication
|
||||
if (!rotxFree) {
|
||||
SoSeparator* sepx = new SoSeparator();
|
||||
createPlacement(sepx, base, rotx);
|
||||
createRotation(sepx, scaledheight, scaledwidth); // OvG: Scaling
|
||||
pShapeSep->addChild(sepx);
|
||||
}
|
||||
if (!rotyFree) {
|
||||
SoSeparator* sepy = new SoSeparator();
|
||||
createPlacement(sepy, base, roty);
|
||||
createRotation(sepy, scaledheight, scaledwidth); // OvG: Scaling
|
||||
pShapeSep->addChild(sepy);
|
||||
}
|
||||
if (!rotzFree) {
|
||||
SoSeparator* sepz = new SoSeparator();
|
||||
createPlacement(sepz, base, rotz);
|
||||
createRotation(sepz, scaledheight, scaledwidth); // OvG: Scaling
|
||||
pShapeSep->addChild(sepz);
|
||||
}
|
||||
#endif
|
||||
n++;
|
||||
}
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
cpx->matrix.finishEditing();
|
||||
cpy->matrix.finishEditing();
|
||||
cpz->matrix.finishEditing();
|
||||
cprotx->matrix.finishEditing();
|
||||
cproty->matrix.finishEditing();
|
||||
cprotz->matrix.finishEditing();
|
||||
#endif
|
||||
else if (prop == &pcConstraint->yFree) {
|
||||
auto sw = static_cast<SoSwitch*>(getSymbolSeparator()->getChild(1));
|
||||
sw->whichChild.setValue((pcConstraint->yFree.getValue() ? -1 : 0));
|
||||
}
|
||||
else if (prop == &pcConstraint->zFree) {
|
||||
auto sw = static_cast<SoSwitch*>(getSymbolSeparator()->getChild(2));
|
||||
sw->whichChild.setValue((pcConstraint->zFree.getValue() ? -1 : 0));
|
||||
}
|
||||
else if (prop == &pcConstraint->rotxFree) {
|
||||
auto sw = static_cast<SoSwitch*>(getSymbolSeparator()->getChild(3));
|
||||
sw->whichChild.setValue((pcConstraint->rotxFree.getValue() ? -1 : 0));
|
||||
}
|
||||
else if (prop == &pcConstraint->rotyFree) {
|
||||
auto sw = static_cast<SoSwitch*>(getSymbolSeparator()->getChild(4));
|
||||
sw->whichChild.setValue((pcConstraint->rotyFree.getValue() ? -1 : 0));
|
||||
}
|
||||
else if (prop == &pcConstraint->rotzFree) {
|
||||
auto sw = static_cast<SoSwitch*>(getSymbolSeparator()->getChild(5));
|
||||
sw->whichChild.setValue((pcConstraint->rotzFree.getValue() ? -1 : 0));
|
||||
}
|
||||
else {
|
||||
ViewProviderFemConstraint::updateData(prop);
|
||||
}
|
||||
|
||||
// Gets called whenever a property of the attached object changes
|
||||
ViewProviderFemConstraint::updateData(prop);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user