From 885b08bfcc044e0d739e033af1284b65c4f7aa2b Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 9 Jun 2011 02:11:50 +0300 Subject: [PATCH] Changed: #1301 Added select path button in project settings dialog. Main window landscape editor is saving own state. --- .../plugins/landscape_editor/CMakeLists.txt | 1 + .../plugins/landscape_editor/builder_zone.cpp | 1 + .../plugins/landscape_editor/builder_zone.h | 4 +- .../landscape_editor_constants.h | 2 + .../landscape_editor_window.cpp | 14 +++++ .../landscape_editor_window.h | 5 +- .../landscape_editor_window.ui | 17 +++++- .../landscape_editor/landscape_view.cpp | 52 +++++++++++++++++++ .../plugins/landscape_editor/landscape_view.h | 49 +++++++++++++++++ .../landscape_editor/list_zones_model.cpp | 16 +++--- .../landscape_editor/list_zones_widget.ui | 9 +++- .../project_settings_dialog.cpp | 9 ++++ .../project_settings_dialog.h | 3 ++ 13 files changed, 168 insertions(+), 14 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index 227210366..e189af74b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -15,6 +15,7 @@ SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h list_zones_model.h list_zones_widget.h landscape_actions.h + landscape_view.h project_settings_dialog.h ) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 3db771224..288a4b1be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -164,6 +164,7 @@ bool ZoneBuilder::initZoneBank (const QString &pathName) if (!m_zoneBank.addElement((pathName + file).toStdString(), error)) QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok); } + delete dir; return true; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index f69c2f7fb..f43bb7d7e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -67,8 +67,8 @@ private: /** @class ZoneBuilder -@brief ZoneBuilder contains all the shared data between the tools and the engine -@details ZoneBank contains the macro zones that is composed of several zones plus a mask +@brief ZoneBuilder contains all the shared data between the tools and the engine. +@details ZoneBank contains the macro zones that is composed of several zones plus a mask. PixmapDatabase contains the graphics for the zones */ class ZoneBuilder diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h index 52775f4c4..6875ddfab 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h @@ -26,6 +26,8 @@ const char * const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor"; //settings const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor"; +const char * const LANDSCAPE_WINDOW_STATE = "LandscapeWindowState"; +const char * const LANDSCAPE_WINDOW_GEOMETRY = "LandscapeWindowGeometry"; //resources const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png"; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 1b8716326..c17de1f43 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -18,6 +18,8 @@ // Project includes #include "landscape_editor_window.h" #include "landscape_editor_constants.h" +#include "builder_zone.h" +#include "landscape_scene.h" #include "project_settings_dialog.h" #include "../core/icore.h" @@ -30,6 +32,8 @@ // Qt includes #include #include +#include +#include namespace LandscapeEditor { @@ -45,6 +49,12 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); m_ui.zoneListWidget->updateUi(); + + m_landscapeScene = new LandscapeScene(this); + m_ui.graphicsView->setScene(m_landscapeScene); + m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers))); + + createMenus(); createToolBars(); readSettings(); @@ -113,6 +123,8 @@ void LandscapeEditorWindow::readSettings() { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); + restoreState(settings->value(Constants::LANDSCAPE_WINDOW_STATE).toByteArray()); + restoreGeometry(settings->value(Constants::LANDSCAPE_WINDOW_GEOMETRY).toByteArray()); settings->endGroup(); } @@ -120,6 +132,8 @@ void LandscapeEditorWindow::writeSettings() { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); + settings->setValue(Constants::LANDSCAPE_WINDOW_STATE, saveState()); + settings->setValue(Constants::LANDSCAPE_WINDOW_GEOMETRY, saveGeometry()); settings->endGroup(); settings->sync(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index 9b2ae0335..1fecd9f03 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -20,7 +20,6 @@ // Project includes #include "ui_landscape_editor_window.h" -#include "builder_zone.h" // Qt includes #include @@ -28,6 +27,9 @@ namespace LandscapeEditor { +class LandscapeScene; +class ZoneBuilder; + class LandscapeEditorWindow: public QMainWindow { Q_OBJECT @@ -51,6 +53,7 @@ private: void readSettings(); void writeSettings(); + LandscapeScene *m_landscapeScene; ZoneBuilder *m_zoneBuilder; QUndoStack *m_undoStack; Ui::LandscapeEditorWindow m_ui; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index 3877d9732..1361cd2bc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -19,8 +19,18 @@ + + 3 + + + 3 + - + + + QGraphicsView::NoDrag + + @@ -73,6 +83,11 @@
list_zones_widget.h
1 + + LandscapeEditor::LandscapeView + QGraphicsView +
landscape_view.h
+
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp new file mode 100644 index 000000000..79b33599e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -0,0 +1,52 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// 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 "landscape_view.h" +#include "landscape_editor_constants.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +// NeL includes +#include + +// Qt includes + + +namespace LandscapeEditor +{ + +LandscapeView::LandscapeView(QWidget *parent) + : QGraphicsView(parent) +{ + setDragMode(ScrollHandDrag); +} + +LandscapeView::~LandscapeView() +{ +} + +void LandscapeView::wheelEvent(QWheelEvent *event) +{ + double numDegrees = event->delta() / 8.0; + double numSteps = numDegrees / 15.0; + double factor = std::pow(1.125, numSteps); + scale(factor, factor); +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h new file mode 100644 index 000000000..db79b79ff --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -0,0 +1,49 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// 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 LANDSCAPE_VIEW_H +#define LANDSCAPE_VIEW_H + +// Project includes + +// Qt includes +#include +#include + +namespace LandscapeEditor +{ + +class LandscapeView: public QGraphicsView +{ + Q_OBJECT + +public: + LandscapeView(QWidget *parent = 0); + ~LandscapeView(); + +protected: + void wheelEvent(QWheelEvent *event); + +private Q_SLOTS: + +private: + +}; /* class LandscapeView */ + +} /* namespace LandscapeEditor */ + +#endif // LANDSCAPE_VIEW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp index 622fd8fb8..57e8683c0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp @@ -59,28 +59,26 @@ QVariant ListZonesModel::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); - if (role == Qt::TextAlignmentRole) + switch (role) { + case Qt::TextAlignmentRole: return int(Qt::AlignLeft | Qt::AlignVCenter); - } - else if (role == Qt::DisplayRole) - { + case Qt::DisplayRole: return m_listNames.at(index.row()); - } - else if (role == Qt::DecorationRole) + case Qt::DecorationRole: { QPixmap *pixmap = getPixmap(m_listNames.at(index.row())); return qVariantFromValue(*pixmap); } - return QVariant(); + default: + return QVariant(); + } } QVariant ListZonesModel::headerData(int section, Qt::Orientation /* orientation */, int role) const { - if (role != Qt::DisplayRole) - return QVariant(); return QVariant(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui index 585371cb7..289cb45dd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui @@ -290,7 +290,14 @@ - + + + false + + + QAbstractItemView::ScrollPerPixel + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp index bf095e6cf..3acd3ff66 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp @@ -28,6 +28,7 @@ // Qt includes #include #include +#include namespace LandscapeEditor { @@ -38,6 +39,7 @@ ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *p m_ui.setupUi(this); m_ui.pathLineEdit->setText(dataPath); setFixedHeight(sizeHint().height()); + connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath())); } ProjectSettingsDialog::~ProjectSettingsDialog() @@ -49,4 +51,11 @@ QString ProjectSettingsDialog::dataPath() const return m_ui.pathLineEdit->text(); } +void ProjectSettingsDialog::selectPath() +{ + QString dataPath = QFileDialog::getExistingDirectory(this, tr("Select data path"), m_ui.pathLineEdit->text()); + if (!dataPath.isEmpty()) + m_ui.pathLineEdit->setText(dataPath); +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h index 74443e3f1..abb93ab81 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h @@ -36,6 +36,9 @@ public: QString dataPath() const; +private Q_SLOTS: + void selectPath(); + private: Ui::ProjectSettingsDialog m_ui;