mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2162 Context menu: Move IJK-slice features to command
This commit is contained in:
parent
e89d2c0717
commit
48b165e2aa
@ -29,6 +29,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicImportFormationNamesFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
|
||||
|
||||
@ -102,6 +103,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicImportFormationNamesFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp
|
||||
|
98
ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp
Normal file
98
ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicNewSliceRangeFilterFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicRangeFilterFeatureImpl.h"
|
||||
#include "RicRangeFilterNewExec.h"
|
||||
|
||||
#include "RimView.h"
|
||||
#include "RimViewController.h"
|
||||
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewSliceRangeFilterFeature, "RicNewSliceRangeFilterFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewSliceRangeFilterFeature::isCommandEnabled()
|
||||
{
|
||||
RimView* view = RiaApplication::instance()->activeReservoirView();
|
||||
if (!view) return false;
|
||||
|
||||
RimViewController* vc = view->viewController();
|
||||
if (!vc) return true;
|
||||
|
||||
return (!vc->isRangeFiltersControlled());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSliceRangeFilterFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
QVariant userData = this->userData();
|
||||
|
||||
if (!userData.isNull() && userData.type() == QVariant::List)
|
||||
{
|
||||
RimView* view = RiaApplication::instance()->activeReservoirView();
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = view->rangeFilterCollection();
|
||||
|
||||
RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec(rangeFilterCollection);
|
||||
|
||||
QVariantList list = userData.toList();
|
||||
CAF_ASSERT(list.size() == 2);
|
||||
|
||||
int direction = list[0].toInt();
|
||||
int sliceStart = list[1].toInt();
|
||||
|
||||
if (direction == 0)
|
||||
{
|
||||
filterExec->m_iSlice = true;
|
||||
filterExec->m_iSliceStart = sliceStart;
|
||||
}
|
||||
else if (direction == 1)
|
||||
{
|
||||
filterExec->m_jSlice = true;
|
||||
filterExec->m_jSliceStart = sliceStart;
|
||||
}
|
||||
else if (direction == 2)
|
||||
{
|
||||
filterExec->m_kSlice = true;
|
||||
filterExec->m_kSliceStart = sliceStart;
|
||||
}
|
||||
|
||||
caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
|
||||
view->setSurfaceDrawstyle();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSliceRangeFilterFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setIcon(QIcon(":/CellFilter_Range.png"));
|
||||
}
|
34
ApplicationCode/Commands/RicNewSliceRangeFilterFeature.h
Normal file
34
ApplicationCode/Commands/RicNewSliceRangeFilterFeature.h
Normal file
@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewSliceRangeFilterFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
@ -18,16 +18,19 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicRangeFilterFeatureImpl.h"
|
||||
|
||||
#include "RicRangeFilterNewExec.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimView.h"
|
||||
#include "RimViewController.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <vector>
|
||||
#include "RimView.h"
|
||||
#include "RimViewController.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -66,7 +69,7 @@ RicRangeFilterNewExec* RicRangeFilterFeatureImpl::createRangeFilterExecCommand()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCellRangeFilterCollection* RicRangeFilterFeatureImpl::findRangeFilterCollection()
|
||||
{
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = NULL;
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = nullptr;
|
||||
|
||||
std::vector<RimCellRangeFilter*> selectedRangeFilter;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedRangeFilter);
|
||||
@ -83,10 +86,13 @@ RimCellRangeFilterCollection* RicRangeFilterFeatureImpl::findRangeFilterCollecti
|
||||
selectedRangeFilter[0]->firstAncestorOrThisOfType(rangeFilterCollection);
|
||||
}
|
||||
|
||||
assert(rangeFilterCollection);
|
||||
RimView* view = RiaApplication::instance()->activeReservoirView();
|
||||
if (view)
|
||||
{
|
||||
rangeFilterCollection = view->rangeFilterCollection();
|
||||
}
|
||||
|
||||
// TODO : When a menu is created in the 3D view, add code to find collection based on a RimView
|
||||
// See RiuViewerCommands
|
||||
assert(rangeFilterCollection);
|
||||
|
||||
return rangeFilterCollection;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "RicEclipsePropertyFilterNewExec.h"
|
||||
#include "RicGeoMechPropertyFilterNewExec.h"
|
||||
#include "RicRangeFilterNewExec.h"
|
||||
#include "RicViewerEventInterface.h"
|
||||
#include "WellPathCommands/RicIntersectionViewerEventHandler.h"
|
||||
#include "WellPathCommands/RicWellPathViewerEventHandler.h"
|
||||
@ -144,13 +143,14 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
int winPosY = event->y();
|
||||
|
||||
QMenu menu;
|
||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||
|
||||
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
|
||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
|
||||
cvf::Part* firstHitPart = NULL;
|
||||
cvf::Part* nncFirstHitPart = NULL;
|
||||
cvf::Part* firstHitPart = nullptr;
|
||||
cvf::Part* nncFirstHitPart = nullptr;
|
||||
|
||||
m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED;
|
||||
|
||||
@ -210,15 +210,29 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
|
||||
// IJK -slice commands
|
||||
|
||||
RimViewController* viewController = NULL;
|
||||
RimViewController* viewController = nullptr;
|
||||
if (m_reservoirView) viewController = m_reservoirView->viewController();
|
||||
|
||||
if (!viewController || !viewController->isRangeFiltersControlled())
|
||||
{
|
||||
menu.addAction(QIcon(":/CellFilter_Range.png"), QString("I-slice range filter"), this, SLOT(slotRangeFilterI()));
|
||||
menu.addAction(QIcon(":/CellFilter_Range.png"), QString("J-slice range filter"), this, SLOT(slotRangeFilterJ()));
|
||||
menu.addAction(QIcon(":/CellFilter_Range.png"), QString("K-slice range filter"), this, SLOT(slotRangeFilterK()));
|
||||
size_t i, j, k;
|
||||
ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k);
|
||||
|
||||
QVariantList iSliceList;
|
||||
iSliceList.push_back(0);
|
||||
iSliceList.push_back(CVF_MAX(static_cast<int>(i + 1), 1));
|
||||
|
||||
QVariantList jSliceList;
|
||||
jSliceList.push_back(1);
|
||||
jSliceList.push_back(CVF_MAX(static_cast<int>(j + 1), 1));
|
||||
|
||||
QVariantList kSliceList;
|
||||
kSliceList.push_back(2);
|
||||
kSliceList.push_back(CVF_MAX(static_cast<int>(k + 1), 1));
|
||||
|
||||
menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "I-slice Range Filter", iSliceList);
|
||||
menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "J-slice Range Filter", jSliceList);
|
||||
menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "K-slice Range Filter", kSliceList);
|
||||
}
|
||||
|
||||
if (menu.actions().size() > 0) menu.addSeparator();
|
||||
@ -238,7 +252,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
RimEclipseCellColors* cellColors = eclipseView->cellResult().p();
|
||||
if (cellColors)
|
||||
{
|
||||
QAction* propertyAction = new QAction(QIcon(":/CellFilter_Values.png"), QString("Add property filter"), this);
|
||||
QAction* propertyAction = new QAction(QIcon(":/CellFilter_Values.png"), QString("Add Property Filter"), this);
|
||||
connect(propertyAction, SIGNAL(triggered()), SLOT(slotAddEclipsePropertyFilter()));
|
||||
|
||||
bool isPerCellFaceResult = RiaDefines::isPerCellFaceResult(cellColors->resultVariable());
|
||||
@ -272,14 +286,13 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
{
|
||||
if (!viewController || !viewController->isPropertyFilterOveridden())
|
||||
{
|
||||
menu.addAction(QIcon(":/CellFilter_Values.png"), QString("Add property filter"), this, SLOT(slotAddGeoMechPropertyFilter()));
|
||||
menu.addAction(QIcon(":/CellFilter_Values.png"), QString("Add Property Filter"), this, SLOT(slotAddGeoMechPropertyFilter()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||
|
||||
// Well log curve creation commands
|
||||
if (firstHitPart && firstHitPart->sourceInfo())
|
||||
@ -371,64 +384,6 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
RiuSelectionManager::instance()->deleteAllItems(RiuSelectionManager::RUI_TEMPORARY);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Todo: Move this to a command instead
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::slotRangeFilterI()
|
||||
{
|
||||
createSliceRangeFilter(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::slotRangeFilterJ()
|
||||
{
|
||||
createSliceRangeFilter(1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::slotRangeFilterK()
|
||||
{
|
||||
createSliceRangeFilter(2);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::createSliceRangeFilter(int ijOrk)
|
||||
{
|
||||
RimView* eclipseView = m_reservoirView.p();
|
||||
if (!eclipseView) return;
|
||||
|
||||
size_t i, j, k;
|
||||
ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k);
|
||||
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = eclipseView->rangeFilterCollection();
|
||||
|
||||
RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec(rangeFilterCollection);
|
||||
|
||||
if (ijOrk == 0){
|
||||
filterExec->m_iSlice = true;
|
||||
filterExec->m_iSliceStart = CVF_MAX(static_cast<int>(i + 1), 1);
|
||||
}
|
||||
else if (ijOrk == 1){
|
||||
filterExec->m_jSlice = true;
|
||||
filterExec->m_jSliceStart = CVF_MAX(static_cast<int>(j + 1), 1);
|
||||
|
||||
}
|
||||
else if (ijOrk == 2){
|
||||
filterExec->m_kSlice = true;
|
||||
filterExec->m_kSliceStart = CVF_MAX(static_cast<int>(k + 1), 1);
|
||||
}
|
||||
|
||||
caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
|
||||
|
||||
eclipseView->setSurfaceDrawstyle();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -519,10 +474,10 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
||||
|
||||
// Extract all the above information from the pick
|
||||
{
|
||||
cvf::Part* firstHitPart = NULL;
|
||||
cvf::Part* firstHitPart = nullptr;
|
||||
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
|
||||
|
||||
cvf::Part* firstNncHitPart = NULL;
|
||||
cvf::Part* firstNncHitPart = nullptr;
|
||||
uint nncPartTriangleIndex = cvf::UNDEFINED_UINT;
|
||||
|
||||
cvf::HitItemCollection hitItems;
|
||||
@ -633,7 +588,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
||||
curveColor = colorTable.cycledColor3f(0);
|
||||
}
|
||||
|
||||
RiuSelectionItem* selItem = NULL;
|
||||
RiuSelectionItem* selItem = nullptr;
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
if (eclipseView)
|
||||
@ -750,7 +705,7 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi
|
||||
}
|
||||
}
|
||||
|
||||
const cvf::HitItem* firstNonNncHitItem = NULL;
|
||||
const cvf::HitItem* firstNonNncHitItem = nullptr;
|
||||
cvf::Vec3d firstItemIntersectionPoint = hitItems.item(0)->intersectionPoint();
|
||||
|
||||
// Check if we have a close hit item with NNC data
|
||||
@ -888,7 +843,7 @@ bool RiuViewerCommands::handleOverlayItemPicking(int winPosX, int winPosY)
|
||||
|
||||
if (pickedOverlayItem)
|
||||
{
|
||||
caf::PdmObject* objToSelect = NULL;
|
||||
caf::PdmObject* objToSelect = nullptr;
|
||||
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
if (eclipseView)
|
||||
|
@ -62,9 +62,6 @@ public:
|
||||
caf::PdmObject* currentPickedObject() const;
|
||||
|
||||
private slots:
|
||||
void slotRangeFilterI();
|
||||
void slotRangeFilterJ();
|
||||
void slotRangeFilterK();
|
||||
void slotHideFault();
|
||||
void slotAddEclipsePropertyFilter();
|
||||
void slotAddGeoMechPropertyFilter();
|
||||
@ -75,7 +72,6 @@ private:
|
||||
void findCellAndGridIndex(const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex);
|
||||
|
||||
void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k);
|
||||
void createSliceRangeFilter(int ijOrk);
|
||||
void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit);
|
||||
|
||||
bool handleOverlayItemPicking(int winPosX, int winPosY);
|
||||
|
Loading…
Reference in New Issue
Block a user