diff --git a/ApplicationCode/ProjectDataModel/RimFaultCollection.h b/ApplicationCode/ProjectDataModel/RimFaultCollection.h index 095a65f96b..39b1fe982a 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultCollection.h +++ b/ApplicationCode/ProjectDataModel/RimFaultCollection.h @@ -75,13 +75,12 @@ public: caf::PdmField showFaultCollection; caf::PdmPointersField faults; + RimFault* findFaultByName(QString name); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual caf::PdmFieldHandle* objectToggleField(); private: - RimFault* findFaultByName(QString name); - virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); private: diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 6d6c7ac57e..750729323b 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -2043,39 +2043,16 @@ void RimReservoirView::updateFaultColors() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::appendFaultName(RigGridBase* grid, size_t cellIndex, cvf::StructGridInterface::FaceType face, QString* resultInfoText) +void RimReservoirView::appendFaultName(RigGridBase* grid, size_t cellIndex, cvf::StructGridInterface::FaceType face, QString* textString) { if (grid->isMainGrid()) { RigMainGrid* mainGrid = grid->mainGrid(); - for (size_t i = 0; i < mainGrid->faults().size(); i++) + const RigFault* fault = mainGrid->findFaultFromCellIndexAndCellFace(cellIndex, face); + if (fault) { - const RigFault* rigFault = mainGrid->faults().at(i); - const std::vector& faultFaces = rigFault->faultFaces(); - - for (size_t fIdx = 0; fIdx < faultFaces.size(); fIdx++) - { - if (faultFaces[fIdx].m_nativeGlobalCellIndex == cellIndex) - { - if (face == faultFaces[fIdx].m_nativeFace ) - { - resultInfoText->append(QString("Fault Name: %1\n").arg(rigFault->name())); - } - - return; - } - - if (faultFaces[fIdx].m_oppositeGlobalCellIndex == cellIndex) - { - if (face == cvf::StructGridInterface::oppositeFace(faultFaces[fIdx].m_nativeFace)) - { - resultInfoText->append(QString("Fault Name: %1\n").arg(rigFault->name())); - } - - return; - } - } + textString->append(QString("Fault Name: %1\n").arg(fault->name())); } } } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 4c37031753..178d17ecd5 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -180,7 +180,7 @@ public: // Display model generation private: - void appendFaultName(RigGridBase* grid, size_t cellIndex, cvf::StructGridInterface::FaceType face, QString* resultInfoText); + void appendFaultName(RigGridBase* grid, size_t cellIndex, cvf::StructGridInterface::FaceType face, QString* textString); void createDisplayModel(); void updateDisplayModelVisibility(); diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index db11222984..4bbdea1cb9 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -369,3 +369,36 @@ bool RigMainGrid::faceNormalsIsOutwards() const { return m_flipXAxis ^ m_flipYAxis; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace(size_t cellIndex, cvf::StructGridInterface::FaceType face) const +{ + for (size_t i = 0; i < m_faults.size(); i++) + { + const RigFault* rigFault = m_faults.at(i); + const std::vector& faultFaces = rigFault->faultFaces(); + + for (size_t fIdx = 0; fIdx < faultFaces.size(); fIdx++) + { + if (faultFaces[fIdx].m_nativeGlobalCellIndex == cellIndex) + { + if (face == faultFaces[fIdx].m_nativeFace ) + { + return rigFault; + } + } + + if (faultFaces[fIdx].m_oppositeGlobalCellIndex == cellIndex) + { + if (face == cvf::StructGridInterface::oppositeFace(faultFaces[fIdx].m_nativeFace)) + { + return rigFault; + } + } + } + } + + return NULL; +} diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index f7fc927571..0cf0dc8286 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -51,6 +51,7 @@ public: void setFaults(const cvf::Collection& faults); const cvf::Collection& faults() { return m_faults; } void calculateFaults(); + const RigFault* findFaultFromCellIndexAndCellFace(size_t cellIndex, cvf::StructGridInterface::FaceType face) const; bool faceNormalsIsOutwards() const; void computeCachedData(); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 71489243e2..286058a707 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -25,12 +25,13 @@ #include "RimReservoirView.h" -#include "RimCase.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" -#include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" #include "Rim3dOverlayInfoConfig.h" +#include "RimCase.h" +#include "RimCellEdgeResultSlot.h" +#include "RimCellPropertyFilterCollection.h" +#include "RimCellRangeFilterCollection.h" +#include "RimFaultCollection.h" +#include "RimResultSlot.h" #include "RimWellCollection.h" #include "RimUiTreeModelPdm.h" @@ -278,11 +279,24 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event) { m_currentGridIdx = firstHitPart->id(); m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex); + m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex); QMenu menu; + menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI())); menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ())); menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK())); + + const RigCaseData* reservoir = m_reservoirView->eclipseCase()->reservoirData(); + const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); + if (fault) + { + menu.addSeparator(); + + QString faultName = fault->name(); + menu.addAction(QString("Hide ") + faultName, this, SLOT(slotHideFault())); + } + menu.exec(event->globalPos()); } } @@ -759,3 +773,22 @@ void RiuViewer::removeOverlayItem(cvf::OverlayItem* overlayItem) m_renderingSequence->firstRendering()->removeOverlayItem(overlayItem); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::slotHideFault() +{ + const RigCaseData* reservoir = m_reservoirView->eclipseCase()->reservoirData(); + const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); + if (fault) + { + QString faultName = fault->name(); + + RimFault* rimFault = m_reservoirView->faultCollection()->findFaultByName(faultName); + if (rimFault) + { + rimFault->showFault.setValueFromUi(!rimFault->showFault); + } + } +} + diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 7e881a1464..a2f5c4de92 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -24,6 +24,7 @@ #include "cafPdmPointer.h" #include "cafMouseState.h" +#include "cvfStructGrid.h" class RimReservoirView; class QLabel; @@ -87,6 +88,7 @@ private slots: void slotRangeFilterI(); void slotRangeFilterJ(); void slotRangeFilterK(); + void slotHideFault(); private: void updateLegends(); @@ -114,6 +116,7 @@ private: size_t m_currentGridIdx; size_t m_currentCellIndex; + cvf::StructGridInterface::FaceType m_currentFaceIndex; QPoint m_lastMousePressPosition; };