mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
#14772 Python: Add Case.create_view as object method and forward createView to it
RimCase_createView creates a 3D view in an Eclipse or GeoMech case and returns it. RicfCreateView forwards to it and wraps the view id in the legacy createViewResult. The hand-written Python create_view() wrapper is removed since the generated method has the same name and signature.
This commit is contained in:
1 parent
3eb63c0b8e
commit
bdef98203b
4 files changed
+89
-61
No files matched your search
@@ -21,9 +21,16 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaProjectModifier.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
|
||||
#include <QDir>
|
||||
@@ -104,3 +111,52 @@ std::expected<caf::PdmObjectHandle*, QString> RimCase_replaceGrid::execute()
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimCase, RimCase_createView, "createView" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCase_createView::RimCase_createView( caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectCreationMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Create View", "", "", "Create a new 3D view in the case" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::expected<caf::PdmObjectHandle*, QString> RimCase_createView::execute()
|
||||
{
|
||||
auto* rimCase = self<RimCase>();
|
||||
if ( !rimCase ) return std::unexpected( "No case is available." );
|
||||
|
||||
Rim3dView* view = nullptr;
|
||||
if ( auto* eclipseCase = dynamic_cast<RimEclipseCase*>( rimCase ) )
|
||||
{
|
||||
RimEclipseView* eclipseView = eclipseCase->createAndAddReservoirView();
|
||||
eclipseView->loadDataAndUpdate();
|
||||
eclipseCase->updateConnectedEditors();
|
||||
view = eclipseView;
|
||||
}
|
||||
else if ( auto* geoMechCase = dynamic_cast<RimGeoMechCase*>( rimCase ) )
|
||||
{
|
||||
RimGeoMechView* geoMechView = geoMechCase->createAndAddReservoirView();
|
||||
geoMechView->loadDataAndUpdate();
|
||||
geoMechCase->updateConnectedEditors();
|
||||
view = geoMechView;
|
||||
}
|
||||
|
||||
if ( !view ) return std::unexpected( QString( "Could not create view for case '%1'" ).arg( rimCase->caseUserDescription() ) );
|
||||
|
||||
Riu3DMainWindowTools::setExpanded( view );
|
||||
return view;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCase_createView::classKeywordReturnedType() const
|
||||
{
|
||||
return Rim3dView::classKeywordStatic();
|
||||
}
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
class Rim3dView;
|
||||
|
||||
//==================================================================================================
|
||||
/// Replace the grid file of a case (Eclipse result case or GeoMech case) and reload the project.
|
||||
///
|
||||
@@ -47,3 +49,17 @@ private:
|
||||
caf::PdmField<QString> m_newGridFile;
|
||||
caf::PdmField<QString> m_projectFile;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
/// Create a new 3D view in the case. Supports Eclipse cases and GeoMech cases.
|
||||
//==================================================================================================
|
||||
class RimCase_createView : public caf::PdmObjectCreationMethod
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimCase_createView( caf::PdmObjectHandle* self );
|
||||
|
||||
std::expected<caf::PdmObjectHandle*, QString> execute() override;
|
||||
QString classKeywordReturnedType() const override;
|
||||
};
|
||||
Reference in new issue
Block a user