mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Python: Create summary plot from string
This commit is contained in:
@@ -39,6 +39,7 @@ target_include_directories(${PROJECT_NAME}
|
||||
|
||||
target_link_libraries ( ${PROJECT_NAME}
|
||||
cafProjectDataModel
|
||||
cafPdmCvf
|
||||
LibCore
|
||||
)
|
||||
|
||||
|
||||
@@ -109,7 +109,10 @@ void PdmFieldScriptabilityIOHandler<QString>::writeToField( QString&
|
||||
// Could interpret as unquoted text
|
||||
}
|
||||
|
||||
fieldValue = accumulatedFieldValue;
|
||||
if ( accumulatedFieldValue != "None" )
|
||||
{
|
||||
fieldValue = accumulatedFieldValue;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -342,6 +342,8 @@ struct PdmFieldScriptabilityIOHandler<DataType*>
|
||||
QTextStream& inputStream,
|
||||
PdmScriptIOMessages* errorMessageContainer )
|
||||
{
|
||||
fieldValue = nullptr; // Default initialized to nullptr
|
||||
|
||||
QString fieldString;
|
||||
PdmFieldScriptabilityIOHandler<QString>::writeToField( fieldString, inputStream, errorMessageContainer, true );
|
||||
|
||||
@@ -355,11 +357,12 @@ struct PdmFieldScriptabilityIOHandler<DataType*>
|
||||
return;
|
||||
}
|
||||
|
||||
if ( fieldString.isEmpty() ) return;
|
||||
|
||||
QStringList classAndAddress = fieldString.split( ":" );
|
||||
CAF_ASSERT( classAndAddress.size() == 2 );
|
||||
|
||||
qulonglong address = classAndAddress[1].toULongLong();
|
||||
fieldValue = nullptr;
|
||||
for ( DataType* object : allObjectsOfType )
|
||||
{
|
||||
if ( reinterpret_cast<qulonglong>( object ) == address )
|
||||
@@ -448,13 +451,10 @@ public:
|
||||
std::vector<DataType*> allObjectsOfType;
|
||||
existingObjectsRoot->descendantsIncludingThisOfType( allObjectsOfType );
|
||||
|
||||
DataType* object;
|
||||
PdmFieldScriptabilityIOHandler<std::vector<DataType*>>::writeToField( object,
|
||||
allObjectsOfType,
|
||||
inputStream,
|
||||
errorMessageContainer );
|
||||
DataType* object = nullptr;
|
||||
PdmFieldScriptabilityIOHandler<DataType*>::writeToField( object, allObjectsOfType, inputStream, errorMessageContainer );
|
||||
|
||||
if ( this->isIOWriteable() )
|
||||
if ( object && this->isIOWriteable() )
|
||||
{
|
||||
m_field->setValue( object );
|
||||
}
|
||||
|
||||
@@ -65,8 +65,9 @@ public:
|
||||
virtual PdmObjectHandle* execute() = 0;
|
||||
virtual QString selfClassKeyword() const { return m_self->xmlCapability()->classKeyword(); }
|
||||
|
||||
// False if object is a persistent project tree item. True if the object is to be deleted on completion.
|
||||
virtual bool deleteObjectAfterReply() const = 0;
|
||||
// True if object is a persistent project tree item. False if the object is to be deleted on completion.
|
||||
virtual bool resultIsPersistent() const = 0;
|
||||
virtual std::unique_ptr<PdmObjectHandle> defaultResult() const = 0;
|
||||
|
||||
protected:
|
||||
// Basically the "this" pointer to the object the method belongs to
|
||||
|
||||
@@ -251,6 +251,12 @@ QString PdmPythonGenerator::generate( PdmObjectFactory* factory ) const
|
||||
QStringList argumentComments;
|
||||
|
||||
outputArgumentStrings.push_back( QString( "\"%1\"" ).arg( methodName ) );
|
||||
QString returnComment( "Data object" );
|
||||
if ( method->resultIsPersistent() )
|
||||
{
|
||||
returnComment = method->defaultResult()->xmlCapability()->classKeyword();
|
||||
}
|
||||
|
||||
for ( auto field : arguments )
|
||||
{
|
||||
bool isList = field->xmlCapability()->isVectorField();
|
||||
@@ -266,10 +272,11 @@ QString PdmPythonGenerator::generate( PdmObjectFactory* factory ) const
|
||||
.arg( dataType )
|
||||
.arg( field->uiCapability()->uiWhatsThis() ) );
|
||||
}
|
||||
QString fullComment =
|
||||
QString( " \"\"\"\n %1\n Arguments:\n %2\n \"\"\"" )
|
||||
.arg( methodComment )
|
||||
.arg( argumentComments.join( "\n " ) );
|
||||
QString fullComment = QString( " \"\"\"\n %1\n Arguments:\n "
|
||||
"%2\n Returns:\n %3\n \"\"\"" )
|
||||
.arg( methodComment )
|
||||
.arg( argumentComments.join( "\n " ) )
|
||||
.arg( returnComment );
|
||||
|
||||
QString methodCode = QString( " def %1(self, %2):\n%3\n return "
|
||||
"self._call_pdm_method(%4)\n" )
|
||||
|
||||
Reference in New Issue
Block a user