Added command exec for "delete property filter"

This commit is contained in:
Pål Hagen 2015-08-10 14:33:43 +02:00
parent 9ab60b1477
commit 94375267bd
4 changed files with 142 additions and 1 deletions

View File

@ -14,6 +14,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipseCasePaste.h
${CEE_CURRENT_LIST_DIR}RicEclipseCellResultSave.h
${CEE_CURRENT_LIST_DIR}RicEclipseFaultResultSave.h
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterDelete.h
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterDeleteExec.h
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsert.h
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNew.h
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.h
@ -45,6 +46,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipseCasePaste.cpp
${CEE_CURRENT_LIST_DIR}RicEclipseCellResultSave.cpp
${CEE_CURRENT_LIST_DIR}RicEclipseFaultResultSave.cpp
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterDelete.cpp
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterDeleteExec.cpp
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsert.cpp
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNew.cpp
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.cpp

View File

@ -19,9 +19,11 @@
#include "RicEclipsePropertyFilterDelete.h"
#include "RicEclipsePropertyFilterDeleteExec.h"
#include "RimEclipsePropertyFilter.h"
#include "cafSelectionManager.h"
#include "cafCmdExecCommandManager.h"
#include <QAction>
@ -45,7 +47,14 @@ bool RicEclipsePropertyFilterDelete::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicEclipsePropertyFilterDelete::onActionTriggered(bool isChecked)
{
// TODO
std::vector<RimEclipsePropertyFilter*> selectedPropertyFilter;
caf::SelectionManager::instance()->objectsByType(&selectedPropertyFilter);
if (selectedPropertyFilter.size() == 1)
{
RicEclipsePropertyFilterDeleteExec* filterExec = new RicEclipsePropertyFilterDeleteExec(selectedPropertyFilter[0]);
caf::CmdExecCommandManager::instance()->processExecuteCommand(filterExec);
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicEclipsePropertyFilterDeleteExec.h"
#include "RimEclipsePropertyFilter.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseView.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicEclipsePropertyFilterDeleteExec::RicEclipsePropertyFilterDeleteExec(RimEclipsePropertyFilter* propertyFilter)
: CmdExecuteCommand(NULL)
{
CVF_ASSERT(propertyFilter);
m_propertyFilter = propertyFilter;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicEclipsePropertyFilterDeleteExec::~RicEclipsePropertyFilterDeleteExec()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicEclipsePropertyFilterDeleteExec::name()
{
return "Delete Property Filter";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipsePropertyFilterDeleteExec::redo()
{
RimEclipsePropertyFilterCollection* propertyFilterCollection = m_propertyFilter->parentContainer();
CVF_ASSERT(propertyFilterCollection);
bool wasFilterActive = m_propertyFilter->isActive();
bool wasSomeFilterActive = propertyFilterCollection->hasActiveFilters();
propertyFilterCollection->remove(m_propertyFilter);
delete m_propertyFilter;
if (wasFilterActive)
{
propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED);
}
if (wasSomeFilterActive)
{
propertyFilterCollection->reservoirView()->createDisplayModelAndRedraw();
}
caf::PdmUiFieldHandle::updateConnectedUiEditors(propertyFilterCollection->parentField());
caf::PdmUiFieldHandle::updateConnectedUiEditors(&propertyFilterCollection->propertyFilters);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipsePropertyFilterDeleteExec::undo()
{
// TODO
CVF_ASSERT(0);
}

View File

@ -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 RicEclipsePropertyFilterDeleteExec : public caf::CmdExecuteCommand
{
public:
RicEclipsePropertyFilterDeleteExec(RimEclipsePropertyFilter* propertyFilter);
virtual ~RicEclipsePropertyFilterDeleteExec();
virtual QString name();
virtual void redo();
virtual void undo();
private:
caf::PdmPointer<RimEclipsePropertyFilter> m_propertyFilter;
};