From 03a873c877f68c2e8f95b09229aa885ce4b2f45c Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sun, 10 Feb 2019 12:07:08 +0800 Subject: [PATCH] Gui: allow changing scale factor in SoAutoZoomTranslation --- src/Gui/Inventor/SoAutoZoomTranslation.cpp | 6 +++++- src/Gui/Inventor/SoAutoZoomTranslation.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Gui/Inventor/SoAutoZoomTranslation.cpp b/src/Gui/Inventor/SoAutoZoomTranslation.cpp index 34f7d58164ab..22b8ce8502c2 100644 --- a/src/Gui/Inventor/SoAutoZoomTranslation.cpp +++ b/src/Gui/Inventor/SoAutoZoomTranslation.cpp @@ -73,16 +73,20 @@ void SoAutoZoomTranslation::initClass() float SoAutoZoomTranslation::getScaleFactor(SoAction* action) const { + float scale = scaleFactor.getValue(); + if(!scale) + return 1.0; // Dividing by 5 seems to work well SbViewVolume vv = SoViewVolumeElement::get(action->getState()); float aspectRatio = SoViewportRegionElement::get(action->getState()).getViewportAspectRatio(); - float scale = vv.getWorldToScreenScale(SbVec3f(0.f, 0.f, 0.f), 0.1f) / (5*aspectRatio); + scale *= vv.getWorldToScreenScale(SbVec3f(0.f, 0.f, 0.f), 0.1f) / (5*aspectRatio); return scale; } SoAutoZoomTranslation::SoAutoZoomTranslation() { SO_NODE_CONSTRUCTOR(SoAutoZoomTranslation); + SO_NODE_ADD_FIELD(scaleFactor, (1.0f)); //SO_NODE_ADD_FIELD(abPos, (SbVec3f(0.f,0.f,0.f))); } diff --git a/src/Gui/Inventor/SoAutoZoomTranslation.h b/src/Gui/Inventor/SoAutoZoomTranslation.h index 954a75eb0816..d763a6bd867c 100644 --- a/src/Gui/Inventor/SoAutoZoomTranslation.h +++ b/src/Gui/Inventor/SoAutoZoomTranslation.h @@ -39,6 +39,8 @@ class GuiExport SoAutoZoomTranslation : public SoTransformation { SoAutoZoomTranslation(); //SoSFVec3f abPos; + SoSFFloat scaleFactor; + protected: virtual ~SoAutoZoomTranslation() {}; virtual void doAction(SoAction * action);