mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add copy/paste of cell filters
This commit is contained in:
@@ -6,6 +6,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseViewsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteGeoMechViewsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteIntersectionsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteCellFiltersFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -16,6 +17,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseViewsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteGeoMechViewsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteIntersectionsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteCellFiltersFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "RicCopyReferencesToClipboardFeature.h"
|
||||
|
||||
#include "RimBoxIntersection.h"
|
||||
#include "RimCellFilter.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
@@ -136,6 +137,7 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported( caf::PdmObjec
|
||||
if ( dynamic_cast<RimGridCrossPlotDataSet*>( pdmObject ) ) return true;
|
||||
if ( dynamic_cast<RimModeledWellPath*>( pdmObject ) ) return true;
|
||||
if ( dynamic_cast<RimSummaryMultiPlot*>( pdmObject ) ) return true;
|
||||
if ( dynamic_cast<RimCellFilter*>( pdmObject ) ) return true;
|
||||
|
||||
// Copy support based combined logic
|
||||
RimWellAllocationPlot* wellAllocPlot = pdmObject->firstAncestorOrThisOfType<RimWellAllocationPlot>();
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023- Equinor 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 "RicPasteCellFiltersFeature.h"
|
||||
|
||||
#include "RicPasteFeatureImpl.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimCellFilter.h"
|
||||
#include "RimCellFilterCollection.h"
|
||||
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicPasteCellFiltersFeature, "RicPasteCellFiltersFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPasteCellFiltersFeature::isCommandEnabled() const
|
||||
{
|
||||
caf::PdmObjectGroup objectGroup;
|
||||
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
|
||||
|
||||
std::vector<caf::PdmPointer<RimCellFilter>> typedObjects;
|
||||
objectGroup.objectsByType( &typedObjects );
|
||||
if ( typedObjects.empty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( dynamic_cast<RimCellFilterCollection*>( caf::SelectionManager::instance()->selectedItem() ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteCellFiltersFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
auto cellFilterCollection = dynamic_cast<RimCellFilterCollection*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( !cellFilterCollection ) return;
|
||||
|
||||
auto eclipseCase = cellFilterCollection->firstAncestorOfType<RimCase>();
|
||||
|
||||
caf::PdmObjectGroup objectGroup;
|
||||
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
|
||||
|
||||
for ( auto obj : objectGroup.objects )
|
||||
{
|
||||
auto duplicatedObject =
|
||||
dynamic_cast<RimCellFilter*>( obj->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
|
||||
if ( duplicatedObject )
|
||||
{
|
||||
cellFilterCollection->addFilterAndNotifyChanges( duplicatedObject, eclipseCase );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteCellFiltersFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Paste Filter" );
|
||||
|
||||
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteCellFiltersFeature::pasteGeometryCellFilters( RimCellFilterCollection* cellFilterCollection )
|
||||
{
|
||||
if ( !cellFilterCollection ) return;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023- Equinor 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 RimCellFilterCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPasteCellFiltersFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() const override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
void pasteGeometryCellFilters( RimCellFilterCollection* cellFilterCollection );
|
||||
};
|
||||
@@ -292,6 +292,16 @@ RimUserDefinedIndexFilter* RimCellFilterCollection::addNewUserDefinedIndexFilter
|
||||
return pFilter;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellFilterCollection::addFilterAndNotifyChanges( RimCellFilter* pFilter, RimCase* srcCase )
|
||||
{
|
||||
addFilter( pFilter );
|
||||
pFilter->setCase( srcCase );
|
||||
onFilterUpdated( pFilter );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
RimUserDefinedFilter* addNewUserDefinedFilter( RimCase* srcCase );
|
||||
RimUserDefinedIndexFilter* addNewUserDefinedIndexFilter( RimCase* srcCase, const std::vector<size_t>& defCellIndexes = {} );
|
||||
|
||||
void addFilterAndNotifyChanges( RimCellFilter* pFilter, RimCase* srcCase );
|
||||
void removeFilter( RimCellFilter* filter );
|
||||
void notifyGridReload();
|
||||
|
||||
|
||||
@@ -1034,6 +1034,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
}
|
||||
else if ( dynamic_cast<RimCellFilterCollection*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicPasteCellFiltersFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicNewPolygonFilterFeature";
|
||||
menuBuilder << "RicNewUserDefinedFilterFeature";
|
||||
menuBuilder << "RicNewUserDefinedIndexFilterFeature";
|
||||
|
||||
Reference in New Issue
Block a user