From 01ff476b2fff7c14d350732fa39c3b5f490a9a00 Mon Sep 17 00:00:00 2001 From: qewer <69015181+qewer33@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:34:26 +0300 Subject: [PATCH] Gui: Transform dragger improvements (#10706) * Gui: Improve transform dragger appereance * Gui: Implement axis color parameters * Gui: Implement plane draggers for the Transform tool * Gui: Clean comments in Transform dragger files --- src/Gui/SoFCCSysDragger.cpp | 597 ++++++++++++++++++++++++++++---- src/Gui/SoFCCSysDragger.h | 95 ++++- src/Gui/ViewParams.h | 7 + src/Gui/ViewProviderDragger.cpp | 14 +- 4 files changed, 625 insertions(+), 88 deletions(-) diff --git a/src/Gui/SoFCCSysDragger.cpp b/src/Gui/SoFCCSysDragger.cpp index 038d09f22f..a248e26455 100644 --- a/src/Gui/SoFCCSysDragger.cpp +++ b/src/Gui/SoFCCSysDragger.cpp @@ -27,11 +27,15 @@ #include #include #include +#include +#include +#include #include #include #include #include #include +#include #include #include #include @@ -45,6 +49,8 @@ #endif #include +#include "Gui/ViewParams.h" +#include "App/Color.h" #include "SoFCCSysDragger.h" #include "MainWindow.h" @@ -164,10 +170,14 @@ SoGroup* TDragger::buildGeometry() //cylinder float cylinderHeight = 10.0; - float cylinderRadius = 0.2f; + float cylinderRadius = 0.1f; auto cylinderSeparator = new SoSeparator(); root->addChild(cylinderSeparator); + auto cylinderLightModel = new SoLightModel(); + cylinderLightModel->model = SoLightModel::BASE_COLOR; + cylinderSeparator->addChild(cylinderLightModel); + auto cylinderTranslation = new SoTranslation(); cylinderTranslation->translation.setValue(0.0, cylinderHeight / 2.0, 0.0); cylinderSeparator->addChild(cylinderTranslation); @@ -178,11 +188,15 @@ SoGroup* TDragger::buildGeometry() cylinderSeparator->addChild(cylinder); //cone - float coneBottomRadius = 1.0; - float coneHeight = 2.0; + float coneBottomRadius = 0.8; + float coneHeight = 2.5; auto coneSeparator = new SoSeparator(); root->addChild(coneSeparator); + auto coneLightModel = new SoLightModel(); + coneLightModel->model = SoLightModel::BASE_COLOR; + coneSeparator->addChild(coneLightModel); + auto pickStyle = new SoPickStyle(); pickStyle->style.setValue(SoPickStyle::SHAPE); pickStyle->setOverride(TRUE); @@ -357,13 +371,292 @@ SbVec3f TDragger::roundTranslation(const SbVec3f &vecIn, float incrementIn) translationIncrementCount.setValue(yCount); SbVec3f out; - out[0] = 0.0; + out[0] = 0; out[1] = static_cast(yCount) * incrementIn; out[2] = 0.0; return out; } + +SO_KIT_SOURCE(TPlanarDragger) + +void TPlanarDragger::initClass() +{ + SO_KIT_INIT_CLASS(TPlanarDragger, SoDragger, "Dragger"); +} + +TPlanarDragger::TPlanarDragger() +{ + SO_KIT_CONSTRUCTOR(TPlanarDragger); + + SO_KIT_ADD_CATALOG_ENTRY(planarTranslatorSwitch, SoSwitch, TRUE, geomSeparator, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(planarTranslator, SoSeparator, TRUE, planarTranslatorSwitch, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(planarTranslatorActive, SoSeparator, TRUE, planarTranslatorSwitch, "", TRUE); + + if (SO_KIT_IS_FIRST_INSTANCE()) + buildFirstInstance(); + + SO_KIT_ADD_FIELD(translation, (0.0, 0.0, 0.0)); + SO_KIT_ADD_FIELD(translationIncrement, (1.0)); + SO_KIT_ADD_FIELD(translationIncrementXCount, (0)); + SO_KIT_ADD_FIELD(translationIncrementYCount, (0)); + SO_KIT_ADD_FIELD(autoScaleResult, (1.0)); + + SO_KIT_INIT_INSTANCE(); + + // initialize default parts. + // first is from 'SO_KIT_CATALOG_ENTRY_HEADER' macro + // second is unique name from buildFirstInstance(). + this->setPartAsDefault("planarTranslator", "CSysDynamics_TPlanarDragger_Translator"); + this->setPartAsDefault("planarTranslatorActive", "CSysDynamics_TPlanarDragger_TranslatorActive"); + + SoSwitch *sw = SO_GET_ANY_PART(this, "planarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, 0); + + this->addStartCallback(&TPlanarDragger::startCB); + this->addMotionCallback(&TPlanarDragger::motionCB); + this->addFinishCallback(&TPlanarDragger::finishCB); + + addValueChangedCallback(&TPlanarDragger::valueChangedCB); + + fieldSensor.setFunction(&TPlanarDragger::fieldSensorCB); + fieldSensor.setData(this); + fieldSensor.setPriority(0); + + this->setUpConnections(TRUE, TRUE); +} + +TPlanarDragger::~TPlanarDragger() +{ + fieldSensor.setData(nullptr); + fieldSensor.detach(); + + this->removeStartCallback(&TPlanarDragger::startCB); + this->removeMotionCallback(&TPlanarDragger::motionCB); + this->removeFinishCallback(&TPlanarDragger::finishCB); + removeValueChangedCallback(&TPlanarDragger::valueChangedCB); +} + +void TPlanarDragger::buildFirstInstance() +{ + SoGroup *geometryGroup = buildGeometry(); + + auto localTranslator = new SoSeparator(); + localTranslator->setName("CSysDynamics_TPlanarDragger_Translator"); + localTranslator->addChild(geometryGroup); + SoFCDB::getStorage()->addChild(localTranslator); + + auto localTranslatorActive = new SoSeparator(); + localTranslatorActive->setName("CSysDynamics_TPlanarDragger_TranslatorActive"); + auto colorActive = new SoBaseColor(); + colorActive->rgb.setValue(1.0, 1.0, 0.0); + localTranslatorActive->addChild(colorActive); + localTranslatorActive->addChild(geometryGroup); + SoFCDB::getStorage()->addChild(localTranslatorActive); +} + +SoGroup* TPlanarDragger::buildGeometry() +{ + auto root = new SoGroup(); + + float cubeWidthHeight = 2.0; + float cubeDepth = 0.1f; + + auto translation = new SoTranslation(); + translation->translation.setValue(cubeWidthHeight + 0.15, cubeWidthHeight + 0.15, 0.0); + root->addChild(translation); + + auto pickStyle = new SoPickStyle(); + pickStyle->style.setValue(SoPickStyle::SHAPE); + pickStyle->setOverride(TRUE); + root->addChild(pickStyle); + + auto lightModel = new SoLightModel(); + lightModel->model = SoLightModel::BASE_COLOR; + root->addChild(lightModel); + + auto cube = new SoCube(); + cube->width.setValue(cubeWidthHeight); + cube->height.setValue(cubeWidthHeight); + cube->depth.setValue(cubeDepth); + root->addChild(cube); + + return root; +} + +void TPlanarDragger::startCB(void *, SoDragger *d) +{ + auto sudoThis = static_cast(d); + assert(sudoThis); + sudoThis->dragStart(); +} + +void TPlanarDragger::motionCB(void *, SoDragger *d) +{ + auto sudoThis = static_cast(d); + assert(sudoThis); + sudoThis->drag(); +} + +void TPlanarDragger::finishCB(void *, SoDragger *d) +{ + auto sudoThis = static_cast(d); + assert(sudoThis); + sudoThis->dragFinish(); +} + +void TPlanarDragger::fieldSensorCB(void *f, SoSensor *) +{ + auto sudoThis = static_cast(f); + + if(!f) + return; + + SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft + sudoThis->workFieldsIntoTransform(matrix); + sudoThis->setMotionMatrix(matrix); +} + +void TPlanarDragger::valueChangedCB(void *, SoDragger *d) +{ + auto sudoThis = dynamic_cast(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); + + sudoThis->fieldSensor.detach(); + if (sudoThis->translation.getValue() != trans) + sudoThis->translation = trans; + sudoThis->fieldSensor.attach(&sudoThis->translation); +} + +void TPlanarDragger::dragStart() +{ + SoSwitch *sw; + sw = SO_GET_ANY_PART(this, "planarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, 1); + + projector.setViewVolume(this->getViewVolume()); + projector.setWorkingSpace(this->getLocalToWorldMatrix()); + projector.setPlane(SbPlane(SbVec3f(0.0, 0.0, 0.0), SbVec3f(1.0, 0.0, 0.0), SbVec3f(0.0, 1.0, 0.0))); + SbVec3f hitPoint = projector.project(getNormalizedLocaterPosition()); + + SbMatrix localToWorld = getLocalToWorldMatrix(); + localToWorld.multVecMatrix(hitPoint, hitPoint); + setStartingPoint((hitPoint)); + + translationIncrementXCount.setValue(0); + translationIncrementYCount.setValue(0); +} +void TPlanarDragger::drag() +{ + projector.setViewVolume(this->getViewVolume()); + projector.setWorkingSpace(this->getLocalToWorldMatrix()); + + SbVec3f hitPoint = projector.project(getNormalizedLocaterPosition()); + SbVec3f startingPoint = getLocalStartingPoint(); + SbVec3f localMovement = hitPoint - startingPoint; + + //scale the increment to match local space. + float scaledIncrement = static_cast(translationIncrement.getValue()) / autoScaleResult.getValue(); + + localMovement = roundTranslation(localMovement, scaledIncrement); + //when the movement vector is null either the appendTranslation or + //the setMotionMatrix doesn't work. either way it stops translating + //back to its initial starting point. + if (localMovement.equals(SbVec3f(0.0, 0.0, 0.0), 0.00001f)) + { + setMotionMatrix(getStartMotionMatrix()); + //don't know why I need the following but if I don't have it + //it won't return to original position. + this->valueChanged(); + } + else + setMotionMatrix(appendTranslation(getStartMotionMatrix(), localMovement)); + + Base::Quantity quantityX( + static_cast(translationIncrementXCount.getValue()) * translationIncrement.getValue(), Base::Unit::Length); + Base::Quantity quantityY( + static_cast(translationIncrementYCount.getValue()) * translationIncrement.getValue(), Base::Unit::Length); + + QString message = QString::fromLatin1("%1 %2, %3") + .arg(QObject::tr("Translation XY:"), quantityX.getUserString(), quantityY.getUserString()); + getMainWindow()->showMessage(message, 3000); +} + +void TPlanarDragger::dragFinish() +{ + SoSwitch *sw; + sw = SO_GET_ANY_PART(this, "planarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, 0); +} + +SbBool TPlanarDragger::setUpConnections(SbBool onoff, SbBool doitalways) +{ + if (!doitalways && this->connectionsSetUp == onoff) + return onoff; + + SbBool oldval = this->connectionsSetUp; + + if (onoff) + { + inherited::setUpConnections(onoff, doitalways); + TPlanarDragger::fieldSensorCB(this, nullptr); + if (this->fieldSensor.getAttachedField() != &this->translation) + this->fieldSensor.attach(&this->translation); + } + else + { + if (this->fieldSensor.getAttachedField()) + this->fieldSensor.detach(); + inherited::setUpConnections(onoff, doitalways); + } + this->connectionsSetUp = onoff; + return oldval; +} + +SbVec3f TPlanarDragger::roundTranslation(const SbVec3f &vecIn, float incrementIn) +{ + int xCount = 0; + float xValue = vecIn[0]; + + if (fabs(xValue) > (incrementIn / 2.0)) + { + xCount = static_cast(xValue / incrementIn); + float remainder = fmod(xValue, incrementIn); + if (remainder >= (incrementIn / 2.0)) + xCount++; + } + + translationIncrementXCount.setValue(xCount); + + int yCount = 0; + float yValue = vecIn[1]; + + if (fabs(yValue) > (incrementIn / 2.0)) + { + yCount = static_cast(yValue / incrementIn); + float remainder = fmod(yValue, incrementIn); + if (remainder >= (incrementIn / 2.0)) + yCount++; + } + + translationIncrementYCount.setValue(yCount); + + SbVec3f out; + out[0] = static_cast(xCount) * incrementIn; + out[1] = static_cast(yCount) * incrementIn; + out[2] = 0.0; + + return out; +} + + SO_KIT_SOURCE(RDragger) void RDragger::initClass() @@ -448,7 +741,7 @@ SoGroup* RDragger::buildGeometry() //arc auto coordinates = new SoCoordinate3(); - unsigned int segments = 6; + unsigned int segments = 15; float angleIncrement = static_cast(M_PI / 2.0) / static_cast(segments); SbRotation rotation(SbVec3f(0.0, 0.0, 1.0), angleIncrement); @@ -460,6 +753,14 @@ SoGroup* RDragger::buildGeometry() } root->addChild(coordinates); + auto drawStyle = new SoDrawStyle(); + drawStyle->lineWidth = 4.0; + root->addChild(drawStyle); + + auto lightModel = new SoLightModel(); + lightModel->model = SoLightModel::BASE_COLOR; + root->addChild(lightModel); + auto lineSet = new SoLineSet(); lineSet->numVertices.setValue(segments + 1); root->addChild(lineSet); @@ -478,7 +779,7 @@ SoGroup* RDragger::buildGeometry() root->addChild(sphereTranslation); auto sphere = new SoSphere(); - sphere->radius.setValue(1.0); + sphere->radius.setValue(0.8); root->addChild(sphere); return root; @@ -656,6 +957,7 @@ SO_KIT_SOURCE(SoFCCSysDragger) void SoFCCSysDragger::initClass() { TDragger::initClass(); + TPlanarDragger::initClass(); RDragger::initClass(); SO_KIT_INIT_CLASS(SoFCCSysDragger, SoDragger, "Dragger"); } @@ -668,6 +970,8 @@ SoFCCSysDragger::SoFCCSysDragger() SO_KIT_ADD_CATALOG_ENTRY(annotation, SoAnnotation, TRUE, geomSeparator, "", TRUE); SO_KIT_ADD_CATALOG_ENTRY(scaleNode, SoScale, 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); @@ -688,6 +992,30 @@ SoFCCSysDragger::SoFCCSysDragger() SO_KIT_ADD_CATALOG_ENTRY(yTranslatorDragger, TDragger, TRUE, yTranslatorSeparator, "", TRUE); SO_KIT_ADD_CATALOG_ENTRY(zTranslatorDragger, TDragger, TRUE, zTranslatorSeparator, "", TRUE); + // Planar Translator + + SO_KIT_ADD_CATALOG_ENTRY(xyPlanarTranslatorSwitch, SoSwitch, TRUE, annotation, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(yzPlanarTranslatorSwitch, SoSwitch, TRUE, annotation, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(zxPlanarTranslatorSwitch, SoSwitch, TRUE, annotation, "", TRUE); + + SO_KIT_ADD_CATALOG_ENTRY(xyPlanarTranslatorSeparator, SoSeparator, TRUE, xyPlanarTranslatorSwitch, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(yzPlanarTranslatorSeparator, SoSeparator, TRUE, yzPlanarTranslatorSwitch, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(zxPlanarTranslatorSeparator, SoSeparator, TRUE, zxPlanarTranslatorSwitch, "", TRUE); + + SO_KIT_ADD_CATALOG_ENTRY(xyPlanarTranslatorColor, SoBaseColor, TRUE, xyPlanarTranslatorSeparator, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(yzPlanarTranslatorColor, SoBaseColor, TRUE, yzPlanarTranslatorSeparator, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(zxPlanarTranslatorColor, SoBaseColor, TRUE, zxPlanarTranslatorSeparator, "", TRUE); + + SO_KIT_ADD_CATALOG_ENTRY(xyPlanarTranslatorRotation, SoRotation, TRUE, xyPlanarTranslatorSeparator, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(yzPlanarTranslatorRotation, SoRotation, TRUE, yzPlanarTranslatorSeparator, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(zxPlanarTranslatorRotation, SoRotation, TRUE, zxPlanarTranslatorSeparator, "", TRUE); + + SO_KIT_ADD_CATALOG_ENTRY(xyPlanarTranslatorDragger, TPlanarDragger, TRUE, xyPlanarTranslatorSeparator, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(yzPlanarTranslatorDragger, TPlanarDragger, TRUE, yzPlanarTranslatorSeparator, "", TRUE); + SO_KIT_ADD_CATALOG_ENTRY(zxPlanarTranslatorDragger, TPlanarDragger, TRUE, zxPlanarTranslatorSeparator, "", TRUE); + + // Rotator + SO_KIT_ADD_CATALOG_ENTRY(xRotatorSwitch, SoSwitch, TRUE, annotation, "", TRUE); SO_KIT_ADD_CATALOG_ENTRY(yRotatorSwitch, SoSwitch, TRUE, annotation, "", TRUE); SO_KIT_ADD_CATALOG_ENTRY(zRotatorSwitch, SoSwitch, TRUE, annotation, "", TRUE); @@ -708,6 +1036,8 @@ SoFCCSysDragger::SoFCCSysDragger() SO_KIT_ADD_CATALOG_ENTRY(yRotatorDragger, RDragger, TRUE, yRotatorSeparator, "", TRUE); SO_KIT_ADD_CATALOG_ENTRY(zRotatorDragger, RDragger, TRUE, zRotatorSeparator, "", TRUE); + // Other + SO_KIT_ADD_FIELD(translation, (0.0, 0.0, 0.0)); SO_KIT_ADD_FIELD(translationIncrement, (1.0)); SO_KIT_ADD_FIELD(translationIncrementCountX, (0)); @@ -725,36 +1055,76 @@ SoFCCSysDragger::SoFCCSysDragger() SO_KIT_INIT_INSTANCE(); - SoBaseColor *color; - color = SO_GET_ANY_PART(this, "xTranslatorColor", SoBaseColor); - color->rgb.setValue(1.0, 0.0, 0.0); - color = SO_GET_ANY_PART(this, "yTranslatorColor", SoBaseColor); - color->rgb.setValue(0.0, 1.0, 0.0); - color = SO_GET_ANY_PART(this, "zTranslatorColor", SoBaseColor); - color->rgb.setValue(0.0, 0.0, 1.0); - color = SO_GET_ANY_PART(this, "xRotatorColor", SoBaseColor); - color->rgb.setValue(1.0, 0.0, 0.0); - color = SO_GET_ANY_PART(this, "yRotatorColor", SoBaseColor); - color->rgb.setValue(0.0, 1.0, 0.0); - color = SO_GET_ANY_PART(this, "zRotatorColor", SoBaseColor); - color->rgb.setValue(0.0, 0.0, 1.0); + // Colors + SoBaseColor *color; + App::Color stdColor; + auto viewParams = Gui::ViewParams::instance(); + // Translator + color = SO_GET_ANY_PART(this, "xTranslatorColor", SoBaseColor); + stdColor.setPackedValue(viewParams->getAxisXColor()); + color->rgb.setValue(stdColor.r, stdColor.g, stdColor.b); + color = SO_GET_ANY_PART(this, "yTranslatorColor", SoBaseColor); + stdColor.setPackedValue(viewParams->getAxisYColor()); + color->rgb.setValue(stdColor.r, stdColor.g, stdColor.b); + color = SO_GET_ANY_PART(this, "zTranslatorColor", SoBaseColor); + stdColor.setPackedValue(viewParams->getAxisZColor()); + color->rgb.setValue(stdColor.r, stdColor.g, stdColor.b); + // Planar Translator + color = SO_GET_ANY_PART(this, "xyPlanarTranslatorColor", SoBaseColor); + stdColor.setPackedValue(viewParams->getAxisZColor()); + color->rgb.setValue(stdColor.r, stdColor.g, stdColor.b); + color = SO_GET_ANY_PART(this, "yzPlanarTranslatorColor", SoBaseColor); + stdColor.setPackedValue(viewParams->getAxisXColor()); + color->rgb.setValue(stdColor.r, stdColor.g, stdColor.b); + color = SO_GET_ANY_PART(this, "zxPlanarTranslatorColor", SoBaseColor); + stdColor.setPackedValue(viewParams->getAxisYColor()); + color->rgb.setValue(stdColor.r, stdColor.g, stdColor.b); + // Rotator + color = SO_GET_ANY_PART(this, "xRotatorColor", SoBaseColor); + stdColor.setPackedValue(viewParams->getAxisXAltColor()); + color->rgb.setValue(stdColor.r, stdColor.g, stdColor.b); + color = SO_GET_ANY_PART(this, "yRotatorColor", SoBaseColor); + stdColor.setPackedValue(viewParams->getAxisYAltColor()); + color->rgb.setValue(stdColor.r, stdColor.g, stdColor.b); + color = SO_GET_ANY_PART(this, "zRotatorColor", SoBaseColor); + stdColor.setPackedValue(viewParams->getAxisZAltColor()); + color->rgb.setValue(stdColor.r, stdColor.g, stdColor.b); + + // Increments + + // Translator TDragger *tDragger; tDragger = SO_GET_ANY_PART(this, "xTranslatorDragger", TDragger); tDragger->translationIncrement.connectFrom(&this->translationIncrement); tDragger->autoScaleResult.connectFrom(&this->autoScaleResult); translationIncrementCountX.connectFrom(&tDragger->translationIncrementCount); - tDragger = SO_GET_ANY_PART(this, "yTranslatorDragger", TDragger); tDragger->translationIncrement.connectFrom(&this->translationIncrement); tDragger->autoScaleResult.connectFrom(&this->autoScaleResult); translationIncrementCountY.connectFrom(&tDragger->translationIncrementCount); - tDragger = SO_GET_ANY_PART(this, "zTranslatorDragger", TDragger); tDragger->translationIncrement.connectFrom(&this->translationIncrement); tDragger->autoScaleResult.connectFrom(&this->autoScaleResult); translationIncrementCountZ.connectFrom(&tDragger->translationIncrementCount); - + // Planar Translator + TPlanarDragger *tPlanarDragger; + tPlanarDragger = SO_GET_ANY_PART(this, "xyPlanarTranslatorDragger", TPlanarDragger); + tPlanarDragger->translationIncrement.connectFrom(&this->translationIncrement); + tPlanarDragger->autoScaleResult.connectFrom(&this->autoScaleResult); + translationIncrementCountX.appendConnection(&tPlanarDragger->translationIncrementXCount); + translationIncrementCountY.appendConnection(&tPlanarDragger->translationIncrementYCount); + tPlanarDragger = SO_GET_ANY_PART(this, "yzPlanarTranslatorDragger", TPlanarDragger); + tPlanarDragger->translationIncrement.connectFrom(&this->translationIncrement); + tPlanarDragger->autoScaleResult.connectFrom(&this->autoScaleResult); + translationIncrementCountZ.appendConnection(&tPlanarDragger->translationIncrementXCount); + translationIncrementCountY.appendConnection(&tPlanarDragger->translationIncrementYCount); + tPlanarDragger = SO_GET_ANY_PART(this, "zxPlanarTranslatorDragger", TPlanarDragger); + tPlanarDragger->translationIncrement.connectFrom(&this->translationIncrement); + tPlanarDragger->autoScaleResult.connectFrom(&this->autoScaleResult); + translationIncrementCountX.appendConnection(&tPlanarDragger->translationIncrementXCount); + translationIncrementCountZ.appendConnection(&tPlanarDragger->translationIncrementYCount); + // Rotator RDragger *rDragger; rDragger = SO_GET_ANY_PART(this, "xRotatorDragger", RDragger); rDragger->rotationIncrement.connectFrom(&this->rotationIncrement); @@ -766,12 +1136,23 @@ SoFCCSysDragger::SoFCCSysDragger() rDragger->rotationIncrement.connectFrom(&this->rotationIncrement); 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); + // Planar Translator + sw = SO_GET_ANY_PART(this, "xyPlanarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); + sw = SO_GET_ANY_PART(this, "yzPlanarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); + sw = SO_GET_ANY_PART(this, "zxPlanarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); + // Rotator sw = SO_GET_ANY_PART(this, "xRotatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); sw = SO_GET_ANY_PART(this, "yRotatorSwitch", SoSwitch); @@ -779,26 +1160,34 @@ SoFCCSysDragger::SoFCCSysDragger() sw = SO_GET_ANY_PART(this, "zRotatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); + // Rotations + SoRotation *localRotation; SbRotation tempRotation; auto angle = static_cast(M_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()); + localRotation = SO_GET_ANY_PART(this, "yzPlanarTranslatorRotation", SoRotation); + localRotation->rotation.setValue(SbVec3f(0.0, -1.0, 0.0), angle); + localRotation = SO_GET_ANY_PART(this, "zxPlanarTranslatorRotation", SoRotation); + localRotation->rotation.setValue(SbVec3f(1.0, 0.0, 0.0), angle); + // Rotator localRotation = SO_GET_ANY_PART(this, "xRotatorRotation", SoRotation); tempRotation = SbRotation(SbVec3f(1.0, 0.0, 0.0), angle); tempRotation *= SbRotation(SbVec3f(0.0, 0.0, 1.0), angle); localRotation->rotation.setValue(tempRotation); - localRotation = SO_GET_ANY_PART(this, "yRotatorRotation", SoRotation); tempRotation = SbRotation(SbVec3f(0.0, -1.0, 0.0), angle); tempRotation *= SbRotation(SbVec3f(0.0, 0.0, -1.0), angle); localRotation->rotation.setValue(tempRotation); - localRotation = SO_GET_ANY_PART(this, "zRotatorRotation", SoRotation); localRotation->rotation.setValue(SbRotation::identity()); @@ -857,6 +1246,9 @@ SbBool SoFCCSysDragger::setUpConnections(SbBool onoff, SbBool doitalways) TDragger *tDraggerX = SO_GET_ANY_PART(this, "xTranslatorDragger", TDragger); TDragger *tDraggerY = SO_GET_ANY_PART(this, "yTranslatorDragger", TDragger); TDragger *tDraggerZ = SO_GET_ANY_PART(this, "zTranslatorDragger", TDragger); + TPlanarDragger *tPlanarDraggerXZ = SO_GET_ANY_PART(this, "xyPlanarTranslatorDragger", TPlanarDragger); + TPlanarDragger *tPlanarDraggerYZ = SO_GET_ANY_PART(this, "yzPlanarTranslatorDragger", TPlanarDragger); + TPlanarDragger *tPlanarDraggerZX = SO_GET_ANY_PART(this, "zxPlanarTranslatorDragger", TPlanarDragger); RDragger *rDraggerX = SO_GET_ANY_PART(this, "xRotatorDragger", RDragger); RDragger *rDraggerY = SO_GET_ANY_PART(this, "yRotatorDragger", RDragger); RDragger *rDraggerZ = SO_GET_ANY_PART(this, "zRotatorDragger", RDragger); @@ -868,6 +1260,9 @@ SbBool SoFCCSysDragger::setUpConnections(SbBool onoff, SbBool doitalways) registerChildDragger(tDraggerX); registerChildDragger(tDraggerY); registerChildDragger(tDraggerZ); + registerChildDragger(tPlanarDraggerXZ); + registerChildDragger(tPlanarDraggerYZ); + registerChildDragger(tPlanarDraggerZX); registerChildDragger(rDraggerX); registerChildDragger(rDraggerY); registerChildDragger(rDraggerZ); @@ -885,6 +1280,9 @@ SbBool SoFCCSysDragger::setUpConnections(SbBool onoff, SbBool doitalways) unregisterChildDragger(tDraggerX); unregisterChildDragger(tDraggerY); unregisterChildDragger(tDraggerZ); + unregisterChildDragger(tPlanarDraggerXZ); + unregisterChildDragger(tPlanarDraggerYZ); + unregisterChildDragger(tPlanarDraggerZX); unregisterChildDragger(rDraggerX); unregisterChildDragger(rDraggerY); unregisterChildDragger(rDraggerZ); @@ -1070,18 +1468,19 @@ void SoFCCSysDragger::clearIncrementCounts() rotationIncrementCountZ.setValue(0); } +// Visiblity API Functions + +// Translator void SoFCCSysDragger::showTranslationX() { SoSwitch *sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); } - void SoFCCSysDragger::showTranslationY() { SoSwitch *sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); } - void SoFCCSysDragger::showTranslationZ() { SoSwitch *sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch); @@ -1093,31 +1492,125 @@ void SoFCCSysDragger::hideTranslationX() SoSwitch *sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE); } - void SoFCCSysDragger::hideTranslationY() { SoSwitch *sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE); } - void SoFCCSysDragger::hideTranslationZ() { SoSwitch *sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE); } +bool SoFCCSysDragger::isShownTranslationX() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_ALL); +} +bool SoFCCSysDragger::isShownTranslationY() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_ALL); +} +bool SoFCCSysDragger::isShownTranslationZ() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_ALL); +} + +bool SoFCCSysDragger::isHiddenTranslationX() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_NONE); +} +bool SoFCCSysDragger::isHiddenTranslationY() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_NONE); +} +bool SoFCCSysDragger::isHiddenTranslationZ() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_NONE); +} + +// Planar Translator +void SoFCCSysDragger::showPlanarTranslationXY() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "xyPlanarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); +} +void SoFCCSysDragger::showPlanarTranslationYZ() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "yzPlanarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); +} +void SoFCCSysDragger::showPlanarTranslationZX() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "zxPlanarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); +} + +void SoFCCSysDragger::hidePlanarTranslationXY() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "xyPlanarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE); +} +void SoFCCSysDragger::hidePlanarTranslationYZ() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "yzPlanarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE); +} +void SoFCCSysDragger::hidePlanarTranslationZX() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "zxPlanarTranslatorSwitch", SoSwitch); + SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE); +} + +bool SoFCCSysDragger::isShownPlanarTranslationXY() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "xyPlanarTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_ALL); +} +bool SoFCCSysDragger::isShownPlanarTranslationYZ() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "yzPlanarTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_ALL); +} +bool SoFCCSysDragger::isShownPlanarTranslationZX() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "zxPlanarTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_ALL); +} + +bool SoFCCSysDragger::isHiddenPlanarTranslationXY() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "xyPlanarTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_NONE); +} +bool SoFCCSysDragger::isHiddenPlanarTranslationYZ() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "yzPlanarTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_NONE); +} +bool SoFCCSysDragger::isHiddenPlanarTranslationZX() +{ + SoSwitch *sw = SO_GET_ANY_PART(this, "zxPlanarTranslatorSwitch", SoSwitch); + return (sw->whichChild.getValue() == SO_SWITCH_NONE); +} + +// Rotator void SoFCCSysDragger::showRotationX() { SoSwitch *sw = SO_GET_ANY_PART(this, "xRotatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); } - void SoFCCSysDragger::showRotationY() { SoSwitch *sw = SO_GET_ANY_PART(this, "yRotatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_ALL); } - void SoFCCSysDragger::showRotationZ() { SoSwitch *sw = SO_GET_ANY_PART(this, "zRotatorSwitch", SoSwitch); @@ -1129,85 +1622,43 @@ void SoFCCSysDragger::hideRotationX() SoSwitch *sw = SO_GET_ANY_PART(this, "xRotatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE); } - void SoFCCSysDragger::hideRotationY() { SoSwitch *sw = SO_GET_ANY_PART(this, "yRotatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE); } - void SoFCCSysDragger::hideRotationZ() { SoSwitch *sw = SO_GET_ANY_PART(this, "zRotatorSwitch", SoSwitch); SoInteractionKit::setSwitchValue(sw, SO_SWITCH_NONE); } -bool SoFCCSysDragger::isShownTranslationX() -{ - SoSwitch *sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch); - return (sw->whichChild.getValue() == SO_SWITCH_ALL); -} - -bool SoFCCSysDragger::isShownTranslationY() -{ - SoSwitch *sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch); - return (sw->whichChild.getValue() == SO_SWITCH_ALL); -} - -bool SoFCCSysDragger::isShownTranslationZ() -{ - SoSwitch *sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch); - return (sw->whichChild.getValue() == SO_SWITCH_ALL); -} - bool SoFCCSysDragger::isShownRotationX() { SoSwitch *sw = SO_GET_ANY_PART(this, "xRotatorSwitch", SoSwitch); return (sw->whichChild.getValue() == SO_SWITCH_ALL); } - bool SoFCCSysDragger::isShownRotationY() { SoSwitch *sw = SO_GET_ANY_PART(this, "yRotatorSwitch", SoSwitch); return (sw->whichChild.getValue() == SO_SWITCH_ALL); } - bool SoFCCSysDragger::isShownRotationZ() { SoSwitch *sw = SO_GET_ANY_PART(this, "zRotatorSwitch", SoSwitch); return (sw->whichChild.getValue() == SO_SWITCH_ALL); } -bool SoFCCSysDragger::isHiddenTranslationX() -{ - SoSwitch *sw = SO_GET_ANY_PART(this, "xTranslatorSwitch", SoSwitch); - return (sw->whichChild.getValue() == SO_SWITCH_NONE); -} - -bool SoFCCSysDragger::isHiddenTranslationY() -{ - SoSwitch *sw = SO_GET_ANY_PART(this, "yTranslatorSwitch", SoSwitch); - return (sw->whichChild.getValue() == SO_SWITCH_NONE); -} - -bool SoFCCSysDragger::isHiddenTranslationZ() -{ - SoSwitch *sw = SO_GET_ANY_PART(this, "zTranslatorSwitch", SoSwitch); - return (sw->whichChild.getValue() == SO_SWITCH_NONE); -} - bool SoFCCSysDragger::isHiddenRotationX() { SoSwitch *sw = SO_GET_ANY_PART(this, "xRotatorSwitch", SoSwitch); return (sw->whichChild.getValue() == SO_SWITCH_NONE); } - bool SoFCCSysDragger::isHiddenRotationY() { SoSwitch *sw = SO_GET_ANY_PART(this, "yRotatorSwitch", SoSwitch); return (sw->whichChild.getValue() == SO_SWITCH_NONE); } - bool SoFCCSysDragger::isHiddenRotationZ() { SoSwitch *sw = SO_GET_ANY_PART(this, "zRotatorSwitch", SoSwitch); diff --git a/src/Gui/SoFCCSysDragger.h b/src/Gui/SoFCCSysDragger.h index 66272cc916..9f76a68929 100644 --- a/src/Gui/SoFCCSysDragger.h +++ b/src/Gui/SoFCCSysDragger.h @@ -86,6 +86,56 @@ private: using inherited = SoDragger; }; +/*! @brief Planar Translation Dragger. + * + * used for translating on a plane. Set the + * translationIncrement to desired step. Use + * 'translationIncrementXCount' or + * 'translationIncrementYCount' multiplied with + * 'translationIncrement' for a full double + * precision vector scalar. + * + * @author qewer33 + */ +class TPlanarDragger : public SoDragger +{ + SO_KIT_HEADER(TDragger); + SO_KIT_CATALOG_ENTRY_HEADER(planarTranslatorSwitch); + SO_KIT_CATALOG_ENTRY_HEADER(planarTranslator); + SO_KIT_CATALOG_ENTRY_HEADER(planarTranslatorActive); +public: + static void initClass(); + TPlanarDragger(); + SoSFVec3f translation; //!< set from outside and used from outside for single precision. + SoSFDouble translationIncrement; //!< set from outside and used for rounding. + SoSFInt32 translationIncrementXCount; //!< number of steps. used from outside. + SoSFInt32 translationIncrementYCount; //!< number of steps. used from outside. + SoSFFloat autoScaleResult; //!< set from parent dragger. + +protected: + ~TPlanarDragger() override; + SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE) override; + + static void startCB(void *, SoDragger * d); + static void motionCB(void *, SoDragger * d); + static void finishCB(void *, SoDragger * d); + static void fieldSensorCB(void *f, SoSensor *); + static void valueChangedCB(void *, SoDragger *d); + + void dragStart(); + void drag(); + void dragFinish(); + + SoFieldSensor fieldSensor; + SbPlaneProjector projector; + +private: + void buildFirstInstance(); + SbVec3f roundTranslation(const SbVec3f &vecIn, float incrementIn); + SoGroup* buildGeometry(); + using inherited = SoDragger; +}; + /*! @brief Rotation Dragger. * * used for rotating around an axis. Set the rotation @@ -149,6 +199,7 @@ class GuiExport SoFCCSysDragger : public SoDragger SO_KIT_HEADER(SoFCCSysDragger); SO_KIT_CATALOG_ENTRY_HEADER(annotation); SO_KIT_CATALOG_ENTRY_HEADER(scaleNode); + // Translator SO_KIT_CATALOG_ENTRY_HEADER(xTranslatorSwitch); SO_KIT_CATALOG_ENTRY_HEADER(yTranslatorSwitch); SO_KIT_CATALOG_ENTRY_HEADER(zTranslatorSwitch); @@ -164,6 +215,23 @@ class GuiExport SoFCCSysDragger : public SoDragger SO_KIT_CATALOG_ENTRY_HEADER(xTranslatorDragger); SO_KIT_CATALOG_ENTRY_HEADER(yTranslatorDragger); SO_KIT_CATALOG_ENTRY_HEADER(zTranslatorDragger); + // Planar Translator + SO_KIT_CATALOG_ENTRY_HEADER(xyPlanarTranslatorSwitch); + SO_KIT_CATALOG_ENTRY_HEADER(yzPlanarTranslatorSwitch); + SO_KIT_CATALOG_ENTRY_HEADER(zxPlanarTranslatorSwitch); + SO_KIT_CATALOG_ENTRY_HEADER(xyPlanarTranslatorSeparator); + SO_KIT_CATALOG_ENTRY_HEADER(yzPlanarTranslatorSeparator); + SO_KIT_CATALOG_ENTRY_HEADER(zxPlanarTranslatorSeparator); + SO_KIT_CATALOG_ENTRY_HEADER(xyPlanarTranslatorColor); + SO_KIT_CATALOG_ENTRY_HEADER(yzPlanarTranslatorColor); + SO_KIT_CATALOG_ENTRY_HEADER(zxPlanarTranslatorColor); + SO_KIT_CATALOG_ENTRY_HEADER(xyPlanarTranslatorRotation); + SO_KIT_CATALOG_ENTRY_HEADER(yzPlanarTranslatorRotation); + SO_KIT_CATALOG_ENTRY_HEADER(zxPlanarTranslatorRotation); + SO_KIT_CATALOG_ENTRY_HEADER(xyPlanarTranslatorDragger); + SO_KIT_CATALOG_ENTRY_HEADER(yzPlanarTranslatorDragger); + SO_KIT_CATALOG_ENTRY_HEADER(zxPlanarTranslatorDragger); + // Rotator SO_KIT_CATALOG_ENTRY_HEADER(xRotatorSwitch); SO_KIT_CATALOG_ENTRY_HEADER(yRotatorSwitch); SO_KIT_CATALOG_ENTRY_HEADER(zRotatorSwitch); @@ -218,6 +286,25 @@ public: void hideTranslationX(); //!< hide the x translation dragger. void hideTranslationY(); //!< hide the y translation dragger. void hideTranslationZ(); //!< hide the z translation dragger. + 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. + void showPlanarTranslationZX(); //!< show the zx planar translation dragger. + void hidePlanarTranslationXY(); //!< hide the xy planar translation dragger. + void hidePlanarTranslationYZ(); //!< hide the yz planar translation dragger. + void hidePlanarTranslationZX(); //!< hide the zx planar translation dragger. + bool isShownPlanarTranslationXY(); //!< is xy planar translation dragger shown. + bool isShownPlanarTranslationYZ(); //!< is yz planar translation dragger shown. + bool isShownPlanarTranslationZX(); //!< is zx planar translation dragger shown. + bool isHiddenPlanarTranslationXY(); //!< is xy planar translation dragger hidden. + bool isHiddenPlanarTranslationYZ(); //!< is yz planar translation dragger hidden. + bool isHiddenPlanarTranslationZX(); //!< is zx planar translation dragger hidden. void showRotationX(); //!< show the x rotation dragger. void showRotationY(); //!< show the y rotation dragger. @@ -225,17 +312,9 @@ public: void hideRotationX(); //!< hide the x rotation dragger. void hideRotationY(); //!< hide the y rotation dragger. void hideRotationZ(); //!< hide the z rotation dragger. - - bool isShownTranslationX(); //!< is x translation dragger shown. - bool isShownTranslationY(); //!< is y translation dragger shown. - bool isShownTranslationZ(); //!< is z translation dragger shown. bool isShownRotationX(); //!< is x rotation dragger shown. bool isShownRotationY(); //!< is x rotation dragger shown. bool isShownRotationZ(); //!< is x rotation dragger shown. - - bool isHiddenTranslationX(); //!< is x translation dragger hidden. - bool isHiddenTranslationY(); //!< is y translation dragger hidden. - bool isHiddenTranslationZ(); //!< is z translation dragger hidden. bool isHiddenRotationX(); //!< is x rotation dragger hidden. bool isHiddenRotationY(); //!< is x rotation dragger hidden. bool isHiddenRotationZ(); //!< is x rotation dragger hidden. diff --git a/src/Gui/ViewParams.h b/src/Gui/ViewParams.h index 654af67bb9..91d8a2ceec 100644 --- a/src/Gui/ViewParams.h +++ b/src/Gui/ViewParams.h @@ -63,6 +63,13 @@ public: FC_VIEW_PARAM(EnablePropertyViewForInactiveDocument,bool,Bool,true) \ FC_VIEW_PARAM(ShowSelectionBoundingBox,bool,Bool,false) \ FC_VIEW_PARAM(PropertyViewTimer, unsigned long, Unsigned, 100) \ + FC_VIEW_PARAM(AxisXColor,unsigned long,Unsigned,0xCC333300) \ + FC_VIEW_PARAM(AxisXAltColor,unsigned long,Unsigned,0xCC4C4C00) \ + FC_VIEW_PARAM(AxisYColor,unsigned long,Unsigned,0x33CC3300) \ + FC_VIEW_PARAM(AxisYAltColor,unsigned long,Unsigned,0x4CCC4C00) \ + FC_VIEW_PARAM(AxisZColor,unsigned long,Unsigned,0x3333CC00) \ + FC_VIEW_PARAM(AxisZAltColor,unsigned long,Unsigned,0x4C4CCC00) \ + #undef FC_VIEW_PARAM #define FC_VIEW_PARAM(_name,_ctype,_type,_def) \ diff --git a/src/Gui/ViewProviderDragger.cpp b/src/Gui/ViewProviderDragger.cpp index a26179e874..42171bcd04 100644 --- a/src/Gui/ViewProviderDragger.cpp +++ b/src/Gui/ViewProviderDragger.cpp @@ -243,7 +243,7 @@ void ViewProviderDragger::updatePlacementFromDragger(ViewProviderDragger* sudoTh int rCountY = draggerIn->rotationIncrementCountY.getValue(); int rCountZ = draggerIn->rotationIncrementCountZ.getValue(); - //just as a little sanity check make sure only 1 field has changed. + //just as a little sanity check make sure only 1 or 2 fields has changed. int numberOfFieldChanged = 0; if (tCountX) numberOfFieldChanged++; if (tCountY) numberOfFieldChanged++; @@ -253,7 +253,7 @@ void ViewProviderDragger::updatePlacementFromDragger(ViewProviderDragger* sudoTh if (rCountZ) numberOfFieldChanged++; if (numberOfFieldChanged == 0) return; - assert(numberOfFieldChanged == 1); + assert(numberOfFieldChanged == 1 || numberOfFieldChanged == 2); //helper lambdas. auto getVectorX = [&pMatrix]() {return Base::Vector3d(pMatrix[0], pMatrix[4], pMatrix[8]);}; @@ -267,35 +267,35 @@ void ViewProviderDragger::updatePlacementFromDragger(ViewProviderDragger* sudoTh freshPlacement.move(movementVector); geoFeature->Placement.setValue(freshPlacement); } - else if (tCountY) + if (tCountY) { Base::Vector3d movementVector(getVectorY()); movementVector *= (tCountY * translationIncrement); freshPlacement.move(movementVector); geoFeature->Placement.setValue(freshPlacement); } - else if (tCountZ) + if (tCountZ) { Base::Vector3d movementVector(getVectorZ()); movementVector *= (tCountZ * translationIncrement); freshPlacement.move(movementVector); geoFeature->Placement.setValue(freshPlacement); } - else if (rCountX) + if (rCountX) { Base::Vector3d rotationVector(getVectorX()); Base::Rotation rotation(rotationVector, rCountX * rotationIncrement); freshPlacement.setRotation(rotation * freshPlacement.getRotation()); geoFeature->Placement.setValue(freshPlacement); } - else if (rCountY) + if (rCountY) { Base::Vector3d rotationVector(getVectorY()); Base::Rotation rotation(rotationVector, rCountY * rotationIncrement); freshPlacement.setRotation(rotation * freshPlacement.getRotation()); geoFeature->Placement.setValue(freshPlacement); } - else if (rCountZ) + if (rCountZ) { Base::Vector3d rotationVector(getVectorZ()); Base::Rotation rotation(rotationVector, rCountZ * rotationIncrement);