1 // Copyright (C) 2013-2014 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, or (at your option) any later version.
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; }
58 virtual bool isMovable() const { return myIsMovable; }
59 virtual void setMovable( bool theMovable ) { myIsMovable = theMovable; }
61 virtual QRectF getRect() const;
63 virtual bool checkHighlight( double theX, double theY, QCursor& theCursor ) const;
65 virtual bool highlight( double theX, double theY );
66 virtual void unhighlight();
67 virtual bool isHighlighted() const { return myIsHighlighted; }
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; }
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; }
80 virtual bool updateScale( bool theIsScaleUp, bool theIsCtrl ) { return false; }
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; }
91 virtual bool handleMousePress( QGraphicsSceneMouseEvent* ) { return false; }
92 virtual bool handleMouseMove( QGraphicsSceneMouseEvent* ) { return false; }
93 virtual bool handleMouseRelease( QGraphicsSceneMouseEvent* ) { return false; }
95 virtual QTransform getViewTransform() const { return myViewTransform; }
96 virtual void setViewTransform( const QTransform& theTransform );
104 bool myIsHighlighted;
110 QTransform myViewTransform;