-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
39 changes: 39 additions & 0 deletions
39
ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters