mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
#14772 Python: Add View.clone as object method and forward cloneView to it
Rim3dView_clone copies an Eclipse or GeoMech view into the same case and returns the new view. RicfCloneView forwards to it. Add a project-wide RicfForwarding::findView(viewId) helper. The hand-written Python View.clone() wrapper is removed since the generated method has the same name and signature.
This commit is contained in:
1 parent
bdef98203b
commit
e87e372c7b
7 files changed
+121
-59
No files matched your search
@@ -24,11 +24,16 @@
|
||||
#include "Polygons/RimPolygon.h"
|
||||
#include "Polygons/RimPolygonInViewCollection.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimGridView.h"
|
||||
#include "Surfaces/RimSurface.h"
|
||||
#include "Surfaces/RimSurfaceInViewCollection.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
@@ -204,3 +209,58 @@ std::expected<caf::PdmObjectHandle*, QString> RimcGridView_setSurfaceProperty::e
|
||||
gridView->scheduleCreateDisplayModelAndRedraw();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( Rim3dView, Rim3dView_clone, "clone" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Rim3dView_clone::Rim3dView_clone( caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectCreationMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Clone View", "", "", "Clone the view and add the copy to the same case" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::expected<caf::PdmObjectHandle*, QString> Rim3dView_clone::execute()
|
||||
{
|
||||
auto* view = self<Rim3dView>();
|
||||
if ( !view ) return std::unexpected( "No view is available." );
|
||||
|
||||
Rim3dView* newView = nullptr;
|
||||
if ( auto* eclipseView = dynamic_cast<RimEclipseView*>( view ) )
|
||||
{
|
||||
RimEclipseCase* eclipseCase = eclipseView->eclipseCase();
|
||||
if ( !eclipseCase ) return std::unexpected( "The view has no case." );
|
||||
|
||||
RimEclipseView* newEclipseView = eclipseCase->createCopyAndAddView( eclipseView );
|
||||
newEclipseView->loadDataAndUpdate();
|
||||
eclipseCase->updateConnectedEditors();
|
||||
newView = newEclipseView;
|
||||
}
|
||||
else if ( auto* geoMechView = dynamic_cast<RimGeoMechView*>( view ) )
|
||||
{
|
||||
RimGeoMechCase* geoMechCase = geoMechView->geoMechCase();
|
||||
if ( !geoMechCase ) return std::unexpected( "The view has no case." );
|
||||
|
||||
RimGeoMechView* newGeoMechView = geoMechCase->createCopyAndAddView( geoMechView );
|
||||
newGeoMechView->loadDataAndUpdate();
|
||||
geoMechCase->updateConnectedEditors();
|
||||
newView = newGeoMechView;
|
||||
}
|
||||
|
||||
if ( !newView ) return std::unexpected( QString( "Could not clone view '%1'" ).arg( view->name() ) );
|
||||
|
||||
Riu3DMainWindowTools::setExpanded( newView );
|
||||
return newView;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString Rim3dView_clone::classKeywordReturnedType() const
|
||||
{
|
||||
return Rim3dView::classKeywordStatic();
|
||||
}
|
||||
@@ -95,3 +95,17 @@ private:
|
||||
caf::PdmPtrField<RimSurface*> m_surface;
|
||||
caf::PdmField<QString> m_propertyName;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
/// Clone the view and add the copy to the same case. Supports Eclipse and GeoMech views.
|
||||
//==================================================================================================
|
||||
class Rim3dView_clone : public caf::PdmObjectCreationMethod
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
Rim3dView_clone( caf::PdmObjectHandle* self );
|
||||
|
||||
std::expected<caf::PdmObjectHandle*, QString> execute() override;
|
||||
QString classKeywordReturnedType() const override;
|
||||
};
|
||||
Reference in new issue
Block a user