Gui: refactor SoLinearDragger (#21451)
* Gui: refactor SoLinearDragger * further improvements * allow changing label visibility * change SoLinearDraggerContainer to not inherit from SoDragger --------- Co-authored-by: captain <captain@captain.captain.com>
This commit is contained in:
@@ -24,9 +24,11 @@
|
||||
#ifndef _PreComp_
|
||||
#include <cassert>
|
||||
#include <numbers>
|
||||
#include <algorithm>
|
||||
|
||||
#include <Inventor/SbRotation.h>
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
#include <Inventor/engines/SoCalculator.h>
|
||||
#include <Inventor/engines/SoComposeVec3f.h>
|
||||
#include <Inventor/nodes/SoLightModel.h>
|
||||
#include <Inventor/nodes/SoDrawStyle.h>
|
||||
@@ -48,6 +50,7 @@
|
||||
#include <Inventor/nodes/SoText2.h>
|
||||
#include <Inventor/nodes/SoAnnotation.h>
|
||||
#include <Inventor/nodes/SoFontStyle.h>
|
||||
#include <Inventor/draggers/SoDragger.h>
|
||||
#endif
|
||||
|
||||
#include <Base/Quantity.h>
|
||||
@@ -55,7 +58,7 @@
|
||||
#include "SoLinearDragger.h"
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "SoFCDB.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <SoTextLabel.h>
|
||||
|
||||
@@ -76,39 +79,35 @@ SoLinearDragger::SoLinearDragger()
|
||||
this->ref();
|
||||
#endif
|
||||
|
||||
SO_KIT_ADD_CATALOG_ENTRY(translator, SoSeparator, TRUE, geomSeparator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(activeSwitch, SoSwitch, TRUE, translator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(activeColor, SoBaseColor, TRUE, activeSwitch, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(coneSeparator, SoSeparator, TRUE, translator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(cylinderSeparator, SoSeparator, TRUE, translator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(labelSeparator, SoSeparator, TRUE, translator, "", TRUE);
|
||||
FC_ADD_CATALOG_ENTRY(translator, SoSeparator, geomSeparator);
|
||||
FC_ADD_CATALOG_ENTRY(activeSwitch, SoSwitch, translator);
|
||||
FC_ADD_CATALOG_ENTRY(secondaryColor, SoBaseColor, activeSwitch);
|
||||
FC_ADD_CATALOG_ENTRY(coneSeparator, SoSeparator, translator);
|
||||
FC_ADD_CATALOG_ENTRY(cylinderSeparator, SoSeparator, translator);
|
||||
// For some reason changing the whichChild parameter of this switch doesn't hide the label
|
||||
FC_ADD_CATALOG_ENTRY(labelSwitch, SoSwitch, translator);
|
||||
FC_ADD_CATALOG_ENTRY(labelSeparator, SoSeparator, labelSwitch);
|
||||
|
||||
if (SO_KIT_IS_FIRST_INSTANCE()) {
|
||||
buildFirstInstance();
|
||||
}
|
||||
|
||||
SO_KIT_ADD_CATALOG_ENTRY(translator, SoSeparator, TRUE, geomSeparator, "", TRUE);
|
||||
|
||||
SO_KIT_ADD_FIELD(label, (""));
|
||||
SO_KIT_ADD_FIELD(translation, (0.0, 0.0, 0.0));
|
||||
SO_KIT_ADD_FIELD(translationIncrement, (1.0));
|
||||
SO_KIT_ADD_FIELD(translationIncrementCount, (0));
|
||||
SO_KIT_ADD_FIELD(autoScaleResult, (1.0));
|
||||
SO_KIT_ADD_FIELD(coneBottomRadius, (0.8));
|
||||
SO_KIT_ADD_FIELD(coneHeight, (2.5));
|
||||
SO_KIT_ADD_FIELD(cylinderHeight, (10.0));
|
||||
SO_KIT_ADD_FIELD(cylinderRadius, (0.1));
|
||||
SO_KIT_ADD_FIELD(activeColor, (1, 1, 0));
|
||||
|
||||
SO_KIT_INIT_INSTANCE();
|
||||
|
||||
// initialize default parts.
|
||||
// first is from 'SO_KIT_CATALOG_ENTRY_HEADER' macro
|
||||
// second is unique name from buildFirstInstance().
|
||||
SoInteractionKit::setPartAsDefault("coneSeparator", "CSysDynamics_TDragger_Cone");
|
||||
SoInteractionKit::setPartAsDefault("cylinderSeparator", "CSysDynamics_TDragger_Cylinder");
|
||||
SoInteractionKit::setPartAsDefault("activeColor", "CSysDynamics_TDragger_ActiveColor");
|
||||
|
||||
setupGeometryCalculator();
|
||||
SoInteractionKit::setPart("cylinderSeparator", buildCylinderGeometry());
|
||||
SoInteractionKit::setPart("coneSeparator", buildConeGeometry());
|
||||
SoInteractionKit::setPart("labelSeparator", buildLabelGeometry());
|
||||
SoInteractionKit::setPart("secondaryColor", buildActiveColor());
|
||||
|
||||
auto sw = SO_GET_ANY_PART(this, "activeSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE);
|
||||
|
||||
FC_SET_SWITCH("activeSwitch", SO_SWITCH_NONE);
|
||||
setLabelVisibility(true);
|
||||
|
||||
this->addStartCallback(&SoLinearDragger::startCB);
|
||||
this->addMotionCallback(&SoLinearDragger::motionCB);
|
||||
@@ -134,22 +133,7 @@ SoLinearDragger::~SoLinearDragger()
|
||||
removeValueChangedCallback(&SoLinearDragger::valueChangedCB);
|
||||
}
|
||||
|
||||
void SoLinearDragger::buildFirstInstance()
|
||||
{
|
||||
auto cylinderSeparator = buildCylinderGeometry();
|
||||
auto coneSeparator = buildConeGeometry();
|
||||
auto activeColor = buildActiveColor();
|
||||
|
||||
cylinderSeparator->setName("CSysDynamics_TDragger_Cylinder");
|
||||
coneSeparator->setName("CSysDynamics_TDragger_Cone");
|
||||
activeColor->setName("CSysDynamics_TDragger_ActiveColor");
|
||||
|
||||
SoFCDB::getStorage()->addChild(cylinderSeparator);
|
||||
SoFCDB::getStorage()->addChild(coneSeparator);
|
||||
SoFCDB::getStorage()->addChild(activeColor);
|
||||
}
|
||||
|
||||
SoSeparator* SoLinearDragger::buildCylinderGeometry() const
|
||||
SoSeparator* SoLinearDragger::buildCylinderGeometry()
|
||||
{
|
||||
auto cylinderSeparator = new SoSeparator();
|
||||
|
||||
@@ -158,18 +142,22 @@ SoSeparator* SoLinearDragger::buildCylinderGeometry() const
|
||||
cylinderSeparator->addChild(cylinderLightModel);
|
||||
|
||||
auto cylinderTranslation = new SoTranslation();
|
||||
cylinderTranslation->translation.setValue(0.0, cylinderHeight / 2.0, 0.0);
|
||||
cylinderSeparator->addChild(cylinderTranslation);
|
||||
cylinderTranslation->translation.connectFrom(&calculator->oA);
|
||||
|
||||
auto cylinder = new SoCylinder();
|
||||
cylinder->radius.setValue(cylinderRadius);
|
||||
cylinder->height.setValue(cylinderHeight);
|
||||
cylinder->radius.setValue(cylinderRadius.getValue());
|
||||
cylinder->height.setValue(cylinderHeight.getValue());
|
||||
cylinderSeparator->addChild(cylinder);
|
||||
|
||||
cylinder->radius.connectFrom(&cylinderRadius);
|
||||
cylinder->height.connectFrom(&cylinderHeight);
|
||||
calculator->a.connectFrom(&cylinder->height);
|
||||
|
||||
return cylinderSeparator;
|
||||
}
|
||||
|
||||
SoSeparator* SoLinearDragger::buildConeGeometry() const
|
||||
SoSeparator* SoLinearDragger::buildConeGeometry()
|
||||
{
|
||||
auto coneLightModel = new SoLightModel();
|
||||
coneLightModel->model = SoLightModel::BASE_COLOR;
|
||||
@@ -183,24 +171,28 @@ SoSeparator* SoLinearDragger::buildConeGeometry() const
|
||||
coneSeparator->addChild(pickStyle);
|
||||
|
||||
auto coneTranslation = new SoTranslation();
|
||||
coneTranslation->translation.setValue(0.0, cylinderHeight + coneHeight / 2.0, 0.0);
|
||||
coneSeparator->addChild(coneTranslation);
|
||||
coneTranslation->translation.connectFrom(&calculator->oB);
|
||||
|
||||
auto cone = new SoCone();
|
||||
cone->bottomRadius.setValue(coneBottomRadius);
|
||||
cone->height.setValue(coneHeight);
|
||||
cone->bottomRadius.setValue(coneBottomRadius.getValue());
|
||||
cone->height.setValue(coneHeight.getValue());
|
||||
coneSeparator->addChild(cone);
|
||||
|
||||
cone->bottomRadius.connectFrom(&coneBottomRadius);
|
||||
cone->height.connectFrom(&coneHeight);
|
||||
calculator->b.connectFrom(&cone->height);
|
||||
|
||||
return coneSeparator;
|
||||
}
|
||||
|
||||
SoSeparator* SoLinearDragger::buildLabelGeometry()
|
||||
{
|
||||
auto labelSeparator = new SoSeparator();
|
||||
auto labelSeparator = new SoSeparator;
|
||||
|
||||
auto labelTranslation = new SoTranslation();
|
||||
labelTranslation->translation.setValue(0.0, cylinderHeight + coneHeight * 1.5, 0.0);
|
||||
labelSeparator->addChild(labelTranslation);
|
||||
labelTranslation->translation.connectFrom(&calculator->oC);
|
||||
|
||||
auto label = new SoFrameLabel();
|
||||
label->string.connectFrom(&this->label);
|
||||
@@ -216,10 +208,25 @@ SoSeparator* SoLinearDragger::buildLabelGeometry()
|
||||
|
||||
SoBaseColor* SoLinearDragger::buildActiveColor()
|
||||
{
|
||||
auto colorActive = new SoBaseColor();
|
||||
colorActive->rgb.setValue(1.0, 1.0, 0.0);
|
||||
auto color = new SoBaseColor;
|
||||
color->rgb.connectFrom(&activeColor);
|
||||
|
||||
return colorActive;
|
||||
return color;
|
||||
}
|
||||
|
||||
void SoLinearDragger::setupGeometryCalculator()
|
||||
{
|
||||
calculator = new SoCalculator;
|
||||
// Recalculate the corresponding variables in the left hand side whenever any of the variables in the right hand side change
|
||||
// oA -> cylinderTranslation
|
||||
// oB -> coneTranslation
|
||||
// oC -> labelTranslation
|
||||
// a -> cylinderHeight
|
||||
// b -> coneHeight
|
||||
calculator->expression =
|
||||
"oA = vec3f(0, a * 0.5, 0); "
|
||||
"oB = vec3f(0, a + b * 0.5, 0); "
|
||||
"oC = vec3f(0, a + b * 1.5, 0); ";
|
||||
}
|
||||
|
||||
void SoLinearDragger::startCB(void*, SoDragger* d)
|
||||
@@ -261,11 +268,7 @@ void SoLinearDragger::valueChangedCB(void*, SoDragger* d)
|
||||
auto sudoThis = dynamic_cast<SoLinearDragger*>(d);
|
||||
assert(sudoThis);
|
||||
SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft
|
||||
|
||||
// all this just to get the translation?
|
||||
SbVec3f trans, scaleDummy;
|
||||
SbRotation rotationDummy, scaleOrientationDummy;
|
||||
matrix.getTransform(trans, rotationDummy, scaleDummy, scaleOrientationDummy);
|
||||
SbVec3f trans = getMatrixTransform(matrix).translation;
|
||||
|
||||
sudoThis->fieldSensor.detach();
|
||||
if (sudoThis->translation.getValue() != trans) {
|
||||
@@ -276,9 +279,7 @@ void SoLinearDragger::valueChangedCB(void*, SoDragger* d)
|
||||
|
||||
void SoLinearDragger::dragStart()
|
||||
{
|
||||
SoSwitch* sw;
|
||||
sw = SO_GET_ANY_PART(this, "activeSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL);
|
||||
FC_SET_SWITCH("activeSwitch", SO_SWITCH_ALL);
|
||||
|
||||
// do an initial projection to eliminate discrepancies
|
||||
// in arrow head pick. we define the arrow in the y+ direction
|
||||
@@ -336,9 +337,7 @@ void SoLinearDragger::drag()
|
||||
|
||||
void SoLinearDragger::dragFinish()
|
||||
{
|
||||
SoSwitch* sw;
|
||||
sw = SO_GET_ANY_PART(this, "activeSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE);
|
||||
FC_SET_SWITCH("activeSwitch", SO_SWITCH_NONE);
|
||||
}
|
||||
|
||||
SbBool SoLinearDragger::setUpConnections(SbBool onoff, SbBool doitalways)
|
||||
@@ -391,3 +390,87 @@ SbVec3f SoLinearDragger::roundTranslation(const SbVec3f& vecIn, float incrementI
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void SoLinearDragger::setLabelVisibility(bool visible) {
|
||||
FC_SET_SWITCH("labelSwitch", visible? SO_SWITCH_ALL : SO_SWITCH_NONE);
|
||||
}
|
||||
|
||||
bool SoLinearDragger::isLabelVisible() {
|
||||
auto* sw = SO_GET_ANY_PART(this, "labelSwitch", SoSwitch);
|
||||
return sw->whichChild.getValue() == SO_SWITCH_ALL;
|
||||
}
|
||||
|
||||
SO_KIT_SOURCE(SoLinearDraggerContainer)
|
||||
|
||||
void SoLinearDraggerContainer::initClass()
|
||||
{
|
||||
SoLinearDragger::initClass();
|
||||
SO_KIT_INIT_CLASS(SoLinearDraggerContainer, SoInteractionKit, "InteractionKit");
|
||||
}
|
||||
|
||||
SoLinearDraggerContainer::SoLinearDraggerContainer()
|
||||
{
|
||||
SO_KIT_CONSTRUCTOR(SoLinearDraggerContainer);
|
||||
|
||||
#if defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||
this->ref();
|
||||
#endif
|
||||
|
||||
FC_ADD_CATALOG_ENTRY(draggerSwitch, SoSwitch, geomSeparator);
|
||||
FC_ADD_CATALOG_ENTRY(baseColor, SoBaseColor, draggerSwitch);
|
||||
FC_ADD_CATALOG_ENTRY(transform, SoTransform, draggerSwitch);
|
||||
FC_ADD_CATALOG_ENTRY(dragger, SoLinearDragger, draggerSwitch);
|
||||
|
||||
SO_KIT_ADD_FIELD(rotation, (0, 0, 0, 0));
|
||||
SO_KIT_ADD_FIELD(color, (0, 0, 0));
|
||||
SO_KIT_ADD_FIELD(translation, (0, 0, 0));
|
||||
|
||||
SO_KIT_INIT_INSTANCE();
|
||||
|
||||
SoInteractionKit::setPart("baseColor", buildColor());
|
||||
SoInteractionKit::setPart("transform", buildTransform());
|
||||
|
||||
setVisibility(true);
|
||||
}
|
||||
|
||||
SoBaseColor* SoLinearDraggerContainer::buildColor()
|
||||
{
|
||||
auto color = new SoBaseColor;
|
||||
color->rgb.connectFrom(&this->color);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
SoTransform* SoLinearDraggerContainer::buildTransform() {
|
||||
auto transform = new SoTransform;
|
||||
transform->translation.connectFrom(&this->translation);
|
||||
transform->rotation.connectFrom(&this->rotation);
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
void SoLinearDraggerContainer::setVisibility(bool visible)
|
||||
{
|
||||
FC_SET_SWITCH("draggerSwitch", visible? SO_SWITCH_ALL : SO_SWITCH_NONE);
|
||||
}
|
||||
|
||||
bool SoLinearDraggerContainer::isVisible() {
|
||||
auto* sw = SO_GET_ANY_PART(this, "draggerSwitch", SoSwitch);
|
||||
return sw->whichChild.getValue() == SO_SWITCH_ALL;
|
||||
}
|
||||
|
||||
SoLinearDragger* SoLinearDraggerContainer::getDragger()
|
||||
{
|
||||
return SO_GET_PART(this, "dragger", SoLinearDragger);
|
||||
}
|
||||
|
||||
void Gui::SoLinearDraggerContainer::setPointerDirection(const Base::Vector3d& dir)
|
||||
{
|
||||
// This is the direction along which the SoLinearDragger points in it local space
|
||||
Base::Vector3d draggerDir{0, 1, 0};
|
||||
Base::Vector3d axis = draggerDir.Cross(dir).Normalize();
|
||||
double ang = draggerDir.GetAngleOriented(dir, axis);
|
||||
|
||||
SbRotation rot{Base::convertTo<SbVec3f>(axis), static_cast<float>(ang)};
|
||||
rotation.setValue(rot);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef GUI_TDRAGGER_H
|
||||
#define GUI_TDRAGGER_H
|
||||
#ifndef GUI_LINEAR_DRAGGER_H
|
||||
#define GUI_LINEAR_DRAGGER_H
|
||||
|
||||
#include <Inventor/draggers/SoDragger.h>
|
||||
#include <Inventor/fields/SoSFColor.h>
|
||||
@@ -30,9 +30,16 @@
|
||||
#include <Inventor/fields/SoSFInt32.h>
|
||||
#include <Inventor/fields/SoSFRotation.h>
|
||||
#include <Inventor/fields/SoSFString.h>
|
||||
#include <Inventor/fields/SoSFVec3f.h>
|
||||
#include <Inventor/projectors/SbLineProjector.h>
|
||||
#include <Inventor/projectors/SbPlaneProjector.h>
|
||||
#include <Inventor/nodes/SoBaseColor.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
class SoCamera;
|
||||
class SoSwitch;
|
||||
class SoBaseColor;
|
||||
class SoTransform;
|
||||
class SoCalculator;
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
@@ -47,18 +54,14 @@ namespace Gui
|
||||
class SoLinearDragger : public SoDragger
|
||||
{
|
||||
SO_KIT_HEADER(SoLinearDragger);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(activeSwitch);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(activeColor);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(translator);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(activeSwitch);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(secondaryColor);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(cylinderSeparator);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(coneSeparator);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(labelSwitch);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(labelSeparator);
|
||||
|
||||
static constexpr float coneBottomRadius { 0.8f };
|
||||
static constexpr float coneHeight { 2.5f };
|
||||
|
||||
static constexpr float cylinderHeight { 10.0f };
|
||||
static constexpr float cylinderRadius { 0.1f };
|
||||
public:
|
||||
static void initClass();
|
||||
SoLinearDragger();
|
||||
@@ -68,6 +71,14 @@ public:
|
||||
SoSFDouble translationIncrement; //!< set from outside and used for rounding.
|
||||
SoSFInt32 translationIncrementCount; //!< number of steps. used from outside.
|
||||
SoSFFloat autoScaleResult; //!< set from parent dragger.
|
||||
SoSFFloat coneBottomRadius;
|
||||
SoSFFloat coneHeight;
|
||||
SoSFFloat cylinderHeight;
|
||||
SoSFFloat cylinderRadius;
|
||||
SoSFColor activeColor;
|
||||
|
||||
void setLabelVisibility(bool visible);
|
||||
bool isLabelVisible();
|
||||
|
||||
protected:
|
||||
~SoLinearDragger() override;
|
||||
@@ -87,18 +98,48 @@ protected:
|
||||
SbLineProjector projector;
|
||||
|
||||
private:
|
||||
void buildFirstInstance();
|
||||
SbVec3f roundTranslation(const SbVec3f &vecIn, float incrementIn);
|
||||
SoGroup* buildGeometry();
|
||||
SoCalculator* calculator;
|
||||
|
||||
SoSeparator* buildCylinderGeometry() const;
|
||||
SoSeparator* buildConeGeometry() const;
|
||||
SbVec3f roundTranslation(const SbVec3f &vecIn, float incrementIn);
|
||||
|
||||
SoSeparator* buildCylinderGeometry();
|
||||
SoSeparator* buildConeGeometry();
|
||||
SoSeparator* buildLabelGeometry();
|
||||
SoBaseColor* buildActiveColor();
|
||||
void setupGeometryCalculator();
|
||||
|
||||
using inherited = SoDragger;
|
||||
};
|
||||
|
||||
class SoLinearDraggerContainer: public SoInteractionKit
|
||||
{
|
||||
SO_KIT_HEADER(SoLinearDraggerContainer);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(draggerSwitch);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(baseColor);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(transform);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(dragger);
|
||||
|
||||
public:
|
||||
static void initClass();
|
||||
SoLinearDraggerContainer();
|
||||
|
||||
SoSFRotation rotation;
|
||||
SoSFColor color;
|
||||
SoSFVec3f translation;
|
||||
|
||||
void setVisibility(bool visible);
|
||||
bool isVisible();
|
||||
void setPointerDirection(const Base::Vector3d& dir);
|
||||
|
||||
SoLinearDragger* getDragger();
|
||||
|
||||
private:
|
||||
SoBaseColor* buildColor();
|
||||
SoTransform* buildTransform();
|
||||
|
||||
using inherited = SoInteractionKit;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* TDRAGGER_H */
|
||||
#endif /* GUI_LINEAR_DRAGGER_H */
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef GUI_TPLANAR_DRAGGER_H
|
||||
#define GUI_TPLANAR_DRAGGER_H
|
||||
#ifndef GUI_PLANAR_DRAGGER_H
|
||||
#define GUI_PLANAR_DRAGGER_H
|
||||
|
||||
#include <Inventor/draggers/SoDragger.h>
|
||||
#include <Inventor/fields/SoSFColor.h>
|
||||
@@ -88,4 +88,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif /* TPLANAR_DRAGGER */
|
||||
#endif /* GUI_PLANAR_DRAGGER_H */
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef GUI_RDRAGGER_H
|
||||
#define GUI_RDRAGGER_H
|
||||
#ifndef GUI_ROTATION_DRAGGER_H
|
||||
#define GUI_ROTATION_DRAGGER_H
|
||||
|
||||
#include <Inventor/draggers/SoDragger.h>
|
||||
#include <Inventor/fields/SoSFColor.h>
|
||||
@@ -84,4 +84,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif /* GUI_RDRAGGER_H */
|
||||
#endif /* GUI_ROTATION_DRAGGER_H */
|
||||
|
||||
@@ -51,11 +51,13 @@
|
||||
#endif
|
||||
|
||||
#include <Base/Quantity.h>
|
||||
#include <Base/Converter.h>
|
||||
|
||||
#include "SoTransformDragger.h"
|
||||
#include "SoLinearDragger.h"
|
||||
#include "SoPlanarDragger.h"
|
||||
#include "SoRotationDragger.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <SoTextLabel.h>
|
||||
|
||||
@@ -92,7 +94,7 @@ SO_KIT_SOURCE(SoTransformDragger)
|
||||
|
||||
void SoTransformDragger::initClass()
|
||||
{
|
||||
SoLinearDragger::initClass();
|
||||
SoLinearDraggerContainer::initClass();
|
||||
SoPlanarDragger::initClass();
|
||||
SoRotationDragger::initClass();
|
||||
SO_KIT_INIT_CLASS(SoTransformDragger, SoDragger, "Dragger");
|
||||
@@ -110,27 +112,11 @@ SoTransformDragger::SoTransformDragger()
|
||||
SO_KIT_ADD_CATALOG_ENTRY(annotation, So3DAnnotation, TRUE, geomSeparator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(scaleNode, SoScale, TRUE, annotation, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(pickStyle, SoPickStyle, TRUE, annotation, "", TRUE);
|
||||
|
||||
// Translator
|
||||
|
||||
SO_KIT_ADD_CATALOG_ENTRY(xTranslatorSwitch, SoSwitch, TRUE, annotation, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(yTranslatorSwitch, SoSwitch, TRUE, annotation, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(zTranslatorSwitch, SoSwitch, TRUE, annotation, "", TRUE);
|
||||
|
||||
SO_KIT_ADD_CATALOG_ENTRY(xTranslatorSeparator, SoSeparator, TRUE, xTranslatorSwitch, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(yTranslatorSeparator, SoSeparator, TRUE, yTranslatorSwitch, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(zTranslatorSeparator, SoSeparator, TRUE, zTranslatorSwitch, "", TRUE);
|
||||
|
||||
SO_KIT_ADD_CATALOG_ENTRY(xTranslatorColor, SoBaseColor, TRUE, xTranslatorSeparator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(yTranslatorColor, SoBaseColor, TRUE, yTranslatorSeparator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(zTranslatorColor, SoBaseColor, TRUE, zTranslatorSeparator, "", TRUE);
|
||||
|
||||
SO_KIT_ADD_CATALOG_ENTRY(xTranslatorRotation, SoRotation, TRUE, xTranslatorSeparator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(yTranslatorRotation, SoRotation, TRUE, yTranslatorSeparator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(zTranslatorRotation, SoRotation, TRUE, zTranslatorSeparator, "", TRUE);
|
||||
|
||||
SO_KIT_ADD_CATALOG_ENTRY(xTranslatorDragger, SoLinearDragger, TRUE, xTranslatorSeparator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(yTranslatorDragger, SoLinearDragger, TRUE, yTranslatorSeparator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(zTranslatorDragger, SoLinearDragger, TRUE, zTranslatorSeparator, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(xTranslatorDragger, SoLinearDraggerContainer, TRUE, annotation, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(yTranslatorDragger, SoLinearDraggerContainer, TRUE, annotation, "", TRUE);
|
||||
SO_KIT_ADD_CATALOG_ENTRY(zTranslatorDragger, SoLinearDraggerContainer, TRUE, annotation, "", TRUE);
|
||||
|
||||
// Planar Translator
|
||||
|
||||
@@ -264,22 +250,8 @@ SoTransformDragger::SoTransformDragger()
|
||||
SbColor(0, 0, 1.0).getPackedValue(0.0f));
|
||||
|
||||
// Translator
|
||||
SoLinearDragger* tDragger;
|
||||
tDragger = SO_GET_ANY_PART(this, "xTranslatorDragger", SoLinearDragger);
|
||||
tDragger->translationIncrement.connectFrom(&this->translationIncrement);
|
||||
tDragger->autoScaleResult.connectFrom(&this->autoScaleResult);
|
||||
tDragger->label.connectFrom(&xAxisLabel);
|
||||
translationIncrementCountX.connectFrom(&tDragger->translationIncrementCount);
|
||||
tDragger = SO_GET_ANY_PART(this, "yTranslatorDragger", SoLinearDragger);
|
||||
tDragger->translationIncrement.connectFrom(&this->translationIncrement);
|
||||
tDragger->autoScaleResult.connectFrom(&this->autoScaleResult);
|
||||
tDragger->label.connectFrom(&yAxisLabel);
|
||||
translationIncrementCountY.connectFrom(&tDragger->translationIncrementCount);
|
||||
tDragger = SO_GET_ANY_PART(this, "zTranslatorDragger", SoLinearDragger);
|
||||
tDragger->translationIncrement.connectFrom(&this->translationIncrement);
|
||||
tDragger->autoScaleResult.connectFrom(&this->autoScaleResult);
|
||||
tDragger->label.connectFrom(&zAxisLabel);
|
||||
translationIncrementCountZ.connectFrom(&tDragger->translationIncrementCount);
|
||||
setupTranslationDraggers();
|
||||
|
||||
// Planar Translator
|
||||
SoPlanarDragger* tPlanarDragger;
|
||||
tPlanarDragger = SO_GET_ANY_PART(this, "xyPlanarTranslatorDragger", SoPlanarDragger);
|
||||
@@ -310,14 +282,7 @@ SoTransformDragger::SoTransformDragger()
|
||||
rotationIncrementCountZ.connectFrom(&rDragger->rotationIncrementCount);
|
||||
|
||||
// Switches
|
||||
|
||||
// Translator
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL);
|
||||
sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL);
|
||||
sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL);
|
||||
SoSwitch* sw;
|
||||
// Planar Translator
|
||||
sw = SO_GET_ANY_PART(this, "xyPlanarTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL);
|
||||
@@ -338,13 +303,6 @@ SoTransformDragger::SoTransformDragger()
|
||||
SoRotation* localRotation;
|
||||
SbRotation tempRotation;
|
||||
auto angle = static_cast<float>(std::numbers::pi / 2.0);
|
||||
// Translator
|
||||
localRotation = SO_GET_ANY_PART(this, "xTranslatorRotation", SoRotation);
|
||||
localRotation->rotation.setValue(SbVec3f(0.0, 0.0, -1.0), angle);
|
||||
localRotation = SO_GET_ANY_PART(this, "yTranslatorRotation", SoRotation);
|
||||
localRotation->rotation.setValue(SbRotation::identity());
|
||||
localRotation = SO_GET_ANY_PART(this, "zTranslatorRotation", SoRotation);
|
||||
localRotation->rotation.setValue(SbVec3f(1.0, 0.0, 0.0), angle);
|
||||
// Planar Translator
|
||||
localRotation = SO_GET_ANY_PART(this, "xyPlanarTranslatorRotation", SoRotation);
|
||||
localRotation->rotation.setValue(SbRotation::identity());
|
||||
@@ -420,9 +378,9 @@ SbBool SoTransformDragger::setUpConnections(SbBool onoff, SbBool doitalways)
|
||||
return onoff;
|
||||
}
|
||||
|
||||
SoLinearDragger* tDraggerX = SO_GET_ANY_PART(this, "xTranslatorDragger", SoLinearDragger);
|
||||
SoLinearDragger* tDraggerY = SO_GET_ANY_PART(this, "yTranslatorDragger", SoLinearDragger);
|
||||
SoLinearDragger* tDraggerZ = SO_GET_ANY_PART(this, "zTranslatorDragger", SoLinearDragger);
|
||||
auto tDraggerX = SO_GET_ANY_PART(this, "xTranslatorDragger", SoLinearDraggerContainer);
|
||||
auto tDraggerY = SO_GET_ANY_PART(this, "yTranslatorDragger", SoLinearDraggerContainer);
|
||||
auto tDraggerZ = SO_GET_ANY_PART(this, "zTranslatorDragger", SoLinearDraggerContainer);
|
||||
SoPlanarDragger* tPlanarDraggerXZ =
|
||||
SO_GET_ANY_PART(this, "xyPlanarTranslatorDragger", SoPlanarDragger);
|
||||
SoPlanarDragger* tPlanarDraggerYZ =
|
||||
@@ -436,9 +394,9 @@ SbBool SoTransformDragger::setUpConnections(SbBool onoff, SbBool doitalways)
|
||||
if (onoff) {
|
||||
inherited::setUpConnections(onoff, doitalways);
|
||||
|
||||
registerChildDragger(tDraggerX);
|
||||
registerChildDragger(tDraggerY);
|
||||
registerChildDragger(tDraggerZ);
|
||||
registerChildDragger(tDraggerX->getDragger());
|
||||
registerChildDragger(tDraggerY->getDragger());
|
||||
registerChildDragger(tDraggerZ->getDragger());
|
||||
registerChildDragger(tPlanarDraggerXZ);
|
||||
registerChildDragger(tPlanarDraggerYZ);
|
||||
registerChildDragger(tPlanarDraggerZX);
|
||||
@@ -457,9 +415,9 @@ SbBool SoTransformDragger::setUpConnections(SbBool onoff, SbBool doitalways)
|
||||
}
|
||||
}
|
||||
else {
|
||||
unregisterChildDragger(tDraggerX);
|
||||
unregisterChildDragger(tDraggerY);
|
||||
unregisterChildDragger(tDraggerZ);
|
||||
unregisterChildDragger(tDraggerX->getDragger());
|
||||
unregisterChildDragger(tDraggerY->getDragger());
|
||||
unregisterChildDragger(tDraggerZ->getDragger());
|
||||
unregisterChildDragger(tPlanarDraggerXZ);
|
||||
unregisterChildDragger(tPlanarDraggerYZ);
|
||||
unregisterChildDragger(tPlanarDraggerZX);
|
||||
@@ -669,12 +627,13 @@ void SoTransformDragger::setAxisColors(unsigned long x, unsigned long y, unsigne
|
||||
SoBaseColor* color;
|
||||
|
||||
// Translator
|
||||
color = SO_GET_ANY_PART(this, "xTranslatorColor", SoBaseColor);
|
||||
color->rgb.setValue(colorX[0], colorX[1], colorX[2]);
|
||||
color = SO_GET_ANY_PART(this, "yTranslatorColor", SoBaseColor);
|
||||
color->rgb.setValue(colorY[0], colorY[1], colorY[2]);
|
||||
color = SO_GET_ANY_PART(this, "zTranslatorColor", SoBaseColor);
|
||||
color->rgb.setValue(colorZ[0], colorZ[1], colorZ[2]);
|
||||
SoLinearDraggerContainer* tDragger;
|
||||
tDragger = SO_GET_ANY_PART(this, "xTranslatorDragger", SoLinearDraggerContainer);
|
||||
tDragger->color.setValue(colorX[0], colorX[1], colorX[2]);
|
||||
tDragger = SO_GET_ANY_PART(this, "yTranslatorDragger", SoLinearDraggerContainer);
|
||||
tDragger->color.setValue(colorY[0], colorY[1], colorY[2]);
|
||||
tDragger = SO_GET_ANY_PART(this, "zTranslatorDragger", SoLinearDraggerContainer);
|
||||
tDragger->color.setValue(colorZ[0], colorZ[1], colorZ[2]);
|
||||
// Planar Translator
|
||||
color = SO_GET_ANY_PART(this, "xyPlanarTranslatorColor", SoBaseColor);
|
||||
color->rgb.setValue(colorZ[0], colorZ[1], colorZ[2]);
|
||||
@@ -696,66 +655,50 @@ void SoTransformDragger::setAxisColors(unsigned long x, unsigned long y, unsigne
|
||||
// Translator
|
||||
void SoTransformDragger::showTranslationX()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL);
|
||||
auto tDragger = SO_GET_ANY_PART(this, "xTranslatorDragger", SoLinearDraggerContainer);
|
||||
tDragger->setVisibility(true);
|
||||
}
|
||||
void SoTransformDragger::showTranslationY()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL);
|
||||
auto tDragger = SO_GET_ANY_PART(this, "yTranslatorDragger", SoLinearDraggerContainer);
|
||||
tDragger->setVisibility(true);
|
||||
}
|
||||
void SoTransformDragger::showTranslationZ()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL);
|
||||
auto tDragger = SO_GET_ANY_PART(this, "zTranslatorDragger", SoLinearDraggerContainer);
|
||||
tDragger->setVisibility(true);
|
||||
}
|
||||
|
||||
void SoTransformDragger::hideTranslationX()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE);
|
||||
auto tDragger = SO_GET_ANY_PART(this, "xTranslatorDragger", SoLinearDraggerContainer);
|
||||
tDragger->setVisibility(false);
|
||||
}
|
||||
void SoTransformDragger::hideTranslationY()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE);
|
||||
auto tDragger = SO_GET_ANY_PART(this, "yTranslatorDragger", SoLinearDraggerContainer);
|
||||
tDragger->setVisibility(false);
|
||||
}
|
||||
void SoTransformDragger::hideTranslationZ()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch);
|
||||
SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE);
|
||||
auto tDragger = SO_GET_ANY_PART(this, "zTranslatorDragger", SoLinearDraggerContainer);
|
||||
tDragger->setVisibility(false);
|
||||
}
|
||||
|
||||
bool SoTransformDragger::isShownTranslationX()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch);
|
||||
return (sw->whichChild.getValue() == SO_SWITCH_ALL);
|
||||
auto tDragger = SO_GET_ANY_PART(this, "xTranslatorDragger", SoLinearDraggerContainer);
|
||||
return tDragger->isVisible();
|
||||
}
|
||||
bool SoTransformDragger::isShownTranslationY()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch);
|
||||
return (sw->whichChild.getValue() == SO_SWITCH_ALL);
|
||||
auto tDragger = SO_GET_ANY_PART(this, "yTranslatorDragger", SoLinearDraggerContainer);
|
||||
return tDragger->isVisible();
|
||||
}
|
||||
bool SoTransformDragger::isShownTranslationZ()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch);
|
||||
return (sw->whichChild.getValue() == SO_SWITCH_ALL);
|
||||
}
|
||||
|
||||
bool SoTransformDragger::isHiddenTranslationX()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch);
|
||||
return (sw->whichChild.getValue() == SO_SWITCH_NONE);
|
||||
}
|
||||
bool SoTransformDragger::isHiddenTranslationY()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch);
|
||||
return (sw->whichChild.getValue() == SO_SWITCH_NONE);
|
||||
}
|
||||
bool SoTransformDragger::isHiddenTranslationZ()
|
||||
{
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch);
|
||||
return (sw->whichChild.getValue() == SO_SWITCH_NONE);
|
||||
auto tDragger = SO_GET_ANY_PART(this, "zTranslatorDragger", SoLinearDraggerContainer);
|
||||
return tDragger->isVisible();
|
||||
}
|
||||
|
||||
// Planar Translator
|
||||
@@ -887,3 +830,23 @@ bool SoTransformDragger::isHiddenRotationZ()
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, "zRotatorSwitch", SoSwitch);
|
||||
return (sw->whichChild.getValue() == SO_SWITCH_NONE);
|
||||
}
|
||||
|
||||
void SoTransformDragger::setupTranslationDraggers()
|
||||
{
|
||||
setupTranslationDragger("xTranslatorDragger", &xAxisLabel, translationIncrementCountX, SbVec3d(1.0, 0.0, 0.0));
|
||||
setupTranslationDragger("yTranslatorDragger", &yAxisLabel, translationIncrementCountY, SbVec3d(0.0, 1.0, 0.0));
|
||||
setupTranslationDragger("zTranslatorDragger", &zAxisLabel, translationIncrementCountZ, SbVec3d(0.0, 0.0, 1.0));
|
||||
}
|
||||
|
||||
void SoTransformDragger::setupTranslationDragger(const std::string& name, SoSFString* label, SoSFInt32& incrementCount, const SbVec3d& rotDir)
|
||||
{
|
||||
SoLinearDraggerContainer* draggerContainer = SO_GET_ANY_PART(this, name.c_str(), SoLinearDraggerContainer);
|
||||
SoLinearDragger* dragger = draggerContainer->getDragger();
|
||||
|
||||
dragger->translationIncrement.connectFrom(&this->translationIncrement);
|
||||
dragger->autoScaleResult.connectFrom(&this->autoScaleResult);
|
||||
dragger->label.connectFrom(label);
|
||||
incrementCount.connectFrom(&dragger->translationIncrementCount);
|
||||
|
||||
draggerContainer->setPointerDirection(Base::convertTo<Base::Vector3d>(rotDir));
|
||||
}
|
||||
|
||||
@@ -34,10 +34,15 @@
|
||||
#include <Inventor/nodes/SoBaseColor.h>
|
||||
#include <FCGlobal.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
class SoCamera;
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
class SoLinearDraggerContainer;
|
||||
|
||||
/*! @brief Coordinate System Dragger
|
||||
*
|
||||
* used to transform objects in 3d space. Set initial:
|
||||
@@ -57,18 +62,6 @@ class GuiExport SoTransformDragger : public SoDragger
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(scaleNode);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(pickStyle);
|
||||
// Translator
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(xTranslatorSwitch);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(yTranslatorSwitch);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(zTranslatorSwitch);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(xTranslatorSeparator);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(yTranslatorSeparator);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(zTranslatorSeparator);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(xTranslatorColor);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(yTranslatorColor);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(zTranslatorColor);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(xTranslatorRotation);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(yTranslatorRotation);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(zTranslatorRotation);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(xTranslatorDragger);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(yTranslatorDragger);
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(zTranslatorDragger);
|
||||
@@ -152,9 +145,6 @@ public:
|
||||
bool isShownTranslationX(); //!< is x translation dragger shown.
|
||||
bool isShownTranslationY(); //!< is y translation dragger shown.
|
||||
bool isShownTranslationZ(); //!< is z translation dragger shown.
|
||||
bool isHiddenTranslationX(); //!< is x translation dragger hidden.
|
||||
bool isHiddenTranslationY(); //!< is y translation dragger hidden.
|
||||
bool isHiddenTranslationZ(); //!< is z translation dragger hidden.
|
||||
|
||||
void showPlanarTranslationXY(); //!< show the xy planar translation dragger.
|
||||
void showPlanarTranslationYZ(); //!< show the yz planar translation dragger.
|
||||
@@ -210,6 +200,9 @@ private:
|
||||
|
||||
void updateAxisScale();
|
||||
|
||||
void setupTranslationDraggers();
|
||||
void setupTranslationDragger(const std::string& name, SoSFString* label, SoSFInt32& incrementCount, const SbVec3d& rotDir);
|
||||
|
||||
using inherited = SoDragger;
|
||||
};
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ void Gui::SoFCDB::init()
|
||||
SoFCTransform ::initClass();
|
||||
SoAutoZoomTranslation ::initClass();
|
||||
MarkerBitmaps ::initClass();
|
||||
SoTransformDragger ::initClass();
|
||||
SoTransformDragger ::initClass();
|
||||
SmSwitchboard ::initClass();
|
||||
SoFCSeparator ::initClass();
|
||||
SoFCSelectionRoot ::initClass();
|
||||
|
||||
@@ -441,6 +441,41 @@ private:
|
||||
class MatchName;
|
||||
};
|
||||
|
||||
#define FC_ADD_CATALOG_ENTRY(__part__, __partclass__, __parent__) SO_KIT_ADD_CATALOG_ENTRY(__part__, __partclass__, TRUE, __parent__, "", TRUE);
|
||||
|
||||
#define FC_SET_SWITCH(__name__, __state__) \
|
||||
do { \
|
||||
SoSwitch* sw = SO_GET_ANY_PART(this, __name__, SoSwitch); \
|
||||
sw->whichChild = __state__; \
|
||||
} while (0)
|
||||
|
||||
|
||||
struct RotationComponents {
|
||||
float angle;
|
||||
SbVec3f axis;
|
||||
};
|
||||
|
||||
[[nodiscard]] inline RotationComponents getRotationComponents(const SbRotation &rotation) {
|
||||
RotationComponents comps;
|
||||
rotation.getValue(comps.axis, comps.angle);
|
||||
|
||||
return comps;
|
||||
}
|
||||
|
||||
struct TransformComponents {
|
||||
SbVec3f translation;
|
||||
SbVec3f scale;
|
||||
SbRotation rotation;
|
||||
SbRotation scaleOrientation;
|
||||
};
|
||||
|
||||
[[nodiscard]] inline TransformComponents getMatrixTransform(const SbMatrix &matrix) {
|
||||
TransformComponents comps;
|
||||
matrix.getTransform(comps.translation, comps.rotation, comps.scale, comps.scaleOrientation);
|
||||
|
||||
return comps;
|
||||
}
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_UTILITIES_H
|
||||
|
||||
Reference in New Issue
Block a user