if ( anIsToSetObject )
{
+ QString anObjName = GetObjPyName();
theScript << QString( "%1.%2( %3 );" )
- .arg( GetObjPyName() ).arg( theMethod ).arg( aRefObjName );
+ .arg( anObjName ).arg( theMethod ).arg( aRefObjName );
}
}
+void HYDROData_Entity::setPythonObjectColor( QStringList& theScript,
+ const QColor& theColor,
+ const QColor& theDefaultColor,
+ const QString& theMethod ) const
+{
+ if ( theColor == theDefaultColor )
+ return; //Do not set the color for object if it like default
+
+ QString anObjName = GetObjPyName();
+ theScript << QString( "%1.%2( QColor( %3, %4, %5, %6 ) );" )
+ .arg( anObjName ).arg( theMethod )
+ .arg( theColor.red() ).arg( theColor.green() )
+ .arg( theColor.blue() ).arg( theColor.alpha() );
+}
+
const Handle(HYDROData_Entity)& theRefObject,
const QString& theMethod ) const;
+ void setPythonObjectColor( QStringList& theScript,
+ const QColor& theColor,
+ const QColor& theDefaultColor,
+ const QString& theMethod ) const;
+
/**
* Dump the initial object creation to a Python script.
* You should call it from DumpToPython implementation before
* dumping fields of the object.
*/
- QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const;
+ HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const;
/**
* Returns an object type name as a string for dumping to Python.
QStringList HYDROData_ImmersibleZone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
{
QStringList aResList = dumpObjectCreation( theTreatedObjects );
+
QString aZoneName = GetObjPyName();
- QColor aFillingColor = GetFillingColor();
- aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" )
- .arg( aFillingColor.red() ).arg( aFillingColor.green() )
- .arg( aFillingColor.blue() ).arg( aFillingColor.alpha() );
- aResList << QString( "%1.SetFillingColor( filling_color );" ).arg( aZoneName );
- aResList << QString( "" );
-
- QColor aBorderColor = GetBorderColor();
- aResList << QString( "border_color = QColor( %1, %2, %3, %4 );" )
- .arg( aBorderColor.red() ).arg( aBorderColor.green() )
- .arg( aBorderColor.blue() ).arg( aBorderColor.alpha() );
- aResList << QString( "%1.SetBorderColor( border_color );" ).arg( aZoneName );
- aResList << QString( "" );
-
Handle(HYDROData_IAltitudeObject) aRefAltitude = GetAltitudeObject();
setPythonReferenceObject( theTreatedObjects, aResList, aRefAltitude, "SetAltitudeObject" );
setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
aResList << QString( "" );
+
aResList << QString( "%1.Update();" ).arg( aZoneName );
aResList << QString( "" );
return QColor( Qt::transparent );
}
+QStringList HYDROData_Object::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const
+{
+ QStringList aResList = HYDROData_Entity::dumpObjectCreation( theTreatedObjects );
+ if ( aResList.isEmpty() )
+ return aResList; //Object was not created
+
+ QStringList aColorsDef;
+
+ QColor aFillingColor = GetFillingColor();
+ setPythonObjectColor( aColorsDef, aFillingColor, getDefaultFillingColor(), "SetFillingColor" );
+
+ QColor aBorderColor = GetBorderColor();
+ setPythonObjectColor( aColorsDef, aBorderColor, getDefaultBorderColor(), "SetBorderColor" );
+
+ if ( !aColorsDef.isEmpty() )
+ {
+ aResList << aColorsDef;
+ aResList << QString( "" );
+ }
+
+ return aResList;
+}
+
ObjectKind HYDROData_Object::getAltitudeObjectType() const
{
return KIND_UNKNOWN;
protected:
+ /**
+ * Dump the initial object creation to a Python script.
+ * Reimplemented to dump the object colors.
+ */
+ HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const;
+
+
/**
* Checks and if necessary create child 3D object.
* Reimplement this function in your subclass if you
QStringList aResList = dumpObjectCreation( theTreatedObjects );
QString aPolylineName = GetObjPyName();
+ // Set the wire color
+ QStringList aWireColorDef;
+
+ QColor aWireColor = GetWireColor();
+ setPythonObjectColor( aWireColorDef, aWireColor, DefaultWireColor(), "SetWireColor" );
+
+ if ( !aWireColorDef.isEmpty() )
+ {
+ aResList << aWireColorDef;
+ aResList << QString( "" );
+ }
+
// Set polilyne data
NCollection_Sequence<TCollection_AsciiString> aSectNames;
NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;