From: adv Date: Wed, 11 Sep 2013 12:28:31 +0000 (+0000) Subject: ImageComposer API has been changed to support universal interface. (Feature #6) X-Git-Tag: BR_hydro_v_0_1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=382f884fc61aae249d214dae5251b04df71f5205;p=modules%2Fgui.git ImageComposer API has been changed to support universal interface. (Feature #6) --- diff --git a/src/ImageComposer/CMakeLists.txt b/src/ImageComposer/CMakeLists.txt index cda4cd568..1f1762f66 100755 --- a/src/ImageComposer/CMakeLists.txt +++ b/src/ImageComposer/CMakeLists.txt @@ -42,6 +42,7 @@ INSTALL(TARGETS ImageComposer DESTINATION ${GUI_salomelib_LIBS}) SET(COMMON_HEADERS_H ImageComposer.h + ImageComposer_MetaTypes.h ImageComposer_ColorMaskOperator.h ImageComposer_CropOperator.h ImageComposer_CutOperator.h diff --git a/src/ImageComposer/ImageComposer_ColorMaskOperator.cxx b/src/ImageComposer/ImageComposer_ColorMaskOperator.cxx index 3a788f54f..d4aba21a3 100644 --- a/src/ImageComposer/ImageComposer_ColorMaskOperator.cxx +++ b/src/ImageComposer/ImageComposer_ColorMaskOperator.cxx @@ -1,6 +1,6 @@ #include "ImageComposer_ColorMaskOperator.h" -#include "ImageComposer_Image.h" +#include "ImageComposer_MetaTypes.h" #include #include #include @@ -78,19 +78,31 @@ QStringList ImageComposer_ColorMaskOperator::dumpArgsToPython( QString& theArray /** */ -QRectF ImageComposer_ColorMaskOperator::calcResultBoundingRect( const QRectF& theImage1Bounds, - const QRectF& ) const +QRectF ImageComposer_ColorMaskOperator::calcResultBoundingRect( const QVariant& theObj1, + const QVariant& ) const { - return theImage1Bounds; + QRectF aResRect; + if ( !theObj1.isNull() && theObj1.canConvert() ) + { + ImageComposer_Image anImage1 = theObj1.value(); + aResRect = anImage1.boundingRect(); + } + return aResRect; } /** */ -void ImageComposer_ColorMaskOperator::drawResult( QPainter& thePainter, - const ImageComposer_Image& theImage1, - const ImageComposer_Image& ) const +void ImageComposer_ColorMaskOperator::drawResult( QPainter& thePainter, + const QVariant& theObj1, + const QVariant& ) const { - QImage anImage = theImage1.convertToFormat( QImage::Format_ARGB32 ); + if ( theObj1.isNull() || !theObj1.canConvert() ) + return; + + ImageComposer_Image anImage1 = theObj1.value(); + + QImage anImage = anImage1.convertToFormat( QImage::Format_ARGB32 ); + int aRMin = myRefColor.red() - myRGBThreshold; int aRMax = myRefColor.red() + myRGBThreshold; int aGMin = myRefColor.green() - myRGBThreshold; @@ -120,7 +132,7 @@ void ImageComposer_ColorMaskOperator::drawResult( QPainter& thePainter, ImageComposer_Image aResult; aResult = anImage; - aResult.setTransform( theImage1.transform() ); + aResult.setTransform( anImage1.transform() ); aResult.draw( thePainter ); } diff --git a/src/ImageComposer/ImageComposer_ColorMaskOperator.h b/src/ImageComposer/ImageComposer_ColorMaskOperator.h index d79034491..8c078fbee 100644 --- a/src/ImageComposer/ImageComposer_ColorMaskOperator.h +++ b/src/ImageComposer/ImageComposer_ColorMaskOperator.h @@ -32,10 +32,10 @@ public: QStringList dumpArgsToPython( QString& theArrayName ) const; protected: - virtual QRectF calcResultBoundingRect( const QRectF& theImage1Bounds, - const QRectF& theImage2Bounds ) const; - virtual void drawResult( QPainter& thePainter, const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const; + virtual QRectF calcResultBoundingRect( const QVariant& theObj1, + const QVariant& theObj2 ) const; + virtual void drawResult( QPainter& thePainter, const QVariant& theObj1, + const QVariant& theObj2 ) const; virtual void storeArgs( QDataStream& theStream ) const; virtual void restoreArgs( QDataStream& theStream ); diff --git a/src/ImageComposer/ImageComposer_CropOperator.cxx b/src/ImageComposer/ImageComposer_CropOperator.cxx index 65aed89de..08a10599b 100644 --- a/src/ImageComposer/ImageComposer_CropOperator.cxx +++ b/src/ImageComposer/ImageComposer_CropOperator.cxx @@ -1,6 +1,8 @@ #include "ImageComposer_CropOperator.h" #include "ImageComposer_Image.h" +#include "ImageComposer_MetaTypes.h" + #include #include @@ -19,91 +21,73 @@ ImageComposer_CropOperator::~ImageComposer_CropOperator() } /** - Set operator arguments - @param theBackground the background color for result image - @param theRect the cropping rectangle (in the global CS) */ -void ImageComposer_CropOperator::setArgs( const QColor& theBackground, const QRect& theRect ) +QString ImageComposer_CropOperator::name() const { - ImageComposer_Operator::setArgs( theBackground ); - myClipPath = QPainterPath(); - myClipPath.addRect( theRect ); + return Type(); } /** - Set operator arguments - @param theBackground the background color for result image - @param thePath the cropping path (in the global CS) */ -void ImageComposer_CropOperator::setArgs( const QColor& theBackground, const QPainterPath& thePath ) +QRectF ImageComposer_CropOperator::calcResultBoundingRect( const QVariant&, + const QVariant& theObj2 ) const { - ImageComposer_Operator::setArgs( theBackground ); - myClipPath = thePath; + QRectF aResRect; + if ( !theObj2.isNull() && theObj2.canConvert() ) + { + QPainterPath aCropPath = theObj2.value(); + aResRect = aCropPath.boundingRect(); + } + return aResRect; } /** - Return clipping path - @return clipping path */ -QPainterPath ImageComposer_CropOperator::clipPath() const +void ImageComposer_CropOperator::drawResult( QPainter& thePainter, + const QVariant& theObj1, + const QVariant& theObj2 ) const { - return myClipPath; -} + if ( theObj1.isNull() || !theObj1.canConvert() || + theObj2.isNull() || !theObj2.canConvert() ) + return; -/** -*/ -QString ImageComposer_CropOperator::name() const -{ - return Type(); -} + ImageComposer_Image anImage1 = theObj1.value(); + QPainterPath anImgClipPath = theObj2.value(); -/** -*/ -QRectF ImageComposer_CropOperator::calcResultBoundingRect( const QRectF&, const QRectF& ) const -{ - return myImgClipPath.boundingRect(); -} + QRectF aBounds = anImgClipPath.boundingRect(); -/** -*/ -void ImageComposer_CropOperator::drawResult( QPainter& thePainter, - const ImageComposer_Image& theImage1, - const ImageComposer_Image& ) const -{ - QRectF aBounds = myImgClipPath.boundingRect(); QTransform aTranslate; aTranslate.translate( -aBounds.left(), -aBounds.top() ); - QPainterPath aClipPath = aTranslate.map( myImgClipPath ); + + QPainterPath aClipPath = aTranslate.map( anImgClipPath ); thePainter.setClipPath( aClipPath ); - theImage1.draw( thePainter ); + + anImage1.draw( thePainter ); //thePainter.fillPath( aClipPath, Qt::red ); } /** */ -ImageComposer_Image ImageComposer_CropOperator::process( const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const +ImageComposer_Image ImageComposer_CropOperator::process( const QVariant& theObj1, + const QVariant& theObj2 ) const { - QRect anImageRect( 0, 0, theImage1.width(), theImage1.height() ); - QPainterPath anImageBoundsPath; - anImageBoundsPath.addPolygon( theImage1.transform().mapToPolygon( anImageRect ) ); + ImageComposer_Image aResult; + if ( theObj1.isNull() || !theObj1.canConvert() || + theObj2.isNull() || !theObj2.canConvert() ) + return aResult; - const_cast( this )->myImgClipPath = - theImage1.transform().inverted().map( myClipPath.intersected( anImageBoundsPath ) ); + ImageComposer_Image anImage1 = theObj1.value(); + QPainterPath aCropPath = theObj2.value(); - return ImageComposer_Operator::process( theImage1, theImage2 ); -} + QRect anImageRect( 0, 0, anImage1.width(), anImage1.height() ); + QPainterPath anImageBoundsPath; + anImageBoundsPath.addPolygon( anImage1.transform().mapToPolygon( anImageRect ) ); -void ImageComposer_CropOperator::storeArgs( QDataStream& theStream ) const -{ - ImageComposer_Operator::storeArgs( theStream ); - theStream << myClipPath; -} + // clipping path mapped to first image's local CS + QVariant anImgClipPath; + anImgClipPath.setValue( + anImage1.transform().inverted().map( aCropPath.intersected( anImageBoundsPath ) ) ); -void ImageComposer_CropOperator::restoreArgs( QDataStream& theStream ) -{ - ImageComposer_Operator::restoreArgs( theStream ); - myClipPath = QPainterPath(); - theStream >> myClipPath; + return ImageComposer_Operator::process( theObj1, anImgClipPath ); } diff --git a/src/ImageComposer/ImageComposer_CropOperator.h b/src/ImageComposer/ImageComposer_CropOperator.h index e1740c332..20a5ee4ad 100644 --- a/src/ImageComposer/ImageComposer_CropOperator.h +++ b/src/ImageComposer/ImageComposer_CropOperator.h @@ -16,32 +16,21 @@ public: ImageComposer_CropOperator(); virtual ~ImageComposer_CropOperator(); - void setArgs( const QColor& theBackground, const QRect& ); - void setArgs( const QColor& theBackground, const QPainterPath& ); - - QPainterPath clipPath() const; - static QString Type() { return "crop"; } virtual QString name() const; - virtual ImageComposer_Image process( const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const; + virtual ImageComposer_Image process( const QVariant& theObj1, + const QVariant& theObj2 ) const; protected: - virtual QRectF calcResultBoundingRect( const QRectF& theImage1Bounds, - const QRectF& theImage2Bounds ) const; - virtual void drawResult( QPainter& thePainter, const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const; - - virtual void storeArgs( QDataStream& theStream ) const; - virtual void restoreArgs( QDataStream& theStream ); + virtual QRectF calcResultBoundingRect( const QVariant& theObj1, + const QVariant& theObj2 ) const; + virtual void drawResult( QPainter& thePainter, const QVariant& theObj1, + const QVariant& theObj2 ) const; private: friend class ImageComposerTests_TestOperators; - - QPainterPath myClipPath; ///< the clipping path specified initially - QPainterPath myImgClipPath; ///< the clipping path mapped to first image's local CS }; #endif diff --git a/src/ImageComposer/ImageComposer_CutOperator.cxx b/src/ImageComposer/ImageComposer_CutOperator.cxx index 25ceb4c83..f0166bcf7 100644 --- a/src/ImageComposer/ImageComposer_CutOperator.cxx +++ b/src/ImageComposer/ImageComposer_CutOperator.cxx @@ -1,6 +1,6 @@ #include "ImageComposer_CutOperator.h" -#include "ImageComposer_Image.h" +#include "ImageComposer_MetaTypes.h" #include #include #include @@ -28,18 +28,33 @@ QString ImageComposer_CutOperator::name() const /** */ -QRectF ImageComposer_CutOperator::calcResultBoundingRect( const QRectF& theImage1Bounds, - const QRectF& ) const +QRectF ImageComposer_CutOperator::calcResultBoundingRect( const QVariant& theObj1, + const QVariant& ) const { - return theImage1Bounds; + QRectF aResRect; + if ( !theObj1.isNull() && theObj1.canConvert() ) + { + ImageComposer_Image anImage1 = theObj1.value(); + aResRect = anImage1.boundingRect(); + } + return aResRect; } /** */ -void ImageComposer_CutOperator::drawResult( QPainter& thePainter, - const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const +void ImageComposer_CutOperator::drawResult( QPainter& thePainter, + const QVariant& theObj1, + const QVariant& theObj2 ) const { - theImage1.draw( thePainter ); - theImage2.draw( thePainter ); + if ( !theObj1.isNull() && theObj1.canConvert() ) + { + ImageComposer_Image anImage1 = theObj1.value(); + anImage1.draw( thePainter ); + } + + if ( !theObj2.isNull() && theObj2.canConvert() ) + { + ImageComposer_Image anImage2 = theObj2.value(); + anImage2.draw( thePainter ); + } } diff --git a/src/ImageComposer/ImageComposer_CutOperator.h b/src/ImageComposer/ImageComposer_CutOperator.h index 15026dc3c..f88ea73bf 100644 --- a/src/ImageComposer/ImageComposer_CutOperator.h +++ b/src/ImageComposer/ImageComposer_CutOperator.h @@ -20,10 +20,10 @@ public: virtual QString name() const; protected: - virtual QRectF calcResultBoundingRect( const QRectF& theImage1Bounds, - const QRectF& theImage2Bounds ) const; - virtual void drawResult( QPainter& thePainter, const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const; + virtual QRectF calcResultBoundingRect( const QVariant& theObj1, + const QVariant& theObj2 ) const; + virtual void drawResult( QPainter& thePainter, const QVariant& theObj1, + const QVariant& theObj2 ) const; }; #endif diff --git a/src/ImageComposer/ImageComposer_FuseOperator.cxx b/src/ImageComposer/ImageComposer_FuseOperator.cxx index e23d58296..2106503f0 100644 --- a/src/ImageComposer/ImageComposer_FuseOperator.cxx +++ b/src/ImageComposer/ImageComposer_FuseOperator.cxx @@ -1,6 +1,6 @@ #include "ImageComposer_FuseOperator.h" -#include "ImageComposer_Image.h" +#include "ImageComposer_MetaTypes.h" #include #include #include @@ -28,18 +28,36 @@ QString ImageComposer_FuseOperator::name() const /** */ -QRectF ImageComposer_FuseOperator::calcResultBoundingRect( const QRectF& theImage1Bounds, - const QRectF& theImage2Bounds ) const +QRectF ImageComposer_FuseOperator::calcResultBoundingRect( const QVariant& theObj1, + const QVariant& theObj2 ) const { - return theImage1Bounds.united( theImage2Bounds ); + QRectF aResRect; + if ( !theObj1.isNull() && theObj1.canConvert() && + !theObj2.isNull() && theObj2.canConvert() ) + { + ImageComposer_Image anImage1 = theObj1.value(); + ImageComposer_Image anImage2 = theObj2.value(); + + aResRect = anImage1.boundingRect().united( anImage2.boundingRect() ); + } + return aResRect; } /** */ -void ImageComposer_FuseOperator::drawResult( QPainter& thePainter, - const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const +void ImageComposer_FuseOperator::drawResult( QPainter& thePainter, + const QVariant& theObj1, + const QVariant& theObj2 ) const { - theImage1.draw( thePainter ); - theImage2.draw( thePainter ); + if ( !theObj1.isNull() && theObj1.canConvert() ) + { + ImageComposer_Image anImage1 = theObj1.value(); + anImage1.draw( thePainter ); + } + + if ( !theObj2.isNull() && theObj2.canConvert() ) + { + ImageComposer_Image anImage2 = theObj2.value(); + anImage2.draw( thePainter ); + } } diff --git a/src/ImageComposer/ImageComposer_FuseOperator.h b/src/ImageComposer/ImageComposer_FuseOperator.h index ac9c5f60b..bdeb5e0f9 100644 --- a/src/ImageComposer/ImageComposer_FuseOperator.h +++ b/src/ImageComposer/ImageComposer_FuseOperator.h @@ -20,10 +20,10 @@ public: virtual QString name() const; protected: - virtual QRectF calcResultBoundingRect( const QRectF& theImage1Bounds, - const QRectF& theImage2Bounds ) const; - virtual void drawResult( QPainter& thePainter, const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const; + virtual QRectF calcResultBoundingRect( const QVariant& theObj1, + const QVariant& theObj2 ) const; + virtual void drawResult( QPainter& thePainter, const QVariant& theObj1, + const QVariant& theObj2 ) const; }; #endif diff --git a/src/ImageComposer/ImageComposer_Image.cxx b/src/ImageComposer/ImageComposer_Image.cxx index a7b1a7e6f..a0e20230a 100644 --- a/src/ImageComposer/ImageComposer_Image.cxx +++ b/src/ImageComposer/ImageComposer_Image.cxx @@ -3,6 +3,8 @@ #include "ImageComposer_CropOperator.h" #include "ImageComposer_CutOperator.h" #include "ImageComposer_FuseOperator.h" +#include "ImageComposer_MetaTypes.h" + #include QColor ImageComposer_Image::myDefaultBackground = TRANSPARENT; @@ -14,6 +16,23 @@ ImageComposer_Image::ImageComposer_Image() { } +/** + Copy constructor +*/ +ImageComposer_Image::ImageComposer_Image( const ImageComposer_Image& theImage ) + : QImage( theImage ), + myTransform( theImage.myTransform ) +{ +} + +/** + Copy constructor +*/ +ImageComposer_Image::ImageComposer_Image( const QImage& theImage ) + : QImage( theImage ) +{ +} + /** Destructor */ @@ -107,9 +126,12 @@ const QImage& ImageComposer_Image::operator = ( const QImage& theImage ) @return the result image */ ImageComposer_Image ImageComposer_Image::apply( const ImageComposer_Operator& theOperator, - const ImageComposer_Image& theImage ) const + const QVariant& theOtherObj ) const { - return theOperator.process( *this, theImage ); + QVariant aVarData; + aVarData.setValue( *this ); + + return theOperator.process( aVarData, theOtherObj ); } /** @@ -137,9 +159,9 @@ void ImageComposer_Image::setDefaultBackground( const QColor& theDefaultBackgrou */ ImageComposer_Image ImageComposer_Image::operator & ( const QRect& theRect ) const { - ImageComposer_CropOperator anOp; - anOp.setArgs( myDefaultBackground, theRect ); - return apply( anOp ); + QPainterPath aPath; + aPath.addRect( theRect ); + return operator &( aPath ); } /** @@ -150,8 +172,12 @@ ImageComposer_Image ImageComposer_Image::operator & ( const QRect& theRect ) con ImageComposer_Image ImageComposer_Image::operator & ( const QPainterPath& thePath ) const { ImageComposer_CropOperator anOp; - anOp.setArgs( myDefaultBackground, thePath ); - return apply( anOp ); + anOp.setArgs( myDefaultBackground ); + + QVariant aVarData; + aVarData.setValue( thePath ); + + return apply( anOp, aVarData ); } /** @@ -163,7 +189,11 @@ ImageComposer_Image ImageComposer_Image::operator & ( const ImageComposer_Image& { ImageComposer_CutOperator anOp; anOp.setArgs( myDefaultBackground ); - return apply( anOp, theImage ); + + QVariant aVarData; + aVarData.setValue( theImage ); + + return apply( anOp, aVarData ); } /** @@ -175,5 +205,9 @@ ImageComposer_Image ImageComposer_Image::operator | ( const ImageComposer_Image& { ImageComposer_FuseOperator anOp; anOp.setArgs( myDefaultBackground ); - return apply( anOp, theImage ); + + QVariant aVarData; + aVarData.setValue( theImage ); + + return apply( anOp, aVarData ); } diff --git a/src/ImageComposer/ImageComposer_Image.h b/src/ImageComposer/ImageComposer_Image.h index fe3db0186..55799631d 100644 --- a/src/ImageComposer/ImageComposer_Image.h +++ b/src/ImageComposer/ImageComposer_Image.h @@ -2,9 +2,11 @@ #ifndef IMAGE_COMPOSER_IMAGE_HEADER #define IMAGE_COMPOSER_IMAGE_HEADER -#include #include "ImageComposer.h" +#include + +class QVariant; class ImageComposer_Operator; /** @@ -15,6 +17,8 @@ class IMAGE_COMPOSER_API ImageComposer_Image : public QImage { public: ImageComposer_Image(); + ImageComposer_Image( const ImageComposer_Image& theImage ); + ImageComposer_Image( const QImage& theImage ); ~ImageComposer_Image(); void draw( QPainter& thePainter ) const; @@ -29,7 +33,7 @@ public: const QImage& operator = ( const QImage& theImage ); ImageComposer_Image apply( const ImageComposer_Operator& theOperator, - const ImageComposer_Image& theImage = ImageComposer_Image() ) const; + const QVariant& theOtherObj ) const; static QColor defaultBackground(); static void setDefaultBackground( const QColor& ); diff --git a/src/ImageComposer/ImageComposer_MetaTypes.h b/src/ImageComposer/ImageComposer_MetaTypes.h new file mode 100644 index 000000000..12096696e --- /dev/null +++ b/src/ImageComposer/ImageComposer_MetaTypes.h @@ -0,0 +1,13 @@ + + +#include "ImageComposer_Image.h" + +#include +#include + +// Here we declare the meta types for classes which used by +// ImageComposer operators so that it could be wrapped to QVariant + +Q_DECLARE_METATYPE(QPainterPath) +Q_DECLARE_METATYPE(ImageComposer_Image) + diff --git a/src/ImageComposer/ImageComposer_Operator.cxx b/src/ImageComposer/ImageComposer_Operator.cxx index e296b4d4d..cb9a75eb0 100644 --- a/src/ImageComposer/ImageComposer_Operator.cxx +++ b/src/ImageComposer/ImageComposer_Operator.cxx @@ -1,6 +1,6 @@ #include "ImageComposer_Operator.h" -#include "ImageComposer_Image.h" +#include "ImageComposer_MetaTypes.h" #include #include @@ -39,25 +39,33 @@ void ImageComposer_Operator::setArgs( const QColor& theBackground ) /** Perform the composing of images - @param theImage1 the first image to compose - @param theImage2 the second image to compose + @param theObj1 the first object to compose + @param theObj2 the second object to compose @return the result image */ -ImageComposer_Image ImageComposer_Operator::process( const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const +ImageComposer_Image ImageComposer_Operator::process( const QVariant& theObj1, + const QVariant& theObj2 ) const { - ImageComposer_Image anImage1 = theImage1; - ImageComposer_Image anImage2 = theImage2; + ImageComposer_Image aResult; + if ( theObj1.isNull() || !theObj1.canConvert() ) + return aResult; + + ImageComposer_Image anImage1 = theObj1.value(); + + ImageComposer_Image anImage2; + if ( !theObj1.isNull() && theObj2.canConvert() ) + anImage2 = theObj2.value(); + QTransform aInvTransform = anImage1.transform().inverted(); anImage1.setTransform( anImage1.transform() * aInvTransform ); if( !anImage2.isNull() ) anImage2.setTransform( anImage2.transform() * aInvTransform ); - QRectF aBounds1 = anImage1.boundingRect(); - QRectF aBounds2; - if( !anImage2.isNull() ) - aBounds2 = anImage2.boundingRect(); - QRectF aBounds = calcResultBoundingRect( aBounds1, aBounds2 ); + QVariant anImage1Var, anImage2Var; + anImage1Var.setValue( anImage1 ); + anImage2Var.setValue( anImage2 ); + + QRectF aBounds = calcResultBoundingRect( anImage1Var, !anImage2.isNull() ? anImage2Var : theObj2 ); QTransform aTranslate; aTranslate.translate( -aBounds.left(), -aBounds.top() ); @@ -72,13 +80,19 @@ ImageComposer_Image ImageComposer_Operator::process( const ImageComposer_Image& aPainter.setRenderHint( QPainter::Antialiasing, true ); aPainter.setRenderHint( QPainter::HighQualityAntialiasing, true ); - drawResult( aPainter, anImage1, anImage2 ); + anImage1Var.setValue( anImage1 ); + anImage2Var.setValue( anImage2 ); - ImageComposer_Image aResult; - aResult = aResultImage.toImage(); - QTransform aResultTransform = theImage1.transform(); + drawResult( aPainter, anImage1Var, !anImage2.isNull() ? anImage2Var : theObj2 ); + + anImage1 = theObj1.value(); + + QTransform aResultTransform = anImage1.transform(); aResultTransform.translate( aBounds.left(), aBounds.top() ); + + aResult = aResultImage.toImage(); aResult.setTransform( aResultTransform ); + return aResult; } diff --git a/src/ImageComposer/ImageComposer_Operator.h b/src/ImageComposer/ImageComposer_Operator.h index ab29b6359..b61a3e2f2 100644 --- a/src/ImageComposer/ImageComposer_Operator.h +++ b/src/ImageComposer/ImageComposer_Operator.h @@ -3,12 +3,14 @@ #define IMAGE_COMPOSER_OPERATOR_HEADER #include "ImageComposer.h" + #include class QString; class QRectF; class QPainter; class QTransform; +class QVariant; class ImageComposer_Image; const QColor TRANSPARENT( 255, 255, 255, 0 ); @@ -42,27 +44,27 @@ public: */ virtual QString name() const = 0; - virtual ImageComposer_Image process( const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const; + virtual ImageComposer_Image process( const QVariant& theObj1, + const QVariant& theObj2 ) const; protected: /** Calculate bounding rectangle for the result image - @param theImage1Bounds bounding rectangle of the first image - @param theImage2Bounds bounding rectangle of the second image + @param theObj1 first object to calculate + @param theObj2 second object to calculate @return calculated bounding rectangle */ - virtual QRectF calcResultBoundingRect( const QRectF& theImage1Bounds, - const QRectF& theImage2Bounds ) const = 0; + virtual QRectF calcResultBoundingRect( const QVariant& theObj1, + const QVariant& theObj2 ) const = 0; /** Draw result image using the given painter @param thePainter the painter on the result image - @param theImage1 the first image to compose - @param theImage2 the second image to compose + @param theObj1 the first object to compose + @param theObj2 the second object to compose */ - virtual void drawResult( QPainter& thePainter, const ImageComposer_Image& theImage1, - const ImageComposer_Image& theImage2 ) const = 0; + virtual void drawResult( QPainter& thePainter, const QVariant& theObj1, + const QVariant& theObj2 ) const = 0; virtual void storeArgs( QDataStream& theStream ) const; virtual void restoreArgs( QDataStream& theStream ); diff --git a/src/ImageComposer/Makefile.am b/src/ImageComposer/Makefile.am index 889c70cc5..df7e00d8e 100644 --- a/src/ImageComposer/Makefile.am +++ b/src/ImageComposer/Makefile.am @@ -21,21 +21,22 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES = libImageComposer.la -salomeinclude_HEADERS = \ -ImageComposer.h \ +salomeinclude_HEADERS = \ +ImageComposer.h \ +ImageComposer_MetaTypes.h \ ImageComposer_ColorMaskOperator.h \ -ImageComposer_CropOperator.h \ -ImageComposer_CutOperator.h \ -ImageComposer_FuseOperator.h \ -ImageComposer_Image.h \ +ImageComposer_CropOperator.h \ +ImageComposer_CutOperator.h \ +ImageComposer_FuseOperator.h \ +ImageComposer_Image.h \ ImageComposer_Operator.h -dist_libImageComposer_la_SOURCES = \ -ImageComposer_ColorMaskOperator.cxx \ -ImageComposer_CropOperator.cxx \ -ImageComposer_CutOperator.cxx \ -ImageComposer_FuseOperator.cxx \ -ImageComposer_Image.cxx \ +dist_libImageComposer_la_SOURCES = \ +ImageComposer_ColorMaskOperator.cxx \ +ImageComposer_CropOperator.cxx \ +ImageComposer_CutOperator.cxx \ +ImageComposer_FuseOperator.cxx \ +ImageComposer_Image.cxx \ ImageComposer_Operator.cxx libImageComposer_la_CPPFLAGS = $(QT_INCLUDES)