1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2011 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
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.
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
21 #include "landscape_editor_global.h"
24 #include <QtGui/QGraphicsView>
25 #include <QtGui/QWheelEvent>
27 namespace LandscapeEditor
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
40 explicit LandscapeView(QWidget
*parent
= 0);
41 virtual ~LandscapeView();
43 //Set the current centerpoint in the
44 void setCenter(const QPointF
¢erPoint
);
45 QPointF
getCenter() const;
47 bool isVisibleGrid() const;
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
);
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
);
71 bool m_visibleGrid
, m_visibleText
;
72 qreal m_maxView
, m_minView
, m_maxViewText
;
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