Salome HOME
LOT 15
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PrsImageFrame.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18 #ifndef HYDROGUI_PRSIMAGEFRAME_H
19 #define HYDROGUI_PRSIMAGEFRAME_H
20
21 #include <GraphicsView_Object.h>
22
23 #include <QGraphicsEllipseItem>
24
25 class HYDROGUI_PrsImage;
26
27 /*
28   Class       : HYDROGUI_PrsImageFrame
29   Description : Presentation for image frame object
30 */
31 class HYDROGUI_PrsImageFrame : public GraphicsView_Object
32 {
33 public:
34   class UnscaledGraphicsEllipseItem;
35
36   enum AnchorType { Undefined = 0, TopLeft, TopRight, BottomLeft, BottomRight };
37
38   typedef QMap        <int, UnscaledGraphicsEllipseItem*> AnchorMap;
39   typedef QMapIterator<int, UnscaledGraphicsEllipseItem*> AnchorMapIterator;
40
41 public:
42   HYDROGUI_PrsImageFrame( HYDROGUI_PrsImage* thePrsImage );
43   virtual ~HYDROGUI_PrsImageFrame();
44
45 public:
46   // from QGraphicsItem
47   virtual QRectF                  boundingRect() const;
48
49   // from GraphicsView_Object
50   virtual void                    compute();
51
52   virtual bool                    hasSpecificZValue() const { return true; }
53
54   virtual bool                    isSelectable() const { return false; }
55   virtual bool                    isMovable() const { return false; }
56
57 public:
58   void                            computeAnchorItems();
59   void                            updateVisibility();
60
61 protected:
62   HYDROGUI_PrsImage*              myPrsImage;
63   AnchorMap                       myAnchorMap;
64 };
65
66 /*
67   Class       : UnscaledGraphicsEllipseItem
68   Description : Class for unscaled ellipse item
69 */
70 class HYDROGUI_PrsImageFrame::UnscaledGraphicsEllipseItem : public QGraphicsEllipseItem
71 {
72 public:
73   UnscaledGraphicsEllipseItem( QGraphicsItem* );
74   virtual ~UnscaledGraphicsEllipseItem();
75
76 public:
77   void           setBasePoint( const QPointF& thePoint ) { myBasePoint = thePoint; }
78   const QPointF& getBasePoint() const { return myBasePoint; }
79
80 public:
81   virtual QRectF boundingRect() const;
82   virtual void   paint( QPainter*, const QStyleOptionGraphicsItem*, QWidget* );
83
84 private:
85   QPointF        myBasePoint;
86 };
87
88 #endif