diff --git a/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake b/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake index 1af8824eb6..fb77d4406a 100644 --- a/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake @@ -8,12 +8,18 @@ set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.h ${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.h ${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.h +${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.h +${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.h +${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.cpp ${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.cpp +${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.cpp +${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.cpp +${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp new file mode 100644 index 0000000000..3a83168297 --- /dev/null +++ b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp @@ -0,0 +1,74 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicLinkViewFeature.h" + +#include "RiaApplication.h" + +#include "RicLinkVisibleViewsFeature.h" + +#include "RimProject.h" +#include "RimView.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicLinkViewFeature, "RicLinkViewFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicLinkViewFeature::isCommandEnabled() +{ + RimView* activeView = RiaApplication::instance()->activeReservoirView(); + if (!activeView) return false; + + RimProject* proj = RiaApplication::instance()->project(); + if (!proj->findViewLinkerFromView(activeView)) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLinkViewFeature::onActionTriggered(bool isChecked) +{ + RimView* activeView = RiaApplication::instance()->activeReservoirView(); + if (!activeView) return; + + std::vector views; + views.push_back(activeView); + + RicLinkVisibleViewsFeature::linkViews(views); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLinkViewFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Link View"); + actionToSetup->setIcon(QIcon(":/chain.png")); +} + diff --git a/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.h b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.h new file mode 100644 index 0000000000..aa912bbe77 --- /dev/null +++ b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicLinkViewFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook(QAction* actionToSetup); +}; diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index 1a82830f80..e6ad7f3d92 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -60,11 +60,72 @@ bool RicLinkVisibleViewsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked) { - RimProject* proj = RiaApplication::instance()->project(); - std::vector views; findNotLinkedVisibleViews(views); + linkViews(views); + return; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLinkVisibleViewsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Link Visible Views"); + actionToSetup->setIcon(QIcon(":/chain.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) +{ + RimProject* proj = RiaApplication::instance()->project(); + for (size_t i = 0; i < proj->viewLinkerCollection()->viewLinkers().size(); i++) + { + RimViewLinker* linkedViews = proj->viewLinkerCollection()->viewLinkers()[i]; + linkedViews->allViews(views); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector &views) +{ + RimProject* proj = RiaApplication::instance()->project(); + + std::vector alreadyLinkedViews; + allLinkedViews(alreadyLinkedViews); + + std::vector visibleViews; + proj->allVisibleViews(visibleViews); + + for (size_t i = 0; i < visibleViews.size(); i++) + { + bool isLinked = false; + for (size_t j = 0; j < alreadyLinkedViews.size(); j++) + { + if (visibleViews[i] == alreadyLinkedViews[j]) + { + isLinked = true; + } + } + + if (!isLinked) + { + views.push_back(visibleViews[i]); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLinkVisibleViewsFeature::linkViews(std::vector& views) +{ + RimProject* proj = RiaApplication::instance()->project(); RimViewLinker* viewLinker = NULL; if (proj->viewLinkerCollection->viewLinkers().size() > 0) @@ -139,56 +200,3 @@ void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked) projTreeView->treeView()->setExpanded(modIndex, true); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::setupActionLook(QAction* actionToSetup) -{ - actionToSetup->setText("Link Visible Views"); - actionToSetup->setIcon(QIcon(":/chain.png")); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) -{ - RimProject* proj = RiaApplication::instance()->project(); - for (size_t i = 0; i < proj->viewLinkerCollection()->viewLinkers().size(); i++) - { - RimViewLinker* linkedViews = proj->viewLinkerCollection()->viewLinkers()[i]; - linkedViews->allViews(views); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector &views) -{ - RimProject* proj = RiaApplication::instance()->project(); - - std::vector alreadyLinkedViews; - allLinkedViews(alreadyLinkedViews); - - std::vector visibleViews; - proj->allVisibleViews(visibleViews); - - for (size_t i = 0; i < visibleViews.size(); i++) - { - bool isLinked = false; - for (size_t j = 0; j < alreadyLinkedViews.size(); j++) - { - if (visibleViews[i] == alreadyLinkedViews[j]) - { - isLinked = true; - } - } - - if (!isLinked) - { - views.push_back(visibleViews[i]); - } - } -} - diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h index fada41eb54..07a1a954ff 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h @@ -32,6 +32,9 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static void linkViews(std::vector &views); + protected: // Overrides virtual bool isCommandEnabled(); diff --git a/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp new file mode 100644 index 0000000000..04b05d4841 --- /dev/null +++ b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp @@ -0,0 +1,93 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicShowLinkOptionsFeature.h" + +#include "RiaApplication.h" +#include "RimProject.h" +#include "RimView.h" +#include "RimViewLink.h" +#include "RimViewLinker.h" +#include "RiuMainWindow.h" + +#include "cafSelectionManager.h" +#include "cafPdmUiTreeView.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicShowLinkOptionsFeature, "RicShowLinkOptionsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowLinkOptionsFeature::isCommandEnabled() +{ + RimView* activeView = RiaApplication::instance()->activeReservoirView(); + if (!activeView) return false; + + RimProject* proj = RiaApplication::instance()->project(); + if (proj->findViewLinkerFromView(activeView)) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowLinkOptionsFeature::onActionTriggered(bool isChecked) +{ + RimView* activeView = RiaApplication::instance()->activeReservoirView(); + if (!activeView) return; + + RimProject* proj = RiaApplication::instance()->project(); + RimViewLinker* viewLinker = proj->findViewLinkerFromView(activeView); + if (viewLinker) + { + if (viewLinker->mainView() == activeView) + { + RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(viewLinker); + + return; + } + + for (size_t i = 0; i < viewLinker->viewLinks.size(); i++) + { + RimViewLink* viewLink = viewLinker->viewLinks[i]; + if (viewLink->managedView() == activeView) + { + RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(viewLink); + + return; + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowLinkOptionsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Show Link Options"); +} + diff --git a/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.h b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.h new file mode 100644 index 0000000000..e80551dd21 --- /dev/null +++ b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicShowLinkOptionsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook(QAction* actionToSetup); +}; diff --git a/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp new file mode 100644 index 0000000000..beedd5487c --- /dev/null +++ b/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp @@ -0,0 +1,96 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicUnLinkViewFeature.h" + +#include "RimViewLink.h" +#include "RimView.h" +#include "RimViewLinker.h" + +#include "cafSelectionManager.h" + +#include +#include "RiaApplication.h" +#include "RimProject.h" +#include "cafCmdFeatureManager.h" + +CAF_CMD_SOURCE_INIT(RicUnLinkViewFeature, "RicUnLinkViewFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicUnLinkViewFeature::isCommandEnabled() +{ + RimView* activeView = RiaApplication::instance()->activeReservoirView(); + if (!activeView) return false; + + RimProject* proj = RiaApplication::instance()->project(); + RimViewLinker* viewLinker = proj->findViewLinkerFromView(activeView); + if (viewLinker) + { + if (viewLinker->mainView() == activeView) + { + return false; + } + + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUnLinkViewFeature::onActionTriggered(bool isChecked) +{ + RimView* activeView = RiaApplication::instance()->activeReservoirView(); + if (!activeView) return; + + RimProject* proj = RiaApplication::instance()->project(); + RimViewLinker* viewLinker = proj->findViewLinkerFromView(activeView); + if (viewLinker) + { + for (size_t i = 0; i < viewLinker->viewLinks.size(); i++) + { + RimViewLink* viewLink = viewLinker->viewLinks[i]; + if (viewLink->managedView() == activeView) + { + caf::SelectionManager::instance()->setSelectedItem(viewLink); + + caf::CmdFeature* feature = caf::CmdFeatureManager::instance()->getCommandFeature("RicDeleteItemFeature"); + if (feature) + { + feature->action()->trigger(); + + return; + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicUnLinkViewFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Unlink View"); +} + diff --git a/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.h b/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.h new file mode 100644 index 0000000000..9b01e73473 --- /dev/null +++ b/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicUnLinkViewFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook(QAction* actionToSetup); +}; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 9f6104c0cf..b1e8973c25 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -18,52 +18,59 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiuViewerCommands.h" -#include "RiuViewer.h" + +#include "RiaApplication.h" + +#include "RicEclipsePropertyFilterNewExec.h" +#include "RicGeoMechPropertyFilterNewExec.h" +#include "RicRangeFilterNewExec.h" + +#include "RigCaseData.h" +#include "RigFemPartCollection.h" +#include "RigFemPartGrid.h" +#include "RigGeoMechCaseData.h" + #include "RimCellRangeFilter.h" -#include "RimView.h" #include "RimCellRangeFilterCollection.h" #include "RimEclipseCase.h" -#include "RimEclipseView.h" -#include "RimGeoMechView.h" -#include "RimFaultCollection.h" #include "RimEclipseCellColors.h" #include "RimEclipsePropertyFilter.h" #include "RimEclipsePropertyFilterCollection.h" -#include "RimGeoMechView.h" +#include "RimEclipseView.h" +#include "RimFaultCollection.h" +#include "RimGeoMechCase.h" +#include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilter.h" #include "RimGeoMechPropertyFilterCollection.h" -#include "RimGeoMechCellColors.h" -#include "RimProject.h" +#include "RimGeoMechView.h" +#include "RimGeoMechView.h" #include "RimOilField.h" -#include "RimWellPathCollection.h" +#include "RimProject.h" +#include "RimView.h" #include "RimWellPath.h" +#include "RimWellPathCollection.h" +#include "RiuFemResultTextBuilder.h" +#include "RiuMainWindow.h" +#include "RiuResultTextBuilder.h" +#include "RiuViewer.h" + +#include "RivFemPartGeometryGenerator.h" +#include "RivFemPickSourceInfo.h" #include "RivSourceInfo.h" #include "RivWellPathSourceInfo.h" -#include "RivFemPickSourceInfo.h" -#include "RivFemPartGeometryGenerator.h" -#include "RigCaseData.h" -#include "RiuMainWindow.h" -#include "RiaApplication.h" -#include "RiuResultTextBuilder.h" -#include "RigGeoMechCaseData.h" -#include "RimGeoMechCase.h" -#include "RigFemPartCollection.h" -#include "RigFemPartGrid.h" + +#include "cafCmdExecCommandManager.h" +#include "cafCmdFeature.h" +#include "cafCmdFeatureManager.h" #include "cvfDrawableGeo.h" -#include "cvfPart.h" #include "cvfHitItemCollection.h" +#include "cvfPart.h" #include #include - #include -#include "RiuFemResultTextBuilder.h" -#include "RicRangeFilterNewExec.h" -#include "cafCmdExecCommandManager.h" -#include "RicGeoMechPropertyFilterNewExec.h" -#include "RicEclipsePropertyFilterNewExec.h" //================================================================================================== // @@ -107,6 +114,8 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) int winPosX = event->x(); int winPosY = event->y(); + QMenu menu; + uint faceIndex = cvf::UNDEFINED_UINT; cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO); @@ -120,77 +129,107 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL); } - if (!firstHitPart) return; - - if (faceIndex == cvf::UNDEFINED_UINT) return; - - if (!firstHitPart->sourceInfo()) return; - - const RivSourceInfo* rivSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); - const RivFemPickSourceInfo* femSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); - - if (!(rivSourceInfo || femSourceInfo) ) return; - - if (rivSourceInfo) + if (firstHitPart && faceIndex != cvf::UNDEFINED_UINT) { - if (!rivSourceInfo->hasCellFaceMapping()) return; + const RivSourceInfo* rivSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + const RivFemPickSourceInfo* femSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); - // Set the data regarding what was hit - - m_currentGridIdx = rivSourceInfo->gridIndex(); - m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex); - m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex); - } - else - { - m_currentGridIdx = femSourceInfo->femPartIndex(); - m_currentCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(faceIndex); - } - - // IJK -slice commands - - 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())); - - RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); - if (eclipseView) - { - RimEclipseCellColors* cellColors = eclipseView->cellResult().p(); - if (cellColors) + if (rivSourceInfo || femSourceInfo) { - QAction* propertyAction = new QAction(QString("Add property filter"), this); - connect(propertyAction, SIGNAL(triggered()), SLOT(slotAddEclipsePropertyFilter())); - - bool isPerCellFaceResult = RimDefines::isPerCellFaceResult(cellColors->resultVariable()); - if (isPerCellFaceResult) + if (rivSourceInfo) { - propertyAction->setEnabled(false); + if (!rivSourceInfo->hasCellFaceMapping()) return; + + // Set the data regarding what was hit + + m_currentGridIdx = rivSourceInfo->gridIndex(); + m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex); + m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex); + } + else + { + m_currentGridIdx = femSourceInfo->femPartIndex(); + m_currentCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(faceIndex); } - menu.addAction(propertyAction); - } - // Hide faults command - const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData(); - const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); - if (fault) - { - menu.addSeparator(); + // IJK -slice commands + + 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())); + + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + if (eclipseView) + { + RimEclipseCellColors* cellColors = eclipseView->cellResult().p(); + if (cellColors) + { + QAction* propertyAction = new QAction(QString("Add property filter"), this); + connect(propertyAction, SIGNAL(triggered()), SLOT(slotAddEclipsePropertyFilter())); + + bool isPerCellFaceResult = RimDefines::isPerCellFaceResult(cellColors->resultVariable()); + if (isPerCellFaceResult) + { + propertyAction->setEnabled(false); + } + menu.addAction(propertyAction); + } + + // Hide faults command + const RigCaseData* reservoir = eclipseView->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())); + } + } + + RimGeoMechView* geoMechView = dynamic_cast(m_reservoirView.p()); + if (geoMechView) + { + RimGeoMechCellColors* cellColors = geoMechView->cellResult().p(); + if (cellColors) + { + menu.addAction(QString("Add property filter"), this, SLOT(slotAddGeoMechPropertyFilter())); + } + } - QString faultName = fault->name(); - menu.addAction(QString("Hide ") + faultName, this, SLOT(slotHideFault())); } } - RimGeoMechView* geoMechView = dynamic_cast(m_reservoirView.p()); - if (geoMechView) + // View Link commands { - RimGeoMechCellColors* cellColors = geoMechView->cellResult().p(); - if (cellColors) + QStringList commandIds; + + commandIds << "RicLinkViewFeature"; + commandIds << "RicUnLinkViewFeature"; + commandIds << "RicShowLinkOptionsFeature"; + + bool firstLinkAction = true; + + caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance(); + for (int i = 0; i < commandIds.size(); i++) { - menu.addAction(QString("Add property filter"), this, SLOT(slotAddGeoMechPropertyFilter())); + caf::CmdFeature* feature = commandManager->getCommandFeature(commandIds[i].toStdString()); + if (feature->canFeatureBeExecuted()) + { + QAction* act = commandManager->action(commandIds[i]); + CVF_ASSERT(act); + + if (firstLinkAction) + { + if (menu.actions().size() > 0) + { + menu.addSeparator(); + } + firstLinkAction = false; + } + + menu.addAction(act); + } } }