diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt index d5a792acd..7da567023 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt @@ -1,6 +1,7 @@ ADD_SUBDIRECTORY(core) ADD_SUBDIRECTORY(example) ADD_SUBDIRECTORY(ovqt_sheet_builder) +ADD_SUBDIRECTORY(landscape_editor) ADD_SUBDIRECTORY(log) ADD_SUBDIRECTORY(disp_sheet_id) ADD_SUBDIRECTORY(object_viewer) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt index 06095790b..3140f02fb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt @@ -18,15 +18,18 @@ SET(OVQT_CORE_PLUGIN_HDR core.h main_window.h menu_manager.h + context_manager.h settings_dialog.h search_paths_settings_page.h general_settings_page.h - plugin_view_dialog.h) + plugin_view_dialog.h +) SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui plugin_view_dialog.ui general_settings_page.ui - search_paths_settings_page.ui) + search_paths_settings_page.ui +) SET(OVQT_CORE_PLUGIN_RCS core.qrc) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp new file mode 100644 index 000000000..68e28429d --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp @@ -0,0 +1,150 @@ +// 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 "context_manager.h" +#include "icontext.h" +#include "main_window.h" + +// NeL includes +#include + +// Qt includes +#include +#include + +namespace Core +{ + +struct ContextManagerPrivate +{ + explicit ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget); + Core::MainWindow *m_mainWindow; + QTabWidget *m_tabWidget; + QVector m_contexts; + int m_oldCurrent; +}; + +ContextManagerPrivate::ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget) + : m_mainWindow(mainWindow), + m_tabWidget(tabWidget), + m_oldCurrent(-1) +{ +} + +ContextManager::ContextManager(Core::MainWindow *mainWindow, QTabWidget *tabWidget) + : d(new ContextManagerPrivate(mainWindow, tabWidget)) +{ + QObject::connect(d->m_mainWindow->pluginManager(), SIGNAL(objectAdded(QObject *)), + this, SLOT(objectAdded(QObject *))); + QObject::connect(d->m_mainWindow->pluginManager(), SIGNAL(aboutToRemoveObject(QObject *)), + this, SLOT(aboutToRemoveObject(QObject *))); + + QObject::connect(d->m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); +} + +ContextManager::~ContextManager() +{ + delete d; +} + +Core::IContext *ContextManager::currentContext() const +{ + int currentIndex = d->m_tabWidget->currentIndex(); + if (currentIndex < 0) + return 0; + return d->m_contexts.at(currentIndex); +} + +Core::IContext *ContextManager::context(const QString &id) const +{ + const int index = indexOf(id); + if (index >= 0) + return d->m_contexts.at(index); + return 0; +} + +void ContextManager::activateContext(const QString &id) +{ + const int index = indexOf(id); + if (index >= 0) + d->m_tabWidget->setCurrentIndex(index); +} + +void ContextManager::objectAdded(QObject *obj) +{ + IContext *context = qobject_cast(obj); + if (context) + addContextObject(context); +} + +void ContextManager::aboutToRemoveObject(QObject *obj) +{ + IContext *context = qobject_cast(obj); + if (context) + removeContextObject(context); +} + +void ContextManager::addContextObject(IContext *context) +{ + d->m_contexts.push_back(context); + d->m_mainWindow->addContextObject(context); + + QWidget *tabWidget = new QWidget(d->m_tabWidget); + d->m_tabWidget->addTab(tabWidget, context->icon(), context->trName()); + QGridLayout *gridLayout = new QGridLayout(tabWidget); + gridLayout->setObjectName(QString::fromUtf8("gridLayout_") + context->id()); + gridLayout->setContentsMargins(0, 0, 0, 0); + gridLayout->addWidget(context->widget(), 0, 0, 1, 1); +} + +void ContextManager::removeContextObject(IContext *context) +{ + d->m_mainWindow->removeContextObject(context); + + const int index = indexOf(context->id()); + QWidget *widget = d->m_tabWidget->widget(index); + d->m_tabWidget->removeTab(index); + d->m_contexts.remove(index); + delete widget; +} + +void ContextManager::currentTabChanged(int index) +{ + if (index >= 0) + { + IContext *context = d->m_contexts.at(index); + IContext *oldContext = 0; + if (d->m_oldCurrent >= 0) + oldContext = d->m_contexts.at(d->m_oldCurrent); + d->m_oldCurrent = index; + Q_EMIT currentContextChanged(context, oldContext); + } +} + +int ContextManager::indexOf(const QString &id) const +{ + for (int i = 0; i < d->m_contexts.count(); ++i) + { + if (d->m_contexts.at(i)->id() == id) + return i; + } + nlwarning(QString("Warning, no such context: %1").arg(id).toStdString().c_str()); + return -1; +} + +} /* namespace Core */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h new file mode 100644 index 000000000..7a3658fff --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h @@ -0,0 +1,70 @@ +// 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 CONTEXT_MANAGER_H +#define CONTEXT_MANAGER_H + +// Project includes +#include "core_global.h" + +// Qt includes +#include + +QT_BEGIN_NAMESPACE +class QTabWidget; +QT_END_NAMESPACE + +namespace Core +{ +class IContext; +class MainWindow; +struct ContextManagerPrivate; + +class CORE_EXPORT ContextManager : public QObject +{ + Q_OBJECT + +public: + explicit ContextManager(Core::MainWindow *mainWindow, QTabWidget *tabWidget); + virtual ~ContextManager(); + + Core::IContext *currentContext() const; + Core::IContext *context(const QString &id) const; + +Q_SIGNALS: + // the default argument '=0' is important for connects without the oldContext argument. + void currentContextChanged(Core::IContext *context, Core::IContext *oldContext = 0); + +public Q_SLOTS: + void activateContext(const QString &id); + +private Q_SLOTS: + void objectAdded(QObject *obj); + void aboutToRemoveObject(QObject *obj); + void addContextObject(IContext *context); + void removeContextObject(IContext *context); + void currentTabChanged(int index); + +private: + int indexOf(const QString &id) const; + + ContextManagerPrivate *d; +}; + +} // namespace Core + +#endif // CONTEXT_MANAGER_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp index 6c681f15a..fa61b5700 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp @@ -18,6 +18,7 @@ #include "core.h" #include "imenu_manager.h" +#include "context_manager.h" #include "main_window.h" #include "../../extension_system/iplugin_manager.h" @@ -54,6 +55,11 @@ IMenuManager *CoreImpl::menuManager() const return m_mainWindow->menuManager(); } +ContextManager *CoreImpl::contextManager() const +{ + return m_mainWindow->contextManager(); +} + QSettings *CoreImpl::settings() const { return m_mainWindow->settings(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h index d3b25b918..2613a06a5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h @@ -38,6 +38,7 @@ public: QWidget *parent = 0); virtual IMenuManager *menuManager() const; + virtual ContextManager *contextManager() const; virtual QSettings *settings() const; virtual QMainWindow *mainWindow() const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp index 47bf4026a..51da80f67 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp @@ -65,6 +65,11 @@ QString GeneralSettingsPage::trCategory() const return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL); } +QIcon GeneralSettingsPage::categoryIcon() const +{ + return QIcon(); +} + void GeneralSettingsPage::applyGeneralSettings() { QSettings *settings = Core::ICore::instance()->settings(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h index 2f73f8715..2fbcb842a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h @@ -44,6 +44,7 @@ public: QString trName() const; QString category() const; QString trCategory() const; + QIcon categoryIcon() const; QWidget *createPage(QWidget *parent); void apply(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h index 776246d8d..8af601418 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h @@ -28,6 +28,7 @@ QT_BEGIN_NAMESPACE class QWidget; +class QUndoStack; QT_END_NAMESPACE namespace Core @@ -56,6 +57,10 @@ public: /// The widget will be destroyed by the widget hierarchy when the main window closes virtual QWidget *widget() = 0; + + virtual QUndoStack *undoStack() = 0; + + virtual void open() = 0; }; } // namespace Core diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h index 71f075973..13b22bfa5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h @@ -36,6 +36,7 @@ class IPluginManager; namespace Core { class IMenuManager; +class ContextManager; class CORE_EXPORT ICore : public QObject { @@ -52,6 +53,7 @@ public: QWidget *parent = 0) = 0; virtual IMenuManager *menuManager() const = 0; + virtual ContextManager *contextManager() const = 0; virtual QSettings *settings() const = 0; virtual QMainWindow *mainWindow() const = 0; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h index 74692833a..4d9ed6fda 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h @@ -27,6 +27,7 @@ QT_BEGIN_NAMESPACE class QWidget; +class QIcon; QT_END_NAMESPACE namespace Core @@ -56,6 +57,8 @@ public: /// trCategory() is the translated category virtual QString trCategory() const = 0; + virtual QIcon categoryIcon() const = 0; + /// createPage() is called to retrieve the widget to show in the preferences dialog /// The widget will be destroyed by the widget hierarchy when the dialog closes virtual QWidget *createPage(QWidget *parent) = 0; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp index e048aa80b..55d6d4579 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp @@ -20,6 +20,7 @@ #include "icontext.h" #include "icore_listener.h" #include "menu_manager.h" +#include "context_manager.h" #include "core.h" #include "core_constants.h" #include "settings_dialog.h" @@ -38,8 +39,10 @@ MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget * : QMainWindow(parent), m_pluginManager(0), m_menuManager(0), + m_contextManager(0), m_coreImpl(0), m_lastDir("."), + m_undoGroup(0), m_settings(0) { QCoreApplication::setApplicationName(QLatin1String("ObjectViewerQt")); @@ -59,12 +62,15 @@ MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget * m_tabWidget = new QTabWidget(this); m_tabWidget->setTabPosition(QTabWidget::South); - m_tabWidget->setMovable(true); + m_tabWidget->setMovable(false); m_tabWidget->setDocumentMode(true); setCentralWidget(m_tabWidget); + m_contextManager = new ContextManager(this, m_tabWidget); + setDockNestingEnabled(true); m_originalPalette = QApplication::palette(); + m_undoGroup = new QUndoGroup(this); createDialogs(); createActions(); @@ -92,15 +98,10 @@ bool MainWindow::initialize(QString *errorString) void MainWindow::extensionsInitialized() { - QList listContexts = m_pluginManager->getObjects(); - - Q_FOREACH(IContext *context, listContexts) - { - addContextObject(context); - } - - connect(m_pluginManager, SIGNAL(objectAdded(QObject *)), this, SLOT(checkObject(QObject *))); readSettings(); + connect(m_contextManager, SIGNAL(currentContextChanged(Core::IContext*)), + this, SLOT(updateContext(Core::IContext*))); + updateContext(m_contextManager->currentContext()); show(); } @@ -109,6 +110,11 @@ IMenuManager *MainWindow::menuManager() const return m_menuManager; } +ContextManager *MainWindow::contextManager() const +{ + return m_contextManager; +} + QSettings *MainWindow::settings() const { return m_settings; @@ -119,15 +125,19 @@ ExtensionSystem::IPluginManager *MainWindow::pluginManager() const return m_pluginManager; } -void MainWindow::open() +void MainWindow::addContextObject(IContext *context) { + m_undoGroup->addStack(context->undoStack()); } -void MainWindow::checkObject(QObject *obj) +void MainWindow::removeContextObject(IContext *context) { - IContext *context = qobject_cast(obj); - if (context) - addContextObject(context); + m_undoGroup->removeStack(context->undoStack()); +} + +void MainWindow::open() +{ + m_contextManager->currentContext()->open(); } bool MainWindow::showOptionsDialog(const QString &group, @@ -151,6 +161,11 @@ void MainWindow::about() "

Ryzom Core team

Compiled on %1 %2").arg(__DATE__).arg(__TIME__)); } +void MainWindow::updateContext(Core::IContext *context) +{ + m_undoGroup->setActiveStack(context->undoStack()); +} + void MainWindow::closeEvent(QCloseEvent *event) { QList listeners = m_pluginManager->getObjects(); @@ -168,16 +183,6 @@ void MainWindow::closeEvent(QCloseEvent *event) event->accept(); } -void MainWindow::addContextObject(IContext *context) -{ - QWidget *tabWidget = new QWidget(m_tabWidget); - m_tabWidget->addTab(tabWidget, context->icon(), context->trName()); - QGridLayout *gridLayout = new QGridLayout(tabWidget); - gridLayout->setObjectName(QString::fromUtf8("gridLayout_") + context->id()); - gridLayout->setContentsMargins(0, 0, 0, 0); - gridLayout->addWidget(context->widget(), 0, 0, 1, 1); -} - void MainWindow::createActions() { m_openAction = new QAction(tr("&Open..."), this); @@ -228,11 +233,14 @@ void MainWindow::createMenus() { m_fileMenu = menuBar()->addMenu(tr("&File")); menuManager()->registerMenu(m_fileMenu, Constants::M_FILE); -// m_fileMenu->addAction(m_openAction); + m_fileMenu->addAction(m_openAction); m_fileMenu->addSeparator(); m_fileMenu->addAction(m_exitAction); m_editMenu = menuBar()->addMenu(tr("&Edit")); + m_editMenu->addAction(m_undoGroup->createUndoAction(this)); + m_editMenu->addAction(m_undoGroup->createRedoAction(this)); + m_editMenu->addSeparator(); menuManager()->registerMenu(m_editMenu, Constants::M_EDIT); m_viewMenu = menuBar()->addMenu(tr("&View")); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h index 4cc24e5eb..74ec08957 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h @@ -26,6 +26,7 @@ // Qt includes #include +#include #include namespace Core @@ -35,6 +36,7 @@ class CorePlugin; class IContext; class IMenuManager; class MenuManager; +class ContextManager; class CoreImpl; class MainWindow : public QMainWindow @@ -49,10 +51,14 @@ public: void extensionsInitialized(); IMenuManager *menuManager() const; + ContextManager *contextManager() const; QSettings *settings() const; ExtensionSystem::IPluginManager *pluginManager() const; + void addContextObject(IContext *context); + void removeContextObject(IContext *context); + public Q_SLOTS: bool showOptionsDialog(const QString &group = QString(), const QString &page = QString(), @@ -60,15 +66,13 @@ public Q_SLOTS: private Q_SLOTS: void open(); - void checkObject(QObject *obj); void about(); + void updateContext(Core::IContext *context); protected: virtual void closeEvent(QCloseEvent *event); private: - void addContextObject(IContext *appPage); - void createActions(); void createMenus(); void createStatusBar(); @@ -80,11 +84,13 @@ private: ExtensionSystem::IPluginManager *m_pluginManager; ExtensionSystem::CPluginView *m_pluginView; MenuManager *m_menuManager; + ContextManager *m_contextManager; CoreImpl *m_coreImpl; QPalette m_originalPalette; QString m_lastDir; + QUndoGroup *m_undoGroup; QSettings *m_settings; QTimer *m_mainTimer; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp index 2d7e7a24f..355a9c0e3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp @@ -70,6 +70,11 @@ QString CSearchPathsSettingsPage::trCategory() const return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL); } +QIcon CSearchPathsSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent) { m_page = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h index fc8e6003c..c7d4c9734 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h @@ -44,6 +44,7 @@ public: QString trName() const; QString category() const; QString trCategory() const; + QIcon categoryIcon() const; QWidget *createPage(QWidget *parent); void apply(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.cpp index 0cb885163..50e7c9db5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.cpp @@ -53,6 +53,11 @@ QString CExampleSettingsPage::trCategory() const return tr("General"); } +QIcon CExampleSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *CExampleSettingsPage::createPage(QWidget *parent) { _currentPage = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.h index 64dd940f8..3475f843f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.h @@ -43,6 +43,7 @@ public: virtual QString trName() const; virtual QString category() const; virtual QString trCategory() const; + QIcon categoryIcon() const; virtual QWidget *createPage(QWidget *parent); virtual void apply(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h index d3be3bc38..5077ff59e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h @@ -86,6 +86,15 @@ public: return m_simpleViewer; } + virtual QUndoStack *undoStack() + { + return m_simpleViewer->m_undoStack; + } + + virtual void open() + { + } + CSimpleViewer *m_simpleViewer; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/simple_viewer.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/simple_viewer.cpp index e128710c4..1f6df9117 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/simple_viewer.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/simple_viewer.cpp @@ -37,6 +37,8 @@ CSimpleViewer::CSimpleViewer(QWidget *parent) gridLayout->setContentsMargins(0, 0, 0, 0); NLQT::QNLWidget *_nelWidget = new NLQT::QNLWidget(this); gridLayout->addWidget(_nelWidget, 0, 0, 1, 1); + + m_undoStack = new QUndoStack(this); } bool CCoreListener::closeMainWindow() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/simple_viewer.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/simple_viewer.h index bbff7e9e0..14b782c22 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/simple_viewer.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/simple_viewer.h @@ -25,7 +25,7 @@ // Qt includes #include - +#include class QWidget; namespace Plugin @@ -37,6 +37,8 @@ class CSimpleViewer : public QWidget public: CSimpleViewer(QWidget *parent = 0); virtual ~CSimpleViewer() {} + + QUndoStack *m_undoStack; }; class CCoreListener : public Core::ICoreListener 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 new file mode 100644 index 000000000..3b6a61c5e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -0,0 +1,48 @@ +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${QT_INCLUDES}) + +FILE(GLOB SRC *.cpp *.h) + +SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) + +SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h + landscape_editor_window.h +) + +SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui +) + +SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTOPENGL TRUE) + +QT4_ADD_RESOURCES(OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS ${OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS}) +QT4_WRAP_CPP(OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC ${OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR}) +QT4_WRAP_UI(OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS}) + +SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS}) +SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC} OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS) +SOURCE_GROUP("Landscape Editor Plugin" FILES ${SRC}) +SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) + +ADD_LIBRARY(ovqt_plugin_landscape_editor MODULE ${SRC} + ${OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC} + ${OVQT_EXT_SYS_SRC} + ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS} + ${OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS}) + +TARGET_LINK_LIBRARIES(ovqt_plugin_landscape_editor ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) + +NL_DEFAULT_PROPS(ovqt_plugin_landscape_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Landscape Editor") +NL_ADD_RUNTIME_FLAGS(ovqt_plugin_landscape_editor) +NL_ADD_LIB_SUFFIX(ovqt_plugin_landscape_editor) + +ADD_DEFINITIONS(-DLANDSCAPE_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) + +INSTALL(TARGETS ovqt_plugin_landscape_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_landscape_item.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_landscape_item.png new file mode 100644 index 000000000..7a51400b3 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_landscape_item.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_landscape_settings.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_landscape_settings.png new file mode 100644 index 000000000..4197f7f97 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_landscape_settings.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_world_editor.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_world_editor.png new file mode 100644 index 000000000..d41f64e2f Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_world_editor.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_zone.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_zone.png new file mode 100644 index 000000000..73be27528 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_zone.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_zonel.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_zonel.png new file mode 100644 index 000000000..40f75828b Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_zonel.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor.qrc b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor.qrc new file mode 100644 index 000000000..5dba9074b --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor.qrc @@ -0,0 +1,9 @@ + + + icons/ic_nel_landscape_item.png + icons/ic_nel_landscape_settings.png + icons/ic_nel_world_editor.png + icons/ic_nel_zone.png + icons/ic_nel_zonel.png + + 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 new file mode 100644 index 000000000..52775f4c4 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h @@ -0,0 +1,37 @@ +// 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_EDITOR_CONSTANTS_H +#define LANDSCAPE_EDITOR_CONSTANTS_H + +namespace LandscapeEditor +{ +namespace Constants +{ +const char * const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor"; + +//settings +const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor"; + +//resources +const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png"; + + +} // namespace Constants +} // namespace LandscapeEditor + +#endif // LANDSCAPE_EDITOR_CONSTANTS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_global.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_global.h new file mode 100644 index 000000000..167c8e24f --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_global.h @@ -0,0 +1,30 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. +// +// 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_EDITOR_GLOBAL_H +#define LANDSCAPE_EDITOR_GLOBAL_H + +#include + +#if defined(LANDSCAPE_EDITOR_LIBRARY) +# define LANDSCAPE_EDITOR_EXPORT Q_DECL_EXPORT +#else +# define LANDSCAPE_EDITOR_EXPORT Q_DECL_IMPORT +#endif + +#endif // LANDSCAPE_EDITOR_GLOBAL_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp new file mode 100644 index 000000000..ac7782343 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp @@ -0,0 +1,128 @@ +// 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_editor_plugin.h" +#include "landscape_editor_window.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +// NeL includes +#include "nel/misc/debug.h" + +// Qt includes +#include + +namespace LandscapeEditor +{ + +LandscapeEditorPlugin::~LandscapeEditorPlugin() +{ + Q_FOREACH(QObject *obj, m_autoReleaseObjects) + { + m_plugMan->removeObject(obj); + } + qDeleteAll(m_autoReleaseObjects); + m_autoReleaseObjects.clear(); +} + +bool LandscapeEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) +{ + Q_UNUSED(errorString); + m_plugMan = pluginManager; + + addAutoReleasedObject(new LandscapeEditorContext(this)); + return true; +} + +void LandscapeEditorPlugin::extensionsInitialized() +{ +} + +void LandscapeEditorPlugin::shutdown() +{ +} + +void LandscapeEditorPlugin::setNelContext(NLMISC::INelContext *nelContext) +{ +#ifdef NL_OS_WINDOWS + // Ensure that a context doesn't exist yet. + // This only applies to platforms without PIC, e.g. Windows. + nlassert(!NLMISC::INelContext::isContextInitialised()); +#endif // NL_OS_WINDOWS + m_libContext = new NLMISC::CLibraryContext(*nelContext); +} + +QString LandscapeEditorPlugin::name() const +{ + return tr("LandscapeEditor"); +} + +QString LandscapeEditorPlugin::version() const +{ + return "0.0.1"; +} + +QString LandscapeEditorPlugin::vendor() const +{ + return "GSoC2011_dnk-88"; +} + +QString LandscapeEditorPlugin::description() const +{ + return "Landscape editor ovqt plugin."; +} + +QStringList LandscapeEditorPlugin::dependencies() const +{ + QStringList list; + list.append(Core::Constants::OVQT_CORE_PLUGIN); + return list; +} + +void LandscapeEditorPlugin::addAutoReleasedObject(QObject *obj) +{ + m_plugMan->addObject(obj); + m_autoReleaseObjects.prepend(obj); +} + +LandscapeEditorContext::LandscapeEditorContext(QObject *parent) + : IContext(parent), + m_landEditorWindow(0) +{ + m_landEditorWindow = new LandscapeEditorWindow(); +} + +QUndoStack *LandscapeEditorContext::undoStack() +{ + return m_landEditorWindow->undoStack(); +} + +void LandscapeEditorContext::open() +{ + m_landEditorWindow->open(); +} + +QWidget *LandscapeEditorContext::widget() +{ + return m_landEditorWindow; +} + +} + +Q_EXPORT_PLUGIN(LandscapeEditor::LandscapeEditorPlugin) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h new file mode 100644 index 000000000..67a3172ee --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h @@ -0,0 +1,108 @@ +// 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_EDITOR_PLUGIN_H +#define LANDSCAPE_EDITOR_PLUGIN_H + +// Project includes +#include "landscape_editor_constants.h" +#include "../../extension_system/iplugin.h" +#include "../core/icontext.h" + +// NeL includes +#include "nel/misc/app_context.h" + +// Qt includes +#include +#include + +namespace NLMISC +{ +class CLibraryContext; +} + +namespace ExtensionSystem +{ +class IPluginSpec; +} + +namespace LandscapeEditor +{ +class LandscapeEditorWindow; + +class LandscapeEditorPlugin : public QObject, public ExtensionSystem::IPlugin +{ + Q_OBJECT + Q_INTERFACES(ExtensionSystem::IPlugin) +public: + + virtual ~LandscapeEditorPlugin(); + + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); + void extensionsInitialized(); + void shutdown(); + + void setNelContext(NLMISC::INelContext *nelContext); + + QString name() const; + QString version() const; + QString vendor() const; + QString description() const; + QStringList dependencies() const; + + void addAutoReleasedObject(QObject *obj); + +protected: + NLMISC::CLibraryContext *m_libContext; + +private: + ExtensionSystem::IPluginManager *m_plugMan; + QList m_autoReleaseObjects; +}; + +class LandscapeEditorContext: public Core::IContext +{ + Q_OBJECT +public: + LandscapeEditorContext(QObject *parent = 0); + virtual ~LandscapeEditorContext() {} + + virtual QString id() const + { + return QLatin1String("LandscapeEditorContext"); + } + virtual QString trName() const + { + return tr("Landscape Editor"); + } + virtual QIcon icon() const + { + return QIcon(); + } + + virtual void open(); + + virtual QUndoStack *undoStack(); + + virtual QWidget *widget(); + + LandscapeEditorWindow *m_landEditorWindow; +}; + +} // namespace LandscapeEditor + +#endif // LANDSCAPE_EDITOR_PLUGIN_H 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 new file mode 100644 index 000000000..4b075adfc --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -0,0 +1,93 @@ +// 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_editor_window.h" +#include "landscape_editor_constants.h" + +#include "../core/icore.h" +#include "../core/imenu_manager.h" +#include "../core/core_constants.h" + +// NeL includes +#include + +// Qt includes +#include +#include + +namespace LandscapeEditor +{ +QString _lastDir; + +LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) + : QMainWindow(parent) +{ + m_ui.setupUi(this); + + m_undoStack = new QUndoStack(this); + + createMenus(); + readSettings(); +} + +LandscapeEditorWindow::~LandscapeEditorWindow() +{ + writeSettings(); +} + +QUndoStack *LandscapeEditorWindow::undoStack() const +{ + return m_undoStack; +} + +void LandscapeEditorWindow::open() +{ + QStringList fileNames = QFileDialog::getOpenFileNames(this, + tr("Open NeL Ligo land file"), _lastDir, + tr("All NeL Ligo land files (*.land)")); + + setCursor(Qt::WaitCursor); + if (!fileNames.isEmpty()) + { + QStringList list = fileNames; + _lastDir = QFileInfo(list.front()).absolutePath(); + } + setCursor(Qt::ArrowCursor); +} + +void LandscapeEditorWindow::createMenus() +{ + Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); +} + +void LandscapeEditorWindow::readSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); + settings->endGroup(); +} + +void LandscapeEditorWindow::writeSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); + settings->endGroup(); + settings->sync(); +} + +} /* namespace LandscapeEditor */ 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 new file mode 100644 index 000000000..cc17e6cbc --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -0,0 +1,56 @@ +// 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_EDITOR_WINDOW_H +#define LANDSCAPE_EDITOR_WINDOW_H + +// Project includes +#include "ui_landscape_editor_window.h" + +// Qt includes +#include + +namespace LandscapeEditor +{ + +class LandscapeEditorWindow: public QMainWindow +{ + Q_OBJECT + +public: + LandscapeEditorWindow(QWidget *parent = 0); + ~LandscapeEditorWindow(); + + QUndoStack *undoStack() const; + +Q_SIGNALS: +public Q_SLOTS: + void open(); + +private Q_SLOTS: +private: + void createMenus(); + void readSettings(); + void writeSettings(); + + QUndoStack *m_undoStack; + Ui::LandscapeEditorWindow m_ui; +}; /* class LandscapeEditorWindow */ + +} /* namespace LandscapeEditor */ + +#endif // LANDSCAPE_EDITOR_WINDOW_H 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 new file mode 100644 index 000000000..5d9606ddf --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -0,0 +1,43 @@ + + + LandscapeEditorWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + :/icons/ic_nel_landscape_item.png:/icons/ic_nel_landscape_item.png + + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp index eabb67f3d..6c2736895 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp @@ -58,6 +58,11 @@ QString GraphicsSettingsPage::trCategory() const return tr("Object Viewer"); } +QIcon GraphicsSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *GraphicsSettingsPage::createPage(QWidget *parent) { m_page = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.h index e1402939f..74df1b140 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.h @@ -42,6 +42,7 @@ public: virtual QString trName() const; virtual QString category() const; virtual QString trCategory() const; + QIcon categoryIcon() const; virtual QWidget *createPage(QWidget *parent); virtual void apply(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp index 6e183d913..dd8a4bb1e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp @@ -89,6 +89,7 @@ CMainWindow::CMainWindow(QWidget *parent) _isSoundInitialized = true; } + _undoStack = new QUndoStack(this); _SkeletonTreeModel = new CSkeletonTreeModel(this); createDialogs(); @@ -272,8 +273,8 @@ void CMainWindow::createMenus() // add actions in file menu QMenu *fileMenu = menuManager->menu(Core::Constants::M_FILE); QAction *exitAction = menuManager->action(Core::Constants::EXIT); - fileMenu->insertAction(exitAction, _openAction); - fileMenu->insertSeparator(exitAction); + //fileMenu->insertAction(exitAction, _openAction); + //fileMenu->insertSeparator(exitAction); // register actions for view menu menuManager->registerAction(_setBackColorAction, "ObjectViewer.View.SetBackgroundColor"); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h index 52b3dc8d5..5a392c191 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h @@ -25,6 +25,7 @@ // Qt includes #include #include +#include // NeL includes #include @@ -72,10 +73,17 @@ public: return _SkeletonTreeModel; } -private Q_SLOTS: + QUndoStack *getUndoStack() const + { + return _undoStack; + } + +public Q_SLOTS: void open(); void resetScene(); void reloadTextures(); + +private Q_SLOTS: void updateStatusBar(); void updateRender(); void setInterval(int value); @@ -130,6 +138,7 @@ private: QAction *_resetSceneAction; QAction *_saveScreenshotAction; QLabel *_statusInfo; + QUndoStack *_undoStack; float _fps; uint _numTri; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/modules.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/modules.cpp index 76afed779..605f484f7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/modules.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/modules.cpp @@ -37,7 +37,7 @@ void Modules::init() void Modules::release() { - delete _mainWindow; +// delete _mainWindow; _mainWindow = NULL; delete _particleEditor; _particleEditor = NULL; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp index b48eb82cc..f82789e66 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp @@ -22,7 +22,7 @@ ObjectViewerPlugin::~ObjectViewerPlugin() } qDeleteAll(_autoReleaseObjects); _autoReleaseObjects.clear(); - //Modules::release(); + Modules::release(); } bool ObjectViewerPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) @@ -43,7 +43,7 @@ void ObjectViewerPlugin::extensionsInitialized() void ObjectViewerPlugin::shutdown() { - Modules::release(); +// Modules::release(); } void ObjectViewerPlugin::setNelContext(NLMISC::INelContext *nelContext) @@ -89,6 +89,16 @@ void ObjectViewerPlugin::addAutoReleasedObject(QObject *obj) _autoReleaseObjects.prepend(obj); } +void CObjectViewerContext::open() +{ + Modules::mainWin().open(); +} + +QUndoStack *CObjectViewerContext::undoStack() +{ + return Modules::mainWin().getUndoStack(); +} + QWidget *CObjectViewerContext::widget() { return &Modules::mainWin(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.h index dae298fce..b5f9c2881 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.h @@ -66,14 +66,21 @@ public: { return QLatin1String("ObjectViewer"); } + virtual QString trName() const { return tr("Object Viewer"); } + virtual QIcon icon() const { return QIcon(); } + + virtual QUndoStack *undoStack(); + + virtual void open(); + virtual QWidget *widget(); }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.cpp index 4c677f4bf..1bceeb80b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.cpp @@ -56,6 +56,11 @@ QString SoundSettingsPage::trCategory() const return tr("Object Viewer"); } +QIcon SoundSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *SoundSettingsPage::createPage(QWidget *parent) { m_page = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.h index c27a82e1f..0e5361f54 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.h @@ -44,6 +44,7 @@ public: virtual QString trName() const; virtual QString category() const; virtual QString trCategory() const; + QIcon categoryIcon() const; virtual QWidget *createPage(QWidget *parent); virtual void apply(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.cpp index 7349a8465..68a1f4b98 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.cpp @@ -59,6 +59,11 @@ QString VegetableSettingsPage::trCategory() const return tr("Object Viewer"); } +QIcon VegetableSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *VegetableSettingsPage::createPage(QWidget *parent) { m_page = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.h index bf49e2d2c..b66d070ba 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.h @@ -43,6 +43,7 @@ public: virtual QString trName() const; virtual QString category() const; virtual QString trCategory() const; + QIcon categoryIcon() const; virtual QWidget *createPage(QWidget *parent); virtual void apply();