Fix manual.tex qmake configuration settings (thanks to Thomas K.!)
[qanava.git] / src / qanGraphicsView.h
blobb77012fc28a3d333deb961b61763b0a6ec831325
1 /*
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)
25 // \date 2006 July 29
26 //-----------------------------------------------------------------------------
29 #ifndef canGraphicsView_h
30 #define canGraphicsView_h
33 // Qanava headers
34 #include "./qanController.h"
37 // QT headers
38 #include <QGraphicsScene>
39 #include <QGraphicsView>
40 #include <QGraphicsItem>
43 //-----------------------------------------------------------------------------
44 namespace qan { // ::qan
46 class GridItem;
48 class GraphicsView : public QGraphicsView
50 Q_OBJECT
52 /*! \name GraphicsView Constructors/Destructors *///-------------------
53 //@{
54 public:
56 GraphicsView( QWidget* parent = 0 );
58 GraphicsView( QGraphicsScene* scene, QWidget* parent = 0 );
60 virtual QSize sizeHint( ) const { return QSize( 300, 250 ); }
61 //@}
62 //---------------------------------------------------------------------
66 /*! \name Grid Management *///-----------------------------------------
67 //@{
68 public:
70 void setGrid( GridItem* grid ) { _grid = grid; }
72 GridItem* getGrid( ) { return _grid; }
74 protected:
76 virtual void drawBackground( QPainter* painter, const QRectF& rect );
78 private:
80 GridItem* _grid;
81 //@}
82 //---------------------------------------------------------------------
86 /*! \name View Controllers Management *///-----------------------------
87 //@{
88 protected:
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 );
102 signals:
104 void itemDoubleClicked( QGraphicsItem* item );
106 public:
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 );
114 private:
116 Controller::Manager _controllerManager;
117 //@}
118 //---------------------------------------------------------------------
122 /*! \name Zoom Management *///----------------------------------------
123 //@{
124 public:
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 );
133 public slots:
135 //! Set the current zoom factor value in percents (from 1 to 100, 100 sets the maximum zoom factor).
136 void setZoomPercent( int value );
138 private:
140 double _zoom;
142 //! Maximum zoom factor (default = 2).
143 double _zoomMaxFactor;
144 //@}
145 //---------------------------------------------------------------------
147 } // ::qan
148 //-----------------------------------------------------------------------------
151 #endif // canGraphicsView_h