Fem: Cleanup ViewProviderFemConstraint class
This commit is contained in:
@@ -305,6 +305,8 @@ SET(FemGui_SRCS_Module
|
||||
ActiveAnalysisObserver.cpp
|
||||
ActiveAnalysisObserver.h
|
||||
Command.cpp
|
||||
FemGuiTools.cpp
|
||||
FemGuiTools.h
|
||||
FemSettings.cpp
|
||||
FemSettings.h
|
||||
Resources/Fem.qrc
|
||||
|
||||
206
src/Mod/Fem/Gui/FemGuiTools.cpp
Normal file
206
src/Mod/Fem/Gui/FemGuiTools.cpp
Normal file
@@ -0,0 +1,206 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2013 Jan Rheinländer *
|
||||
* <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <Inventor/nodes/SoCone.h>
|
||||
#include <Inventor/nodes/SoCube.h>
|
||||
#include <Inventor/nodes/SoCylinder.h>
|
||||
#include <Inventor/nodes/SoTranslation.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <Inventor/nodes/SoRotation.h>
|
||||
#endif
|
||||
|
||||
#include "FemGuiTools.h"
|
||||
|
||||
|
||||
namespace FemGui::GuiTools
|
||||
{
|
||||
|
||||
#define PLACEMENT_CHILDREN 2
|
||||
#define CONE_CHILDREN 2
|
||||
|
||||
void createPlacement(SoSeparator* sep, const SbVec3f& base, const SbRotation& r)
|
||||
{
|
||||
SoTranslation* trans = new SoTranslation();
|
||||
trans->translation.setValue(base);
|
||||
sep->addChild(trans);
|
||||
SoRotation* rot = new SoRotation();
|
||||
rot->rotation.setValue(r);
|
||||
sep->addChild(rot);
|
||||
}
|
||||
|
||||
void updatePlacement(const SoSeparator* sep,
|
||||
const int idx,
|
||||
const SbVec3f& base,
|
||||
const SbRotation& r)
|
||||
{
|
||||
SoTranslation* trans = static_cast<SoTranslation*>(sep->getChild(idx));
|
||||
trans->translation.setValue(base);
|
||||
SoRotation* rot = static_cast<SoRotation*>(sep->getChild(idx + 1));
|
||||
rot->rotation.setValue(r);
|
||||
}
|
||||
|
||||
void createCone(SoSeparator* sep, const double height, const double radius)
|
||||
{
|
||||
// Adjust cone so that the tip is on base
|
||||
SoTranslation* trans = new SoTranslation();
|
||||
trans->translation.setValue(SbVec3f(0, -height / 2, 0));
|
||||
sep->addChild(trans);
|
||||
SoCone* cone = new SoCone();
|
||||
cone->height.setValue(height);
|
||||
cone->bottomRadius.setValue(radius);
|
||||
sep->addChild(cone);
|
||||
}
|
||||
|
||||
SoSeparator* createCone(const double height, const double radius)
|
||||
{
|
||||
// Create a new cone node
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createCone(sep, height, radius);
|
||||
return sep;
|
||||
}
|
||||
|
||||
void updateCone(const SoNode* node, const int idx, const double height, const double radius)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(node);
|
||||
SoTranslation* trans = static_cast<SoTranslation*>(sep->getChild(idx));
|
||||
trans->translation.setValue(SbVec3f(0, -height / 2, 0));
|
||||
SoCone* cone = static_cast<SoCone*>(sep->getChild(idx + 1));
|
||||
cone->height.setValue(height);
|
||||
cone->bottomRadius.setValue(radius);
|
||||
}
|
||||
|
||||
void createCylinder(SoSeparator* sep, const double height, const double radius)
|
||||
{
|
||||
SoCylinder* cyl = new SoCylinder();
|
||||
cyl->height.setValue(height);
|
||||
cyl->radius.setValue(radius);
|
||||
sep->addChild(cyl);
|
||||
}
|
||||
|
||||
SoSeparator* createCylinder(const double height, const double radius)
|
||||
{
|
||||
// Create a new cylinder node
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createCylinder(sep, height, radius);
|
||||
return sep;
|
||||
}
|
||||
|
||||
void updateCylinder(const SoNode* node, const int idx, const double height, const double radius)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(node);
|
||||
SoCylinder* cyl = static_cast<SoCylinder*>(sep->getChild(idx));
|
||||
cyl->height.setValue(height);
|
||||
cyl->radius.setValue(radius);
|
||||
}
|
||||
|
||||
void createCube(SoSeparator* sep, const double width, const double length, const double height)
|
||||
{
|
||||
SoCube* cube = new SoCube();
|
||||
cube->width.setValue(width);
|
||||
cube->depth.setValue(length);
|
||||
cube->height.setValue(height);
|
||||
sep->addChild(cube);
|
||||
}
|
||||
|
||||
SoSeparator* createCube(const double width, const double length, const double height)
|
||||
{
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createCube(sep, width, length, height);
|
||||
return sep;
|
||||
}
|
||||
|
||||
void updateCube(const SoNode* node,
|
||||
const int idx,
|
||||
const double width,
|
||||
const double length,
|
||||
const double height)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(node);
|
||||
SoCube* cube = static_cast<SoCube*>(sep->getChild(idx));
|
||||
cube->width.setValue(width);
|
||||
cube->depth.setValue(length);
|
||||
cube->height.setValue(height);
|
||||
}
|
||||
|
||||
void 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);
|
||||
}
|
||||
|
||||
SoSeparator* createArrow(const double length, const double radius)
|
||||
{
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createArrow(sep, length, radius);
|
||||
return sep;
|
||||
}
|
||||
|
||||
void updateArrow(const SoNode* node, const int idx, const double length, const double radius)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(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);
|
||||
}
|
||||
|
||||
void 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);
|
||||
}
|
||||
|
||||
SoSeparator* createFixed(const double height, const double width, const bool gap)
|
||||
{
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createFixed(sep, height, width, gap);
|
||||
return sep;
|
||||
}
|
||||
|
||||
void updateFixed(const SoNode* node,
|
||||
const int idx,
|
||||
const double height,
|
||||
const double width,
|
||||
const bool gap)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(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);
|
||||
}
|
||||
|
||||
} // namespace FemGui::GuiTools
|
||||
74
src/Mod/Fem/Gui/FemGuiTools.h
Normal file
74
src/Mod/Fem/Gui/FemGuiTools.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2013 Jan Rheinländer *
|
||||
* <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef FEM_GUI_TOOLS_H
|
||||
#define FEM_GUI_TOOLS_H
|
||||
|
||||
#include <Inventor/SbVec3f.h>
|
||||
#include <Inventor/SbRotation.h>
|
||||
|
||||
|
||||
class SoNode;
|
||||
class SoSeparator;
|
||||
|
||||
namespace FemGui
|
||||
{
|
||||
|
||||
namespace GuiTools
|
||||
{
|
||||
|
||||
void createPlacement(SoSeparator* sep, const SbVec3f& base, const SbRotation& r);
|
||||
void updatePlacement(const SoSeparator* sep,
|
||||
const int idx,
|
||||
const SbVec3f& base,
|
||||
const SbRotation& r);
|
||||
void createCone(SoSeparator* sep, const double height, const double radius);
|
||||
SoSeparator* createCone(const double height, const double radius);
|
||||
void updateCone(const SoNode* node, const int idx, const double height, const double radius);
|
||||
void createCylinder(SoSeparator* sep, const double height, const double radius);
|
||||
SoSeparator* createCylinder(const double height, const double radius);
|
||||
void updateCylinder(const SoNode* node, const int idx, const double height, const double radius);
|
||||
void createCube(SoSeparator* sep, const double width, const double length, const double height);
|
||||
SoSeparator* createCube(const double width, const double length, const double height);
|
||||
void updateCube(const SoNode* node,
|
||||
const int idx,
|
||||
const double width,
|
||||
const double length,
|
||||
const double height);
|
||||
void createArrow(SoSeparator* sep, const double length, const double radius);
|
||||
SoSeparator* createArrow(const double length, const double radius);
|
||||
void updateArrow(const SoNode* node, const int idx, const double length, const double radius);
|
||||
void createFixed(SoSeparator* sep, const double height, const double width, const bool gap = false);
|
||||
SoSeparator* createFixed(const double height, const double width, const bool gap = false);
|
||||
void updateFixed(const SoNode* node,
|
||||
const int idx,
|
||||
const double height,
|
||||
const double width,
|
||||
const bool gap = false);
|
||||
|
||||
} // namespace GuiTools
|
||||
|
||||
} // namespace FemGui
|
||||
|
||||
|
||||
#endif // FEM_GUI_TOOLS_H
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2013 Jan Rheinländer *
|
||||
* <jrheinlaender@users.sourceforge.net> *
|
||||
* Copyright (c) 2024 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
@@ -24,17 +25,12 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <Inventor/nodes/SoCone.h>
|
||||
#include <Inventor/nodes/SoCube.h>
|
||||
#include <Inventor/nodes/SoCylinder.h>
|
||||
#include <Inventor/nodes/SoMaterial.h>
|
||||
#include <Inventor/nodes/SoMultipleCopy.h>
|
||||
#include <Inventor/nodes/SoPickStyle.h>
|
||||
#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>
|
||||
#include <QMenu>
|
||||
@@ -318,348 +314,7 @@ PyObject* ViewProviderFemConstraint::getPyObject()
|
||||
pyViewObject->IncRef();
|
||||
return pyViewObject;
|
||||
}
|
||||
/*
|
||||
// Create a local coordinate system with the z-axis given in dir
|
||||
void getLocalCoordinateSystem(const SbVec3f& z, SbVec3f& y, SbVec3f& x)
|
||||
{
|
||||
// Find the y axis in an arbitrary direction, normal to z
|
||||
// Conditions:
|
||||
// y1 * z1 + y2 * z2 + y3 * z3 = |y| |z| cos(90°) = 0
|
||||
// |y| = sqrt(y1^2 + y2^2 + y3^2) = 1
|
||||
float z1, z2, z3;
|
||||
z.getValue(z1, z2, z3);
|
||||
float y1, y2, y3;
|
||||
if (fabs(z1) > Precision::Confusion()) {
|
||||
// Choose: y3 = 0
|
||||
// Solution:
|
||||
// y1 * z1 + y2 * z2 = 0
|
||||
// y1 = - z2/z1 y2
|
||||
// sqrt(z2^2/z1^2 y2^2 + y2^2) = 1
|
||||
// y2^2 ( 1 + z2^2/z1^2)) = +-1 -> choose +1 otherwise no solution
|
||||
// y2 = +- sqrt(1 / (1 + z2^2/z1^2))
|
||||
y3 = 0;
|
||||
y2 = sqrt(1 / (1 + z2*z2 / (z1*z1)));
|
||||
y1 = -z2/z1 * y2;
|
||||
// Note: result might be (0, 1, 0)
|
||||
} else if (fabs(z2) > Precision::Confusion()) {
|
||||
// Given: z1 = 0
|
||||
// Choose: y1 = 0
|
||||
// Solution:
|
||||
// y2 * z2 + y3 * z3 = 0
|
||||
// y2 = - z3/z2 y3
|
||||
// sqrt(z3^2/z2^2 y3^3 + y3^2) = 1
|
||||
// y3^2 (1 + z3^2/z2^2)) = +1
|
||||
// y3 = +- sqrt(1 / (1 + z3^2/z2^2))
|
||||
y1 = 0;
|
||||
y3 = sqrt(1 / (1 + z3*z3 / (z2*z2)));
|
||||
y2 = -z3/z2 * y3;
|
||||
// Note: result might be (0, 0, 1)
|
||||
} else if (fabs(z3) > Precision::Confusion()) {
|
||||
// Given: z1 = z2 = 0
|
||||
// Choose the remaining possible axis
|
||||
y1 = 1;
|
||||
y2 = 0;
|
||||
y3 = 0;
|
||||
}
|
||||
|
||||
y = SbVec3f(y1, y2, y3);
|
||||
x = y.cross(z);
|
||||
}
|
||||
*/
|
||||
#define PLACEMENT_CHILDREN 2
|
||||
|
||||
void ViewProviderFemConstraint::createPlacement(SoSeparator* sep,
|
||||
const SbVec3f& base,
|
||||
const SbRotation& r)
|
||||
{
|
||||
SoTranslation* trans = new SoTranslation();
|
||||
trans->translation.setValue(base);
|
||||
sep->addChild(trans);
|
||||
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)
|
||||
{
|
||||
SoTranslation* trans = static_cast<SoTranslation*>(sep->getChild(idx));
|
||||
trans->translation.setValue(base);
|
||||
SoRotation* rot = static_cast<SoRotation*>(sep->getChild(idx + 1));
|
||||
rot->rotation.setValue(r);
|
||||
}
|
||||
|
||||
#define CONE_CHILDREN 2
|
||||
|
||||
void ViewProviderFemConstraint::createCone(SoSeparator* sep,
|
||||
const double height,
|
||||
const double radius)
|
||||
{
|
||||
// Adjust cone so that the tip is on base
|
||||
SoTranslation* trans = new SoTranslation();
|
||||
trans->translation.setValue(SbVec3f(0, -height / 2, 0));
|
||||
sep->addChild(trans);
|
||||
SoCone* cone = new SoCone();
|
||||
cone->height.setValue(height);
|
||||
cone->bottomRadius.setValue(radius);
|
||||
sep->addChild(cone);
|
||||
}
|
||||
|
||||
SoSeparator* ViewProviderFemConstraint::createCone(const double height, const double radius)
|
||||
{
|
||||
// Create a new cone node
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createCone(sep, height, radius);
|
||||
return sep;
|
||||
}
|
||||
|
||||
void ViewProviderFemConstraint::updateCone(const SoNode* node,
|
||||
const int idx,
|
||||
const double height,
|
||||
const double radius)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(node);
|
||||
SoTranslation* trans = static_cast<SoTranslation*>(sep->getChild(idx));
|
||||
trans->translation.setValue(SbVec3f(0, -height / 2, 0));
|
||||
SoCone* cone = static_cast<SoCone*>(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)
|
||||
{
|
||||
SoCylinder* cyl = new SoCylinder();
|
||||
cyl->height.setValue(height);
|
||||
cyl->radius.setValue(radius);
|
||||
sep->addChild(cyl);
|
||||
}
|
||||
|
||||
SoSeparator* ViewProviderFemConstraint::createCylinder(const double height, const double radius)
|
||||
{
|
||||
// Create a new cylinder node
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createCylinder(sep, height, radius);
|
||||
return sep;
|
||||
}
|
||||
|
||||
void ViewProviderFemConstraint::updateCylinder(const SoNode* node,
|
||||
const int idx,
|
||||
const double height,
|
||||
const double radius)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(node);
|
||||
SoCylinder* cyl = static_cast<SoCylinder*>(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)
|
||||
{
|
||||
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* 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)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(node);
|
||||
SoCube* cube = static_cast<SoCube*>(sep->getChild(idx));
|
||||
cube->width.setValue(width);
|
||||
cube->depth.setValue(length);
|
||||
cube->height.setValue(height);
|
||||
}
|
||||
|
||||
#define ARROW_CHILDREN (CONE_CHILDREN + PLACEMENT_CHILDREN + CYLINDER_CHILDREN)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
SoSeparator* ViewProviderFemConstraint::createArrow(const double length, const double radius)
|
||||
{
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createArrow(sep, length, radius);
|
||||
return sep;
|
||||
}
|
||||
|
||||
void ViewProviderFemConstraint::updateArrow(const SoNode* node,
|
||||
const int idx,
|
||||
const double length,
|
||||
const double radius)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(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);
|
||||
}
|
||||
|
||||
SoSeparator* ViewProviderFemConstraint::createSpring(const double length, const double width)
|
||||
{
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createSpring(sep, length, width);
|
||||
return sep;
|
||||
}
|
||||
|
||||
void ViewProviderFemConstraint::updateSpring(const SoNode* node,
|
||||
const int idx,
|
||||
const double length,
|
||||
const double width)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(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)
|
||||
{
|
||||
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* 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)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(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)
|
||||
{
|
||||
createCone(sep, height, width);
|
||||
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* 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)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
SoSeparator*
|
||||
ViewProviderFemConstraint::createRotation(const double height, const double width, const bool gap)
|
||||
{
|
||||
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)
|
||||
{
|
||||
const SoSeparator* sep = static_cast<const SoSeparator*>(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)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2013 Jan Rheinländer *
|
||||
* <jrheinlaender@users.sourceforge.net> *
|
||||
* Copyright (c) 2024 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
@@ -98,67 +99,6 @@ protected:
|
||||
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,
|
||||
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:
|
||||
bool rotateSymbol;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#endif
|
||||
|
||||
#include "Gui/Control.h"
|
||||
#include "FemGuiTools.h"
|
||||
#include "TaskFemConstraintBearing.h"
|
||||
#include "ViewProviderFemConstraintBearing.h"
|
||||
#include <Base/Console.h>
|
||||
@@ -131,9 +132,10 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop)
|
||||
SbVec3f dir(normal.x, normal.y, normal.z);
|
||||
SbRotation rot(SbVec3f(0, -1, 0), dir);
|
||||
|
||||
createPlacement(pShapeSep, b, rot);
|
||||
pShapeSep->addChild(
|
||||
createFixed(radius / 2, radius / 2 * 1.5, pcConstraint->AxialFree.getValue()));
|
||||
GuiTools::createPlacement(pShapeSep, b, rot);
|
||||
pShapeSep->addChild(GuiTools::createFixed(radius / 2,
|
||||
radius / 2 * 1.5,
|
||||
pcConstraint->AxialFree.getValue()));
|
||||
}
|
||||
else if (prop == &pcConstraint->AxialFree) {
|
||||
if (pShapeSep->getNumChildren() > 0) {
|
||||
@@ -147,9 +149,13 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop)
|
||||
SbVec3f dir(normal.x, normal.y, normal.z);
|
||||
SbRotation rot(SbVec3f(0, -1, 0), dir);
|
||||
|
||||
updatePlacement(pShapeSep, 0, b, rot);
|
||||
GuiTools::updatePlacement(pShapeSep, 0, b, rot);
|
||||
const SoSeparator* sep = static_cast<SoSeparator*>(pShapeSep->getChild(2));
|
||||
updateFixed(sep, 0, radius / 2, radius / 2 * 1.5, pcConstraint->AxialFree.getValue());
|
||||
GuiTools::updateFixed(sep,
|
||||
0,
|
||||
radius / 2,
|
||||
radius / 2 * 1.5,
|
||||
pcConstraint->AxialFree.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "Gui/Control.h"
|
||||
#include <Mod/Fem/App/FemConstraintFluidBoundary.h>
|
||||
|
||||
#include "FemGuiTools.h"
|
||||
#include "TaskFemConstraintFluidBoundary.h"
|
||||
#include "ViewProviderFemConstraintFluidBoundary.h"
|
||||
|
||||
@@ -157,7 +158,8 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
|
||||
if (pShapeSep->getNumChildren() == 0) {
|
||||
// Set up the nodes
|
||||
cp->matrix.setNum(0);
|
||||
cp->addChild((SoNode*)createArrow(scaledlength, scaledheadradius)); // OvG: Scaling
|
||||
cp->addChild(
|
||||
(SoNode*)GuiTools::createArrow(scaledlength, scaledheadradius)); // OvG: Scaling
|
||||
pShapeSep->addChild(cp);
|
||||
}
|
||||
#endif
|
||||
@@ -199,8 +201,8 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
|
||||
idx++;
|
||||
#else
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createPlacement(sep, base, rot);
|
||||
createArrow(sep, scaledlength, scaledheadradius); // OvG: Scaling
|
||||
GuiTools::createPlacement(sep, base, rot);
|
||||
GuiTools::createArrow(sep, scaledlength, scaledheadradius); // OvG: Scaling
|
||||
pShapeSep->addChild(sep);
|
||||
#endif
|
||||
}
|
||||
@@ -243,8 +245,8 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
|
||||
matrices[idx] = m;
|
||||
#else
|
||||
SoSeparator* sep = static_cast<SoSeparator*>(pShapeSep->getChild(idx));
|
||||
updatePlacement(sep, 0, base, rot);
|
||||
updateArrow(sep, 2, scaledlength, scaledheadradius); // OvG: Scaling
|
||||
GuiTools::updatePlacement(sep, 0, base, rot);
|
||||
GuiTools::updateArrow(sep, 2, scaledlength, scaledheadradius); // OvG: Scaling
|
||||
#endif
|
||||
idx++;
|
||||
}
|
||||
@@ -261,7 +263,8 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
|
||||
if (pShapeSep->getNumChildren() == 0) {
|
||||
// Set up the nodes
|
||||
cp->matrix.setNum(0);
|
||||
cp->addChild((SoNode*)createFixed(scaledheight, scaledwidth)); // OvG: Scaling
|
||||
cp->addChild(
|
||||
(SoNode*)GuiTools::createFixed(scaledheight, scaledwidth)); // OvG: Scaling
|
||||
pShapeSep->addChild(cp);
|
||||
}
|
||||
#endif
|
||||
@@ -295,8 +298,8 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
|
||||
idx++;
|
||||
#else
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createPlacement(sep, base, rot);
|
||||
createFixed(sep, scaledheight, scaledwidth); // OvG: Scaling
|
||||
GuiTools::createPlacement(sep, base, rot);
|
||||
GuiTools::createFixed(sep, scaledheight, scaledwidth); // OvG: Scaling
|
||||
pShapeSep->addChild(sep);
|
||||
#endif
|
||||
n++;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <Base/Console.h>
|
||||
#include <Mod/Fem/App/FemConstraintGear.h>
|
||||
|
||||
#include "FemGuiTools.h"
|
||||
#include "TaskFemConstraintGear.h"
|
||||
#include "ViewProviderFemConstraintGear.h"
|
||||
|
||||
@@ -139,12 +140,13 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
|
||||
// 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));
|
||||
GuiTools::createPlacement(pShapeSep, b, SbRotation(SbVec3f(0, 1, 0), ax));
|
||||
pShapeSep->addChild(
|
||||
GuiTools::createCylinder(pcConstraint->Height.getValue() * 0.8, dia / 2));
|
||||
GuiTools::createPlacement(pShapeSep,
|
||||
SbVec3f(dia / 2 * sin(angle), 0, dia / 2 * cos(angle)),
|
||||
SbRotation(ax, dir));
|
||||
pShapeSep->addChild(GuiTools::createArrow(dia / 2, dia / 8));
|
||||
}
|
||||
}
|
||||
else if (prop == &pcConstraint->Diameter) {
|
||||
@@ -166,13 +168,13 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
|
||||
SbVec3f dir(direction.x, direction.y, direction.z);
|
||||
|
||||
const SoSeparator* sep = static_cast<SoSeparator*>(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));
|
||||
GuiTools::updateCylinder(sep, 0, pcConstraint->Height.getValue() * 0.8, dia / 2);
|
||||
GuiTools::updatePlacement(pShapeSep,
|
||||
3,
|
||||
SbVec3f(dia / 2 * sin(angle), 0, dia / 2 * cos(angle)),
|
||||
SbRotation(ax, dir));
|
||||
sep = static_cast<SoSeparator*>(pShapeSep->getChild(5));
|
||||
updateArrow(sep, 0, dia / 2, dia / 8);
|
||||
GuiTools::updateArrow(sep, 0, dia / 2, dia / 8);
|
||||
}
|
||||
}
|
||||
else if ((prop == &pcConstraint->DirectionVector) || (prop == &pcConstraint->ForceAngle)) {
|
||||
@@ -203,10 +205,10 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
|
||||
directions!)
|
||||
*/
|
||||
|
||||
updatePlacement(pShapeSep,
|
||||
3,
|
||||
SbVec3f(dia / 2 * sin(angle), 0, dia / 2 * cos(angle)),
|
||||
SbRotation(ax, dir));
|
||||
GuiTools::updatePlacement(pShapeSep,
|
||||
3,
|
||||
SbVec3f(dia / 2 * sin(angle), 0, dia / 2 * cos(angle)),
|
||||
SbRotation(ax, dir));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#endif
|
||||
|
||||
#include "Gui/Control.h"
|
||||
#include "FemGuiTools.h"
|
||||
#include "TaskFemConstraintPulley.h"
|
||||
#include "ViewProviderFemConstraintPulley.h"
|
||||
#include <Mod/Fem/App/FemConstraintPulley.h>
|
||||
@@ -138,32 +139,34 @@ 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
|
||||
pShapeSep->addChild(
|
||||
createCylinder(pcConstraint->Height.getValue() * 0.8, dia / 2)); // child 2
|
||||
GuiTools::createPlacement(pShapeSep,
|
||||
b,
|
||||
SbRotation(SbVec3f(0, 1, 0), ax)); // child 0 and 1
|
||||
pShapeSep->addChild(GuiTools::createCylinder(pcConstraint->Height.getValue() * 0.8,
|
||||
dia / 2)); // child 2
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createPlacement(sep,
|
||||
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,
|
||||
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));
|
||||
GuiTools::createPlacement(sep,
|
||||
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,
|
||||
cos(forceAngle + beltAngle + M_PI_2))));
|
||||
GuiTools::createPlacement(sep, SbVec3f(0, dia / 8 + dia / 2 * rat1, 0), SbRotation());
|
||||
sep->addChild(GuiTools::createArrow(dia / 8 + dia / 2 * rat1, dia / 8));
|
||||
pShapeSep->addChild(sep); // child 3
|
||||
sep = new SoSeparator();
|
||||
createPlacement(sep,
|
||||
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,
|
||||
-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));
|
||||
GuiTools::createPlacement(sep,
|
||||
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,
|
||||
-cos(forceAngle - beltAngle - M_PI_2))));
|
||||
GuiTools::createPlacement(sep, SbVec3f(0, dia / 8 + dia / 2 * rat2, 0), SbRotation());
|
||||
sep->addChild(GuiTools::createArrow(dia / 8 + dia / 2 * rat2, dia / 8));
|
||||
pShapeSep->addChild(sep); // child 4
|
||||
}
|
||||
}
|
||||
@@ -186,33 +189,39 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
}
|
||||
|
||||
const SoSeparator* sep = static_cast<SoSeparator*>(pShapeSep->getChild(2));
|
||||
updateCylinder(sep, 0, pcConstraint->Height.getValue() * 0.8, dia / 2);
|
||||
GuiTools::updateCylinder(sep, 0, pcConstraint->Height.getValue() * 0.8, dia / 2);
|
||||
sep = static_cast<SoSeparator*>(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,
|
||||
cos(forceAngle + beltAngle + M_PI_2))));
|
||||
updatePlacement(sep, 2, SbVec3f(0, dia / 8 + dia / 2 * rat1, 0), SbRotation());
|
||||
GuiTools::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,
|
||||
cos(forceAngle + beltAngle + M_PI_2))));
|
||||
GuiTools::updatePlacement(sep,
|
||||
2,
|
||||
SbVec3f(0, dia / 8 + dia / 2 * rat1, 0),
|
||||
SbRotation());
|
||||
const SoSeparator* subsep = static_cast<SoSeparator*>(sep->getChild(4));
|
||||
updateArrow(subsep, 0, dia / 8 + dia / 2 * rat1, dia / 8);
|
||||
GuiTools::updateArrow(subsep, 0, dia / 8 + dia / 2 * rat1, dia / 8);
|
||||
sep = static_cast<SoSeparator*>(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,
|
||||
-cos(forceAngle - beltAngle - M_PI_2))));
|
||||
updatePlacement(sep, 2, SbVec3f(0, dia / 8 + dia / 2 * rat2, 0), SbRotation());
|
||||
GuiTools::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,
|
||||
-cos(forceAngle - beltAngle - M_PI_2))));
|
||||
GuiTools::updatePlacement(sep,
|
||||
2,
|
||||
SbVec3f(0, dia / 8 + dia / 2 * rat2, 0),
|
||||
SbRotation());
|
||||
subsep = static_cast<SoSeparator*>(sep->getChild(4));
|
||||
updateArrow(subsep, 0, dia / 8 + dia / 2 * rat2, dia / 8);
|
||||
GuiTools::updateArrow(subsep, 0, dia / 8 + dia / 2 * rat2, dia / 8);
|
||||
}
|
||||
}
|
||||
else if ((prop == &pcConstraint->ForceAngle) || (prop == &pcConstraint->BeltAngle)) {
|
||||
@@ -226,25 +235,25 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
double beltAngle = pcConstraint->BeltAngle.getValue();
|
||||
|
||||
const SoSeparator* sep = static_cast<SoSeparator*>(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,
|
||||
cos(forceAngle + beltAngle + M_PI_2))));
|
||||
GuiTools::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,
|
||||
cos(forceAngle + beltAngle + M_PI_2))));
|
||||
sep = static_cast<SoSeparator*>(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,
|
||||
-cos(forceAngle - beltAngle - M_PI_2))));
|
||||
GuiTools::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,
|
||||
-cos(forceAngle - beltAngle - M_PI_2))));
|
||||
}
|
||||
}
|
||||
else if ((prop == &pcConstraint->BeltForce1) || (prop == &pcConstraint->BeltForce2)) {
|
||||
@@ -263,13 +272,19 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
}
|
||||
|
||||
const SoSeparator* sep = static_cast<SoSeparator*>(pShapeSep->getChild(3));
|
||||
updatePlacement(sep, 2, SbVec3f(0, dia / 8 + dia / 2 * rat1, 0), SbRotation());
|
||||
GuiTools::updatePlacement(sep,
|
||||
2,
|
||||
SbVec3f(0, dia / 8 + dia / 2 * rat1, 0),
|
||||
SbRotation());
|
||||
const SoSeparator* subsep = static_cast<SoSeparator*>(sep->getChild(4));
|
||||
updateArrow(subsep, 0, dia / 8 + dia / 2 * rat1, dia / 8);
|
||||
GuiTools::updateArrow(subsep, 0, dia / 8 + dia / 2 * rat1, dia / 8);
|
||||
sep = static_cast<SoSeparator*>(pShapeSep->getChild(4));
|
||||
updatePlacement(sep, 2, SbVec3f(0, dia / 8 + dia / 2 * rat2, 0), SbRotation());
|
||||
GuiTools::updatePlacement(sep,
|
||||
2,
|
||||
SbVec3f(0, dia / 8 + dia / 2 * rat2, 0),
|
||||
SbRotation());
|
||||
subsep = static_cast<SoSeparator*>(sep->getChild(4));
|
||||
updateArrow(subsep, 0, dia / 8 + dia / 2 * rat2, dia / 8);
|
||||
GuiTools::updateArrow(subsep, 0, dia / 8 + dia / 2 * rat2, dia / 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user