Salome HOME
07a0dc526a5caf9d6a2d7d529b0509e78b246a67
[modules/gui.git] / src / ImageComposer / ImageComposer_FuseOperator.cxx
1 // Copyright (C) 2013-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "ImageComposer_FuseOperator.h"
21 #include "ImageComposer_MetaTypes.h"
22 #include <QString>
23 #include <QPixmap>
24 #include <QPainter>
25
26 /**
27   Constructor
28 */
29 ImageComposer_FuseOperator::ImageComposer_FuseOperator()
30   : ImageComposer_Operator()
31 {
32 }
33
34 /**
35 */
36 ImageComposer_FuseOperator::~ImageComposer_FuseOperator()
37 {
38 }
39
40 /**
41 */
42 QString ImageComposer_FuseOperator::name() const
43 {
44   return Type();
45 }
46
47 /**
48 */
49 QRectF ImageComposer_FuseOperator::calcResultBoundingRect( const QVariant& theObj1, 
50                                                            const QVariant& theObj2 ) const
51 {
52   QRectF aResRect;
53   if ( !theObj1.isNull() && theObj1.canConvert<ImageComposer_Image>() &&
54        !theObj2.isNull() && theObj2.canConvert<ImageComposer_Image>() )
55   {
56     ImageComposer_Image anImage1 = theObj1.value<ImageComposer_Image>();
57     ImageComposer_Image anImage2 = theObj2.value<ImageComposer_Image>();
58
59     aResRect = anImage1.boundingRect().united( anImage2.boundingRect() );
60   }
61   return aResRect;
62 }
63
64 /**
65 */
66 void ImageComposer_FuseOperator::drawResult( QPainter&       thePainter,
67                                              const QVariant& theObj1,
68                                              const QVariant& theObj2 ) const
69 {
70   if ( !theObj1.isNull() && theObj1.canConvert<ImageComposer_Image>() )
71   {
72     ImageComposer_Image anImage1 = theObj1.value<ImageComposer_Image>();
73     anImage1.draw( thePainter );
74   }
75
76   if ( !theObj2.isNull() && theObj2.canConvert<ImageComposer_Image>() )
77   {
78     ImageComposer_Image anImage2 = theObj2.value<ImageComposer_Image>();
79     anImage2.draw( thePainter );
80   }
81 }