From 5edc56cf1512da9683c845e10788815846a7a9fe Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 30 Jul 2011 22:32:06 +0300 Subject: [PATCH] Changed: #1302 Added 2d render in world editor plugin. --- .../src/plugins/world_editor/CMakeLists.txt | 1 + .../world_editor/world_editor_scene.cpp | 71 +++++++++++++++++++ .../plugins/world_editor/world_editor_scene.h | 57 +++++++++++++++ .../world_editor/world_editor_window.cpp | 10 +++ .../world_editor/world_editor_window.h | 8 +++ 5 files changed, 147 insertions(+) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt index 8b51838d7..1e41175bd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt @@ -11,6 +11,7 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h world_editor_window.h + world_editor_scene.h primitives_model.h primitives_view.h ) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp new file mode 100644 index 000000000..2c4c41065 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -0,0 +1,71 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "world_editor_scene.h" + +// NeL includes +#include + +// Qt includes +#include +#include +#include +#include + +namespace WorldEditor +{ + +WorldEditorScene::WorldEditorScene(int sizeCell, QObject *parent) + : LandscapeEditor::LandscapeSceneBase(sizeCell, parent) +{ +} + +WorldEditorScene::~WorldEditorScene() +{ +} +/* +void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + QGraphicsScene::mousePressEvent(mouseEvent); + + qreal x = mouseEvent->scenePos().x(); + qreal y = mouseEvent->scenePos().y(); + m_posX = sint32(floor(x / m_cellSize)); + m_posY = sint32(-floor(y / m_cellSize)); + + m_mouseButton = mouseEvent->button(); +} + +void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + m_mouseX = mouseEvent->scenePos().x(); + m_mouseY = mouseEvent->scenePos().y() - m_cellSize; + + m_posX = sint32(floor(m_mouseX / m_cellSize)); + m_posY = sint32(-floor(m_mouseY / m_cellSize)); + + QGraphicsScene::mouseMoveEvent(mouseEvent); +} + +void LandscapeSceneBase::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + QGraphicsScene::mouseReleaseEvent(mouseEvent); + m_mouseButton = Qt::NoButton; +} +*/ + +} /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h new file mode 100644 index 000000000..84dba333c --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -0,0 +1,57 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef WORLD_EDITOR_SCENE_H +#define WORLD_EDITOR_SCENE_H + +// Project includes +#include "world_editor_global.h" + +#include "../landscape_editor/landscape_scene_base.h" + +// NeL includes + +// Qt includes + +namespace WorldEditor +{ + +/* +@class WorldEditorScene +@brief +@details +*/ +class WORLD_EDITOR_EXPORT WorldEditorScene : public LandscapeEditor::LandscapeSceneBase +{ + Q_OBJECT + +public: + WorldEditorScene(int sizeCell = 160, QObject *parent = 0); + virtual ~WorldEditorScene(); + +public Q_SLOTS: + +protected: +// virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); +// virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); +// virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); + +private: +}; + +} /* namespace WorldEditor */ + +#endif // WORLD_EDITOR_SCENE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 7ddb5484c..fd9f9c755 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -19,6 +19,7 @@ #include "world_editor_window.h" #include "world_editor_constants.h" #include "primitives_model.h" +#include "world_editor_scene.h" // Core #include "../core/icore.h" @@ -26,6 +27,7 @@ #include "../core/core_constants.h" // Lanscape Editor plugin +#include "../landscape_editor/builder_zone_base.h" //#include "../landscape_editor/project_settings_dialog.h" // NeL includes @@ -55,6 +57,12 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); + m_worldEditorScene = new WorldEditorScene(160, this); + m_zoneBuilderBase = new LandscapeEditor::ZoneBuilderBase(m_worldEditorScene); + + m_worldEditorScene->setZoneBuilder(m_zoneBuilderBase); + m_ui.graphicsView->setScene(m_worldEditorScene); + QActionGroup *sceneModeGroup = new QActionGroup(this); sceneModeGroup->addAction(m_ui.selectAction); sceneModeGroup->addAction(m_ui.moveAction); @@ -82,6 +90,8 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) WorldEditorWindow::~WorldEditorWindow() { writeSettings(); + + delete m_zoneBuilderBase; } QUndoStack *WorldEditorWindow::undoStack() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 1b2937dad..99768736b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -24,9 +24,15 @@ // Qt includes #include +namespace LandscapeEditor +{ +class ZoneBuilderBase; +} + namespace WorldEditor { class PrimitivesTreeModel; +class WorldEditorScene; class WorldEditorWindow: public QMainWindow { @@ -57,6 +63,8 @@ private: PrimitivesTreeModel *m_primitivesModel; QUndoStack *m_undoStack; + WorldEditorScene *m_worldEditorScene; + LandscapeEditor::ZoneBuilderBase *m_zoneBuilderBase; Ui::WorldEditorWindow m_ui; }; /* class WorldEditorWindow */