Python: Create summary plot from string

This commit is contained in:
Gaute Lindkvist
2020-03-13 08:34:05 +01:00
parent 6b289f0db2
commit 2853308a4a
17 changed files with 415 additions and 205 deletions

View File

@@ -39,6 +39,7 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries ( ${PROJECT_NAME}
cafProjectDataModel
cafPdmCvf
LibCore
)

View File

@@ -109,7 +109,10 @@ void PdmFieldScriptabilityIOHandler<QString>::writeToField( QString&
// Could interpret as unquoted text
}
fieldValue = accumulatedFieldValue;
if ( accumulatedFieldValue != "None" )
{
fieldValue = accumulatedFieldValue;
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -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 );
}

View File

@@ -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

View File

@@ -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" )