(#674) Clicking on items in 3D view selects corresponding item in tree view/property panel

Clicking on 3D Info box and legends for cell result, separate fault
result and cell edge selects corresponding items in tree view
This commit is contained in:
Magne Sjaastad 2015-12-07 09:59:19 +01:00
parent e65facd590
commit a2bfc12c57
8 changed files with 122 additions and 15 deletions

View File

@ -870,3 +870,11 @@ bool RimView::showActiveCellsOnly()
return false; return false;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::selectOverlayInfoConfig()
{
RiuMainWindow::instance()->setCurrentObjectInTreeView(m_overlayInfoConfig);
}

View File

@ -147,6 +147,8 @@ public:
virtual bool showActiveCellsOnly(); virtual bool showActiveCellsOnly();
virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) = 0; virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) = 0;
void selectOverlayInfoConfig();
public: public:
virtual void loadDataAndUpdate() = 0; virtual void loadDataAndUpdate() = 0;
virtual RimCase* ownerCase() = 0; virtual RimCase* ownerCase() = 0;
@ -210,7 +212,6 @@ protected:
private: private:
RimViewLinker* viewLinkerIfMasterView() const; RimViewLinker* viewLinkerIfMasterView() const;
private: private:
bool m_previousGridModeMeshLinesWasFaults; bool m_previousGridModeMeshLinesWasFaults;
caf::PdmField<bool> m_disableLighting; caf::PdmField<bool> m_disableLighting;

View File

@ -115,10 +115,10 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
p.setColor(QPalette::Dark, progressAndHistogramColor); p.setColor(QPalette::Dark, progressAndHistogramColor);
// Info Text // Info Text
m_InfoLabel = new QLabel(); m_infoLabel = new QLabel();
m_InfoLabel->setPalette(p); m_infoLabel->setPalette(p);
m_InfoLabel->setFrameShape(QFrame::Box); m_infoLabel->setFrameShape(QFrame::Box);
m_InfoLabel->setMinimumWidth(275); m_infoLabel->setMinimumWidth(275);
m_showInfoText = true; m_showInfoText = true;
// Version info label // Version info label
@ -152,10 +152,10 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
if (RiaApplication::instance()->isRunningRegressionTests()) if (RiaApplication::instance()->isRunningRegressionTests())
{ {
QFont regTestFont = m_InfoLabel->font(); QFont regTestFont = m_infoLabel->font();
regTestFont.setPixelSize(11); regTestFont.setPixelSize(11);
m_InfoLabel->setFont(regTestFont); m_infoLabel->setFont(regTestFont);
m_versionInfoLabel->setFont(regTestFont); m_versionInfoLabel->setFont(regTestFont);
m_animationProgress->setFont(regTestFont); m_animationProgress->setFont(regTestFont);
m_histogramWidget->setFont(regTestFont); m_histogramWidget->setFont(regTestFont);
@ -183,7 +183,7 @@ RiuViewer::~RiuViewer()
m_rimView->cameraPosition = m_mainCamera->viewMatrix(); m_rimView->cameraPosition = m_mainCamera->viewMatrix();
} }
delete m_InfoLabel; delete m_infoLabel;
delete m_animationProgress; delete m_animationProgress;
delete m_histogramWidget; delete m_histogramWidget;
delete m_progressBarStyle; delete m_progressBarStyle;
@ -228,6 +228,16 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
{ {
if (!m_infoLabelOverlayArea.isNull())
{
if (m_infoLabelOverlayArea.contains(event->x(), event->y()))
{
m_rimView->selectOverlayInfoConfig();
return;
}
}
m_viewerCommands->handlePickAction(event->x(), event->y(), event->modifiers()); m_viewerCommands->handlePickAction(event->x(), event->y(), event->modifiers());
return; return;
} }
@ -336,7 +346,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
if (isAnimationActive() && frameCount() > 1) showAnimBar = true; if (isAnimationActive() && frameCount() > 1) showAnimBar = true;
//if (showAnimBar) columnWidth = CVF_MAX(columnWidth, m_animationProgress->width()); //if (showAnimBar) columnWidth = CVF_MAX(columnWidth, m_animationProgress->width());
if (m_showInfoText) columnWidth = CVF_MAX(columnWidth, m_InfoLabel->sizeHint().width()); if (m_showInfoText) columnWidth = CVF_MAX(columnWidth, m_infoLabel->sizeHint().width());
int columnPos = this->width() - columnWidth - margin; int columnPos = this->width() - columnWidth - margin;
@ -356,9 +366,19 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
if (m_showInfoText) if (m_showInfoText)
{ {
m_InfoLabel->resize(columnWidth, m_InfoLabel->sizeHint().height()); QPoint topLeft = QPoint(columnPos, yPos);
m_InfoLabel->render(painter, QPoint(columnPos, yPos)); m_infoLabel->resize(columnWidth, m_infoLabel->sizeHint().height());
yPos += m_InfoLabel->height() + margin; m_infoLabel->render(painter, topLeft);
m_infoLabelOverlayArea.setTopLeft(topLeft);
m_infoLabelOverlayArea.setBottom(yPos + m_infoLabel->height());
m_infoLabelOverlayArea.setRight(columnPos + columnWidth);
yPos += m_infoLabel->height() + margin;
}
else
{
m_infoLabelOverlayArea = QRect();
} }
if (m_showHistogram) if (m_showHistogram)
@ -383,7 +403,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuViewer::setInfoText(QString text) void RiuViewer::setInfoText(QString text)
{ {
m_InfoLabel->setText(text); m_infoLabel->setText(text);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -110,7 +110,9 @@ private:
void mousePressEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event);
private: private:
QLabel* m_InfoLabel; QLabel* m_infoLabel;
QRect m_infoLabelOverlayArea;
QLabel* m_versionInfoLabel; QLabel* m_versionInfoLabel;
bool m_showInfoText; bool m_showInfoText;

View File

@ -30,17 +30,20 @@
#include "RigFemPartGrid.h" #include "RigFemPartGrid.h"
#include "RigGeoMechCaseData.h" #include "RigGeoMechCaseData.h"
#include "RimCellEdgeColors.h"
#include "RimContextCommandBuilder.h" #include "RimContextCommandBuilder.h"
#include "RimCrossSection.h" #include "RimCrossSection.h"
#include "RimDefines.h" #include "RimDefines.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimEclipseCellColors.h" #include "RimEclipseCellColors.h"
#include "RimEclipseFaultColors.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimEclipseWell.h" #include "RimEclipseWell.h"
#include "RimFaultCollection.h" #include "RimFaultCollection.h"
#include "RimGeoMechCase.h" #include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h" #include "RimGeoMechCellColors.h"
#include "RimGeoMechView.h" #include "RimGeoMechView.h"
#include "RimTernaryLegendConfig.h"
#include "RimViewController.h" #include "RimViewController.h"
#include "RimWellPath.h" #include "RimWellPath.h"
@ -53,6 +56,7 @@
#include "RivFemPartGeometryGenerator.h" #include "RivFemPartGeometryGenerator.h"
#include "RivFemPickSourceInfo.h" #include "RivFemPickSourceInfo.h"
#include "RivSourceInfo.h" #include "RivSourceInfo.h"
#include "RivTernarySaturationOverlayItem.h"
#include "RivWellPathSourceInfo.h" #include "RivWellPathSourceInfo.h"
#include "RivWellPipeSourceInfo.h" #include "RivWellPipeSourceInfo.h"
@ -63,6 +67,8 @@
#include "cvfDrawableGeo.h" #include "cvfDrawableGeo.h"
#include "cvfHitItemCollection.h" #include "cvfHitItemCollection.h"
#include "cvfOverlayAxisCross.h"
#include "cvfOverlayScalarMapperLegend.h"
#include "cvfPart.h" #include "cvfPart.h"
#include "WellPathCommands/RicWellPathViewerEventHandler.h" #include "WellPathCommands/RicWellPathViewerEventHandler.h"
@ -419,6 +425,11 @@ void RiuViewerCommands::slotHideIntersection()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardModifiers keyboardModifiers) void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardModifiers keyboardModifiers)
{ {
if (handleOverlayItemPicking(winPosX, winPosY))
{
return;
}
size_t gridIndex = cvf::UNDEFINED_SIZE_T; size_t gridIndex = cvf::UNDEFINED_SIZE_T;
size_t cellIndex = cvf::UNDEFINED_SIZE_T; size_t cellIndex = cvf::UNDEFINED_SIZE_T;
size_t nncIndex = cvf::UNDEFINED_SIZE_T; size_t nncIndex = cvf::UNDEFINED_SIZE_T;
@ -434,7 +445,6 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
uint nncPartTriangleIndex = cvf::UNDEFINED_UINT; uint nncPartTriangleIndex = cvf::UNDEFINED_UINT;
cvf::HitItemCollection hitItems; cvf::HitItemCollection hitItems;
if (m_viewer->rayPick(winPosX, winPosY, &hitItems)) if (m_viewer->rayPick(winPosX, winPosY, &hitItems))
{ {
extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &firstNncHitPart, &nncPartTriangleIndex); extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &firstNncHitPart, &nncPartTriangleIndex);
@ -715,3 +725,52 @@ void RiuViewerCommands::updateSelectionFromPickedPart(cvf::Part* part)
} }
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuViewerCommands::handleOverlayItemPicking(int winPosX, int winPosY)
{
cvf::OverlayItem* pickedOverlayItem = m_viewer->overlayItem(winPosX, winPosY);
if (pickedOverlayItem)
{
caf::PdmObject* objToSelect = NULL;
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
if (eclipseView)
{
if (eclipseView->cellResult()->legendConfig()->legend() == pickedOverlayItem
|| eclipseView->cellResult()->ternaryLegendConfig->legend() == pickedOverlayItem)
{
objToSelect = eclipseView->cellResult();
}
else if (eclipseView->faultResultSettings()->customFaultResult()->legendConfig()->legend() == pickedOverlayItem
|| eclipseView->faultResultSettings()->customFaultResult()->ternaryLegendConfig()->legend() == pickedOverlayItem)
{
objToSelect = eclipseView->faultResultSettings();
}
else if (eclipseView->cellEdgeResult()->legendConfig()->legend() == pickedOverlayItem)
{
objToSelect = eclipseView->cellEdgeResult();
}
}
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
if (geomView)
{
if (geomView->cellResult()->legendConfig()->legend() == pickedOverlayItem)
{
objToSelect = geomView->cellResult();
}
}
if (objToSelect)
{
RiuMainWindow::instance()->setCurrentObjectInTreeView(objToSelect);
return true;
}
}
return false;
}

View File

@ -70,6 +70,8 @@ private:
void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit); void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit);
void updateSelectionFromPickedPart(cvf::Part* part); void updateSelectionFromPickedPart(cvf::Part* part);
bool handleOverlayItemPicking(int winPosX, int winPosY);
size_t m_currentGridIdx; size_t m_currentGridIdx;
size_t m_currentCellIndex; size_t m_currentCellIndex;
cvf::StructGridInterface::FaceType m_currentFaceIndex; cvf::StructGridInterface::FaceType m_currentFaceIndex;

View File

@ -908,3 +908,16 @@ void caf::Viewer::appendAllStaticModelsToFrame(cvf::Scene* scene)
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::OverlayItem* caf::Viewer::overlayItem(int winPosX, int winPosY)
{
if (m_mainRendering.isNull()) return NULL;
int translatedMousePosX = winPosX;
int translatedMousePosY = height() - winPosY;
return m_mainRendering->overlayItemFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
}

View File

@ -57,6 +57,7 @@ namespace cvf {
class Rendering; class Rendering;
class Scene; class Scene;
class TextureImage; class TextureImage;
class OverlayItem;
} }
namespace caf { namespace caf {
@ -123,6 +124,7 @@ public:
bool canRender() const; bool canRender() const;
bool rayPick(int winPosX, int winPosY, cvf::HitItemCollection* pickedPoints) ; bool rayPick(int winPosX, int winPosY, cvf::HitItemCollection* pickedPoints) ;
cvf::OverlayItem* overlayItem(int winPosX, int winPosY);
// QPainter based drawing on top of the OpenGL graphics // QPainter based drawing on top of the OpenGL graphics