From 85365fd7bb71536c3b8f8a7f60cdb9cc68d07e5e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Sep 2013 00:08:49 +0200 Subject: [PATCH] Fix line endings --- .../georges_editor/expandable_headerview.h | 64 +- .../src/plugins/log/log_plugin.cpp | 374 ++-- .../src/plugins/log/log_plugin.h | 66 +- .../src/plugins/log/log_settings_page.cpp | 244 +-- .../mission_compiler_main_window.h | 132 +- .../mission_compiler/server_entry_dialog.cpp | 146 +- .../mission_compiler/server_entry_dialog.h | 4 +- .../zone_painter/zone_painter_main_window.cpp | 310 ++-- .../zone_painter/zone_painter_main_window.h | 104 +- .../src/object_viewer_widget.cpp | 1568 ++++++++--------- .../src/object_viewer_widget.h | 452 ++--- .../3d/object_viewer_widget/src/stdpch.cpp | 2 +- .../server/src/ai_share/ai_spawn_commands.h | 114 +- .../georges_editor_qt/src/formitem.h | 112 +- 14 files changed, 1846 insertions(+), 1846 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.h index f7f26eafc..4071b4637 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.h @@ -15,35 +15,35 @@ // along with this program. If not, see . #ifndef EXPANDABLE_HEADERVIEW_H -#define EXPANDABLE_HEADERVIEW_H - -// Qt includes -#include - -namespace GeorgesQt -{ - class ExpandableHeaderView : public QHeaderView - { - Q_OBJECT - public: - ExpandableHeaderView(Qt::Orientation orientation, QWidget * parent = 0); - - bool* expanded() { return &m_expanded; } - - protected: - void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const; - bool isPointInDecoration(int section, QPoint pos)const; - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - - private: - bool m_expanded; - bool m_inDecoration; - -Q_SIGNALS: - void headerClicked(int); - }; - -} /* namespace NLQT */ - -#endif // EXPANDABLE_HEADERVIEW_H +#define EXPANDABLE_HEADERVIEW_H + +// Qt includes +#include + +namespace GeorgesQt +{ + class ExpandableHeaderView : public QHeaderView + { + Q_OBJECT + public: + ExpandableHeaderView(Qt::Orientation orientation, QWidget * parent = 0); + + bool* expanded() { return &m_expanded; } + + protected: + void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const; + bool isPointInDecoration(int section, QPoint pos)const; + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + + private: + bool m_expanded; + bool m_inDecoration; + +Q_SIGNALS: + void headerClicked(int); + }; + +} /* namespace NLQT */ + +#endif // EXPANDABLE_HEADERVIEW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp index 5a8c64f93..0f86ab90c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp @@ -1,191 +1,191 @@ -// Object Viewer Qt - Log Plugin - MMORPG Framework -// Copyright (C) 2011 Adrian Jaekel -// -// 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 "log_plugin.h" -#include "log_settings_page.h" -#include "qt_displayer.h" - -#include "../core/icore.h" -#include "../core/core_constants.h" -#include "../core/menu_manager.h" -#include "../../extension_system/iplugin_spec.h" - -// Qt includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// NeL includes -#include - -namespace Plugin -{ - - CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent) - { - m_ui.setupUi(this); - } - - CLogPlugin::~CLogPlugin() - { - Q_FOREACH(QObject *obj, m_autoReleaseObjects) - { - m_plugMan->removeObject(obj); - } - qDeleteAll(m_autoReleaseObjects); - m_autoReleaseObjects.clear(); - - NLMISC::ErrorLog->removeDisplayer(m_displayer); - NLMISC::WarningLog->removeDisplayer(m_displayer); - NLMISC::DebugLog->removeDisplayer(m_displayer); - NLMISC::AssertLog->removeDisplayer(m_displayer); - NLMISC::InfoLog->removeDisplayer(m_displayer); - delete m_displayer; - } - - bool CLogPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) - { - Q_UNUSED(errorString); - m_plugMan = pluginManager; - m_logSettingsPage = new CLogSettingsPage(this, this); - addAutoReleasedObject(m_logSettingsPage); - return true; - } - - void CLogPlugin::extensionsInitialized() - { - setDisplayers(); - - Core::ICore *core = Core::ICore::instance(); - Core::MenuManager *menuManager = core->menuManager(); - QMenu *viewMenu = menuManager->menu(Core::Constants::M_VIEW); - - QMainWindow *wnd = Core::ICore::instance()->mainWindow(); - wnd->addDockWidget(Qt::RightDockWidgetArea, this); - hide(); - - viewMenu->addAction(this->toggleViewAction()); - } - - void CLogPlugin::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 // fdef NL_OS_WINDOWS^M - m_libContext = new NLMISC::CLibraryContext(*nelContext); - - m_displayer = new NLQT::CQtDisplayer(m_ui.plainTextEdit); - - } - - QString CLogPlugin::name() const - { - return "LogPlugin"; - } - - QString CLogPlugin::version() const - { - return "1.1"; - } - - QString CLogPlugin::vendor() const - { - return "aquiles"; - } - - QString CLogPlugin::description() const - { - return tr("DockWidget to display all log messages from NeL."); - } - - QStringList CLogPlugin::dependencies() const - { - QStringList list; - list.append(Core::Constants::OVQT_CORE_PLUGIN); - return list; - } - - void CLogPlugin::addAutoReleasedObject(QObject *obj) - { - m_plugMan->addObject(obj); - m_autoReleaseObjects.prepend(obj); - } - - void CLogPlugin::setDisplayers() - { - QSettings *settings = Core::ICore::instance()->settings(); - - settings->beginGroup(Core::Constants::LOG_SECTION); +// Object Viewer Qt - Log Plugin - MMORPG Framework +// Copyright (C) 2011 Adrian Jaekel +// +// 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 "log_plugin.h" +#include "log_settings_page.h" +#include "qt_displayer.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" +#include "../core/menu_manager.h" +#include "../../extension_system/iplugin_spec.h" + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// NeL includes +#include + +namespace Plugin +{ + + CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent) + { + m_ui.setupUi(this); + } + + CLogPlugin::~CLogPlugin() + { + Q_FOREACH(QObject *obj, m_autoReleaseObjects) + { + m_plugMan->removeObject(obj); + } + qDeleteAll(m_autoReleaseObjects); + m_autoReleaseObjects.clear(); + + NLMISC::ErrorLog->removeDisplayer(m_displayer); + NLMISC::WarningLog->removeDisplayer(m_displayer); + NLMISC::DebugLog->removeDisplayer(m_displayer); + NLMISC::AssertLog->removeDisplayer(m_displayer); + NLMISC::InfoLog->removeDisplayer(m_displayer); + delete m_displayer; + } + + bool CLogPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) + { + Q_UNUSED(errorString); + m_plugMan = pluginManager; + m_logSettingsPage = new CLogSettingsPage(this, this); + addAutoReleasedObject(m_logSettingsPage); + return true; + } + + void CLogPlugin::extensionsInitialized() + { + setDisplayers(); + + Core::ICore *core = Core::ICore::instance(); + Core::MenuManager *menuManager = core->menuManager(); + QMenu *viewMenu = menuManager->menu(Core::Constants::M_VIEW); + + QMainWindow *wnd = Core::ICore::instance()->mainWindow(); + wnd->addDockWidget(Qt::RightDockWidgetArea, this); + hide(); + + viewMenu->addAction(this->toggleViewAction()); + } + + void CLogPlugin::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 // fdef NL_OS_WINDOWS^M + m_libContext = new NLMISC::CLibraryContext(*nelContext); + + m_displayer = new NLQT::CQtDisplayer(m_ui.plainTextEdit); + + } + + QString CLogPlugin::name() const + { + return "LogPlugin"; + } + + QString CLogPlugin::version() const + { + return "1.1"; + } + + QString CLogPlugin::vendor() const + { + return "aquiles"; + } + + QString CLogPlugin::description() const + { + return tr("DockWidget to display all log messages from NeL."); + } + + QStringList CLogPlugin::dependencies() const + { + QStringList list; + list.append(Core::Constants::OVQT_CORE_PLUGIN); + return list; + } + + void CLogPlugin::addAutoReleasedObject(QObject *obj) + { + m_plugMan->addObject(obj); + m_autoReleaseObjects.prepend(obj); + } + + void CLogPlugin::setDisplayers() + { + QSettings *settings = Core::ICore::instance()->settings(); + + settings->beginGroup(Core::Constants::LOG_SECTION); bool error = settings->value(Core::Constants::LOG_ERROR, true).toBool(); bool warning = settings->value(Core::Constants::LOG_WARNING, true).toBool(); bool debug = settings->value(Core::Constants::LOG_DEBUG, true).toBool(); bool assert = settings->value(Core::Constants::LOG_ASSERT, true).toBool(); - bool info = settings->value(Core::Constants::LOG_INFO, true).toBool(); - settings->endGroup(); - - if (error) { - if (!NLMISC::ErrorLog->attached(m_displayer)) - NLMISC::ErrorLog->addDisplayer(m_displayer); - } else { - if (m_displayer) { - NLMISC::ErrorLog->removeDisplayer(m_displayer); - } - } - if (warning) { - if (!NLMISC::WarningLog->attached(m_displayer)) - NLMISC::WarningLog->addDisplayer(m_displayer); - } else { - if (m_displayer) { - NLMISC::WarningLog->removeDisplayer(m_displayer); - } - } - if (debug) { - if (!NLMISC::DebugLog->attached(m_displayer)) - NLMISC::DebugLog->addDisplayer(m_displayer); - } else { - if (m_displayer) { - NLMISC::DebugLog->removeDisplayer(m_displayer); - } - } - if (assert) { - if (!NLMISC::AssertLog->attached(m_displayer)) - NLMISC::AssertLog->addDisplayer(m_displayer); - } else { - if (m_displayer) { - NLMISC::AssertLog->removeDisplayer(m_displayer); - } - } - if (info) { - if (!NLMISC::InfoLog->attached(m_displayer)) - NLMISC::InfoLog->addDisplayer(m_displayer); - } else { - if (m_displayer) { - NLMISC::InfoLog->removeDisplayer(m_displayer); - } - } - } -} -Q_EXPORT_PLUGIN(Plugin::CLogPlugin) + bool info = settings->value(Core::Constants::LOG_INFO, true).toBool(); + settings->endGroup(); + + if (error) { + if (!NLMISC::ErrorLog->attached(m_displayer)) + NLMISC::ErrorLog->addDisplayer(m_displayer); + } else { + if (m_displayer) { + NLMISC::ErrorLog->removeDisplayer(m_displayer); + } + } + if (warning) { + if (!NLMISC::WarningLog->attached(m_displayer)) + NLMISC::WarningLog->addDisplayer(m_displayer); + } else { + if (m_displayer) { + NLMISC::WarningLog->removeDisplayer(m_displayer); + } + } + if (debug) { + if (!NLMISC::DebugLog->attached(m_displayer)) + NLMISC::DebugLog->addDisplayer(m_displayer); + } else { + if (m_displayer) { + NLMISC::DebugLog->removeDisplayer(m_displayer); + } + } + if (assert) { + if (!NLMISC::AssertLog->attached(m_displayer)) + NLMISC::AssertLog->addDisplayer(m_displayer); + } else { + if (m_displayer) { + NLMISC::AssertLog->removeDisplayer(m_displayer); + } + } + if (info) { + if (!NLMISC::InfoLog->attached(m_displayer)) + NLMISC::InfoLog->addDisplayer(m_displayer); + } else { + if (m_displayer) { + NLMISC::InfoLog->removeDisplayer(m_displayer); + } + } + } +} +Q_EXPORT_PLUGIN(Plugin::CLogPlugin) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.h index 6a2d78f79..2221195a8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.h @@ -1,33 +1,33 @@ -/* -Log Plugin Qt -Copyright (C) 2011 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - +/* +Log Plugin Qt +Copyright (C) 2011 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + */ #ifndef LOG_PLUGIN_H #define LOG_PLUGIN_H -// Project includes +// Project includes #include "ui_log_form.h" #include "../../extension_system/iplugin.h" // NeL includes #include "nel/misc/app_context.h" -// Qt includes +// Qt includes #include namespace NLMISC @@ -54,7 +54,7 @@ namespace Plugin Q_OBJECT Q_INTERFACES(ExtensionSystem::IPlugin) public: - CLogPlugin(QWidget *parent = 0); + CLogPlugin(QWidget *parent = 0); ~CLogPlugin(); bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); @@ -63,26 +63,26 @@ namespace Plugin void setNelContext(NLMISC::INelContext *nelContext); NLQT::CQtDisplayer* displayer() { return m_displayer; } - QString name() const; - QString version() const; - QString vendor() const; + QString name() const; + QString version() const; + QString vendor() const; QString description() const; - QStringList dependencies() const; - - void addAutoReleasedObject(QObject *obj); - - void setDisplayers(); - - protected: - NLMISC::CLibraryContext *m_libContext; + QStringList dependencies() const; + + void addAutoReleasedObject(QObject *obj); + + void setDisplayers(); + + protected: + NLMISC::CLibraryContext *m_libContext; private: ExtensionSystem::IPluginManager *m_plugMan; QList m_autoReleaseObjects; CLogSettingsPage *m_logSettingsPage; - Ui::CLogPlugin m_ui; - + Ui::CLogPlugin m_ui; + NLQT::CQtDisplayer *m_displayer; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_settings_page.cpp index 3aba359a5..4b3fa1ebb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_settings_page.cpp @@ -1,133 +1,133 @@ -// Object Viewer Qt - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// Copyright (C) 2011 Adrian Jaekel -// -// 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 "log_settings_page.h" -#include "log_plugin.h" -#include "../core/core_constants.h" -#include "../core/icore.h" -#include "../../extension_system/plugin_manager.h" - -// NeL includes - -// Qt includes -#include -#include - +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Adrian Jaekel +// +// 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 "log_settings_page.h" +#include "log_plugin.h" +#include "../core/core_constants.h" +#include "../core/icore.h" +#include "../../extension_system/plugin_manager.h" + +// NeL includes + +// Qt includes +#include +#include + namespace ExtensionSystem { - class IPluginManager; -} - -namespace Plugin -{ - - class CLogPlugin; - - CLogSettingsPage::CLogSettingsPage(CLogPlugin *logPlugin, QObject *parent) - : IOptionsPage(parent), - m_logPlugin(logPlugin), - m_currentPage(NULL), + class IPluginManager; +} + +namespace Plugin +{ + + class CLogPlugin; + + CLogSettingsPage::CLogSettingsPage(CLogPlugin *logPlugin, QObject *parent) + : IOptionsPage(parent), + m_logPlugin(logPlugin), + m_currentPage(NULL), m_error(true), m_warning(true), m_debug(true), m_assert(true), - m_info(true) - { - } - - QString CLogSettingsPage::id() const - { - return QLatin1String("log"); - } - - QString CLogSettingsPage::trName() const - { - return tr("Log"); - } - - QString CLogSettingsPage::category() const - { - return QLatin1String(Core::Constants::SETTINGS_CATEGORY_GENERAL); - } - - QString CLogSettingsPage::trCategory() const - { - return tr(Core::Constants::SETTINGS_TR_CATEGORY_GENERAL); - } - - QIcon CLogSettingsPage::categoryIcon() const - { - return QIcon(); - } - - QWidget *CLogSettingsPage::createPage(QWidget *parent) - { - m_currentPage = new QWidget(parent); - m_ui.setupUi(m_currentPage); - - readSettings(); - m_ui.errorCheck->setChecked(m_error); - m_ui.warningCheck->setChecked(m_warning); - m_ui.debugCheck->setChecked(m_debug); - m_ui.assertCheck->setChecked(m_assert); - m_ui.infoCheck->setChecked(m_info); - - return m_currentPage; - } - - void CLogSettingsPage::apply() - { - m_error = m_ui.errorCheck->isChecked(); - m_warning = m_ui.warningCheck->isChecked(); - m_debug = m_ui.debugCheck->isChecked(); - m_assert = m_ui.assertCheck->isChecked(); - m_info = m_ui.infoCheck->isChecked(); - - writeSettings(); - m_logPlugin->setDisplayers(); - } - - void CLogSettingsPage::readSettings() - { - QSettings *settings = Core::ICore::instance()->settings(); - - settings->beginGroup(Core::Constants::LOG_SECTION); + m_info(true) + { + } + + QString CLogSettingsPage::id() const + { + return QLatin1String("log"); + } + + QString CLogSettingsPage::trName() const + { + return tr("Log"); + } + + QString CLogSettingsPage::category() const + { + return QLatin1String(Core::Constants::SETTINGS_CATEGORY_GENERAL); + } + + QString CLogSettingsPage::trCategory() const + { + return tr(Core::Constants::SETTINGS_TR_CATEGORY_GENERAL); + } + + QIcon CLogSettingsPage::categoryIcon() const + { + return QIcon(); + } + + QWidget *CLogSettingsPage::createPage(QWidget *parent) + { + m_currentPage = new QWidget(parent); + m_ui.setupUi(m_currentPage); + + readSettings(); + m_ui.errorCheck->setChecked(m_error); + m_ui.warningCheck->setChecked(m_warning); + m_ui.debugCheck->setChecked(m_debug); + m_ui.assertCheck->setChecked(m_assert); + m_ui.infoCheck->setChecked(m_info); + + return m_currentPage; + } + + void CLogSettingsPage::apply() + { + m_error = m_ui.errorCheck->isChecked(); + m_warning = m_ui.warningCheck->isChecked(); + m_debug = m_ui.debugCheck->isChecked(); + m_assert = m_ui.assertCheck->isChecked(); + m_info = m_ui.infoCheck->isChecked(); + + writeSettings(); + m_logPlugin->setDisplayers(); + } + + void CLogSettingsPage::readSettings() + { + QSettings *settings = Core::ICore::instance()->settings(); + + settings->beginGroup(Core::Constants::LOG_SECTION); m_error = settings->value(Core::Constants::LOG_ERROR, true).toBool(); m_warning = settings->value(Core::Constants::LOG_WARNING, true).toBool(); m_debug = settings->value(Core::Constants::LOG_DEBUG, true).toBool(); m_assert = settings->value(Core::Constants::LOG_ASSERT, true).toBool(); - m_info = settings->value(Core::Constants::LOG_INFO, true).toBool(); - settings->endGroup(); - } - - void CLogSettingsPage::writeSettings() - { - QSettings *settings = Core::ICore::instance()->settings(); - - settings->beginGroup(Core::Constants::LOG_SECTION); - settings->setValue(Core::Constants::LOG_ERROR, m_error); - settings->setValue(Core::Constants::LOG_WARNING, m_warning); - settings->setValue(Core::Constants::LOG_DEBUG, m_debug); - settings->setValue(Core::Constants::LOG_ASSERT, m_assert); - settings->setValue(Core::Constants::LOG_INFO, m_info); - settings->endGroup(); - - settings->sync(); - } - + m_info = settings->value(Core::Constants::LOG_INFO, true).toBool(); + settings->endGroup(); + } + + void CLogSettingsPage::writeSettings() + { + QSettings *settings = Core::ICore::instance()->settings(); + + settings->beginGroup(Core::Constants::LOG_SECTION); + settings->setValue(Core::Constants::LOG_ERROR, m_error); + settings->setValue(Core::Constants::LOG_WARNING, m_warning); + settings->setValue(Core::Constants::LOG_DEBUG, m_debug); + settings->setValue(Core::Constants::LOG_ASSERT, m_assert); + settings->setValue(Core::Constants::LOG_INFO, m_info); + settings->endGroup(); + + settings->sync(); + } + } /* namespace Plugin */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h index 1dffea313..dc19db1c6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h @@ -1,56 +1,56 @@ -#ifndef MISSION_COMPILER_MAIN_WINDOW_H -#define MISSION_COMPILER_MAIN_WINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace Ui { - class MissionCompilerMainWindow; -} - -struct CMission; - -class MissionCompilerMainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MissionCompilerMainWindow(QWidget *parent = 0); - ~MissionCompilerMainWindow(); - - void loadConfig(); - void saveConfig(); - QUndoStack *getUndoStack() { return m_undoStack; } - - typedef std::map TMissionContainer; - -public Q_SLOTS: - void handleFilterChanged(const QString &text); - void handleValidation(); - void handleCompile(); - void handlePublish(); - void handleAllDoubleClick(const QModelIndex &index); - void handleSelDoubleClick(const QModelIndex &index); - void handleMoveSelectedRight(); - void handleMoveSelectedLeft(); - void handleMoveAllRight(); - void handleMoveAllLeft(); - void handleDataDirButton(); - void handleDataDirChanged(const QString &text); - void handleResetFiltersButton(); - void handleChangedSettings(); - -private: - Ui::MissionCompilerMainWindow *ui; +#ifndef MISSION_COMPILER_MAIN_WINDOW_H +#define MISSION_COMPILER_MAIN_WINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace Ui { + class MissionCompilerMainWindow; +} + +struct CMission; + +class MissionCompilerMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MissionCompilerMainWindow(QWidget *parent = 0); + ~MissionCompilerMainWindow(); + + void loadConfig(); + void saveConfig(); + QUndoStack *getUndoStack() { return m_undoStack; } + + typedef std::map TMissionContainer; + +public Q_SLOTS: + void handleFilterChanged(const QString &text); + void handleValidation(); + void handleCompile(); + void handlePublish(); + void handleAllDoubleClick(const QModelIndex &index); + void handleSelDoubleClick(const QModelIndex &index); + void handleMoveSelectedRight(); + void handleMoveSelectedLeft(); + void handleMoveAllRight(); + void handleMoveAllLeft(); + void handleDataDirButton(); + void handleDataDirChanged(const QString &text); + void handleResetFiltersButton(); + void handleChangedSettings(); + +private: + Ui::MissionCompilerMainWindow *ui; void updateCompileLog(); void populateAllPrimitives(const QString &dataDir = QString()); @@ -60,16 +60,16 @@ private: void applyCheckboxes(const QStringList &servers); - QMenu *_toolModeMenu; - QUndoStack *m_undoStack; - QStringListModel *m_allPrimitivesModel; - QStringListModel *m_selectedPrimitivesModel; - QSortFilterProxyModel *m_filteredProxyModel; - QRegExp *m_regexpFilter; - QString m_compileLog; - QString m_lastDir; - - NLLIGO::CLigoConfig m_ligoConfig; -}; - -#endif // MISSION_COMPILER_MAIN_WINDOW_H + QMenu *_toolModeMenu; + QUndoStack *m_undoStack; + QStringListModel *m_allPrimitivesModel; + QStringListModel *m_selectedPrimitivesModel; + QSortFilterProxyModel *m_filteredProxyModel; + QRegExp *m_regexpFilter; + QString m_compileLog; + QString m_lastDir; + + NLLIGO::CLigoConfig m_ligoConfig; +}; + +#endif // MISSION_COMPILER_MAIN_WINDOW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp index a9ef08f50..206f0db77 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.cpp @@ -1,63 +1,63 @@ -// 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 "server_entry_dialog.h" - -#include "ui_server_entry_dialog.h" - -// NeL includes - -// Qt includes -#include - -namespace MissionCompiler -{ - -ServerEntryDialog::ServerEntryDialog(QWidget *parent) - : QDialog(parent), - m_ui(new Ui::ServerEntryDialog) -{ - m_ui->setupUi(this); - - connect(m_ui->serverTextPathButton, SIGNAL(clicked()), this, SLOT(lookupTextPath())); - connect(m_ui->serverPrimPathButton, SIGNAL(clicked()), this, SLOT(lookupPrimPath())); -} - -ServerEntryDialog::~ServerEntryDialog() -{ - delete m_ui; -} - +// 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 "server_entry_dialog.h" + +#include "ui_server_entry_dialog.h" + +// NeL includes + +// Qt includes +#include + +namespace MissionCompiler +{ + +ServerEntryDialog::ServerEntryDialog(QWidget *parent) + : QDialog(parent), + m_ui(new Ui::ServerEntryDialog) +{ + m_ui->setupUi(this); + + connect(m_ui->serverTextPathButton, SIGNAL(clicked()), this, SLOT(lookupTextPath())); + connect(m_ui->serverPrimPathButton, SIGNAL(clicked()), this, SLOT(lookupPrimPath())); +} + +ServerEntryDialog::~ServerEntryDialog() +{ + delete m_ui; +} + QString ServerEntryDialog::getServerName() { return m_ui->serverNameEdit->text(); } -QString ServerEntryDialog::getTextPath() -{ - return m_ui->serverTextPathEdit->text(); -} - -QString ServerEntryDialog::getPrimPath() -{ - return m_ui->serverPrimPathEdit->text(); -} - +QString ServerEntryDialog::getTextPath() +{ + return m_ui->serverTextPathEdit->text(); +} + +QString ServerEntryDialog::getPrimPath() +{ + return m_ui->serverPrimPathEdit->text(); +} + void ServerEntryDialog::setServerName(QString name) { m_ui->serverNameEdit->setText(name); @@ -68,22 +68,22 @@ void ServerEntryDialog::setTextPath(QString path) m_ui->serverTextPathEdit->setText(path); } -void ServerEntryDialog::setPrimPath(QString path) -{ - m_ui->serverPrimPathEdit->setText(path); -} - -void ServerEntryDialog::lookupTextPath() -{ - QString curPath = m_ui->serverTextPathEdit->text(); - QString path = QFileDialog::getExistingDirectory(this, "", curPath); - m_ui->serverTextPathEdit->setText(path); -} - -void ServerEntryDialog::lookupPrimPath() -{ - QString curPath = m_ui->serverPrimPathEdit->text(); - QString path = QFileDialog::getExistingDirectory(this, "", curPath); - m_ui->serverPrimPathEdit->setText(path); -} +void ServerEntryDialog::setPrimPath(QString path) +{ + m_ui->serverPrimPathEdit->setText(path); +} + +void ServerEntryDialog::lookupTextPath() +{ + QString curPath = m_ui->serverTextPathEdit->text(); + QString path = QFileDialog::getExistingDirectory(this, "", curPath); + m_ui->serverTextPathEdit->setText(path); +} + +void ServerEntryDialog::lookupPrimPath() +{ + QString curPath = m_ui->serverPrimPathEdit->text(); + QString path = QFileDialog::getExistingDirectory(this, "", curPath); + m_ui->serverPrimPathEdit->setText(path); +} } /* namespace MissionCompiler */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h index 98a086cd0..6dd560876 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/server_entry_dialog.h @@ -21,8 +21,8 @@ #include -namespace Ui { - class ServerEntryDialog; +namespace Ui { + class ServerEntryDialog; } namespace MissionCompiler diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.cpp index e0c2dab0c..8cbc89200 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.cpp @@ -1,155 +1,155 @@ -#include "zone_painter_main_window.h" -#include "ui_zone_painter_main_window.h" - -#include -#include -#include -#include -#include - -#include "qnel_widget.h" -#include "painter_dock_widget.h" - -#include "../core/icore.h" -#include "../core/menu_manager.h" -#include "../core/core_constants.h" - -ZonePainterMainWindow::ZonePainterMainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::ZonePainterMainWindow) -{ - ui->setupUi(this); - m_nelWidget = new NLQT::QNLWidget(this); - setCentralWidget(m_nelWidget); - - // Load the settings. - loadConfig(); - - // Set up dock widget(s) and toolbar. - m_painterDockWidget = new PainterDockWidget(this); - addDockWidget(Qt::RightDockWidgetArea, m_painterDockWidget); - m_painterDockWidget->setVisible(true); - - // Insert tool modes - _toolModeMenu = new QMenu(tr("Tool Mode"), ui->painterToolBar); - _toolModeMenu->setIcon(QIcon(":/painterTools/images/draw-brush.png")); - ui->painterToolBar->addAction(_toolModeMenu->menuAction()); - //connect(_renderModeMenu->menuAction(), SIGNAL(triggered()), this, SLOT(setRenderMode())); - - QSignalMapper *modeMapper = new QSignalMapper(this); - - _toolPaintModeAction = _toolModeMenu->addAction(tr("Paint Mode")); - _toolPaintModeAction->setIcon(QIcon(":/painterTools/images/draw-brush.png")); - _toolPaintModeAction->setStatusTip(tr("Set paint mode")); - connect(_toolPaintModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); - modeMapper->setMapping(_toolPaintModeAction, 0); - - _toolFillModeAction = _toolModeMenu->addAction(tr("Fill Mode")); - _toolFillModeAction->setStatusTip(tr("Set fill mode")); - _toolFillModeAction->setIcon(QIcon(":/painterTools/images/color-fill.png")); - connect(_toolFillModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); - modeMapper->setMapping(_toolFillModeAction, 1); - - _toolSelectModeAction = _toolModeMenu->addAction(tr("Select mode")); - _toolSelectModeAction->setIcon(QIcon(":/painterTools/images/go-jump-4.png")); - _toolSelectModeAction->setStatusTip(tr("Set select mode")); - connect(_toolSelectModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); - modeMapper->setMapping(_toolSelectModeAction, 2); - - _toolPickModeAction = _toolModeMenu->addAction(tr("Pick mode")); - _toolPickModeAction->setIcon(QIcon(":/painterTools/images/color-picker-black.png")); - _toolPickModeAction->setStatusTip(tr("Set color picking mode")); - connect(_toolPickModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); - modeMapper->setMapping(_toolPickModeAction, 2); - - connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(setToolMode(int))); - - m_statusBarTimer = new QTimer(this); - connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); - m_statusInfo = new QLabel(this); - m_statusInfo->hide(); - - // Set Background Color Toolbar - - - connect(ui->actionBackground_Dlg, SIGNAL(triggered()), this, SLOT(setBackgroundColor())); - - - Core::ICore::instance()->mainWindow()->statusBar()->addPermanentWidget(m_statusInfo); - - m_undoStack = new QUndoStack(this); -} - -void ZonePainterMainWindow::showEvent(QShowEvent *showEvent) -{ - QMainWindow::showEvent(showEvent); - m_statusBarTimer->start(1000); - m_statusInfo->show(); -} - -void ZonePainterMainWindow::hideEvent(QHideEvent *hideEvent) -{ - m_statusBarTimer->stop(); - m_statusInfo->hide(); - QMainWindow::hideEvent(hideEvent); -} - -void ZonePainterMainWindow::updateStatusBar() -{ - m_statusInfo->setText(QString("Tool Mode: Paint Mode")); -} - -void ZonePainterMainWindow::setToolMode(int value) -{ - switch (value) - { - case 0: - //Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Point); - break; - case 1: - //Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Line); - break; - case 2: - //Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Filled); - break; - } -} - -void ZonePainterMainWindow::setToolMode() -{ - //switch (Modules::objView().getDriver()->getPolygonMode()) - //{ - //case NL3D::UDriver::Filled: - // Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Line); - // break; - //case NL3D::UDriver::Line: - // Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Point); - // break; - //case NL3D::UDriver::Point: - // Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Filled); - // break; - //} -} - -void ZonePainterMainWindow::setBackgroundColor() { - QColor color = QColorDialog::getColor(QColor(m_nelWidget->backgroundColor().R, - m_nelWidget->backgroundColor().G, - m_nelWidget->backgroundColor().B)); - if (color.isValid()) - m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue())); -} - -void ZonePainterMainWindow::loadConfig() { +#include "zone_painter_main_window.h" +#include "ui_zone_painter_main_window.h" + +#include +#include +#include +#include +#include + +#include "qnel_widget.h" +#include "painter_dock_widget.h" + +#include "../core/icore.h" +#include "../core/menu_manager.h" +#include "../core/core_constants.h" + +ZonePainterMainWindow::ZonePainterMainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::ZonePainterMainWindow) +{ + ui->setupUi(this); + m_nelWidget = new NLQT::QNLWidget(this); + setCentralWidget(m_nelWidget); + + // Load the settings. + loadConfig(); + + // Set up dock widget(s) and toolbar. + m_painterDockWidget = new PainterDockWidget(this); + addDockWidget(Qt::RightDockWidgetArea, m_painterDockWidget); + m_painterDockWidget->setVisible(true); + + // Insert tool modes + _toolModeMenu = new QMenu(tr("Tool Mode"), ui->painterToolBar); + _toolModeMenu->setIcon(QIcon(":/painterTools/images/draw-brush.png")); + ui->painterToolBar->addAction(_toolModeMenu->menuAction()); + //connect(_renderModeMenu->menuAction(), SIGNAL(triggered()), this, SLOT(setRenderMode())); + + QSignalMapper *modeMapper = new QSignalMapper(this); + + _toolPaintModeAction = _toolModeMenu->addAction(tr("Paint Mode")); + _toolPaintModeAction->setIcon(QIcon(":/painterTools/images/draw-brush.png")); + _toolPaintModeAction->setStatusTip(tr("Set paint mode")); + connect(_toolPaintModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); + modeMapper->setMapping(_toolPaintModeAction, 0); + + _toolFillModeAction = _toolModeMenu->addAction(tr("Fill Mode")); + _toolFillModeAction->setStatusTip(tr("Set fill mode")); + _toolFillModeAction->setIcon(QIcon(":/painterTools/images/color-fill.png")); + connect(_toolFillModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); + modeMapper->setMapping(_toolFillModeAction, 1); + + _toolSelectModeAction = _toolModeMenu->addAction(tr("Select mode")); + _toolSelectModeAction->setIcon(QIcon(":/painterTools/images/go-jump-4.png")); + _toolSelectModeAction->setStatusTip(tr("Set select mode")); + connect(_toolSelectModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); + modeMapper->setMapping(_toolSelectModeAction, 2); + + _toolPickModeAction = _toolModeMenu->addAction(tr("Pick mode")); + _toolPickModeAction->setIcon(QIcon(":/painterTools/images/color-picker-black.png")); + _toolPickModeAction->setStatusTip(tr("Set color picking mode")); + connect(_toolPickModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); + modeMapper->setMapping(_toolPickModeAction, 2); + + connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(setToolMode(int))); + + m_statusBarTimer = new QTimer(this); + connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); + m_statusInfo = new QLabel(this); + m_statusInfo->hide(); + + // Set Background Color Toolbar + + + connect(ui->actionBackground_Dlg, SIGNAL(triggered()), this, SLOT(setBackgroundColor())); + + + Core::ICore::instance()->mainWindow()->statusBar()->addPermanentWidget(m_statusInfo); + + m_undoStack = new QUndoStack(this); +} + +void ZonePainterMainWindow::showEvent(QShowEvent *showEvent) +{ + QMainWindow::showEvent(showEvent); + m_statusBarTimer->start(1000); + m_statusInfo->show(); +} + +void ZonePainterMainWindow::hideEvent(QHideEvent *hideEvent) +{ + m_statusBarTimer->stop(); + m_statusInfo->hide(); + QMainWindow::hideEvent(hideEvent); +} + +void ZonePainterMainWindow::updateStatusBar() +{ + m_statusInfo->setText(QString("Tool Mode: Paint Mode")); +} + +void ZonePainterMainWindow::setToolMode(int value) +{ + switch (value) + { + case 0: + //Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Point); + break; + case 1: + //Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Line); + break; + case 2: + //Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Filled); + break; + } +} + +void ZonePainterMainWindow::setToolMode() +{ + //switch (Modules::objView().getDriver()->getPolygonMode()) + //{ + //case NL3D::UDriver::Filled: + // Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Line); + // break; + //case NL3D::UDriver::Line: + // Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Point); + // break; + //case NL3D::UDriver::Point: + // Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Filled); + // break; + //} +} + +void ZonePainterMainWindow::setBackgroundColor() { + QColor color = QColorDialog::getColor(QColor(m_nelWidget->backgroundColor().R, + m_nelWidget->backgroundColor().G, + m_nelWidget->backgroundColor().B)); + if (color.isValid()) + m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue())); +} + +void ZonePainterMainWindow::loadConfig() { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("ZonePainter"); QColor color; color = settings->value("BackgroundColor", QColor(80, 80, 80)).value(); settings->endGroup(); - m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha())); -} - -void ZonePainterMainWindow::saveConfig() { + m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha())); +} + +void ZonePainterMainWindow::saveConfig() { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("ZonePainter" ); @@ -157,12 +157,12 @@ void ZonePainterMainWindow::saveConfig() { settings->setValue("BackgroundColor", color); settings->endGroup(); - settings->sync(); -} - -ZonePainterMainWindow::~ZonePainterMainWindow() -{ - delete ui; - delete m_nelWidget; - delete m_painterDockWidget; -} + settings->sync(); +} + +ZonePainterMainWindow::~ZonePainterMainWindow() +{ + delete ui; + delete m_nelWidget; + delete m_painterDockWidget; +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.h index 0dbfd9948..caa4433e4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.h @@ -1,57 +1,57 @@ -#ifndef ZONE_PAINTER_MAIN_WINDOW_H -#define ZONE_PAINTER_MAIN_WINDOW_H - -#include -#include -#include -#include -#include - -namespace NLQT { - class QNLWidget; -} - -namespace Ui { - class ZonePainterMainWindow; -} - -class PainterDockWidget; - -class ZonePainterMainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit ZonePainterMainWindow(QWidget *parent = 0); - ~ZonePainterMainWindow(); - - void loadConfig(); - void saveConfig(); - QUndoStack *getUndoStack() { return m_undoStack; } -public Q_SLOTS: +#ifndef ZONE_PAINTER_MAIN_WINDOW_H +#define ZONE_PAINTER_MAIN_WINDOW_H + +#include +#include +#include +#include +#include + +namespace NLQT { + class QNLWidget; +} + +namespace Ui { + class ZonePainterMainWindow; +} + +class PainterDockWidget; + +class ZonePainterMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit ZonePainterMainWindow(QWidget *parent = 0); + ~ZonePainterMainWindow(); + + void loadConfig(); + void saveConfig(); + QUndoStack *getUndoStack() { return m_undoStack; } +public Q_SLOTS: void setToolMode(int value); - void setToolMode(); - void updateStatusBar(); - void setBackgroundColor(); - -protected: - virtual void showEvent(QShowEvent *showEvent); - virtual void hideEvent(QHideEvent *hideEvent); - -private: - Ui::ZonePainterMainWindow *ui; - NLQT::QNLWidget *m_nelWidget; - PainterDockWidget *m_painterDockWidget; - QTimer *m_statusBarTimer; - QLabel *m_statusInfo; - + void setToolMode(); + void updateStatusBar(); + void setBackgroundColor(); + +protected: + virtual void showEvent(QShowEvent *showEvent); + virtual void hideEvent(QHideEvent *hideEvent); + +private: + Ui::ZonePainterMainWindow *ui; + NLQT::QNLWidget *m_nelWidget; + PainterDockWidget *m_painterDockWidget; + QTimer *m_statusBarTimer; + QLabel *m_statusInfo; + QAction *_toolPaintModeAction; QAction *_toolFillModeAction; QAction *_toolSelectModeAction; QAction *_toolPickModeAction; - QMenu *_toolModeMenu; - QUndoStack *m_undoStack; - //QAction *m_setBackColorAction; -}; - -#endif // ZONE_PAINTER_MAIN_WINDOW_H + QMenu *_toolModeMenu; + QUndoStack *m_undoStack; + //QAction *m_setBackColorAction; +}; + +#endif // ZONE_PAINTER_MAIN_WINDOW_H diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp index 70bf51f81..af026b3df 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp @@ -1,724 +1,724 @@ -/* -Object Viewer Qt Widget -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "object_viewer_widget.h" - -// STL includes - -// NeL includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Qt includes -#include - -// Project includes - -Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget) - -using namespace NLMISC; -using namespace NL3D; -using namespace std; - -namespace NLQT -{ - CObjectViewerWidget *CObjectViewerWidget::_objectViewerWidget = NULL; - - CObjectViewerWidget::CObjectViewerWidget(QWidget *parent) - : _isGraphicsInitialized(false), _isGraphicsEnabled(false), - _Driver(NULL), _Light(0), _phi(0), _psi(0),_dist(2), - _CameraFocal(75), _CurrentInstance(""), _BloomEffect(false), - _Scene(0), QWidget(parent) - { +/* +Object Viewer Qt Widget +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "object_viewer_widget.h" + +// STL includes + +// NeL includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Qt includes +#include + +// Project includes + +Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget) + +using namespace NLMISC; +using namespace NL3D; +using namespace std; + +namespace NLQT +{ + CObjectViewerWidget *CObjectViewerWidget::_objectViewerWidget = NULL; + + CObjectViewerWidget::CObjectViewerWidget(QWidget *parent) + : _isGraphicsInitialized(false), _isGraphicsEnabled(false), + _Driver(NULL), _Light(0), _phi(0), _psi(0),_dist(2), + _CameraFocal(75), _CurrentInstance(""), _BloomEffect(false), + _Scene(0), QWidget(parent) + { setMouseTracking(true); - setFocusPolicy(Qt::StrongFocus); - _objectViewerWidget = this; - - _isGraphicsEnabled = true; - - // As a special case, a QTimer with a timeout of 0 will time out as soon as all the events in the window system's event queue have been processed. - // This can be used to do heavy work while providing a snappy user interface. - _mainTimer = new QTimer(this); - connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender())); - // timer->start(); // <- timeout 0 - // it's heavy on cpu, though, when no 3d driver initialized :) - _mainTimer->start(25); // 25fps - } - - CObjectViewerWidget::~CObjectViewerWidget() - { - release(); - } - - void CObjectViewerWidget::showEvent ( QShowEvent * event ) - { - if (!_mainTimer->isActive()) - { - _mainTimer->start(25); - } - } - - void CObjectViewerWidget::setNelContext(NLMISC::INelContext &nelContext) - { - _LibContext = new CLibraryContext(nelContext); - } - - void CObjectViewerWidget::init() - { - - connect(this, SIGNAL(topLevelChanged(bool)), - this, SLOT(topLevelChanged(bool))); - //H_AUTO2 - //nldebug("%d %d %d",_nlw->winId(), width(), height()); - - -#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC) - //dynamic_cast(widget())->makeCurrent(); -#endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC) - - nlWindow wnd = (nlWindow)winId(); - uint16 w = width(); - uint16 h = height(); - - setMouseTracking(true); - - // set background color from config - //NLMISC::CConfigFile::CVar v = Modules::config().getConfigFile().getVar("BackgroundColor"); - //_BackgroundColor = CRGBA(v.asInt(0), v.asInt(1), v.asInt(2)); - _BackgroundColor = CRGBA(255, 255, 255); - - // set graphics driver from config - //NLMISC::CConfigFile::CVar v2 = Modules::config().getConfigFile().getVar("GraphicsDriver"); - // Choose driver opengl to work correctly under Linux example - _Direct3D = false; //_Driver = OpenGL; - -#ifdef NL_OS_WINDOWS - //std::string driver = v2.asString(); - //if (driver == "Direct3D") _Direct3D = true; //m_Driver = Direct3D; - //else if (driver == "OpenGL") _Direct3D = false; //m_Driver = OpenGL; - //else nlwarning("Invalid driver specified, defaulting to OpenGL"); -#endif - - //Modules::config().setAndCallback("CameraFocal",CConfigCallback(this,&CObjectViewer::cfcbCameraFocal)); - //Modules::config().setAndCallback("BloomEffect",CConfigCallback(this,&CObjectViewer::cfcbBloomEffect)); - - // create the driver - nlassert(!_Driver); - - _Driver = UDriver::createDriver(0, _Direct3D, 0); - nlassert(_Driver); - - // initialize the window with config file values - _Driver->setDisplay(wnd, NL3D::UDriver::CMode(w, h, 32)); - - //_Light = ULight::createLight(); - - //// set mode of the light - //_Light->setMode(ULight::DirectionalLight); - - //// set position of the light - //_Light->setPosition(CVector(-20.f, 30.f, 10.f)); - - //// white light - //_Light->setAmbiant(CRGBA(255, 255, 255)); - - //// set and enable the light - //_Driver->setLight(0, *_Light); - //_Driver->enableLight(0); - - // Create a scene - _Scene = _Driver->createScene(true); - - _PlayListManager = _Scene->createPlayListManager(); - - //_Scene->enableLightingSystem(true); - - // create the camera - UCamera camera = _Scene->getCam(); - - camera.setTransformMode (UTransformable::DirectMatrix); - - setSizeViewport(w, h); - - // camera will look at entities - camera.lookAt(NLMISC::CVector(_dist,0,1), NLMISC::CVector(0,0,0.5)); - - NLMISC::CVector hotSpot=NLMISC::CVector(0,0,0); - - _MouseListener = _Driver->create3dMouseListener(); - _MouseListener->setMatrix(_Scene->getCam().getMatrix()); - _MouseListener->setFrustrum(_Scene->getCam().getFrustum()); - _MouseListener->setHotSpot(hotSpot); - _MouseListener->setMouseMode(U3dMouseListener::edit3d); - - NL3D::CBloomEffect::instance().setDriver(_Driver); - NL3D::CBloomEffect::instance().setScene(_Scene); - NL3D::CBloomEffect::instance().init(!_Direct3D); - //NL3D::CBloomEffect::instance().setDensityBloom(Modules::config().getConfigFile().getVar("BloomDensity").asInt()); - //NL3D::CBloomEffect::instance().setSquareBloom(Modules::config().getConfigFile().getVar("BloomSquare").asBool()); - } - - void CObjectViewerWidget::release() - { - //H_AUTO2 - nldebug(""); - - _Driver->delete3dMouseListener(_MouseListener); - - // delete all entities - deleteEntities(); - - _Scene->deletePlayListManager(_PlayListManager); - - // delete the scene - _Driver->deleteScene(_Scene); - - // delete the light - delete _Light; - - // release driver - nlassert(_Driver); - _Driver->release(); - delete _Driver; - _Driver = NULL; - } - - void CObjectViewerWidget::updateRender() - { - //nldebug("CMainWindow::updateRender"); - updateInitialization(isVisible()); - - //QModelIndex index = _dirModel->setRootPath("D:/Dev/Ryzom/code/ryzom/common/data_leveldesign/leveldesign"); - //_dirTree->setRootIndex(index); - - if (isVisible()) - { - // call all update functions - // 01. Update Utilities (configuration etc) - - // 02. Update Time (deltas) - // ... - - // 03. Update Receive (network, servertime, receive messages) - // ... - - // 04. Update Input (keyboard controls, etc) - if (_isGraphicsInitialized) - updateInput(); - - // 05. Update Weather (sky, snow, wind, fog, sun) - // ... - - // 06. Update Entities (movement, do after possible tp from incoming messages etc) - // - Move other entities - // - Update self entity - // - Move bullets - // ... - - // 07. Update Landscape (async zone loading near entity) - // ... - - // 08. Update Collisions (entities) - // - Update entities - // - Update move container (swap with Update entities? todo: check code!) - // - Update bullets - // ... - - // 09. Update Animations (playlists) - // - Needs to be either before or after entities, not sure, - // there was a problem with wrong order a while ago!!! - - - //updateAnimation(_AnimationDialog->getTime()); - updateAnimatePS(); - // 10. Update Camera (depends on entities) - // ... - - // 11. Update Interface (login, ui, etc) - // ... - - // 12. Update Sound (sound driver) - // ... - - // 13. Update Send (network, send new position etc) - // ... - - // 14. Update Debug (stuff for dev) - // ... - - if (_isGraphicsInitialized && !getDriver()->isLost()) - { - // 01. Render Driver (background color) - renderDriver(); // clear all buffers - - // 02. Render Sky (sky scene) - // ... - - // 04. Render Scene (entity scene) - renderScene(); - - // 05. Render Effects (flare) - // ... - - // 06. Render Interface 3D (player names) - // ... - - // 07. Render Debug 3D - // ... - - // 08. Render Interface 2D (chatboxes etc, optionally does have 3d) - // ... - - // 09. Render Debug 2D (stuff for dev) - renderDebug2D(); - - // swap 3d buffers - getDriver()->swapBuffers(); - } - } - } - - void CObjectViewerWidget::updateInitialization(bool visible) - { - //nldebug("CMainWindow::updateInitialization"); - bool done; - do - { - done = true; // set false whenever change - bool wantGraphics = _isGraphicsEnabled && visible; - // bool wantLandscape = wantGraphics && m_IsGraphicsInitialized && isLandscapeEnabled; - - // .. stuff that depends on other stuff goes on top to prioritize deinitialization - - // Landscape - // ... - - // Graphics (Driver) - if (_isGraphicsInitialized) - { - if (!wantGraphics) - { - //_isGraphicsInitialized = false; - //release(); - _mainTimer->stop(); - //done = false; - } - } - else - { - if (wantGraphics) - { - init(); - _isGraphicsInitialized = true; - _mainTimer->start(25); - //done = false; - } - } - } - while (!done); - } - - void CObjectViewerWidget::updateInput() - { - _Driver->EventServer.pump(); - - // New matrix from camera - _Scene->getCam().setTransformMode(NL3D::UTransformable::DirectMatrix); - _Scene->getCam().setMatrix (_MouseListener->getViewMatrix()); - - //nldebug("%s",_Scene->getCam().getMatrix().getPos().asString().c_str()); - } - - void CObjectViewerWidget::renderDriver() - { - // Render the scene. - if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) - { - NL3D::CBloomEffect::instance().initBloom(); - } - _Driver->clearBuffers(_BackgroundColor); - } - - void CObjectViewerWidget::renderScene() - { - // render the scene - _Scene->render(); - - if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) - { - NL3D::CBloomEffect::instance().endBloom(); - NL3D::CBloomEffect::instance().endInterfacesDisplayBloom(); - } - } - - void CObjectViewerWidget::renderDebug2D() - { - } - - void CObjectViewerWidget::saveScreenshot(const std::string &nameFile, bool jpg, bool png, bool tga) - { - //H_AUTO2 - - // FIXME: create screenshot path if it doesn't exist! - - // empty bitmap - CBitmap bitmap; - // copy the driver buffer to the bitmap - _Driver->getBuffer(bitmap); - // create the file name - string filename = std::string("./") + nameFile; - // write the bitmap as a jpg, png or tga to the file - if (jpg) - { - string newfilename = CFile::findNewFile(filename + ".jpg"); - COFile outputFile(newfilename); - bitmap.writeJPG(outputFile, 100); - nlinfo("Screenshot '%s' saved", newfilename.c_str()); - } - if (png) - { - string newfilename = CFile::findNewFile(filename + ".png"); - COFile outputFile(newfilename); - bitmap.writePNG(outputFile, 24); - nlinfo("Screenshot '%s' saved", newfilename.c_str()); - } - if (tga) - { - string newfilename = CFile::findNewFile(filename + ".tga"); - COFile outputFile(newfilename); - bitmap.writeTGA(outputFile, 24, false); - nlinfo("Screenshot '%s' saved", newfilename.c_str()); - } - } - - bool CObjectViewerWidget::loadMesh(const std::string &meshFileName, const std::string &skelFileName) - { - std::string fileName = CFile::getFilenameWithoutExtension(meshFileName); - if ( _Entities.count(fileName) != 0) - return false; - - CPath::addSearchPath(CFile::getPath(meshFileName), false, false); - - // create instance of the mesh character - UInstance Entity = _Scene->createInstance(meshFileName); - - CAABBox bbox; - Entity.getShapeAABBox(bbox); - setCamera(_Scene, bbox , Entity, true); - - _MouseListener->setMatrix(_Scene->getCam().getMatrix()); - - USkeleton Skeleton = _Scene->createSkeleton(skelFileName); - - // if we can't create entity, skip it - if (Entity.empty()) return false; - - // create a new entity - EIT eit = (_Entities.insert (make_pair (fileName, CEntity()))).first; - CEntity &entity = (*eit).second; - - // set the entity up - entity._Name = fileName; - entity._FileNameShape = meshFileName; - entity._FileNameSkeleton = skelFileName; - entity._Instance = Entity; - if (!Skeleton.empty()) - { - entity._Skeleton = Skeleton; - entity._Skeleton.bindSkin (entity._Instance); - } - entity._AnimationSet = _Driver->createAnimationSet(false); - entity._PlayList = _PlayListManager->createPlayList(entity._AnimationSet); - return true; - } - - void CObjectViewerWidget::setVisible(bool visible) - { - // called by show() - // code assuming visible window needed to init the 3d driver - nldebug("%d", visible); - if (visible) - { - QWidget::setVisible(true); - } - else - { - QWidget::setVisible(false); - } - } - - void CObjectViewerWidget::resetScene() - { - deleteEntities(); - - // Reset camera. - //.. - - // to load files with the same name but located in different directories - //CPath::clearMap(); - - // load and set search paths from config - //Modules::config().configSearchPaths(); - - _CurrentInstance = ""; - - nlinfo("Scene cleared"); - } - - void CObjectViewerWidget::setBackgroundColor(NLMISC::CRGBA backgroundColor) - { - _BackgroundColor = backgroundColor; - - // config file variable changes - //Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.R, 0); - //Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.G, 1); - //Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.B, 2); - } - - void CObjectViewerWidget::setGraphicsDriver(bool Direct3D) - { - //_Direct3D = Direct3D; - - //if (_Direct3D) Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString("Direct3D"); - //else Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString("OpenGL"); - } - - void CObjectViewerWidget::setSizeViewport(uint16 w, uint16 h) - { - _Scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)w/h, 0.1f, 1000); - } - - void CObjectViewerWidget::setCurrentObject(const std::string &name) - { - if ((_Entities.count(name) != 0) || ( name.empty() )) _CurrentInstance = name; - else nlerror ("Entity %s not found", name.c_str()); - nlinfo("set current entity %s", _CurrentInstance.c_str()); - } - - CEntity& CObjectViewerWidget::getEntity(const std::string &name) - { - if ( _Entities.count(name) == 0) nlerror("Entity %s not found", name.c_str()); - EIT eit = _Entities.find (name); - return (*eit).second; - } - - void CObjectViewerWidget::getListObjects(std::vector &listObj) - { - listObj.clear(); - for (EIT eit = _Entities.begin(); eit != _Entities.end(); ++eit) - listObj.push_back((*eit).second._Name); - } - - void CObjectViewerWidget::deleteEntity(CEntity &entity) - { - if (entity._PlayList != NULL) - { - _PlayListManager->deletePlayList (entity._PlayList); - entity._PlayList = NULL; - } - - if (entity._AnimationSet != NULL) - { - _Driver->deleteAnimationSet(entity._AnimationSet); - entity._AnimationSet = NULL; - } - - if (!entity._Skeleton.empty()) - { - entity._Skeleton.detachSkeletonSon(entity._Instance); - - _Scene->deleteSkeleton(entity._Skeleton); - entity._Skeleton = NULL; - } - - if (!entity._Instance.empty()) - { - _Scene->deleteInstance(entity._Instance); - entity._Instance = NULL; - } - } - - void CObjectViewerWidget::deleteEntities() - { - for (EIT eit = _Entities.begin(); eit != _Entities.end(); ++eit) - { - CEntity &entity = (*eit).second; - deleteEntity(entity); - } - _Entities.clear(); - } - - void CObjectViewerWidget::setCamera(NL3D::UScene *scene, CAABBox &bbox, UTransform &entity, bool high_z) - { - CVector pos(0.f, 0.f, 0.f); - CQuat quat(0.f, 0.f, 0.f, 0.f); - NL3D::UInstance inst; - inst.cast(entity); - if (!inst.empty()) - { - inst.getDefaultPos(pos); - inst.getDefaultRotQuat(quat); - } - - // fix scale (some shapes have a different value) - entity.setScale(1.f, 1.f, 1.f); - - UCamera Camera = scene->getCam(); - CVector max_radius = bbox.getHalfSize(); - - CVector center = bbox.getCenter(); - entity.setPivot(center); - center += pos; - - //scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)w/h, 0.1f, 1000); - float fov = float(_CameraFocal * (float)Pi/180.0); - //Camera.setPerspective (fov, 1.0f, 0.1f, 1000.0f); - float radius = max(max(max_radius.x, max_radius.y), max_radius.z); - if (radius == 0.f) radius = 1.f; - float left, right, bottom, top, znear, zfar; - Camera.getFrustum(left, right, bottom, top, znear, zfar); - float dist = (radius / (tan(fov/2))) * 0.2; - CVector eye(center); - CVector ax(quat.getAxis()); - - if (ax.isNull() || ax == CVector::I) - { - ax = CVector::J; - } - else if (ax == -CVector::K) - { - ax = -CVector::J; - } - - eye -= ax * (dist+radius); - if (high_z) - eye.z += max_radius.z/1.0f; - Camera.lookAt(eye, center); - setupLight(eye, center - eye); - } - - bool CObjectViewerWidget::setupLight(const CVector &position, const CVector &direction) - { - if (!_Light) - _Light = ULight::createLight(); - if (!_Light) return false; - - // set mode of the light - _Light->setMode(ULight::DirectionalLight); - - // set position of the light - // Light->setupDirectional(settings.light_ambiant, settings.light_diffuse, settings.light_specular, settings.light_direction); - NLMISC::CRGBA light_ambiant = CRGBA(0,0,0); - NLMISC::CRGBA light_diffuse = CRGBA(255,255,255); - NLMISC::CRGBA light_specular = CRGBA(255,255,255); - NLMISC::CVector light_direction = CVector(0.25, 0.25, 0.25); - _Light->setupPointLight(light_ambiant, light_diffuse, light_specular, position, direction + light_direction); - - // set and enable the light - _Driver->setLight(0, *_Light); - _Driver->enableLight(0); - - return true; - } - - QIcon* CObjectViewerWidget::saveOneImage(string shapename) - { - int output_width = 128; - int output_height = 128; - - // Create a scene - NL3D::UScene* Scene = _Driver->createScene(true); - if (!Scene) return 0; - - // get scene camera - if (Scene->getCam().empty()) - { - nlwarning("can't get camera from scene"); - return 0; - } - - // add an entity to the scene - UInstance Entity = Scene->createInstance(shapename.c_str()); - - // if we can't create entity, skip it - if (Entity.empty()) - { - nlwarning("can't create instance from %s", shapename.c_str()); - return 0; - } - - // get AABox of Entity - CAABBox bbox; - Entity.getShapeAABBox(bbox); - setCamera(Scene, bbox , Entity, true); - Scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)output_width/output_height, 0.1f, 1000); - - string filename = CPath::standardizePath("") + toString("%s.%s", shapename.c_str(), "png"); - - // the background is white - _Driver->clearBuffers(); - - // render the scene - Scene->render(); - - CBitmap btm; - _Driver->getBuffer(btm); - - btm.resample(output_width, output_height); - - COFile fs; - - if (fs.open(filename)) - { - if (!btm.writePNG(fs, 24)) - { - nlwarning("can't save image to PNG"); - return 0; - } - } - else - { - nlwarning("can't create %s", "test.png"); - return 0; - } - fs.close(); - - QIcon *icon = new QIcon(QString(filename.c_str())); - //CFile::deleteFile(filename); - return icon; - } + setFocusPolicy(Qt::StrongFocus); + _objectViewerWidget = this; + + _isGraphicsEnabled = true; + + // As a special case, a QTimer with a timeout of 0 will time out as soon as all the events in the window system's event queue have been processed. + // This can be used to do heavy work while providing a snappy user interface. + _mainTimer = new QTimer(this); + connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender())); + // timer->start(); // <- timeout 0 + // it's heavy on cpu, though, when no 3d driver initialized :) + _mainTimer->start(25); // 25fps + } + + CObjectViewerWidget::~CObjectViewerWidget() + { + release(); + } + + void CObjectViewerWidget::showEvent ( QShowEvent * event ) + { + if (!_mainTimer->isActive()) + { + _mainTimer->start(25); + } + } + + void CObjectViewerWidget::setNelContext(NLMISC::INelContext &nelContext) + { + _LibContext = new CLibraryContext(nelContext); + } + + void CObjectViewerWidget::init() + { + + connect(this, SIGNAL(topLevelChanged(bool)), + this, SLOT(topLevelChanged(bool))); + //H_AUTO2 + //nldebug("%d %d %d",_nlw->winId(), width(), height()); + + +#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC) + //dynamic_cast(widget())->makeCurrent(); +#endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC) + + nlWindow wnd = (nlWindow)winId(); + uint16 w = width(); + uint16 h = height(); + + setMouseTracking(true); + + // set background color from config + //NLMISC::CConfigFile::CVar v = Modules::config().getConfigFile().getVar("BackgroundColor"); + //_BackgroundColor = CRGBA(v.asInt(0), v.asInt(1), v.asInt(2)); + _BackgroundColor = CRGBA(255, 255, 255); + + // set graphics driver from config + //NLMISC::CConfigFile::CVar v2 = Modules::config().getConfigFile().getVar("GraphicsDriver"); + // Choose driver opengl to work correctly under Linux example + _Direct3D = false; //_Driver = OpenGL; + +#ifdef NL_OS_WINDOWS + //std::string driver = v2.asString(); + //if (driver == "Direct3D") _Direct3D = true; //m_Driver = Direct3D; + //else if (driver == "OpenGL") _Direct3D = false; //m_Driver = OpenGL; + //else nlwarning("Invalid driver specified, defaulting to OpenGL"); +#endif + + //Modules::config().setAndCallback("CameraFocal",CConfigCallback(this,&CObjectViewer::cfcbCameraFocal)); + //Modules::config().setAndCallback("BloomEffect",CConfigCallback(this,&CObjectViewer::cfcbBloomEffect)); + + // create the driver + nlassert(!_Driver); + + _Driver = UDriver::createDriver(0, _Direct3D, 0); + nlassert(_Driver); + + // initialize the window with config file values + _Driver->setDisplay(wnd, NL3D::UDriver::CMode(w, h, 32)); + + //_Light = ULight::createLight(); + + //// set mode of the light + //_Light->setMode(ULight::DirectionalLight); + + //// set position of the light + //_Light->setPosition(CVector(-20.f, 30.f, 10.f)); + + //// white light + //_Light->setAmbiant(CRGBA(255, 255, 255)); + + //// set and enable the light + //_Driver->setLight(0, *_Light); + //_Driver->enableLight(0); + + // Create a scene + _Scene = _Driver->createScene(true); + + _PlayListManager = _Scene->createPlayListManager(); + + //_Scene->enableLightingSystem(true); + + // create the camera + UCamera camera = _Scene->getCam(); + + camera.setTransformMode (UTransformable::DirectMatrix); + + setSizeViewport(w, h); + + // camera will look at entities + camera.lookAt(NLMISC::CVector(_dist,0,1), NLMISC::CVector(0,0,0.5)); + + NLMISC::CVector hotSpot=NLMISC::CVector(0,0,0); + + _MouseListener = _Driver->create3dMouseListener(); + _MouseListener->setMatrix(_Scene->getCam().getMatrix()); + _MouseListener->setFrustrum(_Scene->getCam().getFrustum()); + _MouseListener->setHotSpot(hotSpot); + _MouseListener->setMouseMode(U3dMouseListener::edit3d); + + NL3D::CBloomEffect::instance().setDriver(_Driver); + NL3D::CBloomEffect::instance().setScene(_Scene); + NL3D::CBloomEffect::instance().init(!_Direct3D); + //NL3D::CBloomEffect::instance().setDensityBloom(Modules::config().getConfigFile().getVar("BloomDensity").asInt()); + //NL3D::CBloomEffect::instance().setSquareBloom(Modules::config().getConfigFile().getVar("BloomSquare").asBool()); + } + + void CObjectViewerWidget::release() + { + //H_AUTO2 + nldebug(""); + + _Driver->delete3dMouseListener(_MouseListener); + + // delete all entities + deleteEntities(); + + _Scene->deletePlayListManager(_PlayListManager); + + // delete the scene + _Driver->deleteScene(_Scene); + + // delete the light + delete _Light; + + // release driver + nlassert(_Driver); + _Driver->release(); + delete _Driver; + _Driver = NULL; + } + + void CObjectViewerWidget::updateRender() + { + //nldebug("CMainWindow::updateRender"); + updateInitialization(isVisible()); + + //QModelIndex index = _dirModel->setRootPath("D:/Dev/Ryzom/code/ryzom/common/data_leveldesign/leveldesign"); + //_dirTree->setRootIndex(index); + + if (isVisible()) + { + // call all update functions + // 01. Update Utilities (configuration etc) + + // 02. Update Time (deltas) + // ... + + // 03. Update Receive (network, servertime, receive messages) + // ... + + // 04. Update Input (keyboard controls, etc) + if (_isGraphicsInitialized) + updateInput(); + + // 05. Update Weather (sky, snow, wind, fog, sun) + // ... + + // 06. Update Entities (movement, do after possible tp from incoming messages etc) + // - Move other entities + // - Update self entity + // - Move bullets + // ... + + // 07. Update Landscape (async zone loading near entity) + // ... + + // 08. Update Collisions (entities) + // - Update entities + // - Update move container (swap with Update entities? todo: check code!) + // - Update bullets + // ... + + // 09. Update Animations (playlists) + // - Needs to be either before or after entities, not sure, + // there was a problem with wrong order a while ago!!! + + + //updateAnimation(_AnimationDialog->getTime()); + updateAnimatePS(); + // 10. Update Camera (depends on entities) + // ... + + // 11. Update Interface (login, ui, etc) + // ... + + // 12. Update Sound (sound driver) + // ... + + // 13. Update Send (network, send new position etc) + // ... + + // 14. Update Debug (stuff for dev) + // ... + + if (_isGraphicsInitialized && !getDriver()->isLost()) + { + // 01. Render Driver (background color) + renderDriver(); // clear all buffers + + // 02. Render Sky (sky scene) + // ... + + // 04. Render Scene (entity scene) + renderScene(); + + // 05. Render Effects (flare) + // ... + + // 06. Render Interface 3D (player names) + // ... + + // 07. Render Debug 3D + // ... + + // 08. Render Interface 2D (chatboxes etc, optionally does have 3d) + // ... + + // 09. Render Debug 2D (stuff for dev) + renderDebug2D(); + + // swap 3d buffers + getDriver()->swapBuffers(); + } + } + } + + void CObjectViewerWidget::updateInitialization(bool visible) + { + //nldebug("CMainWindow::updateInitialization"); + bool done; + do + { + done = true; // set false whenever change + bool wantGraphics = _isGraphicsEnabled && visible; + // bool wantLandscape = wantGraphics && m_IsGraphicsInitialized && isLandscapeEnabled; + + // .. stuff that depends on other stuff goes on top to prioritize deinitialization + + // Landscape + // ... + + // Graphics (Driver) + if (_isGraphicsInitialized) + { + if (!wantGraphics) + { + //_isGraphicsInitialized = false; + //release(); + _mainTimer->stop(); + //done = false; + } + } + else + { + if (wantGraphics) + { + init(); + _isGraphicsInitialized = true; + _mainTimer->start(25); + //done = false; + } + } + } + while (!done); + } + + void CObjectViewerWidget::updateInput() + { + _Driver->EventServer.pump(); + + // New matrix from camera + _Scene->getCam().setTransformMode(NL3D::UTransformable::DirectMatrix); + _Scene->getCam().setMatrix (_MouseListener->getViewMatrix()); + + //nldebug("%s",_Scene->getCam().getMatrix().getPos().asString().c_str()); + } + + void CObjectViewerWidget::renderDriver() + { + // Render the scene. + if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) + { + NL3D::CBloomEffect::instance().initBloom(); + } + _Driver->clearBuffers(_BackgroundColor); + } + + void CObjectViewerWidget::renderScene() + { + // render the scene + _Scene->render(); + + if((NL3D::CBloomEffect::instance().getDriver() != NULL) && (_BloomEffect)) + { + NL3D::CBloomEffect::instance().endBloom(); + NL3D::CBloomEffect::instance().endInterfacesDisplayBloom(); + } + } + + void CObjectViewerWidget::renderDebug2D() + { + } + + void CObjectViewerWidget::saveScreenshot(const std::string &nameFile, bool jpg, bool png, bool tga) + { + //H_AUTO2 + + // FIXME: create screenshot path if it doesn't exist! + + // empty bitmap + CBitmap bitmap; + // copy the driver buffer to the bitmap + _Driver->getBuffer(bitmap); + // create the file name + string filename = std::string("./") + nameFile; + // write the bitmap as a jpg, png or tga to the file + if (jpg) + { + string newfilename = CFile::findNewFile(filename + ".jpg"); + COFile outputFile(newfilename); + bitmap.writeJPG(outputFile, 100); + nlinfo("Screenshot '%s' saved", newfilename.c_str()); + } + if (png) + { + string newfilename = CFile::findNewFile(filename + ".png"); + COFile outputFile(newfilename); + bitmap.writePNG(outputFile, 24); + nlinfo("Screenshot '%s' saved", newfilename.c_str()); + } + if (tga) + { + string newfilename = CFile::findNewFile(filename + ".tga"); + COFile outputFile(newfilename); + bitmap.writeTGA(outputFile, 24, false); + nlinfo("Screenshot '%s' saved", newfilename.c_str()); + } + } + + bool CObjectViewerWidget::loadMesh(const std::string &meshFileName, const std::string &skelFileName) + { + std::string fileName = CFile::getFilenameWithoutExtension(meshFileName); + if ( _Entities.count(fileName) != 0) + return false; + + CPath::addSearchPath(CFile::getPath(meshFileName), false, false); + + // create instance of the mesh character + UInstance Entity = _Scene->createInstance(meshFileName); + + CAABBox bbox; + Entity.getShapeAABBox(bbox); + setCamera(_Scene, bbox , Entity, true); + + _MouseListener->setMatrix(_Scene->getCam().getMatrix()); + + USkeleton Skeleton = _Scene->createSkeleton(skelFileName); + + // if we can't create entity, skip it + if (Entity.empty()) return false; + + // create a new entity + EIT eit = (_Entities.insert (make_pair (fileName, CEntity()))).first; + CEntity &entity = (*eit).second; + + // set the entity up + entity._Name = fileName; + entity._FileNameShape = meshFileName; + entity._FileNameSkeleton = skelFileName; + entity._Instance = Entity; + if (!Skeleton.empty()) + { + entity._Skeleton = Skeleton; + entity._Skeleton.bindSkin (entity._Instance); + } + entity._AnimationSet = _Driver->createAnimationSet(false); + entity._PlayList = _PlayListManager->createPlayList(entity._AnimationSet); + return true; + } + + void CObjectViewerWidget::setVisible(bool visible) + { + // called by show() + // code assuming visible window needed to init the 3d driver + nldebug("%d", visible); + if (visible) + { + QWidget::setVisible(true); + } + else + { + QWidget::setVisible(false); + } + } + + void CObjectViewerWidget::resetScene() + { + deleteEntities(); + + // Reset camera. + //.. + + // to load files with the same name but located in different directories + //CPath::clearMap(); + + // load and set search paths from config + //Modules::config().configSearchPaths(); + + _CurrentInstance = ""; + + nlinfo("Scene cleared"); + } + + void CObjectViewerWidget::setBackgroundColor(NLMISC::CRGBA backgroundColor) + { + _BackgroundColor = backgroundColor; + + // config file variable changes + //Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.R, 0); + //Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.G, 1); + //Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.B, 2); + } + + void CObjectViewerWidget::setGraphicsDriver(bool Direct3D) + { + //_Direct3D = Direct3D; + + //if (_Direct3D) Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString("Direct3D"); + //else Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString("OpenGL"); + } + + void CObjectViewerWidget::setSizeViewport(uint16 w, uint16 h) + { + _Scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)w/h, 0.1f, 1000); + } + + void CObjectViewerWidget::setCurrentObject(const std::string &name) + { + if ((_Entities.count(name) != 0) || ( name.empty() )) _CurrentInstance = name; + else nlerror ("Entity %s not found", name.c_str()); + nlinfo("set current entity %s", _CurrentInstance.c_str()); + } + + CEntity& CObjectViewerWidget::getEntity(const std::string &name) + { + if ( _Entities.count(name) == 0) nlerror("Entity %s not found", name.c_str()); + EIT eit = _Entities.find (name); + return (*eit).second; + } + + void CObjectViewerWidget::getListObjects(std::vector &listObj) + { + listObj.clear(); + for (EIT eit = _Entities.begin(); eit != _Entities.end(); ++eit) + listObj.push_back((*eit).second._Name); + } + + void CObjectViewerWidget::deleteEntity(CEntity &entity) + { + if (entity._PlayList != NULL) + { + _PlayListManager->deletePlayList (entity._PlayList); + entity._PlayList = NULL; + } + + if (entity._AnimationSet != NULL) + { + _Driver->deleteAnimationSet(entity._AnimationSet); + entity._AnimationSet = NULL; + } + + if (!entity._Skeleton.empty()) + { + entity._Skeleton.detachSkeletonSon(entity._Instance); + + _Scene->deleteSkeleton(entity._Skeleton); + entity._Skeleton = NULL; + } + + if (!entity._Instance.empty()) + { + _Scene->deleteInstance(entity._Instance); + entity._Instance = NULL; + } + } + + void CObjectViewerWidget::deleteEntities() + { + for (EIT eit = _Entities.begin(); eit != _Entities.end(); ++eit) + { + CEntity &entity = (*eit).second; + deleteEntity(entity); + } + _Entities.clear(); + } + + void CObjectViewerWidget::setCamera(NL3D::UScene *scene, CAABBox &bbox, UTransform &entity, bool high_z) + { + CVector pos(0.f, 0.f, 0.f); + CQuat quat(0.f, 0.f, 0.f, 0.f); + NL3D::UInstance inst; + inst.cast(entity); + if (!inst.empty()) + { + inst.getDefaultPos(pos); + inst.getDefaultRotQuat(quat); + } + + // fix scale (some shapes have a different value) + entity.setScale(1.f, 1.f, 1.f); + + UCamera Camera = scene->getCam(); + CVector max_radius = bbox.getHalfSize(); + + CVector center = bbox.getCenter(); + entity.setPivot(center); + center += pos; + + //scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)w/h, 0.1f, 1000); + float fov = float(_CameraFocal * (float)Pi/180.0); + //Camera.setPerspective (fov, 1.0f, 0.1f, 1000.0f); + float radius = max(max(max_radius.x, max_radius.y), max_radius.z); + if (radius == 0.f) radius = 1.f; + float left, right, bottom, top, znear, zfar; + Camera.getFrustum(left, right, bottom, top, znear, zfar); + float dist = (radius / (tan(fov/2))) * 0.2; + CVector eye(center); + CVector ax(quat.getAxis()); + + if (ax.isNull() || ax == CVector::I) + { + ax = CVector::J; + } + else if (ax == -CVector::K) + { + ax = -CVector::J; + } + + eye -= ax * (dist+radius); + if (high_z) + eye.z += max_radius.z/1.0f; + Camera.lookAt(eye, center); + setupLight(eye, center - eye); + } + + bool CObjectViewerWidget::setupLight(const CVector &position, const CVector &direction) + { + if (!_Light) + _Light = ULight::createLight(); + if (!_Light) return false; + + // set mode of the light + _Light->setMode(ULight::DirectionalLight); + + // set position of the light + // Light->setupDirectional(settings.light_ambiant, settings.light_diffuse, settings.light_specular, settings.light_direction); + NLMISC::CRGBA light_ambiant = CRGBA(0,0,0); + NLMISC::CRGBA light_diffuse = CRGBA(255,255,255); + NLMISC::CRGBA light_specular = CRGBA(255,255,255); + NLMISC::CVector light_direction = CVector(0.25, 0.25, 0.25); + _Light->setupPointLight(light_ambiant, light_diffuse, light_specular, position, direction + light_direction); + + // set and enable the light + _Driver->setLight(0, *_Light); + _Driver->enableLight(0); + + return true; + } + + QIcon* CObjectViewerWidget::saveOneImage(string shapename) + { + int output_width = 128; + int output_height = 128; + + // Create a scene + NL3D::UScene* Scene = _Driver->createScene(true); + if (!Scene) return 0; + + // get scene camera + if (Scene->getCam().empty()) + { + nlwarning("can't get camera from scene"); + return 0; + } + + // add an entity to the scene + UInstance Entity = Scene->createInstance(shapename.c_str()); + + // if we can't create entity, skip it + if (Entity.empty()) + { + nlwarning("can't create instance from %s", shapename.c_str()); + return 0; + } + + // get AABox of Entity + CAABBox bbox; + Entity.getShapeAABBox(bbox); + setCamera(Scene, bbox , Entity, true); + Scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)output_width/output_height, 0.1f, 1000); + + string filename = CPath::standardizePath("") + toString("%s.%s", shapename.c_str(), "png"); + + // the background is white + _Driver->clearBuffers(); + + // render the scene + Scene->render(); + + CBitmap btm; + _Driver->getBuffer(btm); + + btm.resample(output_width, output_height); + + COFile fs; + + if (fs.open(filename)) + { + if (!btm.writePNG(fs, 24)) + { + nlwarning("can't save image to PNG"); + return 0; + } + } + else + { + nlwarning("can't create %s", "test.png"); + return 0; + } + fs.close(); + + QIcon *icon = new QIcon(QString(filename.c_str())); + //CFile::deleteFile(filename); + return icon; + } void CObjectViewerWidget::updateAnimatePS(uint64 deltaTime) { @@ -731,67 +731,67 @@ namespace NLQT lastTime += deltaTime; float fdelta = 0.001f * (float) (lastTime - firstTime); _Scene->animate ( fdelta); - } - -#if defined(NL_OS_WINDOWS) - - typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - - bool CObjectViewerWidget::winEvent(MSG * message, long * result) - { - if (getDriver() && getDriver()->isActive()) - { - NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); - if (driver) - { - winProc proc = (winProc)driver->getWindowProc(); - return proc(driver, message->hwnd, message->message, message->wParam, message->lParam); - } - } - - return false; - } - -#elif defined(NL_OS_MAC) - - typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e); - - bool CObjectViewerWidget::macEvent(EventHandlerCallRef caller, EventRef event) - { - if(caller) - nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt"); - - if (getDriver() && getDriver()->isActive()) - { - NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); - if (driver) - { - cocoaProc proc = (cocoaProc)driver->getWindowProc(); - return proc(driver, event); - } - } - - return false; - } - -#elif defined(NL_OS_UNIX) - - typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e); - - bool CObjectViewerWidget::x11Event(XEvent *event) - { - if (getDriver() && getDriver()->isActive()) - { - NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); - if (driver) - { - x11Proc proc = (x11Proc)driver->getWindowProc(); - return proc(driver, event); - } - } - - return false; - } -#endif - -} /* namespace NLQT */ + } + +#if defined(NL_OS_WINDOWS) + + typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + + bool CObjectViewerWidget::winEvent(MSG * message, long * result) + { + if (getDriver() && getDriver()->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); + if (driver) + { + winProc proc = (winProc)driver->getWindowProc(); + return proc(driver, message->hwnd, message->message, message->wParam, message->lParam); + } + } + + return false; + } + +#elif defined(NL_OS_MAC) + + typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e); + + bool CObjectViewerWidget::macEvent(EventHandlerCallRef caller, EventRef event) + { + if(caller) + nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt"); + + if (getDriver() && getDriver()->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); + if (driver) + { + cocoaProc proc = (cocoaProc)driver->getWindowProc(); + return proc(driver, event); + } + } + + return false; + } + +#elif defined(NL_OS_UNIX) + + typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e); + + bool CObjectViewerWidget::x11Event(XEvent *event) + { + if (getDriver() && getDriver()->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); + if (driver) + { + x11Proc proc = (x11Proc)driver->getWindowProc(); + return proc(driver, event); + } + } + + return false; + } +#endif + +} /* namespace NLQT */ diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h index 15c9b0fa9..fb6656679 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h @@ -1,229 +1,229 @@ -/* -Object Viewer Qt Widget -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef OBJECT_VIEWER_WIDGET_H -#define OBJECT_VIEWER_WIDGET_H - -// STL includes - -// Qt includes -#include -#include - -// NeL includes -#include -#include - -// Project includes -#include "entity.h" -#include "interfaces.h" - -namespace NL3D -{ - class UDriver; - class UScene; - class ULight; - class UInstance; - class UCamera; - class USkeleton; - class UPlayListManager; - class U3dMouseListener; -} - -class QIcon; -/** -namespace NLQT -@brief namespace NLQT -*/ -namespace NLQT -{ - class CObjectViewerWidget: - public QWidget, - public IObjectViewer - { - Q_OBJECT - Q_INTERFACES(NLQT::IObjectViewer) - - public: - /// Default constructor. - CObjectViewerWidget(QWidget *parent = 0); - virtual ~CObjectViewerWidget(); - - virtual QPaintEngine* paintEngine() const { return NULL; } - virtual void showEvent ( QShowEvent * event ); - - void setNelContext(NLMISC::INelContext &nelContext); - - static CObjectViewerWidget &objViewWid() { return *_objectViewerWidget; } - - /// Init a driver and create scene. - void init(); - - /// Release class. - void release(); - - /// Update mouse and keyboard events. And update camera matrix. - void updateInput(); - - /// Render Driver (clear all buffers and set background color). - void renderDriver(); - - /// Render current scene. - void renderScene(); - - /// Render Debug 2D (stuff for dev). - void renderDebug2D(); - - /// Make a screenshot of the current scene and save. - void saveScreenshot(const std::string &nameFile, bool jpg, bool png, bool tga); - - /// Load a mesh or particle system and add to current scene. - /// @param meshFileName - name loading shape or ps file. - /// @param skelFileName - name loading skeletin file. - /// @return true if file have been loaded, false if file have not been loaded. - bool loadMesh (const std::string &meshFileName, const std::string &skelFileName); - - /// Reset current scene. - void resetScene(); - - /// Set the background color. - /// @param backgroundColor - background color. - void setBackgroundColor(NLMISC::CRGBA backgroundColor); - - /// Set type driver. - /// @param Direct3D - type driver (true - Direct3D) or (false -OpenGL) - void setGraphicsDriver(bool Direct3D); - - /// Set size viewport for correct set perspective - /// @param w - width window. - /// @param h - height window. - void setSizeViewport(uint16 w, uint16 h); - - void setBloomEffect(bool enabled) { _BloomEffect = enabled; } - - /// Select instance from the scene - /// @param name - name instance, "" if no instance edited - void setCurrentObject(const std::string &name); - - /// Get current instance from the scene - /// @return name current instance, "" if no instance edited - const std::string& getCurrentObject() { return _CurrentInstance; } - - /// Get entity from the scene - /// @return ref Entity - CEntity& getEntity(const std::string &name); - - /// Get full list instances from the scene - /// @param listObj - ref of return list instances - void getListObjects(std::vector &listObj); - - /// Get value background color. - /// @return background color. - NLMISC::CRGBA getBackgroundColor() { return _BackgroundColor; } - - /// Get type driver. - /// @return true if have used Direct3D driver, false OpenGL driver. - inline bool getDirect3D() { return _Direct3D; } - - inline bool getBloomEffect() const { return _BloomEffect; } - - /// Get a pointer to the driver. - /// @return pointer to the driver. - inline NL3D::UDriver *getDriver() { return _Driver; } - - /// Get a pointer to the scene. - /// @return pointer to the scene. - inline NL3D::UScene *getScene() { return _Scene; } - - /// Get a manager of playlist - /// @return pointer to the UPlayListManager - inline NL3D::UPlayListManager *getPlayListManager() { return _PlayListManager; } - - void setCamera(NL3D::UScene *scene, NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z=false); - bool setupLight(const NLMISC::CVector &position, const NLMISC::CVector &direction); - - QIcon* saveOneImage(std::string shapename); - - virtual void setVisible(bool visible); - - QWidget* getWidget() {return this;} - - virtual QString name() const {return ("ObjectViewerWidget");} - - protected: -#if defined(NL_OS_WINDOWS) - virtual bool winEvent(MSG * message, long * result); -#elif defined(NL_OS_MAC) - virtual bool macEvent(EventHandlerCallRef caller, EventRef event); -#elif defined(NL_OS_UNIX) - virtual bool x11Event(XEvent *event); -#endif - - private Q_SLOTS: - void updateRender(); - - private: +/* +Object Viewer Qt Widget +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef OBJECT_VIEWER_WIDGET_H +#define OBJECT_VIEWER_WIDGET_H + +// STL includes + +// Qt includes +#include +#include + +// NeL includes +#include +#include + +// Project includes +#include "entity.h" +#include "interfaces.h" + +namespace NL3D +{ + class UDriver; + class UScene; + class ULight; + class UInstance; + class UCamera; + class USkeleton; + class UPlayListManager; + class U3dMouseListener; +} + +class QIcon; +/** +namespace NLQT +@brief namespace NLQT +*/ +namespace NLQT +{ + class CObjectViewerWidget: + public QWidget, + public IObjectViewer + { + Q_OBJECT + Q_INTERFACES(NLQT::IObjectViewer) + + public: + /// Default constructor. + CObjectViewerWidget(QWidget *parent = 0); + virtual ~CObjectViewerWidget(); + + virtual QPaintEngine* paintEngine() const { return NULL; } + virtual void showEvent ( QShowEvent * event ); + + void setNelContext(NLMISC::INelContext &nelContext); + + static CObjectViewerWidget &objViewWid() { return *_objectViewerWidget; } + + /// Init a driver and create scene. + void init(); + + /// Release class. + void release(); + + /// Update mouse and keyboard events. And update camera matrix. + void updateInput(); + + /// Render Driver (clear all buffers and set background color). + void renderDriver(); + + /// Render current scene. + void renderScene(); + + /// Render Debug 2D (stuff for dev). + void renderDebug2D(); + + /// Make a screenshot of the current scene and save. + void saveScreenshot(const std::string &nameFile, bool jpg, bool png, bool tga); + + /// Load a mesh or particle system and add to current scene. + /// @param meshFileName - name loading shape or ps file. + /// @param skelFileName - name loading skeletin file. + /// @return true if file have been loaded, false if file have not been loaded. + bool loadMesh (const std::string &meshFileName, const std::string &skelFileName); + + /// Reset current scene. + void resetScene(); + + /// Set the background color. + /// @param backgroundColor - background color. + void setBackgroundColor(NLMISC::CRGBA backgroundColor); + + /// Set type driver. + /// @param Direct3D - type driver (true - Direct3D) or (false -OpenGL) + void setGraphicsDriver(bool Direct3D); + + /// Set size viewport for correct set perspective + /// @param w - width window. + /// @param h - height window. + void setSizeViewport(uint16 w, uint16 h); + + void setBloomEffect(bool enabled) { _BloomEffect = enabled; } + + /// Select instance from the scene + /// @param name - name instance, "" if no instance edited + void setCurrentObject(const std::string &name); + + /// Get current instance from the scene + /// @return name current instance, "" if no instance edited + const std::string& getCurrentObject() { return _CurrentInstance; } + + /// Get entity from the scene + /// @return ref Entity + CEntity& getEntity(const std::string &name); + + /// Get full list instances from the scene + /// @param listObj - ref of return list instances + void getListObjects(std::vector &listObj); + + /// Get value background color. + /// @return background color. + NLMISC::CRGBA getBackgroundColor() { return _BackgroundColor; } + + /// Get type driver. + /// @return true if have used Direct3D driver, false OpenGL driver. + inline bool getDirect3D() { return _Direct3D; } + + inline bool getBloomEffect() const { return _BloomEffect; } + + /// Get a pointer to the driver. + /// @return pointer to the driver. + inline NL3D::UDriver *getDriver() { return _Driver; } + + /// Get a pointer to the scene. + /// @return pointer to the scene. + inline NL3D::UScene *getScene() { return _Scene; } + + /// Get a manager of playlist + /// @return pointer to the UPlayListManager + inline NL3D::UPlayListManager *getPlayListManager() { return _PlayListManager; } + + void setCamera(NL3D::UScene *scene, NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z=false); + bool setupLight(const NLMISC::CVector &position, const NLMISC::CVector &direction); + + QIcon* saveOneImage(std::string shapename); + + virtual void setVisible(bool visible); + + QWidget* getWidget() {return this;} + + virtual QString name() const {return ("ObjectViewerWidget");} + + protected: +#if defined(NL_OS_WINDOWS) + virtual bool winEvent(MSG * message, long * result); +#elif defined(NL_OS_MAC) + virtual bool macEvent(EventHandlerCallRef caller, EventRef event); +#elif defined(NL_OS_UNIX) + virtual bool x11Event(XEvent *event); +#endif + + private Q_SLOTS: + void updateRender(); + + private: /// Update the animation time for Particle System animation. /// @param deltaTime - set the manual animation time. - void updateAnimatePS(uint64 deltaTime = 0); - - static CObjectViewerWidget *_objectViewerWidget; - - NLMISC::CLibraryContext *_LibContext; - - // render stuff - QTimer *_mainTimer; - bool _isGraphicsInitialized, _isGraphicsEnabled; - - void updateInitialization(bool visible); - - void deleteEntity (CEntity &entity); - - /// Delete all entities - void deleteEntities(); - - NLMISC::CRGBA _BackgroundColor; - - NL3D::UDriver *_Driver; - NL3D::UScene *_Scene; - NL3D::UPlayListManager *_PlayListManager; - NL3D::ULight *_Light; - NL3D::UCamera *_Camera; - NL3D::U3dMouseListener *_MouseListener; - - // The entities storage - CEntities _Entities; - - /// Camera parameters. - float _phi, _psi, _dist; - float _CameraFocal; - - bool _Direct3D; - bool _BloomEffect; - - std::string _CurrentInstance; - - // a temporary solution, and later remove - friend class CAnimationSetDialog; - - };/* class CObjectViewerWidget */ - -} /* namespace NLQT */ - -#endif // OBJECT_VIEWER_WIDGET_H + void updateAnimatePS(uint64 deltaTime = 0); + + static CObjectViewerWidget *_objectViewerWidget; + + NLMISC::CLibraryContext *_LibContext; + + // render stuff + QTimer *_mainTimer; + bool _isGraphicsInitialized, _isGraphicsEnabled; + + void updateInitialization(bool visible); + + void deleteEntity (CEntity &entity); + + /// Delete all entities + void deleteEntities(); + + NLMISC::CRGBA _BackgroundColor; + + NL3D::UDriver *_Driver; + NL3D::UScene *_Scene; + NL3D::UPlayListManager *_PlayListManager; + NL3D::ULight *_Light; + NL3D::UCamera *_Camera; + NL3D::U3dMouseListener *_MouseListener; + + // The entities storage + CEntities _Entities; + + /// Camera parameters. + float _phi, _psi, _dist; + float _CameraFocal; + + bool _Direct3D; + bool _BloomEffect; + + std::string _CurrentInstance; + + // a temporary solution, and later remove + friend class CAnimationSetDialog; + + };/* class CObjectViewerWidget */ + +} /* namespace NLQT */ + +#endif // OBJECT_VIEWER_WIDGET_H diff --git a/code/nel/tools/3d/object_viewer_widget/src/stdpch.cpp b/code/nel/tools/3d/object_viewer_widget/src/stdpch.cpp index e5875aca1..3dd66d085 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/stdpch.cpp +++ b/code/nel/tools/3d/object_viewer_widget/src/stdpch.cpp @@ -1,5 +1,5 @@ /* -Object Viewer Qt Widget +Object Viewer Qt Widget Copyright (C) 2010 Adrian Jaekel This program is free software: you can redistribute it and/or modify diff --git a/code/ryzom/server/src/ai_share/ai_spawn_commands.h b/code/ryzom/server/src/ai_share/ai_spawn_commands.h index 96f2d99a0..059f08f1b 100644 --- a/code/ryzom/server/src/ai_share/ai_spawn_commands.h +++ b/code/ryzom/server/src/ai_share/ai_spawn_commands.h @@ -1,59 +1,59 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// 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 . - - - +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// 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 RYAI_SPAWN_COMMANDS_H #define RYAI_SPAWN_COMMANDS_H - -#include "nel/misc/types_nl.h" -#include "nel/misc/debug.h" - -#include - - -//class CAISpawnCtrl -//{ -//public: -// static bool spawn (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawn(aiInstance, name); } -// static bool spawnMap (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawnMap(aiInstance, name); } -// static bool spawnMgr (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawnMgr(aiInstance, name); } -// static bool spawnGrp (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawnGrp(aiInstance, name); } -// static bool spawnAll (int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawnAll(aiInstance); } -// -// static bool despawn (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawn(aiInstance, name); } -// static bool despawnMap (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawnMap(aiInstance, name); } -// static bool despawnMgr (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawnMgr(aiInstance, name); } -// static bool despawnGrp (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawnGrp(aiInstance, name); } -// static bool despawnAll (int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawnAll(aiInstance); } -// -//protected: -// virtual bool _spawn (int aiInstance, const std::string &name)=0; -// virtual bool _spawnMap (int aiInstance, const std::string &name)=0; -// virtual bool _spawnMgr (int aiInstance, const std::string &name)=0; -// virtual bool _spawnGrp (int aiInstance, const std::string &name)=0; -// virtual bool _spawnAll (int aiInstance)=0; -// -// virtual bool _despawn (int aiInstance, const std::string &name)=0; -// virtual bool _despawnMap (int aiInstance, const std::string &name)=0; -// virtual bool _despawnMgr (int aiInstance, const std::string &name)=0; -// virtual bool _despawnGrp (int aiInstance, const std::string &name)=0; -// virtual bool _despawnAll (int aiInstance)=0; -// -// static CAISpawnCtrl *_instance; -//}; - -#endif + +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" + +#include + + +//class CAISpawnCtrl +//{ +//public: +// static bool spawn (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawn(aiInstance, name); } +// static bool spawnMap (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawnMap(aiInstance, name); } +// static bool spawnMgr (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawnMgr(aiInstance, name); } +// static bool spawnGrp (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawnGrp(aiInstance, name); } +// static bool spawnAll (int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_spawnAll(aiInstance); } +// +// static bool despawn (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawn(aiInstance, name); } +// static bool despawnMap (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawnMap(aiInstance, name); } +// static bool despawnMgr (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawnMgr(aiInstance, name); } +// static bool despawnGrp (const std::string &name, int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawnGrp(aiInstance, name); } +// static bool despawnAll (int aiInstance=-1) { nlassert(_instance!=NULL); return _instance->_despawnAll(aiInstance); } +// +//protected: +// virtual bool _spawn (int aiInstance, const std::string &name)=0; +// virtual bool _spawnMap (int aiInstance, const std::string &name)=0; +// virtual bool _spawnMgr (int aiInstance, const std::string &name)=0; +// virtual bool _spawnGrp (int aiInstance, const std::string &name)=0; +// virtual bool _spawnAll (int aiInstance)=0; +// +// virtual bool _despawn (int aiInstance, const std::string &name)=0; +// virtual bool _despawnMap (int aiInstance, const std::string &name)=0; +// virtual bool _despawnMgr (int aiInstance, const std::string &name)=0; +// virtual bool _despawnGrp (int aiInstance, const std::string &name)=0; +// virtual bool _despawnAll (int aiInstance)=0; +// +// static CAISpawnCtrl *_instance; +//}; + +#endif diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.h index 18a0ae23e..3f4ad0c98 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.h @@ -1,5 +1,5 @@ /* -Georges Editor Qt +Georges Editor Qt Copyright (C) 2010 Adrian Jaekel This program is free software: you can redistribute it and/or modify @@ -14,58 +14,58 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -*/ - -#ifndef FORMITEM_H -#define FORMITEM_H - -// NeL includes -#include - -// Qt includes -#include -#include - -namespace NLQT -{ - - class CFormItem - - { - public: - CFormItem(NLGEORGES::UFormElm *elm, const QList &data, - CFormItem *parent = 0, - NLGEORGES::UFormElm::TWhereIsValue = NLGEORGES::UFormElm::ValueForm, - NLGEORGES::UFormElm::TWhereIsNode = NLGEORGES::UFormElm::NodeForm); - ~CFormItem(); - - void appendChild(CFormItem *child); - - CFormItem *child(int row); - int childCount() const; - int columnCount() const; - QVariant data(int column) const; - int row() const; - CFormItem *parent(); - bool setData(int column, const QVariant &value); - NLGEORGES::UFormElm* getFormElm() {return formElm;} - NLGEORGES::UFormElm::TWhereIsValue valueFrom() - { - return whereV; - } - NLGEORGES::UFormElm::TWhereIsNode nodeFrom() - { - return whereN; - } - - private: - QList childItems; - QList itemData; - CFormItem *parentItem; - NLGEORGES::UFormElm* formElm; - NLGEORGES::UFormElm::TWhereIsValue whereV; - NLGEORGES::UFormElm::TWhereIsNode whereN; - }; // CFormItem - -} -#endif // FORMITEM_H +*/ + +#ifndef FORMITEM_H +#define FORMITEM_H + +// NeL includes +#include + +// Qt includes +#include +#include + +namespace NLQT +{ + + class CFormItem + + { + public: + CFormItem(NLGEORGES::UFormElm *elm, const QList &data, + CFormItem *parent = 0, + NLGEORGES::UFormElm::TWhereIsValue = NLGEORGES::UFormElm::ValueForm, + NLGEORGES::UFormElm::TWhereIsNode = NLGEORGES::UFormElm::NodeForm); + ~CFormItem(); + + void appendChild(CFormItem *child); + + CFormItem *child(int row); + int childCount() const; + int columnCount() const; + QVariant data(int column) const; + int row() const; + CFormItem *parent(); + bool setData(int column, const QVariant &value); + NLGEORGES::UFormElm* getFormElm() {return formElm;} + NLGEORGES::UFormElm::TWhereIsValue valueFrom() + { + return whereV; + } + NLGEORGES::UFormElm::TWhereIsNode nodeFrom() + { + return whereN; + } + + private: + QList childItems; + QList itemData; + CFormItem *parentItem; + NLGEORGES::UFormElm* formElm; + NLGEORGES::UFormElm::TWhereIsValue whereV; + NLGEORGES::UFormElm::TWhereIsNode whereN; + }; // CFormItem + +} +#endif // FORMITEM_H