mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merged branch maintenance-enhancements into dev
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "cafCategoryLegend.h"
|
||||
#include "cafCeetronPlusNavigation.h"
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafFrameAnimationControl.h"
|
||||
|
||||
@@ -170,8 +171,9 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
||||
setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
|
||||
m_gridBoxGenerator = new RivGridBoxGenerator;
|
||||
}
|
||||
|
||||
m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -408,6 +410,29 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
|
||||
m_versionInfoLabel->render(painter, pos);
|
||||
yPos += size.height() + margin;
|
||||
}
|
||||
|
||||
if (!m_cursorPositionDomainCoords.isUndefined())
|
||||
{
|
||||
if (mainCamera())
|
||||
{
|
||||
cvf::ref<caf::DisplayCoordTransform> trans = m_rimView->displayCoordTransform();
|
||||
|
||||
cvf::Vec3d displayCoord = trans->transformToDisplayCoord(m_cursorPositionDomainCoords);
|
||||
|
||||
cvf::Vec3d screenCoords;
|
||||
if (mainCamera()->project(displayCoord, &screenCoords))
|
||||
{
|
||||
int translatedMousePosY = height() - screenCoords.y();
|
||||
QPoint centerPos(screenCoords.x(), translatedMousePosY);
|
||||
|
||||
// Draw a cross hair marker
|
||||
int markerHalfLength = 6;
|
||||
|
||||
painter->drawLine(centerPos.x(), centerPos.y() - markerHalfLength, centerPos.x(), centerPos.y() + markerHalfLength);
|
||||
painter->drawLine(centerPos.x() - markerHalfLength, centerPos.y(), centerPos.x() + markerHalfLength, centerPos.y());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -658,6 +683,54 @@ void RiuViewer::resizeGL(int width, int height)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent)
|
||||
{
|
||||
if (m_rimView)
|
||||
{
|
||||
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
|
||||
if (viewLinker)
|
||||
{
|
||||
int translatedMousePosX = mouseEvent->pos().x();
|
||||
int translatedMousePosY = height() - mouseEvent->pos().y();
|
||||
|
||||
cvf::Vec3d displayCoord(0, 0, 0);
|
||||
if (mainCamera()->unproject(cvf::Vec3d(static_cast<double>(translatedMousePosX), static_cast<double>(translatedMousePosY), 0), &displayCoord))
|
||||
{
|
||||
if (m_cursorPositionDomainCoords != cvf::Vec3d::UNDEFINED)
|
||||
{
|
||||
// Reset the extra cursor if the view currently is receiving mouse cursor events
|
||||
// Set undefined and redraw to remove the previously displayed cursor
|
||||
m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> trans = m_rimView->displayCoordTransform();
|
||||
cvf::Vec3d domainCoord = trans->transformToDomainCoord(displayCoord);
|
||||
|
||||
viewLinker->updateCursorPosition(m_rimView, domainCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
caf::Viewer::mouseMoveEvent(mouseEvent);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::leaveEvent(QEvent *)
|
||||
{
|
||||
if (m_rimView && m_rimView->assosiatedViewLinker())
|
||||
{
|
||||
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
|
||||
viewLinker->updateCursorPosition(m_rimView, cvf::Vec3d::UNDEFINED);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -755,6 +828,19 @@ void RiuViewer::updateParallelProjectionSettings(RiuViewer* sourceViewer)
|
||||
this->updateParallelProjectionCameraPosFromPointOfInterestMove(poi);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::setCursorPosition(const cvf::Vec3d& domainCoord)
|
||||
{
|
||||
if (m_cursorPositionDomainCoords != domainCoord)
|
||||
{
|
||||
m_cursorPositionDomainCoords = domainCoord;
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -96,6 +96,8 @@ public:
|
||||
|
||||
void updateParallelProjectionSettings(RiuViewer* sourceViewer);
|
||||
|
||||
void setCursorPosition(const cvf::Vec3d& domainCoord);
|
||||
|
||||
public slots:
|
||||
virtual void slotSetCurrentFrame(int frameIndex);
|
||||
virtual void slotEndAnimation();
|
||||
@@ -103,6 +105,8 @@ public slots:
|
||||
protected:
|
||||
virtual void optimizeClippingPlanes();
|
||||
virtual void resizeGL(int width, int height);
|
||||
virtual void mouseMoveEvent(QMouseEvent* e) override;
|
||||
virtual void leaveEvent(QEvent *) override;
|
||||
|
||||
private:
|
||||
void updateTextAndTickMarkColorForOverlayItems();
|
||||
@@ -140,5 +144,7 @@ private:
|
||||
RiuViewerCommands* m_viewerCommands;
|
||||
|
||||
RivGridBoxGenerator* m_gridBoxGenerator;
|
||||
|
||||
cvf::Vec3d m_cursorPositionDomainCoords;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user