#552 Linked Views : Prototype - show label at cursor position in dependant views

This commit is contained in:
Magne Sjaastad
2016-12-15 18:20:43 +01:00
parent 16cc14a71d
commit 90a2d384d3
6 changed files with 160 additions and 7 deletions

View File

@@ -39,6 +39,7 @@
#include "cafCategoryLegend.h"
#include "cafCeetronPlusNavigation.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
#include "cvfCamera.h"
@@ -169,8 +170,9 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
setContextMenuPolicy(Qt::PreventContextMenu);
m_gridBoxGenerator = new RivGridBoxGenerator;
}
m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED;
}
//--------------------------------------------------------------------------------------------------
///
@@ -407,6 +409,26 @@ 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 pos(screenCoords.x(), translatedMousePosY);
QLabel test("x");
test.render(painter, pos);
}
}
}
}
//--------------------------------------------------------------------------------------------------
@@ -655,6 +677,42 @@ void RiuViewer::resizeGL(int width, int height)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent)
{
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_rimView)
{
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
if (viewLinker)
{
if (m_cursorPositionDomainCoords != cvf::Vec3d::UNDEFINED)
{
// Set undefined and redraw to make sure the cursor is not visible in the view
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);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -752,6 +810,19 @@ void RiuViewer::updateParallelProjectionSettings(RiuViewer* sourceViewer)
this->updateParallelProjectionCameraPosFromPointOfInterestMove(poi);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setCursorPosition(const cvf::Vec3d& domainCoord)
{
if (m_cursorPositionDomainCoords != domainCoord)
{
m_cursorPositionDomainCoords = domainCoord;
update();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------