mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactored property filter commands, moved code to helper class
This commit is contained in:
parent
b36ce378d7
commit
c4ab24db9c
@ -20,9 +20,10 @@
|
||||
#include "RicEclipsePropertyFilterDelete.h"
|
||||
|
||||
#include "RicEclipsePropertyFilterDeleteExec.h"
|
||||
#include "RicEclipsePropertyFilter.h"
|
||||
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
|
||||
#include <QAction>
|
||||
@ -36,10 +37,8 @@ CAF_CMD_SOURCE_INIT(RicEclipsePropertyFilterDelete, "RicEclipsePropertyFilterDel
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEclipsePropertyFilterDelete::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimEclipsePropertyFilter*> selectedPropertyFilter;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedPropertyFilter);
|
||||
|
||||
return selectedPropertyFilter.size() == 1;
|
||||
std::vector<RimEclipsePropertyFilter*> propertyFilters = RicEclipsePropertyFilter::selectedPropertyFilters();
|
||||
return propertyFilters.size() == 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -47,12 +46,10 @@ bool RicEclipsePropertyFilterDelete::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipsePropertyFilterDelete::onActionTriggered(bool isChecked)
|
||||
{
|
||||
std::vector<RimEclipsePropertyFilter*> selectedPropertyFilter;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedPropertyFilter);
|
||||
|
||||
if (selectedPropertyFilter.size() == 1)
|
||||
std::vector<RimEclipsePropertyFilter*> propertyFilters = RicEclipsePropertyFilter::selectedPropertyFilters();
|
||||
if (propertyFilters.size() == 1)
|
||||
{
|
||||
RicEclipsePropertyFilterDeleteExec* filterExec = new RicEclipsePropertyFilterDeleteExec(selectedPropertyFilter[0]);
|
||||
RicEclipsePropertyFilterDeleteExec* filterExec = new RicEclipsePropertyFilterDeleteExec(propertyFilters[0]);
|
||||
caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,12 @@
|
||||
|
||||
#include "RicEclipsePropertyFilterInsert.h"
|
||||
|
||||
#include "RicEclipsePropertyFilterInsertExec.h"
|
||||
#include "RicEclipsePropertyFilter.h"
|
||||
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
@ -34,10 +37,8 @@ CAF_CMD_SOURCE_INIT(RicEclipsePropertyFilterInsert, "RicEclipsePropertyFilterIns
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEclipsePropertyFilterInsert::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimEclipsePropertyFilter*> selectedPropertyFilter;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedPropertyFilter);
|
||||
|
||||
return selectedPropertyFilter.size() == 1;
|
||||
std::vector<RimEclipsePropertyFilter*> propertyFilters = RicEclipsePropertyFilter::selectedPropertyFilters();
|
||||
return propertyFilters.size() == 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -45,7 +46,12 @@ bool RicEclipsePropertyFilterInsert::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipsePropertyFilterInsert::onActionTriggered(bool isChecked)
|
||||
{
|
||||
// TODO
|
||||
std::vector<RimEclipsePropertyFilter*> propertyFilters = RicEclipsePropertyFilter::selectedPropertyFilters();
|
||||
if (propertyFilters.size() == 1)
|
||||
{
|
||||
RicEclipsePropertyFilterInsertExec* filterExec = new RicEclipsePropertyFilterInsertExec(propertyFilters[0]);
|
||||
caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -20,10 +20,11 @@
|
||||
#include "RicEclipsePropertyFilterNew.h"
|
||||
|
||||
#include "RicEclipsePropertyFilterNewExec.h"
|
||||
#include "RicEclipsePropertyFilter.h"
|
||||
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
#include "RimEclipsePropertyFilterCollection.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
|
||||
#include <QAction>
|
||||
@ -35,20 +36,8 @@ CAF_CMD_SOURCE_INIT(RicEclipsePropertyFilterNew, "RicEclipsePropertyFilterNew");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEclipsePropertyFilterNew::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimEclipsePropertyFilter*> selectedPropertyFilter;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedPropertyFilter);
|
||||
|
||||
std::vector<RimEclipsePropertyFilterCollection*> selectedPropertyFilterCollection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedPropertyFilterCollection);
|
||||
|
||||
if (selectedPropertyFilter.size() > 0 || selectedPropertyFilterCollection.size() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
std::vector<RimEclipsePropertyFilterCollection*> filterCollections = RicEclipsePropertyFilter::selectedPropertyFilterCollections();
|
||||
return filterCollections.size() == 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -56,25 +45,10 @@ bool RicEclipsePropertyFilterNew::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipsePropertyFilterNew::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimEclipsePropertyFilterCollection* propertyFilterCollection = NULL;
|
||||
|
||||
std::vector<RimEclipsePropertyFilter*> selectedPropertyFilter;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedPropertyFilter);
|
||||
|
||||
std::vector<RimEclipsePropertyFilterCollection*> selectedPropertyFilterCollection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedPropertyFilterCollection);
|
||||
if (selectedPropertyFilterCollection.size() == 1)
|
||||
std::vector<RimEclipsePropertyFilterCollection*> filterCollections = RicEclipsePropertyFilter::selectedPropertyFilterCollections();
|
||||
if (filterCollections.size() == 1)
|
||||
{
|
||||
propertyFilterCollection = selectedPropertyFilterCollection[0];
|
||||
}
|
||||
else if (selectedPropertyFilter.size() > 0)
|
||||
{
|
||||
propertyFilterCollection = dynamic_cast<RimEclipsePropertyFilterCollection*>(selectedPropertyFilter[0]->owner());
|
||||
}
|
||||
|
||||
if (propertyFilterCollection)
|
||||
{
|
||||
RicEclipsePropertyFilterNewExec* filterExec = new RicEclipsePropertyFilterNewExec(propertyFilterCollection);
|
||||
RicEclipsePropertyFilterNewExec* filterExec = new RicEclipsePropertyFilterNewExec(filterCollections[0]);
|
||||
caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,10 @@
|
||||
|
||||
#include "RicEclipsePropertyFilterNewExec.h"
|
||||
|
||||
#include "RicEclipsePropertyFilter.h"
|
||||
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
#include "RimEclipsePropertyFilterCollection.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -56,25 +55,7 @@ QString RicEclipsePropertyFilterNewExec::name()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipsePropertyFilterNewExec::redo()
|
||||
{
|
||||
RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter();
|
||||
propertyFilter->setParentContainer(m_propertyFilterCollection);
|
||||
|
||||
RimEclipseView* reservoirView = m_propertyFilterCollection->reservoirView();
|
||||
assert(reservoirView);
|
||||
|
||||
propertyFilter->resultDefinition->setReservoirView(reservoirView);
|
||||
propertyFilter->resultDefinition->setResultVariable(reservoirView->cellResult->resultVariable());
|
||||
propertyFilter->resultDefinition->setPorosityModel(reservoirView->cellResult->porosityModel());
|
||||
propertyFilter->resultDefinition->setResultType(reservoirView->cellResult->resultType());
|
||||
propertyFilter->resultDefinition->loadResult();
|
||||
propertyFilter->setToDefaultValues();
|
||||
propertyFilter->updateFilterName();
|
||||
|
||||
m_propertyFilterCollection->propertyFilters.push_back(propertyFilter);
|
||||
m_propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED);
|
||||
|
||||
caf::PdmUiFieldHandle::updateConnectedUiEditors(m_propertyFilterCollection->parentField());
|
||||
caf::PdmUiFieldHandle::updateConnectedUiEditors(&m_propertyFilterCollection->propertyFilters);
|
||||
RicEclipsePropertyFilter::addPropertyFilter(m_propertyFilterCollection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user