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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROGUI_PRSIMAGE_H
20 #define HYDROGUI_PRSIMAGE_H
22 #include "HYDROGUI_Prs.h"
24 class HYDROGUI_PrsImageFrame;
27 Class : HYDROGUI_PrsImage
28 Description : Presentation for image object
30 class HYDROGUI_PrsImage : public HYDROGUI_Prs
33 enum TransformationPointType { None = 0, PointA, PointB, PointC };
34 struct TransformationPoint
36 TransformationPoint() : Point( 0, 0 ), Caption( "" ), GroupItem( 0 ) {}
40 QGraphicsItemGroup* GroupItem;
42 typedef QMap < int, TransformationPoint > TransformationPointMap;
43 typedef QMapIterator< int, TransformationPoint > TransformationPointMapIterator;
46 HYDROGUI_PrsImage( const Handle(HYDROData_Entity)& theObject );
47 virtual ~HYDROGUI_PrsImage();
50 void setImage( const QImage& theImage,
51 const bool theCompute = false );
52 QImage getImage() const;
54 void setCaption( const QString& theCaption );
55 QString getCaption() const;
57 void setIsTransformationPointPreview( const bool theState );
58 bool getIsTransformationPointPreview() const;
60 void setIsByTwoPoints( const bool theIsByTwoPoints );
61 bool getIsByTwoPoints() const;
63 void setTransformationPointType( const int thePointType );
65 void setTransformationPointMap( const TransformationPointMap& theMap );
66 const TransformationPointMap& getTransformationPointMap() const { return myTransformationPointMap; }
68 void updateTransformationPoint( const int thePointType,
73 * Set shape of the transformation point cursor.
74 * @param theCursorShape a cursor shape to be set
76 void setTransformationPointCursorShape(Qt::CursorShape theCursorShape);
80 virtual QRectF boundingRect() const;
82 // from GraphicsView_Object
83 virtual void compute();
85 virtual void addTo( GraphicsView_ViewPort* theViewPort );
86 virtual void removeFrom( GraphicsView_ViewPort* theViewPort );
88 virtual bool isMovable() const { return false; }
90 virtual bool checkHighlight( double theX, double theY, QCursor& theCursor ) const;
92 virtual bool select( double theX, double theY, const QRectF& theRect );
93 virtual void unselect();
94 virtual void setSelected( bool theState );
97 void computeTransformationPoints( const bool theObligatoryInit = false );
99 QGraphicsItemGroup* createPointItem( const QString& theCaption,
100 const QColor& theColor );
103 * Create presentations for transformation points A, B and C or update the presentation
104 * parameters if it is already created
106 void initTrsfPoints( const int thePointType );
108 * Show/hide a transformation point if necessary.
110 void updateTrsfPoint( const int thePointType );
113 QCursor* getTransformationPointCursor() const { return myTransformationPointCursor; }
118 QGraphicsPixmapItem* myPixmapItem;
119 QGraphicsSimpleTextItem* myCaptionItem;
120 HYDROGUI_PrsImageFrame* myPrsImageFrame;
122 bool myIsTransformationPointPreview;
123 bool myIsByTwoPoints;
124 int myTransformationPointType;
125 TransformationPointMap myTransformationPointMap;
128 QCursor* myTransformationPointCursor;