]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
now the operators have constructors without arguments and allows getting/setting...
authorasl <asl@opencascade.com>
Wed, 17 Jul 2013 06:21:33 +0000 (06:21 +0000)
committerasl <asl@opencascade.com>
Wed, 17 Jul 2013 06:21:33 +0000 (06:21 +0000)
12 files changed:
src/ImageComposer/ImageComposer.h
src/ImageComposer/ImageComposer_ColorMaskOperator.cxx
src/ImageComposer/ImageComposer_ColorMaskOperator.h
src/ImageComposer/ImageComposer_CropOperator.cxx
src/ImageComposer/ImageComposer_CropOperator.h
src/ImageComposer/ImageComposer_CutOperator.cxx
src/ImageComposer/ImageComposer_CutOperator.h
src/ImageComposer/ImageComposer_FuseOperator.cxx
src/ImageComposer/ImageComposer_FuseOperator.h
src/ImageComposer/ImageComposer_Image.cxx
src/ImageComposer/ImageComposer_Operator.cxx
src/ImageComposer/ImageComposer_Operator.h

index c759c8f846957c31745eb38e19d093fb1f29d943..13d2d232e0f0f626a7e1e83ca5156fd41c3f9ec7 100644 (file)
@@ -1,7 +1,7 @@
 
 #ifdef WIN32
 
-  #ifdef IMAGECOMPOSER_EXPORTS
+  #ifdef IMAGE_COMPOSER_EXPORTS
     #define IMAGE_COMPOSER_API __declspec( dllexport )
   #else
     #define IMAGE_COMPOSER_API __declspec( dllimport )
index b0ceddc9c02a23df5f0da4d9ae3d8f4966135418..9a1110679db3a28514f4f642f1b04c8602569a1a 100644 (file)
@@ -8,19 +8,11 @@
 
 /**
   Constructor
-  @param theRefColor the color to the searched (the color for mask)
-  @param isMakeTransparent the boolean flag controlling if the pixels with matching color
-                           should be made transparent or one with non-matching color
-  @param theRGBThreshold the threshold for RGB components
-  @param theAlphaThreshold the threshold for Alpha component
 */
-ImageComposer_ColorMaskOperator::ImageComposer_ColorMaskOperator( const QColor& theRefColor,
-                                                                  bool isMakeTransparent,
-                                                                  int theRGBThreshold,
-                                                                  int theAlphaThreshold )
-: ImageComposer_Operator( TRANSPARENT ),
-  myRefColor( theRefColor ), myIsMakeTransparent( isMakeTransparent ),
-  myRGBThreshold( theRGBThreshold ), myAlphaThreshold( theAlphaThreshold )
+ImageComposer_ColorMaskOperator::ImageComposer_ColorMaskOperator()
+: ImageComposer_Operator(),
+  myRefColor( Qt::black ), myIsMakeTransparent( false ),
+  myRGBThreshold( 0 ), myAlphaThreshold( 0 )
 {
 }
 
@@ -30,6 +22,25 @@ ImageComposer_ColorMaskOperator::~ImageComposer_ColorMaskOperator()
 {
 }
 
+/**
+  Set operator arguments
+  @param theRefColor the color to the searched (the color for mask)
+  @param isMakeTransparent the boolean flag controlling if the pixels with matching color
+                           should be made transparent or one with non-matching color
+  @param theRGBThreshold the threshold for RGB components
+  @param theAlphaThreshold the threshold for Alpha component
+*/
+void ImageComposer_ColorMaskOperator::setArgs( const QColor& theRefColor,
+                                               bool isMakeTransparent,
+                                               int theRGBThreshold,
+                                               int theAlphaThreshold )
+{
+  myRefColor = theRefColor;
+  myIsMakeTransparent = isMakeTransparent;
+  myRGBThreshold = theRGBThreshold;
+  myAlphaThreshold = theAlphaThreshold;
+}
+
 /**
 */
 QString ImageComposer_ColorMaskOperator::name() const
@@ -84,3 +95,21 @@ void ImageComposer_ColorMaskOperator::drawResult( QPainter& thePainter,
   aResult.setTransform( theImage1.transform() );
   aResult.draw( thePainter );
 }
+
+void ImageComposer_ColorMaskOperator::storeArgs( QDataStream& theStream ) const
+{
+  ImageComposer_Operator::storeArgs( theStream );
+  theStream << myRefColor;
+  theStream << myIsMakeTransparent;
+  theStream << myRGBThreshold;
+  theStream << myAlphaThreshold;
+}
+
+void ImageComposer_ColorMaskOperator::restoreArgs( QDataStream& theStream )
+{
+  ImageComposer_Operator::restoreArgs( theStream );
+  theStream >> myRefColor;
+  theStream >> myIsMakeTransparent;
+  theStream >> myRGBThreshold;
+  theStream >> myAlphaThreshold;
+}
index 15b15aa6d90a539c0887273579f17f383d3d6003..d3b6ec67c0372fd5dd5639827e3a5a7517d4eb6d 100644 (file)
 class IMAGE_COMPOSER_API ImageComposer_ColorMaskOperator : public ImageComposer_Operator
 {
 public:
-  ImageComposer_ColorMaskOperator( const QColor& theRefColor,
-                                   bool isMakeTransparent,
-                                   int theRGBThreshold,
-                                   int theAlphaThreshold );
+  ImageComposer_ColorMaskOperator();
   virtual ~ImageComposer_ColorMaskOperator();
 
+  void setArgs( const QColor& theRefColor,
+                bool isMakeTransparent,
+                int theRGBThreshold,
+                int theAlphaThreshold );
+
   virtual QString name() const;
 
 protected:
@@ -26,7 +28,12 @@ protected:
   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 );
+
 private:
+  friend class ImageComposerTests_TestOperators;
+
   QColor myRefColor;         ///< the color to the searched (the color for mask)
   bool myIsMakeTransparent;  ///< the boolean flag controlling if the pixels with matching color
                              ///< should be made transparent or one with non-matching color
index a1de87547dc1a09af3b8d82afc6b80c3b5d2bc27..bacee5a7f90308d3c6d8a9b9777d0e747096e1ce 100644 (file)
@@ -6,30 +6,39 @@
 
 /**
   Constructor
-  @param theBackground the background color for result image
-  @param theRect the cropping rectangle (in the global CS)
 */
-ImageComposer_CropOperator::ImageComposer_CropOperator( const QColor& theBackground, const QRect& theRect )
-: ImageComposer_Operator( theBackground )
+ImageComposer_CropOperator::ImageComposer_CropOperator()
+: ImageComposer_Operator()
 {
-  myClipPath.addRect( theRect );
 }
 
 /**
-  Constructor
+*/
+ImageComposer_CropOperator::~ImageComposer_CropOperator()
+{
+}
+
+/**
+  Set operator arguments
   @param theBackground the background color for result image
-  @param thePath the cropping path (in the global CS)
+  @param theRect the cropping rectangle (in the global CS)
 */
-ImageComposer_CropOperator::ImageComposer_CropOperator( const QColor& theBackground, const QPainterPath& thePath )
-: ImageComposer_Operator( theBackground )
+void ImageComposer_CropOperator::setArgs( const QColor& theBackground, const QRect& theRect )
 {
-  myClipPath = thePath;
+  ImageComposer_Operator::setArgs( theBackground );
+  myClipPath = QPainterPath();
+  myClipPath.addRect( theRect );
 }
 
 /**
+  Set operator arguments
+  @param theBackground the background color for result image
+  @param thePath the cropping path (in the global CS)
 */
-ImageComposer_CropOperator::~ImageComposer_CropOperator()
+void ImageComposer_CropOperator::setArgs( const QColor& theBackground, const QPainterPath& thePath )
 {
+  ImageComposer_Operator::setArgs( theBackground );
+  myClipPath = thePath;
 }
 
 /**
@@ -84,3 +93,16 @@ ImageComposer_Image ImageComposer_CropOperator::process( const ImageComposer_Ima
 
   return ImageComposer_Operator::process( theImage1, theImage2 );
 }
+
+
+void ImageComposer_CropOperator::storeArgs( QDataStream& theStream ) const
+{
+  ImageComposer_Operator::storeArgs( theStream );
+  theStream << myClipPath;
+}
+
+void ImageComposer_CropOperator::restoreArgs( QDataStream& theStream )
+{
+  ImageComposer_Operator::restoreArgs( theStream );
+  theStream >> myClipPath;
+}
index a359249fd543469aedc43cbb7f718e84c2ee5a23..d4a545990cb257ad7edf11a202b1ee998129ebbc 100644 (file)
 class IMAGE_COMPOSER_API ImageComposer_CropOperator : public ImageComposer_Operator
 {
 public:
-  ImageComposer_CropOperator( const QColor& theBackground, const QRect& );
-  ImageComposer_CropOperator( const QColor& theBackground, const QPainterPath& );
+  ImageComposer_CropOperator();
   virtual ~ImageComposer_CropOperator();
 
+  void setArgs( const QColor& theBackground, const QRect& );
+  void setArgs( const QColor& theBackground, const QPainterPath& );
+
   QPainterPath clipPath() const;
 
   virtual QString name() const;
@@ -29,7 +31,12 @@ protected:
   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 );
+
 private:
+  friend class ImageComposerTests_TestOperators;
+
   QPainterPath myClipPath;     ///< the clipping path specified initially
   QPainterPath myImgClipPath;  ///< the clipping path mapped to first image's local CS
 };
index f516235b40a7894a3ab8bf1fcd32d3c0f330961e..07af47e45e04fea58d8efaa515c9ee154be068ee 100644 (file)
@@ -7,10 +7,9 @@
 
 /**
   Constructor
-  @param theBackground the background color for result image
 */
-ImageComposer_CutOperator::ImageComposer_CutOperator( const QColor& theBackground )
-  : ImageComposer_Operator( theBackground )
+ImageComposer_CutOperator::ImageComposer_CutOperator()
+  : ImageComposer_Operator()
 {
 }
 
index 4df8224a857cbb2db7a93c8ca08fe31c6e68da71..fd12d3a2b037a49ce3f03bf6f5ba18de39661859 100644 (file)
@@ -12,7 +12,7 @@
 class IMAGE_COMPOSER_API ImageComposer_CutOperator : public ImageComposer_Operator
 {
 public:
-  ImageComposer_CutOperator( const QColor& theBackground );
+  ImageComposer_CutOperator();
   virtual ~ImageComposer_CutOperator();
 
   virtual QString name() const;
index 2c314e2e8d1219fac3ba15d365e4dcc1d1e68939..9012f8af97c72ca3a8f40d76a8e4236ce6f901ea 100644 (file)
@@ -7,10 +7,9 @@
 
 /**
   Constructor
-  @param theBackground the background color for result image
 */
-ImageComposer_FuseOperator::ImageComposer_FuseOperator( const QColor& theBackground )
-  : ImageComposer_Operator( theBackground )
+ImageComposer_FuseOperator::ImageComposer_FuseOperator()
+  : ImageComposer_Operator()
 {
 }
 
index cffc368bfaf1dc36a3f42a63adf360fbd5adf5c1..a6ad4c001abe8cb54158d4abd2f2ee35e4b25fff 100644 (file)
@@ -12,7 +12,7 @@
 class IMAGE_COMPOSER_API ImageComposer_FuseOperator : public ImageComposer_Operator
 {
 public:
-  ImageComposer_FuseOperator( const QColor& theBackground );
+  ImageComposer_FuseOperator();
   virtual ~ImageComposer_FuseOperator();
 
   virtual QString name() const;
index d08eb7b64f38fa62db98ea224803901a6860bd7e..1d9ede6dc05f28527f1499eb3a251abe6fb1778b 100644 (file)
@@ -137,7 +137,9 @@ void ImageComposer_Image::setDefaultBackground( const QColor& theDefaultBackgrou
 */
 ImageComposer_Image ImageComposer_Image::operator & ( const QRect& theRect ) const
 {
-  return apply( ImageComposer_CropOperator( myDefaultBackground, theRect ) );
+  ImageComposer_CropOperator anOp;
+  anOp.setArgs( myDefaultBackground, theRect );
+  return apply( anOp );
 }
 
 /**
@@ -147,7 +149,9 @@ ImageComposer_Image ImageComposer_Image::operator & ( const QRect& theRect ) con
 */
 ImageComposer_Image ImageComposer_Image::operator & ( const QPainterPath& thePath ) const
 {
-  return apply( ImageComposer_CropOperator( myDefaultBackground, thePath ) );
+  ImageComposer_CropOperator anOp;
+  anOp.setArgs( myDefaultBackground, thePath );
+  return apply( anOp );
 }
 
 /**
@@ -157,7 +161,9 @@ ImageComposer_Image ImageComposer_Image::operator & ( const QPainterPath& thePat
 */
 ImageComposer_Image ImageComposer_Image::operator & ( const ImageComposer_Image& theImage ) const
 {
-  return apply( ImageComposer_CutOperator( myDefaultBackground ), theImage );
+  ImageComposer_CutOperator anOp;
+  anOp.setArgs( myDefaultBackground );
+  return apply( anOp, theImage );
 }
 
 /**
@@ -167,5 +173,7 @@ ImageComposer_Image ImageComposer_Image::operator & ( const ImageComposer_Image&
 */
 ImageComposer_Image ImageComposer_Image::operator | ( const ImageComposer_Image& theImage ) const
 {
-  return apply( ImageComposer_FuseOperator( myDefaultBackground ), theImage );
+  ImageComposer_FuseOperator anOp;
+  anOp.setArgs( myDefaultBackground );
+  return apply( anOp, theImage );
 }
index 451629cfa9165bd55c5eebcf08936944b1532991..882015e3f73d35c3260c8946aa5b6e5a3b9cdfb8 100644 (file)
@@ -6,10 +6,9 @@
 
 /**
   Constructor
-  @param theBackground the background color for result image
 */
-ImageComposer_Operator::ImageComposer_Operator( const QColor& theBackground )
-: myBackground( theBackground )
+ImageComposer_Operator::ImageComposer_Operator()
+: myBackground( TRANSPARENT )
 {
 }
 
@@ -20,6 +19,15 @@ ImageComposer_Operator::~ImageComposer_Operator()
 {
 }
 
+/**
+  Set operator arguments
+  @param theBackground the background color for result image
+*/
+void ImageComposer_Operator::setArgs( const QColor& theBackground )
+{
+  myBackground = theBackground;
+}
+
 /**
   Return name of the operator
    @return name of the operator
@@ -73,3 +81,43 @@ ImageComposer_Image ImageComposer_Operator::process( const ImageComposer_Image&
   aResult.setTransform( aResultTransform );
   return aResult;
 }
+
+/**
+  Get the operator's arguments in the form of a binary array
+  @return the binary array with arguments
+*/
+QByteArray ImageComposer_Operator::getBinArgs() const
+{
+  QByteArray aData;
+  QDataStream aStream( &aData, QIODevice::WriteOnly );
+  storeArgs( aStream );
+  return aData;
+}
+
+/**
+  Set the operator's arguments in the form of a binary array
+  @param theData the binary array with arguments
+*/
+void ImageComposer_Operator::setBinArgs( const QByteArray& theData )
+{
+  QDataStream aStream( theData );
+  restoreArgs( aStream );
+}
+
+/**
+  Store the operator's arguments to the stream
+  @param theStream the stream for storing
+*/
+void ImageComposer_Operator::storeArgs( QDataStream& theStream ) const
+{
+  theStream << myBackground;
+}
+
+/**
+  Restore the operator's arguments from the stream
+  @param theStream the stream for restoring
+*/
+void ImageComposer_Operator::restoreArgs( QDataStream& theStream )
+{
+  theStream >> myBackground;
+}
index 3a21be3fa21c36c7e0d5954c810b680a5f5fb337..b54552ddb63566110c96fbebb2e7e9f11f017eca 100644 (file)
@@ -20,9 +20,13 @@ const QColor TRANSPARENT( 255, 255, 255, 0 );
 class IMAGE_COMPOSER_API ImageComposer_Operator
 {
 public:
-  ImageComposer_Operator( const QColor& theBackground );
+  ImageComposer_Operator();
   virtual ~ImageComposer_Operator();
 
+  void setArgs( const QColor& theBackground );
+  QByteArray getBinArgs() const;
+  void setBinArgs( const QByteArray& );
+
   virtual QString name() const;
   virtual ImageComposer_Image process( const ImageComposer_Image& theImage1,
                                        const ImageComposer_Image& theImage2 ) const;
@@ -46,7 +50,12 @@ protected:
   virtual void drawResult( QPainter& thePainter, const ImageComposer_Image& theImage1,
                                                  const ImageComposer_Image& theImage2 ) const = 0;
 
+  virtual void storeArgs( QDataStream& theStream ) const;
+  virtual void restoreArgs( QDataStream& theStream );
+
 private:
+  friend class ImageComposerTests_TestOperators;
+
   QColor myBackground;  ///< the background color for result image
 };