diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt index 4ac0fff11..d5a792acd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt @@ -3,4 +3,5 @@ ADD_SUBDIRECTORY(example) ADD_SUBDIRECTORY(ovqt_sheet_builder) ADD_SUBDIRECTORY(log) ADD_SUBDIRECTORY(disp_sheet_id) -ADD_SUBDIRECTORY(object_viewer) \ No newline at end of file +ADD_SUBDIRECTORY(object_viewer) +ADD_SUBDIRECTORY(zone_painter) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/CMakeLists.txt new file mode 100644 index 000000000..8b473854e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/CMakeLists.txt @@ -0,0 +1,45 @@ +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${QT_INCLUDES}) + +FILE(GLOB SRC *.cpp *.h) + +SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) + +SET(OVQT_PLUG_ZONE_PAINTER_HDR zone_painter_plugin.h + qnel_widget.h + zone_painter_settings_page.h + zone_painter_main_window.h + painter_dock_widget.h) + +SET(OVQT_PLUG_ZONE_PAINTER_UIS zone_painter_settings_page.ui zone_painter_main_window.ui painter_dock_widget.ui) + +SET(OVQT_PLUG_ZONE_PAINTER_RCS zone_painter.qrc) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTOPENGL TRUE) + +QT4_WRAP_CPP(OVQT_PLUG_ZONE_PAINTER_MOC_SRC ${OVQT_PLUG_ZONE_PAINTER_HDR}) +QT4_ADD_RESOURCES( OVQT_PLUG_ZONE_PAINTER_RC_SRCS ${OVQT_PLUG_ZONE_PAINTER_RCS}) +QT4_WRAP_UI(OVQT_PLUG_ZONE_PAINTER_UI_HDRS ${OVQT_PLUG_ZONE_PAINTER_UIS}) + +SOURCE_GROUP(QtResources FILES ${OVQT_PLUG_ZONE_PAINTER_UIS} ${OVQT_PLUG_ZONE_PAINTER_RCS}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUG_ZONE_PAINTER_UI_HDRS}) +SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_PLUG_ZONE_PAINTER_MOC_SRC} ${OVQT_PLUG_ZONE_PAINTER_RC_SRCS}) +SOURCE_GROUP("Zone Painter Plugin" FILES ${SRC}) +SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) + +ADD_LIBRARY(ovqt_plugin_zone_painter MODULE ${SRC} ${OVQT_PLUG_ZONE_PAINTER_MOC_SRC} ${OVQT_PLUG_ZONE_PAINTER_RC_SRCS} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_ZONE_PAINTER_UI_HDRS}) + +TARGET_LINK_LIBRARIES(ovqt_plugin_zone_painter ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) + +NL_DEFAULT_PROPS(ovqt_plugin_zone_painter "NeL, Tools, 3D: Object Viewer Qt Plugin: Zone Painter") +NL_ADD_RUNTIME_FLAGS(ovqt_plugin_zone_painter) +NL_ADD_LIB_SUFFIX(ovqt_plugin_zone_painter) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) + +INSTALL(TARGETS ovqt_plugin_zone_painter LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/color-fill.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/color-fill.png new file mode 100644 index 000000000..b18b56e14 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/color-fill.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/color-picker-black.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/color-picker-black.png new file mode 100644 index 000000000..f4b0ce765 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/color-picker-black.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/colorize.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/colorize.png new file mode 100644 index 000000000..f48e18299 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/colorize.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/draw-brush.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/draw-brush.png new file mode 100644 index 000000000..e214eb770 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/draw-brush.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/go-down-7.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/go-down-7.png new file mode 100644 index 000000000..566be207d Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/go-down-7.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/go-jump-4.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/go-jump-4.png new file mode 100644 index 000000000..d5aaa93bb Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/go-jump-4.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/lock-6.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/lock-6.png new file mode 100644 index 000000000..3ded18d5f Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/lock-6.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/lock-silver.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/lock-silver.png new file mode 100644 index 000000000..c47509e88 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/images/lock-silver.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/painter_dock_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/painter_dock_widget.cpp new file mode 100644 index 000000000..66315aaf7 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/painter_dock_widget.cpp @@ -0,0 +1,16 @@ +#include "painter_dock_widget.h" +#include "ui_painter_dock_widget.h" + +#include "qnel_widget.h" + +PainterDockWidget::PainterDockWidget(QWidget *parent) : + QDockWidget(parent), + ui(new Ui::PainterDockWidget) +{ + ui->setupUi(this); +} + +PainterDockWidget::~PainterDockWidget() +{ + delete ui; +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/painter_dock_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/painter_dock_widget.h new file mode 100644 index 000000000..27a777d75 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/painter_dock_widget.h @@ -0,0 +1,22 @@ +#ifndef PAINTER_DOCK_WIDGET_H +#define PAINTER_DOCK_WIDGET_H + +#include + +namespace Ui { + class PainterDockWidget; +} + +class PainterDockWidget : public QDockWidget +{ + Q_OBJECT + +public: + explicit PainterDockWidget(QWidget *parent = 0); + ~PainterDockWidget(); + +private: + Ui::PainterDockWidget *ui; +}; + +#endif // PAINTER_DOCK_WIDGET_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/painter_dock_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/painter_dock_widget.ui new file mode 100644 index 000000000..24c3d048a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/painter_dock_widget.ui @@ -0,0 +1,58 @@ + + + PainterDockWidget + + + + 0 + 0 + 304 + 510 + + + + + 300 + 80 + + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + + + Painter Modes + + + + + + 0 + 0 + 300 + 480 + + + + 0 + + + + Paint Tiles + + + + + Paint Colors + + + + + Paint Displacement + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/qnel_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/qnel_widget.cpp new file mode 100644 index 000000000..9a67abb80 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/qnel_widget.cpp @@ -0,0 +1,197 @@ +// 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 . + +#include "qnel_widget.h" + +// STL includes + +// Qt includes +#include +#include + +// NeL includes +#include +#include +#include +#include + +namespace NLQT +{ + +QNLWidget::QNLWidget(QWidget *parent) + : QNeLWidget(parent), + m_driver(NULL), + m_initialized(false), + m_interval(25) +{ + setMouseTracking(true); + setFocusPolicy(Qt::StrongFocus); + + init(); +#ifdef Q_OS_LINUX + makeCurrent(); +#endif + m_mainTimer = new QTimer(this); + connect(m_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender())); +} + +QNLWidget::~QNLWidget() +{ + release(); +} + +void QNLWidget::init() +{ + // create the driver + m_driver = NL3D::UDriver::createDriver(NULL, false, NULL); + nlassert(m_driver); + + // initialize the nel 3d viewport + m_driver->setDisplay((nlWindow)winId(), NL3D::UDriver::CMode(width(), height(), 32)); + + // set the cache size for the font manager(in bytes) + m_driver->setFontManagerMaxMemory(2097152); + + m_initialized = true; +} + +void QNLWidget::release() +{ + m_mainTimer->stop(); + delete m_mainTimer; + if (m_initialized) + { + m_driver->release(); + delete m_driver; + m_driver = NULL; + } +} + +void QNLWidget::setInterval(int msec) +{ + m_interval = msec; + m_mainTimer->setInterval(msec); +} + +void QNLWidget::setBackgroundColor(NLMISC::CRGBA backgroundColor) +{ + m_backgroundColor = backgroundColor; +} + +void QNLWidget::updateRender() +{ + if (isVisible()) + { + if (m_initialized) + m_driver->EventServer.pump(); + Q_EMIT updateData(); + + // Calc FPS + static sint64 lastTime = NLMISC::CTime::getPerformanceTime (); + sint64 newTime = NLMISC::CTime::getPerformanceTime (); + m_fps = float(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime)); + lastTime = newTime; + + if (m_initialized && !m_driver->isLost()) + { + //_driver->activate(); + m_driver->clearBuffers(m_backgroundColor); + Q_EMIT updatePreRender(); + + Q_EMIT updatePostRender(); + // swap 3d buffers + m_driver->swapBuffers(); + } + } +} + +void QNLWidget::showEvent(QShowEvent *showEvent) +{ + QWidget::showEvent(showEvent); + m_driver->activate(); + m_mainTimer->start(m_interval); +} + +void QNLWidget::hideEvent(QHideEvent *hideEvent) +{ + m_mainTimer->stop(); + QWidget::hideEvent(hideEvent); +} + +#if defined(NL_OS_WINDOWS) + +typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + +bool QNLWidget::winEvent(MSG *message, long *result) +{ + if (m_driver && m_driver->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(m_driver)->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 QNLWidget::macEvent(EventHandlerCallRef caller, EventRef event) +{ + if(caller) + nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt"); + + if (m_driver && m_driver->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(m_driver)->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 QNLWidget::x11Event(XEvent *event) +{ + if (m_driver && m_driver->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(m_driver)->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_qt/src/plugins/zone_painter/qnel_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/qnel_widget.h new file mode 100644 index 000000000..a54e6bb8a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/qnel_widget.h @@ -0,0 +1,130 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef QNEL_WIDGET_H +#define QNEL_WIDGET_H + +// NeL includes +#include +#include +#include + +// Qt includes +#include +#include + +class QAction; + +/* TODO every platform should use QWidget */ +#if defined(NL_OS_WINDOWS) +typedef QWidget QNeLWidget; +#elif defined(NL_OS_MAC) +typedef QWidget QNeLWidget; +#elif defined(NL_OS_UNIX) +typedef QGLWidget QNeLWidget; +#endif // NL_OS_UNIX + +namespace NL3D +{ +class UDriver; +class UScene; +} + +namespace NLQT +{ + +/** +@class QNLWidget +@brief Responsible for interaction between Qt and NeL. +@details Automatically begins to update the render if the widget is visible +or suspends the updating of render if the widget is hidden. +*/ +class QNLWidget : public QNeLWidget +{ + Q_OBJECT + +public: + QNLWidget(QWidget *parent); + virtual ~QNLWidget(); + + /// Set the update interval renderer + void setInterval(int msec); + + /// Set the background color. + void setBackgroundColor(NLMISC::CRGBA backgroundColor); + + float fps() const + { + return m_fps; + } + + inline NLMISC::CRGBA backgroundColor() const + { + return m_backgroundColor; + } + + NL3D::UDriver *driver() const + { + return m_driver; + } + + virtual QPaintEngine* paintEngine() const + { + return NULL; + } +Q_SIGNALS: + void updateData(); + void updatePreRender(); + void updatePostRender(); + +private Q_SLOTS: + void updateRender(); + +protected: + virtual void showEvent(QShowEvent *showEvent); + virtual void hideEvent(QHideEvent *hideEvent); + +#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: + void init(); + void release(); + + QNLWidget(const QNLWidget &); + QNLWidget &operator=(const QNLWidget &); + + NL3D::UDriver *m_driver; + NLMISC::CRGBA m_backgroundColor; + + QTimer *m_mainTimer; + + bool m_initialized; + int m_interval; + float m_fps; + +}; /* class QNLWidget */ + +} /* namespace NLQT */ + + +#endif // QNEL_WIDGET_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter.qrc b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter.qrc new file mode 100644 index 000000000..55c890670 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter.qrc @@ -0,0 +1,12 @@ + + + images/color-picker-black.png + images/colorize.png + images/draw-brush.png + images/go-down-7.png + images/go-jump-4.png + images/lock-6.png + images/lock-silver.png + images/color-fill.png + + 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 new file mode 100644 index 000000000..c187e2ddc --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.cpp @@ -0,0 +1,61 @@ +#include "zone_painter_main_window.h" +#include "ui_zone_painter_main_window.h" + +#include "qnel_widget.h" +#include "painter_dock_widget.h" + +ZonePainterMainWindow::ZonePainterMainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::ZonePainterMainWindow) +{ + ui->setupUi(this); + m_nelWidget = new NLQT::QNLWidget(this); + setCentralWidget(m_nelWidget); + + // 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(_pointRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); + //modeMapper->setMapping(_pointRenderModeAction, 0); + + _toolFillModeAction = _toolModeMenu->addAction(tr("Fill Mode")); + _toolFillModeAction->setStatusTip(tr("Set fill mode")); + _toolFillModeAction->setIcon(QIcon(":/painterTools/images/color-fill.png")); + //connect(_lineRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); + //modeMapper->setMapping(_lineRenderModeAction, 1); + + _toolSelectModeAction = _toolModeMenu->addAction(tr("Select mode")); + _toolSelectModeAction->setIcon(QIcon(":/painterTools/images/go-jump-4.png")); + _toolSelectModeAction->setStatusTip(tr("Set select mode")); + //connect(_fillRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); + //modeMapper->setMapping(_fillRenderModeAction, 2); + + _toolPickModeAction = _toolModeMenu->addAction(tr("Pick mode")); + _toolPickModeAction->setIcon(QIcon(":/painterTools/images/color-picker-black.png")); + _toolPickModeAction->setStatusTip(tr("Set color picking mode")); + //connect(_fillRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map())); + //modeMapper->setMapping(_fillRenderModeAction, 2); + + //connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(setRenderMode(int))); + +} + +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 new file mode 100644 index 000000000..d4d1584ba --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.h @@ -0,0 +1,36 @@ +#ifndef ZONE_PAINTER_MAIN_WINDOW_H +#define ZONE_PAINTER_MAIN_WINDOW_H + +#include + +namespace NLQT { + class QNLWidget; +} + +namespace Ui { + class ZonePainterMainWindow; +} + +class PainterDockWidget; + +class ZonePainterMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit ZonePainterMainWindow(QWidget *parent = 0); + ~ZonePainterMainWindow(); + +private: + Ui::ZonePainterMainWindow *ui; + NLQT::QNLWidget *m_nelWidget; + PainterDockWidget *m_painterDockWidget; + + QAction *_toolPaintModeAction; + QAction *_toolFillModeAction; + QAction *_toolSelectModeAction; + QAction *_toolPickModeAction; + QMenu *_toolModeMenu; +}; + +#endif // ZONE_PAINTER_MAIN_WINDOW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.ui new file mode 100644 index 000000000..56360a7a2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_main_window.ui @@ -0,0 +1,110 @@ + + + ZonePainterMainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 0 + 0 + 800 + 21 + + + + + + + toolBar + + + false + + + TopToolBarArea + + + false + + + + + + + + + toolBar_2 + + + LeftToolBarArea + + + false + + + + + + :/painterTools/images/colorize.png:/painterTools/images/colorize.png + + + Background + + + Background Color Dialog + + + + + + :/painterTools/images/go-down-7.png:/painterTools/images/go-down-7.png + + + ShowArrows + + + Show Landscape Orientation Arrows + + + + + Toggle Lighting + + + Toggle automatic lighting + + + + + true + + + + :/painterTools/images/lock-silver.png + :/painterTools/images/lock-6.png:/painterTools/images/lock-silver.png + + + Lock Borders + + + Lock Landscape Borders + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_plugin.cpp new file mode 100644 index 000000000..7b8237ccb --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_plugin.cpp @@ -0,0 +1,123 @@ +// Project includes +#include "zone_painter_plugin.h" +#include "zone_painter_settings_page.h" +#include "../core/icore.h" +#include "../core/core_constants.h" +#include "../core/imenu_manager.h" +#include "../../extension_system/iplugin_spec.h" + +// NeL includes +#include "nel/misc/debug.h" + +// Qt includes +#include +#include +#include +#include +#include +#include + +namespace Plugin +{ +ZonePainterPlugin::~ZonePainterPlugin() +{ + Q_FOREACH(QObject *obj, _autoReleaseObjects) + { + _plugMan->removeObject(obj); + } + qDeleteAll(_autoReleaseObjects); + _autoReleaseObjects.clear(); +} + +bool ZonePainterPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) +{ + Q_UNUSED(errorString); + _plugMan = pluginManager; + + addAutoReleasedObject(new CZonePainterSettingsPage(this)); + addAutoReleasedObject(new CZonePainterContext(this)); + //addAutoReleasedObject(new CCoreListener(this)); + return true; +} + +void ZonePainterPlugin::extensionsInitialized() +{ + Core::ICore *core = Core::ICore::instance(); + Core::IMenuManager *menuManager = core->menuManager(); + //menuManager = _plugMan->getObject(); + QAction *exampleAction1 = new QAction("Zone1", this); + QAction *exampleAction2 = new QAction("Zone2", this); + QAction *aboutQtAction = menuManager->action(Core::Constants::ABOUT_QT); + QMenu *helpMenu = menuManager->menu(Core::Constants::M_HELP); + helpMenu->insertAction(aboutQtAction, exampleAction1); + helpMenu->addSeparator(); + helpMenu->addAction(exampleAction2); + QMenu *zoneMenu = menuManager->menuBar()->addMenu("ZoneMenu"); + zoneMenu->insertAction(aboutQtAction, exampleAction1); + zoneMenu->addSeparator(); + zoneMenu->addAction(exampleAction2); +} + +void ZonePainterPlugin::setNelContext(NLMISC::INelContext *nelContext) +{ +#ifdef NL_OS_WINDOWS + // Ensure that a context doesn't exist yet. + // This only applies to platforms without PIC, e.g. Windows. + nlassert(!NLMISC::INelContext::isContextInitialised()); +#endif // NL_OS_WINDOWS + _LibContext = new NLMISC::CLibraryContext(*nelContext); +} + +QString ZonePainterPlugin::name() const +{ + return "ZonePainterPlugin"; +} + +QString ZonePainterPlugin::version() const +{ + return "0.2"; +} + +QString ZonePainterPlugin::vendor() const +{ + return "Ryzom Core"; +} + +QString ZonePainterPlugin::description() const +{ + return "Zone Painter Plugin"; +} + +QStringList ZonePainterPlugin::dependencies() const +{ + QStringList list; + list.append(Core::Constants::OVQT_CORE_PLUGIN); + //list.append("ObjectViewer"); + return list; +} + +void ZonePainterPlugin::addAutoReleasedObject(QObject *obj) +{ + _plugMan->addObject(obj); + _autoReleaseObjects.prepend(obj); +} + +QObject* ZonePainterPlugin::objectByName(const QString &name) const +{ + Q_FOREACH (QObject *qobj, _plugMan->allObjects()) + if (qobj->objectName() == name) + return qobj; + return 0; +} + +ExtensionSystem::IPluginSpec *ZonePainterPlugin::pluginByName(const QString &name) const +{ + Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins()) + if (spec->name() == name) + return spec; + return 0; +} + +} + +Q_EXPORT_PLUGIN(Plugin::ZonePainterPlugin) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_plugin.h new file mode 100644 index 000000000..7cb6b9c43 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_plugin.h @@ -0,0 +1,105 @@ +#ifndef ZONE_PAINTER_PLUGIN_H +#define ZONE_PAINTER_PLUGIN_H + +// Project includes +#include "../../extension_system/iplugin.h" +#include "../core/icontext.h" +#include "zone_painter_main_window.h" + +// NeL includes +#include "nel/misc/app_context.h" +#include +#include +#include + +// Qt includes +#include +#include + +namespace NLMISC +{ +class CLibraryContext; +} + +namespace ExtensionSystem +{ +class IPluginSpec; +} + +namespace Plugin +{ + + class CZoneManager { + public: + NL3D::CZone zone; + + std::string getZoneInfo() { + NL3D::CZone zone; + zone.getNumPatchs(); + + return ""; + } + }; + +class ZonePainterPlugin : public QObject, public ExtensionSystem::IPlugin +{ + Q_OBJECT + Q_INTERFACES(ExtensionSystem::IPlugin) +public: + + virtual ~ZonePainterPlugin(); + + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); + void extensionsInitialized(); + + void setNelContext(NLMISC::INelContext *nelContext); + + QString name() const; + QString version() const; + QString vendor() const; + QString description() const; + QStringList dependencies() const; + + void addAutoReleasedObject(QObject *obj); + + QObject *objectByName(const QString &name) const; + ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const; + + + +protected: + NLMISC::CLibraryContext *_LibContext; + +private: + ExtensionSystem::IPluginManager *_plugMan; + QList _autoReleaseObjects; +}; + +class CZonePainterContext: public Core::IContext +{ + Q_OBJECT +public: + CZonePainterContext(QObject *parent = 0): IContext(parent) {} + virtual ~CZonePainterContext() {} + + virtual QString id() const + { + return QLatin1String("ZonePainterContext"); + } + virtual QString trName() const + { + return tr("Zone Painter"); + } + virtual QIcon icon() const + { + return QIcon(); + } + virtual QWidget *widget() + { + return new ZonePainterMainWindow(); + } +}; + +} // namespace Plugin + +#endif // ZONE_PAINTER_PLUGIN_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_settings_page.cpp new file mode 100644 index 000000000..69c4e7525 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_settings_page.cpp @@ -0,0 +1,67 @@ +// 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 . + +#include "zone_painter_settings_page.h" + +// Qt includes +#include + +// NeL includes + +// Project includes + +namespace Plugin +{ + +CZonePainterSettingsPage::CZonePainterSettingsPage(QObject *parent) + : IOptionsPage(parent), + _currentPage(NULL) +{ +} + +QString CZonePainterSettingsPage::id() const +{ + return QLatin1String("ZonePainterPage"); +} + +QString CZonePainterSettingsPage::trName() const +{ + return tr("Zone Painter page"); +} + +QString CZonePainterSettingsPage::category() const +{ + return QLatin1String("General"); +} + +QString CZonePainterSettingsPage::trCategory() const +{ + return tr("General"); +} + +QWidget *CZonePainterSettingsPage::createPage(QWidget *parent) +{ + _currentPage = new QWidget(parent); + _ui.setupUi(_currentPage); + return _currentPage; +} + +void CZonePainterSettingsPage::apply() +{ +} + +} /* namespace Plugin */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_settings_page.h new file mode 100644 index 000000000..8e4b3f3d6 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_settings_page.h @@ -0,0 +1,58 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef ZONE_PAINTER_SETTINGS_PAGE_H +#define ZONE_PAINTER_SETTINGS_PAGE_H + +#include + +#include "../core/ioptions_page.h" + +#include "ui_zone_painter_settings_page.h" + +class QWidget; + +namespace Plugin +{ +/** +@class CZonePainterSettingsPage +*/ +class CZonePainterSettingsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + CZonePainterSettingsPage(QObject *parent = 0); + virtual ~CZonePainterSettingsPage() {} + + virtual QString id() const; + virtual QString trName() const; + virtual QString category() const; + virtual QString trCategory() const; + virtual QWidget *createPage(QWidget *parent); + + virtual void apply(); + virtual void finish() {} + +private: + QWidget *_currentPage; + Ui::CZonePainterSettingsPage _ui; +}; + +} // namespace Plugin + +#endif // EXAMPLE_SETTINGS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_settings_page.ui new file mode 100644 index 000000000..ccd302975 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/zone_painter/zone_painter_settings_page.ui @@ -0,0 +1,92 @@ + + + CZonePainterSettingsPage + + + + 0 + 0 + 458 + 479 + + + + Form + + + + 0 + + + + + GroupBox + + + + + + PushButton + + + + + + + + + + PushButton + + + + + + + RadioButton + + + + + + + RadioButton + + + + + + + CheckBox + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + + + +