mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#552 Linked Views : Prototype - show label at cursor position in dependant views
This commit is contained in:
parent
16cc14a71d
commit
90a2d384d3
@ -67,6 +67,7 @@ RimViewController::RimViewController(void)
|
||||
m_managedView.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_syncCamera, "SyncCamera", true, "Camera", "", "", "");
|
||||
CAF_PDM_InitField(&m_showCursor, "ShowCursor", false, " Show Cursor", "", "", "");
|
||||
CAF_PDM_InitField(&m_syncTimeStep, "SyncTimeStep", true, "Time Step", "", "", "");
|
||||
CAF_PDM_InitField(&m_syncCellResult, "SyncCellResult", false, "Cell Result", "", "", "");
|
||||
CAF_PDM_InitField(&m_syncLegendDefinitions, "SyncLegendDefinitions", true, " Legend Definition", "", "", "");
|
||||
@ -174,6 +175,13 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField
|
||||
{
|
||||
updateTimeStepLink();
|
||||
}
|
||||
else if (changedField == &m_showCursor)
|
||||
{
|
||||
if (!m_showCursor && m_managedView && m_managedView->viewer())
|
||||
{
|
||||
m_managedView->viewer()->setCursorPosition(cvf::Vec3d::UNDEFINED);
|
||||
}
|
||||
}
|
||||
else if (changedField == &m_syncCellResult)
|
||||
{
|
||||
updateResultColorsControl();
|
||||
@ -418,6 +426,16 @@ void RimViewController::updateOptionSensitivity()
|
||||
this->m_syncRangeFilters = false;
|
||||
}
|
||||
|
||||
if (m_syncCamera)
|
||||
{
|
||||
this->m_showCursor.uiCapability()->setUiReadOnly(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_showCursor.uiCapability()->setUiReadOnly(true);
|
||||
this->m_showCursor = false;
|
||||
}
|
||||
|
||||
m_syncVisibleCells.uiCapability()->setUiReadOnly(!this->isMasterAndDepViewDifferentType());
|
||||
}
|
||||
|
||||
@ -455,6 +473,7 @@ void RimViewController::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin
|
||||
caf::PdmUiGroup* scriptGroup = uiOrdering.addNewGroup("Link Options");
|
||||
|
||||
scriptGroup->add(&m_syncCamera);
|
||||
scriptGroup->add(&m_showCursor);
|
||||
scriptGroup->add(&m_syncTimeStep);
|
||||
scriptGroup->add(&m_syncCellResult);
|
||||
scriptGroup->add(&m_syncLegendDefinitions);
|
||||
@ -713,6 +732,14 @@ bool RimViewController::isCameraLinked()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimViewController::showCursor() const
|
||||
{
|
||||
return m_showCursor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
const RigCaseToCaseCellMapper* cellMapper();
|
||||
|
||||
bool isCameraLinked();
|
||||
bool showCursor() const;
|
||||
bool isTimeStepLinked();
|
||||
|
||||
bool isResultColorControlled();
|
||||
@ -109,8 +110,10 @@ private:
|
||||
|
||||
caf::PdmField<bool> m_isActive;
|
||||
caf::PdmField<bool> m_syncCamera;
|
||||
caf::PdmField<bool> m_showCursor;
|
||||
caf::PdmField<bool> m_syncTimeStep;
|
||||
|
||||
|
||||
// Overridden properties
|
||||
caf::PdmField<bool> m_syncCellResult;
|
||||
caf::PdmField<bool> m_syncLegendDefinitions;
|
||||
|
@ -250,7 +250,7 @@ void RimViewLinker::removeOverrides()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::allViewsForCameraSync(RimView* source, std::vector<RimView*>& views)
|
||||
void RimViewLinker::allViewsForCameraSync(const RimView* source, std::vector<RimView*>& views)
|
||||
{
|
||||
if (!isActive()) return;
|
||||
|
||||
@ -333,7 +333,7 @@ RimView* RimViewLinker::masterView()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::allViews(std::vector<RimView*>& views)
|
||||
void RimViewLinker::allViews(std::vector<RimView*>& views) const
|
||||
{
|
||||
views.push_back(m_masterView());
|
||||
|
||||
@ -485,6 +485,49 @@ void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimView*
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::updateCursorPosition(const RimView* sourceView, const cvf::Vec3d& domainCoord)
|
||||
{
|
||||
std::vector<RimView*> viewsToUpdate;
|
||||
allViewsForCameraSync(sourceView, viewsToUpdate);
|
||||
|
||||
for (RimView* destinationView : viewsToUpdate)
|
||||
{
|
||||
if (destinationView == sourceView) continue;
|
||||
|
||||
RimViewController* viewLink = destinationView->viewController();
|
||||
if (!viewLink) continue;
|
||||
|
||||
if (!viewLink->showCursor()) continue;
|
||||
|
||||
RiuViewer* destinationViewer = destinationView->viewer();
|
||||
if (destinationViewer)
|
||||
{
|
||||
destinationViewer->setCursorPosition(domainCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::disableCursor()
|
||||
{
|
||||
std::vector<RimView*> viewsToUpdate;
|
||||
allViewsForCameraSync(m_masterView, viewsToUpdate);
|
||||
|
||||
for (RimView* destinationView : viewsToUpdate)
|
||||
{
|
||||
RiuViewer* destinationViewer = destinationView->viewer();
|
||||
if (destinationViewer)
|
||||
{
|
||||
destinationViewer->setCursorPosition(cvf::Vec3d::UNDEFINED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -629,8 +672,6 @@ void RimViewLinker::addDependentView(RimView* view)
|
||||
this->m_viewControllers.push_back(viewContr);
|
||||
|
||||
viewContr->setManagedView(view);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -28,6 +28,9 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class BoundingBox;
|
||||
@ -73,7 +76,7 @@ public:
|
||||
void scheduleGeometryRegenForDepViews(RivCellSetEnum geometryType);
|
||||
void scheduleCreateDisplayModelAndRedrawForDependentViews();
|
||||
|
||||
void allViews(std::vector<RimView*>& views);
|
||||
void allViews(std::vector<RimView*>& views) const;
|
||||
|
||||
void updateUiNameAndIcon();
|
||||
|
||||
@ -82,6 +85,9 @@ public:
|
||||
static void applyIconEnabledState(caf::PdmObject* obj, const QIcon& icon, bool disable);
|
||||
static void findNameAndIconFromView(QString* name, QIcon* icon, RimView* view);
|
||||
|
||||
void updateCursorPosition(const RimView* sourceView, const cvf::Vec3d& domainCoord);
|
||||
void disableCursor();
|
||||
|
||||
public:
|
||||
static QString displayNameForView(RimView* view);
|
||||
|
||||
@ -90,7 +96,7 @@ protected:
|
||||
virtual void initAfterRead();
|
||||
|
||||
private:
|
||||
void allViewsForCameraSync(RimView* source, std::vector<RimView*>& views);
|
||||
void allViewsForCameraSync(const RimView* source, std::vector<RimView*>& views);
|
||||
|
||||
void removeOverrides();
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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,7 @@ public slots:
|
||||
protected:
|
||||
virtual void optimizeClippingPlanes();
|
||||
virtual void resizeGL(int width, int height);
|
||||
virtual void mouseMoveEvent(QMouseEvent* e) override;
|
||||
|
||||
private:
|
||||
void updateTextAndTickMarkColorForOverlayItems();
|
||||
@ -140,5 +143,7 @@ private:
|
||||
RiuViewerCommands* m_viewerCommands;
|
||||
|
||||
RivGridBoxGenerator* m_gridBoxGenerator;
|
||||
|
||||
cvf::Vec3d m_cursorPositionDomainCoords;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user