Salome HOME
Fix for the bug #42: point C is not activated, but point C is shown in preview in...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PrsImage.h
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROGUI_PRSIMAGE_H
24 #define HYDROGUI_PRSIMAGE_H
25
26 #include "HYDROGUI_Prs.h"
27
28 class HYDROGUI_PrsImageFrame;
29
30 /*
31   Class       : HYDROGUI_PrsImage
32   Description : Presentation for image object
33 */
34 class HYDROGUI_PrsImage : public HYDROGUI_Prs
35 {
36 public:
37   enum TransformationPointType { None = 0, PointA, PointB, PointC };
38   struct TransformationPoint
39   {
40     QPoint                   Point;
41     QString                  Caption;
42     QGraphicsEllipseItem*    PointItem;
43     QGraphicsSimpleTextItem* CaptionItem;
44   };
45   typedef QMap        < int, TransformationPoint > TransformationPointMap;
46   typedef QMapIterator< int, TransformationPoint > TransformationPointMapIterator;
47
48 public:
49   HYDROGUI_PrsImage( const Handle(HYDROData_Entity)& theObject );
50   virtual ~HYDROGUI_PrsImage();
51
52 public:
53   void                            setImage( const QImage& theImage );
54   QImage                          getImage() const;
55
56   void                            setCaption( const QString& theCaption );
57   QString                         getCaption() const;
58
59   void                            setIsTransformationPointPreview( const bool theState );
60   bool                            getIsTransformationPointPreview() const;
61
62   void                            setIsByTwoPoints( const bool theIsByTwoPoints );
63   bool                            getIsByTwoPoints() const;
64
65   void                            setTransformationPointType( const int thePointType );
66
67   void                            setTransformationPointMap( const TransformationPointMap& theMap );
68   const TransformationPointMap&   getTransformationPointMap() const { return myTransformationPointMap; }
69
70   void                            updateTransformationPoint( const int thePointType,
71                                                              const bool theIsY,
72                                                              const int theValue );
73
74 public:
75   // from QGraphicsItem
76   virtual QRectF                  boundingRect() const;
77
78   // from GraphicsView_Object
79   virtual void                    compute();
80
81   virtual void                    addTo( GraphicsView_ViewPort* theViewPort );
82   virtual void                    removeFrom( GraphicsView_ViewPort* theViewPort );
83
84   virtual bool                    isMovable() const { return false; }
85
86   virtual bool                    checkHighlight( double theX, double theY, QCursor& theCursor ) const;
87
88   virtual bool                    select( double theX, double theY, const QRectF& theRect );
89   virtual void                    unselect();
90   virtual void                    setSelected( bool theState );
91
92 protected:
93   void                            computeTransformationPoints();
94   /**
95    * Show/hide a transformation point if necessary.
96    */
97   void                            updateTrsfPoint( const int thePointType );
98
99 protected:
100   QCursor*                        getTransformationPointCursor() const { return myTransformationPointCursor; }
101
102 protected:
103   QImage                          myImage;
104
105   QGraphicsPixmapItem*            myPixmapItem;
106   QGraphicsSimpleTextItem*        myCaptionItem;
107   HYDROGUI_PrsImageFrame*         myPrsImageFrame;
108
109   bool                            myIsTransformationPointPreview;
110   bool                            myIsByTwoPoints;
111   int                             myTransformationPointType;
112   TransformationPointMap          myTransformationPointMap;
113
114 private:
115   QCursor*                        myTransformationPointCursor;
116 };
117
118 #endif