Skip to content

Commit

Permalink
Gui: allow changing scale factor in SoAutoZoomTranslation
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder committed Feb 10, 2019
1 parent 916985b commit 03a873c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Gui/Inventor/SoAutoZoomTranslation.cpp
Expand Up @@ -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)));
}

Expand Down
2 changes: 2 additions & 0 deletions src/Gui/Inventor/SoAutoZoomTranslation.h
Expand Up @@ -39,6 +39,8 @@ class GuiExport SoAutoZoomTranslation : public SoTransformation {
SoAutoZoomTranslation();
//SoSFVec3f abPos;

SoSFFloat scaleFactor;

protected:
virtual ~SoAutoZoomTranslation() {};
virtual void doAction(SoAction * action);
Expand Down

0 comments on commit 03a873c

Please sign in to comment.