Move to use a static registry of scriptable classes

This commit is contained in:
Gaute Lindkvist 2020-02-24 15:42:23 +01:00
parent 50ae160e2d
commit d95f3a349d
34 changed files with 270 additions and 145 deletions

View File

@ -37,6 +37,7 @@
#include "RicfCommandFileExecutor.h"
#include "RicfFieldHandle.h"
#include "RicfMessages.h"
#include "RicfObjectCapability.h"
#include "Rim2dIntersectionViewCollection.h"
#include "RimAnnotationCollection.h"
@ -1708,8 +1709,7 @@ void RiaApplication::generatePythonClasses( const QString& fileName )
{
return;
}
QTextStream out( &pythonFile );
out << "import builtins\n\n";
QTextStream out( &pythonFile );
std::vector<QString> classKeywords = factory->classKeywords();
std::vector<std::shared_ptr<const caf::PdmObject>> dummyObjects;
@ -1718,9 +1718,10 @@ void RiaApplication::generatePythonClasses( const QString& fileName )
auto objectHandle = factory->create( classKeyword );
const caf::PdmObject* object = dynamic_cast<const caf::PdmObject*>( objectHandle );
CAF_ASSERT( object );
if ( object->isScriptable() )
std::shared_ptr<const caf::PdmObject> sharedObject( object );
if ( RicfObjectCapability::isScriptable( sharedObject.get() ) )
{
std::shared_ptr<const caf::PdmObject> sharedObject( object );
dummyObjects.push_back( sharedObject );
}
}
@ -1746,14 +1747,15 @@ void RiaApplication::generatePythonClasses( const QString& fileName )
for ( auto it = classInheritanceStack.begin(); it != classInheritanceStack.end(); ++it )
{
const QString& classKeyword = *it;
const QString& classKeyword = *it;
QString scriptClassComment = RicfObjectCapability::scriptClassComment( classKeyword );
std::map<QString, QString> attributesGenerated;
if ( !scriptClassComment.isEmpty() ) classCommentsGenerated[classKeyword] = scriptClassComment;
if ( classKeyword == object->classKeyword() )
{
if ( !object->uiWhatsThis().isEmpty() ) classCommentsGenerated[classKeyword] = object->uiWhatsThis();
std::vector<caf::PdmFieldHandle*> fields;
object->fields( fields );
for ( auto field : fields )
@ -1768,7 +1770,7 @@ void RiaApplication::generatePythonClasses( const QString& fileName )
QString snake_field_name = RiaTextStringTools::camelToSnakeCase( ricfHandle->fieldName() );
if ( classesGenerated[field->ownerClass()].count( snake_field_name ) ) continue;
QString fieldCode = QString( " self.%1 = None\n" ).arg( snake_field_name );
QString fieldPythonCode = QString( " self.%1 = None\n" ).arg( snake_field_name );
QString comment;
{
@ -1782,7 +1784,7 @@ void RiaApplication::generatePythonClasses( const QString& fileName )
QVariant valueVariant = pdmValueField->toQVariant();
QString dataTypeString = valueVariant.typeName();
classesGenerated[field->ownerClass()][snake_field_name].first = fieldCode;
classesGenerated[field->ownerClass()][snake_field_name].first = fieldPythonCode;
classesGenerated[field->ownerClass()][snake_field_name].second =
QString( "%1 (%2): %3\n" ).arg( snake_field_name ).arg( dataTypeString ).arg( comment );
}
@ -1797,22 +1799,24 @@ void RiaApplication::generatePythonClasses( const QString& fileName )
for ( std::shared_ptr<const caf::PdmObject> object : dummyObjects )
{
const std::list<QString>& classInheritanceStack = object->classInheritanceStack();
std::list<QString> parentClassKeywords;
std::list<QString> scriptSuperClassNames;
for ( auto it = classInheritanceStack.begin(); it != classInheritanceStack.end(); ++it )
{
const QString& classKeyword = *it;
const QString& classKeyword = *it;
QString scriptClassName = RicfObjectCapability::scriptClassNameFromClassKeyword( classKeyword );
if ( scriptClassName.isEmpty() ) scriptClassName = classKeyword;
if ( !classesWritten.count( classKeyword ) )
{
QString classCode;
if ( parentClassKeywords.empty() )
if ( scriptSuperClassNames.empty() )
{
classCode = QString( "class %1:\n" ).arg( classKeyword );
classCode = QString( "class %1:\n" ).arg( scriptClassName );
}
else
{
classCode = QString( "class %1(%2):\n" ).arg( classKeyword ).arg( parentClassKeywords.back() );
classCode = QString( "class %1(%2):\n" ).arg( scriptClassName ).arg( scriptSuperClassNames.back() );
}
if ( !classCommentsGenerated[classKeyword].isEmpty() || !classesGenerated[classKeyword].empty() )
@ -1834,12 +1838,12 @@ void RiaApplication::generatePythonClasses( const QString& fileName )
QString( " __custom_init__ = None #: Assign a custom init routine to be run at __init__\n\n" );
classCode += QString( " def __init__(self, pb2_object=None, channel=None):\n" );
if ( !parentClassKeywords.empty() )
if ( !scriptSuperClassNames.empty() )
{
// Parent constructor
classCode +=
QString( " %1.__init__(self, pb2_object, channel)\n" ).arg( parentClassKeywords.back() );
QString( " %1.__init__(self, pb2_object, channel)\n" ).arg( scriptSuperClassNames.back() );
// Own attributes. This initializes a lot of attributes to None.
// This means it has to be done before we set any values.
@ -1849,14 +1853,14 @@ void RiaApplication::generatePythonClasses( const QString& fileName )
}
}
classCode += QString( " if %1.__custom_init__ is not None:\n" ).arg( classKeyword );
classCode += QString( " if %1.__custom_init__ is not None:\n" ).arg( scriptClassName );
classCode += QString( " %1.__custom_init__(self, pb2_object=pb2_object, channel=channel)\n" )
.arg( classKeyword );
.arg( scriptClassName );
out << classCode << "\n";
classesWritten.insert( classKeyword );
}
parentClassKeywords.push_back( classKeyword );
scriptSuperClassNames.push_back( scriptClassName );
}
}
}

View File

@ -77,6 +77,14 @@ public:
whatsThis ); \
AddRicfCapabilityToField( field, scriptKeyword )
#define RICF_InitObject( uiName, iconResourceName, toolTip, whatsThis ) \
CAF_PDM_InitObject( uiName, iconResourceName, toolTip, whatsThis ); \
RicfObjectCapability::addCapabilityToObject( this, classKeyword(), whatsThis );
#define RICF_InitObjectWithScriptNameAndComment( uiName, iconResourceName, toolTip, whatsThis, scriptClassName, scriptComment ) \
CAF_PDM_InitObject( uiName, iconResourceName, toolTip, whatsThis ); \
RicfObjectCapability::addCapabilityToObject( this, scriptClassName, scriptComment );
#define RICF_HEADER_INIT \
CAF_CMD_HEADER_INIT; \
CAF_PDM_HEADER_INIT

View File

@ -19,16 +19,23 @@
#include "RicfObjectCapability.h"
#include "RicfFieldHandle.h"
#include "RicfMessages.h"
#include "cafPdmObject.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmXmlFieldHandle.h"
#include <QTextStream>
std::map<QString, QString> RicfObjectCapability::s_classKeywordToScriptClassName;
std::map<QString, QString> RicfObjectCapability::s_scriptClassNameToClassKeyword;
std::map<QString, QString> RicfObjectCapability::s_scriptClassComments;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfObjectCapability::RicfObjectCapability( caf::PdmObjectHandle* owner, bool giveOwnership )
: m_owner( owner )
{
m_owner = owner;
m_owner->addCapability( this, giveOwnership );
}
@ -216,3 +223,76 @@ void RicfObjectCapability::writeFields( QTextStream& outputStream ) const
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfObjectCapability::registerScriptClassNameAndComment( const QString& classKeyword,
const QString& scriptClassName,
const QString& scriptClassComment )
{
s_classKeywordToScriptClassName[classKeyword] = scriptClassName;
s_scriptClassNameToClassKeyword[scriptClassName] = classKeyword;
s_scriptClassComments[classKeyword] = scriptClassComment;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicfObjectCapability::scriptClassNameFromClassKeyword( const QString& classKeyword )
{
auto it = s_classKeywordToScriptClassName.find( classKeyword );
if ( it != s_classKeywordToScriptClassName.end() )
{
return it->second;
}
return classKeyword;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicfObjectCapability::classKeywordFromScriptClassName( const QString& scriptClassName )
{
auto it = s_scriptClassNameToClassKeyword.find( scriptClassName );
if ( it != s_scriptClassNameToClassKeyword.end() )
{
return it->second;
}
return scriptClassName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicfObjectCapability::scriptClassComment( const QString& classKeyword )
{
auto it = s_scriptClassComments.find( classKeyword );
if ( it != s_scriptClassComments.end() )
{
return it->second;
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicfObjectCapability::isScriptable( const caf::PdmObject* object )
{
return s_classKeywordToScriptClassName.find( object->classKeyword() ) != s_classKeywordToScriptClassName.end();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfObjectCapability::addCapabilityToObject( caf::PdmObject* object,
const QString& scriptClassName,
const QString& scriptClassComment )
{
if ( !object->capability<RicfObjectCapability>() )
{
new RicfObjectCapability( object, true );
}
RicfObjectCapability::registerScriptClassNameAndComment( object->classKeyword(), scriptClassName, scriptClassComment );
}

View File

@ -19,8 +19,13 @@
#pragma once
#include "cafPdmObjectCapability.h"
#include <QString>
#include <map>
namespace caf
{
class PdmObject;
class PdmObjectHandle;
class PdmObjectFactory;
} // namespace caf
@ -43,6 +48,21 @@ public:
void readFields( QTextStream& inputStream, caf::PdmObjectFactory* objectFactory, RicfMessages* errorMessageContainer );
void writeFields( QTextStream& outputStream ) const;
static void registerScriptClassNameAndComment( const QString& classKeyword,
const QString& scriptClassName,
const QString& scriptClassComment );
static QString scriptClassNameFromClassKeyword( const QString& classKeyword );
static QString classKeywordFromScriptClassName( const QString& scriptClassName );
static QString scriptClassComment( const QString& classKeyword );
static bool isScriptable( const caf::PdmObject* object );
static void
addCapabilityToObject( caf::PdmObject* object, const QString& scriptClassName, const QString& scriptClassComment );
private:
caf::PdmObjectHandle* m_owner;
static std::map<QString, QString> s_classKeywordToScriptClassName;
static std::map<QString, QString> s_scriptClassNameToClassKeyword;
static std::map<QString, QString> s_scriptClassComments;
};

View File

@ -41,7 +41,6 @@ RICF_SOURCE_INIT( RicNewMultiPlotFeature, "RicNewMultiPlotFeature", "createMulti
//--------------------------------------------------------------------------------------------------
RicNewMultiPlotFeature::RicNewMultiPlotFeature()
{
CAF_PDM_InitObject( "Create Multi Plot", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_plots, "plots", "Plots", "", "", "" );
}

View File

@ -78,6 +78,7 @@ def copy_from(self, object):
for attribute in dir(object):
if not attribute.startswith('__'):
value = getattr(object, attribute)
# This is crucial to avoid overwriting methods
if not callable(value):
setattr(self, attribute, value)

View File

@ -90,12 +90,7 @@ def cases(self):
Returns:
A list of rips Case objects
"""
pdm_objects = self.descendants(Case.__name__)
cases = []
for pdm_object in pdm_objects:
cases.append(pdm_object.cast(Case))
return cases
return self.descendants(Case)
@add_method(Project)
def case(self, case_id):
@ -142,11 +137,7 @@ def create_grid_case_group(self, case_paths):
@add_method(Project)
def views(self):
"""Get a list of views belonging to a project"""
pdm_objects = self.descendants("ReservoirView")
view_list = []
for pdm_object in pdm_objects:
view_list.append(View(pdm_object))
return view_list
return self.descendants(View)
@add_method(Project)
def view(self, view_id):

View File

@ -7,11 +7,11 @@ import rips.generated.Commands_pb2 as Cmd
import rips.case # Circular import of Case, which already imports View. Use full name.
from rips.pdmobject import add_method
from rips.generated.pdm_objects import View, ViewWindow, ReservoirView, GeoMechView
from rips.generated.pdm_objects import View, ViewWindow, EclipseView, GeoMechView
@add_method(View)
def is_eclipse_view(self):
return isinstance(self, ReservoirView)
return isinstance(self, EclipseView)
@add_method(View)
def is_geomech_view(self):

View File

@ -19,6 +19,7 @@
#include "RiaApplication.h"
#include "RiaGrpcCallbacks.h"
#include "RicfObjectCapability.h"
#include "Rim3dView.h"
#include "RimEclipseResultDefinition.h"
#include "RimProject.h"
@ -36,8 +37,11 @@ grpc::Status RiaGrpcPdmObjectService::GetAncestorPdmObject( grpc::ServerContext*
{
RimProject* project = RiaApplication::instance()->project();
std::vector<caf::PdmObject*> objectsOfCurrentClass;
project->descendantsIncludingThisFromClassKeyword( QString::fromStdString( request->object().class_keyword() ),
objectsOfCurrentClass );
QString scriptClassName = QString::fromStdString( request->object().class_keyword() );
QString classKeyword = RicfObjectCapability::classKeywordFromScriptClassName( scriptClassName );
project->descendantsIncludingThisFromClassKeyword( classKeyword, objectsOfCurrentClass );
caf::PdmObject* matchingObject = nullptr;
for ( caf::PdmObject* testObject : objectsOfCurrentClass )
@ -50,9 +54,10 @@ grpc::Status RiaGrpcPdmObjectService::GetAncestorPdmObject( grpc::ServerContext*
if ( matchingObject )
{
caf::PdmObject* parentObject = nullptr;
matchingObject->firstAncestorOrThisFromClassKeyword( QString::fromStdString( request->parent_keyword() ),
parentObject );
caf::PdmObject* parentObject = nullptr;
QString ancestorScriptName = QString::fromStdString( request->parent_keyword() );
QString ancestorClassKeyword = RicfObjectCapability::classKeywordFromScriptClassName( ancestorScriptName );
matchingObject->firstAncestorOrThisFromClassKeyword( ancestorClassKeyword, parentObject );
if ( parentObject )
{
copyPdmObjectFromCafToRips( parentObject, reply );
@ -71,8 +76,11 @@ grpc::Status RiaGrpcPdmObjectService::GetDescendantPdmObjects( grpc::ServerConte
{
RimProject* project = RiaApplication::instance()->project();
std::vector<caf::PdmObject*> objectsOfCurrentClass;
project->descendantsIncludingThisFromClassKeyword( QString::fromStdString( request->object().class_keyword() ),
objectsOfCurrentClass );
QString scriptClassName = QString::fromStdString( request->object().class_keyword() );
QString classKeyword = RicfObjectCapability::classKeywordFromScriptClassName( scriptClassName );
project->descendantsIncludingThisFromClassKeyword( classKeyword, objectsOfCurrentClass );
caf::PdmObject* matchingObject = nullptr;
for ( caf::PdmObject* testObject : objectsOfCurrentClass )
@ -86,8 +94,9 @@ grpc::Status RiaGrpcPdmObjectService::GetDescendantPdmObjects( grpc::ServerConte
if ( matchingObject )
{
std::vector<caf::PdmObject*> childObjects;
matchingObject->descendantsIncludingThisFromClassKeyword( QString::fromStdString( request->child_keyword() ),
childObjects );
QString childClassKeyword =
RicfObjectCapability::classKeywordFromScriptClassName( QString::fromStdString( request->child_keyword() ) );
matchingObject->descendantsIncludingThisFromClassKeyword( childClassKeyword, childObjects );
for ( auto pdmChild : childObjects )
{
rips::PdmObject* ripsChild = reply->add_objects();
@ -107,8 +116,11 @@ grpc::Status RiaGrpcPdmObjectService::GetChildPdmObjects( grpc::ServerContext*
{
RimProject* project = RiaApplication::instance()->project();
std::vector<caf::PdmObject*> objectsOfCurrentClass;
project->descendantsIncludingThisFromClassKeyword( QString::fromStdString( request->object().class_keyword() ),
objectsOfCurrentClass );
QString scriptClassName = QString::fromStdString( request->object().class_keyword() );
QString classKeyword = RicfObjectCapability::classKeywordFromScriptClassName( scriptClassName );
project->descendantsIncludingThisFromClassKeyword( classKeyword, objectsOfCurrentClass );
caf::PdmObject* matchingObject = nullptr;
for ( caf::PdmObject* testObject : objectsOfCurrentClass )
@ -152,8 +164,11 @@ grpc::Status RiaGrpcPdmObjectService::UpdateExistingPdmObject( grpc::ServerConte
{
RimProject* project = RiaApplication::instance()->project();
std::vector<caf::PdmObject*> objectsOfCurrentClass;
project->descendantsIncludingThisFromClassKeyword( QString::fromStdString( request->class_keyword() ),
objectsOfCurrentClass );
QString scriptClassName = QString::fromStdString( request->class_keyword() );
QString classKeyword = RicfObjectCapability::classKeywordFromScriptClassName( scriptClassName );
project->descendantsIncludingThisFromClassKeyword( classKeyword, objectsOfCurrentClass );
caf::PdmObject* matchingObject = nullptr;
for ( caf::PdmObject* pdmObject : objectsOfCurrentClass )
@ -196,8 +211,11 @@ grpc::Status RiaGrpcPdmObjectService::CreateChildPdmObject( grpc::ServerContext*
{
RimProject* project = RiaApplication::instance()->project();
std::vector<caf::PdmObject*> objectsOfCurrentClass;
project->descendantsIncludingThisFromClassKeyword( QString::fromStdString( request->object().class_keyword() ),
objectsOfCurrentClass );
QString scriptClassName = QString::fromStdString( request->object().class_keyword() );
QString classKeyword = RicfObjectCapability::classKeywordFromScriptClassName( scriptClassName );
project->descendantsIncludingThisFromClassKeyword( classKeyword, objectsOfCurrentClass );
caf::PdmObject* matchingObject = nullptr;
for ( caf::PdmObject* testObject : objectsOfCurrentClass )

View File

@ -23,6 +23,7 @@
#include "RicfFieldHandle.h"
#include "RicfMessages.h"
#include "RicfObjectCapability.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
@ -69,7 +70,9 @@ void RiaGrpcServiceInterface::copyPdmObjectFromCafToRips( const caf::PdmObjectHa
{
CAF_ASSERT( source && destination && source->xmlCapability() );
destination->set_class_keyword( source->xmlCapability()->classKeyword().toStdString() );
QString classKeyword = source->xmlCapability()->classKeyword();
QString scriptName = RicfObjectCapability::scriptClassNameFromClassKeyword( classKeyword );
destination->set_class_keyword( scriptName.toStdString() );
destination->set_address( reinterpret_cast<uint64_t>( source ) );
bool visible = true;
@ -112,7 +115,6 @@ void RiaGrpcServiceInterface::copyPdmObjectFromCafToRips( const caf::PdmObjectHa
void RiaGrpcServiceInterface::copyPdmObjectFromRipsToCaf( const rips::PdmObject* source, caf::PdmObjectHandle* destination )
{
CAF_ASSERT( source && destination && destination->xmlCapability() );
CAF_ASSERT( destination->xmlCapability()->matchesClassKeyword( QString::fromStdString( source->class_keyword() ) ) );
if ( destination->uiCapability() && destination->uiCapability()->objectToggleField() )
{

View File

@ -43,7 +43,7 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimCase, "Case", "RimCase" );
RimCase::RimCase()
: m_isInActiveDestruction( false )
{
CAF_PDM_InitObject( "Case", ":/Case48x48.png", "", "The ResInsight base class for Cases" );
RICF_InitObjectWithScriptNameAndComment( "Case", ":/Case48x48.png", "", "", "Case", "The ResInsight base class for Cases" );
RICF_InitField( &caseUserDescription, "Name", QString(), "Case Name", "", "", "" );
caseUserDescription.xmlCapability()->registerKeywordAlias( "CaseUserDescription" );

View File

@ -28,6 +28,7 @@
#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h"
#include "RicfCommandObject.h"
#include "RifReaderSettings.h"
#include "RigActiveCellInfo.h"
@ -77,7 +78,12 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimEclipseCase, "RimReservoir" );
//--------------------------------------------------------------------------------------------------
RimEclipseCase::RimEclipseCase()
{
CAF_PDM_InitObject( "EclipseCase", ":/Case48x48.png", "", "" );
RICF_InitObjectWithScriptNameAndComment( "EclipseCase",
":/Case48x48.png",
"",
"",
"Reservoir",
"Abtract base class for Eclipse Cases" );
CAF_PDM_InitFieldNoDefault( &reservoirViews, "ReservoirViews", "", "", "", "" );
reservoirViews.uiCapability()->setUiHidden( true );

View File

@ -63,14 +63,14 @@
#include <fstream>
#include <string>
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimEclipseResultCase, "EclipseCase" );
CAF_PDM_SOURCE_INIT( RimEclipseResultCase, "EclipseCase" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseResultCase::RimEclipseResultCase()
: RimEclipseCase()
{
CAF_PDM_InitObject( "Eclipse Case", ":/Case48x48.png", "", "The Regular Eclipse Results Case" );
RICF_InitObject( "Eclipse Case", ":/Case48x48.png", "", "The Regular Eclipse Results Case" );
CAF_PDM_InitFieldNoDefault( &m_unitSystem, "UnitSystem", "Unit System", "", "", "" );
m_unitSystem.registerGetMethod( RiaApplication::instance()->project(), &RimProject::commonUnitSystemForAllCases );

View File

@ -27,6 +27,7 @@
#include "HoloLensCommands/RicExportToSharingServerScheduler.h"
#include "RicfCommandObject.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
@ -110,7 +111,7 @@
#include <climits>
CAF_PDM_XML_SCRIPTABLE_SOURCE_INIT( RimEclipseView, "ReservoirView" );
CAF_PDM_XML_SOURCE_INIT( RimEclipseView, "ReservoirView" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -120,7 +121,12 @@ RimEclipseView::RimEclipseView()
RiaPreferences* preferences = app->preferences();
CVF_ASSERT( preferences );
CAF_PDM_InitObject( "Reservoir View", ":/3DView16x16.png", "", "The Eclipse 3d Reservoir View" );
RICF_InitObjectWithScriptNameAndComment( "Reservoir View",
":/3DView16x16.png",
"",
"The Eclipse 3d Reservoir View",
"EclipseView",
"The Eclipse 3d Reservoir View" );
CAF_PDM_InitFieldNoDefault( &m_cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", "" );
m_cellResult = new RimEclipseCellColors();

View File

@ -1,18 +1,21 @@
#include "RimFileWellPath.h"
#include "QDir"
#include "QFileInfo"
#include "RicfCommandObject.h"
#include "RifWellPathImporter.h"
#include "RimTools.h"
#include "cafUtils.h"
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimFileWellPath, "WellPath" );
#include "QDir"
#include "QFileInfo"
CAF_PDM_SOURCE_INIT( RimFileWellPath, "WellPath" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFileWellPath::RimFileWellPath()
{
CAF_PDM_InitObject( "File Well Path", ":/Well.png", "", "" );
RICF_InitObjectWithScriptNameAndComment( "File Well Path", ":/Well.png", "", "", "FileWellPath", "Well Paths Loaded From File" );
CAF_PDM_InitFieldNoDefault( &id, "WellPathId", "Id", "", "", "" );
id.uiCapability()->setUiReadOnly( true );

View File

@ -61,14 +61,20 @@
#include <array>
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimGeoMechCase, "GeoMechCase", "ResInsightGeoMechCase" );
CAF_PDM_SOURCE_INIT( RimGeoMechCase, "ResInsightGeoMechCase" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechCase::RimGeoMechCase( void )
: m_applyTimeFilter( false )
{
CAF_PDM_InitObject( "Geomechanical Case", ":/GeoMechCase48x48.png", "", "The GeoMechanical Results Case" );
RICF_InitObjectWithScriptNameAndComment( "GeoMechanical Case",
":/GeoMechCase48x48.png",
"",
"The GeoMechanical Results Case",
"GeoMechCase",
"The Abaqus Based GeoMech Case" );
CAF_PDM_InitFieldNoDefault( &geoMechViews, "GeoMechViews", "", "", "", "" );
geoMechViews.uiCapability()->setUiHidden( true );

View File

@ -24,6 +24,8 @@
#include "RiaPreferences.h"
#include "RiaRegressionTestRunner.h"
#include "RicfCommandObject.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigFemPartResultsCollection.h"
@ -77,17 +79,13 @@
#include <QMessageBox>
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimGeoMechView, "GeoMechView" );
CAF_PDM_SOURCE_INIT( RimGeoMechView, "GeoMechView" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechView::RimGeoMechView( void )
{
RiaApplication* app = RiaApplication::instance();
RiaPreferences* preferences = app->preferences();
CVF_ASSERT( preferences );
CAF_PDM_InitObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "The Geomechanical 3d View" );
RICF_InitObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "The Geomechanical 3d View" );
CAF_PDM_InitFieldNoDefault( &cellResult, "GridCellResult", "Color Result", ":/CellResult.png", "", "" );
cellResult = new RimGeoMechCellColors();

View File

@ -48,14 +48,19 @@
#include <QDir>
#include <QMessageBox>
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimIdenticalGridCaseGroup, "GridCaseGroup", "RimIdenticalGridCaseGroup" );
CAF_PDM_SOURCE_INIT( RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup()
{
CAF_PDM_InitObject( "Grid Case Group", ":/GridCaseGroup16x16.png", "", "" );
RICF_InitObjectWithScriptNameAndComment( "Grid Case Group",
":/GridCaseGroup16x16.png",
"",
"",
"GridCaseGroup",
"A statistics case group" );
RICF_InitField( &name, "UserDescription", QString( "Grid Case Group" ), "Name", "", "", "" );

View File

@ -18,6 +18,7 @@
#include "RimModeledWellPath.h"
#include "RicfCommandObject.h"
#include "RimProject.h"
#include "RimWellPathGeometryDef.h"
@ -32,14 +33,14 @@
#include "RimWellPathFractureCollection.h"
#include "cafPdmUiTreeOrdering.h"
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimModeledWellPath, "ModeledWellPath" );
CAF_PDM_SOURCE_INIT( RimModeledWellPath, "ModeledWellPath" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimModeledWellPath::RimModeledWellPath()
{
CAF_PDM_InitObject( "Modeled WellPath", ":/EditableWell.png", "", "" );
RICF_InitObject( "Modeled WellPath", ":/EditableWell.png", "", "A Well Path created interactively in ResInsight" );
CAF_PDM_InitFieldNoDefault( &m_geometryDefinition, "WellPathGeometryDef", "Trajectory", "", "", "" );
m_geometryDefinition = new RimWellPathGeometryDef;

View File

@ -1,5 +1,6 @@
#include "RimPlot.h"
#include "RicfCommandObject.h"
#include "RimMultiPlot.h"
#include "RimPlotCurve.h"
#include "RimPlotWindow.h"
@ -25,14 +26,14 @@ void RimPlot::RowOrColSpanEnum::setUp()
}
} // namespace caf
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "Plot", "RimPlot" ); // Do not use. Abstract class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "RimPlot" ); // Do not use. Abstract class
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlot::RimPlot()
{
CAF_PDM_InitObject( "Plot", "", "", "" );
RICF_InitObjectWithScriptNameAndComment( "Plot", "", "", "", "Plot", "The Abstract Base Class for all Plot Objects" );
CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Col Span", "", "", "" );

View File

@ -30,14 +30,19 @@
#include <QPainter>
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotWindow, "PlotWindow", "RimPlotWindow" ); // Do not use. Abstract class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotWindow, "RimPlotWindow" ); // Do not use. Abstract class
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotWindow::RimPlotWindow()
{
CAF_PDM_InitObject( "PlotWindow", "", "", "" );
RICF_InitObjectWithScriptNameAndComment( "PlotWindow",
"",
"",
"",
"PlotWindow",
"The Abstract base class for all MDI Windows in the Plot Window" );
RICF_InitField( &m_id, "Id", -1, "View ID", "", "", "" );
m_id.xmlCapability()->registerKeywordAlias( "ViewId" );

View File

@ -27,6 +27,7 @@
#include "RiaProjectFileVersionTools.h"
#include "RiaVersionInfo.h"
#include "RicfCommandObject.h"
#include "RigEclipseCaseData.h"
#include "RigGridBase.h"
@ -101,7 +102,7 @@
#include <QMenu>
#include <algorithm>
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimProject, "Project", "ResInsightProject" );
CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -112,7 +113,7 @@ RimProject::RimProject( void )
, m_nextValidPlotId( 1 )
, m_nextValidCalculationId( 1 )
{
CAF_PDM_InitObject( "Project", "", "", "" );
RICF_InitObjectWithScriptNameAndComment( "Project", "", "", "", "Project", "The ResInsight Project" );
CAF_PDM_InitFieldNoDefault( &m_projectFileVersionString, "ProjectFileVersionString", "", "", "", "" );
m_projectFileVersionString.uiCapability()->setUiHidden( true );

View File

@ -55,14 +55,14 @@
//--------------------------------------------------------------------------------------------------
Rim2dIntersectionView* corresponding2dIntersectionView( RimSimWellInView* simWellInView );
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimSimWellInView, "SimulationWell", "Well" );
CAF_PDM_SOURCE_INIT( RimSimWellInView, "Well" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSimWellInView::RimSimWellInView()
{
CAF_PDM_InitObject( "Simulation Well", ":/Well.png", "", "" );
RICF_InitObjectWithScriptNameAndComment( "Simulation Well", ":/Well.png", "", "", "SimulationWell", "An Eclipse Simulation Well" );
RICF_InitFieldNoDefault( &name, "Name", "Name", "", "", "" );
name.xmlCapability()->registerKeywordAlias( "WellName" );

View File

@ -43,7 +43,12 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimViewWindow, "ViewWindow" ); // Do not use.
//--------------------------------------------------------------------------------------------------
RimViewWindow::RimViewWindow( void )
{
CAF_PDM_InitObject( "View window", "", "", "" );
RICF_InitObjectWithScriptNameAndComment( "View window",
"",
"",
"",
"ViewWindow",
"The Base Class for all Views and Plots in ResInsight" );
CAF_PDM_InitFieldNoDefault( &m_windowController, "WindowController", "", "", "", "" );
m_windowController.uiCapability()->setUiHidden( true );

View File

@ -26,14 +26,14 @@
#include "RimWellLogFile.h"
#include "RimWellPath.h"
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWbsParameters, "WbsParameters" );
CAF_PDM_SOURCE_INIT( RimWbsParameters, "WbsParameters" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWbsParameters::RimWbsParameters()
{
CAF_PDM_InitObject( "Well Bore Stability Parameters", ":/WellLogPlot16x16.png", "", "" );
RICF_InitObject( "Well Bore Stability Parameters", ":/WellLogPlot16x16.png", "", "" );
RICF_InitFieldNoDefault( &m_porePressureSource,
"PorePressureReservoirSource",

View File

@ -18,6 +18,8 @@
#include "RimWellBoreStabilityPlot.h"
#include "RiaDefines.h"
#include "RicfCommandObject.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemResultAddress.h"
#include "RigGeoMechCaseData.h"
@ -33,14 +35,14 @@
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiGroup.h"
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellBoreStabilityPlot, "WellBoreStabilityPlot" );
CAF_PDM_SOURCE_INIT( RimWellBoreStabilityPlot, "WellBoreStabilityPlot" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellBoreStabilityPlot::RimWellBoreStabilityPlot()
{
CAF_PDM_InitObject( "Well Bore Stability Plot", ":/WellBoreStability16x16.png", "", "" );
RICF_InitObject( "Well Bore Stability Plot", ":/WellBoreStability16x16.png", "", "A GeoMechanical Well Bore Stabilit Plot" );
CAF_PDM_InitFieldNoDefault( &m_wbsParameters, "WbsParameters", "Well Bore Stability Parameters", "", "", "" );
m_wbsParameters = new RimWbsParameters;

View File

@ -64,17 +64,17 @@ void RimWellLogPlot::AxisGridEnum::setUp()
} // End namespace caf
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellLogPlot, "WellLogPlot" );
CAF_PDM_SOURCE_INIT( RimWellLogPlot, "WellLogPlot" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlot::RimWellLogPlot()
{
CAF_PDM_InitObject( "Well Log Plot",
":/WellLogPlot16x16.png",
"",
"A Well Log Plot With a shared Depth Axis and Multiple Tracks" );
RICF_InitObject( "Well Log Plot",
":/WellLogPlot16x16.png",
"",
"A Well Log Plot With a shared Depth Axis and Multiple Tracks" );
CAF_PDM_InitFieldNoDefault( &m_commonDataSource,
"CommonDataSource",

View File

@ -61,7 +61,7 @@
#include <regex>
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimWellPath, "WellPathBase" );
CAF_PDM_SOURCE_INIT( RimWellPath, "WellPathBase" );
//--------------------------------------------------------------------------------------------------
///
@ -73,7 +73,7 @@ const char RimWellPath::SIM_WELL_NONE_UI_TEXT[] = "None";
//--------------------------------------------------------------------------------------------------
RimWellPath::RimWellPath()
{
CAF_PDM_InitObject( "WellPath", ":/Well.png", "", "" );
RICF_InitObject( "WellPath", ":/Well.png", "", "The Base class for Well Paths" );
RICF_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" );
m_name.xmlCapability()->registerKeywordAlias( "WellPathName" );

View File

@ -20,6 +20,7 @@
#include "RiaLogging.h"
#include "RicfCommandObject.h"
#include "RifEclipseSummaryTools.h"
#include "RifReaderEclipseRft.h"
#include "RifReaderEclipseSummary.h"
@ -34,14 +35,14 @@
//
//
//==================================================================================================
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimFileSummaryCase, "FileSummaryCase" );
CAF_PDM_SOURCE_INIT( RimFileSummaryCase, "FileSummaryCase" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFileSummaryCase::RimFileSummaryCase()
{
CAF_PDM_InitObject( "File Summary Case ", "", "", "A Summary Case based on SMSPEC files" );
RICF_InitObject( "File Summary Case ", "", "", "A Summary Case based on SMSPEC files" );
CAF_PDM_InitField( &m_includeRestartFiles, "IncludeRestartFiles", false, "Include Restart Files", "", "", "" );
m_includeRestartFiles.uiCapability()->setUiHidden( true );

View File

@ -18,6 +18,7 @@
#include "RimGridSummaryCase.h"
#include "RicfCommandObject.h"
#include "RifReaderEclipseSummary.h"
#include "RimEclipseCase.h"
@ -32,14 +33,14 @@
//
//==================================================================================================
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimGridSummaryCase, "GridSummaryCase" );
CAF_PDM_SOURCE_INIT( RimGridSummaryCase, "GridSummaryCase" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGridSummaryCase::RimGridSummaryCase()
{
CAF_PDM_InitObject( "Grid Summary Case ", "", "", "A Summary Case based on extracting grid data." );
RICF_InitObject( "Grid Summary Case ", "", "", "A Summary Case based on extracting grid data." );
CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "Associated3DCase", "Eclipse Case", "", "", "" );
m_eclipseCase.uiCapability()->setUiHidden( true );

View File

@ -44,7 +44,7 @@ const QString RimSummaryCase::DEFAULT_DISPLAY_NAME = "Display Name";
//--------------------------------------------------------------------------------------------------
RimSummaryCase::RimSummaryCase()
{
CAF_PDM_InitObject( "Summary Case", ":/SummaryCase16x16.png", "", "" );
RICF_InitObject( "Summary Case", ":/SummaryCase16x16.png", "", "The Base Class for all Summary Cases" );
RICF_InitField( &m_shortName, "ShortName", QString( "Display Name" ), DEFAULT_DISPLAY_NAME, "", "", "" );
RICF_InitField( &m_useAutoShortName, "AutoShortyName", false, "Use Auto Display Name", "", "", "" );

View File

@ -25,6 +25,7 @@
#include "RiaSummaryCurveDefinition.h"
#include "RiaSummaryTools.h"
#include "RiaTimeHistoryCurveResampler.h"
#include "RicfCommandObject.h"
#include "SummaryPlotCommands/RicSummaryPlotEditorUi.h"
@ -74,7 +75,7 @@
#include <limits>
#include <set>
CAF_PDM_SCRIPTABLE_SOURCE_INIT( RimSummaryPlot, "SummaryPlot" );
CAF_PDM_SOURCE_INIT( RimSummaryPlot, "SummaryPlot" );
//--------------------------------------------------------------------------------------------------
/// Internal types
@ -142,16 +143,16 @@ CurvesData concatCurvesData( const std::vector<CurvesData>& curvesData );
RimSummaryPlot::RimSummaryPlot()
: RimPlot()
{
CAF_PDM_InitObject( "Summary Plot", ":/SummaryPlotLight16x16.png", "", "" );
RICF_InitObject( "Summary Plot", ":/SummaryPlotLight16x16.png", "", "A Summary Plot" );
CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Plot Title", "", "", "" );
RICF_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Plot Title", "", "", "" );
m_showPlotTitle.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto Title", "", "", "" );
RICF_InitField( &m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto Title", "", "", "" );
CAF_PDM_InitField( &m_description, "PlotDescription", QString( "Summary Plot" ), "Name", "", "", "" );
RICF_InitField( &m_description, "PlotDescription", QString( "Summary Plot" ), "Name", "", "", "" );
CAF_PDM_InitField( &m_normalizeCurveYValues, "normalizeCurveYValues", false, "Normalize all curves", "", "", "" );
RICF_InitField( &m_normalizeCurveYValues, "normalizeCurveYValues", false, "Normalize all curves", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_summaryCurveCollection, "SummaryCurveCollection", "", "", "", "" );
m_summaryCurveCollection.uiCapability()->setUiTreeHidden( true );

View File

@ -77,8 +77,6 @@ class PdmObjectCapability;
#define CAF_PDM_SOURCE_INIT CAF_PDM_XML_SOURCE_INIT
#define CAF_PDM_ABSTRACT_SOURCE_INIT CAF_PDM_XML_ABSTRACT_SOURCE_INIT
#define CAF_PDM_SCRIPTABLE_SOURCE_INIT CAF_PDM_XML_SCRIPTABLE_SOURCE_INIT
/// InitObject sets up the user interface related information for the object
/// Placed in the constructor of your PdmObject
/// Note that classKeyword() is not virtual in the constructor of the PdmObject

View File

@ -27,30 +27,15 @@
// To be renamed CAF_PDM_XML_HEADER_INIT
#define CAF_PDM_XML_HEADER_INIT \
private: \
static bool classIsScriptable(); \
public: \
virtual QString classKeyword() const; \
static QString classKeywordStatic(); \
static std::vector<QString> classKeywordAliases(); \
virtual bool isScriptable() const; \
virtual bool matchesClassKeyword(const QString& keyword) const; \
\
static bool Error_You_forgot_to_add_the_macro_CAF_PDM_XML_HEADER_INIT_and_or_CAF_PDM_XML_SOURCE_INIT_to_your_cpp_file_for_this_class()
#define CAF_PDM_XML_NON_SCRIPTABLE_INIT(ClassName) \
bool ClassName::classIsScriptable() \
{ \
return false; \
} \
#define CAF_PDM_XML_SCRIPTABLE_INIT(ClassName) \
bool ClassName::classIsScriptable() \
{ \
return true; \
} \
#define CAF_PDM_XML_ABSTRACT_BASE_SOURCE_INIT(ClassName, keyword, ...) \
#define CAF_PDM_XML_ABSTRACT_SOURCE_INIT(ClassName, keyword, ...) \
bool ClassName::Error_You_forgot_to_add_the_macro_CAF_PDM_XML_HEADER_INIT_and_or_CAF_PDM_XML_SOURCE_INIT_to_your_cpp_file_for_this_class() { return false;} \
\
QString ClassName::classKeyword() const \
@ -66,10 +51,6 @@ public: \
CAF_PDM_VERIFY_XML_KEYWORD(keyword) \
return {keyword, ##__VA_ARGS__}; \
} \
bool ClassName::isScriptable() const \
{ \
return ClassName::classIsScriptable(); \
} \
bool ClassName::matchesClassKeyword(const QString& matchKeyword) const\
{ \
auto aliases = classKeywordAliases(); \
@ -80,18 +61,6 @@ public: \
return false; \
} \
/// CAF_PDM_XML_ABSTRACT_SOURCE_INIT associates the file keyword used for storage with the class
/// Place this in the cpp file, preferably above the constructor
#define CAF_PDM_XML_ABSTRACT_SOURCE_INIT(ClassName, keyword, ...) \
CAF_PDM_XML_ABSTRACT_BASE_SOURCE_INIT(ClassName, keyword, ##__VA_ARGS__) \
CAF_PDM_XML_NON_SCRIPTABLE_INIT(ClassName) \
/// CAF_PDM_XML_ABSTRACT_SOURCE_INIT associates the file keyword used for storage with the *scriptable* class
/// Place this in the cpp file, preferably above the constructor
#define CAF_PDM_XML_ABSTRACT_SCRIPTABLE_SOURCE_INIT(ClassName, keyword, ...) \
CAF_PDM_XML_ABSTRACT_BASE_SOURCE_INIT(ClassName, keyword, ##__VA_ARGS__) \
CAF_PDM_XML_SCRIPTABLE_INIT(ClassName) \
/// CAF_PDM_XML_SOURCE_INIT associates the file keyword used for storage with the class and
// initializes the factory
/// Place this in the cpp file, preferably above the constructor
@ -99,13 +68,6 @@ public: \
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(ClassName, keyword, ##__VA_ARGS__) \
static bool PDM_OBJECT_STRING_CONCATENATE(my##ClassName, __LINE__) = caf::PdmDefaultObjectFactory::instance()->registerCreator<ClassName>()
/// CAF_PDM_XML_SCRIPTABLE_SOURCE_INIT associates the file keyword used for storage with the *scriptable* class and
// initializes the factory
/// Place this in the cpp file, preferably above the constructor
#define CAF_PDM_XML_SCRIPTABLE_SOURCE_INIT(ClassName, keyword, ...) \
CAF_PDM_XML_ABSTRACT_SCRIPTABLE_SOURCE_INIT(ClassName, keyword, ##__VA_ARGS__) \
static bool PDM_OBJECT_STRING_CONCATENATE(my##ClassName, __LINE__) = caf::PdmDefaultObjectFactory::instance()->registerCreator<ClassName>()
#define CAF_PDM_XML_InitField(field, keyword) \
{ \
CAF_PDM_VERIFY_XML_KEYWORD(keyword) \