#2412 2D Navigation only for Intersectino Views

This commit is contained in:
Jacob Støren
2018-01-26 14:33:32 +01:00
parent b1bbbc2aeb
commit 5640f91b68
10 changed files with 26 additions and 6 deletions

View File

@@ -340,6 +340,7 @@ void Rim2dIntersectionView::resetLegendsInViewer()
m_viewer->showInfoText(false);
m_viewer->setMainScene(new cvf::Scene());
m_viewer->enableNavigationRotation(false);
}
//--------------------------------------------------------------------------------------------------

View File

@@ -59,7 +59,7 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent)
int translatedMousePosX, translatedMousePosY;
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier)
if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled())
{
cvf::HitItemCollection hic;
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);

View File

@@ -59,7 +59,7 @@ bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent)
int translatedMousePosX, translatedMousePosY;
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
if (me->button() == Qt::LeftButton)
if (me->button() == Qt::LeftButton && isRotationEnabled())
{
cvf::HitItemCollection hic;
bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic);

View File

@@ -59,7 +59,7 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent)
int translatedMousePosX, translatedMousePosY;
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
if (me->button() == Qt::MidButton)
if (me->button() == Qt::MidButton && isRotationEnabled())
{
cvf::HitItemCollection hic;
bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic);

View File

@@ -79,7 +79,7 @@ const double RI_MIN_NEARPLANE_DISTANCE = 0.1;
///
//--------------------------------------------------------------------------------------------------
RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
: caf::Viewer(format, parent)
: caf::Viewer(format, parent), m_isNavigationRotationEnabled(true)
{
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont);
@@ -589,6 +589,17 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::enableNavigationRotation(bool enable)
{
auto tbNavPol = dynamic_cast<caf::TrackBallBasedNavigation*>(m_navigationPolicy.p());
m_isNavigationRotationEnabled = enable;
if (tbNavPol) tbNavPol->enableRotation(m_isNavigationRotationEnabled);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -616,6 +627,8 @@ void RiuViewer::updateNavigationPolicy()
CVF_ASSERT(0);
break;
}
enableNavigationRotation(m_isNavigationRotationEnabled);
}
//--------------------------------------------------------------------------------------------------

View File

@@ -91,6 +91,7 @@ public:
void removeAllColorLegends();
void addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend);
void enableNavigationRotation(bool disable);
void updateNavigationPolicy();
virtual void navigationPolicyUpdate(); // Override of caf::Viewer::navigationPolicyUpdate()
@@ -156,5 +157,6 @@ private:
RivGridBoxGenerator* m_gridBoxGenerator;
cvf::Vec3d m_cursorPositionDomainCoords;
bool m_isNavigationRotationEnabled;
};

View File

@@ -77,7 +77,7 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent)
int translatedMousePosX, translatedMousePosY;
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier)
if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled())
{
cvf::HitItemCollection hic;
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);

View File

@@ -77,7 +77,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
int translatedMousePosX, translatedMousePosY;
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
if (me->button() == Qt::RightButton)
if (me->button() == Qt::RightButton && isRotationEnabled())
{
cvf::HitItemCollection hic;
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);

View File

@@ -78,6 +78,7 @@ void caf::TrackBallBasedNavigation::init()
m_trackball = new cvf::ManipulatorTrackball;
m_trackball->setCamera(m_viewer->mainCamera());
m_isRotCenterInitialized = false;
m_isRotationEnabled = true;
m_hasMovedMouseDuringNavigation = false;
m_isNavigating = false;
m_isZooming = false;

View File

@@ -59,6 +59,7 @@ public:
TrackBallBasedNavigation();
virtual ~TrackBallBasedNavigation();
void enableEventEating(bool enable) { m_consumeEvents = enable; }
void enableRotation(bool enable) { m_isRotationEnabled = enable; }
protected:
// General navigation policy overrides
@@ -88,9 +89,11 @@ protected:
int m_lastPosY;
bool isSupposedToConsumeEvents() { return m_consumeEvents; }
bool isRotationEnabled() { return m_isRotationEnabled; }
private:
bool m_consumeEvents;
bool m_isRotationEnabled;
};
} // End namespace caf