Version: 9.12.0
GraphicsView_Object.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2023 CEA, EDF, 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 #ifndef GRAPHICSVIEW_OBJECT_H
21 #define GRAPHICSVIEW_OBJECT_H
22 
23 #include "GraphicsView.h"
24 
25 #include "GraphicsView_Defs.h"
26 
27 #include <QGraphicsItemGroup>
28 
30 
31 /*
32  Class : GraphicsView_Object
33  Description : Base class for all objects displayed at the scene
34 */
36 {
37 public:
38  GraphicsView_Object( QGraphicsItem* theParent = 0 );
40 
41  virtual void compute() = 0;
42 
43  virtual void addTo( GraphicsView_ViewPort* theViewPort );
44  virtual void removeFrom( GraphicsView_ViewPort* theViewPort );
45 
46  const QString& getName() const { return myName; }
47  virtual void setName( const QString& theName );
48 
49  virtual int getPriority() const { return myPriority; }
50 
51  virtual bool isOnTop() const { return myIsOnTop; }
52  virtual void setIsOnTop( bool theIsOnTop ) { myIsOnTop = theIsOnTop; }
53 
54  virtual bool hasSpecificZValue() const { return false; }
55 
56  virtual bool isSelectable() const { return true; }
57 
58  virtual bool isMovable() const { return myIsMovable; }
59  virtual void setMovable( bool theMovable ) { myIsMovable = theMovable; }
60 
61  virtual QRectF getRect() const;
62 
63  virtual bool checkHighlight( double theX, double theY, QCursor& theCursor ) const;
64 
65  virtual bool highlight( double theX, double theY );
66  virtual void unhighlight();
67  virtual bool isHighlighted() const { return myIsHighlighted; }
68 
69  virtual bool select( double theX, double theY, const QRectF& theRect );
70  virtual void unselect();
71  virtual bool isSelected() const { return myIsSelected; }
72  virtual void setSelected( bool theState ) { myIsSelected = theState; }
73 
74  virtual void move( double theDX, double theDY, bool theIsAtOnce = false );
75  virtual bool finishMove( bool theStatus );
76  virtual bool isMoving() const { return myIsMoving; }
77  virtual bool isMovingByXAllowed( double /*theDX*/ ) { return true; }
78  virtual bool isMovingByYAllowed( double /*theDY*/ ) { return true; }
79 
80  virtual bool updateScale( bool /*theIsScaleUp*/, bool /*theIsCtrl*/ ) { return false; }
81 
82  virtual QRectF getPullingRect() const { return getRect(); }
83  virtual bool portContains( const QPointF& ) { return false; }
84  virtual bool startPulling( const QPointF& ) { return false; }
85  virtual void pull( const QPointF&,
87  const GraphicsView_ObjectList& ) {}
88  virtual void finishPulling( bool, const GraphicsView_ObjectList& ) {}
89  virtual bool isPulling() { return false; }
90 
91  virtual bool handleMousePress( QGraphicsSceneMouseEvent* ) { return false; }
92  virtual bool handleMouseMove( QGraphicsSceneMouseEvent* ) { return false; }
93  virtual bool handleMouseRelease( QGraphicsSceneMouseEvent* ) { return false; }
94 
95  virtual QTransform getViewTransform() const { return myViewTransform; }
96  virtual void setViewTransform( const QTransform& theTransform );
97 
98 protected:
99  QString myName;
100 
102  bool myIsOnTop;
103 
106 
109 
110  QTransform myViewTransform;
111 };
112 
113 #endif
#define GRAPHICSVIEW_API
Definition: GraphicsView.h:29
QList< GraphicsView_Object * > GraphicsView_ObjectList
Definition: GraphicsView_Defs.h:25
Definition: GraphicsView_Object.h:36
virtual bool isMovable() const
Definition: GraphicsView_Object.h:58
bool myIsMovable
Definition: GraphicsView_Object.h:108
int myPriority
Definition: GraphicsView_Object.h:101
QString myName
Definition: GraphicsView_Object.h:99
virtual void setMovable(bool theMovable)
Definition: GraphicsView_Object.h:59
virtual void compute()=0
virtual int getPriority() const
Definition: GraphicsView_Object.h:49
virtual bool handleMousePress(QGraphicsSceneMouseEvent *)
Definition: GraphicsView_Object.h:91
bool myIsMoving
Definition: GraphicsView_Object.h:107
virtual bool hasSpecificZValue() const
Definition: GraphicsView_Object.h:54
virtual bool isSelectable() const
Definition: GraphicsView_Object.h:56
virtual bool startPulling(const QPointF &)
Definition: GraphicsView_Object.h:84
virtual bool isOnTop() const
Definition: GraphicsView_Object.h:51
bool myIsSelected
Definition: GraphicsView_Object.h:105
virtual void setSelected(bool theState)
Definition: GraphicsView_Object.h:72
virtual bool isHighlighted() const
Definition: GraphicsView_Object.h:67
virtual bool isMovingByXAllowed(double)
Definition: GraphicsView_Object.h:77
virtual bool isPulling()
Definition: GraphicsView_Object.h:89
virtual bool handleMouseRelease(QGraphicsSceneMouseEvent *)
Definition: GraphicsView_Object.h:93
virtual QTransform getViewTransform() const
Definition: GraphicsView_Object.h:95
bool myIsOnTop
Definition: GraphicsView_Object.h:102
const QString & getName() const
Definition: GraphicsView_Object.h:46
bool myIsHighlighted
Definition: GraphicsView_Object.h:104
virtual QRectF getPullingRect() const
Definition: GraphicsView_Object.h:82
QTransform myViewTransform
Definition: GraphicsView_Object.h:110
virtual bool isMovingByYAllowed(double)
Definition: GraphicsView_Object.h:78
virtual bool portContains(const QPointF &)
Definition: GraphicsView_Object.h:83
virtual bool updateScale(bool, bool)
Definition: GraphicsView_Object.h:80
virtual bool isMoving() const
Definition: GraphicsView_Object.h:76
virtual void pull(const QPointF &, GraphicsView_Object *, const GraphicsView_ObjectList &)
Definition: GraphicsView_Object.h:85
virtual void finishPulling(bool, const GraphicsView_ObjectList &)
Definition: GraphicsView_Object.h:88
virtual bool isSelected() const
Definition: GraphicsView_Object.h:71
virtual void setIsOnTop(bool theIsOnTop)
Definition: GraphicsView_Object.h:52
virtual bool handleMouseMove(QGraphicsSceneMouseEvent *)
Definition: GraphicsView_Object.h:92
Definition: GraphicsView_ViewPort.h:41