mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4857 AppFwk: Add handling of comparison view to the 3d navigation policies
This commit is contained in:
parent
d438158691
commit
e3dc32bd71
@ -79,18 +79,7 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
|
||||
if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled())
|
||||
{
|
||||
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();
|
||||
}
|
||||
this->pickAndSetPointOfInterest(me->x(), me->y());
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
m_roationSensitivityCalculator.init(me);
|
||||
|
@ -81,18 +81,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
|
||||
if (me->button() == Qt::RightButton && isRotationEnabled())
|
||||
{
|
||||
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();
|
||||
}
|
||||
this->pickAndSetPointOfInterest(me->x(), me->y());
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
m_roationSensitivityCalculator.init(me);
|
||||
|
@ -159,19 +159,20 @@ void caf::TrackBallBasedNavigation::setPointOfInterest(cvf::Vec3d poi)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::TrackBallBasedNavigation::updatePointOfInterestDuringZoomIfNecessary(int zoomX, int zoomY)
|
||||
void caf::TrackBallBasedNavigation::pickAndSetPointOfInterest(int winPosX, int winPosY)
|
||||
{
|
||||
bool hitSomething = false;
|
||||
cvf::HitItemCollection hic;
|
||||
if (shouldRaytraceForNewPoiDuringWheelZoom(zoomX, zoomY))
|
||||
{
|
||||
hitSomething = m_viewer->rayPick(zoomX, zoomY, &hic);
|
||||
updateWheelZoomPosition(zoomX, zoomY);
|
||||
}
|
||||
bool hitSomething = m_viewer->rayPick( winPosX, winPosY, &hic);
|
||||
|
||||
if (hitSomething)
|
||||
{
|
||||
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
|
||||
|
||||
if (m_viewer->isMousePosWithinComparisonView( winPosX, winPosY ))
|
||||
{
|
||||
pointOfInterest -= m_viewer->comparisonViewEyePointOffset();
|
||||
}
|
||||
|
||||
this->setPointOfInterest(pointOfInterest);
|
||||
}
|
||||
else
|
||||
@ -180,6 +181,22 @@ void caf::TrackBallBasedNavigation::updatePointOfInterestDuringZoomIfNecessary(i
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::TrackBallBasedNavigation::updatePointOfInterestDuringZoomIfNecessary(int winPosX, int winPosY)
|
||||
{
|
||||
if (shouldRaytraceForNewPoiDuringWheelZoom(winPosX, winPosY))
|
||||
{
|
||||
this->pickAndSetPointOfInterest(winPosX, winPosY);
|
||||
updateWheelZoomPosition(winPosX, winPosY);
|
||||
}
|
||||
else
|
||||
{
|
||||
initializeRotationCenter();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -271,24 +288,24 @@ cvf::ref<cvf::Ray> caf::TrackBallBasedNavigation::createZoomRay(int cvfXPos, int
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::TrackBallBasedNavigation::updateWheelZoomPosition(int zoomX, int zoomY)
|
||||
void caf::TrackBallBasedNavigation::updateWheelZoomPosition(int winPosX, int winPosY)
|
||||
{
|
||||
m_lastWheelZoomPosX = zoomX;
|
||||
m_lastWheelZoomPosY = zoomY;
|
||||
m_lastWheelZoomPosX = winPosX;
|
||||
m_lastWheelZoomPosY = winPosY;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::TrackBallBasedNavigation::shouldRaytraceForNewPoiDuringWheelZoom(int zoomX, int zoomY) const
|
||||
bool caf::TrackBallBasedNavigation::shouldRaytraceForNewPoiDuringWheelZoom(int winPosX, int winPosY) const
|
||||
{
|
||||
// Raytrace if the last zoom position isn't set
|
||||
if (m_lastWheelZoomPosX == -1 || m_lastWheelZoomPosY == -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int diffX = zoomX - m_lastWheelZoomPosX;
|
||||
int diffY = zoomY - m_lastWheelZoomPosY;
|
||||
int diffX = winPosX - m_lastWheelZoomPosX;
|
||||
int diffY = winPosY - m_lastWheelZoomPosY;
|
||||
|
||||
const int pixelThreshold = 5;
|
||||
if (diffX * diffX + diffY * diffY > pixelThreshold * pixelThreshold)
|
||||
|
@ -107,7 +107,8 @@ protected:
|
||||
void setView( const cvf::Vec3d& alongDirection, const cvf::Vec3d& upDirection ) override;
|
||||
cvf::Vec3d pointOfInterest() override;
|
||||
void setPointOfInterest(cvf::Vec3d poi) override;
|
||||
void updatePointOfInterestDuringZoomIfNecessary(int zoomX, int zoomY);
|
||||
void pickAndSetPointOfInterest(int winPosX, int winPosY);
|
||||
void updatePointOfInterestDuringZoomIfNecessary(int winPosX, int winPosY);
|
||||
void forcePointOfInterestUpdateDuringNextWheelZoom();
|
||||
|
||||
// Track ball navigation specific
|
||||
@ -134,8 +135,8 @@ protected:
|
||||
bool isRotationEnabled() { return m_isRotationEnabled; }
|
||||
|
||||
private:
|
||||
void updateWheelZoomPosition(int zoomX, int zoomY);
|
||||
bool shouldRaytraceForNewPoiDuringWheelZoom(int zoomX, int zoomY) const;
|
||||
void updateWheelZoomPosition(int winPosX, int winPosY);
|
||||
bool shouldRaytraceForNewPoiDuringWheelZoom(int winPosX, int winPosY) const;
|
||||
|
||||
private:
|
||||
bool m_consumeEvents;
|
||||
|
Loading…
Reference in New Issue
Block a user