mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added helper class for property filter commands and exec command for insert
This commit is contained in:
parent
319d9a1aa7
commit
b36ce378d7
@ -13,9 +13,11 @@ ${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewView.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCasePaste.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCellResultSave.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseFaultResultSave.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilter.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterDelete.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterDeleteExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsert.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNew.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseViewCopy.h
|
||||
@ -45,9 +47,11 @@ ${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewView.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCasePaste.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCellResultSave.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseFaultResultSave.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilter.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterDelete.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterDeleteExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsert.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNew.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseViewCopy.cpp
|
||||
|
119
ApplicationCode/Commands/RicEclipsePropertyFilter.cpp
Normal file
119
ApplicationCode/Commands/RicEclipsePropertyFilter.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicEclipsePropertyFilter.h"
|
||||
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
#include "RimEclipsePropertyFilterCollection.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimEclipsePropertyFilter*> RicEclipsePropertyFilter::selectedPropertyFilters()
|
||||
{
|
||||
std::vector<RimEclipsePropertyFilter*> propertyFilters;
|
||||
caf::SelectionManager::instance()->objectsByType(&propertyFilters);
|
||||
|
||||
return propertyFilters;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimEclipsePropertyFilterCollection*> RicEclipsePropertyFilter::selectedPropertyFilterCollections()
|
||||
{
|
||||
std::vector<RimEclipsePropertyFilterCollection*> propertyFilterCollections;
|
||||
caf::SelectionManager::instance()->objectsByType(&propertyFilterCollections);
|
||||
|
||||
return propertyFilterCollections;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipsePropertyFilter::addPropertyFilter(RimEclipsePropertyFilterCollection* propertyFilterCollection)
|
||||
{
|
||||
RimEclipsePropertyFilter* propertyFilter = createPropertyFilter(propertyFilterCollection);
|
||||
CVF_ASSERT(propertyFilter);
|
||||
|
||||
propertyFilterCollection->propertyFilters.push_back(propertyFilter);
|
||||
propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED);
|
||||
|
||||
caf::PdmUiFieldHandle::updateConnectedUiEditors(propertyFilterCollection->parentField());
|
||||
caf::PdmUiFieldHandle::updateConnectedUiEditors(&propertyFilterCollection->propertyFilters);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipsePropertyFilter::insertPropertyFilter(RimEclipsePropertyFilterCollection* propertyFilterCollection, size_t index)
|
||||
{
|
||||
RimEclipsePropertyFilter* propertyFilter = createPropertyFilter(propertyFilterCollection);
|
||||
CVF_ASSERT(propertyFilter);
|
||||
|
||||
propertyFilterCollection->propertyFilters.insertAt(index, propertyFilter);
|
||||
propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED);
|
||||
|
||||
caf::PdmUiFieldHandle::updateConnectedUiEditors(propertyFilterCollection->parentField());
|
||||
caf::PdmUiFieldHandle::updateConnectedUiEditors(&propertyFilterCollection->propertyFilters);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipsePropertyFilter* RicEclipsePropertyFilter::createPropertyFilter( RimEclipsePropertyFilterCollection* propertyFilterCollection )
|
||||
{
|
||||
CVF_ASSERT(propertyFilterCollection);
|
||||
|
||||
RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter();
|
||||
propertyFilter->setParentContainer(propertyFilterCollection);
|
||||
|
||||
setDefaults(propertyFilter);
|
||||
|
||||
return propertyFilter;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipsePropertyFilter::setDefaults(RimEclipsePropertyFilter* propertyFilter)
|
||||
{
|
||||
CVF_ASSERT(propertyFilter);
|
||||
|
||||
RimEclipsePropertyFilterCollection* propertyFilterCollection = propertyFilter->parentContainer();
|
||||
CVF_ASSERT(propertyFilterCollection);
|
||||
|
||||
RimEclipseView* reservoirView = propertyFilterCollection->reservoirView();
|
||||
CVF_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();
|
||||
}
|
44
ApplicationCode/Commands/RicEclipsePropertyFilter.h
Normal file
44
ApplicationCode/Commands/RicEclipsePropertyFilter.h
Normal file
@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimEclipsePropertyFilter;
|
||||
class RimEclipsePropertyFilterCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicEclipsePropertyFilter
|
||||
{
|
||||
public:
|
||||
static std::vector<RimEclipsePropertyFilter*> selectedPropertyFilters();
|
||||
static std::vector<RimEclipsePropertyFilterCollection*> selectedPropertyFilterCollections();
|
||||
|
||||
static void addPropertyFilter(RimEclipsePropertyFilterCollection* propertyFilterCollection);
|
||||
static void insertPropertyFilter(RimEclipsePropertyFilterCollection* propertyFilterCollection, size_t index);
|
||||
|
||||
private:
|
||||
static RimEclipsePropertyFilter* createPropertyFilter(RimEclipsePropertyFilterCollection* propertyFilterCollection);
|
||||
static void setDefaults(RimEclipsePropertyFilter* propertyFilter);
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,76 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicEclipsePropertyFilterInsertExec.h"
|
||||
|
||||
|
||||
#include "RicEclipsePropertyFilter.h"
|
||||
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
#include "RimEclipsePropertyFilterCollection.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicEclipsePropertyFilterInsertExec::RicEclipsePropertyFilterInsertExec(RimEclipsePropertyFilter* propertyFilter)
|
||||
: CmdExecuteCommand(NULL)
|
||||
{
|
||||
CVF_ASSERT(propertyFilter);
|
||||
m_propertyFilter = propertyFilter;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicEclipsePropertyFilterInsertExec::~RicEclipsePropertyFilterInsertExec()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicEclipsePropertyFilterInsertExec::name()
|
||||
{
|
||||
return "Delete";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipsePropertyFilterInsertExec::redo()
|
||||
{
|
||||
RimEclipsePropertyFilterCollection* propertyFilterCollection = m_propertyFilter->parentContainer();
|
||||
CVF_ASSERT(propertyFilterCollection);
|
||||
|
||||
size_t index = propertyFilterCollection->propertyFilters.index(m_propertyFilter);
|
||||
CVF_ASSERT(index < propertyFilterCollection->propertyFilters.size());
|
||||
|
||||
RicEclipsePropertyFilter::insertPropertyFilter(propertyFilterCollection, index);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipsePropertyFilterInsertExec::undo()
|
||||
{
|
||||
// TODO
|
||||
CVF_ASSERT(0);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdExecuteCommand.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
class RimEclipsePropertyFilter;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicEclipsePropertyFilterInsertExec : public caf::CmdExecuteCommand
|
||||
{
|
||||
public:
|
||||
RicEclipsePropertyFilterInsertExec(RimEclipsePropertyFilter* propertyFilter);
|
||||
virtual ~RicEclipsePropertyFilterInsertExec();
|
||||
|
||||
virtual QString name();
|
||||
virtual void redo();
|
||||
virtual void undo();
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimEclipsePropertyFilter> m_propertyFilter;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user