1 // Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef GRAPHICSVIEW_OBJECT_H
21 #define GRAPHICSVIEW_OBJECT_H
23 #include "GraphicsView.h"
25 #include "GraphicsView_Defs.h"
27 #include <QGraphicsItemGroup>
29 class GraphicsView_ViewPort;
32 Class : GraphicsView_Object
33 Description : Base class for all objects displayed at the scene
35 class GRAPHICSVIEW_API GraphicsView_Object : public QGraphicsItemGroup
38 GraphicsView_Object( QGraphicsItem* theParent = 0 );
39 ~GraphicsView_Object();
41 virtual void compute() = 0;
43 virtual void addTo( GraphicsView_ViewPort* theViewPort );
44 virtual void removeFrom( GraphicsView_ViewPort* theViewPort );
46 const QString& getName() const { return myName; }
47 virtual void setName( const QString& theName );
49 virtual int getPriority() const { return myPriority; }
51 virtual bool isOnTop() const { return myIsOnTop; }
52 virtual void setIsOnTop( bool theIsOnTop ) { myIsOnTop = theIsOnTop; }
54 virtual bool hasSpecificZValue() const { return false; }
56 virtual bool isSelectable() const { return true; }
57 virtual bool isMovable() const { return true; }
59 virtual QRectF getRect() const;
61 virtual bool checkHighlight( double theX, double theY, QCursor& theCursor ) const;
63 virtual bool highlight( double theX, double theY );
64 virtual void unhighlight();
65 virtual bool isHighlighted() const { return myIsHighlighted; }
67 virtual bool select( double theX, double theY, const QRectF& theRect );
68 virtual void unselect();
69 virtual bool isSelected() const { return myIsSelected; }
70 virtual void setSelected( bool theState ) { myIsSelected = theState; }
72 virtual void move( double theDX, double theDY, bool theIsAtOnce = false );
73 virtual bool finishMove( bool theStatus );
74 virtual bool isMoving() const { return myIsMoving; }
75 virtual bool isMovingByXAllowed( double theDX ) { return true; }
76 virtual bool isMovingByYAllowed( double theDY ) { return true; }
78 virtual bool updateScale( bool theIsScaleUp, bool theIsCtrl ) { return false; }
80 virtual QRectF getPullingRect() const { return getRect(); }
81 virtual bool portContains( const QPointF& ) { return false; }
82 virtual bool startPulling( const QPointF& ) { return false; }
83 virtual void pull( const QPointF&,
85 const GraphicsView_ObjectList& ) {}
86 virtual void finishPulling( bool, const GraphicsView_ObjectList& ) {}
87 virtual bool isPulling() { return false; }
89 virtual bool handleMousePress( QGraphicsSceneMouseEvent* ) { return false; }
90 virtual bool handleMouseMove( QGraphicsSceneMouseEvent* ) { return false; }
91 virtual bool handleMouseRelease( QGraphicsSceneMouseEvent* ) { return false; }
93 virtual QTransform getViewTransform() const { return myViewTransform; }
94 virtual void setViewTransform( const QTransform& theTransform );
102 bool myIsHighlighted;
107 QTransform myViewTransform;