New lua versions
[ryzomcore.git] / studio / src / plugins / landscape_editor / landscape_scene.h
blob9d77fe7c47def8e65a82a9853d34b7e81ad0cdf5
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 source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef LANDSCAPE_SCENE_H
21 #define LANDSCAPE_SCENE_H
23 // Project includes
24 #include "zone_region_editor.h"
25 #include "builder_zone.h"
26 #include "landscape_editor_global.h"
28 // NeL includes
29 #include <nel/ligo/zone_region.h>
31 // Qt includes
32 #include <QtGui/QGraphicsScene>
33 #include <QtGui/QGraphicsSceneMouseEvent>
35 namespace LandscapeEditor
38 /**
39 @class LandscapeScene
40 @brief
41 @details
43 class LandscapeScene : public QGraphicsScene
45 Q_OBJECT
47 public:
48 LandscapeScene(int sizeCell = 160, QObject *parent = 0);
49 virtual ~LandscapeScene();
51 int cellSize() const;
52 void setZoneBuilder(ZoneBuilder *zoneBuilder);
54 QGraphicsItem *createItemZone(const LigoData &data, const ZonePosition &zonePos);
55 QGraphicsItem *createItemEmptyZone(const ZonePosition &zonePos);
56 QGraphicsRectItem *createLayerBlackout(const NLLIGO::CZoneRegion &zoneRegion);
57 void deleteItemZone(const ZonePosition &zonePos);
59 void addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
60 void delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion);
62 void snapshot(const QString &fileName, int width, int height, const QRectF &landRect);
64 QString zoneNameFromMousePos() const;
65 bool transitionMode() const;
67 public Q_SLOTS:
68 void setTransitionMode(bool enabled);
70 protected:
71 virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
72 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
73 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
74 virtual void drawForeground(QPainter *painter, const QRectF &rect);
76 void drawTransition(QPainter *painter, const QRectF &rect);
78 private:
79 bool checkUnderZone(const int posX, const int posY);
81 int m_cellSize;
82 bool m_transitionMode;
83 qreal m_mouseX, m_mouseY;
84 sint32 m_posX, m_posY;
85 Qt::MouseButton m_mouseButton;
86 ZoneBuilder *m_zoneBuilder;
89 } /* namespace LandscapeEditor */
91 #endif // LANDSCAPE_SCENE_H