From fa7f54ee1c5fc278d9710e5aa6edbd3f419019af Mon Sep 17 00:00:00 2001 From: adv Date: Tue, 10 Sep 2013 06:28:47 +0000 Subject: [PATCH] Dump arguments of comser operator to python string representation (base implementation). --- src/ImageComposer/ImageComposer_Operator.cxx | 25 ++++++++++++++++++++ src/ImageComposer/ImageComposer_Operator.h | 7 ++++++ 2 files changed, 32 insertions(+) diff --git a/src/ImageComposer/ImageComposer_Operator.cxx b/src/ImageComposer/ImageComposer_Operator.cxx index 5e52f22b9..c9cdc7735 100644 --- a/src/ImageComposer/ImageComposer_Operator.cxx +++ b/src/ImageComposer/ImageComposer_Operator.cxx @@ -113,6 +113,31 @@ void ImageComposer_Operator::setBinArgs( const QByteArray& theData ) restoreArgs( aStream ); } +QStringList ImageComposer_Operator::dumpArgsToPython( QString& theArrayName ) const +{ + QStringList aResList; + + if ( theArrayName.isEmpty() ) + theArrayName = "composer_args"; + + QString aStreamName = theArrayName + "_stream"; + + aResList << QString( "%1 = QByteArray();" ).arg( theArrayName ); + aResList << QString( "%1 = QDataStream( %2, QIODevice.WriteOnly );" ) + .arg( aStreamName ).arg( theArrayName ); + + //Dump background color + aResList << QString( "" ); + + aResList << QString( "background_color = QColor( %1, %2, %3, %4 );" ) + .arg( myBackground.red() ).arg( myBackground.green() ) + .arg( myBackground.blue() ).arg( myBackground.alpha() ); + + aResList << QString( "%1 << background_color;" ).arg( aStreamName ); + + return aResList; +} + /** Store the operator's arguments to the stream @param theStream the stream for storing diff --git a/src/ImageComposer/ImageComposer_Operator.h b/src/ImageComposer/ImageComposer_Operator.h index 142a1c6cb..cfece776d 100644 --- a/src/ImageComposer/ImageComposer_Operator.h +++ b/src/ImageComposer/ImageComposer_Operator.h @@ -29,6 +29,13 @@ public: QByteArray getBinArgs() const; void setBinArgs( const QByteArray& ); + /** + Dumps arguments of operator to python script representation + @param theArrayName name of result \c QByteArray array variable + @return list of strings with python representation + **/ + QStringList dumpArgsToPython( QString& theArrayName ) const; + virtual QString name() const; virtual ImageComposer_Image process( const ImageComposer_Image& theImage1, const ImageComposer_Image& theImage2 ) const; -- 2.39.2