Gui: [skip ci] add method NavigationStyle::getNormalizedPosition() to reduce code duplication

This commit is contained in:
wmayer
2021-11-02 15:57:54 +01:00
parent 3b7a758563
commit 0c59884e83
9 changed files with 32 additions and 35 deletions

View File

@@ -92,13 +92,11 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
const SoType type(ev->getTypeId());
const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion();
const SbVec2s size(vp.getViewportSizePixels());
const SbVec2f prevnormalized = this->lastmouseposition;
const SbVec2s pos(ev->getPosition());
const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1),
(float) pos[1] / (float) std::max((int)(size[1] - 1), 1));
const SbVec2f posn = getNormalizedPosition(ev, vp);
const SbVec2f prevnormalized = this->lastmouseposition;
this->lastmouseposition = posn;
const SbVec2s pos(ev->getPosition());
// Set to true if any event processing happened. Note that it is not
// necessary to restrict ourselves to only do one "action" for an