Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GraphicsView_Object.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2016 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 #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