New lua versions
[ryzomcore.git] / studio / src / plugins / landscape_editor / landscape_view.h
blob2b20bf7490eb5f523fe0456330bfbfd6d147a864
1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2011 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef LANDSCAPE_VIEW_H
18 #define LANDSCAPE_VIEW_H
20 // Project includes
21 #include "landscape_editor_global.h"
23 // Qt includes
24 #include <QtGui/QGraphicsView>
25 #include <QtGui/QWheelEvent>
27 namespace LandscapeEditor
30 /**
31 @class LandscapeView
32 @brief Provides graphics view for viewing zone regions.
33 @details Also provides zooming, panning and displaying grid
35 class LANDSCAPE_EDITOR_EXPORT LandscapeView: public QGraphicsView
37 Q_OBJECT
39 public:
40 explicit LandscapeView(QWidget *parent = 0);
41 virtual ~LandscapeView();
43 //Set the current centerpoint in the
44 void setCenter(const QPointF &centerPoint);
45 QPointF getCenter() const;
47 bool isVisibleGrid() const;
49 public Q_SLOTS:
51 /// Enable/disable displaying grid.
52 void setVisibleGrid(bool visible);
54 /// Enable/disable displaying text(coord.) above each zone bricks.
55 void setVisibleText(bool visible);
57 private Q_SLOTS:
58 protected:
59 //Take over the interaction
60 virtual void wheelEvent(QWheelEvent *event);
61 virtual void mousePressEvent(QMouseEvent *event);
62 virtual void mouseMoveEvent(QMouseEvent *event);
63 virtual void mouseReleaseEvent(QMouseEvent *event);
64 virtual void drawForeground(QPainter *painter, const QRectF &rect);
65 virtual void resizeEvent(QResizeEvent *event);
67 void drawGrid(QPainter *painter, const QRectF &rect);
68 void drawZoneNames(QPainter *painter, const QRectF &rect);
69 private:
71 bool m_visibleGrid, m_visibleText;
72 qreal m_maxView, m_minView, m_maxViewText;
73 int m_cellSize;
75 //Holds the current centerpoint for the view, used for panning and zooming
76 QPointF m_currentCenterPoint;
78 //From panning the view
79 QPoint m_lastPanPoint;
80 }; /* class LandscapeView */
82 } /* namespace LandscapeEditor */
84 #endif // LANDSCAPE_VIEW_H