mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#168 Finalized. Zoom along ray is now updated to cope with parallel projection. The code in the different navigations are cleaned up a bit, and alligned
This commit is contained in:
parent
0f3fe3ac1b
commit
c1f5ec5bdf
@ -43,15 +43,6 @@ RiuCadNavigation::~RiuCadNavigation()
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuCadNavigation::init()
|
||||
{
|
||||
caf::TrackBallBasedNavigation::init();
|
||||
m_navigationUpdated = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -59,55 +50,42 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
{
|
||||
if (! inputEvent) return false;
|
||||
bool isEventHandled = false;
|
||||
|
||||
switch (inputEvent->type())
|
||||
{
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
|
||||
if (me->button() == Qt::LeftButton)
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
cvf::HitItemCollection hic;
|
||||
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);
|
||||
|
||||
if (hitSomething)
|
||||
{
|
||||
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
|
||||
this->setPointOfInterest(pointOfInterest);
|
||||
}
|
||||
else
|
||||
{
|
||||
initializeRotationCenter();
|
||||
}
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
}
|
||||
else if (me->button() == Qt::LeftButton || (me->button() == Qt::MidButton && (me->modifiers() & Qt::ShiftModifier)))
|
||||
{
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY);
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
}
|
||||
else if (me->button() == Qt::MidButton)
|
||||
{
|
||||
if (me->modifiers() & Qt::ShiftModifier)
|
||||
{
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY);
|
||||
m_isNavigating = true;
|
||||
isEventHandled = true;
|
||||
}
|
||||
else if (me->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
cvf::HitItemCollection hic;
|
||||
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);
|
||||
|
||||
if (hitSomething)
|
||||
{
|
||||
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
|
||||
this->setPointOfInterest(pointOfInterest);
|
||||
}
|
||||
else
|
||||
{
|
||||
initializeRotationCenter();
|
||||
}
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
//m_viewer->setCursor(RiuCursors::get(RiuCursors::ROTATE));
|
||||
m_isNavigating = true;
|
||||
isEventHandled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEventHandled)
|
||||
{
|
||||
m_navigationUpdated = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
@ -118,11 +96,11 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
if (me->button() == Qt::MidButton || me->button() == Qt::LeftButton)
|
||||
{
|
||||
m_trackball->endNavigation();
|
||||
//m_viewer->setCursor(RiuCursors::get(RiuCursors::PICK));
|
||||
|
||||
m_isNavigating = false;
|
||||
|
||||
isEventHandled = m_navigationUpdated;
|
||||
m_navigationUpdated = false;
|
||||
if (m_hasMovedMouseDuringNavigation) isEventHandled = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,8 +111,9 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (m_isNavigating)
|
||||
{
|
||||
@ -142,9 +121,10 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
if (needRedraw)
|
||||
{
|
||||
m_viewer->navigationPolicyUpdate();
|
||||
m_navigationUpdated = true;
|
||||
|
||||
}
|
||||
isEventHandled = true;
|
||||
m_hasMovedMouseDuringNavigation = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -156,15 +136,12 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
initializeRotationCenter();
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
QWheelEvent* we = static_cast<QWheelEvent*>(inputEvent);
|
||||
int translatedMousePosX = we->x();
|
||||
int translatedMousePosY = m_viewer->height() - we->y();
|
||||
QWheelEvent* we = static_cast<QWheelEvent*> ( inputEvent);
|
||||
|
||||
cvf::ref<cvf::Ray> ray;
|
||||
if (we->delta() > 0)
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
else
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY));
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(we->x(), we->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
cvf::ref<cvf::Ray> ray = createZoomRay(translatedMousePosX, translatedMousePosY);
|
||||
|
||||
zoomAlongRay(ray.p(), -we->delta());
|
||||
}
|
||||
@ -179,4 +156,3 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,5 @@ public:
|
||||
RiuCadNavigation();
|
||||
virtual ~RiuCadNavigation();
|
||||
protected:
|
||||
virtual void init();
|
||||
virtual bool handleInputEvent(QInputEvent* inputEvent);
|
||||
|
||||
bool m_navigationUpdated;
|
||||
};
|
||||
|
@ -55,8 +55,9 @@ bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (me->button() == Qt::LeftButton)
|
||||
{
|
||||
@ -74,7 +75,6 @@ bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
}
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
//m_viewer->setCursor(RICursors::get(RICursors::ROTATE));
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
@ -113,8 +113,9 @@ bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (m_isNavigating)
|
||||
{
|
||||
@ -146,19 +147,14 @@ bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
initializeRotationCenter();
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
QWheelEvent* we = static_cast<QWheelEvent*> ( inputEvent);
|
||||
int translatedMousePosX = we->x();
|
||||
int translatedMousePosY = m_viewer->height() - we->y();
|
||||
int delta = we->delta();
|
||||
QWheelEvent* we = static_cast<QWheelEvent*>(inputEvent);
|
||||
|
||||
cvf::ref<cvf::Ray> ray;
|
||||
if (delta < 0)
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
else
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY));
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(we->x(), we->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
zoomAlongRay(ray.p(), -delta);
|
||||
cvf::ref<cvf::Ray> ray = createZoomRay(translatedMousePosX, translatedMousePosY);
|
||||
|
||||
zoomAlongRay(ray.p(), -we->delta());
|
||||
}
|
||||
isEventHandled = true;
|
||||
}
|
||||
|
@ -55,8 +55,9 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (me->button() == Qt::MidButton)
|
||||
{
|
||||
@ -74,27 +75,10 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
}
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
//m_viewer->setCursor(RICursors::get(RICursors::ROTATE));
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
}
|
||||
else if (me->button() == Qt::LeftButton)
|
||||
{
|
||||
if (me->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
QMouseEvent* we = static_cast<QMouseEvent*> ( inputEvent);
|
||||
m_lastPosX = we->x();
|
||||
m_lastPosY = we->y();
|
||||
|
||||
m_zoomRay = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
m_isZooming = true;
|
||||
}
|
||||
}
|
||||
else if (me->button() == Qt::RightButton)
|
||||
{
|
||||
if (me->modifiers() == Qt::NoModifier)
|
||||
@ -104,7 +88,24 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
}
|
||||
}
|
||||
else if (me->button() == Qt::LeftButton)
|
||||
{
|
||||
if (me->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
QMouseEvent* we = static_cast<QMouseEvent*> ( inputEvent);
|
||||
m_lastPosX = we->x();
|
||||
m_lastPosY = we->y();
|
||||
|
||||
m_zoomRay = createZoomRay(translatedMousePosX, translatedMousePosY);
|
||||
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
m_isZooming = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
@ -137,8 +138,9 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (m_isNavigating)
|
||||
{
|
||||
@ -171,18 +173,13 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
QWheelEvent* we = static_cast<QWheelEvent*> ( inputEvent);
|
||||
int translatedMousePosX = we->x();
|
||||
int translatedMousePosY = m_viewer->height() - we->y();
|
||||
int delta = we->delta();
|
||||
|
||||
cvf::ref<cvf::Ray> ray;
|
||||
if (delta < 0)
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
else
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY));
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(we->x(), we->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
zoomAlongRay(ray.p(), -delta);
|
||||
cvf::ref<cvf::Ray> ray = createZoomRay(translatedMousePosX, translatedMousePosY);
|
||||
|
||||
zoomAlongRay(ray.p(), -we->delta());
|
||||
}
|
||||
isEventHandled = true;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "cvfManipulatorTrackball.h"
|
||||
|
||||
#include <QInputEvent>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -60,15 +61,6 @@ caf::CadNavigation::~CadNavigation()
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::CadNavigation::init()
|
||||
{
|
||||
caf::TrackBallBasedNavigation::init();
|
||||
m_navigationUpdated = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -76,48 +68,41 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
{
|
||||
if (! inputEvent) return false;
|
||||
bool isEventHandled = false;
|
||||
|
||||
switch (inputEvent->type())
|
||||
{
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
|
||||
if (me->button() == Qt::MidButton)
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
if (me->modifiers() & Qt::ShiftModifier)
|
||||
{
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY);
|
||||
m_isNavigating = true;
|
||||
isEventHandled = true;
|
||||
}
|
||||
else if (me->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
cvf::HitItemCollection hic;
|
||||
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);
|
||||
cvf::HitItemCollection hic;
|
||||
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);
|
||||
|
||||
if (hitSomething)
|
||||
{
|
||||
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
|
||||
this->setPointOfInterest(pointOfInterest);
|
||||
}
|
||||
else
|
||||
{
|
||||
initializeRotationCenter();
|
||||
}
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
//m_viewer->setCursor(RiuCursors::get(RiuCursors::ROTATE));
|
||||
m_isNavigating = true;
|
||||
isEventHandled = true;
|
||||
if (hitSomething)
|
||||
{
|
||||
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
|
||||
this->setPointOfInterest(pointOfInterest);
|
||||
}
|
||||
else
|
||||
{
|
||||
initializeRotationCenter();
|
||||
}
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
}
|
||||
|
||||
if (isEventHandled)
|
||||
else if (me->button() == Qt::MidButton && (me->modifiers() & Qt::ShiftModifier))
|
||||
{
|
||||
m_navigationUpdated = false;
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY);
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -129,11 +114,11 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
if (me->button() == Qt::MidButton)
|
||||
{
|
||||
m_trackball->endNavigation();
|
||||
//m_viewer->setCursor(RiuCursors::get(RiuCursors::PICK));
|
||||
|
||||
m_isNavigating = false;
|
||||
if (m_hasMovedMouseDuringNavigation) isEventHandled = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
|
||||
isEventHandled = m_navigationUpdated;
|
||||
m_navigationUpdated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,19 +128,21 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
initializeRotationCenter();
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>(inputEvent);
|
||||
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (m_isNavigating)
|
||||
{
|
||||
bool needRedraw = m_trackball->updateNavigation(translatedMousePosX, translatedMousePosY);
|
||||
if (needRedraw)
|
||||
if(needRedraw)
|
||||
{
|
||||
m_viewer->navigationPolicyUpdate();
|
||||
m_navigationUpdated = true;
|
||||
|
||||
}
|
||||
isEventHandled = true;
|
||||
m_hasMovedMouseDuringNavigation = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,15 +154,12 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
initializeRotationCenter();
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
QWheelEvent* we = static_cast<QWheelEvent*>(inputEvent);
|
||||
int translatedMousePosX = we->x();
|
||||
int translatedMousePosY = m_viewer->height() - we->y();
|
||||
QWheelEvent* we = static_cast<QWheelEvent*> ( inputEvent);
|
||||
|
||||
cvf::ref<cvf::Ray> ray;
|
||||
if (we->delta() > 0)
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
else
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY));
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(we->x(), we->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
cvf::ref<cvf::Ray> ray = createZoomRay(translatedMousePosX, translatedMousePosY);
|
||||
|
||||
zoomAlongRay(ray.p(), -we->delta());
|
||||
}
|
||||
|
@ -48,10 +48,7 @@ public:
|
||||
CadNavigation();
|
||||
virtual ~CadNavigation();
|
||||
protected:
|
||||
virtual void init();
|
||||
virtual bool handleInputEvent(QInputEvent* inputEvent);
|
||||
|
||||
bool m_navigationUpdated;
|
||||
};
|
||||
|
||||
} // End namespace caf
|
||||
|
@ -61,7 +61,6 @@ caf::CeetronPlusNavigation::~CeetronPlusNavigation()
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -74,13 +73,14 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (me->button() == Qt::RightButton)
|
||||
{
|
||||
cvf::HitItemCollection hic;
|
||||
bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic);
|
||||
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);
|
||||
|
||||
if (hitSomething)
|
||||
{
|
||||
@ -93,7 +93,6 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
}
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
//m_viewer->setCursor(RICursors::get(RICursors::ROTATE));
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
isEventHandled = true;
|
||||
@ -116,7 +115,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
m_lastPosX = we->x();
|
||||
m_lastPosY = we->y();
|
||||
|
||||
m_zoomRay = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
m_zoomRay = createZoomRay(translatedMousePosX, translatedMousePosY);
|
||||
|
||||
m_isNavigating = true;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
@ -156,8 +155,9 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
|
||||
int translatedMousePosX = me->x();
|
||||
int translatedMousePosY = m_viewer->height() - me->y();
|
||||
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
if (m_isNavigating)
|
||||
{
|
||||
@ -189,27 +189,14 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
initializeRotationCenter();
|
||||
if (m_isRotCenterInitialized)
|
||||
{
|
||||
|
||||
|
||||
QWheelEvent* we = static_cast<QWheelEvent*> ( inputEvent);
|
||||
#if 0
|
||||
int translatedMousePosX = we->x();
|
||||
int translatedMousePosY = m_viewer->height() - we->y();
|
||||
int delta = we->delta();
|
||||
|
||||
cvf::ref<cvf::Ray> ray;
|
||||
if (delta < 0)
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
else
|
||||
ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY));
|
||||
#endif
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos(we->x(), we->y(), &translatedMousePosX, &translatedMousePosY);
|
||||
|
||||
int cvfEvPosX, cvfEvPosY;
|
||||
cvfEventPos(we->x(), we->y(), &cvfEvPosX, &cvfEvPosY);
|
||||
cvf::ref<cvf::Ray> ray = createZoomRay(cvfEvPosX, cvfEvPosY);
|
||||
cvf::ref<cvf::Ray> ray = createZoomRay(translatedMousePosX, translatedMousePosY);
|
||||
|
||||
zoomAlongRay(ray.p(), we->delta());
|
||||
|
||||
}
|
||||
isEventHandled = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user