2 Qanava - Graph drawing library for QT
3 Copyright (C) 2006 Benoit AUTHEMAN
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //-----------------------------------------------------------------------------
21 // This file is a part of the Qanava software.
23 // \file canGraphicsView.h
24 // \author Benoit Autheman (benoit@libqanava.org)
26 //-----------------------------------------------------------------------------
29 #ifndef canGraphicsView_h
30 #define canGraphicsView_h
34 #include "./qanController.h"
38 #include <QGraphicsScene>
39 #include <QGraphicsView>
40 #include <QGraphicsItem>
43 //-----------------------------------------------------------------------------
44 namespace qan
{ // ::qan
48 class GraphicsView
: public QGraphicsView
52 /*! \name GraphicsView Constructors/Destructors *///-------------------
56 GraphicsView( QWidget
* parent
= 0 );
58 GraphicsView( QGraphicsScene
* scene
, QWidget
* parent
= 0 );
60 virtual QSize
sizeHint( ) const { return QSize( 300, 250 ); }
62 //---------------------------------------------------------------------
66 /*! \name Grid Management *///-----------------------------------------
70 void setGrid( GridItem
* grid
) { _grid
= grid
; }
72 GridItem
* getGrid( ) { return _grid
; }
76 virtual void drawBackground( QPainter
* painter
, const QRectF
& rect
);
82 //---------------------------------------------------------------------
86 /*! \name View Controllers Management *///-----------------------------
90 virtual void keyPressEvent( QKeyEvent
* e
);
92 virtual void mousePressEvent( QMouseEvent
* e
);
94 virtual void mouseReleaseEvent( QMouseEvent
* e
);
96 virtual void mouseMoveEvent( QMouseEvent
* e
);
98 virtual void mouseDoubleClickEvent( QMouseEvent
* e
);
100 virtual void wheelEvent( QWheelEvent
* e
);
104 void itemDoubleClicked( QGraphicsItem
* item
);
108 //! Get this item view controller manager.
109 Controller::Manager
& getControllerManager( ) { return _controllerManager
; }
111 //! Get the action for a controller with a given name.
112 QAction
* getAction( QString name
);
116 Controller::Manager _controllerManager
;
118 //---------------------------------------------------------------------
122 /*! \name Zoom Management *///----------------------------------------
126 //! Set the maximum zoom factor that can be sets with the setZoomValue() method.
127 void setZoomMaxFactor( double zoomMaxFactor
) { _zoomMaxFactor
= zoomMaxFactor
; }
129 double getZoom( ) const { return _zoom
; }
131 void setZoom( double zoom
);
135 //! Set the current zoom factor value in percents (from 1 to 100, 100 sets the maximum zoom factor).
136 void setZoomPercent( int value
);
142 //! Maximum zoom factor (default = 2).
143 double _zoomMaxFactor
;
145 //---------------------------------------------------------------------
148 //-----------------------------------------------------------------------------
151 #endif // canGraphicsView_h