From 3ccfad6d6b259c39ca9d8edc7dbc75653a913f40 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 2 Jun 2011 16:57:10 +0300 Subject: [PATCH 001/747] Added: #1301 Added pixmap database --- .../plugins/landscape_editor/CMakeLists.txt | 6 +- .../plugins/landscape_editor/builder_zone.cpp | 104 +++++++ .../plugins/landscape_editor/builder_zone.h | 75 +++++ .../landscape_editor/builder_zone_region.cpp | 28 ++ .../landscape_editor/builder_zone_region.h | 33 +++ .../landscape_editor_plugin.h | 2 +- .../landscape_editor_window.cpp | 7 +- .../landscape_editor_window.h | 2 + .../landscape_editor_window.ui | 17 ++ .../landscape_editor/landscape_scene.cpp | 38 +++ .../landscape_editor/landscape_scene.h | 42 +++ .../landscape_editor/zone_list_model.cpp | 165 +++++++++++ .../landscape_editor/zone_list_model.h | 82 ++++++ .../landscape_editor/zone_list_widget.cpp | 44 +++ .../landscape_editor/zone_list_widget.h | 54 ++++ .../landscape_editor/zone_list_widget.ui | 266 ++++++++++++++++++ 16 files changed, 962 insertions(+), 3 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index 3b6a61c5e..2f7487fe7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -11,9 +11,13 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h landscape_editor_window.h + landscape_scene.h + zone_list_model.h + zone_list_widget.h ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui + zone_list_widget.ui ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc) @@ -37,7 +41,7 @@ ADD_LIBRARY(ovqt_plugin_landscape_editor MODULE ${SRC} ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS} ${OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS}) -TARGET_LINK_LIBRARIES(ovqt_plugin_landscape_editor ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) +TARGET_LINK_LIBRARIES(ovqt_plugin_landscape_editor ovqt_plugin_core nelmisc nel3d nelgeorges nelligo ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) NL_DEFAULT_PROPS(ovqt_plugin_landscape_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Landscape Editor") NL_ADD_RUNTIME_FLAGS(ovqt_plugin_landscape_editor) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp new file mode 100644 index 000000000..d79770cf3 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -0,0 +1,104 @@ +// 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 "builder_zone.h" +#include "zone_list_model.h" + +// NeL includes +#include + +// Qt includes +#include +#include + +namespace LandscapeEditor +{ + +ZoneBuilder::ZoneBuilder() + : m_zoneListModel(0) +{ + m_zoneListModel = new ZoneListModel(); + m_lastPathName = ""; +} + +ZoneBuilder::~ZoneBuilder() +{ + delete m_zoneListModel; +} + +bool ZoneBuilder::init(const QString &pathName, bool makeAZone) +{ + bool bRet = true; + if (pathName != m_lastPathName) + { + m_lastPathName = pathName; + QString zoneBankPath = pathName; + zoneBankPath += "/zoneligos/"; + + // Init the ZoneBank + m_zoneBank.reset (); + if (!initZoneBank (zoneBankPath)) + { + m_zoneBank.reset (); + return false; + } + // Construct the DataBase from the ZoneBank + QString zoneBitmapPath = pathName; + zoneBitmapPath += "/zonebitmaps/"; + m_zoneListModel->resetModel(); + if (!m_zoneListModel->rebuildModel(zoneBitmapPath, m_zoneBank)) + { + m_zoneBank.reset(); + return false; + } + } + + if ((makeAZone) && (bRet)) + newZone(); + return bRet; +} + +bool ZoneBuilder::initZoneBank (const QString &pathName) +{ + QDir *dir = new QDir(pathName); + QStringList filters; + filters << "*.ligozone"; + + // Find all ligozone files in dir + QStringList listFiles = dir->entryList(filters, QDir::Files); + + std::string error; + Q_FOREACH(QString file, listFiles) + { + //nlinfo(file.toStdString().c_str()); + if (!m_zoneBank.addElement((pathName + file).toStdString(), error)) + QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok); + } + return true; +} + +ZoneListModel *ZoneBuilder::zoneModel() const +{ + return m_zoneListModel; +} + +void ZoneBuilder::newZone (bool bDisplay) +{ +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h new file mode 100644 index 000000000..b578a2bb2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -0,0 +1,75 @@ +// 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 BUILDER_ZONE_H +#define BUILDER_ZONE_H + +// Project includes + +// NeL includes +#include + +// STL includes +#include +#include + +// Qt includes +#include + +namespace LandscapeEditor +{ +class ZoneListModel; + +/** +@class ZoneBuilder +@brief ZoneBuilder contains all the shared data between the tools and the engine +@details ZoneBank contains the macro zones that is composed of several zones plus a mask +ZoneListModel contains the graphics for the zones +*/ +class ZoneBuilder +{ +public: + ZoneBuilder(); + ~ZoneBuilder(); + + // Init zoneBank and init zone pixmap database + bool init(const QString &pathName, bool bMakeAZone); + + void newZone(bool bDisplay=true); + + // Accessors + NLLIGO::CZoneBank &getZoneBank() + { + return m_zoneBank; + } + ZoneListModel *zoneModel() const; +private: + + // Scan ./zoneligos dir and add all *.ligozone files to zoneBank + bool initZoneBank (const QString &path); + + sint32 m_minX, m_maxX, m_minY, m_maxY; + QString m_lastPathName; + + ZoneListModel *m_zoneListModel; + NLLIGO::CZoneBank m_zoneBank; + std::vector m_currentSelection; +}; + +} /* namespace LandscapeEditor */ + +#endif // BUILDER_ZONE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp new file mode 100644 index 000000000..4dbd3e9e1 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp @@ -0,0 +1,28 @@ +// 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 "builder_zone_region.h" + +// NeL includes +#include + +// Qt includes + +namespace LandscapeEditor +{ +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h new file mode 100644 index 000000000..158c72715 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h @@ -0,0 +1,33 @@ +// 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 BUILDER_ZONE_REGION_H +#define BUILDER_ZONE_REGION_H + +// Project includes + +// NeL includes +#include + +// Qt includes + +namespace LandscapeEditor +{ + +} /* namespace LandscapeEditor */ + +#endif // BUILDER_ZONE_REGION_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h index 67a3172ee..8f9f811cf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h @@ -91,7 +91,7 @@ public: } virtual QIcon icon() const { - return QIcon(); + return QIcon(Constants::ICON_LANDSCAPE_ITEM); } virtual void open(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 4b075adfc..c46278f38 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -18,6 +18,7 @@ // Project includes #include "landscape_editor_window.h" #include "landscape_editor_constants.h" +#include "zone_list_model.h" #include "../core/icore.h" #include "../core/imenu_manager.h" @@ -40,7 +41,11 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); - + /* + m_zoneBuilder = new ZoneBuilder(); + m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); + m_ui.zoneListWidget->setModel(m_zoneBuilder->zoneModel()); + */ createMenus(); readSettings(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index cc17e6cbc..61e0c7eb1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -20,6 +20,7 @@ // Project includes #include "ui_landscape_editor_window.h" +#include "builder_zone.h" // Qt includes #include @@ -47,6 +48,7 @@ private: void readSettings(); void writeSettings(); + ZoneBuilder *m_zoneBuilder; QUndoStack *m_undoStack; Ui::LandscapeEditorWindow m_ui; }; /* class LandscapeEditorWindow */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index 5d9606ddf..ce6e905a3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -35,7 +35,24 @@ false + + + Zones + + + 2 + + + + + + LandscapeEditor::ZoneListWidget + QWidget +
zone_list_widget.h
+ 1 +
+
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp new file mode 100644 index 000000000..f491dfa2b --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -0,0 +1,38 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "landscape_scene.h" + +// NeL includes +#include + +// Qt includes + +namespace LandscapeEditor +{ + +LandscapeScene::LandscapeScene(QObject *parent) + : QGraphicsScene(parent) +{ +} + +LandscapeScene::~LandscapeScene() +{ +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h new file mode 100644 index 000000000..d4fb91c78 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -0,0 +1,42 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef LANDSCAPE_SCENE_H +#define LANDSCAPE_SCENE_H + +// Project includes + +// NeL includes + +// Qt includes +#include + +namespace LandscapeEditor +{ + +class LandscapeScene : public QGraphicsScene +{ + Q_OBJECT + +public: + LandscapeScene(QObject *parent = 0); + virtual ~LandscapeScene(); +}; + +} /* namespace LandscapeEditor */ + +#endif // LANDSCAPE_SCENE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp new file mode 100644 index 000000000..32dded570 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp @@ -0,0 +1,165 @@ +// 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 "zone_list_model.h" + +// NeL includes +#include + +// STL includes +#include +#include + +// Qt includes +#include +#include +#include + +namespace LandscapeEditor +{ + +ZoneListModel::ZoneListModel(int pixmapSize, QObject *parent) + : QAbstractListModel(parent), + m_pixmapSize(pixmapSize) +{ + +} +ZoneListModel::~ZoneListModel() +{ + resetModel(); +} + +int ZoneListModel::rowCount(const QModelIndex & /* parent */) const +{ + return m_pixmapMap.count(); +} + +int ZoneListModel::columnCount(const QModelIndex & /* parent */) const +{ + return 1; +} + +QVariant ZoneListModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (role == Qt::TextAlignmentRole) + { + return int(Qt::AlignLeft | Qt::AlignVCenter); + } + else if (role == Qt::DisplayRole) + { + return m_pixmapNameList.at(index.row()); + } + else if (role == Qt::DecorationRole) + { + QPixmap *pixmap = getSmallPixmap(m_pixmapNameList.at(index.row())); + return qVariantFromValue(*pixmap); + } + return QVariant(); +} + +QVariant ZoneListModel::headerData(int section, + Qt::Orientation /* orientation */, + int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + return QVariant(); +} + +void ZoneListModel::setSmallPixmapSize(int pixmapSize) +{ + m_pixmapSize = pixmapSize; +} + +void ZoneListModel::resetModel() +{ + beginResetModel(); + Q_FOREACH(QString name, m_pixmapNameList) + { + QPixmap *pixmap = m_pixmapMap.value(name); + delete pixmap; + QPixmap *smallPixmap = m_smallPixmapMap.value(name); + delete smallPixmap; + } + m_pixmapMap.clear(); + m_pixmapNameList.clear(); + m_smallPixmapMap.clear(); + endResetModel(); +} + +bool ZoneListModel::rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank) +{ + beginResetModel(); + m_zonePath = zonePath; + + QProgressDialog *progressDialog = new QProgressDialog(); + + std::vector zoneNames; + zoneBank.getCategoryValues ("zone", zoneNames); + progressDialog->setRange(0, zoneNames.size()); + for (uint i = 0; i < zoneNames.size(); ++i) + { + QApplication::processEvents(); + progressDialog->setValue(i); + + NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (zoneNames[i]); + + // Read the texture file + QString zonePixmapName(zoneNames[i].c_str()); + uint8 sizeX = zoneBankItem->getSizeX(); + uint8 sizeY = zoneBankItem->getSizeY(); + const std::vector &rMask = zoneBankItem->getMask(); + + QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png"); + QPixmap *smallPixmap = new QPixmap(pixmap->scaled(m_pixmapSize * sizeX, m_pixmapSize * sizeY)); + + m_pixmapMap.insert(zonePixmapName, pixmap); + m_smallPixmapMap.insert(zonePixmapName, smallPixmap); + + } + m_pixmapNameList = m_pixmapMap.keys(); + endResetModel(); + delete progressDialog; + return false; +} + +QPixmap *ZoneListModel::getPixmap(const QString &zoneName) const +{ + QPixmap *result = 0; + if (!m_pixmapMap.contains(zoneName)) + nlwarning("QPixmap %s not found", zoneName.toStdString().c_str()); + else + result = m_pixmapMap.value(zoneName); + return result; +} + +QPixmap *ZoneListModel::getSmallPixmap(const QString &zoneName) const +{ + QPixmap *result = 0; + if (!m_pixmapMap.contains(zoneName)) + nlwarning("QPixmap %s not found", zoneName.toStdString().c_str()); + else + result = m_smallPixmapMap.value(zoneName); + return result; +} + + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h new file mode 100644 index 000000000..1bfb0f93f --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h @@ -0,0 +1,82 @@ +// 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_LIST_MODEL_H +#define ZONE_LIST_MODEL_H + +// Project includes + +// NeL includes +#include + +// Qt includes +#include +#include +#include +#include + +namespace LandscapeEditor +{ + +/** +@class ZoneListModel +@brief ZoneListModel contains the image database for QGraphicsScene and +small images for QListView +@details +*/ +class ZoneListModel : public QAbstractListModel +{ + Q_OBJECT +public: + ZoneListModel(int pixmapSize = 64, QObject *parent = 0); + ~ZoneListModel(); + + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role) const; + + /// Set size for small pixmaps + /// Value should be set before calling rebuildModel + void setSmallPixmapSize(int pixmapSize); + + /// Unload all images and reset model + void resetModel(); + + /// Load all images(png) from zonePath, list images gets from zoneBank + bool rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank); + + /// Get original pixmap + /// @return QPixmap* if the image is in the database ; otherwise returns 0. + QPixmap *getPixmap(const QString &zoneName) const; + + /// Get scaled pixmap (pixmapSize * zoneSize.sizeX, pixmapSize * zoneSize.sizeY) + /// @return QPixmap* if the image is in the database ; otherwise returns 0. + QPixmap *getSmallPixmap(const QString &zoneName) const; +private: + + QString m_zonePath; + int m_pixmapSize; + QMap m_pixmapMap; + QMap m_smallPixmapMap; + QList m_pixmapNameList; +}; + +} /* namespace LandscapeEditor */ + +#endif // ZONE_LIST_MODEL_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp new file mode 100644 index 000000000..423c2c50f --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp @@ -0,0 +1,44 @@ +// 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 "zone_list_widget.h" + +// NeL includes +#include + +// Qt includes + +namespace LandscapeEditor +{ + +ZoneListWidget::ZoneListWidget(QWidget *parent) + : QWidget(parent) +{ + m_ui.setupUi(this); +} + +ZoneListWidget::~ZoneListWidget() +{ +} + +void ZoneListWidget::setModel(QAbstractItemModel *model) +{ + m_ui.listView->setModel(model); +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h new file mode 100644 index 000000000..5b90f81d6 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h @@ -0,0 +1,54 @@ +// 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_LIST_WIDGET_H +#define ZONE_LIST_WIDGET_H + +// Project includes +#include "ui_zone_list_widget.h" + +// NeL includes + +// Qt includes + +namespace LandscapeEditor +{ +/** +@class ZoneListWidget +@brief ZoneListWidget +@details +*/ +class ZoneListWidget: public QWidget +{ + Q_OBJECT + +public: + ZoneListWidget(QWidget *parent = 0); + ~ZoneListWidget(); + + void setModel(QAbstractItemModel *model); + +Q_SIGNALS: +public Q_SLOTS: +private Q_SLOTS: +private: + Ui::ZoneListWidget m_ui; +}; /* ZoneListWidget */ + +} /* namespace LandscapeEditor */ + +#endif // ZONE_LIST_WIDGET_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui new file mode 100644 index 000000000..725e6cf83 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui @@ -0,0 +1,266 @@ + + + ZoneListWidget + + + + 0 + 0 + 359 + 579 + + + + Form + + + + 3 + + + 3 + + + + + Filter + + + + 6 + + + 3 + + + + + + <Unused> + + + + + + + + + + + + Random + + + + + Fyll cycle + + + + + + + + true + + + + <Unused> + + + + + + + + true + + + + + + + true + + + + And + + + + + Or + + + + + + + + false + + + + <Unused> + + + + + + + + false + + + + + + + false + + + + And + + + + + Or + + + + + + + + false + + + + <Unused> + + + + + + + + false + + + + + + + false + + + + And + + + + + Or + + + + + + + + + + + Placement + + + + 6 + + + 3 + + + + + + + + + + + 90° + + + + + 180° + + + + + 170° + + + + + Random + + + + + Full cycle + + + + + + + + + NoFlip + + + + + Flip + + + + + Random + + + + + Fyll cycle + + + + + + + + Force + + + + + + + Not propogate + + + + + + + + + + + + + + From cd729782990d031f2d7f965ed7741f2a83c48603 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 2 Jun 2011 23:31:21 +0300 Subject: [PATCH 002/747] Added: #1301 Added filter for list zones in landscape editor. --- .../plugins/landscape_editor/CMakeLists.txt | 7 +- .../plugins/landscape_editor/builder_zone.cpp | 7 +- .../plugins/landscape_editor/builder_zone.h | 6 +- ..._list_widget.cpp => landscape_actions.cpp} | 18 +- ...zone_list_widget.h => landscape_actions.h} | 28 +- .../landscape_editor_window.cpp | 12 +- .../landscape_editor_window.ui | 6 +- ...ne_list_model.cpp => list_zones_model.cpp} | 46 +- .../{zone_list_model.h => list_zones_model.h} | 18 +- .../landscape_editor/list_zones_widget.cpp | 219 ++++++++ .../landscape_editor/list_zones_widget.h | 68 +++ .../landscape_editor/list_zones_widget.ui | 478 ++++++++++++++++++ .../landscape_editor/zone_list_widget.ui | 266 ---------- 13 files changed, 827 insertions(+), 352 deletions(-) rename code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/{zone_list_widget.cpp => landscape_actions.cpp} (76%) rename code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/{zone_list_widget.h => landscape_actions.h} (68%) rename code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/{zone_list_model.cpp => list_zones_model.cpp} (73%) rename code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/{zone_list_model.h => list_zones_model.h} (86%) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui delete mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index 2f7487fe7..714d1f125 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -12,12 +12,13 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h landscape_editor_window.h landscape_scene.h - zone_list_model.h - zone_list_widget.h + list_zones_model.h + list_zones_widget.h + landscape_actions.h ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui - zone_list_widget.ui + list_zones_widget.ui ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index d79770cf3..42242921e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -17,7 +17,7 @@ // Project includes #include "builder_zone.h" -#include "zone_list_model.h" +#include "list_zones_model.h" // NeL includes #include @@ -32,7 +32,7 @@ namespace LandscapeEditor ZoneBuilder::ZoneBuilder() : m_zoneListModel(0) { - m_zoneListModel = new ZoneListModel(); + m_zoneListModel = new ListZonesModel(); m_lastPathName = ""; } @@ -67,7 +67,6 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone) return false; } } - if ((makeAZone) && (bRet)) newZone(); return bRet; @@ -92,7 +91,7 @@ bool ZoneBuilder::initZoneBank (const QString &pathName) return true; } -ZoneListModel *ZoneBuilder::zoneModel() const +ListZonesModel *ZoneBuilder::zoneModel() const { return m_zoneListModel; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index b578a2bb2..97c4d8d3a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -32,7 +32,7 @@ namespace LandscapeEditor { -class ZoneListModel; +class ListZonesModel; /** @class ZoneBuilder @@ -56,7 +56,7 @@ public: { return m_zoneBank; } - ZoneListModel *zoneModel() const; + ListZonesModel *zoneModel() const; private: // Scan ./zoneligos dir and add all *.ligozone files to zoneBank @@ -65,7 +65,7 @@ private: sint32 m_minX, m_maxX, m_minY, m_maxY; QString m_lastPathName; - ZoneListModel *m_zoneListModel; + ListZonesModel *m_zoneListModel; NLLIGO::CZoneBank m_zoneBank; std::vector m_currentSelection; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp similarity index 76% rename from code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp rename to code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp index 423c2c50f..f0b86dd8e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp @@ -16,7 +16,7 @@ // along with this program. If not, see . // Project includes -#include "zone_list_widget.h" +#include "landscape_actions.h" // NeL includes #include @@ -25,20 +25,4 @@ namespace LandscapeEditor { - -ZoneListWidget::ZoneListWidget(QWidget *parent) - : QWidget(parent) -{ - m_ui.setupUi(this); -} - -ZoneListWidget::~ZoneListWidget() -{ -} - -void ZoneListWidget::setModel(QAbstractItemModel *model) -{ - m_ui.listView->setModel(model); -} - } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h similarity index 68% rename from code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h rename to code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h index 5b90f81d6..fdcda5451 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h @@ -15,11 +15,10 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#ifndef ZONE_LIST_WIDGET_H -#define ZONE_LIST_WIDGET_H +#ifndef LANDSCAPE_ACTIONS_H +#define LANDSCAPE_ACTIONS_H // Project includes -#include "ui_zone_list_widget.h" // NeL includes @@ -27,28 +26,7 @@ namespace LandscapeEditor { -/** -@class ZoneListWidget -@brief ZoneListWidget -@details -*/ -class ZoneListWidget: public QWidget -{ - Q_OBJECT - -public: - ZoneListWidget(QWidget *parent = 0); - ~ZoneListWidget(); - - void setModel(QAbstractItemModel *model); - -Q_SIGNALS: -public Q_SLOTS: -private Q_SLOTS: -private: - Ui::ZoneListWidget m_ui; -}; /* ZoneListWidget */ } /* namespace LandscapeEditor */ -#endif // ZONE_LIST_WIDGET_H +#endif // LANDSCAPE_ACTIONS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index c46278f38..eb9b8b8e8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -18,7 +18,7 @@ // Project includes #include "landscape_editor_window.h" #include "landscape_editor_constants.h" -#include "zone_list_model.h" +#include "list_zones_model.h" #include "../core/icore.h" #include "../core/imenu_manager.h" @@ -41,11 +41,11 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); - /* - m_zoneBuilder = new ZoneBuilder(); - m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); - m_ui.zoneListWidget->setModel(m_zoneBuilder->zoneModel()); - */ + m_zoneBuilder = new ZoneBuilder(); + m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); + m_ui.zoneListWidget->setModel(m_zoneBuilder->zoneModel()); + m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); + m_ui.zoneListWidget->updateUi(); createMenus(); readSettings(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index ce6e905a3..ac16ad9fd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -42,14 +42,14 @@ 2 - + - LandscapeEditor::ZoneListWidget + LandscapeEditor::ListZonesWidget QWidget -
zone_list_widget.h
+
list_zones_widget.h
1
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp similarity index 73% rename from code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp rename to code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp index 32dded570..ffcb7617b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp @@ -16,7 +16,7 @@ // along with this program. If not, see . // Project includes -#include "zone_list_model.h" +#include "list_zones_model.h" // NeL includes #include @@ -33,28 +33,28 @@ namespace LandscapeEditor { -ZoneListModel::ZoneListModel(int pixmapSize, QObject *parent) +ListZonesModel::ListZonesModel(int pixmapSize, QObject *parent) : QAbstractListModel(parent), m_pixmapSize(pixmapSize) { } -ZoneListModel::~ZoneListModel() +ListZonesModel::~ListZonesModel() { resetModel(); } -int ZoneListModel::rowCount(const QModelIndex & /* parent */) const +int ListZonesModel::rowCount(const QModelIndex & /* parent */) const { - return m_pixmapMap.count(); + return m_pixmapNameList.count(); } -int ZoneListModel::columnCount(const QModelIndex & /* parent */) const +int ListZonesModel::columnCount(const QModelIndex & /* parent */) const { return 1; } -QVariant ZoneListModel::data(const QModelIndex &index, int role) const +QVariant ListZonesModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); @@ -75,21 +75,29 @@ QVariant ZoneListModel::data(const QModelIndex &index, int role) const return QVariant(); } -QVariant ZoneListModel::headerData(int section, - Qt::Orientation /* orientation */, - int role) const +QVariant ListZonesModel::headerData(int section, + Qt::Orientation /* orientation */, + int role) const { if (role != Qt::DisplayRole) return QVariant(); return QVariant(); } -void ZoneListModel::setSmallPixmapSize(int pixmapSize) +void ListZonesModel::setSmallPixmapSize(int pixmapSize) { m_pixmapSize = pixmapSize; } -void ZoneListModel::resetModel() +void ListZonesModel::setListZones(QStringList &listZones) +{ + beginResetModel(); + m_pixmapNameList.clear(); + m_pixmapNameList = listZones; + endResetModel(); +} + +void ListZonesModel::resetModel() { beginResetModel(); Q_FOREACH(QString name, m_pixmapNameList) @@ -105,12 +113,13 @@ void ZoneListModel::resetModel() endResetModel(); } -bool ZoneListModel::rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank) +bool ListZonesModel::rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank) { beginResetModel(); m_zonePath = zonePath; QProgressDialog *progressDialog = new QProgressDialog(); + progressDialog->show(); std::vector zoneNames; zoneBank.getCategoryValues ("zone", zoneNames); @@ -129,19 +138,22 @@ bool ZoneListModel::rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zon const std::vector &rMask = zoneBankItem->getMask(); QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png"); + if (pixmap->isNull()) + { + // Generate filled pixmap + } QPixmap *smallPixmap = new QPixmap(pixmap->scaled(m_pixmapSize * sizeX, m_pixmapSize * sizeY)); m_pixmapMap.insert(zonePixmapName, pixmap); m_smallPixmapMap.insert(zonePixmapName, smallPixmap); } - m_pixmapNameList = m_pixmapMap.keys(); endResetModel(); delete progressDialog; - return false; + return true; } -QPixmap *ZoneListModel::getPixmap(const QString &zoneName) const +QPixmap *ListZonesModel::getPixmap(const QString &zoneName) const { QPixmap *result = 0; if (!m_pixmapMap.contains(zoneName)) @@ -151,7 +163,7 @@ QPixmap *ZoneListModel::getPixmap(const QString &zoneName) const return result; } -QPixmap *ZoneListModel::getSmallPixmap(const QString &zoneName) const +QPixmap *ListZonesModel::getSmallPixmap(const QString &zoneName) const { QPixmap *result = 0; if (!m_pixmapMap.contains(zoneName)) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h similarity index 86% rename from code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h rename to code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h index 1bfb0f93f..16a28bf07 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h @@ -15,8 +15,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#ifndef ZONE_LIST_MODEL_H -#define ZONE_LIST_MODEL_H +#ifndef LIST_ZONES_MODEL_H +#define LIST_ZONES_MODEL_H // Project includes @@ -33,17 +33,17 @@ namespace LandscapeEditor { /** -@class ZoneListModel -@brief ZoneListModel contains the image database for QGraphicsScene and +@class ListZonesModel +@brief ListZonesModel contains the image database for QGraphicsScene and small images for QListView @details */ -class ZoneListModel : public QAbstractListModel +class ListZonesModel : public QAbstractListModel { Q_OBJECT public: - ZoneListModel(int pixmapSize = 64, QObject *parent = 0); - ~ZoneListModel(); + ListZonesModel(int pixmapSize = 64, QObject *parent = 0); + ~ListZonesModel(); int rowCount(const QModelIndex &parent) const; int columnCount(const QModelIndex &parent) const; @@ -58,6 +58,8 @@ public: /// Unload all images and reset model void resetModel(); + void setListZones(QStringList &listZones); + /// Load all images(png) from zonePath, list images gets from zoneBank bool rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank); @@ -79,4 +81,4 @@ private: } /* namespace LandscapeEditor */ -#endif // ZONE_LIST_MODEL_H +#endif // LIST_ZONES_MODEL_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp new file mode 100644 index 000000000..8dcb87383 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp @@ -0,0 +1,219 @@ +// 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 "list_zones_widget.h" +#include "builder_zone.h" +#include "list_zones_model.h" + +// NeL includes +#include +#include +#include + +// STL includes +#include +#include + +// Qt includes +#include + +namespace LandscapeEditor +{ + +ListZonesWidget::ListZonesWidget(QWidget *parent) + : QWidget(parent), + m_zoneBuilder(0) +{ + m_ui.setupUi(this); + + m_ui.addFilterButton_1->setChecked(false); + m_ui.addFilterButton_2->setChecked(false); + m_ui.addFilterButton_3->setChecked(false); + + connect(m_ui.categoryTypeComboBox_1, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_1(QString))); + connect(m_ui.categoryTypeComboBox_2, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_2(QString))); + connect(m_ui.categoryTypeComboBox_3, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_3(QString))); + connect(m_ui.categoryTypeComboBox_4, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_4(QString))); + connect(m_ui.categoryValueComboBox_1, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones())); + connect(m_ui.categoryValueComboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones())); + connect(m_ui.categoryValueComboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones())); + connect(m_ui.categoryValueComboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones())); + connect(m_ui.logicComboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones())); + connect(m_ui.logicComboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones())); + connect(m_ui.logicComboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones())); +} + +ListZonesWidget::~ListZonesWidget() +{ +} + +void ListZonesWidget::updateUi() +{ + if (m_zoneBuilder == 0) + return; + + disableSignals(true); + std::vector listCategoryType; + m_zoneBuilder->getZoneBank().getCategoriesType(listCategoryType); + + QStringList listCategories; + + listCategories << STRING_UNUSED; + for (size_t i = 0; i < listCategoryType.size(); ++i) + listCategories << QString(listCategoryType[i].c_str()); + + m_ui.categoryTypeComboBox_1->clear(); + m_ui.categoryTypeComboBox_2->clear(); + m_ui.categoryTypeComboBox_3->clear(); + m_ui.categoryTypeComboBox_4->clear(); + + m_ui.categoryTypeComboBox_1->addItems(listCategories); + m_ui.categoryTypeComboBox_2->addItems(listCategories); + m_ui.categoryTypeComboBox_3->addItems(listCategories); + m_ui.categoryTypeComboBox_4->addItems(listCategories); + + disableSignals(false); +} + +void ListZonesWidget::setModel(QAbstractItemModel *model) +{ + m_ui.listView->setModel(model); +} + +void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder) +{ + m_zoneBuilder = zoneBuilder; +} + +void ListZonesWidget::updateFilters_1(const QString &value) +{ + disableSignals(true); + std::vector allCategoryValues; + m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues); + m_ui.categoryValueComboBox_1->clear(); + for(size_t i = 0; i < allCategoryValues.size(); ++i) + m_ui.categoryValueComboBox_1->addItem(QString(allCategoryValues[i].c_str())); + + disableSignals(false); + updateListZones(); +} + +void ListZonesWidget::updateFilters_2(const QString &value) +{ + disableSignals(true); + std::vector allCategoryValues; + m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues); + + m_ui.categoryValueComboBox_2->clear(); + for(size_t i = 0; i < allCategoryValues.size(); ++i) + m_ui.categoryValueComboBox_2->addItem(QString(allCategoryValues[i].c_str())); + + disableSignals(false); + updateListZones(); +} + +void ListZonesWidget::updateFilters_3(const QString &value) +{ + disableSignals(true); + std::vector allCategoryValues; + m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues); + + m_ui.categoryValueComboBox_3->clear(); + for(size_t i = 0; i < allCategoryValues.size(); ++i) + m_ui.categoryValueComboBox_3->addItem(QString(allCategoryValues[i].c_str())); + + disableSignals(false); + updateListZones(); +} + +void ListZonesWidget::updateFilters_4(const QString &value) +{ + disableSignals(true); + std::vector allCategoryValues; + m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues); + + m_ui.categoryValueComboBox_4->clear(); + for(size_t i = 0; i < allCategoryValues.size(); ++i) + m_ui.categoryValueComboBox_4->addItem(QString(allCategoryValues[i].c_str())); + + disableSignals(false); + updateListZones(); +} + +void ListZonesWidget::updateListZones() +{ + // Execute the filter + NLLIGO::CZoneBank &zoneBank = m_zoneBuilder->getZoneBank(); + zoneBank.resetSelection (); + + if(m_ui.categoryTypeComboBox_1->currentIndex() > 0 ) + zoneBank.addOrSwitch (m_ui.categoryTypeComboBox_1->currentText().toStdString() + , m_ui.categoryValueComboBox_1->currentText().toStdString()); + + if(m_ui.categoryTypeComboBox_2->currentIndex() > 0 ) + { + if (m_ui.logicComboBox_2->currentIndex() == 0) // AND switch wanted + zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_2->currentText().toStdString() + ,m_ui.categoryValueComboBox_2->currentText().toStdString()); + else // OR switch wanted + zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_2->currentText().toStdString() + ,m_ui.categoryValueComboBox_2->currentText().toStdString()); + } + + if(m_ui.categoryTypeComboBox_3->currentIndex() > 0 ) + { + if (m_ui.logicComboBox_3->currentIndex() == 0) // AND switch wanted + zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_3->currentText().toStdString() + ,m_ui.categoryValueComboBox_3->currentText().toStdString()); + else // OR switch wanted + zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_3->currentText().toStdString() + ,m_ui.categoryValueComboBox_3->currentText().toStdString()); + } + + if(m_ui.categoryTypeComboBox_4->currentIndex() > 0 ) + { + if (m_ui.logicComboBox_4->currentIndex() == 0) // AND switch wanted + zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_4->currentText().toStdString() + ,m_ui.categoryValueComboBox_4->currentText().toStdString()); + else // OR switch wanted + zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_4->currentText().toStdString() + ,m_ui.categoryValueComboBox_4->currentText().toStdString()); + } + + std::vector currentSelection; + zoneBank.getSelection (currentSelection); + + QStringList listSelection; + for (size_t i = 0; i < currentSelection.size(); ++i) + listSelection << currentSelection[i]->getName().c_str(); + m_zoneBuilder->zoneModel()->setListZones(listSelection); +} + +void ListZonesWidget::disableSignals(bool block) +{ + m_ui.categoryTypeComboBox_1->blockSignals(block); + m_ui.categoryTypeComboBox_2->blockSignals(block); + m_ui.categoryTypeComboBox_3->blockSignals(block); + m_ui.categoryTypeComboBox_4->blockSignals(block); + m_ui.categoryValueComboBox_1->blockSignals(block); + m_ui.categoryValueComboBox_2->blockSignals(block); + m_ui.categoryValueComboBox_3->blockSignals(block); + m_ui.categoryValueComboBox_4->blockSignals(block); +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h new file mode 100644 index 000000000..fed0134cf --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -0,0 +1,68 @@ +// 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 LIST_ZONES_WIDGET_H +#define LIST_ZONES_WIDGET_H + +// Project includes +#include "ui_list_zones_widget.h" + +// NeL includes + +// Qt includes + +namespace LandscapeEditor +{ +class ZoneBuilder; + +/** +@class ZoneListWidget +@brief ZoneListWidget +@details +*/ +class ListZonesWidget: public QWidget +{ + Q_OBJECT + +public: + ListZonesWidget(QWidget *parent = 0); + ~ListZonesWidget(); + + void updateUi(); + void setZoneBuilder(ZoneBuilder *zoneBuilder); + void setModel(QAbstractItemModel *model); + +Q_SIGNALS: +public Q_SLOTS: + void updateFilters_1(const QString &value); + void updateFilters_2(const QString &value); + void updateFilters_3(const QString &value); + void updateFilters_4(const QString &value); + +private Q_SLOTS: + void updateListZones(); + +private: + void disableSignals(bool block); + + ZoneBuilder *m_zoneBuilder; + Ui::ListZonesWidget m_ui; +}; /* ZoneListWidget */ + +} /* namespace LandscapeEditor */ + +#endif // LIST_ZONES_WIDGET_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui new file mode 100644 index 000000000..585371cb7 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui @@ -0,0 +1,478 @@ + + + ListZonesWidget + + + + 0 + 0 + 359 + 579 + + + + Form + + + + 3 + + + 3 + + + + + Filter + + + + 6 + + + 3 + + + + + + + + + + + + Random + + + + + Fyll cycle + + + + + + + + true + + + + + + + true + + + + + + + true + + + + And + + + + + Or + + + + + + + + true + + + + + + + true + + + + + + + true + + + + And + + + + + Or + + + + + + + + true + + + + + + + true + + + + + + + true + + + + And + + + + + Or + + + + + + + + ... + + + + :/core/icons/ic_nel_add_item.png + :/core/icons/ic_nel_delete_item.png:/core/icons/ic_nel_add_item.png + + + true + + + true + + + + + + + ... + + + + :/core/icons/ic_nel_add_item.png + :/core/icons/ic_nel_delete_item.png:/core/icons/ic_nel_add_item.png + + + true + + + true + + + + + + + ... + + + + :/core/icons/ic_nel_add_item.png + :/core/icons/ic_nel_delete_item.png:/core/icons/ic_nel_add_item.png + + + true + + + true + + + + + + + + + + Placement + + + + 6 + + + 3 + + + + + + + + + + + 90° + + + + + 180° + + + + + 170° + + + + + Random + + + + + Full cycle + + + + + + + + + NoFlip + + + + + Flip + + + + + Random + + + + + Fyll cycle + + + + + + + + Force + + + + + + + Not propogate + + + + + + + + + + + + + + + + + addFilterButton_1 + toggled(bool) + categoryTypeComboBox_2 + setVisible(bool) + + + 20 + 36 + + + 81 + 53 + + + + + addFilterButton_1 + toggled(bool) + categoryValueComboBox_2 + setVisible(bool) + + + 24 + 32 + + + 181 + 50 + + + + + addFilterButton_1 + toggled(bool) + logicComboBox_2 + setVisible(bool) + + + 20 + 31 + + + 301 + 55 + + + + + addFilterButton_2 + toggled(bool) + categoryTypeComboBox_3 + setVisible(bool) + + + 27 + 62 + + + 57 + 75 + + + + + addFilterButton_2 + toggled(bool) + categoryValueComboBox_3 + setVisible(bool) + + + 23 + 58 + + + 156 + 76 + + + + + addFilterButton_2 + toggled(bool) + logicComboBox_3 + setVisible(bool) + + + 23 + 53 + + + 255 + 77 + + + + + addFilterButton_3 + toggled(bool) + categoryTypeComboBox_4 + setVisible(bool) + + + 32 + 94 + + + 44 + 104 + + + + + addFilterButton_3 + toggled(bool) + categoryValueComboBox_4 + setVisible(bool) + + + 32 + 94 + + + 207 + 103 + + + + + addFilterButton_3 + toggled(bool) + logicComboBox_4 + setVisible(bool) + + + 21 + 81 + + + 278 + 104 + + + + + addFilterButton_2 + toggled(bool) + addFilterButton_3 + setVisible(bool) + + + 15 + 59 + + + 16 + 80 + + + + + addFilterButton_1 + toggled(bool) + addFilterButton_2 + setVisible(bool) + + + 13 + 35 + + + 17 + 60 + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui deleted file mode 100644 index 725e6cf83..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_list_widget.ui +++ /dev/null @@ -1,266 +0,0 @@ - - - ZoneListWidget - - - - 0 - 0 - 359 - 579 - - - - Form - - - - 3 - - - 3 - - - - - Filter - - - - 6 - - - 3 - - - - - - <Unused> - - - - - - - - - - - - Random - - - - - Fyll cycle - - - - - - - - true - - - - <Unused> - - - - - - - - true - - - - - - - true - - - - And - - - - - Or - - - - - - - - false - - - - <Unused> - - - - - - - - false - - - - - - - false - - - - And - - - - - Or - - - - - - - - false - - - - <Unused> - - - - - - - - false - - - - - - - false - - - - And - - - - - Or - - - - - - - - - - - Placement - - - - 6 - - - 3 - - - - - - - - - - - 90° - - - - - 180° - - - - - 170° - - - - - Random - - - - - Full cycle - - - - - - - - - NoFlip - - - - - Flip - - - - - Random - - - - - Fyll cycle - - - - - - - - Force - - - - - - - Not propogate - - - - - - - - - - - - - - From f02f5525aa0978376857f0e9c36d9b1395928077 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 4 Jun 2011 17:29:08 +0300 Subject: [PATCH 003/747] Changed: #1301 Added project settings dialog. --- .../plugins/landscape_editor/CMakeLists.txt | 2 + .../plugins/landscape_editor/builder_zone.cpp | 97 +++++++++++++++++-- .../plugins/landscape_editor/builder_zone.h | 43 +++++++- .../landscape_editor_window.cpp | 33 ++++++- .../landscape_editor_window.h | 3 + .../landscape_editor_window.ui | 23 ++++- .../landscape_editor/list_zones_model.cpp | 80 +++++---------- .../landscape_editor/list_zones_model.h | 27 +++--- .../landscape_editor/list_zones_widget.cpp | 16 ++- .../landscape_editor/list_zones_widget.h | 9 +- .../project_settings_dialog.cpp | 52 ++++++++++ .../project_settings_dialog.h | 46 +++++++++ .../project_settings_dialog.ui | 97 +++++++++++++++++++ 13 files changed, 429 insertions(+), 99 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index 714d1f125..227210366 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -15,10 +15,12 @@ SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h list_zones_model.h list_zones_widget.h landscape_actions.h + project_settings_dialog.h ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui list_zones_widget.ui + project_settings_dialog.ui ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 42242921e..3db771224 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -17,7 +17,6 @@ // Project includes #include "builder_zone.h" -#include "list_zones_model.h" // NeL includes #include @@ -25,20 +24,97 @@ // Qt includes #include #include +#include +#include namespace LandscapeEditor { +const int PixmapScale = 256; + +PixmapDatabase::PixmapDatabase() +{ +} + +PixmapDatabase::~PixmapDatabase() +{ + reset(); +} + +bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank) +{ + QProgressDialog *progressDialog = new QProgressDialog(); + progressDialog->show(); + + std::vector listNames; + zoneBank.getCategoryValues ("zone", listNames); + progressDialog->setRange(0, listNames.size()); + for (uint i = 0; i < listNames.size(); ++i) + { + QApplication::processEvents(); + progressDialog->setValue(i); + + NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (listNames[i]); + + // Read the texture file + QString zonePixmapName(listNames[i].c_str()); + uint8 sizeX = zoneBankItem->getSizeX(); + uint8 sizeY = zoneBankItem->getSizeY(); + + QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png"); + if (pixmap->isNull()) + { + // Generate filled pixmap + } + // All pixmaps must be have same size + if (pixmap->width() != sizeX * PixmapScale) + { + QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * PixmapScale, sizeY * PixmapScale)); + delete pixmap; + m_pixmapMap.insert(zonePixmapName, scaledPixmap); + } + else + m_pixmapMap.insert(zonePixmapName, pixmap); + } + delete progressDialog; + return true; +} + +void PixmapDatabase::reset() +{ + QStringList listNames(m_pixmapMap.keys()); + Q_FOREACH(QString name, listNames) + { + QPixmap *pixmap = m_pixmapMap.value(name); + delete pixmap; + } + m_pixmapMap.clear(); +} + +QStringList PixmapDatabase::listPixmaps() const +{ + return m_pixmapMap.keys(); +} + +QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const +{ + QPixmap *result = 0; + if (!m_pixmapMap.contains(zoneName)) + nlwarning("QPixmap %s not found", zoneName.toStdString().c_str()); + else + result = m_pixmapMap.value(zoneName); + return result; +} ZoneBuilder::ZoneBuilder() - : m_zoneListModel(0) + : m_pixmapDatabase(0) { - m_zoneListModel = new ListZonesModel(); + m_pixmapDatabase = new PixmapDatabase(); m_lastPathName = ""; } ZoneBuilder::~ZoneBuilder() { - delete m_zoneListModel; + delete m_pixmapDatabase; } bool ZoneBuilder::init(const QString &pathName, bool makeAZone) @@ -60,8 +136,8 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone) // Construct the DataBase from the ZoneBank QString zoneBitmapPath = pathName; zoneBitmapPath += "/zonebitmaps/"; - m_zoneListModel->resetModel(); - if (!m_zoneListModel->rebuildModel(zoneBitmapPath, m_zoneBank)) + m_pixmapDatabase->reset(); + if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank)) { m_zoneBank.reset(); return false; @@ -91,9 +167,14 @@ bool ZoneBuilder::initZoneBank (const QString &pathName) return true; } -ListZonesModel *ZoneBuilder::zoneModel() const +PixmapDatabase *ZoneBuilder::pixmapDatabase() const { - return m_zoneListModel; + return m_pixmapDatabase; +} + +QString ZoneBuilder::dataPath() const +{ + return m_lastPathName; } void ZoneBuilder::newZone (bool bDisplay) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index 97c4d8d3a..f69c2f7fb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -29,16 +29,47 @@ // Qt includes #include +#include +#include +#include namespace LandscapeEditor { -class ListZonesModel; + +/** +@class PixmapDatabase +@brief PixmapDatabase contains the image database +@details +*/ +class PixmapDatabase +{ +public: + PixmapDatabase(); + ~PixmapDatabase(); + + /// Load all images(png) from zonePath, list images gets from zoneBank + bool loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank); + + /// Unload all images + void reset(); + + /// Get list names all loaded pixmaps + QStringList listPixmaps() const; + + /// Get original pixmap + /// @return QPixmap* if the image is in the database ; otherwise returns 0. + QPixmap *pixmap(const QString &zoneName) const; +private: + + QMap m_pixmapMap; +}; + /** @class ZoneBuilder @brief ZoneBuilder contains all the shared data between the tools and the engine @details ZoneBank contains the macro zones that is composed of several zones plus a mask -ZoneListModel contains the graphics for the zones +PixmapDatabase contains the graphics for the zones */ class ZoneBuilder { @@ -56,7 +87,11 @@ public: { return m_zoneBank; } - ListZonesModel *zoneModel() const; + + PixmapDatabase *pixmapDatabase() const; + + QString dataPath() const; + private: // Scan ./zoneligos dir and add all *.ligozone files to zoneBank @@ -65,7 +100,7 @@ private: sint32 m_minX, m_maxX, m_minY, m_maxY; QString m_lastPathName; - ListZonesModel *m_zoneListModel; + PixmapDatabase *m_pixmapDatabase; NLLIGO::CZoneBank m_zoneBank; std::vector m_currentSelection; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index eb9b8b8e8..1b8716326 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -18,7 +18,7 @@ // Project includes #include "landscape_editor_window.h" #include "landscape_editor_constants.h" -#include "list_zones_model.h" +#include "project_settings_dialog.h" #include "../core/icore.h" #include "../core/imenu_manager.h" @@ -43,15 +43,18 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_undoStack = new QUndoStack(this); m_zoneBuilder = new ZoneBuilder(); m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); - m_ui.zoneListWidget->setModel(m_zoneBuilder->zoneModel()); m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); m_ui.zoneListWidget->updateUi(); createMenus(); + createToolBars(); readSettings(); + + connect(m_ui.projectSettingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings())); } LandscapeEditorWindow::~LandscapeEditorWindow() { + delete m_zoneBuilder; writeSettings(); } @@ -75,11 +78,37 @@ void LandscapeEditorWindow::open() setCursor(Qt::ArrowCursor); } +void LandscapeEditorWindow::openProjectSettings() +{ + ProjectSettingsDialog *dialog = new ProjectSettingsDialog(m_zoneBuilder->dataPath(), this); + dialog->show(); + int ok = dialog->exec(); + if (ok == QDialog::Accepted) + { + m_zoneBuilder->init(dialog->dataPath(), false); + m_ui.zoneListWidget->updateUi(); + } + delete dialog; +} + void LandscapeEditorWindow::createMenus() { Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); } +void LandscapeEditorWindow::createToolBars() +{ + Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); + //QAction *action = menuManager->action(Core::Constants::NEW); + //m_ui.fileToolBar->addAction(action); + QAction *action = menuManager->action(Core::Constants::OPEN); + m_ui.fileToolBar->addAction(action); + //action = menuManager->action(Core::Constants::SAVE); + //m_ui.fileToolBar->addAction(action); + //action = menuManager->action(Core::Constants::SAVE_AS); + //m_ui.fileToolBar->addAction(action); +} + void LandscapeEditorWindow::readSettings() { QSettings *settings = Core::ICore::instance()->settings(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index 61e0c7eb1..9b2ae0335 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -43,8 +43,11 @@ public Q_SLOTS: void open(); private Q_SLOTS: + void openProjectSettings(); + private: void createMenus(); + void createToolBars(); void readSettings(); void writeSettings(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index ac16ad9fd..3877d9732 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -24,7 +24,7 @@ - + toolBar @@ -44,6 +44,27 @@ + + + toolBar_2 + + + TopToolBarArea + + + false + + + + + + + :/icons/ic_nel_landscape_settings.png:/icons/ic_nel_landscape_settings.png + + + Project settings + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp index ffcb7617b..622fd8fb8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp @@ -17,6 +17,7 @@ // Project includes #include "list_zones_model.h" +#include "builder_zone.h" // NeL includes #include @@ -27,15 +28,14 @@ // Qt includes #include -#include #include namespace LandscapeEditor { -ListZonesModel::ListZonesModel(int pixmapSize, QObject *parent) +ListZonesModel::ListZonesModel(int scaleRatio, QObject *parent) : QAbstractListModel(parent), - m_pixmapSize(pixmapSize) + m_scaleRatio(scaleRatio) { } @@ -46,7 +46,7 @@ ListZonesModel::~ListZonesModel() int ListZonesModel::rowCount(const QModelIndex & /* parent */) const { - return m_pixmapNameList.count(); + return m_listNames.count(); } int ListZonesModel::columnCount(const QModelIndex & /* parent */) const @@ -65,11 +65,11 @@ QVariant ListZonesModel::data(const QModelIndex &index, int role) const } else if (role == Qt::DisplayRole) { - return m_pixmapNameList.at(index.row()); + return m_listNames.at(index.row()); } else if (role == Qt::DecorationRole) { - QPixmap *pixmap = getSmallPixmap(m_pixmapNameList.at(index.row())); + QPixmap *pixmap = getPixmap(m_listNames.at(index.row())); return qVariantFromValue(*pixmap); } return QVariant(); @@ -84,73 +84,48 @@ QVariant ListZonesModel::headerData(int section, return QVariant(); } -void ListZonesModel::setSmallPixmapSize(int pixmapSize) +void ListZonesModel::setScaleRatio(int scaleRatio) { - m_pixmapSize = pixmapSize; + m_scaleRatio = scaleRatio; } void ListZonesModel::setListZones(QStringList &listZones) { beginResetModel(); - m_pixmapNameList.clear(); - m_pixmapNameList = listZones; + m_listNames.clear(); + m_listNames = listZones; endResetModel(); } void ListZonesModel::resetModel() { beginResetModel(); - Q_FOREACH(QString name, m_pixmapNameList) + QStringList listNames(m_pixmapMap.keys()); + Q_FOREACH(QString name, listNames) { QPixmap *pixmap = m_pixmapMap.value(name); delete pixmap; - QPixmap *smallPixmap = m_smallPixmapMap.value(name); - delete smallPixmap; } m_pixmapMap.clear(); - m_pixmapNameList.clear(); - m_smallPixmapMap.clear(); + m_listNames.clear(); endResetModel(); } -bool ListZonesModel::rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank) +void ListZonesModel::rebuildModel(PixmapDatabase *pixmapDatabase) { + resetModel(); + beginResetModel(); - m_zonePath = zonePath; + QStringList listNames; + listNames = pixmapDatabase->listPixmaps(); - QProgressDialog *progressDialog = new QProgressDialog(); - progressDialog->show(); - - std::vector zoneNames; - zoneBank.getCategoryValues ("zone", zoneNames); - progressDialog->setRange(0, zoneNames.size()); - for (uint i = 0; i < zoneNames.size(); ++i) + Q_FOREACH(QString name, listNames) { - QApplication::processEvents(); - progressDialog->setValue(i); - - NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (zoneNames[i]); - - // Read the texture file - QString zonePixmapName(zoneNames[i].c_str()); - uint8 sizeX = zoneBankItem->getSizeX(); - uint8 sizeY = zoneBankItem->getSizeY(); - const std::vector &rMask = zoneBankItem->getMask(); - - QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png"); - if (pixmap->isNull()) - { - // Generate filled pixmap - } - QPixmap *smallPixmap = new QPixmap(pixmap->scaled(m_pixmapSize * sizeX, m_pixmapSize * sizeY)); - - m_pixmapMap.insert(zonePixmapName, pixmap); - m_smallPixmapMap.insert(zonePixmapName, smallPixmap); - + QPixmap *pixmap = pixmapDatabase->pixmap(name); + QPixmap *smallPixmap = new QPixmap(pixmap->scaled(pixmap->width() / m_scaleRatio, pixmap->height() / m_scaleRatio)); + m_pixmapMap.insert(name, smallPixmap); } endResetModel(); - delete progressDialog; - return true; } QPixmap *ListZonesModel::getPixmap(const QString &zoneName) const @@ -163,15 +138,4 @@ QPixmap *ListZonesModel::getPixmap(const QString &zoneName) const return result; } -QPixmap *ListZonesModel::getSmallPixmap(const QString &zoneName) const -{ - QPixmap *result = 0; - if (!m_pixmapMap.contains(zoneName)) - nlwarning("QPixmap %s not found", zoneName.toStdString().c_str()); - else - result = m_smallPixmapMap.value(zoneName); - return result; -} - - } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h index 16a28bf07..475416887 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h @@ -31,18 +31,18 @@ namespace LandscapeEditor { +class PixmapDatabase; /** @class ListZonesModel -@brief ListZonesModel contains the image database for QGraphicsScene and -small images for QListView +@brief ListZonesModel contains the small images for QListView @details */ class ListZonesModel : public QAbstractListModel { Q_OBJECT public: - ListZonesModel(int pixmapSize = 64, QObject *parent = 0); + ListZonesModel(int scaleRatio = 4, QObject *parent = 0); ~ListZonesModel(); int rowCount(const QModelIndex &parent) const; @@ -53,30 +53,25 @@ public: /// Set size for small pixmaps /// Value should be set before calling rebuildModel - void setSmallPixmapSize(int pixmapSize); + void setScaleRatio(int scaleRatio); /// Unload all images and reset model void resetModel(); + /// Set current list zones which will be available in QListView void setListZones(QStringList &listZones); - /// Load all images(png) from zonePath, list images gets from zoneBank - bool rebuildModel(const QString &zonePath, NLLIGO::CZoneBank &zoneBank); + /// Build own pixmaps database(all images are scaled: width/scaleRatio, height/scaleRatio) from pixmapDatabase + void rebuildModel(PixmapDatabase *pixmapDatabase); - /// Get original pixmap +private: + /// Get pixmap /// @return QPixmap* if the image is in the database ; otherwise returns 0. QPixmap *getPixmap(const QString &zoneName) const; - /// Get scaled pixmap (pixmapSize * zoneSize.sizeX, pixmapSize * zoneSize.sizeY) - /// @return QPixmap* if the image is in the database ; otherwise returns 0. - QPixmap *getSmallPixmap(const QString &zoneName) const; -private: - - QString m_zonePath; - int m_pixmapSize; + int m_scaleRatio; QMap m_pixmapMap; - QMap m_smallPixmapMap; - QList m_pixmapNameList; + QStringList m_listNames; }; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp index 8dcb87383..e4e3fae0d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp @@ -37,10 +37,14 @@ namespace LandscapeEditor ListZonesWidget::ListZonesWidget(QWidget *parent) : QWidget(parent), + m_listZonesModel(0), m_zoneBuilder(0) { m_ui.setupUi(this); + m_listZonesModel = new ListZonesModel(4, this); + m_ui.listView->setModel(m_listZonesModel); + m_ui.addFilterButton_1->setChecked(false); m_ui.addFilterButton_2->setChecked(false); m_ui.addFilterButton_3->setChecked(false); @@ -81,6 +85,10 @@ void ListZonesWidget::updateUi() m_ui.categoryTypeComboBox_2->clear(); m_ui.categoryTypeComboBox_3->clear(); m_ui.categoryTypeComboBox_4->clear(); + m_ui.categoryValueComboBox_1->clear(); + m_ui.categoryValueComboBox_2->clear(); + m_ui.categoryValueComboBox_3->clear(); + m_ui.categoryValueComboBox_4->clear(); m_ui.categoryTypeComboBox_1->addItems(listCategories); m_ui.categoryTypeComboBox_2->addItems(listCategories); @@ -88,11 +96,8 @@ void ListZonesWidget::updateUi() m_ui.categoryTypeComboBox_4->addItems(listCategories); disableSignals(false); -} -void ListZonesWidget::setModel(QAbstractItemModel *model) -{ - m_ui.listView->setModel(model); + m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase()); } void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder) @@ -201,7 +206,8 @@ void ListZonesWidget::updateListZones() QStringList listSelection; for (size_t i = 0; i < currentSelection.size(); ++i) listSelection << currentSelection[i]->getName().c_str(); - m_zoneBuilder->zoneModel()->setListZones(listSelection); + + m_listZonesModel->setListZones(listSelection); } void ListZonesWidget::disableSignals(bool block) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h index fed0134cf..049f0ebcb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -28,10 +28,11 @@ namespace LandscapeEditor { class ZoneBuilder; +class ListZonesModel; /** @class ZoneListWidget -@brief ZoneListWidget +@brief ZoneListWidget displays list available zones in accordance with the filter settings @details */ class ListZonesWidget: public QWidget @@ -44,21 +45,19 @@ public: void updateUi(); void setZoneBuilder(ZoneBuilder *zoneBuilder); - void setModel(QAbstractItemModel *model); Q_SIGNALS: -public Q_SLOTS: +private Q_SLOTS: void updateFilters_1(const QString &value); void updateFilters_2(const QString &value); void updateFilters_3(const QString &value); void updateFilters_4(const QString &value); - -private Q_SLOTS: void updateListZones(); private: void disableSignals(bool block); + ListZonesModel *m_listZonesModel; ZoneBuilder *m_zoneBuilder; Ui::ListZonesWidget m_ui; }; /* ZoneListWidget */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp new file mode 100644 index 000000000..bf095e6cf --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp @@ -0,0 +1,52 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "project_settings_dialog.h" +#include "landscape_editor_constants.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +// NeL includes +#include + +// Qt includes +#include +#include + +namespace LandscapeEditor +{ + +ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *parent) + : QDialog(parent) +{ + m_ui.setupUi(this); + m_ui.pathLineEdit->setText(dataPath); + setFixedHeight(sizeHint().height()); +} + +ProjectSettingsDialog::~ProjectSettingsDialog() +{ +} + +QString ProjectSettingsDialog::dataPath() const +{ + return m_ui.pathLineEdit->text(); +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h new file mode 100644 index 000000000..74443e3f1 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h @@ -0,0 +1,46 @@ +// 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 PROJECT_SETTINGS_DIALOG_H +#define PROJECT_SETTINGS_DIALOG_H + +// Project includes +#include "ui_project_settings_dialog.h" + +// Qt includes + +namespace LandscapeEditor +{ + +class ProjectSettingsDialog: public QDialog +{ + Q_OBJECT + +public: + ProjectSettingsDialog(const QString &dataPath, QWidget *parent = 0); + ~ProjectSettingsDialog(); + + QString dataPath() const; + +private: + + Ui::ProjectSettingsDialog m_ui; +}; /* class ProjectSettingsDialog */ + +} /* namespace LandscapeEditor */ + +#endif // PROJECT_SETTINGS_DIALOG_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui new file mode 100644 index 000000000..bb94fcc0d --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui @@ -0,0 +1,97 @@ + + + ProjectSettingsDialog + + + + 0 + 0 + 419 + 93 + + + + Project settings + + + + :/icons/ic_nel_landscape_settings.png:/icons/ic_nel_landscape_settings.png + + + + + + Data directory: + + + + + + + + + + ... + + + + + + + Context: + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + ProjectSettingsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ProjectSettingsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From 8903f6ca4b0ba73c9eccdd1c428edb5691164fc8 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 9 Jun 2011 02:11:50 +0300 Subject: [PATCH 004/747] Changed: #1301 Added select path button in project settings dialog. Main window landscape editor is saving own state. --- .../plugins/landscape_editor/CMakeLists.txt | 1 + .../plugins/landscape_editor/builder_zone.cpp | 1 + .../plugins/landscape_editor/builder_zone.h | 4 +- .../landscape_editor_constants.h | 2 + .../landscape_editor_window.cpp | 14 +++++ .../landscape_editor_window.h | 5 +- .../landscape_editor_window.ui | 17 +++++- .../landscape_editor/landscape_view.cpp | 52 +++++++++++++++++++ .../plugins/landscape_editor/landscape_view.h | 49 +++++++++++++++++ .../landscape_editor/list_zones_model.cpp | 16 +++--- .../landscape_editor/list_zones_widget.ui | 9 +++- .../project_settings_dialog.cpp | 9 ++++ .../project_settings_dialog.h | 3 ++ 13 files changed, 168 insertions(+), 14 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index 227210366..e189af74b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -15,6 +15,7 @@ SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h list_zones_model.h list_zones_widget.h landscape_actions.h + landscape_view.h project_settings_dialog.h ) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 3db771224..288a4b1be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -164,6 +164,7 @@ bool ZoneBuilder::initZoneBank (const QString &pathName) if (!m_zoneBank.addElement((pathName + file).toStdString(), error)) QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok); } + delete dir; return true; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index f69c2f7fb..f43bb7d7e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -67,8 +67,8 @@ private: /** @class ZoneBuilder -@brief ZoneBuilder contains all the shared data between the tools and the engine -@details ZoneBank contains the macro zones that is composed of several zones plus a mask +@brief ZoneBuilder contains all the shared data between the tools and the engine. +@details ZoneBank contains the macro zones that is composed of several zones plus a mask. PixmapDatabase contains the graphics for the zones */ class ZoneBuilder diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h index 52775f4c4..6875ddfab 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h @@ -26,6 +26,8 @@ const char * const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor"; //settings const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor"; +const char * const LANDSCAPE_WINDOW_STATE = "LandscapeWindowState"; +const char * const LANDSCAPE_WINDOW_GEOMETRY = "LandscapeWindowGeometry"; //resources const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png"; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 1b8716326..c17de1f43 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -18,6 +18,8 @@ // Project includes #include "landscape_editor_window.h" #include "landscape_editor_constants.h" +#include "builder_zone.h" +#include "landscape_scene.h" #include "project_settings_dialog.h" #include "../core/icore.h" @@ -30,6 +32,8 @@ // Qt includes #include #include +#include +#include namespace LandscapeEditor { @@ -45,6 +49,12 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); m_ui.zoneListWidget->updateUi(); + + m_landscapeScene = new LandscapeScene(this); + m_ui.graphicsView->setScene(m_landscapeScene); + m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers))); + + createMenus(); createToolBars(); readSettings(); @@ -113,6 +123,8 @@ void LandscapeEditorWindow::readSettings() { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); + restoreState(settings->value(Constants::LANDSCAPE_WINDOW_STATE).toByteArray()); + restoreGeometry(settings->value(Constants::LANDSCAPE_WINDOW_GEOMETRY).toByteArray()); settings->endGroup(); } @@ -120,6 +132,8 @@ void LandscapeEditorWindow::writeSettings() { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); + settings->setValue(Constants::LANDSCAPE_WINDOW_STATE, saveState()); + settings->setValue(Constants::LANDSCAPE_WINDOW_GEOMETRY, saveGeometry()); settings->endGroup(); settings->sync(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index 9b2ae0335..1fecd9f03 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -20,7 +20,6 @@ // Project includes #include "ui_landscape_editor_window.h" -#include "builder_zone.h" // Qt includes #include @@ -28,6 +27,9 @@ namespace LandscapeEditor { +class LandscapeScene; +class ZoneBuilder; + class LandscapeEditorWindow: public QMainWindow { Q_OBJECT @@ -51,6 +53,7 @@ private: void readSettings(); void writeSettings(); + LandscapeScene *m_landscapeScene; ZoneBuilder *m_zoneBuilder; QUndoStack *m_undoStack; Ui::LandscapeEditorWindow m_ui; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index 3877d9732..1361cd2bc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -19,8 +19,18 @@ + + 3 + + + 3 + - + + + QGraphicsView::NoDrag + + @@ -73,6 +83,11 @@
list_zones_widget.h
1
+ + LandscapeEditor::LandscapeView + QGraphicsView +
landscape_view.h
+
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp new file mode 100644 index 000000000..79b33599e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -0,0 +1,52 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "landscape_view.h" +#include "landscape_editor_constants.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +// NeL includes +#include + +// Qt includes + + +namespace LandscapeEditor +{ + +LandscapeView::LandscapeView(QWidget *parent) + : QGraphicsView(parent) +{ + setDragMode(ScrollHandDrag); +} + +LandscapeView::~LandscapeView() +{ +} + +void LandscapeView::wheelEvent(QWheelEvent *event) +{ + double numDegrees = event->delta() / 8.0; + double numSteps = numDegrees / 15.0; + double factor = std::pow(1.125, numSteps); + scale(factor, factor); +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h new file mode 100644 index 000000000..db79b79ff --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -0,0 +1,49 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef LANDSCAPE_VIEW_H +#define LANDSCAPE_VIEW_H + +// Project includes + +// Qt includes +#include +#include + +namespace LandscapeEditor +{ + +class LandscapeView: public QGraphicsView +{ + Q_OBJECT + +public: + LandscapeView(QWidget *parent = 0); + ~LandscapeView(); + +protected: + void wheelEvent(QWheelEvent *event); + +private Q_SLOTS: + +private: + +}; /* class LandscapeView */ + +} /* namespace LandscapeEditor */ + +#endif // LANDSCAPE_VIEW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp index 622fd8fb8..57e8683c0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp @@ -59,28 +59,26 @@ QVariant ListZonesModel::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); - if (role == Qt::TextAlignmentRole) + switch (role) { + case Qt::TextAlignmentRole: return int(Qt::AlignLeft | Qt::AlignVCenter); - } - else if (role == Qt::DisplayRole) - { + case Qt::DisplayRole: return m_listNames.at(index.row()); - } - else if (role == Qt::DecorationRole) + case Qt::DecorationRole: { QPixmap *pixmap = getPixmap(m_listNames.at(index.row())); return qVariantFromValue(*pixmap); } - return QVariant(); + default: + return QVariant(); + } } QVariant ListZonesModel::headerData(int section, Qt::Orientation /* orientation */, int role) const { - if (role != Qt::DisplayRole) - return QVariant(); return QVariant(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui index 585371cb7..289cb45dd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui @@ -290,7 +290,14 @@
- + + + false + + + QAbstractItemView::ScrollPerPixel + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp index bf095e6cf..3acd3ff66 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp @@ -28,6 +28,7 @@ // Qt includes #include #include +#include namespace LandscapeEditor { @@ -38,6 +39,7 @@ ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *p m_ui.setupUi(this); m_ui.pathLineEdit->setText(dataPath); setFixedHeight(sizeHint().height()); + connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath())); } ProjectSettingsDialog::~ProjectSettingsDialog() @@ -49,4 +51,11 @@ QString ProjectSettingsDialog::dataPath() const return m_ui.pathLineEdit->text(); } +void ProjectSettingsDialog::selectPath() +{ + QString dataPath = QFileDialog::getExistingDirectory(this, tr("Select data path"), m_ui.pathLineEdit->text()); + if (!dataPath.isEmpty()) + m_ui.pathLineEdit->setText(dataPath); +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h index 74443e3f1..abb93ab81 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h @@ -36,6 +36,9 @@ public: QString dataPath() const; +private Q_SLOTS: + void selectPath(); + private: Ui::ProjectSettingsDialog m_ui; From c3867d1699220f332d9a0550ecadcbf254f60ad6 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 14 Jun 2011 12:26:41 +0300 Subject: [PATCH 005/747] Changed: #1301 Experiments with undo\redo and QGraphicsScene. --- .../plugins/landscape_editor/builder_zone.h | 29 +++++++++++ .../landscape_editor/landscape_actions.cpp | 31 ++++++++++++ .../landscape_editor/landscape_actions.h | 22 ++++++++ .../landscape_editor_window.cpp | 6 +-- .../landscape_editor_window.ui | 8 +++ .../landscape_editor/landscape_scene.cpp | 50 ++++++++++++++++++- .../landscape_editor/landscape_scene.h | 19 ++++++- .../landscape_editor/landscape_view.cpp | 43 ++++++++++++---- .../plugins/landscape_editor/landscape_view.h | 6 ++- .../landscape_editor/list_zones_widget.cpp | 12 ++++- .../landscape_editor/list_zones_widget.h | 3 +- 11 files changed, 209 insertions(+), 20 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index f43bb7d7e..0ccbf4e23 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -36,6 +36,35 @@ namespace LandscapeEditor { +// Data +struct LigoData +{ + uint32 PosX; + uint32 PosY; + qreal Scale; + uint8 Rot; + uint8 Flip; + std::string ZoneName; + std::string SharingMatNames[4]; + uint8 SharingCutEdges[4]; + bool operator!= (const LigoData& other) const + { + return (PosX != other.PosX) || + (PosY != other.PosY) || + (Rot != other.Rot) || + (Flip != other.Flip) || + (ZoneName != other.ZoneName) || + (SharingMatNames[0] != other.SharingMatNames[0]) || + (SharingMatNames[1] != other.SharingMatNames[1]) || + (SharingMatNames[2] != other.SharingMatNames[2]) || + (SharingMatNames[3] != other.SharingMatNames[3]) || + (SharingCutEdges[0] != other.SharingCutEdges[0]) || + (SharingCutEdges[1] != other.SharingCutEdges[1]) || + (SharingCutEdges[2] != other.SharingCutEdges[2]) || + (SharingCutEdges[3] != other.SharingCutEdges[3]); + } +}; + /** @class PixmapDatabase @brief PixmapDatabase contains the image database diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp index f0b86dd8e..14cdb4f4b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp @@ -17,6 +17,7 @@ // Project includes #include "landscape_actions.h" +#include "builder_zone.h" // NeL includes #include @@ -25,4 +26,34 @@ namespace LandscapeEditor { + +ActionLigoTile::ActionLigoTile(const LigoData &data, ZoneBuilder *zoneBuilder, QGraphicsScene *scene, QUndoCommand *parent) + : QUndoCommand(parent), + m_item(0), + m_zoneBuilder(zoneBuilder), + m_scene(scene) +{ + m_ligoData = data; +} + +ActionLigoTile::~ActionLigoTile() +{ +} + +void ActionLigoTile::undo() +{ + m_scene->removeItem(m_item); + delete m_item; + m_item = 0; +} + +void ActionLigoTile::redo() +{ + QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(m_ligoData.ZoneName.c_str())); + m_item = new QGraphicsPixmapItem(*pixmap, 0, m_scene); + m_item->setPos(m_ligoData.PosX, m_ligoData.PosY); + m_item->setScale(m_ligoData.Scale); + setText(QObject::tr("Add tile(%1, %2)").arg(m_ligoData.PosX).arg(m_ligoData.PosY)); +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h index fdcda5451..76cb92762 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h @@ -19,13 +19,35 @@ #define LANDSCAPE_ACTIONS_H // Project includes +#include "builder_zone.h" // NeL includes // Qt includes +#include +#include +#include namespace LandscapeEditor { +class ZoneBuilder; + +class ActionLigoTile : public QUndoCommand +{ +public: + ActionLigoTile(const LigoData &data, ZoneBuilder *zoneBuilder, QGraphicsScene *scene, QUndoCommand *parent = 0); + ~ActionLigoTile(); + + virtual void undo(); + virtual void redo(); + +private: + + LigoData m_ligoData; + QGraphicsPixmapItem *m_item; + ZoneBuilder *m_zoneBuilder; + QGraphicsScene *m_scene; +}; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index c17de1f43..90c712e6c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -33,7 +33,6 @@ #include #include #include -#include namespace LandscapeEditor { @@ -50,10 +49,9 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); m_ui.zoneListWidget->updateUi(); - m_landscapeScene = new LandscapeScene(this); + m_landscapeScene = new LandscapeScene(m_undoStack, m_ui.zoneListWidget, m_zoneBuilder, this); m_ui.graphicsView->setScene(m_landscapeScene); - m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers))); - + //m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers))); createMenus(); createToolBars(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index 1361cd2bc..bb14576a2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -27,6 +27,14 @@ + + + 0.000000000000000 + 0.000000000000000 + 99999.000000000000000 + 99999.000000000000000 + + QGraphicsView::NoDrag diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index f491dfa2b..993b6ec9c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -17,22 +17,68 @@ // Project includes #include "landscape_scene.h" +#include "builder_zone.h" +#include "landscape_actions.h" +#include "list_zones_widget.h" // NeL includes #include // Qt includes +#include +#include namespace LandscapeEditor { -LandscapeScene::LandscapeScene(QObject *parent) - : QGraphicsScene(parent) +LandscapeScene::LandscapeScene(QUndoStack *undoStack, ListZonesWidget *listZonesWidget, ZoneBuilder *zoneBuilder, QObject *parent) + : QGraphicsScene(parent), + m_undoStack(undoStack), + m_listZonesWidget(listZonesWidget), + m_zoneBuilder(zoneBuilder) { + m_cellSize = 160; + createBackgroundPixmap(); } LandscapeScene::~LandscapeScene() { } +void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + if (mouseEvent->button() != Qt::LeftButton) + return; + + qreal x = mouseEvent->scenePos().rx(); + qreal y = mouseEvent->scenePos().ry(); + if ((x < 0) || (y < 0)) + return; + + LigoData ligoData = m_listZonesWidget->currentLigoData(); + if (ligoData.ZoneName == "") + return; + + ligoData.PosX = m_cellSize * int(x / m_cellSize);; + ligoData.PosY = m_cellSize * int(y / m_cellSize); + ligoData.Scale = m_cellSize / 256.0; + + ActionLigoTile *action = new ActionLigoTile(ligoData, m_zoneBuilder, this); + m_undoStack->push(action); + + QGraphicsScene::mousePressEvent(mouseEvent); +} + +void LandscapeScene::createBackgroundPixmap() +{ + QPixmap pixmap(QSize(m_cellSize, m_cellSize)); + QPainter painter(&pixmap); + //painter.setRenderHint(QPainter::Antialiasing, true); + painter.setBrush(QBrush(Qt::lightGray)); + painter.setPen(QPen(Qt::black, 3, Qt::DotLine)); + painter.drawRect(0, 0, pixmap.width(), pixmap.height()); + + setBackgroundBrush(pixmap); +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index d4fb91c78..b4a7a68de 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -23,18 +23,33 @@ // NeL includes // Qt includes -#include +#include +#include +#include namespace LandscapeEditor { +class ZoneBuilder; +class ListZonesWidget; class LandscapeScene : public QGraphicsScene { Q_OBJECT public: - LandscapeScene(QObject *parent = 0); + LandscapeScene(QUndoStack *undoStack, ListZonesWidget *listZonesWidget, ZoneBuilder *zoneBuilder, QObject *parent = 0); virtual ~LandscapeScene(); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); + +private: + void createBackgroundPixmap(); + + int m_cellSize; + ListZonesWidget *m_listZonesWidget; + QUndoStack *m_undoStack; + ZoneBuilder *m_zoneBuilder; }; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index 79b33599e..4bd202b7c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -26,27 +26,52 @@ #include // Qt includes - +#include namespace LandscapeEditor { LandscapeView::LandscapeView(QWidget *parent) - : QGraphicsView(parent) + : QGraphicsView(parent), + m_moveMouse(false) { - setDragMode(ScrollHandDrag); + setDragMode(ScrollHandDrag); + setTransformationAnchor(AnchorUnderMouse); } LandscapeView::~LandscapeView() { } -void LandscapeView::wheelEvent(QWheelEvent *event) -{ - double numDegrees = event->delta() / 8.0; - double numSteps = numDegrees / 15.0; - double factor = std::pow(1.125, numSteps); - scale(factor, factor); +void LandscapeView::wheelEvent(QWheelEvent *event) +{ + double numDegrees = event->delta() / 8.0; + double numSteps = numDegrees / 15.0; + double factor = std::pow(1.125, numSteps); + scale(factor, factor); +} + +void LandscapeView::mousePressEvent(QMouseEvent *event) +{ + QGraphicsView::mousePressEvent(event); + if (event->button() != Qt::MiddleButton) + return; + m_moveMouse = true; + QApplication::setOverrideCursor(Qt::ClosedHandCursor); +} + +void LandscapeView::mouseMoveEvent(QMouseEvent *event) +{ + if (m_moveMouse) + translate(0.001, 0.001); + QGraphicsView::mouseMoveEvent(event); +} + +void LandscapeView::mouseReleaseEvent(QMouseEvent *event) +{ + QApplication::restoreOverrideCursor(); + m_moveMouse = false; + QGraphicsView::mouseReleaseEvent(event); } } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h index db79b79ff..4ac090af6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -36,12 +36,16 @@ public: ~LandscapeView(); protected: - void wheelEvent(QWheelEvent *event); + virtual void wheelEvent(QWheelEvent *event); + virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseMoveEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); private Q_SLOTS: private: + bool m_moveMouse; }; /* class LandscapeView */ } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp index e4e3fae0d..56e362181 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp @@ -17,7 +17,6 @@ // Project includes #include "list_zones_widget.h" -#include "builder_zone.h" #include "list_zones_model.h" // NeL includes @@ -31,6 +30,7 @@ // Qt includes #include +#include namespace LandscapeEditor { @@ -100,6 +100,16 @@ void ListZonesWidget::updateUi() m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase()); } +LigoData ListZonesWidget::currentLigoData() const +{ + LigoData ligoData; + ligoData.ZoneName = ""; + QModelIndex index = m_ui.listView->currentIndex(); + if (index.isValid()) + ligoData.ZoneName = index.data().toString().toStdString(); + return ligoData; +} + void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder) { m_zoneBuilder = zoneBuilder; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h index 049f0ebcb..b1a6525fc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -20,6 +20,7 @@ // Project includes #include "ui_list_zones_widget.h" +#include "builder_zone.h" // NeL includes @@ -27,7 +28,6 @@ namespace LandscapeEditor { -class ZoneBuilder; class ListZonesModel; /** @@ -45,6 +45,7 @@ public: void updateUi(); void setZoneBuilder(ZoneBuilder *zoneBuilder); + LigoData currentLigoData() const; Q_SIGNALS: private Q_SLOTS: From c0c6700dd013074085fb42b28c727fe65b4066d8 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 16 Jun 2011 09:32:49 +0300 Subject: [PATCH 006/747] Changed: #1301 Added max\min scale view. Improved drawing of the grid. --- .../landscape_editor/landscape_actions.cpp | 44 +++++++++++-- .../landscape_editor/landscape_actions.h | 28 ++++++++- .../landscape_editor_window.cpp | 3 +- .../landscape_editor_window.ui | 18 ++++++ .../landscape_editor/landscape_scene.cpp | 15 +---- .../landscape_editor/landscape_scene.h | 3 +- .../landscape_editor/landscape_view.cpp | 61 +++++++++++++++++++ .../plugins/landscape_editor/landscape_view.h | 17 ++++-- 8 files changed, 161 insertions(+), 28 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp index 14cdb4f4b..5582de2d7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp @@ -27,7 +27,42 @@ namespace LandscapeEditor { -ActionLigoTile::ActionLigoTile(const LigoData &data, ZoneBuilder *zoneBuilder, QGraphicsScene *scene, QUndoCommand *parent) +OpenLandscapeCommand::OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent) + : QUndoCommand(parent), + m_fileName(fileName) +{ +} + +OpenLandscapeCommand::~OpenLandscapeCommand() +{ +} + +void OpenLandscapeCommand::undo() +{ +} + +void OpenLandscapeCommand::redo() +{ +} + +NewLandscapeCommand::NewLandscapeCommand(QUndoCommand *parent) + : QUndoCommand(parent) +{ +} + +NewLandscapeCommand::~NewLandscapeCommand() +{ +} + +void NewLandscapeCommand::undo() +{ +} + +void NewLandscapeCommand::redo() +{ +} + +LigoTileCommand::LigoTileCommand(const LigoData &data, ZoneBuilder *zoneBuilder, QGraphicsScene *scene, QUndoCommand *parent) : QUndoCommand(parent), m_item(0), m_zoneBuilder(zoneBuilder), @@ -36,23 +71,24 @@ ActionLigoTile::ActionLigoTile(const LigoData &data, ZoneBuilder *zoneBuilder, Q m_ligoData = data; } -ActionLigoTile::~ActionLigoTile() +LigoTileCommand::~LigoTileCommand() { } -void ActionLigoTile::undo() +void LigoTileCommand::undo() { m_scene->removeItem(m_item); delete m_item; m_item = 0; } -void ActionLigoTile::redo() +void LigoTileCommand::redo() { QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(m_ligoData.ZoneName.c_str())); m_item = new QGraphicsPixmapItem(*pixmap, 0, m_scene); m_item->setPos(m_ligoData.PosX, m_ligoData.PosY); m_item->setScale(m_ligoData.Scale); + m_item->setTransformationMode(Qt::SmoothTransformation); setText(QObject::tr("Add tile(%1, %2)").arg(m_ligoData.PosX).arg(m_ligoData.PosY)); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h index 76cb92762..ff9c9dde0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h @@ -32,11 +32,33 @@ namespace LandscapeEditor { class ZoneBuilder; -class ActionLigoTile : public QUndoCommand +class OpenLandscapeCommand: public QUndoCommand { public: - ActionLigoTile(const LigoData &data, ZoneBuilder *zoneBuilder, QGraphicsScene *scene, QUndoCommand *parent = 0); - ~ActionLigoTile(); + OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent = 0); + ~OpenLandscapeCommand(); + virtual void undo(); + virtual void redo(); +private: + + QString m_fileName; +}; + +class NewLandscapeCommand: public QUndoCommand +{ +public: + NewLandscapeCommand(QUndoCommand *parent = 0); + ~NewLandscapeCommand(); + virtual void undo(); + virtual void redo(); +private: +}; + +class LigoTileCommand: public QUndoCommand +{ +public: + LigoTileCommand(const LigoData &data, ZoneBuilder *zoneBuilder, QGraphicsScene *scene, QUndoCommand *parent = 0); + ~LigoTileCommand(); virtual void undo(); virtual void redo(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 90c712e6c..59a4553b9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -51,13 +51,14 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_landscapeScene = new LandscapeScene(m_undoStack, m_ui.zoneListWidget, m_zoneBuilder, this); m_ui.graphicsView->setScene(m_landscapeScene); - //m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers))); + m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers))); createMenus(); createToolBars(); readSettings(); connect(m_ui.projectSettingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings())); + connect(m_ui.enableGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool))); } LandscapeEditorWindow::~LandscapeEditorWindow() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index bb14576a2..ff3121d04 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -73,6 +73,7 @@ false + @@ -83,6 +84,23 @@ Project settings + + + true + + + true + + + EnableGrid + + + Show/Hide Grid + + + Ctrl+G + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 993b6ec9c..3b1ddd9fb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -38,7 +38,6 @@ LandscapeScene::LandscapeScene(QUndoStack *undoStack, ListZonesWidget *listZones m_zoneBuilder(zoneBuilder) { m_cellSize = 160; - createBackgroundPixmap(); } LandscapeScene::~LandscapeScene() @@ -63,22 +62,10 @@ void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) ligoData.PosY = m_cellSize * int(y / m_cellSize); ligoData.Scale = m_cellSize / 256.0; - ActionLigoTile *action = new ActionLigoTile(ligoData, m_zoneBuilder, this); + LigoTileCommand *action = new LigoTileCommand(ligoData, m_zoneBuilder, this); m_undoStack->push(action); QGraphicsScene::mousePressEvent(mouseEvent); } -void LandscapeScene::createBackgroundPixmap() -{ - QPixmap pixmap(QSize(m_cellSize, m_cellSize)); - QPainter painter(&pixmap); - //painter.setRenderHint(QPainter::Antialiasing, true); - painter.setBrush(QBrush(Qt::lightGray)); - painter.setPen(QPen(Qt::black, 3, Qt::DotLine)); - painter.drawRect(0, 0, pixmap.width(), pixmap.height()); - - setBackgroundBrush(pixmap); -} - } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index b4a7a68de..80417d4ff 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -41,10 +41,9 @@ public: virtual ~LandscapeScene(); protected: - void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); private: - void createBackgroundPixmap(); int m_cellSize; ListZonesWidget *m_listZonesWidget; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index 4bd202b7c..26dd386ed 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -33,21 +33,55 @@ namespace LandscapeEditor LandscapeView::LandscapeView(QWidget *parent) : QGraphicsView(parent), + m_visibleGrid(true), m_moveMouse(false) { setDragMode(ScrollHandDrag); setTransformationAnchor(AnchorUnderMouse); + setBackgroundBrush(QBrush(Qt::lightGray)); + //setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + //setRenderHints(QPainter::Antialiasing); + m_cellSize = 160; + m_numSteps = 0; + m_maxSteps = 20; } LandscapeView::~LandscapeView() { } +bool LandscapeView::isVisibleGrid() const +{ + return m_visibleGrid; +} + +void LandscapeView::setVisibleGrid(bool visible) +{ + m_visibleGrid = visible; + + // hack for repaint view + translate(0.0001, 0.0001); +} + void LandscapeView::wheelEvent(QWheelEvent *event) { double numDegrees = event->delta() / 8.0; double numSteps = numDegrees / 15.0; double factor = std::pow(1.125, numSteps); + if (factor > 1.0) + { + // check max scale view + if (m_numSteps > m_maxSteps) + return; + ++m_numSteps; + } + else + { + // check min scale view + if (m_numSteps < -m_maxSteps) + return; + --m_numSteps; + } scale(factor, factor); } @@ -74,4 +108,31 @@ void LandscapeView::mouseReleaseEvent(QMouseEvent *event) QGraphicsView::mouseReleaseEvent(event); } +void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect) +{ + if (!m_visibleGrid) + return; + + qreal scaleFactor = transform().m11(); + painter->setPen(QPen(Qt::white, 1 / scaleFactor, Qt::SolidLine)); + + // draw grid + qreal left = m_cellSize * int(rect.left() / m_cellSize); + qreal top = m_cellSize * int(rect.top() / m_cellSize); + + // draw vertical lines + while (left < rect.right()) + { + painter->drawLine(int(left), int(rect.bottom()), int(left), int(rect.top())); + left += m_cellSize; + } + + // draw horizontal lines + while (top < rect.bottom()) + { + painter->drawLine(int(rect.left()), int(top), int(rect.right()), int(top)); + top += m_cellSize; + } +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h index 4ac090af6..2ae251fee 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -19,6 +19,7 @@ #define LANDSCAPE_VIEW_H // Project includes +#include "landscape_editor_global.h" // Qt includes #include @@ -27,24 +28,32 @@ namespace LandscapeEditor { -class LandscapeView: public QGraphicsView +class LANDSCAPE_EDITOR_EXPORT LandscapeView: public QGraphicsView { Q_OBJECT public: LandscapeView(QWidget *parent = 0); - ~LandscapeView(); + virtual ~LandscapeView(); + bool isVisibleGrid() const; + +public Q_SLOTS: + void setVisibleGrid(bool visible); + +private Q_SLOTS: protected: virtual void wheelEvent(QWheelEvent *event); virtual void mousePressEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); - -private Q_SLOTS: + virtual void drawForeground(QPainter *painter, const QRectF &rect); private: + bool m_visibleGrid; + int m_numSteps, m_maxSteps; + int m_cellSize; bool m_moveMouse; }; /* class LandscapeView */ From 4306ab94b5e869002161c0a89ac6c37c56e41232 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 21 Jun 2011 10:14:46 +0300 Subject: [PATCH 007/747] Changed: #1301 Added load landscape from file. Added initial snapshot dialog. --- .../plugins/landscape_editor/CMakeLists.txt | 2 + .../plugins/landscape_editor/builder_zone.h | 29 --- .../landscape_editor/landscape_actions.cpp | 40 +++- .../landscape_editor/landscape_actions.h | 37 +++- .../landscape_editor_window.cpp | 29 +++ .../landscape_editor_window.h | 4 + .../landscape_editor_window.ui | 6 + .../landscape_editor/landscape_scene.cpp | 164 +++++++++++++- .../landscape_editor/landscape_scene.h | 39 ++++ .../landscape_editor/landscape_view.cpp | 6 +- .../landscape_editor/list_zones_widget.cpp | 3 + .../landscape_editor/list_zones_widget.h | 1 + .../landscape_editor/list_zones_widget.ui | 10 +- .../project_settings_dialog.ui | 14 +- .../landscape_editor/shapshot_dialog.ui | 208 ++++++++++++++++++ .../landscape_editor/snapshot_dialog.cpp | 45 ++++ .../landscape_editor/snapshot_dialog.h | 47 ++++ .../landscape_editor/zone_region_editor.cpp | 119 ++++++++++ .../landscape_editor/zone_region_editor.h | 62 ++++++ 19 files changed, 793 insertions(+), 72 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index e189af74b..8c4278c46 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -17,11 +17,13 @@ SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h landscape_actions.h landscape_view.h project_settings_dialog.h + snapshot_dialog.h ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui list_zones_widget.ui project_settings_dialog.ui + shapshot_dialog.ui ) SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index 0ccbf4e23..f43bb7d7e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -36,35 +36,6 @@ namespace LandscapeEditor { -// Data -struct LigoData -{ - uint32 PosX; - uint32 PosY; - qreal Scale; - uint8 Rot; - uint8 Flip; - std::string ZoneName; - std::string SharingMatNames[4]; - uint8 SharingCutEdges[4]; - bool operator!= (const LigoData& other) const - { - return (PosX != other.PosX) || - (PosY != other.PosY) || - (Rot != other.Rot) || - (Flip != other.Flip) || - (ZoneName != other.ZoneName) || - (SharingMatNames[0] != other.SharingMatNames[0]) || - (SharingMatNames[1] != other.SharingMatNames[1]) || - (SharingMatNames[2] != other.SharingMatNames[2]) || - (SharingMatNames[3] != other.SharingMatNames[3]) || - (SharingCutEdges[0] != other.SharingCutEdges[0]) || - (SharingCutEdges[1] != other.SharingCutEdges[1]) || - (SharingCutEdges[2] != other.SharingCutEdges[2]) || - (SharingCutEdges[3] != other.SharingCutEdges[3]); - } -}; - /** @class PixmapDatabase @brief PixmapDatabase contains the image database diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp index 5582de2d7..84d59ba8d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp @@ -62,34 +62,54 @@ void NewLandscapeCommand::redo() { } -LigoTileCommand::LigoTileCommand(const LigoData &data, ZoneBuilder *zoneBuilder, QGraphicsScene *scene, QUndoCommand *parent) +AddLigoTileCommand::AddLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent) : QUndoCommand(parent), m_item(0), - m_zoneBuilder(zoneBuilder), m_scene(scene) { m_ligoData = data; } -LigoTileCommand::~LigoTileCommand() +AddLigoTileCommand::~AddLigoTileCommand() { } -void LigoTileCommand::undo() +void AddLigoTileCommand::undo() { m_scene->removeItem(m_item); delete m_item; m_item = 0; } -void LigoTileCommand::redo() +void AddLigoTileCommand::redo() { - QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(m_ligoData.ZoneName.c_str())); - m_item = new QGraphicsPixmapItem(*pixmap, 0, m_scene); - m_item->setPos(m_ligoData.PosX, m_ligoData.PosY); - m_item->setScale(m_ligoData.Scale); - m_item->setTransformationMode(Qt::SmoothTransformation); + m_item = m_scene->createZoneItem(m_ligoData); setText(QObject::tr("Add tile(%1, %2)").arg(m_ligoData.PosX).arg(m_ligoData.PosY)); } +DelLigoTileCommand::DelLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent) + : QUndoCommand(parent), + m_item(0), + m_scene(scene) +{ + m_ligoData = data; +} + +DelLigoTileCommand::~DelLigoTileCommand() +{ +} + +void DelLigoTileCommand::undo() +{ + m_item = m_scene->createZoneItem(m_ligoData); +} + +void DelLigoTileCommand::redo() +{ + m_item = m_scene->itemAt(m_ligoData.PosX * m_scene->cellSize(), m_ligoData.PosY * m_scene->cellSize()); + delete m_item; + m_item = 0; + setText(QObject::tr("Del tile(%1, %2)").arg(m_ligoData.PosX).arg(m_ligoData.PosY)); +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h index ff9c9dde0..7bbd1bd96 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h @@ -20,23 +20,24 @@ // Project includes #include "builder_zone.h" +#include "landscape_scene.h" // NeL includes // Qt includes #include #include -#include +#include namespace LandscapeEditor { -class ZoneBuilder; class OpenLandscapeCommand: public QUndoCommand { public: OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent = 0); - ~OpenLandscapeCommand(); + virtual ~OpenLandscapeCommand(); + virtual void undo(); virtual void redo(); private: @@ -48,17 +49,18 @@ class NewLandscapeCommand: public QUndoCommand { public: NewLandscapeCommand(QUndoCommand *parent = 0); - ~NewLandscapeCommand(); + virtual ~NewLandscapeCommand(); + virtual void undo(); virtual void redo(); private: }; -class LigoTileCommand: public QUndoCommand +class AddLigoTileCommand: public QUndoCommand { public: - LigoTileCommand(const LigoData &data, ZoneBuilder *zoneBuilder, QGraphicsScene *scene, QUndoCommand *parent = 0); - ~LigoTileCommand(); + AddLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent = 0); + virtual ~AddLigoTileCommand(); virtual void undo(); virtual void redo(); @@ -66,9 +68,24 @@ public: private: LigoData m_ligoData; - QGraphicsPixmapItem *m_item; - ZoneBuilder *m_zoneBuilder; - QGraphicsScene *m_scene; + QGraphicsItem *m_item; + LandscapeScene *m_scene; +}; + +class DelLigoTileCommand: public QUndoCommand +{ +public: + DelLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent = 0); + virtual ~DelLigoTileCommand(); + + virtual void undo(); + virtual void redo(); + +private: + + LigoData m_ligoData; + QGraphicsItem *m_item; + LandscapeScene *m_scene; }; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 59a4553b9..5ec3f6196 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -21,6 +21,7 @@ #include "builder_zone.h" #include "landscape_scene.h" #include "project_settings_dialog.h" +#include "snapshot_dialog.h" #include "../core/icore.h" #include "../core/imenu_manager.h" @@ -51,6 +52,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_landscapeScene = new LandscapeScene(m_undoStack, m_ui.zoneListWidget, m_zoneBuilder, this); m_ui.graphicsView->setScene(m_landscapeScene); + //m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer))); m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers))); createMenus(); @@ -58,6 +60,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) readSettings(); connect(m_ui.projectSettingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings())); + connect(m_ui.snapshotAction, SIGNAL(triggered()), this, SLOT(openSnapshotDialog())); connect(m_ui.enableGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool))); } @@ -83,6 +86,14 @@ void LandscapeEditorWindow::open() { QStringList list = fileNames; _lastDir = QFileInfo(list.front()).absolutePath(); + Q_FOREACH(QString fileName, fileNames) + { + m_zoneRegionEditor.load(fileName.toStdString()); + m_landscapeScene->processZoneRegion(m_zoneRegionEditor.zoneRegion()); + m_landscapeScene->setCurrentZoneRegion(&m_zoneRegionEditor.zoneRegion()); + m_ui.graphicsView->centerOn(m_zoneRegionEditor.zoneRegion().getMinX() * m_landscapeScene->cellSize(), + abs(m_zoneRegionEditor.zoneRegion().getMinY()) * m_landscapeScene->cellSize()); + } } setCursor(Qt::ArrowCursor); } @@ -100,6 +111,24 @@ void LandscapeEditorWindow::openProjectSettings() delete dialog; } +void LandscapeEditorWindow::openSnapshotDialog() +{ + SnapshotDialog *dialog = new SnapshotDialog(this); + dialog->show(); + int ok = dialog->exec(); + if (ok == QDialog::Accepted) + { + QString fileName = QFileDialog::getSaveFileName(this, + tr("Save screenshot landscape"), _lastDir, + tr("Image file (*.png)")); + + setCursor(Qt::WaitCursor); + m_landscapeScene->snapshot(fileName, 128); + setCursor(Qt::ArrowCursor); + } + delete dialog; +} + void LandscapeEditorWindow::createMenus() { Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index 1fecd9f03..311a65013 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -20,6 +20,7 @@ // Project includes #include "ui_landscape_editor_window.h" +#include "zone_region_editor.h" // Qt includes #include @@ -46,6 +47,7 @@ public Q_SLOTS: private Q_SLOTS: void openProjectSettings(); + void openSnapshotDialog(); private: void createMenus(); @@ -53,6 +55,8 @@ private: void readSettings(); void writeSettings(); + ZoneRegionEditor m_zoneRegionEditor; + LandscapeScene *m_landscapeScene; ZoneBuilder *m_zoneBuilder; QUndoStack *m_undoStack; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index ff3121d04..212d0eb13 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -72,6 +72,7 @@ false + @@ -101,6 +102,11 @@ Ctrl+G + + + snapshot + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 3b1ddd9fb..96ad0879b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -27,6 +27,7 @@ // Qt includes #include #include +#include namespace LandscapeEditor { @@ -35,7 +36,8 @@ LandscapeScene::LandscapeScene(QUndoStack *undoStack, ListZonesWidget *listZones : QGraphicsScene(parent), m_undoStack(undoStack), m_listZonesWidget(listZonesWidget), - m_zoneBuilder(zoneBuilder) + m_zoneBuilder(zoneBuilder), + m_zoneRegion(0) { m_cellSize = 160; } @@ -44,27 +46,167 @@ LandscapeScene::~LandscapeScene() { } -void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) +int LandscapeScene::cellSize() const { - if (mouseEvent->button() != Qt::LeftButton) + return m_cellSize; +} + +QGraphicsItem *LandscapeScene::createZoneItem(const LigoData &data) +{ + // Get image from pixmap database + QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.ZoneName.c_str())); + if (pixmap == 0) + return 0; + + // Rotate the image counterclockwise + QMatrix matrix; + matrix.rotate(-data.Rot * 90.0); + + QGraphicsPixmapItem *item; + + if (data.Flip == 0) + { + item = new QGraphicsPixmapItem(pixmap->transformed(matrix, Qt::SmoothTransformation), 0, this); + } + else + { + // mirror image + QImage mirrorImage = pixmap->toImage(); + QPixmap mirrorPixmap = QPixmap::fromImage(mirrorImage.mirrored(true, false)); + item = new QGraphicsPixmapItem(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation), 0, this); + } + // Enable bilinear filtering + item->setTransformationMode(Qt::SmoothTransformation); + + // Set position graphics item with offset for large piece + NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.ZoneName); + item->setPos(data.PosX * m_cellSize, (abs(data.PosY) - zoneBankItem->getSizeY() + 1) * m_cellSize); + + // The size graphics item should be equal or proportional m_cellSize + item->setScale(m_cellSize / 256.0); + + // add debug info + QGraphicsSimpleTextItem *itemText = addSimpleText(QString("%1,%2 R-%3 F-%4"). + arg(data.PosX).arg(data.PosY). + arg(data.Rot * 90.0). + arg(data.Flip), + QFont("Helvetica [Cronyx]", 14)); + + itemText->setZValue(2); + itemText->setPos(data.PosX * m_cellSize + 10, (abs(data.PosY) - zoneBankItem->getSizeY() + 1) * m_cellSize + 10); + itemText->setBrush(QBrush(Qt::white)); + + return item; +} + +void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) +{ + for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) + { + for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) + { + std::string zoneName = zoneRegion.getName(i, j); + if ((!zoneName.empty()) && + (zoneName != STRING_UNUSED) && + (zoneRegion.getPosX(i, j) == 0) && + (zoneRegion.getPosY(i, j) == 0)) + { + LigoData data; + data.PosX = i; + data.PosY = j; + data.ZoneName = zoneName; + data.Rot = zoneRegion.getRot(i, j); + data.Flip = zoneRegion.getFlip(i, j); + QGraphicsItem *item = createZoneItem(data); + } + } + } +} + +void LandscapeScene::setCurrentZoneRegion(NLLIGO::CZoneRegion *zoneRegion) +{ + m_zoneRegion = zoneRegion; +} + +void LandscapeScene::snapshot(const QString &fileName, int sizeSource) +{ + if (m_zoneRegion == 0) return; + sint32 regionMinX = m_zoneRegion->getMinX(); + sint32 regionMaxX = m_zoneRegion->getMaxX(); + sint32 regionMinY = m_zoneRegion->getMinY(); + sint32 regionMaxY = m_zoneRegion->getMaxY(); + + int regionWidth = (regionMaxX - regionMinX + 1); + int regionHeight = (regionMaxY - regionMinY + 1); + + snapshot(fileName, regionWidth * sizeSource, regionHeight * sizeSource); +} + +void LandscapeScene::snapshot(const QString &fileName, int width, int height) +{ + if (m_zoneRegion == 0) + return; + + sint32 regionMinX = m_zoneRegion->getMinX(); + sint32 regionMaxX = m_zoneRegion->getMaxX(); + sint32 regionMinY = m_zoneRegion->getMinY(); + sint32 regionMaxY = m_zoneRegion->getMaxY(); + + int regionWidth = (regionMaxX - regionMinX + 1); + int regionHeight = (regionMaxY - regionMinY + 1); + + QImage image(width, height, QImage::Format_RGB888); + QPainter painter(&image); + painter.setRenderHint(QPainter::Antialiasing, true); + + // add white background + painter.setBrush(QBrush(Qt::white)); + painter.setPen(Qt::NoPen); + painter.drawRect(0, 0, width, height); + + render(&painter, QRectF(0, 0, width, height), + QRectF(regionMinX * m_cellSize, abs(regionMaxY) * m_cellSize, regionWidth * m_cellSize, regionHeight * m_cellSize)); + + image.save(fileName); + +} + +void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ qreal x = mouseEvent->scenePos().rx(); qreal y = mouseEvent->scenePos().ry(); if ((x < 0) || (y < 0)) return; - LigoData ligoData = m_listZonesWidget->currentLigoData(); - if (ligoData.ZoneName == "") - return; + if (mouseEvent->button() == Qt::LeftButton) + { + // Add new zone brick + LigoData ligoData = m_listZonesWidget->currentLigoData(); + if (ligoData.ZoneName == "") + return; - ligoData.PosX = m_cellSize * int(x / m_cellSize);; - ligoData.PosY = m_cellSize * int(y / m_cellSize); - ligoData.Scale = m_cellSize / 256.0; + ligoData.PosX = int(floor(x / m_cellSize)); + ligoData.PosY = int(-floor(y / m_cellSize)); - LigoTileCommand *action = new LigoTileCommand(ligoData, m_zoneBuilder, this); - m_undoStack->push(action); + AddLigoTileCommand *action = new AddLigoTileCommand(ligoData, this); + m_undoStack->push(action); + } + /*if (mouseEvent->button() == Qt::RightButton) + { + // Delete zone brick + LigoData ligoData; + + ligoData.PosX = int(floor(x / m_cellSize)); + ligoData.PosY = int(floor(y / m_cellSize)); + ligoData.ZoneName = m_zoneRegion->getName(ligoData.PosX, -ligoData.PosY); + ligoData.Flip = m_zoneRegion->getFlip(ligoData.PosX, -ligoData.PosY); + ligoData.Rot = m_zoneRegion->getRot(ligoData.PosX, -ligoData.PosY); + DelLigoTileCommand *action = new DelLigoTileCommand(ligoData, this); + m_undoStack->push(action); + }*/ QGraphicsScene::mousePressEvent(mouseEvent); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index 80417d4ff..2af45bf4b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -21,6 +21,7 @@ // Project includes // NeL includes +#include // Qt includes #include @@ -32,6 +33,34 @@ namespace LandscapeEditor class ZoneBuilder; class ListZonesWidget; +// Data +struct LigoData +{ + sint32 PosX; + sint32 PosY; + uint8 Rot; + uint8 Flip; + std::string ZoneName; + std::string SharingMatNames[4]; + uint8 SharingCutEdges[4]; + bool operator!= (const LigoData& other) const + { + return (PosX != other.PosX) || + (PosY != other.PosY) || + (Rot != other.Rot) || + (Flip != other.Flip) || + (ZoneName != other.ZoneName) || + (SharingMatNames[0] != other.SharingMatNames[0]) || + (SharingMatNames[1] != other.SharingMatNames[1]) || + (SharingMatNames[2] != other.SharingMatNames[2]) || + (SharingMatNames[3] != other.SharingMatNames[3]) || + (SharingCutEdges[0] != other.SharingCutEdges[0]) || + (SharingCutEdges[1] != other.SharingCutEdges[1]) || + (SharingCutEdges[2] != other.SharingCutEdges[2]) || + (SharingCutEdges[3] != other.SharingCutEdges[3]); + } +}; + class LandscapeScene : public QGraphicsScene { Q_OBJECT @@ -40,6 +69,15 @@ public: LandscapeScene(QUndoStack *undoStack, ListZonesWidget *listZonesWidget, ZoneBuilder *zoneBuilder, QObject *parent = 0); virtual ~LandscapeScene(); + int cellSize() const; + + QGraphicsItem *createZoneItem(const LigoData &data); + void processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); + void setCurrentZoneRegion(NLLIGO::CZoneRegion *zoneRegion); + + void snapshot(const QString &fileName, int sizeSource); + void snapshot(const QString &fileName, int width, int height); + protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); @@ -49,6 +87,7 @@ private: ListZonesWidget *m_listZonesWidget; QUndoStack *m_undoStack; ZoneBuilder *m_zoneBuilder; + NLLIGO::CZoneRegion *m_zoneRegion; }; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index 26dd386ed..610028762 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -114,11 +114,11 @@ void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect) return; qreal scaleFactor = transform().m11(); - painter->setPen(QPen(Qt::white, 1 / scaleFactor, Qt::SolidLine)); + painter->setPen(QPen(Qt::white, 0, Qt::SolidLine)); // draw grid - qreal left = m_cellSize * int(rect.left() / m_cellSize); - qreal top = m_cellSize * int(rect.top() / m_cellSize); + qreal left = m_cellSize * floor(rect.left() / m_cellSize); + qreal top = m_cellSize * floor(rect.top() / m_cellSize); // draw vertical lines while (left < rect.right()) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp index 56e362181..66d31479b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp @@ -107,6 +107,9 @@ LigoData ListZonesWidget::currentLigoData() const QModelIndex index = m_ui.listView->currentIndex(); if (index.isValid()) ligoData.ZoneName = index.data().toString().toStdString(); + + ligoData.Rot = m_ui.rotComboBox->currentIndex(); + ligoData.Flip = m_ui.flipComboBox->currentIndex(); return ligoData; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h index b1a6525fc..8ad5d4c25 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -21,6 +21,7 @@ // Project includes #include "ui_list_zones_widget.h" #include "builder_zone.h" +#include "landscape_scene.h" // NeL includes diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui index 289cb45dd..4d9f63129 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui @@ -215,7 +215,7 @@ 3 - + @@ -233,7 +233,7 @@ - 170° + 270° @@ -249,7 +249,7 @@ - + NoFlip @@ -273,14 +273,14 @@ - + Force - + Not propogate diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui index bb94fcc0d..8be20c9aa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui @@ -23,6 +23,9 @@ Data directory: + + pathLineEdit + @@ -40,6 +43,9 @@ Context: + + contextComboBox + @@ -68,8 +74,8 @@ accept() - 248 - 254 + 257 + 83 157 @@ -84,8 +90,8 @@ reject() - 316 - 260 + 325 + 83 286 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui new file mode 100644 index 000000000..792d9f7a4 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui @@ -0,0 +1,208 @@ + + + SnapshotDialog + + + + 0 + 0 + 286 + 182 + + + + Snapshot + + + + + + Original size + + + true + + + + + + + false + + + Custom size + + + + + + + false + + + + + + + + + 99999 + + + 512 + + + + + + + false + + + TextLabel + + + heightSpinBox + + + + + + + false + + + 99999 + + + 512 + + + + + + + TextLabel + + + widthSpinBox + + + + + + + Keep bitmap ratio + + + true + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + originalSizeRadioButton + customSizeRadioButton + widthSpinBox + heightSpinBox + keepRatioCheckBox + buttonBox + + + + + buttonBox + accepted() + SnapshotDialog + accept() + + + 227 + 164 + + + 157 + 158 + + + + + buttonBox + rejected() + SnapshotDialog + reject() + + + 276 + 170 + + + 285 + 158 + + + + + customSizeRadioButton + toggled(bool) + groupBox + setEnabled(bool) + + + 59 + 39 + + + 78 + 62 + + + + + keepRatioCheckBox + toggled(bool) + heightSpinBox + setDisabled(bool) + + + 84 + 122 + + + 178 + 106 + + + + + keepRatioCheckBox + toggled(bool) + label_2 + setDisabled(bool) + + + 55 + 129 + + + 48 + 103 + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp new file mode 100644 index 000000000..ff6ef1673 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp @@ -0,0 +1,45 @@ +// 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 "snapshot_dialog.h" +#include "landscape_editor_constants.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +// NeL includes +#include + +// Qt includes +#include +#include + +namespace LandscapeEditor +{ + +SnapshotDialog::SnapshotDialog(QWidget *parent) + : QDialog(parent) +{ + m_ui.setupUi(this); +} + +SnapshotDialog::~SnapshotDialog() +{ +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h new file mode 100644 index 000000000..906d59498 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h @@ -0,0 +1,47 @@ +// 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 SNAPSHOT_DIALOG_H +#define SNAPSHOT_DIALOG_H + +// Project includes +#include "ui_shapshot_dialog.h" + +// Qt includes + +namespace LandscapeEditor +{ + +class SnapshotDialog: public QDialog +{ + Q_OBJECT + +public: + SnapshotDialog(QWidget *parent = 0); + ~SnapshotDialog(); + +private Q_SLOTS: + + +private: + + Ui::SnapshotDialog m_ui; +}; /* class SnapshotDialog */ + +} /* namespace LandscapeEditor */ + +#endif // SNAPSHOT_DIALOG_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp new file mode 100644 index 000000000..a3f109ada --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp @@ -0,0 +1,119 @@ +// 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 "zone_region_editor.h" + +// NeL includes +#include +#include +#include +#include + +// Qt includes +#include + +namespace LandscapeEditor +{ + +ZoneRegionEditor::ZoneRegionEditor() +{ + m_fileName = ""; +} + +ZoneRegionEditor::~ZoneRegionEditor() +{ +} + +bool ZoneRegionEditor::load(const std::string &fileName) +{ + bool result = true; + try + { + // Open it + NLMISC::CIFile fileIn; + if (fileIn.open(fileName)) + { + NLMISC::CIXml xml(true); + xml.init(fileIn); + m_zoneRegion.serial(xml); + } + else + { + nlwarning("Can't open file %s for reading", fileName.c_str()); + result = false; + } + } + catch (NLMISC::Exception& e) + { + nlwarning("Error reading file %s : %s", fileName.c_str(), e.what ()); + result = false; + } + if (result) + m_fileName = fileName; + return result; +} + +bool ZoneRegionEditor::save() +{ + if (m_fileName.empty()) + return false; + + bool result = true; + // Save the landscape + try + { + + // Open file for writing + NLMISC::COFile fileOut; + if (fileOut.open(m_fileName, false, false, true)) + { + // Be careful with the flushing of the COXml object + { + NLMISC::COXml xmlOut; + xmlOut.init(&fileOut); + m_zoneRegion.serial(xmlOut); + // Done + m_modified = false; + } + fileOut.close(); + } + else + { + nlwarning("Can't open file %s for writing.", m_fileName.c_str()); + result = false; + } + } + catch (NLMISC::Exception& e) + { + nlwarning("Error writing file %s : %s", m_fileName.c_str(), e.what()); + result = false; + } + return result; +} + +void ZoneRegionEditor::setFileName(const std::string &fileName) +{ + m_fileName = fileName; +} + +NLLIGO::CZoneRegion &ZoneRegionEditor::zoneRegion() +{ + return m_zoneRegion; +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h new file mode 100644 index 000000000..fd53d5483 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h @@ -0,0 +1,62 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef LANDSCAPE_EDITOR_H +#define LANDSCAPE_EDITOR_H + +// Project includes + +// NeL includes +#include +#include + +// STL includes +#include + +// Qt includes + +namespace LandscapeEditor +{ + +class ZoneRegionEditor +{ +public: + ZoneRegionEditor(); + ~ZoneRegionEditor(); + + // Load landscape data from file + bool load(const std::string &fileName); + + // Save landscape data to file + bool save(); + + // Set file name + void setFileName(const std::string &fileName); + + NLLIGO::CZoneRegion &zoneRegion(); + +private: + + bool m_modified; + bool m_editable; + std::string m_fileName; + NLLIGO::CZoneRegion m_zoneRegion; +}; + +} /* namespace LandscapeEditor */ + +#endif // LANDSCAPE_EDITOR_H From 5951c39cda535827810f44c159faca070f7b9e51 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 28 Jun 2011 02:55:38 +0300 Subject: [PATCH 008/747] Changed: #1301 Binding 2d renderer to NELLIGO. --- .../plugins/landscape_editor/builder_zone.cpp | 256 +- .../plugins/landscape_editor/builder_zone.h | 77 +- .../landscape_editor/builder_zone_region.cpp | 2084 +++++++++++++++++ .../landscape_editor/builder_zone_region.h | 134 +- .../landscape_editor/landscape_actions.cpp | 103 +- .../landscape_editor/landscape_actions.h | 56 +- .../landscape_editor_window.cpp | 22 +- .../landscape_editor_window.h | 3 - .../landscape_editor/landscape_scene.cpp | 213 +- .../landscape_editor/landscape_scene.h | 45 +- .../landscape_editor/list_zones_widget.cpp | 32 +- .../landscape_editor/list_zones_widget.h | 9 +- .../landscape_editor/zone_region_editor.cpp | 66 + .../landscape_editor/zone_region_editor.h | 36 + 14 files changed, 2904 insertions(+), 232 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 288a4b1be..8271fe37c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -17,6 +17,8 @@ // Project includes #include "builder_zone.h" +#include "list_zones_widget.h" +#include "landscape_actions.h" // NeL includes #include @@ -29,9 +31,9 @@ namespace LandscapeEditor { -const int PixmapScale = 256; PixmapDatabase::PixmapDatabase() + : m_textureSize(256) { } @@ -66,15 +68,21 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon // Generate filled pixmap } // All pixmaps must be have same size - if (pixmap->width() != sizeX * PixmapScale) + if (pixmap->width() != sizeX * m_textureSize) { - QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * PixmapScale, sizeY * PixmapScale)); + QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); delete pixmap; m_pixmapMap.insert(zonePixmapName, scaledPixmap); } else m_pixmapMap.insert(zonePixmapName, pixmap); } + + QPixmap *pixmap = new QPixmap(zonePath + "_UNUSED_.png"); + QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(m_textureSize, m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + delete pixmap; + m_pixmapMap.insert(QString(STRING_UNUSED), scaledPixmap); + delete progressDialog; return true; } @@ -105,8 +113,17 @@ QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const return result; } -ZoneBuilder::ZoneBuilder() - : m_pixmapDatabase(0) +int PixmapDatabase::textureSize() const +{ + return m_textureSize; +} + +ZoneBuilder::ZoneBuilder(ListZonesWidget *listZonesWidget, LandscapeScene *landscapeScene, QUndoStack *undoStack) + : m_currentZoneRegion(-1), + m_pixmapDatabase(0), + m_listZonesWidget(listZonesWidget), + m_landscapeScene(landscapeScene), + m_undoStack(undoStack) { m_pixmapDatabase = new PixmapDatabase(); m_lastPathName = ""; @@ -144,10 +161,131 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone) } } if ((makeAZone) && (bRet)) - newZone(); + createZoneRegion(); return bRet; } +void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zonePos) +{ + nlinfo(QString("%1 %2 %3 (%4 %5)").arg(data.zoneName.c_str()).arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).toStdString().c_str()); + m_undoStack->push(new LigoTileCommand(data, zonePos, this, m_landscapeScene)); +} + +void ZoneBuilder::actionLigoMove(uint index, sint32 deltaX, sint32 deltaY) +{ + nlinfo("ligoMove"); + //m_undoStack->push(new LigoMoveCommand(index, deltaX, deltaY, this)); +} + +void ZoneBuilder::actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY) +{ + nlinfo(QString("minX=%1 maxX=%2 minY=%3 maxY=%4").arg(newMinX).arg(newMaxX).arg(newMinY).arg(newMaxY).toStdString().c_str()); + m_undoStack->push(new LigoResizeCommand(index, newMinX, newMaxX, newMinY, newMaxY, this)); +} + +void ZoneBuilder::addZone(sint32 posX, sint32 posY) +{ + if (m_builderZoneRegions.empty()) + return; + + std::string zoneName = m_listZonesWidget->currentZoneName().toStdString(); + if (zoneName.empty()) + return; + + std::string error; + BuilderZoneRegion *builderZoneRegion = m_builderZoneRegions.at(m_currentZoneRegion); + builderZoneRegion->init(this, error); + + uint8 rot = uint8(m_listZonesWidget->currentRot()); + uint8 flip = uint8(m_listZonesWidget->currentFlip()); + + NLLIGO::CZoneBankElement *zoneBankElement = getZoneBank().getElementByZoneName(zoneName); + + m_undoStack->beginMacro(QString("Add zone %1,%2").arg(posX).arg(posY)); + if (m_listZonesWidget->isForce()) + { + builderZoneRegion->addForce(posX, posY, rot, flip, zoneBankElement); + } + else + { + if (m_listZonesWidget->isNotPropogate()) + builderZoneRegion->addNotPropagate(posX, posY, rot, flip, zoneBankElement); + else + builderZoneRegion->add(posX, posY, rot, flip, zoneBankElement); + } + m_undoStack->endMacro(); +} + +void ZoneBuilder::addTransition(const sint32 posX, const sint32 posY) +{ +} + +void ZoneBuilder::delZone(const sint32 posX, const sint32 posY) +{ + if (m_builderZoneRegions.empty()) + return; + + m_undoStack->beginMacro(QString("Del zone %1,%2").arg(posX).arg(posY)); + BuilderZoneRegion *builderZoneRegion = m_builderZoneRegions.at(m_currentZoneRegion); + std::string error; + builderZoneRegion->init(this, error); + builderZoneRegion->del(posX, posY); + m_undoStack->endMacro(); +} + +int ZoneBuilder::createZoneRegion() +{ + ZoneRegionEditor *newZoneRegion = new ZoneRegionEditor(); + m_zoneRegions.push_back(newZoneRegion); + if (m_currentZoneRegion == -1) + m_currentZoneRegion = m_zoneRegions.indexOf(newZoneRegion); + + newZone(); + return m_zoneRegions.indexOf(newZoneRegion); +} + +void ZoneBuilder::deleteZoneRegion(int id) +{ + if ((0 <= id) && (id < m_zoneRegions.size())) + delete m_zoneRegions.takeAt(id); +} + +void ZoneBuilder::setCurrentZoneRegion(int id) +{ + if ((0 <= id) && (id < m_zoneRegions.size())) + m_currentZoneRegion = id; +} + +int ZoneBuilder::currentIdZoneRegion() const +{ + return m_currentZoneRegion; +} + +ZoneRegionEditor *ZoneBuilder::currentZoneRegion() const +{ + return m_zoneRegions.at(m_currentZoneRegion); +} + +int ZoneBuilder::countZoneRegion() const +{ + return m_zoneRegions.size(); +} + +ZoneRegionEditor *ZoneBuilder::zoneRegion(int id) const +{ + return m_zoneRegions.at(id); +} + +void ZoneBuilder::ligoData(LigoData &data, const ZonePosition &zonePos) +{ + m_zoneRegions.at(zonePos.region)->ligoData(data, zonePos.x, zonePos.y); +} + +void ZoneBuilder::setLigoData(LigoData &data, const ZonePosition &zonePos) +{ + m_zoneRegions.at(zonePos.region)->setLigoData(data, zonePos.x, zonePos.y); +} + bool ZoneBuilder::initZoneBank (const QString &pathName) { QDir *dir = new QDir(pathName); @@ -178,8 +316,112 @@ QString ZoneBuilder::dataPath() const return m_lastPathName; } -void ZoneBuilder::newZone (bool bDisplay) +void ZoneBuilder::newZone() { + BuilderZoneRegion *builderZoneRegion = new BuilderZoneRegion(m_builderZoneRegions.size()); + m_builderZoneRegions.push_back(builderZoneRegion); + + // Select starting point for the moment 0,0 + sint32 x = 0, y = 0; + + // If there are some zone already present increase x until free + for (int i = 0; i < m_zoneRegions.size(); ++i) + { + const NLLIGO::CZoneRegion &zoneRegion = m_zoneRegions.at(i)->zoneRegion(); + const std::string &zoneName = zoneRegion.getName (x, y); + if ((zoneName != STRING_OUT_OF_BOUND) && (zoneName != STRING_UNUSED)) + { + ++x; + i = -1; + } + } + calcMask(); +} + +bool ZoneBuilder::getZoneMask(sint32 x, sint32 y) +{ + if ((x < m_minX) || (x > m_maxX) || + (y < m_minY) || (y > m_maxY)) + { + return true; + } + else + { + return m_zoneMask[(x - m_minX) + (y - m_minY) * (1 + m_maxX - m_minX)]; + } +} + +void ZoneBuilder::calcMask() +{ + sint32 i; + sint32 x, y; + + m_minY = m_minX = 1000000; + m_maxY = m_maxX = -1000000; + + if (m_builderZoneRegions.size() == 0) + return; + + for (i = 0; i < (sint32)m_builderZoneRegions.size(); ++i) + { + const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->zoneRegion(); + + if (m_minX > region.getMinX()) + m_minX = region.getMinX(); + if (m_minY > region.getMinY()) + m_minY = region.getMinY(); + if (m_maxX < region.getMaxX()) + m_maxX = region.getMaxX(); + if (m_maxY < region.getMaxY()) + m_maxY = region.getMaxY(); + } + + m_zoneMask.resize ((1 + m_maxX - m_minX) * (1 + m_maxY - m_minY)); + sint32 stride = (1 + m_maxX - m_minX); + for (y = m_minY; y <= m_maxY; ++y) + for (x = m_minX; x <= m_maxX; ++x) + { + m_zoneMask[x - m_minX + (y - m_minY) * stride] = true; + + for (i = 0; i < (sint32)m_builderZoneRegions.size(); ++i) + if (i != m_currentZoneRegion) + { + const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->zoneRegion(); + + const std::string &rSZone = region.getName (x, y); + if ((rSZone != STRING_OUT_OF_BOUND) && (rSZone != STRING_UNUSED)) + { + m_zoneMask[x - m_minX + (y - m_minY) * stride] = false; + } + } + } +} + +bool ZoneBuilder::getZoneAmongRegions (ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y) +{ + Q_FOREACH(ZoneRegionEditor *zoneRegion, m_zoneRegions) + { + const NLLIGO::CZoneRegion ®ion = zoneRegion->zoneRegion(); + if ((x < region.getMinX()) || (x > region.getMaxX()) || + (y < region.getMinY()) || (y > region.getMaxY())) + continue; + if (region.getName(x, y) != STRING_UNUSED) + { + int index = m_zoneRegions.indexOf(zoneRegion); + builderZoneRegionFrom = m_builderZoneRegions.at(index); + zonePos = ZonePosition(x, y, index); + return true; + } + } + + // The zone is not present in other region so it is an empty or oob zone of the current region + const NLLIGO::CZoneRegion ®ion = zoneRegion(builderZoneRegionFrom->getRegionId())->zoneRegion(); + if ((x < region.getMinX()) || (x > region.getMaxX()) || + (y < region.getMinY()) || (y > region.getMaxY())) + return false; // Out Of Bound + + zonePos = ZonePosition(x, y, builderZoneRegionFrom->getRegionId()); + return true; } } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index f43bb7d7e..54cdb3b73 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -19,9 +19,12 @@ #define BUILDER_ZONE_H // Project includes +#include "builder_zone_region.h" +#include "zone_region_editor.h" // NeL includes #include +#include // STL includes #include @@ -30,11 +33,38 @@ // Qt includes #include #include +#include #include #include +#include namespace LandscapeEditor { +class ListZonesWidget; +class LandscapeScene; + +// Data +struct ZonePosition +{ + // Absolute position + sint32 x; + sint32 y; + int region; + + ZonePosition() + { + x = 0xffffffff; + y = 0xffffffff; + region = -1; + } + + ZonePosition(const sint32 posX, const sint32 posY, const int id) + { + x = posX; + y = posY; + region = id; + } +}; /** @class PixmapDatabase @@ -59,8 +89,12 @@ public: /// Get original pixmap /// @return QPixmap* if the image is in the database ; otherwise returns 0. QPixmap *pixmap(const QString &zoneName) const; + + int textureSize() const; + private: + int m_textureSize; QMap m_pixmapMap; }; @@ -74,13 +108,37 @@ PixmapDatabase contains the graphics for the zones class ZoneBuilder { public: - ZoneBuilder(); + ZoneBuilder(ListZonesWidget *listZonesWidget, LandscapeScene *landscapeScene, QUndoStack *undoStack); ~ZoneBuilder(); - // Init zoneBank and init zone pixmap database + /// Init zoneBank and init zone pixmap database bool init(const QString &pathName, bool bMakeAZone); - void newZone(bool bDisplay=true); + void calcMask(); + void newZone(); + bool getZoneMask (sint32 x, sint32 y); + bool getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y); + + // Ligo Actions + void actionLigoTile(const LigoData &data, const ZonePosition &zonePos); + void actionLigoMove(uint index, sint32 deltaX, sint32 deltaY); + void actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY); + + // Zone Bricks + void addZone(sint32 posX, sint32 posY); + void addTransition(const sint32 posX, const sint32 posY); + void delZone(const sint32 posX, const sint32 posY); + + // Zone Region + int createZoneRegion(); + void deleteZoneRegion(int id); + void setCurrentZoneRegion(int id); + int currentIdZoneRegion() const; + ZoneRegionEditor *currentZoneRegion() const; + int countZoneRegion() const; + ZoneRegionEditor *zoneRegion(int id) const; + void ligoData(LigoData &data, const ZonePosition &zonePos); + void setLigoData(LigoData &data, const ZonePosition &zonePos); // Accessors NLLIGO::CZoneBank &getZoneBank() @@ -94,15 +152,24 @@ public: private: - // Scan ./zoneligos dir and add all *.ligozone files to zoneBank + /// Scan ./zoneligos dir and add all *.ligozone files to zoneBank bool initZoneBank (const QString &path); sint32 m_minX, m_maxX, m_minY, m_maxY; + std::vector m_zoneMask; + QString m_lastPathName; + QList m_zoneRegions; + int m_currentZoneRegion; + + std::vector m_builderZoneRegions; + PixmapDatabase *m_pixmapDatabase; NLLIGO::CZoneBank m_zoneBank; - std::vector m_currentSelection; + ListZonesWidget *m_listZonesWidget; + LandscapeScene *m_landscapeScene; + QUndoStack *m_undoStack; }; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp index 4dbd3e9e1..2a4fc204a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp @@ -17,6 +17,8 @@ // Project includes #include "builder_zone_region.h" +#include "builder_zone.h" +#include "zone_region_editor.h" // NeL includes #include @@ -25,4 +27,2086 @@ namespace LandscapeEditor { + +BuilderZoneRegion::BuilderZoneRegion(uint regionId) + : m_regionId(regionId), + m_zoneBuilder(0), + m_firstInit(false) +{ +} + +bool BuilderZoneRegion::init(ZoneBuilder *zoneBuilder, std::string &error) +{ + if (m_firstInit) + return true; + + m_zoneBuilder = zoneBuilder; + + uint32 j, k; + SMatNode mn; + std::vector AllValues; + + // Build the material tree + m_zoneBuilder->getZoneBank().getCategoryValues("material", AllValues); + for (uint32 i = 0; i < AllValues.size(); ++i) + { + mn.Name = AllValues[i]; + m_matTree.push_back(mn); + } + + // Link between materials + AllValues.clear (); + m_zoneBuilder->getZoneBank().getCategoryValues("transname", AllValues); + for (uint32 i = 0; i < AllValues.size(); ++i) + { + // Get the 2 materials linked together + std::string matAstr, matBstr; + for (j = 0; j < AllValues[i].size(); ++j) + { + if (AllValues[i][j] == '-') + break; + else + matAstr += AllValues[i][j]; + } + ++j; + for (; j < AllValues[i].size(); ++j) + matBstr += AllValues[i][j]; + + // Find matA + for (j = 0; j < m_matTree.size(); ++j) + if (m_matTree[j].Name == matAstr) + break; + + if (j < m_matTree.size()) + { + // Find matB + for (k = 0; k < m_matTree.size(); ++k) + if (m_matTree[k].Name == matBstr) + break; + + if (k < m_matTree.size()) + { + // Add a ref to matB in node matA + m_matTree[j].Arcs.push_back(k); + + // Add a ref to matA in node matB + m_matTree[k].Arcs.push_back(j); + } + } + } + + m_firstInit = true; + return true; +} + +class ToUpdate +{ + struct SElement + { + sint32 x, y; + + // Material put into the cell to update + std::string matPut; + + BuilderZoneRegion *builderZoneRegion; + }; + + std::vector m_elements; + +public: + + void add(BuilderZoneRegion *builderZoneRegion, sint32 x, sint32 y, const std::string &matName) + { + bool bFound = false; + for (uint32 m = 0; m < m_elements.size(); ++m) + if ((m_elements[m].x == x) && (m_elements[m].y == y)) + { + bFound = true; + break; + } + if (!bFound) + { + SElement newElement; + newElement.x = x; + newElement.y = y; + newElement.matPut = matName; + newElement.builderZoneRegion = builderZoneRegion; + m_elements.push_back (newElement); + } + } + + void del(sint32 x, sint32 y) + { + bool bFound = false; + uint32 m; + for (m = 0; m < m_elements.size(); ++m) + if ((m_elements[m].x == x) && (m_elements[m].y == y)) + { + bFound = true; + break; + } + if (bFound) + { + for (; m < m_elements.size() - 1; ++m) + m_elements[m] = m_elements[m + 1]; + m_elements.resize (m_elements.size() - 1); + } + } + + uint32 size() + { + return m_elements.size(); + } + + sint32 getX(uint32 m) + { + return m_elements[m].x; + } + + sint32 getY(uint32 m) + { + return m_elements[m].y; + } + + BuilderZoneRegion* getBuilderZoneRegion(uint32 m) + { + return m_elements[m].builderZoneRegion; + } + + const std::string& getMat (uint32 m) + { + return m_elements[m].matPut; + } +}; + +void BuilderZoneRegion::add(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement) +{ + sint32 sizeX = zoneBankElement->getSizeX(), sizeY = zoneBankElement->getSizeY(); + sint32 i, j; + NLLIGO::SPiece sMask, sPosX, sPosY; + ToUpdate tUpdate; // Transition to update + + if (!m_zoneBuilder->getZoneMask (x,y)) + return; + + if (zoneBankElement->getCategory("transname") != STRING_NO_CAT_TYPE) + { + addTransition (x, y, rot, flip, zoneBankElement); + return; + } + + // Create the mask in the good rotation and flip + sMask.Tab.resize(sizeX * sizeY); + sPosX.Tab.resize(sizeX * sizeY); + sPosY.Tab.resize(sizeX * sizeY); + + for(j = 0; j < sizeY; ++j) + for(i = 0; i < sizeX; ++i) + { + sPosX.Tab[i + j * sizeX] = (uint8)i; + sPosY.Tab[i + j * sizeX] = (uint8)j; + sMask.Tab[i + j * sizeX] = zoneBankElement->getMask()[i + j * sizeX]; + } + sPosX.w = sPosY.w = sMask.w = sizeX; + sPosX.h = sPosY.h = sMask.h = sizeY; + sMask.rotFlip(rot, flip); + sPosX.rotFlip(rot, flip); + sPosY.rotFlip(rot, flip); + + // Test if the pieces can be put (due to mask) + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i + j * sMask.w]) + { + if (m_zoneBuilder->getZoneMask(x + i, y + j) == false) + return; + } + + // Delete all pieces that are under the mask + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i + j * sMask.w]) + { + del(x + i, y + j, true, &tUpdate); + } + + // Delete all around all material that are not from the same as us + const std::string &curMat = zoneBankElement->getCategory ("material"); + + if (curMat != STRING_NO_CAT_TYPE) + { + // This element is a valid material + // Place the piece + const std::string &eltName = zoneBankElement->getName (); + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i + j * sMask.w]) + { + set(x + i, y + j, sPosX.Tab[i + j * sPosX.w], sPosY.Tab[i + j * sPosY.w], eltName); + setRot(x + i, y + j, rot); + setFlip(x + i, y + j, flip); + } + + // Put all transitions between different materials + putTransitions (x, y, sMask, curMat, &tUpdate); + + // Place the piece + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i + j * sMask.w]) + { + set(x + i, y + j, sPosX.Tab[i + j * sPosX.w], sPosY.Tab[i + j * sPosY.w], eltName); + setRot(x + i, y + j, rot); + setFlip(x + i, y + j, flip); + } + } +} + +void BuilderZoneRegion::invertCutEdge(sint32 x, sint32 y, uint8 cePos) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + if ((x < zoneRegion.getMinX ()) || (x > zoneRegion.getMaxX ()) || + (y < zoneRegion.getMinY ()) || (y > zoneRegion.getMaxY ())) + return; + + NLLIGO::CZoneBankElement *zoneBankElement = m_zoneBuilder->getZoneBank().getElementByZoneName(zoneRegion.getName(x, y)); + if (zoneBankElement == NULL) + return; + if (zoneBankElement->getCategory("transname") == STRING_NO_CAT_TYPE) + return; + + + ZonePosition zonePos(x, y, m_regionId); + LigoData dataZone; + + m_zoneBuilder->ligoData(dataZone, zonePos); + if (dataZone.sharingCutEdges[cePos] != 3 - dataZone.sharingCutEdges[cePos]) + { + dataZone.sharingCutEdges[cePos] = 3 - dataZone.sharingCutEdges[cePos]; + + m_zoneBuilder->actionLigoTile(dataZone, zonePos); + } + updateTrans(x, y); + + // If the transition number is not the same propagate the change + // Propagate where the edge is cut (1/3 or 2/3) and update the transition + if (cePos == 2) + if (dataZone.sharingMatNames[0] != dataZone.sharingMatNames[2]) + { + if (x > zoneRegion.getMinX ()) + { + // [x-1][y].right = [x][y].left + // _Zones[(x-1-zoneRegion->getMinX ())+(y-zoneRegion->getMinY ())*stride].SharingCutEdges[3] = dataZonePos.SharingCutEdges[2]; + ZonePosition zonePosTemp(x - 1, y, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + if (dataZoneTemp.sharingCutEdges[3] != dataZone.sharingCutEdges[2]) + { + dataZoneTemp.sharingCutEdges[3] = dataZone.sharingCutEdges[2]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + } + } + updateTrans (x - 1, y); + } + if (cePos == 3) + if (dataZone.sharingMatNames[1] != dataZone.sharingMatNames[3]) + { + if (x < zoneRegion.getMaxX ()) + { + // [x+1][y].left = [x][y].right + ZonePosition zonePosTemp(x + 1, y, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + if (dataZoneTemp.sharingCutEdges[2] != dataZone.sharingCutEdges[3]) + { + dataZoneTemp.sharingCutEdges[2] = dataZone.sharingCutEdges[3]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + } + } + updateTrans (x + 1, y); + } + if (cePos == 1) + if (dataZone.sharingMatNames[0] != dataZone.sharingMatNames[1]) + { + if (y > zoneRegion.getMinY ()) + { + // [x][y-1].up = [x][y].down + ZonePosition zonePosTemp(x, y - 1, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + if (dataZoneTemp.sharingCutEdges[0] != dataZone.sharingCutEdges[1]) + { + dataZoneTemp.sharingCutEdges[0] = dataZone.sharingCutEdges[1]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + } + } + updateTrans (x, y-1); + } + if (cePos == 0) + if (dataZone.sharingMatNames[2] != dataZone.sharingMatNames[3]) + { + if (y < zoneRegion.getMaxY ()) + { + // [x][y+1].down = [x][y].up + ZonePosition zonePosTemp(x, y + 1, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + if (dataZoneTemp.sharingCutEdges[1] != dataZone.sharingCutEdges[0]) + { + dataZoneTemp.sharingCutEdges[1] = dataZone.sharingCutEdges[0]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + } + } + updateTrans (x, y + 1); + } +} + +void BuilderZoneRegion::cycleTransition(sint32 x, sint32 y) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + if ((x < zoneRegion.getMinX ()) || (x > zoneRegion.getMaxX ()) || + (y < zoneRegion.getMinY ()) || (y > zoneRegion.getMaxY ())) + return; + + NLLIGO::CZoneBankElement *zoneBankElement = m_zoneBuilder->getZoneBank().getElementByZoneName (zoneRegion.getName (x, y)); + if (zoneBankElement == NULL) + return; + if (zoneBankElement->getCategory("transname") == STRING_NO_CAT_TYPE) + return; + + // \todo trap -> choose the good transition in function of the transition under the current location + // Choose the next possible transition if not the same as the first one + // Choose among all transition of the same number + + updateTrans (x, y); +} + +bool BuilderZoneRegion::addNotPropagate (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + sint32 sizeX = zoneBankElement->getSizeX(), sizeY = zoneBankElement->getSizeY(); + sint32 i, j; + NLLIGO::SPiece sMask, sPosX, sPosY; + ToUpdate tUpdate; // Transition to update + + if (!m_zoneBuilder->getZoneMask (x, y)) + return false; + + if (zoneBankElement->getCategory("transname") != STRING_NO_CAT_TYPE) + { + addTransition (x, y, rot, flip, zoneBankElement); + return true; + } + + // Create the mask in the good rotation and flip + sMask.Tab.resize (sizeX * sizeY); + sPosX.Tab.resize (sizeX * sizeY); + sPosY.Tab.resize (sizeX * sizeY); + + for (j = 0; j < sizeY; ++j) + for (i = 0; i < sizeX; ++i) + { + sPosX.Tab[i + j * sizeX] = (uint8)i; + sPosY.Tab[i + j * sizeX] = (uint8)j; + sMask.Tab[i + j * sizeX] = zoneBankElement->getMask()[i + j * sizeX]; + } + sPosX.w = sPosY.w = sMask.w = sizeX; + sPosX.h = sPosY.h = sMask.h = sizeY; + sMask.rotFlip (rot, flip); + sPosX.rotFlip (rot, flip); + sPosY.rotFlip (rot, flip); + + // Test if the pieces can be put (due to mask) + sint32 stride = (1 + zoneRegion.getMaxX () - zoneRegion.getMinX ()); + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i+j*sMask.w]) + { + if (m_zoneBuilder->getZoneMask(x + i, y + j) == false) + return false; + if (((x + i) < zoneRegion.getMinX ()) || ((x + i) > zoneRegion.getMaxX ()) || + ((y + j) < zoneRegion.getMinY ()) || ((y + j) > zoneRegion.getMaxY ())) + return false; + NLLIGO::CZoneBankElement *zoneBankElementUnder = m_zoneBuilder->getZoneBank().getElementByZoneName(zoneRegion.getName (x + i, y + j)); + if (zoneBankElementUnder == NULL) + return false; + if (zoneBankElementUnder->getCategory("material") != zoneBankElement->getCategory("material")) + return false; + } + + // Delete all pieces that are under the mask + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i + j * sMask.w]) + { + del(x + i, y + j, true, &tUpdate); + } + + const std::string &curMat = zoneBankElement->getCategory ("material"); + + if (curMat != STRING_NO_CAT_TYPE) + { + // This element is a valid material + // Place the piece + const std::string &EltName = zoneBankElement->getName (); + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i + j * sMask.w]) + { + set (x + i, y + j, sPosX.Tab[i + j * sPosX.w], sPosY.Tab[i + j * sPosY.w], EltName); + setRot (x + i, y + j, rot); + setFlip (x + i, y + j, flip); + } + } + + return true; +} + +void BuilderZoneRegion::addForce (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + sint32 sizeX = zoneBankElement->getSizeX(), sizeY = zoneBankElement->getSizeY(); + sint32 i, j; + NLLIGO::SPiece sMask, sPosX, sPosY; + ToUpdate tUpdate; // Transition to update + + if (!m_zoneBuilder->getZoneMask (x, y)) + return; + + /* + if (pElt->getCategory("transname") != STRING_NO_CAT_TYPE) + { + addTransition (x, y, nRot, nFlip, pElt); + return; + }*/ + + // Create the mask in the good rotation and flip + sMask.Tab.resize (sizeX * sizeY); + sPosX.Tab.resize (sizeX * sizeY); + sPosY.Tab.resize (sizeX * sizeY); + + for (j = 0; j < sizeY; ++j) + for (i = 0; i < sizeX; ++i) + { + sPosX.Tab[i + j * sizeX] = (uint8)i; + sPosY.Tab[i + j * sizeX] = (uint8)j; + sMask.Tab[i + j * sizeX] = zoneBankElement->getMask()[i + j * sizeX]; + } + sPosX.w = sPosY.w = sMask.w = sizeX; + sPosX.h = sPosY.h = sMask.h = sizeY; + sMask.rotFlip (rot, flip); + sPosX.rotFlip (rot, flip); + sPosY.rotFlip (rot, flip); + + // Test if the pieces can be put (due to mask) + // All space under the mask must be empty + sint32 stride = (1 + zoneRegion.getMaxX () - zoneRegion.getMinX ()); + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i+j*sMask.w]) + { + if (m_zoneBuilder->getZoneMask(x+i, y+j) == false) + return; + if (((x+i) < zoneRegion.getMinX ()) || ((x+i) > zoneRegion.getMaxX ()) || + ((y+j) < zoneRegion.getMinY ()) || ((y+j) > zoneRegion.getMaxY ())) + return; + NLLIGO::CZoneBankElement *zoneBankElementUnder = m_zoneBuilder->getZoneBank().getElementByZoneName(zoneRegion.getName (x + i, y + i)); + if (zoneBankElementUnder != NULL) + return; + } + + // Delete all pieces that are under the mask + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i+j*sMask.w]) + { + del(x+i, y+j, true, &tUpdate); + } + + const std::string &curMat = zoneBankElement->getCategory ("material"); + const bool transition = zoneBankElement->getCategory("transname") != STRING_NO_CAT_TYPE; + + if (curMat != STRING_NO_CAT_TYPE || transition) + { + // This element is a valid material + // Place the piece + const std::string &eltName = zoneBankElement->getName(); + for (j = 0; j < sMask.h; ++j) + for (i = 0; i < sMask.w; ++i) + if (sMask.Tab[i + j * sMask.w]) + { + set(x + i, y + j, sPosX.Tab[i + j * sPosX.w], sPosY.Tab[i + j * sPosY.w], eltName, transition); + setRot(x + i, y + j, rot); + setFlip(x + i, y + j, flip); + } + } +} + +uint8 TransToEdge[72][4] = +{ + { 0, 0, 1, 1 }, // TransNum = 0, Flip = 0, Rot = 0 + { 2, 2, 0, 0 }, // TransNum = 0, Flip = 0, Rot = 1 + { 0, 0, 2, 2 }, // TransNum = 0, Flip = 0, Rot = 2 + { 1, 1, 0, 0 }, // TransNum = 0, Flip = 0, Rot = 3 + { 0, 0, 1, 1 }, // TransNum = 0, Flip = 1, Rot = 0 + { 2, 2, 0, 0 }, // TransNum = 0, Flip = 1, Rot = 1 + { 0, 0, 2, 2 }, // TransNum = 0, Flip = 1, Rot = 2 + { 1, 1, 0, 0 }, // TransNum = 0, Flip = 1, Rot = 3 + + { 0, 0, 1, 2 }, // TransNum = 1, Flip = 0, Rot = 0 + { 1, 2, 0, 0 }, // TransNum = 1, Flip = 0, Rot = 1 + { 0, 0, 1, 2 }, // TransNum = 1, Flip = 0, Rot = 2 + { 1, 2, 0, 0 }, // TransNum = 1, Flip = 0, Rot = 3 + { 0, 0, 2, 1 }, // TransNum = 1, Flip = 1, Rot = 0 + { 2, 1, 0, 0 }, // TransNum = 1, Flip = 1, Rot = 1 + { 0, 0, 2, 1 }, // TransNum = 1, Flip = 1, Rot = 2 + { 2, 1, 0, 0 }, // TransNum = 1, Flip = 1, Rot = 3 + + { 0, 0, 2, 2 }, // TransNum = 2, Flip = 0, Rot = 0 + { 1, 1, 0, 0 }, // TransNum = 2, Flip = 0, Rot = 1 + { 0, 0, 1, 1 }, // TransNum = 2, Flip = 0, Rot = 2 + { 2, 2, 0, 0 }, // TransNum = 2, Flip = 0, Rot = 3 + { 0, 0, 2, 2 }, // TransNum = 2, Flip = 1, Rot = 0 + { 1, 1, 0, 0 }, // TransNum = 2, Flip = 1, Rot = 1 + { 0, 0, 1, 1 }, // TransNum = 2, Flip = 1, Rot = 2 + { 2, 2, 0, 0 }, // TransNum = 2, Flip = 1, Rot = 3 + + { 0, 1, 1, 0 }, // TransNum = 3, Flip = 0, Rot = 0 + { 0, 2, 0, 1 }, // TransNum = 3, Flip = 0, Rot = 1 + { 2, 0, 0, 2 }, // TransNum = 3, Flip = 0, Rot = 2 + { 1, 0, 2, 0 }, // TransNum = 3, Flip = 0, Rot = 3 + { 0, 2, 0, 1 }, // TransNum = 3, Flip = 1, Rot = 0 + { 2, 0, 0, 2 }, // TransNum = 3, Flip = 1, Rot = 1 + { 1, 0, 2, 0 }, // TransNum = 3, Flip = 1, Rot = 2 + { 0, 1, 1, 0 }, // TransNum = 3, Flip = 1, Rot = 3 + + { 0, 2, 1, 0 }, // TransNum = 4, Flip = 0, Rot = 0 + { 0, 2, 0, 2 }, // TransNum = 4, Flip = 0, Rot = 1 + { 1, 0, 0, 2 }, // TransNum = 4, Flip = 0, Rot = 2 + { 1, 0, 1, 0 }, // TransNum = 4, Flip = 0, Rot = 3 + { 0, 1, 0, 1 }, // TransNum = 4, Flip = 1, Rot = 0 + { 2, 0, 0, 1 }, // TransNum = 4, Flip = 1, Rot = 1 + { 2, 0, 2, 0 }, // TransNum = 4, Flip = 1, Rot = 2 + { 0, 1, 2, 0 }, // TransNum = 4, Flip = 1, Rot = 3 + + { 0, 2, 2, 0 }, // TransNum = 5, Flip = 0, Rot = 0 + { 0, 1, 0, 2 }, // TransNum = 5, Flip = 0, Rot = 1 + { 1, 0, 0, 1 }, // TransNum = 5, Flip = 0, Rot = 2 + { 2, 0, 1, 0 }, // TransNum = 5, Flip = 0, Rot = 3 + { 0, 1, 0, 2 }, // TransNum = 5, Flip = 1, Rot = 0 + { 1, 0, 0, 1 }, // TransNum = 5, Flip = 1, Rot = 1 + { 2, 0, 1, 0 }, // TransNum = 5, Flip = 1, Rot = 2 + { 0, 2, 2, 0 }, // TransNum = 5, Flip = 1, Rot = 3 + + { 0, 1, 1, 0 }, // TransNum = 6, Flip = 0, Rot = 0 + { 0, 2, 0, 1 }, // TransNum = 6, Flip = 0, Rot = 1 + { 2, 0, 0, 2 }, // TransNum = 6, Flip = 0, Rot = 2 + { 1, 0, 2, 0 }, // TransNum = 6, Flip = 0, Rot = 3 + { 0, 2, 0, 1 }, // TransNum = 6, Flip = 1, Rot = 0 + { 2, 0, 0, 2 }, // TransNum = 6, Flip = 1, Rot = 1 + { 1, 0, 2, 0 }, // TransNum = 6, Flip = 1, Rot = 2 + { 0, 1, 1, 0 }, // TransNum = 6, Flip = 1, Rot = 3 + + { 0, 2, 1, 0 }, // TransNum = 7, Flip = 0, Rot = 0 + { 0, 2, 0, 2 }, // TransNum = 7, Flip = 0, Rot = 1 + { 1, 0, 0, 2 }, // TransNum = 7, Flip = 0, Rot = 2 + { 1, 0, 1, 0 }, // TransNum = 7, Flip = 0, Rot = 3 + { 0, 1, 0, 1 }, // TransNum = 7, Flip = 1, Rot = 0 + { 2, 0, 0, 1 }, // TransNum = 7, Flip = 1, Rot = 1 + { 2, 0, 2, 0 }, // TransNum = 7, Flip = 1, Rot = 2 + { 0, 1, 2, 0 }, // TransNum = 7, Flip = 1, Rot = 3 + + { 0, 2, 2, 0 }, // TransNum = 8, Flip = 0, Rot = 0 + { 0, 1, 0, 2 }, // TransNum = 8, Flip = 0, Rot = 1 + { 1, 0, 0, 1 }, // TransNum = 8, Flip = 0, Rot = 2 + { 2, 0, 1, 0 }, // TransNum = 8, Flip = 0, Rot = 3 + { 0, 1, 0, 2 }, // TransNum = 8, Flip = 1, Rot = 0 + { 1, 0, 0, 1 }, // TransNum = 8, Flip = 1, Rot = 1 + { 2, 0, 1, 0 }, // TransNum = 8, Flip = 1, Rot = 2 + { 0, 2, 2, 0 }, // TransNum = 8, Flip = 1, Rot = 3 +}; + +void BuilderZoneRegion::addTransition (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + uint32 i; + // Check that we write in an already defined place + if ((x < zoneRegion.getMinX ()) || (x > zoneRegion.getMaxX ()) || + (y < zoneRegion.getMinY ()) || (y > zoneRegion.getMaxY ())) + return; + + // Check size + if ((zoneBankElement->getSizeX() != 1) || (zoneBankElement->getSizeY() != 1)) + return; + + // Check that an element already exist at position we want put the transition + NLLIGO::CZoneBankElement *zoneBankElementUnder = m_zoneBuilder->getZoneBank().getElementByZoneName(zoneRegion.getName(x, y)); + if (zoneBankElementUnder == NULL) + return; + + // And check that this element is also a transition and the same transition + if (zoneBankElementUnder->getCategory ("transname") == STRING_NO_CAT_TYPE) + return; + if (zoneBankElementUnder->getCategory ("transname") != zoneBankElement->getCategory("transname")) + return; + + std::string underType = zoneBankElementUnder->getCategory("transtype"); + std::string overType = zoneBankElement->getCategory("transtype"); + std::string underNum = zoneBankElementUnder->getCategory("transnum"); + std::string overNum = zoneBankElement ->getCategory("transnum"); + + ZonePosition zonePosTemp(x, y, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + LigoData dataZoneOriginal = dataZoneTemp; + + bool bMustPropagate = false; + // Same type of transition ? + if (zoneBankElementUnder->getCategory("transtype") != zoneBankElement->getCategory("transtype")) + { + // No so random the cutEdges + for (i = 0; i < 4; ++i) + { + uint8 nCut = (uint8)(1.0f + NLMISC::frand(2.0f)); + NLMISC::clamp(nCut, (uint8)1, (uint8)2); + + dataZoneTemp.sharingCutEdges[i] = nCut; + } + zoneBankElement = NULL; + bMustPropagate = true; + } + else + { + // Put exactly the transition as given + sint32 transnum = atoi(zoneBankElement->getCategory("transnum").c_str()); + sint32 flip = zoneRegion.getFlip(x, y); + sint32 rot = zoneRegion.getRot(x, y); + sint32 pos1 = -1, pos2 = -1; + + for (i = 0; i < 4; ++i) + { + if ((TransToEdge[transnum * 8 + flip * 4 + rot][i] != 0) && + (TransToEdge[transnum * 8 + flip * 4 + rot][i] != dataZoneTemp.sharingCutEdges[i])) + bMustPropagate = true; + + dataZoneTemp.sharingCutEdges[i] = TransToEdge[transnum * 8 + flip * 4 + rot][i]; + + if ((pos1 != -1) && (dataZoneTemp.sharingCutEdges[i] != 0)) + pos2 = i; + if ((pos1 == -1) && (dataZoneTemp.sharingCutEdges[i] != 0)) + pos1 = i; + } + // Exchange cutedges != 0 one time /2 to permit all positions + if ((transnum == 1) || (transnum == 4) || (transnum == 7)) + if (zoneBankElement->getName() == zoneBankElementUnder->getName()) + { + bMustPropagate = true; + + dataZoneTemp.sharingCutEdges[pos1] = 3 - dataZoneTemp.sharingCutEdges[pos1]; + dataZoneTemp.sharingCutEdges[pos2] = 3 - dataZoneTemp.sharingCutEdges[pos2]; + } + } + if (dataZoneTemp != dataZoneOriginal) + { + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + } + updateTrans (x, y, zoneBankElement); + + // If the transition number is not the same propagate the change + if (bMustPropagate) + { + // Propagate where the edge is cut (1/3 or 2/3) and update the transition + if (dataZoneTemp.sharingMatNames[0] != dataZoneTemp.sharingMatNames[2]) + { + if (x > zoneRegion.getMinX ()) + { + // [x-1][y].right = [x][y].left + // _Zones[(x-1-pBZR->getMinX ())+(y-pBZR->getMinY ())*stride].SharingCutEdges[3] = dataZoneTemp.SharingCutEdges[2]; + ZonePosition zonePosTemp2(x - 1, y, m_regionId); + LigoData dataZoneTemp2; + m_zoneBuilder->ligoData(dataZoneTemp2, zonePosTemp2); + if (dataZoneTemp2.sharingCutEdges[3] != dataZoneTemp.sharingCutEdges[2]) + { + dataZoneTemp2.sharingCutEdges[3] = dataZoneTemp.sharingCutEdges[2]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp2, zonePosTemp2); + } + } + updateTrans (x - 1, y); + } + if (dataZoneTemp.sharingMatNames[1] != dataZoneTemp.sharingMatNames[3]) + { + if (x < zoneRegion.getMaxX ()) + { + // [x+1][y].left = [x][y].right + //_Zones[(x+1-pBZR->getMinX ())+(y-pBZR->getMinY ())*stride].SharingCutEdges[2] = dataZoneTemp.SharingCutEdges[3]; + ZonePosition zonePosTemp2(x + 1, y, m_regionId); + LigoData dataZoneTemp2; + m_zoneBuilder->ligoData(dataZoneTemp2, zonePosTemp2); + if (dataZoneTemp2.sharingCutEdges[2] != dataZoneTemp.sharingCutEdges[3]) + { + dataZoneTemp2.sharingCutEdges[2] = dataZoneTemp.sharingCutEdges[3]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp2, zonePosTemp2); + } + } + updateTrans (x + 1, y); + } + if (dataZoneTemp.sharingMatNames[0] != dataZoneTemp.sharingMatNames[1]) + { + if (y > zoneRegion.getMinY ()) + { + // [x][y-1].up = [x][y].down + //_Zones[(x-pBZR->getMinX ())+(y-1-pBZR->getMinY ())*stride].SharingCutEdges[0] = dataZoneTemp.SharingCutEdges[1]; + ZonePosition zonePosTemp2(x, y - 1, m_regionId); + LigoData dataZoneTemp2; + m_zoneBuilder->ligoData(dataZoneTemp2, zonePosTemp2); + if (dataZoneTemp2.sharingCutEdges[0] != dataZoneTemp.sharingCutEdges[1]) + { + dataZoneTemp2.sharingCutEdges[0] = dataZoneTemp.sharingCutEdges[1]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp2, zonePosTemp2); + } + } + updateTrans (x, y - 1); + } + if (dataZoneTemp.sharingMatNames[2] != dataZoneTemp.sharingMatNames[3]) + { + if (y < zoneRegion.getMaxY ()) + { + // [x][y+1].down = [x][y].up + //_Zones[(x-pBZR->getMinX ())+(y+1-pBZR->getMinY ())*stride].SharingCutEdges[1] = dataZoneTemp.SharingCutEdges[0]; + ZonePosition zonePosTemp2(x, y + 1, m_regionId); + LigoData dataZoneTemp2; + m_zoneBuilder->ligoData(dataZoneTemp2, zonePosTemp2); + if (dataZoneTemp2.sharingCutEdges[1] != dataZoneTemp.sharingCutEdges[0]) + { + dataZoneTemp2.sharingCutEdges[1] = dataZoneTemp.sharingCutEdges[0]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp2, zonePosTemp2); + } + } + updateTrans (x, y + 1); + } + } +} + +void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion* builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + ToUpdate *ptCreate = reinterpret_cast(pInt1); + ToUpdate *ptUpdate = reinterpret_cast(pInt2); + sint32 stride = (1 + zoneRegion.getMaxX() - zoneRegion.getMinX()); + + ZonePosition zonePos; + if (m_zoneBuilder->getZoneAmongRegions(zonePos, builderZoneRegion, x, y)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePos); + if (data.sharingMatNames[sharePos] != newMat) + { + data.sharingMatNames[sharePos] = newMat; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePos); + } + builderZoneRegion->del(x, y, true, ptUpdate); + ptCreate->add(builderZoneRegion, x, y, newMat); + } +} + +void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SPiece &mask, const std::string &matName, + void *pInternal) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + ToUpdate tCreate; // Transition to create + ToUpdate *ptUpdate = reinterpret_cast(pInternal); // Transition to update + + sint32 i, j, k, l, m; + sint32 x = inX, y = inY; + for (j = 0; j < mask.h; ++j) + for (i = 0; i < mask.w; ++i) + if (mask.Tab[i + j * mask.w]) + { + for (k = -1; k <= 1; ++k) + for (l = -1; l <= 1; ++l) + { + BuilderZoneRegion *builderZoneRegion2 = this; + ZonePosition zonePos; + if (m_zoneBuilder->getZoneAmongRegions(zonePos, builderZoneRegion2, inX + i + l, inY + j + k)) + tCreate.add(builderZoneRegion2, inX + i + l, inY + j + k, matName); + } + } + + // Check coherency of the transition to update + for (m = 0; m < (sint32)tCreate.size(); ++m) + { + BuilderZoneRegion *builderZoneRegion2 = tCreate.getBuilderZoneRegion(m); + x = tCreate.getX(m); + y = tCreate.getY(m); + std::string putMat = tCreate.getMat(m); + + //if ((x < pBZR->getMinX ())||(x > pBZR->getMaxX ())||(y < pBZR->getMinY ())||(y > pBZR->getMaxY ())) + // continue; + + ZonePosition zoneTemp(x, y, builderZoneRegion2->getRegionId()); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zoneTemp); + + if (!((dataZoneTemp.sharingMatNames[0] == dataZoneTemp.sharingMatNames[1])&& + (dataZoneTemp.sharingMatNames[1] == dataZoneTemp.sharingMatNames[2])&& + (dataZoneTemp.sharingMatNames[2] == dataZoneTemp.sharingMatNames[3]))) + builderZoneRegion2->del(x, y, true, ptUpdate); + + // Check to see material can be posed + uint corner; + for (corner = 0; corner < 4; corner++) + { + std::string newMat = getNextMatInTree (putMat, dataZoneTemp.sharingMatNames[corner]); + + // Can't be posed ? + if (newMat == STRING_UNUSED) + break; + } + if ( (corner < 4) && (m != 0) ) + { + // The material can't be paused + dataZoneTemp.sharingMatNames[0] = STRING_UNUSED; + dataZoneTemp.sharingMatNames[1] = STRING_UNUSED; + dataZoneTemp.sharingMatNames[2] = STRING_UNUSED; + dataZoneTemp.sharingMatNames[3] = STRING_UNUSED; + + // Don't propagate any more + } + else + { + // Expand material for the 1st quarter + std::string newMat = getNextMatInTree(putMat, dataZoneTemp.sharingMatNames[0]); + if (newMat != dataZoneTemp.sharingMatNames[0]) + { + // Update the quarter + if (dataZoneTemp.sharingMatNames[0] != newMat) + { + dataZoneTemp.sharingMatNames[0] = newMat; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + } + + addToUpdateAndCreate(builderZoneRegion2, 1, x - 1, y, newMat, &tCreate, ptUpdate); + addToUpdateAndCreate(builderZoneRegion2, 3, x - 1, y - 1, newMat, &tCreate, ptUpdate); + addToUpdateAndCreate(builderZoneRegion2, 2, x, y - 1, newMat, &tCreate, ptUpdate); + } + + // Expand material for the 2nd quarter + newMat = getNextMatInTree(putMat, dataZoneTemp.sharingMatNames[1]); + if (newMat != dataZoneTemp.sharingMatNames[1]) + { + // Update the quarter + //if (_Builder->getZoneMask(x,y)) + if (dataZoneTemp.sharingMatNames[1] != newMat) + { + dataZoneTemp.sharingMatNames[1] = newMat; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + } + + addToUpdateAndCreate(builderZoneRegion2, 0, x + 1, y, newMat, &tCreate, ptUpdate); + addToUpdateAndCreate(builderZoneRegion2, 2, x + 1, y - 1, newMat, &tCreate, ptUpdate); + addToUpdateAndCreate(builderZoneRegion2, 3, x, y - 1, newMat, &tCreate, ptUpdate); + } + + // Expand material for the 3rd quarter + newMat = getNextMatInTree(putMat, dataZoneTemp.sharingMatNames[2]); + if (newMat != dataZoneTemp.sharingMatNames[2]) + { + // Update the quarter + //if (_Builder->getZoneMask(x,y)) + if (dataZoneTemp.sharingMatNames[2] != newMat) + { + dataZoneTemp.sharingMatNames[2] = newMat; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + } + + addToUpdateAndCreate(builderZoneRegion2, 3, x - 1, y, newMat, &tCreate, ptUpdate); + addToUpdateAndCreate(builderZoneRegion2, 1, x - 1, y + 1, newMat, &tCreate, ptUpdate); + addToUpdateAndCreate(builderZoneRegion2, 0, x, y + 1, newMat, &tCreate, ptUpdate); + } + + // Expand material for the 4th quarter + newMat = getNextMatInTree(putMat, dataZoneTemp.sharingMatNames[3]); + if (newMat != dataZoneTemp.sharingMatNames[3]) + { + // Update the quarter + //if (_Builder->getZoneMask(x,y)) + if (dataZoneTemp.sharingMatNames[3] != newMat) + { + dataZoneTemp.sharingMatNames[3] = newMat; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + } + + addToUpdateAndCreate(builderZoneRegion2, 2, x + 1, y, newMat, &tCreate, ptUpdate); + addToUpdateAndCreate(builderZoneRegion2, 0, x + 1, y + 1, newMat, &tCreate, ptUpdate); + addToUpdateAndCreate(builderZoneRegion2, 1, x, y + 1, newMat, &tCreate, ptUpdate); + } + } + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + } + + // Delete transitions that are inside the mask + for (j = 0; j < mask.h; ++j) + for (i = 0; i < mask.w; ++i) + if (mask.Tab[i + j * mask.w]) + { + tCreate.del(inX + i, inY + j); + } + + // For all transition to update choose the cut edge + for (m = 0; m < (sint32)tCreate.size(); ++m) + { + const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion(); + x = tCreate.getX(m); + y = tCreate.getY(m); + + if ((x < zoneRegion.getMinX()) || (x > zoneRegion.getMaxX()) || + (y < zoneRegion.getMinY()) || (y > zoneRegion.getMaxY())) + continue; + + ZonePosition zoneTemp(x, y, tCreate.getBuilderZoneRegion(m)->getRegionId()); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zoneTemp); + LigoData dataZoneTempOriginal = dataZoneTemp; + + for (i = 0; i < 4; ++i) + { + uint8 nCut = (uint8)(1.0f + NLMISC::frand(2.0f)); + NLMISC::clamp(nCut, (uint8)1, (uint8)2); + dataZoneTemp.sharingCutEdges[i] = nCut; + } + + // Add modification landscape + if (dataZoneTempOriginal != dataZoneTemp) + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + + // Propagate + if (dataZoneTemp.sharingMatNames[0] != dataZoneTemp.sharingMatNames[2]) + { + // [x-1][y].right = [x][y].left + BuilderZoneRegion *builderZoneRegion3 = tCreate.getBuilderZoneRegion(m); + ZonePosition zonePosU; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion3, x - 1, y)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if (data.sharingCutEdges[3] != dataZoneTemp.sharingCutEdges[2]) + { + data.sharingCutEdges[3] = dataZoneTemp.sharingCutEdges[2]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + ptUpdate->add(builderZoneRegion3, x - 1, y, ""); + } + } + else + { + m_zoneBuilder->ligoData(dataZoneTemp, zoneTemp); + if (dataZoneTemp.sharingCutEdges[2] != 0) + { + dataZoneTemp.sharingCutEdges[2] = 0; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + } + } + + if (dataZoneTemp.sharingMatNames[0] != dataZoneTemp.sharingMatNames[1]) + { + // [x][y-1].up = [x][y].down + BuilderZoneRegion *builderZoneRegion3 = tCreate.getBuilderZoneRegion(m); + ZonePosition zonePosU; + if (m_zoneBuilder->getZoneAmongRegions (zonePosU, builderZoneRegion3, x, y - 1)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if (data.sharingCutEdges[0] != dataZoneTemp.sharingCutEdges[1]) + { + data.sharingCutEdges[0] = dataZoneTemp.sharingCutEdges[1]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + ptUpdate->add (builderZoneRegion3, x, y - 1, ""); + } + } + else + { + m_zoneBuilder->ligoData(dataZoneTemp, zoneTemp); + if (dataZoneTemp.sharingCutEdges[1] != 0) + { + dataZoneTemp.sharingCutEdges[1] = 0; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + } + } + + if (dataZoneTemp.sharingMatNames[3] != dataZoneTemp.sharingMatNames[1]) + { + // [x+1][y].left = [x][y].right + BuilderZoneRegion *builderZoneRegion3 = tCreate.getBuilderZoneRegion(m); + ZonePosition zonePosU; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion3, x + 1, y)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if (data.sharingCutEdges[2] != dataZoneTemp.sharingCutEdges[3]) + { + data.sharingCutEdges[2] = dataZoneTemp.sharingCutEdges[3]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + ptUpdate->add(builderZoneRegion3, x + 1, y, ""); + } + } + else + { + m_zoneBuilder->ligoData(dataZoneTemp, zoneTemp); + if (dataZoneTemp.sharingCutEdges[3] != 0) + { + dataZoneTemp.sharingCutEdges[3] = 0; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + } + } + + if (dataZoneTemp.sharingMatNames[2] != dataZoneTemp.sharingMatNames[3]) + { + // [x][y+1].down = [x][y].up + BuilderZoneRegion *builderZoneRegion3 = tCreate.getBuilderZoneRegion(m); + ZonePosition zonePosU; + if (m_zoneBuilder->getZoneAmongRegions (zonePosU, builderZoneRegion3, x, y+1)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if (data.sharingCutEdges[1] = dataZoneTemp.sharingCutEdges[0]) + { + data.sharingCutEdges[1] = dataZoneTemp.sharingCutEdges[0]; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + ptUpdate->add (builderZoneRegion3, x, y + 1, ""); + } + } + else + { + m_zoneBuilder->ligoData(dataZoneTemp, zoneTemp); + if (dataZoneTemp.sharingCutEdges[0] = 0) + { + dataZoneTemp.sharingCutEdges[0] = 0; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zoneTemp); + } + } + } + + // Delete in tUpdate each element in common with tCreate + for (m = 0; m < (sint32)tCreate.size(); ++m) + { + x = tCreate.getX(m); + y = tCreate.getY(m); + ptUpdate->del (x,y); + } + + // Finally update all transition + for (m = 0; m < (sint32)tCreate.size(); ++m) + { + const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion(); + x = tCreate.getX(m); + y = tCreate.getY(m); + + if ((x >= zoneRegion2.getMinX()) && (x <= zoneRegion2.getMaxX()) && + (y >= zoneRegion2.getMinY()) && (y <= zoneRegion2.getMaxY())) + tCreate.getBuilderZoneRegion(m)->updateTrans(x, y); + } + for (m = 0; m < (sint32)ptUpdate->size(); ++m) + { + const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion(); + x = ptUpdate->getX(m); + y = ptUpdate->getY(m); + if ((x >= zoneRegion2.getMinX()) && (x <= zoneRegion2.getMaxX()) && + (y >= zoneRegion2.getMinY()) && (y <= zoneRegion2.getMaxY())) + tCreate.getBuilderZoneRegion(m)->updateTrans(x, y); + } + + // Cross material + for (m = 0; m < (sint32)tCreate.size(); ++m) + { + const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion(); + x = tCreate.getX(m); + y = tCreate.getY(m); + + + ZonePosition zoneTemp(x, y, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zoneTemp); + + std::set matNameSet; + for (i = 0; i < 4; ++i) + matNameSet.insert(dataZoneTemp.sharingMatNames[i]); + + if (((dataZoneTemp.sharingMatNames[0] == dataZoneTemp.sharingMatNames[3]) && + (dataZoneTemp.sharingMatNames[1] == dataZoneTemp.sharingMatNames[2]) && + (dataZoneTemp.sharingMatNames[0] != dataZoneTemp.sharingMatNames[1])) + || (matNameSet.size()>2)) + { + NLLIGO::CZoneBank &zoneBank = m_zoneBuilder->getZoneBank(); + zoneBank.resetSelection(); + zoneBank.addOrSwitch("material", tCreate.getMat(m)); + zoneBank.addAndSwitch("size", "1x1"); + std::vector vElts; + zoneBank.getSelection(vElts); + if (vElts.size() == 0) + return; + sint32 nRan = (sint32)(NLMISC::frand((float)vElts.size())); + NLMISC::clamp(nRan, (sint32)0, (sint32)(vElts.size() - 1)); + NLLIGO::CZoneBankElement *zoneBankElement = vElts[nRan]; + nRan = (uint32)(NLMISC::frand (1.0) * 4); + NLMISC::clamp(nRan, (sint32)0, (sint32)3); + uint8 rot = (uint8)nRan; + nRan = (uint32)(NLMISC::frand (1.0) * 2); + NLMISC::clamp (nRan, (sint32)0, (sint32)1); + uint8 flip = (uint8)nRan; + + tCreate.getBuilderZoneRegion(m)->add(x, y, rot, flip, zoneBankElement); + } + } +} + +struct STrans +{ + uint8 Num; + uint8 Rot; + uint8 Flip; +}; + +STrans TranConvTable[128] = +{ + { 0,0,0 }, // Quart = 0, CutEdge = 0, Np = 0 UNUSED + { 0,0,0 }, // Quart = 0, CutEdge = 0, Np = 1 UNUSED + { 0,0,0 }, // Quart = 0, CutEdge = 1, Np = 0 UNUSED + { 0,0,0 }, // Quart = 0, CutEdge = 1, Np = 1 UNUSED + { 0,0,0 }, // Quart = 0, CutEdge = 2, Np = 0 UNUSED + { 0,0,0 }, // Quart = 0, CutEdge = 2, Np = 1 UNUSED + { 0,0,0 }, // Quart = 0, CutEdge = 3, Np = 0 UNUSED + { 0,0,0 }, // Quart = 0, CutEdge = 3, Np = 1 UNUSED + + { 6,0,0 }, // Quart = 1, CutEdge = 0, Np = 0 + { 6,3,1 }, // Quart = 1, CutEdge = 0, Np = 1 + { 7,0,0 }, // Quart = 1, CutEdge = 1, Np = 0 + { 7,0,0 }, // Quart = 1, CutEdge = 1, Np = 1 + { 7,3,1 }, // Quart = 1, CutEdge = 2, Np = 0 + { 7,3,1 }, // Quart = 1, CutEdge = 2, Np = 1 + { 8,0,0 }, // Quart = 1, CutEdge = 3, Np = 0 + { 8,3,1 }, // Quart = 1, CutEdge = 3, Np = 1 + + { 7,0,1 }, // Quart = 2, CutEdge = 0, Np = 0 + { 7,0,1 }, // Quart = 2, CutEdge = 0, Np = 1 + { 6,0,1 }, // Quart = 2, CutEdge = 1, Np = 0 + { 6,1,0 }, // Quart = 2, CutEdge = 1, Np = 1 + { 8,1,0 }, // Quart = 2, CutEdge = 2, Np = 0 + { 8,0,1 }, // Quart = 2, CutEdge = 2, Np = 1 + { 7,1,0 }, // Quart = 2, CutEdge = 3, Np = 0 + { 7,1,0 }, // Quart = 2, CutEdge = 3, Np = 1 + + { 0,0,0 }, // Quart = 3, CutEdge = 0, Np = 0 + { 0,0,1 }, // Quart = 3, CutEdge = 0, Np = 1 + { 1,0,1 }, // Quart = 3, CutEdge = 1, Np = 0 + { 1,0,1 }, // Quart = 3, CutEdge = 1, Np = 1 + { 1,0,0 }, // Quart = 3, CutEdge = 2, Np = 0 + { 1,0,0 }, // Quart = 3, CutEdge = 2, Np = 1 + { 2,0,0 }, // Quart = 3, CutEdge = 3, Np = 0 + { 2,0,1 }, // Quart = 3, CutEdge = 3, Np = 1 + + { 7,3,0 }, // Quart = 4, CutEdge = 0, Np = 0 + { 7,3,0 }, // Quart = 4, CutEdge = 0, Np = 1 + { 8,3,0 }, // Quart = 4, CutEdge = 1, Np = 0 + { 8,2,1 }, // Quart = 4, CutEdge = 1, Np = 1 + { 6,3,0 }, // Quart = 4, CutEdge = 2, Np = 0 + { 6,2,1 }, // Quart = 4, CutEdge = 2, Np = 1 + { 7,2,1 }, // Quart = 4, CutEdge = 3, Np = 0 + { 7,2,1 }, // Quart = 4, CutEdge = 3, Np = 1 + + { 0,3,0 }, // Quart = 5, CutEdge = 0, Np = 0 + { 0,3,1 }, // Quart = 5, CutEdge = 0, Np = 1 + { 1,3,1 }, // Quart = 5, CutEdge = 1, Np = 0 + { 1,3,1 }, // Quart = 5, CutEdge = 1, Np = 1 + { 1,3,0 }, // Quart = 5, CutEdge = 2, Np = 0 + { 1,3,0 }, // Quart = 5, CutEdge = 2, Np = 1 + { 2,3,0 }, // Quart = 5, CutEdge = 3, Np = 0 + { 2,3,1 }, // Quart = 5, CutEdge = 3, Np = 1 + + { 0,0,0 }, // Quart = 6, CutEdge = 0, Np = 0 UNUSED + { 0,0,0 }, // Quart = 6, CutEdge = 0, Np = 1 UNUSED + { 0,0,0 }, // Quart = 6, CutEdge = 1, Np = 0 UNUSED + { 0,0,0 }, // Quart = 6, CutEdge = 1, Np = 1 UNUSED + { 0,0,0 }, // Quart = 6, CutEdge = 2, Np = 0 UNUSED + { 0,0,0 }, // Quart = 6, CutEdge = 2, Np = 1 UNUSED + { 0,0,0 }, // Quart = 6, CutEdge = 3, Np = 0 UNUSED + { 0,0,0 }, // Quart = 6, CutEdge = 3, Np = 1 UNUSED + + { 5,2,0 }, // Quart = 7, CutEdge = 0, Np = 0 + { 5,1,1 }, // Quart = 7, CutEdge = 0, Np = 1 + { 4,1,1 }, // Quart = 7, CutEdge = 1, Np = 0 + { 4,1,1 }, // Quart = 7, CutEdge = 1, Np = 1 + { 4,2,0 }, // Quart = 7, CutEdge = 2, Np = 0 + { 4,2,0 }, // Quart = 7, CutEdge = 2, Np = 1 + { 3,2,0 }, // Quart = 7, CutEdge = 3, Np = 0 + { 3,1,1 }, // Quart = 7, CutEdge = 3, Np = 1 + + { 8,2,0 }, // Quart = 8, CutEdge = 0, Np = 0 + { 8,1,1 }, // Quart = 8, CutEdge = 0, Np = 1 + { 7,1,1 }, // Quart = 8, CutEdge = 1, Np = 0 + { 7,1,1 }, // Quart = 8, CutEdge = 1, Np = 1 + { 7,2,0 }, // Quart = 8, CutEdge = 2, Np = 0 + { 7,2,0 }, // Quart = 8, CutEdge = 2, Np = 1 + { 6,2,0 }, // Quart = 8, CutEdge = 3, Np = 0 + { 6,1,1 }, // Quart = 8, CutEdge = 3, Np = 1 + + { 0,0,0 }, // Quart = 9, CutEdge = 0, Np = 0 UNUSED + { 0,0,0 }, // Quart = 9, CutEdge = 0, Np = 1 UNUSED + { 0,0,0 }, // Quart = 9, CutEdge = 1, Np = 0 UNUSED + { 0,0,0 }, // Quart = 9, CutEdge = 1, Np = 1 UNUSED + { 0,0,0 }, // Quart = 9, CutEdge = 2, Np = 0 UNUSED + { 0,0,0 }, // Quart = 9, CutEdge = 2, Np = 1 UNUSED + { 0,0,0 }, // Quart = 9, CutEdge = 3, Np = 0 UNUSED + { 0,0,0 }, // Quart = 9, CutEdge = 3, Np = 1 UNUSED + + { 2,1,0 }, // Quart = 10, CutEdge = 0, Np = 0 + { 2,1,1 }, // Quart = 10, CutEdge = 0, Np = 1 + { 1,1,1 }, // Quart = 10, CutEdge = 1, Np = 0 + { 1,1,1 }, // Quart = 10, CutEdge = 1, Np = 1 + { 1,1,0 }, // Quart = 10, CutEdge = 2, Np = 0 + { 1,1,0 }, // Quart = 10, CutEdge = 2, Np = 1 + { 0,1,0 }, // Quart = 10, CutEdge = 3, Np = 0 + { 0,1,1 }, // Quart = 10, CutEdge = 3, Np = 1 + + { 4,3,0 }, // Quart = 11, CutEdge = 0, Np = 0 + { 4,3,0 }, // Quart = 11, CutEdge = 0, Np = 1 + { 5,3,0 }, // Quart = 11, CutEdge = 1, Np = 0 + { 5,2,1 }, // Quart = 11, CutEdge = 1, Np = 1 + { 3,3,0 }, // Quart = 11, CutEdge = 2, Np = 0 + { 3,2,1 }, // Quart = 11, CutEdge = 2, Np = 1 + { 4,2,1 }, // Quart = 11, CutEdge = 3, Np = 0 + { 4,2,1 }, // Quart = 11, CutEdge = 3, Np = 1 + + { 2,2,0 }, // Quart = 12, CutEdge = 0, Np = 0 + { 2,2,1 }, // Quart = 12, CutEdge = 0, Np = 1 + { 1,2,1 }, // Quart = 12, CutEdge = 1, Np = 0 + { 1,2,1 }, // Quart = 12, CutEdge = 1, Np = 1 + { 1,2,0 }, // Quart = 12, CutEdge = 2, Np = 0 + { 1,2,0 }, // Quart = 12, CutEdge = 2, Np = 1 + { 0,2,0 }, // Quart = 12, CutEdge = 3, Np = 0 + { 0,2,1 }, // Quart = 12, CutEdge = 3, Np = 1 + + { 4,0,1 }, // Quart = 13, CutEdge = 0, Np = 0 + { 4,0,1 }, // Quart = 13, CutEdge = 0, Np = 1 + { 3,1,0 }, // Quart = 13, CutEdge = 1, Np = 0 + { 3,0,1 }, // Quart = 13, CutEdge = 1, Np = 1 + { 5,1,0 }, // Quart = 13, CutEdge = 2, Np = 0 + { 5,0,1 }, // Quart = 13, CutEdge = 2, Np = 1 + { 4,1,0 }, // Quart = 13, CutEdge = 3, Np = 0 + { 4,1,0 }, // Quart = 13, CutEdge = 3, Np = 1 + + { 3,0,0 }, // Quart = 14, CutEdge = 0, Np = 0 + { 3,3,1 }, // Quart = 14, CutEdge = 0, Np = 1 + { 4,0,0 }, // Quart = 14, CutEdge = 1, Np = 0 + { 4,0,0 }, // Quart = 14, CutEdge = 1, Np = 1 + { 4,3,1 }, // Quart = 14, CutEdge = 2, Np = 0 + { 4,3,1 }, // Quart = 14, CutEdge = 2, Np = 1 + { 5,0,0 }, // Quart = 14, CutEdge = 3, Np = 0 + { 5,3,1 }, // Quart = 14, CutEdge = 3, Np = 1 + + { 0,0,0 }, // Quart = 15, CutEdge = 0, Np = 0 UNUSED + { 0,0,0 }, // Quart = 15, CutEdge = 0, Np = 1 UNUSED + { 0,0,0 }, // Quart = 15, CutEdge = 1, Np = 0 UNUSED + { 0,0,0 }, // Quart = 15, CutEdge = 1, Np = 1 UNUSED + { 0,0,0 }, // Quart = 15, CutEdge = 2, Np = 0 UNUSED + { 0,0,0 }, // Quart = 15, CutEdge = 2, Np = 1 UNUSED + { 0,0,0 }, // Quart = 15, CutEdge = 3, Np = 0 UNUSED + { 0,0,0 } // Quart = 15, CutEdge = 3, Np = 1 UNUSED +}; + +void BuilderZoneRegion::updateTrans (sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + if ((x < zoneRegion.getMinX()) || (x > zoneRegion.getMaxX()) || + (y < zoneRegion.getMinY()) || (y > zoneRegion.getMaxY())) + return; + + //if (!_Builder->getZoneMask(x,y)) + // return; + + // Interpret the transition info + x -= zoneRegion.getMinX (); + y -= zoneRegion.getMinY (); + sint32 m; + + // Calculate the number of material around with transition info + std::set matNameSet; + + ZonePosition zonePosTemp(x + zoneRegion.getMinX(), y + zoneRegion.getMinY(), m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + LigoData dataZoneTempOriginal = dataZoneTemp; + + for (m = 0; m < 4; ++m) + matNameSet.insert(dataZoneTemp.sharingMatNames[m]); + + if (matNameSet.size() == 1) + { + if (dataZoneTemp.sharingMatNames[0] == STRING_UNUSED) + { + del(x + zoneRegion.getMinX (), y + zoneRegion.getMinY ()); + // set (x+pBZR->getMinX (), y+pBZR->getMinY (), 0, 0, STRING_UNUSED, false); + return; + } + else + { + NLLIGO::CZoneBankElement *zoneBankElement2 = m_zoneBuilder->getZoneBank().getElementByZoneName(dataZoneTemp.zoneName); + if ((zoneBankElement != NULL) && (zoneBankElement2->getCategory("material") == dataZoneTemp.sharingMatNames[0])) + return; + + NLLIGO::CZoneBank &zoneBank = m_zoneBuilder->getZoneBank(); + zoneBank.resetSelection (); + zoneBank.addOrSwitch ("material", dataZoneTemp.sharingMatNames[0]); + zoneBank.addAndSwitch ("size", "1x1"); + std::vector vElts; + zoneBank.getSelection (vElts); + if (vElts.size() == 0) + return; + sint32 nRan = (sint32)(NLMISC::frand((float)vElts.size())); + NLMISC::clamp (nRan, (sint32)0, (sint32)(vElts.size()-1)); + zoneBankElement = vElts[nRan]; + nRan = (uint32)(NLMISC::frand(1.0) * 4); + NLMISC::clamp (nRan, (sint32)0, (sint32)3); + uint8 rot = (uint8)nRan; + nRan = (uint32)(NLMISC::frand(1.0) * 2); + NLMISC::clamp (nRan, (sint32)0, (sint32)1); + uint8 flip = (uint8)nRan; + + set(x + zoneRegion.getMinX(), y + zoneRegion.getMinY(), 0, 0, zoneBankElement->getName(), false); + setRot(x + zoneRegion.getMinX(), y + zoneRegion.getMinY(), rot); + setFlip(x + zoneRegion.getMinX(), y + zoneRegion.getMinY(), flip); + return; + } + } + + // No 2 materials so the transition system dont work + if (matNameSet.size() != 2) + return; + + std::set::iterator it = matNameSet.begin(); + std::string matA = *it; + ++it; + std::string matB = *it; + + NLLIGO::CZoneBank &zoneBank = m_zoneBuilder->getZoneBank(); + zoneBank.resetSelection (); + zoneBank.addOrSwitch("transname", matA + "-" + matB); + std::vector selection; + zoneBank.getSelection(selection); + if (selection.size() == 0) + { + std::string matTmp = matA; + matA = matB; + matB = matTmp; + zoneBank.resetSelection (); + zoneBank.addOrSwitch ("transname", matA + "-" + matB); + zoneBank.getSelection (selection); + } + + if (selection.size() == 0) + return; + + // Convert the sharingCutEdges and SharingNames to the num and type of transition + uint8 nQuart = 0; // 0-MatA 1-MatB + for (m = 0; m < 4; ++m) + if (dataZoneTemp.sharingMatNames[m] == matB) + nQuart |= (1 << m); + + if ((nQuart == 0) || (nQuart == 6) || + (nQuart == 9) || (nQuart == 15)) + return; // No transition for those types + + uint8 nCutEdge = 0; + uint8 nPosCorner = 0; + + // If up edge is cut write the cut position in nCutEdge bitfield (1->0, 2->1) + if ((nQuart == 4) || (nQuart == 5) || + (nQuart == 7) || (nQuart == 8) || + (nQuart == 10) || (nQuart == 11)) + { + if (dataZoneTemp.sharingCutEdges[0] == 2) + nCutEdge |= 1 << nPosCorner; + ++nPosCorner; + } + else + { + dataZoneTemp.sharingCutEdges[0] = 0; + } + + // Same for down edge + if ((nQuart == 1) || (nQuart == 2) || + (nQuart == 5) || (nQuart == 10) || + (nQuart == 13) || (nQuart == 14)) + { + if (dataZoneTemp.sharingCutEdges[1] == 2) + nCutEdge |= 1 << nPosCorner; + ++nPosCorner; + } + else + { + dataZoneTemp.sharingCutEdges[1] = 0; + } + + // Same for left edge + if ((nQuart == 1) || (nQuart == 3) || + (nQuart == 4) ||(nQuart == 11) || + (nQuart == 12) || (nQuart == 14)) + { + if (dataZoneTemp.sharingCutEdges[2] == 2) + nCutEdge |= 1 << nPosCorner; + ++nPosCorner; + } + else + { + dataZoneTemp.sharingCutEdges[2] = 0; + } + + // Same for right edge + if ((nQuart == 2) || (nQuart == 3) || + (nQuart == 7) || (nQuart == 8) || + (nQuart == 12) || (nQuart == 13)) + { + if (dataZoneTemp.sharingCutEdges[3] == 2) + nCutEdge |= 1 << nPosCorner; + ++nPosCorner; + } + else + { + dataZoneTemp.sharingCutEdges[3] = 0; + } + + nlassert (nPosCorner == 2); // If not this means that more than 2 edges are cut which is not possible + + STrans Trans, TransTmp1, TransTmp2; + + TransTmp1 = TranConvTable[nQuart * 8 + 2 * nCutEdge + 0]; + TransTmp2 = TranConvTable[nQuart * 8 + 2 * nCutEdge + 1]; + + // Choose one or the two + sint32 nTrans = (sint32)(NLMISC::frand(2.0f)); + NLMISC::clamp(nTrans, (sint32)0, (sint32)1); + if (nTrans == 0) + Trans = TransTmp1; + else + Trans = TransTmp2; + + zoneBank.addAndSwitch ("transnum", NLMISC::toString(Trans.Num)); + zoneBank.getSelection (selection); + + if (selection.size() > 0) + { + if (zoneBankElement != NULL) + { + dataZoneTemp.zoneName = zoneBankElement->getName(); + } + else + { + nTrans = (uint32)(NLMISC::frand (1.0) * selection.size()); + NLMISC::clamp(nTrans, (sint32)0, (sint32)(selection.size() - 1)); + dataZoneTemp.zoneName = selection[nTrans]->getName(); + } + dataZoneTemp.posX = dataZoneTemp.posY = 0; + dataZoneTemp.rot = Trans.Rot; + dataZoneTemp.flip = Trans.Flip; + } + + // Add modification landscape + if (dataZoneTempOriginal != dataZoneTemp) + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); +} + +std::string BuilderZoneRegion::getNextMatInTree (const std::string &matA, const std::string &matB) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + uint32 i, posA = 10000, posB = 10000; + + if (matA == matB) + return matA; + + for (i = 0; i < m_matTree.size(); ++i) + { + if (m_matTree[i].Name == matA) + posA = i; + if (m_matTree[i].Name == matB) + posB = i; + } + if ((posA == 10000) || (posB == 10000)) + return STRING_UNUSED; + + std::vector vTemp; + tryPath (posA, posB, vTemp); + if (vTemp.size() <= 1) + return STRING_UNUSED; + else + return m_matTree[vTemp[1]].Name; +} + +struct SNode +{ + sint32 NodePos, Dist, PrevNodePos; + + SNode() + { + NodePos = Dist = PrevNodePos = -1; + } +}; + +void BuilderZoneRegion::tryPath(uint32 posA, uint32 posB, std::vector &path) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + + // Build the adjascence matrix + std::vector matAdj; + sint32 numNodes = m_matTree.size(); + sint32 i, j, cost; + matAdj.resize(numNodes * numNodes, -1); + for (i = 0; i < numNodes; ++i) + for (j = 0; j < (sint32)m_matTree[i].Arcs.size(); ++j) + matAdj[i + m_matTree[i].Arcs[j] * numNodes] = 1; + + std::vector vNodes; // NodesPos == index + vNodes.resize (numNodes); + for (i = 0; i < numNodes; ++i) + vNodes[i].NodePos = i; + vNodes[posA].Dist = 0; + + std::queue qNodes; + qNodes.push (vNodes[posA]); + + while (qNodes.size() > 0) + { + SNode node = qNodes.front(); + qNodes.pop (); + + for (i = 0; i < numNodes; ++i) + { + cost = matAdj[node.NodePos + i * numNodes]; + if (cost != -1) + { + if ((vNodes[i].Dist == -1) || (vNodes[i].Dist > (cost + node.Dist))) + { + vNodes[i].Dist = cost + node.Dist; + vNodes[i].PrevNodePos = node.NodePos; + qNodes.push(vNodes[i]); + } + } + } + } + + // Get path length + i = posB; + j = 0; + while (i != -1) + { + ++j; + i = vNodes[i].PrevNodePos; + } + + // Write the path in the good order (from posA to posB) + path.resize(j); + i = posB; + while (i != -1) + { + --j; + path[j] = i; + i = vNodes[i].PrevNodePos; + } +} + +void BuilderZoneRegion::del(sint32 x, sint32 y, bool transition, void *pInternal) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + if (!m_zoneBuilder->getZoneMask(x, y)) + return; + + const std::string &nameZone = zoneRegion.getName(x, y); + + ToUpdate *pUpdate = reinterpret_cast(pInternal); + + NLLIGO::CZoneBankElement *zoneBankElement = m_zoneBuilder->getZoneBank().getElementByZoneName(nameZone); + if (zoneBankElement != NULL) + { + sint32 sizeX = zoneBankElement->getSizeX(), sizeY = zoneBankElement->getSizeY(); + sint32 posX = zoneRegion.getPosX (x, y), posY = zoneRegion.getPosY (x, y); + uint8 rot = zoneRegion.getRot (x, y); + uint8 flip = zoneRegion.getFlip (x, y); + sint32 i, j; + sint32 deltaX, deltaY; + + if (flip == 0) + { + switch (rot) + { + case 0: + deltaX = -posX; + deltaY = -posY; + break; + case 1: + deltaX = -(sizeY - 1 - posY); + deltaY = -posX; + break; + case 2: + deltaX = -(sizeX - 1 - posX); + deltaY = -(sizeY - 1 - posY); + break; + case 3: + deltaX = -posY; + deltaY = -(sizeX - 1 - posX); + break; + } + } + else + { + switch (rot) + { + case 0: + deltaX = -(sizeX - 1 - posX); + deltaY = -posY; + break; + case 1: + deltaX = -(sizeY - 1 - posY); + deltaY = -(sizeX - 1 - posX); + break; + case 2: + deltaX = -posX; + deltaY = -(sizeY - 1 - posY); + break; + case 3: + deltaX = -posY; + deltaY = -posX; + break; + } + } + + NLLIGO::SPiece mask; + mask.Tab.resize (sizeX * sizeY); + for(i = 0; i < sizeX * sizeY; ++i) + mask.Tab[i] = zoneBankElement->getMask()[i]; + mask.w = sizeX; + mask.h = sizeY; + mask.rotFlip (rot, flip); + + for (j = 0; j < mask.h; ++j) + for (i = 0; i < mask.w; ++i) + if (mask.Tab[i + j * mask.w]) + { + set(x + deltaX + i, y + deltaY + j, 0, 0, STRING_UNUSED, true); + setRot(x + deltaX + i, y + deltaY + j, 0); + setFlip(x + deltaX + i, y + deltaY + j, 0); + if (pUpdate != NULL) + { + pUpdate->add(this, x + deltaX + i, y + deltaY + j, ""); + } + } + if (!transition) + reduceMin (); + } + else + { + if ((x < zoneRegion.getMinX()) || (x > zoneRegion.getMaxX()) || + (y < zoneRegion.getMinY()) || (y > zoneRegion.getMaxY())) + return; + + ZonePosition zonePosTemp(x, y, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + LigoData dataZoneTempOriginal = dataZoneTemp; + + dataZoneTemp.zoneName = STRING_UNUSED; + dataZoneTemp.posX = 0; + dataZoneTemp.posY = 0; + + for (uint32 i = 0; i < 4; ++i) + { + dataZoneTemp.sharingMatNames[i] = STRING_UNUSED; + dataZoneTemp.sharingCutEdges[i] = 0; + } + + // Add modification landscape + if (dataZoneTempOriginal != dataZoneTemp) + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + + } +} + +void BuilderZoneRegion::move (sint32 x, sint32 y) +{ + m_zoneBuilder->actionLigoMove(m_regionId, x, y); +} + +uint32 BuilderZoneRegion::countZones () +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + sint32 x, y; + + uint32 counter = 0; + + for (y = zoneRegion.getMinY (); y <= zoneRegion.getMaxY (); ++y) + for (x = zoneRegion.getMinX (); x <= zoneRegion.getMaxX (); ++x) + if (zoneRegion.getName (x, y) != STRING_UNUSED) + ++counter; + + return counter; +} + +void BuilderZoneRegion::set(sint32 x, sint32 y, sint32 posX, sint32 posY, + const std::string &zoneName, bool transition) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + + // Do we need to resize ? + if ((x < zoneRegion.getMinX()) || (x > zoneRegion.getMaxX()) || + (y < zoneRegion.getMinY()) || (y > zoneRegion.getMaxY())) + { + sint32 newMinX = (x < zoneRegion.getMinX() ? x: zoneRegion.getMinX()), newMinY = (y < zoneRegion.getMinY() ? y: zoneRegion.getMinY()); + sint32 newMaxX = (x > zoneRegion.getMaxX() ? x: zoneRegion.getMaxX()), newMaxY = (y > zoneRegion.getMaxY() ? y: zoneRegion.getMaxY()); + + resize(newMinX, newMaxX, newMinY, newMaxY); + } + + ZonePosition zonePosTemp(x, y, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + LigoData dataZoneTempOriginal = dataZoneTemp; + + dataZoneTemp.zoneName = zoneName; + dataZoneTemp.posX = (uint8)posX; + dataZoneTemp.posY = (uint8)posY; + + if (!transition) + { + NLLIGO::CZoneBankElement *zoneBankElem = m_zoneBuilder->getZoneBank().getElementByZoneName(zoneName); + if (zoneBankElem == NULL) + return; + + const std::string &matName = zoneBankElem->getCategory ("material"); + if (matName == STRING_NO_CAT_TYPE) + return; + for (uint32 i = 0; i < 4; ++i) + { + dataZoneTemp.sharingMatNames[i] = matName; + dataZoneTemp.sharingCutEdges[i] = 0; + } + + // Add modification landscape + if (dataZoneTempOriginal != dataZoneTemp) + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + + BuilderZoneRegion *builderZoneRegion = this; + ZonePosition zonePosU; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion, x - 1, y - 1)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if (data.sharingMatNames[3] != matName) + { + data.sharingMatNames[3] = matName; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + } + builderZoneRegion = this; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion, x, y - 1)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if ((data.sharingMatNames[2] != matName) || (data.sharingMatNames[3] != matName)) + { + data.sharingMatNames[2] = matName; + data.sharingMatNames[3] = matName; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + } + builderZoneRegion = this; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion, x + 1, y - 1)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if (data.sharingMatNames[2] != matName) + { + data.sharingMatNames[2] = matName; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + } + builderZoneRegion = this; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion, x - 1, y)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if ((data.sharingMatNames[1] != matName) || (data.sharingMatNames[3] != matName)) + { + data.sharingMatNames[1] = matName; + data.sharingMatNames[3] = matName; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + } + builderZoneRegion = this; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion, x + 1, y)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if ((data.sharingMatNames[0] != matName) || (data.sharingMatNames[2] != matName)) + { + data.sharingMatNames[0] = matName; + data.sharingMatNames[2] = matName; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + } + builderZoneRegion = this; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion, x - 1, y + 1)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if (data.sharingMatNames[1] != matName) + { + data.sharingMatNames[1] = matName; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + } + builderZoneRegion = this; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion, x, y + 1)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if ((data.sharingMatNames[0] != matName) || (data.sharingMatNames[1] != matName)) + { + data.sharingMatNames[0] = matName; + data.sharingMatNames[1] = matName; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + } + builderZoneRegion = this; + if (m_zoneBuilder->getZoneAmongRegions(zonePosU, builderZoneRegion, x + 1, y + 1)) + { + LigoData data; + m_zoneBuilder->ligoData(data, zonePosU); + if (data.sharingMatNames[0] != matName) + { + data.sharingMatNames[0] = matName; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(data, zonePosU); + } + } + } + else + { + // Add modification landscape + if (dataZoneTempOriginal != dataZoneTemp) + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + } +} + +void BuilderZoneRegion::setRot (sint32 x, sint32 y, uint8 rot) +{ + ZonePosition zonePosTemp(x, y, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + if (dataZoneTemp.rot != rot) + { + dataZoneTemp.rot = rot; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + } +} + +void BuilderZoneRegion::setFlip(sint32 x, sint32 y, uint8 flip) +{ + ZonePosition zonePosTemp(x, y, m_regionId); + LigoData dataZoneTemp; + m_zoneBuilder->ligoData(dataZoneTemp, zonePosTemp); + if (dataZoneTemp.flip != flip) + { + dataZoneTemp.flip = flip; + + // Add modification landscape + m_zoneBuilder->actionLigoTile(dataZoneTemp, zonePosTemp); + } +} + + +void BuilderZoneRegion::reduceMin () +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + sint32 i, j; + + sint32 newMinX = zoneRegion.getMinX(), newMinY = zoneRegion.getMinY (); + sint32 newMaxX = zoneRegion.getMaxX(), newMaxY = zoneRegion.getMaxY (); + bool bCanSuppr; + + // Reduce the MinY + while (true) + { + if (newMinY == newMaxY) + break; + j = newMinY; + bCanSuppr = true; + for (i = newMinX; i <= newMaxX; ++i) + { + std::string str = zoneRegion.getName (i, j) ; + if (!str.empty() && (str != STRING_UNUSED)) + { + bCanSuppr = false; + break; + } + } + if (bCanSuppr) + ++newMinY; + else + break; + } + + // Reduce the MaxY + while (true) + { + if (newMinY == newMaxY) + break; + j = newMaxY; + bCanSuppr = true; + for (i = newMinX; i <= newMaxX; ++i) + { + std::string str = zoneRegion.getName (i, j) ; + if (!str.empty() && (str != STRING_UNUSED)) + { + bCanSuppr = false; + break; + } + } + if (bCanSuppr) + --newMaxY; + else + break; + } + + // Reduce the MinX + while (true) + { + if (newMinX == newMaxX) + break; + i = newMinX; + bCanSuppr = true; + for (j = newMinY; j <= newMaxY; ++j) + { + std::string str = zoneRegion.getName (i, j) ; + if (!str.empty() && (str != STRING_UNUSED)) + { + bCanSuppr = false; + break; + } + } + if (bCanSuppr) + ++newMinX; + else + break; + } + + // Reduce the MaxX + while (true) + { + if (newMinX == newMaxX) + break; + i = newMaxX; + bCanSuppr = true; + for (j = newMinY; j <= newMaxY; ++j) + { + std::string str = zoneRegion.getName (i, j) ; + if (!str.empty() && (str != STRING_UNUSED)) + { + bCanSuppr = false; + break; + } + } + if (bCanSuppr) + --newMaxX; + else + break; + } + + if ((newMinX != zoneRegion.getMinX ()) || + (newMinY != zoneRegion.getMinY ()) || + (newMaxX != zoneRegion.getMaxX ()) || + (newMaxY != zoneRegion.getMaxY ())) + { + resize(newMinX, newMaxX, newMinY, newMaxY); + } +} + +uint BuilderZoneRegion::getRegionId() const +{ + return m_regionId; +} + +void BuilderZoneRegion::resize (sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY) +{ + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + if ((zoneRegion.getMinX ()!= newMinX) || + (zoneRegion.getMaxX ()!= newMaxX) || + (zoneRegion.getMinY ()!= newMinY) || + (zoneRegion.getMaxY ()!= newMaxY)) + { + m_zoneBuilder->actionLigoResize(m_regionId, newMinX, newMaxX, newMinY, newMaxY); + } +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h index 158c72715..7322e47b6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h @@ -1,33 +1,101 @@ -// 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 BUILDER_ZONE_REGION_H -#define BUILDER_ZONE_REGION_H - -// Project includes - -// NeL includes -#include - -// Qt includes - -namespace LandscapeEditor -{ - -} /* namespace LandscapeEditor */ - -#endif // BUILDER_ZONE_REGION_H +// 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 BUILDER_ZONE_REGION_H +#define BUILDER_ZONE_REGION_H + +// Project includes + +// NeL includes +#include +#include + +// STL includes +#include +#include +#include + +// Qt includes + +namespace LandscapeEditor +{ +class ZoneBuilder; + +// CZoneRegion contains informations about the zones painted +class BuilderZoneRegion +{ +public: + + BuilderZoneRegion(uint regionId); + + // New interface + bool init(ZoneBuilder *zoneBuilder, std::string &error); + void add(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement); + void invertCutEdge(sint32 x, sint32 y, uint8 cePos); + void cycleTransition(sint32 x, sint32 y); + bool addNotPropagate(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement); + + /// Brutal adding a zone over empty space do not propagate in any way -> can result + /// in inconsistency when trying the propagation mode + void addForce (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement); + void del(sint32 x, sint32 y, bool transition = false, void *pInternal = NULL); + void move(sint32 x, sint32 y); + uint32 countZones(); + void reduceMin(); + uint getRegionId() const; + +private: + + // An element of the graph + struct SMatNode + { + std::string Name; + // Position in the tree (vector of nodes) + std::vector Arcs; + }; + + void addTransition(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement); + + void addToUpdateAndCreate(BuilderZoneRegion* builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2); + + void putTransitions(sint32 x, sint32 y, const NLLIGO::SPiece &mask, const std::string &matName, void *pInternal); + void updateTrans(sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement = NULL); + + std::string getNextMatInTree(const std::string &matA, const std::string &matB); + + /// Find the fastest way between posA and posB in the MatTree (Dijkstra) + void tryPath(uint32 posA, uint32 posB, std::vector &path); + + void set(sint32 x, sint32 y, sint32 posX, sint32 posY, const std::string &zoneName, bool transition=false); + void setRot(sint32 x, sint32 y, uint8 rot); + void setFlip(sint32 x, sint32 y, uint8 flip); + void resize(sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY); + + uint m_regionId; + + // To use the global mask + ZoneBuilder *m_zoneBuilder; + + // The tree of transition between materials + std::vector m_matTree; + + bool m_firstInit; +}; + +} /* namespace LandscapeEditor */ + +#endif // BUILDER_ZONE_REGION_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp index 84d59ba8d..95f030631 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp @@ -62,54 +62,111 @@ void NewLandscapeCommand::redo() { } -AddLigoTileCommand::AddLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent) +LigoTileCommand::LigoTileCommand(const LigoData &data, const ZonePosition &zonePos, + ZoneBuilder *zoneBuilder, LandscapeScene *scene, + QUndoCommand *parent) : QUndoCommand(parent), - m_item(0), + m_zoneBuilder(zoneBuilder), m_scene(scene) { - m_ligoData = data; + // Backup position + m_zonePos = zonePos; + + // Backup new data + m_newLigoData = data; + + // Backup old data + m_zoneBuilder->ligoData(m_oldLigoData, m_zonePos); } -AddLigoTileCommand::~AddLigoTileCommand() +LigoTileCommand::~LigoTileCommand() { } -void AddLigoTileCommand::undo() +void LigoTileCommand::undo () { - m_scene->removeItem(m_item); - delete m_item; - m_item = 0; + m_zoneBuilder->setLigoData(m_oldLigoData, m_zonePos); + m_scene->createZoneItem(m_oldLigoData, m_zonePos); } -void AddLigoTileCommand::redo() +void LigoTileCommand::redo () { - m_item = m_scene->createZoneItem(m_ligoData); - setText(QObject::tr("Add tile(%1, %2)").arg(m_ligoData.PosX).arg(m_ligoData.PosY)); + m_zoneBuilder->setLigoData(m_newLigoData, m_zonePos); + m_scene->createZoneItem(m_newLigoData, m_zonePos); } -DelLigoTileCommand::DelLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent) +LigoResizeCommand::LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX, + sint32 newMinY, sint32 newMaxY, ZoneBuilder *zoneBuilder, + QUndoCommand *parent) : QUndoCommand(parent), - m_item(0), - m_scene(scene) + m_zoneBuilder(zoneBuilder) { - m_ligoData = data; + m_index = index; + m_newMinX = newMinX; + m_newMaxX = newMaxX; + m_newMinY = newMinY; + m_newMaxY = newMaxY; + + // Backup old region zone + m_oldZoneRegion = m_zoneBuilder->zoneRegion(m_index)->zoneRegion(); } -DelLigoTileCommand::~DelLigoTileCommand() +LigoResizeCommand::~LigoResizeCommand() { } -void DelLigoTileCommand::undo() +void LigoResizeCommand::undo () { - m_item = m_scene->createZoneItem(m_ligoData); + // Restore old region zone + m_zoneBuilder->zoneRegion(m_index)->setZoneRegion(m_oldZoneRegion); } -void DelLigoTileCommand::redo() +void LigoResizeCommand::redo () { - m_item = m_scene->itemAt(m_ligoData.PosX * m_scene->cellSize(), m_ligoData.PosY * m_scene->cellSize()); - delete m_item; - m_item = 0; - setText(QObject::tr("Del tile(%1, %2)").arg(m_ligoData.PosX).arg(m_ligoData.PosY)); + // Get the zone region + NLLIGO::CZoneRegion ®ion = m_zoneBuilder->zoneRegion(m_index)->zoneRegion(); + + sint32 i, j; + std::vector newZones; + newZones.resize((1 + m_newMaxX - m_newMinX) * (1 + m_newMaxY - m_newMinY)); + + sint32 newStride = 1 + m_newMaxX - m_newMinX; + sint32 Stride = 1 + region.getMaxX() - region.getMinX(); + + for (j = m_newMinY; j <= m_newMaxY; ++j) + for (i = m_newMinX; i <= m_newMaxX; ++i) + { + // Ref on the new value + LigoData &data = newZones[(i - m_newMinX) + (j - m_newMinY) * newStride]; + + // In the old array ? + if ((i >= region.getMinX()) && (i <= region.getMaxX()) && + (j >= region.getMinY()) && (j <= region.getMaxY())) + { + // Backup values + m_zoneBuilder->ligoData(data, ZonePosition(i, j, m_index)); + } + } + region.resize(m_newMinX, m_newMaxX, m_newMinY, m_newMaxY); + + for (j = m_newMinY; j <= m_newMaxY; ++j) + for (i = m_newMinX; i <= m_newMaxX; ++i) + { + // Ref on the new value + const LigoData &data = newZones[(i - m_newMinX) + (j - m_newMinY) * newStride]; + + region.setName(i, j, data.zoneName); + region.setPosX(i, j, data.posX); + region.setPosY(i, j, data.posY); + region.setRot(i, j, data.rot); + region.setFlip(i, j, data.flip); + uint k; + for (k = 0; k < 4; k++) + { + region.setSharingMatNames(i, j, k, data.sharingMatNames[k]); + region.setSharingCutEdges(i, j, k, data.sharingCutEdges[k]); + } + } } } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h index 7bbd1bd96..e7a39d8b1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h @@ -56,36 +56,64 @@ public: private: }; -class AddLigoTileCommand: public QUndoCommand +// Modify the landscape +class LigoTileCommand: public QUndoCommand { public: - AddLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent = 0); - virtual ~AddLigoTileCommand(); + LigoTileCommand(const LigoData &data, const ZonePosition &zonePos, + ZoneBuilder *zoneBuilder, LandscapeScene *scene, + QUndoCommand *parent = 0); + virtual ~LigoTileCommand(); virtual void undo(); virtual void redo(); private: - - LigoData m_ligoData; - QGraphicsItem *m_item; + ZonePosition m_zonePos; + LigoData m_newLigoData; + LigoData m_oldLigoData; + ZoneBuilder *m_zoneBuilder; LandscapeScene *m_scene; }; - -class DelLigoTileCommand: public QUndoCommand +/* +// Move the landscape +class LigoMoveCommand: public QUndoCommand { public: - DelLigoTileCommand(const LigoData &data, LandscapeScene *scene, QUndoCommand *parent = 0); - virtual ~DelLigoTileCommand(); + + LigoMoveCommand(int index, sint32 deltaX, sint32 deltaY, ZoneBuilder *zoneBuilder, QUndoCommand *parent = 0); + virtual ~LigoMoveCommand(); + + virtual void undo(); + virtual void redo(); +private: + + int m_index; + sint32 m_deltaX; + sint32 m_deltaY; + ZoneBuilder *m_zoneBuilder; +}; +*/ +// Modify the landscape +class LigoResizeCommand: public QUndoCommand +{ +public: + LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX, + sint32 newMinY, sint32 newMaxY, ZoneBuilder *zoneBuilder, + QUndoCommand *parent = 0); + virtual ~LigoResizeCommand(); virtual void undo(); virtual void redo(); private: - - LigoData m_ligoData; - QGraphicsItem *m_item; - LandscapeScene *m_scene; + int m_index; + sint32 m_newMinX; + sint32 m_newMaxX; + sint32 m_newMinY; + sint32 m_newMaxY; + NLLIGO::CZoneRegion m_oldZoneRegion; + ZoneBuilder *m_zoneBuilder; }; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 5ec3f6196..0c38adbf6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -19,6 +19,7 @@ #include "landscape_editor_window.h" #include "landscape_editor_constants.h" #include "builder_zone.h" +#include "zone_region_editor.h" #include "landscape_scene.h" #include "project_settings_dialog.h" #include "snapshot_dialog.h" @@ -45,12 +46,14 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); - m_zoneBuilder = new ZoneBuilder(); - m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); + m_landscapeScene = new LandscapeScene(this); + + m_zoneBuilder = new ZoneBuilder(m_ui.zoneListWidget, m_landscapeScene, m_undoStack); + m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", true); m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); m_ui.zoneListWidget->updateUi(); - m_landscapeScene = new LandscapeScene(m_undoStack, m_ui.zoneListWidget, m_zoneBuilder, this); + m_landscapeScene->setZoneBuilder(m_zoneBuilder); m_ui.graphicsView->setScene(m_landscapeScene); //m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer))); m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers))); @@ -88,11 +91,14 @@ void LandscapeEditorWindow::open() _lastDir = QFileInfo(list.front()).absolutePath(); Q_FOREACH(QString fileName, fileNames) { - m_zoneRegionEditor.load(fileName.toStdString()); - m_landscapeScene->processZoneRegion(m_zoneRegionEditor.zoneRegion()); - m_landscapeScene->setCurrentZoneRegion(&m_zoneRegionEditor.zoneRegion()); - m_ui.graphicsView->centerOn(m_zoneRegionEditor.zoneRegion().getMinX() * m_landscapeScene->cellSize(), - abs(m_zoneRegionEditor.zoneRegion().getMinY()) * m_landscapeScene->cellSize()); + int id = m_zoneBuilder->createZoneRegion(); + ZoneRegionEditor *zoneRegion = m_zoneBuilder->zoneRegion(id); + zoneRegion->load(fileName.toStdString()); + m_landscapeScene->processZoneRegion(zoneRegion->zoneRegion()); + m_ui.graphicsView->centerOn(zoneRegion->zoneRegion().getMinX() * m_landscapeScene->cellSize(), + abs(zoneRegion->zoneRegion().getMinY()) * m_landscapeScene->cellSize()); + + m_zoneBuilder->setCurrentZoneRegion(id); } } setCursor(Qt::ArrowCursor); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index 311a65013..3a35b90f4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -20,7 +20,6 @@ // Project includes #include "ui_landscape_editor_window.h" -#include "zone_region_editor.h" // Qt includes #include @@ -55,8 +54,6 @@ private: void readSettings(); void writeSettings(); - ZoneRegionEditor m_zoneRegionEditor; - LandscapeScene *m_landscapeScene; ZoneBuilder *m_zoneBuilder; QUndoStack *m_undoStack; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 96ad0879b..3aa2bbc9a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -17,9 +17,6 @@ // Project includes #include "landscape_scene.h" -#include "builder_zone.h" -#include "landscape_actions.h" -#include "list_zones_widget.h" // NeL includes #include @@ -32,12 +29,9 @@ namespace LandscapeEditor { -LandscapeScene::LandscapeScene(QUndoStack *undoStack, ListZonesWidget *listZonesWidget, ZoneBuilder *zoneBuilder, QObject *parent) +LandscapeScene::LandscapeScene(QObject *parent) : QGraphicsScene(parent), - m_undoStack(undoStack), - m_listZonesWidget(listZonesWidget), - m_zoneBuilder(zoneBuilder), - m_zoneRegion(0) + m_zoneBuilder(0) { m_cellSize = 160; } @@ -51,20 +45,34 @@ int LandscapeScene::cellSize() const return m_cellSize; } -QGraphicsItem *LandscapeScene::createZoneItem(const LigoData &data) +void LandscapeScene::setZoneBuilder(ZoneBuilder *zoneBuilder) { + m_zoneBuilder = zoneBuilder; +} + +QGraphicsItem *LandscapeScene::createZoneItem(const LigoData &data, const ZonePosition &zonePos) +{ + if (data.zoneName == STRING_UNUSED) + return createEmptyZoneItem(zonePos); + + if ((m_zoneBuilder == 0) || (data.zoneName.empty()) || + (data.posX != 0) || (data.posY != 0)) + return 0; + + checkUnderZone(data, zonePos); + // Get image from pixmap database - QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.ZoneName.c_str())); + QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.zoneName.c_str())); if (pixmap == 0) return 0; // Rotate the image counterclockwise QMatrix matrix; - matrix.rotate(-data.Rot * 90.0); + matrix.rotate(-data.rot * 90.0); QGraphicsPixmapItem *item; - if (data.Flip == 0) + if (data.flip == 0) { item = new QGraphicsPixmapItem(pixmap->transformed(matrix, Qt::SmoothTransformation), 0, this); } @@ -79,135 +87,156 @@ QGraphicsItem *LandscapeScene::createZoneItem(const LigoData &data) item->setTransformationMode(Qt::SmoothTransformation); // Set position graphics item with offset for large piece - NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.ZoneName); - item->setPos(data.PosX * m_cellSize, (abs(data.PosY) - zoneBankItem->getSizeY() + 1) * m_cellSize); + NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName); + item->setPos(zonePos.x * m_cellSize, (abs(zonePos.y) - zoneBankItem->getSizeY() + 1) * m_cellSize); // The size graphics item should be equal or proportional m_cellSize - item->setScale(m_cellSize / 256.0); - - // add debug info - QGraphicsSimpleTextItem *itemText = addSimpleText(QString("%1,%2 R-%3 F-%4"). - arg(data.PosX).arg(data.PosY). - arg(data.Rot * 90.0). - arg(data.Flip), - QFont("Helvetica [Cronyx]", 14)); - - itemText->setZValue(2); - itemText->setPos(data.PosX * m_cellSize + 10, (abs(data.PosY) - zoneBankItem->getSizeY() + 1) * m_cellSize + 10); - itemText->setBrush(QBrush(Qt::white)); + item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); return item; } +QGraphicsItem *LandscapeScene::createEmptyZoneItem(const ZonePosition &zonePos) +{ + if (m_zoneBuilder == 0) + return 0; + + deleteZoneItem(zonePos); + + // Get image from pixmap database + QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED)); + if (pixmap == 0) + return 0; + + QGraphicsPixmapItem *item = new QGraphicsPixmapItem(*pixmap, 0, this); + + // Enable bilinear filtering + item->setTransformationMode(Qt::SmoothTransformation); + + // Set position graphics item + item->setPos(zonePos.x * m_cellSize, abs(int(zonePos.y)) * m_cellSize); + + // The size graphics item should be equal or proportional m_cellSize + item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); + + return item; +} + +void LandscapeScene::deleteZoneItem(const ZonePosition &zonePos) +{ + QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize); + if (item != 0) + { + removeItem(item); + delete item; + } +} + void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) { for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) { for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) { + nlinfo(QString("%1 %2 %3").arg(i).arg(j).arg(zoneRegion.getName(i, j).c_str()).toStdString().c_str()); std::string zoneName = zoneRegion.getName(i, j); - if ((!zoneName.empty()) && - (zoneName != STRING_UNUSED) && - (zoneRegion.getPosX(i, j) == 0) && - (zoneRegion.getPosY(i, j) == 0)) + if (zoneName == STRING_UNUSED) + { + ZonePosition zonePos(i, j, -1); + QGraphicsItem *item = createEmptyZoneItem(zonePos); + } + else if (!zoneName.empty()) { LigoData data; - data.PosX = i; - data.PosY = j; - data.ZoneName = zoneName; - data.Rot = zoneRegion.getRot(i, j); - data.Flip = zoneRegion.getFlip(i, j); - QGraphicsItem *item = createZoneItem(data); + ZonePosition zonePos(i, j, -1); + data.zoneName = zoneName; + data.rot = zoneRegion.getRot(i, j); + data.flip = zoneRegion.getFlip(i, j); + data.posX = zoneRegion.getPosX(i, j); + data.posY = zoneRegion.getPosY(i, j); + QGraphicsItem *item = createZoneItem(data, zonePos); } } } } -void LandscapeScene::setCurrentZoneRegion(NLLIGO::CZoneRegion *zoneRegion) -{ - m_zoneRegion = zoneRegion; -} - void LandscapeScene::snapshot(const QString &fileName, int sizeSource) { - if (m_zoneRegion == 0) - return; + /* if (m_zoneRegion == 0) + return; - sint32 regionMinX = m_zoneRegion->getMinX(); - sint32 regionMaxX = m_zoneRegion->getMaxX(); - sint32 regionMinY = m_zoneRegion->getMinY(); - sint32 regionMaxY = m_zoneRegion->getMaxY(); + sint32 regionMinX = m_zoneRegion->getMinX(); + sint32 regionMaxX = m_zoneRegion->getMaxX(); + sint32 regionMinY = m_zoneRegion->getMinY(); + sint32 regionMaxY = m_zoneRegion->getMaxY(); - int regionWidth = (regionMaxX - regionMinX + 1); - int regionHeight = (regionMaxY - regionMinY + 1); + int regionWidth = (regionMaxX - regionMinX + 1); + int regionHeight = (regionMaxY - regionMinY + 1); - snapshot(fileName, regionWidth * sizeSource, regionHeight * sizeSource); + snapshot(fileName, regionWidth * sizeSource, regionHeight * sizeSource); + */ } void LandscapeScene::snapshot(const QString &fileName, int width, int height) { - if (m_zoneRegion == 0) + if (m_zoneBuilder == 0) return; - sint32 regionMinX = m_zoneRegion->getMinX(); - sint32 regionMaxX = m_zoneRegion->getMaxX(); - sint32 regionMinY = m_zoneRegion->getMinY(); - sint32 regionMaxY = m_zoneRegion->getMaxY(); + /* if (m_zoneRegion == 0) + return; - int regionWidth = (regionMaxX - regionMinX + 1); - int regionHeight = (regionMaxY - regionMinY + 1); + sint32 regionMinX = m_zoneRegion->getMinX(); + sint32 regionMaxX = m_zoneRegion->getMaxX(); + sint32 regionMinY = m_zoneRegion->getMinY(); + sint32 regionMaxY = m_zoneRegion->getMaxY(); - QImage image(width, height, QImage::Format_RGB888); - QPainter painter(&image); - painter.setRenderHint(QPainter::Antialiasing, true); + int regionWidth = (regionMaxX - regionMinX + 1); + int regionHeight = (regionMaxY - regionMinY + 1); - // add white background - painter.setBrush(QBrush(Qt::white)); - painter.setPen(Qt::NoPen); - painter.drawRect(0, 0, width, height); + QImage image(width, height, QImage::Format_RGB888); + QPainter painter(&image); + painter.setRenderHint(QPainter::Antialiasing, true); - render(&painter, QRectF(0, 0, width, height), - QRectF(regionMinX * m_cellSize, abs(regionMaxY) * m_cellSize, regionWidth * m_cellSize, regionHeight * m_cellSize)); + // add white background + painter.setBrush(QBrush(Qt::white)); + painter.setPen(Qt::NoPen); + painter.drawRect(0, 0, width, height); - image.save(fileName); + render(&painter, QRectF(0, 0, width, height), + QRectF(regionMinX * m_cellSize, abs(regionMaxY) * m_cellSize, regionWidth * m_cellSize, regionHeight * m_cellSize)); + image.save(fileName); + */ } void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { + if (m_zoneBuilder == 0) + return; + qreal x = mouseEvent->scenePos().rx(); qreal y = mouseEvent->scenePos().ry(); if ((x < 0) || (y < 0)) return; + sint32 posX = sint32(floor(x / m_cellSize)); + sint32 posY = sint32(-floor(y / m_cellSize)); + if (mouseEvent->button() == Qt::LeftButton) - { - // Add new zone brick - LigoData ligoData = m_listZonesWidget->currentLigoData(); - if (ligoData.ZoneName == "") - return; + m_zoneBuilder->addZone(posX, posY); + else if (mouseEvent->button() == Qt::RightButton) + m_zoneBuilder->delZone(posX, posY); - ligoData.PosX = int(floor(x / m_cellSize)); - ligoData.PosY = int(-floor(y / m_cellSize)); - - AddLigoTileCommand *action = new AddLigoTileCommand(ligoData, this); - m_undoStack->push(action); - } - - /*if (mouseEvent->button() == Qt::RightButton) - { - // Delete zone brick - LigoData ligoData; - - ligoData.PosX = int(floor(x / m_cellSize)); - ligoData.PosY = int(floor(y / m_cellSize)); - ligoData.ZoneName = m_zoneRegion->getName(ligoData.PosX, -ligoData.PosY); - ligoData.Flip = m_zoneRegion->getFlip(ligoData.PosX, -ligoData.PosY); - ligoData.Rot = m_zoneRegion->getRot(ligoData.PosX, -ligoData.PosY); - DelLigoTileCommand *action = new DelLigoTileCommand(ligoData, this); - m_undoStack->push(action); - }*/ QGraphicsScene::mousePressEvent(mouseEvent); } +void LandscapeScene::checkUnderZone(const LigoData &data, const ZonePosition &zonePos) +{ +// NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName); +// uint8 sizeX = zoneBankItem->getSizeX(); +// uint8 sizeY = zoneBankItem->getSizeY(); +// std::vector &mask = zoneBankItem->getMask(); + deleteZoneItem(zonePos); +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index 2af45bf4b..ea314faac 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -19,6 +19,8 @@ #define LANDSCAPE_SCENE_H // Project includes +#include "zone_region_editor.h" +#include "builder_zone.h" // NeL includes #include @@ -26,54 +28,25 @@ // Qt includes #include #include -#include namespace LandscapeEditor { -class ZoneBuilder; -class ListZonesWidget; - -// Data -struct LigoData -{ - sint32 PosX; - sint32 PosY; - uint8 Rot; - uint8 Flip; - std::string ZoneName; - std::string SharingMatNames[4]; - uint8 SharingCutEdges[4]; - bool operator!= (const LigoData& other) const - { - return (PosX != other.PosX) || - (PosY != other.PosY) || - (Rot != other.Rot) || - (Flip != other.Flip) || - (ZoneName != other.ZoneName) || - (SharingMatNames[0] != other.SharingMatNames[0]) || - (SharingMatNames[1] != other.SharingMatNames[1]) || - (SharingMatNames[2] != other.SharingMatNames[2]) || - (SharingMatNames[3] != other.SharingMatNames[3]) || - (SharingCutEdges[0] != other.SharingCutEdges[0]) || - (SharingCutEdges[1] != other.SharingCutEdges[1]) || - (SharingCutEdges[2] != other.SharingCutEdges[2]) || - (SharingCutEdges[3] != other.SharingCutEdges[3]); - } -}; class LandscapeScene : public QGraphicsScene { Q_OBJECT public: - LandscapeScene(QUndoStack *undoStack, ListZonesWidget *listZonesWidget, ZoneBuilder *zoneBuilder, QObject *parent = 0); + LandscapeScene(QObject *parent = 0); virtual ~LandscapeScene(); int cellSize() const; + void setZoneBuilder(ZoneBuilder *zoneBuilder); - QGraphicsItem *createZoneItem(const LigoData &data); + QGraphicsItem *createZoneItem(const LigoData &data, const ZonePosition &zonePos); + QGraphicsItem *createEmptyZoneItem(const ZonePosition &zonePos); + void deleteZoneItem(const ZonePosition &zonePos); void processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); - void setCurrentZoneRegion(NLLIGO::CZoneRegion *zoneRegion); void snapshot(const QString &fileName, int sizeSource); void snapshot(const QString &fileName, int width, int height); @@ -82,12 +55,10 @@ protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); private: + void checkUnderZone(const LigoData &data, const ZonePosition &zonePos); int m_cellSize; - ListZonesWidget *m_listZonesWidget; - QUndoStack *m_undoStack; ZoneBuilder *m_zoneBuilder; - NLLIGO::CZoneRegion *m_zoneRegion; }; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp index 66d31479b..7ce3f5421 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp @@ -18,6 +18,7 @@ // Project includes #include "list_zones_widget.h" #include "list_zones_model.h" +#include "builder_zone.h" // NeL includes #include @@ -100,17 +101,34 @@ void ListZonesWidget::updateUi() m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase()); } -LigoData ListZonesWidget::currentLigoData() const +QString ListZonesWidget::currentZoneName() const { - LigoData ligoData; - ligoData.ZoneName = ""; + QString zoneName = ""; QModelIndex index = m_ui.listView->currentIndex(); if (index.isValid()) - ligoData.ZoneName = index.data().toString().toStdString(); + zoneName = index.data().toString(); - ligoData.Rot = m_ui.rotComboBox->currentIndex(); - ligoData.Flip = m_ui.flipComboBox->currentIndex(); - return ligoData; + return zoneName; +} + +int ListZonesWidget::currentRot() const +{ + return m_ui.rotComboBox->currentIndex(); +} + +int ListZonesWidget::currentFlip() const +{ + return m_ui.flipComboBox->currentIndex(); +} + +bool ListZonesWidget::isNotPropogate() const +{ + return m_ui.propogateCheckBox->isChecked(); +} + +bool ListZonesWidget::isForce() const +{ + return m_ui.forceCheckBox->isChecked(); } void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h index 8ad5d4c25..c35e7b0fa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -20,8 +20,6 @@ // Project includes #include "ui_list_zones_widget.h" -#include "builder_zone.h" -#include "landscape_scene.h" // NeL includes @@ -30,6 +28,7 @@ namespace LandscapeEditor { class ListZonesModel; +class ZoneBuilder; /** @class ZoneListWidget @@ -46,7 +45,11 @@ public: void updateUi(); void setZoneBuilder(ZoneBuilder *zoneBuilder); - LigoData currentLigoData() const; + QString currentZoneName() const; + int currentRot() const; + int currentFlip() const; + bool isNotPropogate() const; + bool isForce() const; Q_SIGNALS: private Q_SLOTS: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp index a3f109ada..045b342fd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp @@ -30,6 +30,23 @@ namespace LandscapeEditor { +LigoData::LigoData() +{ + posX = 0; + posY = 0; + zoneName = ""; + rot = 0; + flip = 0; + sharingMatNames[0] = ""; + sharingMatNames[1] = ""; + sharingMatNames[2] = ""; + sharingMatNames[3] = ""; + sharingCutEdges[0] = 0; + sharingCutEdges[1] = 0; + sharingCutEdges[2] = 0; + sharingCutEdges[3] = 0; +} + ZoneRegionEditor::ZoneRegionEditor() { m_fileName = ""; @@ -111,9 +128,58 @@ void ZoneRegionEditor::setFileName(const std::string &fileName) m_fileName = fileName; } +void ZoneRegionEditor::ligoData(LigoData &data, const sint32 x, const sint32 y) +{ + nlassert((x >= m_zoneRegion.getMinX()) && + (x <= m_zoneRegion.getMaxX()) && + (y >= m_zoneRegion.getMinY()) && + (y <= m_zoneRegion.getMaxY())); + + data.posX = m_zoneRegion.getPosX(x, y); + data.posY = m_zoneRegion.getPosY(x, y); + data.zoneName = m_zoneRegion.getName(x, y); + data.rot = m_zoneRegion.getRot(x, y); + data.flip = m_zoneRegion.getFlip(x, y); + data.sharingMatNames[0] = m_zoneRegion.getSharingMatNames(x, y, 0); + data.sharingMatNames[1] = m_zoneRegion.getSharingMatNames(x, y, 1); + data.sharingMatNames[2] = m_zoneRegion.getSharingMatNames(x, y, 2); + data.sharingMatNames[3] = m_zoneRegion.getSharingMatNames(x, y, 3); + data.sharingCutEdges[0] = m_zoneRegion.getSharingCutEdges(x, y, 0); + data.sharingCutEdges[1] = m_zoneRegion.getSharingCutEdges(x, y, 1); + data.sharingCutEdges[2] = m_zoneRegion.getSharingCutEdges(x, y, 2); + data.sharingCutEdges[3] = m_zoneRegion.getSharingCutEdges(x, y, 3); +} + +void ZoneRegionEditor::setLigoData(const LigoData &data, const sint32 x, const sint32 y) +{ + nlassert((x >= m_zoneRegion.getMinX()) && + (x <= m_zoneRegion.getMaxX()) && + (y >= m_zoneRegion.getMinY()) && + (y <= m_zoneRegion.getMaxY())); + + m_zoneRegion.setPosX(x, y, data.posX); + m_zoneRegion.setPosY(x, y, data.posY); + m_zoneRegion.setName(x, y, data.zoneName); + m_zoneRegion.setRot(x, y, data.rot); + m_zoneRegion.setFlip(x, y, data.flip); + m_zoneRegion.setSharingMatNames(x, y, 0, data.sharingMatNames[0]); + m_zoneRegion.setSharingMatNames(x, y, 1, data.sharingMatNames[1]); + m_zoneRegion.setSharingMatNames(x, y, 2, data.sharingMatNames[2]); + m_zoneRegion.setSharingMatNames(x, y, 3, data.sharingMatNames[3]); + m_zoneRegion.setSharingCutEdges(x, y, 0, data.sharingCutEdges[0]); + m_zoneRegion.setSharingCutEdges(x, y, 1, data.sharingCutEdges[1]); + m_zoneRegion.setSharingCutEdges(x, y, 2, data.sharingCutEdges[2]); + m_zoneRegion.setSharingCutEdges(x, y, 3, data.sharingCutEdges[3]); +} + NLLIGO::CZoneRegion &ZoneRegionEditor::zoneRegion() { return m_zoneRegion; } +void ZoneRegionEditor::setZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) +{ + m_zoneRegion = zoneRegion; +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h index fd53d5483..50fab0e58 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h @@ -32,6 +32,36 @@ namespace LandscapeEditor { +struct LigoData +{ + uint8 posX; + uint8 posY; + uint8 rot; + uint8 flip; + std::string zoneName; + std::string sharingMatNames[4]; + uint8 sharingCutEdges[4]; + + LigoData(); + + bool operator!= (const LigoData& other) const + { + return (posX != other.posX) || + (posY != other.posY) || + (rot != other.rot) || + (flip != other.flip) || + (zoneName != other.zoneName) || + (sharingMatNames[0] != other.sharingMatNames[0]) || + (sharingMatNames[1] != other.sharingMatNames[1]) || + (sharingMatNames[2] != other.sharingMatNames[2]) || + (sharingMatNames[3] != other.sharingMatNames[3]) || + (sharingCutEdges[0] != other.sharingCutEdges[0]) || + (sharingCutEdges[1] != other.sharingCutEdges[1]) || + (sharingCutEdges[2] != other.sharingCutEdges[2]) || + (sharingCutEdges[3] != other.sharingCutEdges[3]); + } +}; + class ZoneRegionEditor { public: @@ -44,11 +74,17 @@ public: // Save landscape data to file bool save(); + void ligoData(LigoData &data, const sint32 x, const sint32 y); + + void setLigoData(const LigoData &data, const sint32 x, const sint32 y); + // Set file name void setFileName(const std::string &fileName); NLLIGO::CZoneRegion &zoneRegion(); + void setZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); + private: bool m_modified; From c647a72abb218c67c09d0218309acb927eaa599b Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 30 Jun 2011 00:25:43 +0300 Subject: [PATCH 009/747] Changed: #1301 Improved 2d render. Fixed adding empty undo/redo operations in command list, improved performance when adding new zones. --- .../plugins/landscape_editor/builder_zone.cpp | 50 ++++++++++-- .../plugins/landscape_editor/builder_zone.h | 15 +++- .../landscape_editor/landscape_actions.cpp | 70 +++++++++++++++- .../landscape_editor/landscape_actions.h | 35 ++++++++ .../landscape_editor_window.cpp | 17 +++- .../landscape_editor_window.h | 1 + .../landscape_editor_window.ui | 6 ++ .../landscape_editor/landscape_scene.cpp | 79 +++++++++++++++---- .../landscape_editor/landscape_scene.h | 11 ++- .../landscape_editor/landscape_view.cpp | 2 + .../landscape_editor/zone_region_editor.cpp | 70 +++++++++++----- .../landscape_editor/zone_region_editor.h | 27 ++----- 12 files changed, 310 insertions(+), 73 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 8271fe37c..0e00d72be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -167,18 +167,22 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone) void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zonePos) { + checkBeginMacro(); nlinfo(QString("%1 %2 %3 (%4 %5)").arg(data.zoneName.c_str()).arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).toStdString().c_str()); + m_zonePositionList.push_back(zonePos); m_undoStack->push(new LigoTileCommand(data, zonePos, this, m_landscapeScene)); } void ZoneBuilder::actionLigoMove(uint index, sint32 deltaX, sint32 deltaY) { + checkBeginMacro(); nlinfo("ligoMove"); //m_undoStack->push(new LigoMoveCommand(index, deltaX, deltaY, this)); } void ZoneBuilder::actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY) { + checkBeginMacro(); nlinfo(QString("minX=%1 maxX=%2 minY=%3 maxY=%4").arg(newMinX).arg(newMaxX).arg(newMinY).arg(newMaxY).toStdString().c_str()); m_undoStack->push(new LigoResizeCommand(index, newMinX, newMaxX, newMinY, newMaxY, this)); } @@ -201,7 +205,11 @@ void ZoneBuilder::addZone(sint32 posX, sint32 posY) NLLIGO::CZoneBankElement *zoneBankElement = getZoneBank().getElementByZoneName(zoneName); - m_undoStack->beginMacro(QString("Add zone %1,%2").arg(posX).arg(posY)); + m_titleAction = QString("Add zone %1,%2").arg(posX).arg(posY); + m_createdAction = false; + m_zonePositionList.clear(); + + nlinfo("---------"); if (m_listZonesWidget->isForce()) { builderZoneRegion->addForce(posX, posY, rot, flip, zoneBankElement); @@ -213,7 +221,7 @@ void ZoneBuilder::addZone(sint32 posX, sint32 posY) else builderZoneRegion->add(posX, posY, rot, flip, zoneBankElement); } - m_undoStack->endMacro(); + checkEndMacro(); } void ZoneBuilder::addTransition(const sint32 posX, const sint32 posY) @@ -225,17 +233,20 @@ void ZoneBuilder::delZone(const sint32 posX, const sint32 posY) if (m_builderZoneRegions.empty()) return; - m_undoStack->beginMacro(QString("Del zone %1,%2").arg(posX).arg(posY)); + m_titleAction = QString("Del zone %1,%2").arg(posX).arg(posY); + m_createdAction = false; + BuilderZoneRegion *builderZoneRegion = m_builderZoneRegions.at(m_currentZoneRegion); std::string error; + nlinfo("---------"); builderZoneRegion->init(this, error); builderZoneRegion->del(posX, posY); - m_undoStack->endMacro(); + checkEndMacro(); } int ZoneBuilder::createZoneRegion() { - ZoneRegionEditor *newZoneRegion = new ZoneRegionEditor(); + ZoneRegionObject *newZoneRegion = new ZoneRegionObject(); m_zoneRegions.push_back(newZoneRegion); if (m_currentZoneRegion == -1) m_currentZoneRegion = m_zoneRegions.indexOf(newZoneRegion); @@ -261,7 +272,7 @@ int ZoneBuilder::currentIdZoneRegion() const return m_currentZoneRegion; } -ZoneRegionEditor *ZoneBuilder::currentZoneRegion() const +ZoneRegionObject *ZoneBuilder::currentZoneRegion() const { return m_zoneRegions.at(m_currentZoneRegion); } @@ -271,7 +282,7 @@ int ZoneBuilder::countZoneRegion() const return m_zoneRegions.size(); } -ZoneRegionEditor *ZoneBuilder::zoneRegion(int id) const +ZoneRegionObject *ZoneBuilder::zoneRegion(int id) const { return m_zoneRegions.at(id); } @@ -399,7 +410,7 @@ void ZoneBuilder::calcMask() bool ZoneBuilder::getZoneAmongRegions (ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y) { - Q_FOREACH(ZoneRegionEditor *zoneRegion, m_zoneRegions) + Q_FOREACH(ZoneRegionObject *zoneRegion, m_zoneRegions) { const NLLIGO::CZoneRegion ®ion = zoneRegion->zoneRegion(); if ((x < region.getMinX()) || (x > region.getMaxX()) || @@ -424,4 +435,27 @@ bool ZoneBuilder::getZoneAmongRegions (ZonePosition &zonePos, BuilderZoneRegion return true; } +void ZoneBuilder::checkBeginMacro() +{ + if (!m_createdAction) + { + m_createdAction = true; + m_undoStack->beginMacro(m_titleAction); + m_undoScanRegionCommand = new UndoScanRegionCommand(this, m_landscapeScene); + m_undoStack->push(m_undoScanRegionCommand); + } +} + +void ZoneBuilder::checkEndMacro() +{ + if (m_createdAction) + { + RedoScanRegionCommand *redoScanRegionCommand = new RedoScanRegionCommand(this, m_landscapeScene); + m_undoScanRegionCommand->setScanList(m_zonePositionList); + redoScanRegionCommand->setScanList(m_zonePositionList); + m_undoStack->push(redoScanRegionCommand); + m_undoStack->endMacro(); + } +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index 54cdb3b73..ecc47976f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -42,6 +42,7 @@ namespace LandscapeEditor { class ListZonesWidget; class LandscapeScene; +class UndoScanRegionCommand; // Data struct ZonePosition @@ -134,9 +135,9 @@ public: void deleteZoneRegion(int id); void setCurrentZoneRegion(int id); int currentIdZoneRegion() const; - ZoneRegionEditor *currentZoneRegion() const; + ZoneRegionObject *currentZoneRegion() const; int countZoneRegion() const; - ZoneRegionEditor *zoneRegion(int id) const; + ZoneRegionObject *zoneRegion(int id) const; void ligoData(LigoData &data, const ZonePosition &zonePos); void setLigoData(LigoData &data, const ZonePosition &zonePos); @@ -155,16 +156,24 @@ private: /// Scan ./zoneligos dir and add all *.ligozone files to zoneBank bool initZoneBank (const QString &path); + void checkBeginMacro(); + void checkEndMacro(); + sint32 m_minX, m_maxX, m_minY, m_maxY; std::vector m_zoneMask; QString m_lastPathName; - QList m_zoneRegions; + QList m_zoneRegions; int m_currentZoneRegion; std::vector m_builderZoneRegions; + bool m_createdAction; + QString m_titleAction; + QList m_zonePositionList; + UndoScanRegionCommand *m_undoScanRegionCommand; + PixmapDatabase *m_pixmapDatabase; NLLIGO::CZoneBank m_zoneBank; ListZonesWidget *m_listZonesWidget; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp index 95f030631..8aea79933 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp @@ -86,13 +86,79 @@ LigoTileCommand::~LigoTileCommand() void LigoTileCommand::undo () { m_zoneBuilder->setLigoData(m_oldLigoData, m_zonePos); - m_scene->createZoneItem(m_oldLigoData, m_zonePos); } void LigoTileCommand::redo () { m_zoneBuilder->setLigoData(m_newLigoData, m_zonePos); - m_scene->createZoneItem(m_newLigoData, m_zonePos); +} + +UndoScanRegionCommand::UndoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent) + : QUndoCommand(parent), + m_zoneBuilder(zoneBuilder), + m_scene(scene) +{ +} + +UndoScanRegionCommand::~UndoScanRegionCommand() +{ + m_zonePositionList.clear(); +} + +void UndoScanRegionCommand::setScanList(const QList &zonePositionList) +{ + m_zonePositionList = zonePositionList; +} + +void UndoScanRegionCommand::undo() +{ + for (int i = 0; i < m_zonePositionList.size(); ++i) + m_scene->deleteItemZone(m_zonePositionList.at(i)); + nlinfo("------"); + for (int i = 0; i < m_zonePositionList.size(); ++i) + { + LigoData data; + m_zoneBuilder->ligoData(data, m_zonePositionList.at(i)); + m_scene->createItemZone(data, m_zonePositionList.at(i)); + } +} + +void UndoScanRegionCommand::redo() +{ +} + +RedoScanRegionCommand::RedoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent) + : QUndoCommand(parent), + m_zoneBuilder(zoneBuilder), + m_scene(scene) +{ +} + +RedoScanRegionCommand::~RedoScanRegionCommand() +{ + m_zonePositionList.clear(); +} + +void RedoScanRegionCommand::setScanList(const QList &zonePositionList) +{ + m_zonePositionList = zonePositionList; +} + +void RedoScanRegionCommand::undo() +{ +} + +void RedoScanRegionCommand::redo() +{ + for (int i = 0; i < m_zonePositionList.size(); ++i) + m_scene->deleteItemZone(m_zonePositionList.at(i)); + nlinfo("------"); + for (int i = 0; i < m_zonePositionList.size(); ++i) + { + LigoData data; + m_zoneBuilder->ligoData(data, m_zonePositionList.at(i)); + m_scene->createItemZone(data, m_zonePositionList.at(i)); + } } LigoResizeCommand::LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX, diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h index e7a39d8b1..c4afcc801 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h @@ -75,6 +75,41 @@ private: ZoneBuilder *m_zoneBuilder; LandscapeScene *m_scene; }; + +class UndoScanRegionCommand: public QUndoCommand +{ +public: + UndoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0); + virtual ~UndoScanRegionCommand(); + + void setScanList(const QList &zonePositionList); + virtual void undo(); + virtual void redo(); + +private: + + QList m_zonePositionList; + ZoneBuilder *m_zoneBuilder; + LandscapeScene *m_scene; +}; + +class RedoScanRegionCommand: public QUndoCommand +{ +public: + RedoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0); + virtual ~RedoScanRegionCommand(); + + void setScanList(const QList &zonePositionList); + virtual void undo(); + virtual void redo(); + +private: + + QList m_zonePositionList; + ZoneBuilder *m_zoneBuilder; + LandscapeScene *m_scene; +}; + /* // Move the landscape class LigoMoveCommand: public QUndoCommand diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 0c38adbf6..facf90264 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -62,6 +62,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) createToolBars(); readSettings(); + connect(m_ui.saveAction, SIGNAL(triggered()), this, SLOT(save())); connect(m_ui.projectSettingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings())); connect(m_ui.snapshotAction, SIGNAL(triggered()), this, SLOT(openSnapshotDialog())); connect(m_ui.enableGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool))); @@ -92,7 +93,7 @@ void LandscapeEditorWindow::open() Q_FOREACH(QString fileName, fileNames) { int id = m_zoneBuilder->createZoneRegion(); - ZoneRegionEditor *zoneRegion = m_zoneBuilder->zoneRegion(id); + ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id); zoneRegion->load(fileName.toStdString()); m_landscapeScene->processZoneRegion(zoneRegion->zoneRegion()); m_ui.graphicsView->centerOn(zoneRegion->zoneRegion().getMinX() * m_landscapeScene->cellSize(), @@ -104,6 +105,20 @@ void LandscapeEditorWindow::open() setCursor(Qt::ArrowCursor); } +void LandscapeEditorWindow::save() +{ + ZoneRegionObject *zoneRegion = m_zoneBuilder->currentZoneRegion(); + if (zoneRegion->fileName().empty()) + { + QString fileName = QFileDialog::getSaveFileName(this, + tr("Save NeL Ligo land file"), _lastDir, + tr("NeL Ligo land file (*.land)")); + if (!fileName.isEmpty()) + zoneRegion->setFileName(fileName.toStdString()); + } + zoneRegion->save(); +} + void LandscapeEditorWindow::openProjectSettings() { ProjectSettingsDialog *dialog = new ProjectSettingsDialog(m_zoneBuilder->dataPath(), this); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index 3a35b90f4..ccfcf2778 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -43,6 +43,7 @@ public: Q_SIGNALS: public Q_SLOTS: void open(); + void save(); private Q_SLOTS: void openProjectSettings(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index 212d0eb13..57eadda73 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -72,6 +72,7 @@ false + @@ -107,6 +108,11 @@ snapshot + + + Save + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 3aa2bbc9a..9970032a7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -29,8 +29,12 @@ namespace LandscapeEditor { +static const int ZoneName = 0; + LandscapeScene::LandscapeScene(QObject *parent) : QGraphicsScene(parent), + m_mouseX(0.0), + m_mouseY(0.0), m_zoneBuilder(0) { m_cellSize = 160; @@ -50,16 +54,21 @@ void LandscapeScene::setZoneBuilder(ZoneBuilder *zoneBuilder) m_zoneBuilder = zoneBuilder; } -QGraphicsItem *LandscapeScene::createZoneItem(const LigoData &data, const ZonePosition &zonePos) +QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePosition &zonePos) { + nlinfo(QString("%1,%2 (%3,%4)-%7 (%5,%6)").arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).arg(data.rot).arg(data.flip).arg(data.zoneName.c_str()).toStdString().c_str()); + if ((data.zoneName == STRING_OUT_OF_BOUND) || (checkUnderZone(zonePos.x, zonePos.y))) + return 0; + if (data.zoneName == STRING_UNUSED) - return createEmptyZoneItem(zonePos); + return createItemEmptyZone(zonePos); if ((m_zoneBuilder == 0) || (data.zoneName.empty()) || (data.posX != 0) || (data.posY != 0)) return 0; - checkUnderZone(data, zonePos); +// if ((m_zoneBuilder == 0) || (data.zoneName.empty())) +// return 0; // Get image from pixmap database QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.zoneName.c_str())); @@ -88,21 +97,27 @@ QGraphicsItem *LandscapeScene::createZoneItem(const LigoData &data, const ZonePo // Set position graphics item with offset for large piece NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName); - item->setPos(zonePos.x * m_cellSize, (abs(zonePos.y) - zoneBankItem->getSizeY() + 1) * m_cellSize); + + int delta = zoneBankItem->getSizeY() - 1; + if ((data.rot == 1) || (data.rot == 3)) + delta = zoneBankItem->getSizeX() - 1; + + //item->setPos((zonePos.x - data.posX) * m_cellSize, (abs(int(zonePos.y)) + data.posY - delta) * m_cellSize); + item->setPos((zonePos.x) * m_cellSize, (abs(int(zonePos.y)) - delta) * m_cellSize); // The size graphics item should be equal or proportional m_cellSize item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); + item->setData(ZoneName, QString(data.zoneName.c_str())); + nlinfo("render"); return item; } -QGraphicsItem *LandscapeScene::createEmptyZoneItem(const ZonePosition &zonePos) +QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos) { if (m_zoneBuilder == 0) return 0; - deleteZoneItem(zonePos); - // Get image from pixmap database QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED)); if (pixmap == 0) @@ -118,11 +133,11 @@ QGraphicsItem *LandscapeScene::createEmptyZoneItem(const ZonePosition &zonePos) // The size graphics item should be equal or proportional m_cellSize item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); - + nlinfo("render"); return item; } -void LandscapeScene::deleteZoneItem(const ZonePosition &zonePos) +void LandscapeScene::deleteItemZone(const ZonePosition &zonePos) { QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize); if (item != 0) @@ -143,7 +158,7 @@ void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) if (zoneName == STRING_UNUSED) { ZonePosition zonePos(i, j, -1); - QGraphicsItem *item = createEmptyZoneItem(zonePos); + QGraphicsItem *item = createItemEmptyZone(zonePos); } else if (!zoneName.empty()) { @@ -154,7 +169,7 @@ void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) data.flip = zoneRegion.getFlip(i, j); data.posX = zoneRegion.getPosX(i, j); data.posY = zoneRegion.getPosY(i, j); - QGraphicsItem *item = createZoneItem(data, zonePos); + QGraphicsItem *item = createItemZone(data, zonePos); } } } @@ -230,13 +245,43 @@ void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) QGraphicsScene::mousePressEvent(mouseEvent); } -void LandscapeScene::checkUnderZone(const LigoData &data, const ZonePosition &zonePos) +void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) { -// NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName); -// uint8 sizeX = zoneBankItem->getSizeX(); -// uint8 sizeY = zoneBankItem->getSizeY(); -// std::vector &mask = zoneBankItem->getMask(); - deleteZoneItem(zonePos); + m_mouseX = mouseEvent->scenePos().x(); + m_mouseY = mouseEvent->scenePos().y(); + QGraphicsScene::mouseMoveEvent(mouseEvent); +} + +bool LandscapeScene::checkUnderZone(const int posX, const int posY) +{ + /* QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize); + if (item != 0) + { + QString zoneName = item->data(ZoneName).toString(); + return true; + } + */ return false; +} + +void LandscapeScene::drawForeground(QPainter *painter, const QRectF &rect) +{ + QGraphicsScene::drawForeground(painter, rect); + painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); + + int left = int(floor(rect.left() / m_cellSize)); + int right = int(floor(rect.right() / m_cellSize)); + int top = int(floor(rect.top() / m_cellSize)); + int bottom = int(floor(rect.bottom() / m_cellSize)); + + for (int i = left; i < right; ++i) + { + for (int j = top; j < bottom; ++j) + { + LigoData data; + m_zoneBuilder->currentZoneRegion()->ligoData(data, i, -j); + painter->drawText(i * m_cellSize + 10, j * m_cellSize + 10, QString("%1 %2 %3 %4").arg(i).arg(j).arg(data.posX).arg(data.posY)); + } + } } } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index ea314faac..525971999 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -43,9 +43,9 @@ public: int cellSize() const; void setZoneBuilder(ZoneBuilder *zoneBuilder); - QGraphicsItem *createZoneItem(const LigoData &data, const ZonePosition &zonePos); - QGraphicsItem *createEmptyZoneItem(const ZonePosition &zonePos); - void deleteZoneItem(const ZonePosition &zonePos); + QGraphicsItem *createItemZone(const LigoData &data, const ZonePosition &zonePos); + QGraphicsItem *createItemEmptyZone(const ZonePosition &zonePos); + void deleteItemZone(const ZonePosition &zonePos); void processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); void snapshot(const QString &fileName, int sizeSource); @@ -53,11 +53,14 @@ public: protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); + virtual void drawForeground(QPainter *painter, const QRectF &rect); private: - void checkUnderZone(const LigoData &data, const ZonePosition &zonePos); + bool checkUnderZone(const int posX, const int posY); int m_cellSize; + qreal m_mouseX, m_mouseY; ZoneBuilder *m_zoneBuilder; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index 610028762..e32f4ae6d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -110,6 +110,8 @@ void LandscapeView::mouseReleaseEvent(QMouseEvent *event) void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect) { + QGraphicsView::drawForeground(painter, rect); + if (!m_visibleGrid) return; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp index 045b342fd..81e4b687c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp @@ -47,16 +47,33 @@ LigoData::LigoData() sharingCutEdges[3] = 0; } -ZoneRegionEditor::ZoneRegionEditor() +bool LigoData::operator!= (const LigoData& other) const +{ + return (posX != other.posX) || + (posY != other.posY) || + (rot != other.rot) || + (flip != other.flip) || + (zoneName != other.zoneName) || + (sharingMatNames[0] != other.sharingMatNames[0]) || + (sharingMatNames[1] != other.sharingMatNames[1]) || + (sharingMatNames[2] != other.sharingMatNames[2]) || + (sharingMatNames[3] != other.sharingMatNames[3]) || + (sharingCutEdges[0] != other.sharingCutEdges[0]) || + (sharingCutEdges[1] != other.sharingCutEdges[1]) || + (sharingCutEdges[2] != other.sharingCutEdges[2]) || + (sharingCutEdges[3] != other.sharingCutEdges[3]); +} + +ZoneRegionObject::ZoneRegionObject() { m_fileName = ""; } -ZoneRegionEditor::~ZoneRegionEditor() +ZoneRegionObject::~ZoneRegionObject() { } -bool ZoneRegionEditor::load(const std::string &fileName) +bool ZoneRegionObject::load(const std::string &fileName) { bool result = true; try @@ -85,7 +102,7 @@ bool ZoneRegionEditor::load(const std::string &fileName) return result; } -bool ZoneRegionEditor::save() +bool ZoneRegionObject::save() { if (m_fileName.empty()) return false; @@ -123,18 +140,24 @@ bool ZoneRegionEditor::save() return result; } -void ZoneRegionEditor::setFileName(const std::string &fileName) +std::string ZoneRegionObject::fileName() const +{ + return m_fileName; +} + +void ZoneRegionObject::setFileName(const std::string &fileName) { m_fileName = fileName; } -void ZoneRegionEditor::ligoData(LigoData &data, const sint32 x, const sint32 y) +void ZoneRegionObject::ligoData(LigoData &data, const sint32 x, const sint32 y) { - nlassert((x >= m_zoneRegion.getMinX()) && - (x <= m_zoneRegion.getMaxX()) && - (y >= m_zoneRegion.getMinY()) && - (y <= m_zoneRegion.getMaxY())); - + /* + nlassert((x >= m_zoneRegion.getMinX()) && + (x <= m_zoneRegion.getMaxX()) && + (y >= m_zoneRegion.getMinY()) && + (y <= m_zoneRegion.getMaxY())); + */ data.posX = m_zoneRegion.getPosX(x, y); data.posY = m_zoneRegion.getPosY(x, y); data.zoneName = m_zoneRegion.getName(x, y); @@ -150,13 +173,14 @@ void ZoneRegionEditor::ligoData(LigoData &data, const sint32 x, const sint32 y) data.sharingCutEdges[3] = m_zoneRegion.getSharingCutEdges(x, y, 3); } -void ZoneRegionEditor::setLigoData(const LigoData &data, const sint32 x, const sint32 y) +void ZoneRegionObject::setLigoData(const LigoData &data, const sint32 x, const sint32 y) { - nlassert((x >= m_zoneRegion.getMinX()) && - (x <= m_zoneRegion.getMaxX()) && - (y >= m_zoneRegion.getMinY()) && - (y <= m_zoneRegion.getMaxY())); - + /* + nlassert((x >= m_zoneRegion.getMinX()) && + (x <= m_zoneRegion.getMaxX()) && + (y >= m_zoneRegion.getMinY()) && + (y <= m_zoneRegion.getMaxY())); + */ m_zoneRegion.setPosX(x, y, data.posX); m_zoneRegion.setPosY(x, y, data.posY); m_zoneRegion.setName(x, y, data.zoneName); @@ -172,14 +196,22 @@ void ZoneRegionEditor::setLigoData(const LigoData &data, const sint32 x, const s m_zoneRegion.setSharingCutEdges(x, y, 3, data.sharingCutEdges[3]); } -NLLIGO::CZoneRegion &ZoneRegionEditor::zoneRegion() +NLLIGO::CZoneRegion &ZoneRegionObject::zoneRegion() { return m_zoneRegion; } -void ZoneRegionEditor::setZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) +void ZoneRegionObject::setZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) { m_zoneRegion = zoneRegion; } +bool ZoneRegionObject::checkPos(const sint32 x, const sint32 y) +{ + return ((x >= m_zoneRegion.getMinX()) && + (x <= m_zoneRegion.getMaxX()) && + (y >= m_zoneRegion.getMinY()) && + (y <= m_zoneRegion.getMaxY())); +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h index 50fab0e58..2d4f063aa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h @@ -44,29 +44,14 @@ struct LigoData LigoData(); - bool operator!= (const LigoData& other) const - { - return (posX != other.posX) || - (posY != other.posY) || - (rot != other.rot) || - (flip != other.flip) || - (zoneName != other.zoneName) || - (sharingMatNames[0] != other.sharingMatNames[0]) || - (sharingMatNames[1] != other.sharingMatNames[1]) || - (sharingMatNames[2] != other.sharingMatNames[2]) || - (sharingMatNames[3] != other.sharingMatNames[3]) || - (sharingCutEdges[0] != other.sharingCutEdges[0]) || - (sharingCutEdges[1] != other.sharingCutEdges[1]) || - (sharingCutEdges[2] != other.sharingCutEdges[2]) || - (sharingCutEdges[3] != other.sharingCutEdges[3]); - } + bool operator!= (const LigoData& other) const; }; -class ZoneRegionEditor +class ZoneRegionObject { public: - ZoneRegionEditor(); - ~ZoneRegionEditor(); + ZoneRegionObject(); + ~ZoneRegionObject(); // Load landscape data from file bool load(const std::string &fileName); @@ -78,6 +63,8 @@ public: void setLigoData(const LigoData &data, const sint32 x, const sint32 y); + std::string fileName() const; + // Set file name void setFileName(const std::string &fileName); @@ -85,6 +72,8 @@ public: void setZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); + bool checkPos(const sint32 x, const sint32 y); + private: bool m_modified; From d1988c74146cd952d79a2b75aef0d6f6f93b568c Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 30 Jun 2011 01:51:18 +0300 Subject: [PATCH 010/747] Changed: #1301 Fixed incorrect rendering of rotated elements. --- .../landscape_editor/landscape_scene.cpp | 115 +++++++++++++----- 1 file changed, 82 insertions(+), 33 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 9970032a7..65316d9f7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -56,20 +56,15 @@ void LandscapeScene::setZoneBuilder(ZoneBuilder *zoneBuilder) QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePosition &zonePos) { - nlinfo(QString("%1,%2 (%3,%4)-%7 (%5,%6)").arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).arg(data.rot).arg(data.flip).arg(data.zoneName.c_str()).toStdString().c_str()); if ((data.zoneName == STRING_OUT_OF_BOUND) || (checkUnderZone(zonePos.x, zonePos.y))) return 0; if (data.zoneName == STRING_UNUSED) return createItemEmptyZone(zonePos); - if ((m_zoneBuilder == 0) || (data.zoneName.empty()) || - (data.posX != 0) || (data.posY != 0)) + if ((m_zoneBuilder == 0) || (data.zoneName.empty())) return 0; -// if ((m_zoneBuilder == 0) || (data.zoneName.empty())) -// return 0; - // Get image from pixmap database QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.zoneName.c_str())); if (pixmap == 0) @@ -98,18 +93,69 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo // Set position graphics item with offset for large piece NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName); - int delta = zoneBankItem->getSizeY() - 1; - if ((data.rot == 1) || (data.rot == 3)) - delta = zoneBankItem->getSizeX() - 1; + sint32 deltaX = 0, deltaY = 0; - //item->setPos((zonePos.x - data.posX) * m_cellSize, (abs(int(zonePos.y)) + data.posY - delta) * m_cellSize); - item->setPos((zonePos.x) * m_cellSize, (abs(int(zonePos.y)) - delta) * m_cellSize); + // Calculate offset for graphics item (for items with size that are larger than 1) + if ((zoneBankItem->getSizeX() > 1) || (zoneBankItem->getSizeY() > 1)) + { + sint32 sizeX = zoneBankItem->getSizeX(), sizeY = zoneBankItem->getSizeY(); + if (data.flip == 0) + { + switch (data.rot) + { + case 0: + deltaX = -data.posX; + deltaY = -data.posY + sizeY - 1; + break; + case 1: + deltaX = -(sizeY - 1 - data.posY); + deltaY = -data.posX + sizeX - 1; + break; + case 2: + deltaX = -(sizeX - 1 - data.posX); + deltaY = data.posY; + break; + case 3: + deltaX = -data.posY; + deltaY = data.posX; + break; + } + } + else + { + switch (data.rot) + { + case 0: + deltaX = -(sizeX - 1 - data.posX); + deltaY = -data.posY + sizeY - 1; + break; + case 1: + deltaX = -(sizeY - 1 - data.posY); + deltaY = +data.posX; + break; + case 2: + deltaX = -data.posX; + deltaY = data.posY; + break; + case 3: + deltaX = -data.posY; + deltaY = -data.posX + sizeX - 1; + break; + } + } + } + + // set position graphics item with taking into account the offset + item->setPos((zonePos.x + deltaX) * m_cellSize, (abs(int(zonePos.y + deltaY))) * m_cellSize); // The size graphics item should be equal or proportional m_cellSize item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); item->setData(ZoneName, QString(data.zoneName.c_str())); - nlinfo("render"); + + // for not full item zone + item->setZValue(0); + return item; } @@ -133,7 +179,10 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos) // The size graphics item should be equal or proportional m_cellSize item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); - nlinfo("render"); + + // for not full item zone + item->setZValue(1); + return item; } @@ -153,7 +202,7 @@ void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) { for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) { - nlinfo(QString("%1 %2 %3").arg(i).arg(j).arg(zoneRegion.getName(i, j).c_str()).toStdString().c_str()); + //nlinfo(QString("%1 %2 %3").arg(i).arg(j).arg(zoneRegion.getName(i, j).c_str()).toStdString().c_str()); std::string zoneName = zoneRegion.getName(i, j); if (zoneName == STRING_UNUSED) { @@ -254,34 +303,34 @@ void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) bool LandscapeScene::checkUnderZone(const int posX, const int posY) { - /* QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize); - if (item != 0) - { - QString zoneName = item->data(ZoneName).toString(); - return true; - } - */ return false; + QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize); + if (item != 0) + return true; + return false; } void LandscapeScene::drawForeground(QPainter *painter, const QRectF &rect) { QGraphicsScene::drawForeground(painter, rect); - painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); + /* + // Render debug text (slow!) + painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); - int left = int(floor(rect.left() / m_cellSize)); - int right = int(floor(rect.right() / m_cellSize)); - int top = int(floor(rect.top() / m_cellSize)); - int bottom = int(floor(rect.bottom() / m_cellSize)); + int left = int(floor(rect.left() / m_cellSize)); + int right = int(floor(rect.right() / m_cellSize)); + int top = int(floor(rect.top() / m_cellSize)); + int bottom = int(floor(rect.bottom() / m_cellSize)); - for (int i = left; i < right; ++i) - { - for (int j = top; j < bottom; ++j) + for (int i = left; i < right; ++i) { - LigoData data; - m_zoneBuilder->currentZoneRegion()->ligoData(data, i, -j); - painter->drawText(i * m_cellSize + 10, j * m_cellSize + 10, QString("%1 %2 %3 %4").arg(i).arg(j).arg(data.posX).arg(data.posY)); + for (int j = top; j < bottom; ++j) + { + LigoData data; + m_zoneBuilder->currentZoneRegion()->ligoData(data, i, -j); + painter->drawText(i * m_cellSize + 10, j * m_cellSize + 10, QString("%1 %2 %3 %4").arg(i).arg(j).arg(data.posX).arg(data.posY)); + } } - } + */ } } /* namespace LandscapeEditor */ From aedfcced67dd231afabddca71b5eeefc07a099b8 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 2 Jul 2011 13:00:28 +0300 Subject: [PATCH 011/747] Fixed: #1301 Fixed incorrect work landscape plugin with other plugins which use opengl (object_viewer plugin). --- .../landscape_editor_window.cpp | 18 ++++++++++++++---- .../landscape_editor/landscape_editor_window.h | 5 +++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index facf90264..abfdcbd35 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -34,14 +34,17 @@ // Qt includes #include #include -#include namespace LandscapeEditor { QString _lastDir; LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) - : QMainWindow(parent) + : QMainWindow(parent), + m_landscapeScene(0), + m_zoneBuilder(0), + m_undoStack(0), + m_oglWidget(0) { m_ui.setupUi(this); @@ -55,8 +58,9 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_landscapeScene->setZoneBuilder(m_zoneBuilder); m_ui.graphicsView->setScene(m_landscapeScene); - //m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer))); - m_ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers))); + //m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); + m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers)); + m_ui.graphicsView->setViewport(m_oglWidget); createMenus(); createToolBars(); @@ -150,6 +154,12 @@ void LandscapeEditorWindow::openSnapshotDialog() delete dialog; } +void LandscapeEditorWindow::showEvent(QShowEvent *showEvent) +{ + QMainWindow::showEvent(showEvent); + m_oglWidget->makeCurrent(); +} + void LandscapeEditorWindow::createMenus() { Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index ccfcf2778..ff9cfd273 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -23,6 +23,7 @@ // Qt includes #include +#include namespace LandscapeEditor { @@ -49,6 +50,9 @@ private Q_SLOTS: void openProjectSettings(); void openSnapshotDialog(); +protected: + virtual void showEvent(QShowEvent *showEvent); + private: void createMenus(); void createToolBars(); @@ -58,6 +62,7 @@ private: LandscapeScene *m_landscapeScene; ZoneBuilder *m_zoneBuilder; QUndoStack *m_undoStack; + QGLWidget *m_oglWidget; Ui::LandscapeEditorWindow m_ui; }; /* class LandscapeEditorWindow */ From 0823243f10264ac8b98dbcc0892d0266ac0680cc Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sun, 3 Jul 2011 17:12:31 +0300 Subject: [PATCH 012/747] Fixed: #1301 Fixed build landscape plugin under linux. --- code/nel/src/ligo/zone_bank.cpp | 13 +++++++------ .../src/plugins/landscape_editor/builder_zone.cpp | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/code/nel/src/ligo/zone_bank.cpp b/code/nel/src/ligo/zone_bank.cpp index 5f03c4bb5..a79b98449 100644 --- a/code/nel/src/ligo/zone_bank.cpp +++ b/code/nel/src/ligo/zone_bank.cpp @@ -19,14 +19,15 @@ #include "nel/ligo/zone_bank.h" -#ifdef NL_OS_WINDOWS - #include "nel/misc/debug.h" #include "nel/misc/file.h" #include "nel/misc/i_xml.h" #include "nel/misc/o_xml.h" + +#ifdef NL_OS_WINDOWS #define NOMINMAX #include +#endif // NL_OS_WINDOWS using namespace std; using namespace NLMISC; @@ -496,8 +497,9 @@ void CZoneBank::reset () _Selection.clear (); } +#ifdef NL_OS_WINDOWS // --------------------------------------------------------------------------- -bool CZoneBank::initFromPath(const string &sPathName, std::string &error) +bool CZoneBank::initFromPath(const std::string &sPathName, std::string &error) { char sDirBackup[512]; GetCurrentDirectory (512, sDirBackup); @@ -520,6 +522,7 @@ bool CZoneBank::initFromPath(const string &sPathName, std::string &error) SetCurrentDirectory (sDirBackup); return true; } +#endif // NL_OS_WINDOWS // --------------------------------------------------------------------------- bool CZoneBank::addElement (const std::string &elementName, std::string &error) @@ -694,6 +697,4 @@ void CZoneBank::getSelection (std::vector &SelectedElements) // *************************************************************************** -} // namespace NLLIGO - -#endif // NL_OS_WINDOWS +} // namespace NLLIGO \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 0e00d72be..21ab1118b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -78,7 +78,7 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon m_pixmapMap.insert(zonePixmapName, pixmap); } - QPixmap *pixmap = new QPixmap(zonePath + "_UNUSED_.png"); + QPixmap *pixmap = new QPixmap(zonePath + "_unused_.png"); QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(m_textureSize, m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); delete pixmap; m_pixmapMap.insert(QString(STRING_UNUSED), scaledPixmap); From 54391eaebf6ce531e5c1e5faadebe67c4ab2e009 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 4 Jul 2011 23:16:45 +0300 Subject: [PATCH 013/747] Changed: #1301 Added random and full cycle modes(for rotation and flip values too) adding zone on landscape. --- .../landscape_editor/list_zones_widget.cpp | 67 ++++++++++++++++--- .../landscape_editor/list_zones_widget.h | 10 ++- .../landscape_editor/list_zones_widget.ui | 10 ++- 3 files changed, 74 insertions(+), 13 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp index 7ce3f5421..d0bfe058c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp @@ -38,6 +38,8 @@ namespace LandscapeEditor ListZonesWidget::ListZonesWidget(QWidget *parent) : QWidget(parent), + m_rotCycle(0), + m_flipCycle(0), m_listZonesModel(0), m_zoneBuilder(0) { @@ -101,24 +103,70 @@ void ListZonesWidget::updateUi() m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase()); } -QString ListZonesWidget::currentZoneName() const +QString ListZonesWidget::currentZoneName() { QString zoneName = ""; QModelIndex index = m_ui.listView->currentIndex(); if (index.isValid()) zoneName = index.data().toString(); - + if (m_ui.zoneSelectComboBox->currentIndex() == 1) + { + // Random value + if (m_listSelection.size() > 0) + { + uint32 randZone = uint32(NLMISC::frand(m_listSelection.size())); + NLMISC::clamp(randZone, (uint32)0, uint32(m_listSelection.size() - 1)); + zoneName = m_listSelection[randZone]; + } + } + else if (m_ui.zoneSelectComboBox->currentIndex() == 2) + { + // Full cycle + zoneName = m_listSelection[m_zoneNameCycle]; + m_zoneNameCycle++; + m_zoneNameCycle = m_zoneNameCycle % m_listSelection.size(); + } return zoneName; } -int ListZonesWidget::currentRot() const +int ListZonesWidget::currentRot() { - return m_ui.rotComboBox->currentIndex(); + int rot = m_ui.rotComboBox->currentIndex(); + if (rot == 4) + { + // Random value + uint32 randRot = uint32(NLMISC::frand(4.0)); + NLMISC::clamp(randRot, (uint32)0, (uint32)3); + rot = int(randRot); + } + else if (rot == 5) + { + // Full cycle + rot = m_rotCycle; + m_rotCycle++; + m_rotCycle = m_rotCycle % 4; + } + return rot; } -int ListZonesWidget::currentFlip() const +int ListZonesWidget::currentFlip() { - return m_ui.flipComboBox->currentIndex(); + int flip = m_ui.flipComboBox->currentIndex(); + if (flip == 2) + { + // Random value + uint32 randFlip = uint32(NLMISC::frand(2.0)); + NLMISC::clamp (randFlip, (uint32)0, (uint32)1); + flip = int(randFlip); + } + else if (flip == 3) + { + // Full cycle + flip = m_flipCycle; + m_flipCycle++; + m_flipCycle = m_flipCycle % 2; + } + return flip; } bool ListZonesWidget::isNotPropogate() const @@ -234,11 +282,12 @@ void ListZonesWidget::updateListZones() std::vector currentSelection; zoneBank.getSelection (currentSelection); - QStringList listSelection; + m_listSelection.clear(); + m_zoneNameCycle = 0; for (size_t i = 0; i < currentSelection.size(); ++i) - listSelection << currentSelection[i]->getName().c_str(); + m_listSelection << currentSelection[i]->getName().c_str(); - m_listZonesModel->setListZones(listSelection); + m_listZonesModel->setListZones(m_listSelection); } void ListZonesWidget::disableSignals(bool block) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h index c35e7b0fa..4128f8cc2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -45,9 +45,9 @@ public: void updateUi(); void setZoneBuilder(ZoneBuilder *zoneBuilder); - QString currentZoneName() const; - int currentRot() const; - int currentFlip() const; + QString currentZoneName(); + int currentRot(); + int currentFlip(); bool isNotPropogate() const; bool isForce() const; @@ -62,6 +62,10 @@ private Q_SLOTS: private: void disableSignals(bool block); + int m_rotCycle, m_flipCycle; + int m_zoneNameCycle; + QStringList m_listSelection; + ListZonesModel *m_listZonesModel; ZoneBuilder *m_zoneBuilder; Ui::ListZonesWidget m_ui; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui index 4d9f63129..ed9faf74e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.ui @@ -39,7 +39,12 @@ - + + + + Select + + Random @@ -297,6 +302,9 @@ QAbstractItemView::ScrollPerPixel + + 1 + From 423d6ae8b31e57e98dc972e3671a25e3034c875e Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 4 Jul 2011 23:19:58 +0300 Subject: [PATCH 014/747] Changed: #1301 Class PixmapDatabase was moved to a separate file. --- .../plugins/landscape_editor/CMakeLists.txt | 1 - .../plugins/landscape_editor/builder_zone.cpp | 86 ------------ .../plugins/landscape_editor/builder_zone.h | 34 +---- .../landscape_editor/pixmap_database.cpp | 132 ++++++++++++++++++ .../landscape_editor/pixmap_database.h | 69 +++++++++ 5 files changed, 202 insertions(+), 120 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index 8c4278c46..2f1d58c66 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -14,7 +14,6 @@ SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h landscape_scene.h list_zones_model.h list_zones_widget.h - landscape_actions.h landscape_view.h project_settings_dialog.h snapshot_dialog.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 21ab1118b..843259ddb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -32,92 +32,6 @@ namespace LandscapeEditor { -PixmapDatabase::PixmapDatabase() - : m_textureSize(256) -{ -} - -PixmapDatabase::~PixmapDatabase() -{ - reset(); -} - -bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank) -{ - QProgressDialog *progressDialog = new QProgressDialog(); - progressDialog->show(); - - std::vector listNames; - zoneBank.getCategoryValues ("zone", listNames); - progressDialog->setRange(0, listNames.size()); - for (uint i = 0; i < listNames.size(); ++i) - { - QApplication::processEvents(); - progressDialog->setValue(i); - - NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (listNames[i]); - - // Read the texture file - QString zonePixmapName(listNames[i].c_str()); - uint8 sizeX = zoneBankItem->getSizeX(); - uint8 sizeY = zoneBankItem->getSizeY(); - - QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png"); - if (pixmap->isNull()) - { - // Generate filled pixmap - } - // All pixmaps must be have same size - if (pixmap->width() != sizeX * m_textureSize) - { - QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - delete pixmap; - m_pixmapMap.insert(zonePixmapName, scaledPixmap); - } - else - m_pixmapMap.insert(zonePixmapName, pixmap); - } - - QPixmap *pixmap = new QPixmap(zonePath + "_unused_.png"); - QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(m_textureSize, m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - delete pixmap; - m_pixmapMap.insert(QString(STRING_UNUSED), scaledPixmap); - - delete progressDialog; - return true; -} - -void PixmapDatabase::reset() -{ - QStringList listNames(m_pixmapMap.keys()); - Q_FOREACH(QString name, listNames) - { - QPixmap *pixmap = m_pixmapMap.value(name); - delete pixmap; - } - m_pixmapMap.clear(); -} - -QStringList PixmapDatabase::listPixmaps() const -{ - return m_pixmapMap.keys(); -} - -QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const -{ - QPixmap *result = 0; - if (!m_pixmapMap.contains(zoneName)) - nlwarning("QPixmap %s not found", zoneName.toStdString().c_str()); - else - result = m_pixmapMap.value(zoneName); - return result; -} - -int PixmapDatabase::textureSize() const -{ - return m_textureSize; -} - ZoneBuilder::ZoneBuilder(ListZonesWidget *listZonesWidget, LandscapeScene *landscapeScene, QUndoStack *undoStack) : m_currentZoneRegion(-1), m_pixmapDatabase(0), diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index ecc47976f..da5c2901f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -21,6 +21,7 @@ // Project includes #include "builder_zone_region.h" #include "zone_region_editor.h" +#include "pixmap_database.h" // NeL includes #include @@ -67,39 +68,6 @@ struct ZonePosition } }; -/** -@class PixmapDatabase -@brief PixmapDatabase contains the image database -@details -*/ -class PixmapDatabase -{ -public: - PixmapDatabase(); - ~PixmapDatabase(); - - /// Load all images(png) from zonePath, list images gets from zoneBank - bool loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank); - - /// Unload all images - void reset(); - - /// Get list names all loaded pixmaps - QStringList listPixmaps() const; - - /// Get original pixmap - /// @return QPixmap* if the image is in the database ; otherwise returns 0. - QPixmap *pixmap(const QString &zoneName) const; - - int textureSize() const; - -private: - - int m_textureSize; - QMap m_pixmapMap; -}; - - /** @class ZoneBuilder @brief ZoneBuilder contains all the shared data between the tools and the engine. diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp new file mode 100644 index 000000000..f0e2859f6 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp @@ -0,0 +1,132 @@ +// 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 "pixmap_database.h" + +// NeL includes +#include +#include + +// STL includes +#include +#include + +// Qt includes +#include +#include +#include +#include + +namespace LandscapeEditor +{ + +PixmapDatabase::PixmapDatabase(int textureSize) + : m_textureSize(textureSize) +{ +} + +PixmapDatabase::~PixmapDatabase() +{ + reset(); +} + +bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank, bool displayProgress) +{ + QProgressDialog *progressDialog; + std::vector listNames; + zoneBank.getCategoryValues ("zone", listNames); + if (displayProgress) + { + progressDialog = new QProgressDialog(); + progressDialog->show(); + progressDialog->setRange(0, listNames.size()); + } + + for (uint i = 0; i < listNames.size(); ++i) + { + QApplication::processEvents(); + + if (displayProgress) + progressDialog->setValue(i); + + NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (listNames[i]); + + // Read the texture file + QString zonePixmapName(listNames[i].c_str()); + uint8 sizeX = zoneBankItem->getSizeX(); + uint8 sizeY = zoneBankItem->getSizeY(); + + QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png"); + if (pixmap->isNull()) + { + // Generate filled pixmap + } + // All pixmaps must be have same size + if (pixmap->width() != sizeX * m_textureSize) + { + QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + delete pixmap; + m_pixmapMap.insert(zonePixmapName, scaledPixmap); + } + else + m_pixmapMap.insert(zonePixmapName, pixmap); + } + + QPixmap *pixmap = new QPixmap(zonePath + "_unused_.png"); + QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(m_textureSize, m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + delete pixmap; + m_pixmapMap.insert(QString(STRING_UNUSED), scaledPixmap); + + if (displayProgress) + delete progressDialog; + + return true; +} + +void PixmapDatabase::reset() +{ + QStringList listNames(m_pixmapMap.keys()); + Q_FOREACH(QString name, listNames) + { + QPixmap *pixmap = m_pixmapMap.value(name); + delete pixmap; + } + m_pixmapMap.clear(); +} + +QStringList PixmapDatabase::listPixmaps() const +{ + return m_pixmapMap.keys(); +} + +QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const +{ + QPixmap *result = 0; + if (!m_pixmapMap.contains(zoneName)) + nlwarning("QPixmap %s not found", zoneName.toStdString().c_str()); + else + result = m_pixmapMap.value(zoneName); + return result; +} + +int PixmapDatabase::textureSize() const +{ + return m_textureSize; +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h new file mode 100644 index 000000000..fc90fe180 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h @@ -0,0 +1,69 @@ +// 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 PIXMAP_DATABASE_H +#define PIXMAP_DATABASE_H + +// Project includes +#include "landscape_editor_global.h" + +// NeL includes +#include + +// Qt includes +#include +#include +#include + +namespace LandscapeEditor +{ + +/** +@class PixmapDatabase +@brief PixmapDatabase contains the image database +@details +*/ +class LANDSCAPE_EDITOR_EXPORT PixmapDatabase +{ +public: + PixmapDatabase(int textureSize = 256); + ~PixmapDatabase(); + + /// Load all images(png) from zonePath, list images gets from zoneBank + bool loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank, bool displayProgress = false); + + /// Unload all images + void reset(); + + /// Get list names all loaded pixmaps + QStringList listPixmaps() const; + + /// Get original pixmap + /// @return QPixmap* if the image is in the database ; otherwise returns 0. + QPixmap *pixmap(const QString &zoneName) const; + + int textureSize() const; + +private: + + int m_textureSize; + QMap m_pixmapMap; +}; + +} /* namespace LandscapeEditor */ + +#endif // PIXMAP_DATABASE_H From 777c00f27064a5a4b1d5269fd9aadd75051c8544 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 6 Jul 2011 03:32:02 +0300 Subject: [PATCH 015/747] Changed: #1301 Added flag "modified" in ZoneRegionObject. --- .../landscape_editor/zone_region_editor.cpp | 14 ++++++++-- .../landscape_editor/zone_region_editor.h | 28 +++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp index 81e4b687c..399d39496 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp @@ -196,12 +196,12 @@ void ZoneRegionObject::setLigoData(const LigoData &data, const sint32 x, const s m_zoneRegion.setSharingCutEdges(x, y, 3, data.sharingCutEdges[3]); } -NLLIGO::CZoneRegion &ZoneRegionObject::zoneRegion() +NLLIGO::CZoneRegion &ZoneRegionObject::ligoZoneRegion() { return m_zoneRegion; } -void ZoneRegionObject::setZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) +void ZoneRegionObject::setLigoZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) { m_zoneRegion = zoneRegion; } @@ -214,4 +214,14 @@ bool ZoneRegionObject::checkPos(const sint32 x, const sint32 y) (y <= m_zoneRegion.getMaxY())); } +bool ZoneRegionObject::isModified() const +{ + return m_modified; +} + +void ZoneRegionObject::setModified(bool modified) +{ + m_modified = modified; +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h index 2d4f063aa..9081d7002 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h @@ -32,6 +32,7 @@ namespace LandscapeEditor { +// Data struct LigoData { uint8 posX; @@ -47,33 +48,50 @@ struct LigoData bool operator!= (const LigoData& other) const; }; +/** +@class ZoneRegionObject +@brief +@details +*/ class ZoneRegionObject { public: ZoneRegionObject(); ~ZoneRegionObject(); - // Load landscape data from file + /// Load landscape data from file bool load(const std::string &fileName); - // Save landscape data to file + /// Save landscape data to file (before save, should set file name). bool save(); + /// Get ligo data void ligoData(LigoData &data, const sint32 x, const sint32 y); + /// Set ligo data void setLigoData(const LigoData &data, const sint32 x, const sint32 y); + /// Get file name std::string fileName() const; - // Set file name + /// Set file name, use for saving data in file void setFileName(const std::string &fileName); - NLLIGO::CZoneRegion &zoneRegion(); + /// Accessor to LIGO CZoneRegion + NLLIGO::CZoneRegion &ligoZoneRegion(); - void setZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); + void setLigoZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); + /// Check position, it belongs to the landscape bool checkPos(const sint32 x, const sint32 y); + /// Helper flag to know if a ps has been modified + /// @{ + bool isModified() const; + + void setModified(bool modified); + /// @} + private: bool m_modified; From eacb41e5b2aed1e1980ba64c1e0f35ac31fb2672 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 6 Jul 2011 03:34:30 +0300 Subject: [PATCH 016/747] Fixed: #1301 Fixed "full cycle" flag with empty list and added comments in list_zones_widget. --- .../src/plugins/landscape_editor/list_zones_widget.cpp | 9 ++++++--- .../src/plugins/landscape_editor/list_zones_widget.h | 10 +++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp index d0bfe058c..554b19ca3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.cpp @@ -122,9 +122,12 @@ QString ListZonesWidget::currentZoneName() else if (m_ui.zoneSelectComboBox->currentIndex() == 2) { // Full cycle - zoneName = m_listSelection[m_zoneNameCycle]; - m_zoneNameCycle++; - m_zoneNameCycle = m_zoneNameCycle % m_listSelection.size(); + if (m_listSelection.size() > 0) + { + zoneName = m_listSelection[m_zoneNameCycle]; + m_zoneNameCycle++; + m_zoneNameCycle = m_zoneNameCycle % m_listSelection.size(); + } } return zoneName; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h index 4128f8cc2..7298bbe3c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -44,14 +44,22 @@ public: ~ListZonesWidget(); void updateUi(); + + // Set zone builder, call this method before using this class void setZoneBuilder(ZoneBuilder *zoneBuilder); + + // Get current zone name which user selected from list. QString currentZoneName(); + + // Get current rotation value which user selected (Rot 0-0deg, 1-90deg, 2-180deg, 3-270deg). int currentRot(); + + // Get current flip value which user selected (Flip 0-false, 1-true). int currentFlip(); + bool isNotPropogate() const; bool isForce() const; -Q_SIGNALS: private Q_SLOTS: void updateFilters_1(const QString &value); void updateFilters_2(const QString &value); From 712349f7f5356e195532479c7386ffbe941912b0 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 6 Jul 2011 03:43:31 +0300 Subject: [PATCH 017/747] Changed: #1301 Added checking for the overlaps when adding a new landscape. Added blackout inactive landscapes. Operations adding and removing landscapes work correctly. --- .../plugins/landscape_editor/builder_zone.cpp | 165 +++++++++++++----- .../plugins/landscape_editor/builder_zone.h | 29 ++- .../landscape_editor/builder_zone_region.cpp | 40 ++--- .../landscape_editor/builder_zone_region.h | 2 +- .../landscape_editor/landscape_actions.cpp | 8 +- .../landscape_editor_window.cpp | 19 +- .../landscape_editor/landscape_scene.cpp | 49 ++++-- .../landscape_editor/landscape_scene.h | 15 +- .../landscape_editor/landscape_view.cpp | 2 + 9 files changed, 232 insertions(+), 97 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 843259ddb..265e380ca 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -32,13 +32,14 @@ namespace LandscapeEditor { -ZoneBuilder::ZoneBuilder(ListZonesWidget *listZonesWidget, LandscapeScene *landscapeScene, QUndoStack *undoStack) +ZoneBuilder::ZoneBuilder(LandscapeScene *landscapeScene, ListZonesWidget *listZonesWidget, QUndoStack *undoStack) : m_currentZoneRegion(-1), m_pixmapDatabase(0), m_listZonesWidget(listZonesWidget), m_landscapeScene(landscapeScene), m_undoStack(undoStack) { + nlassert(m_landscapeScene); m_pixmapDatabase = new PixmapDatabase(); m_lastPathName = ""; } @@ -81,6 +82,9 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone) void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zonePos) { + if (m_undoStack == 0) + return; + checkBeginMacro(); nlinfo(QString("%1 %2 %3 (%4 %5)").arg(data.zoneName.c_str()).arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).toStdString().c_str()); m_zonePositionList.push_back(zonePos); @@ -89,6 +93,9 @@ void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zoneP void ZoneBuilder::actionLigoMove(uint index, sint32 deltaX, sint32 deltaY) { + if (m_undoStack == 0) + return; + checkBeginMacro(); nlinfo("ligoMove"); //m_undoStack->push(new LigoMoveCommand(index, deltaX, deltaY, this)); @@ -96,6 +103,9 @@ void ZoneBuilder::actionLigoMove(uint index, sint32 deltaX, sint32 deltaY) void ZoneBuilder::actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY) { + if (m_undoStack == 0) + return; + checkBeginMacro(); nlinfo(QString("minX=%1 maxX=%2 minY=%3 maxY=%4").arg(newMinX).arg(newMaxX).arg(newMinY).arg(newMaxY).toStdString().c_str()); m_undoStack->push(new LigoResizeCommand(index, newMinX, newMaxX, newMinY, newMaxY, this)); @@ -103,16 +113,20 @@ void ZoneBuilder::actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, s void ZoneBuilder::addZone(sint32 posX, sint32 posY) { - if (m_builderZoneRegions.empty()) + // Read-only mode + if ((m_listZonesWidget == 0) || (m_undoStack == 0)) return; + if (m_landscapeItems.empty()) + return; + + // Check zone name std::string zoneName = m_listZonesWidget->currentZoneName().toStdString(); if (zoneName.empty()) return; - std::string error; - BuilderZoneRegion *builderZoneRegion = m_builderZoneRegions.at(m_currentZoneRegion); - builderZoneRegion->init(this, error); + BuilderZoneRegion *builderZoneRegion = m_landscapeItems.at(m_currentZoneRegion).builderZoneRegion; + builderZoneRegion->init(this); uint8 rot = uint8(m_listZonesWidget->currentRot()); uint8 flip = uint8(m_listZonesWidget->currentFlip()); @@ -122,8 +136,6 @@ void ZoneBuilder::addZone(sint32 posX, sint32 posY) m_titleAction = QString("Add zone %1,%2").arg(posX).arg(posY); m_createdAction = false; m_zonePositionList.clear(); - - nlinfo("---------"); if (m_listZonesWidget->isForce()) { builderZoneRegion->addForce(posX, posY, rot, flip, zoneBankElement); @@ -140,45 +152,95 @@ void ZoneBuilder::addZone(sint32 posX, sint32 posY) void ZoneBuilder::addTransition(const sint32 posX, const sint32 posY) { + if ((m_listZonesWidget == 0) || (m_undoStack == 0)) + return; } void ZoneBuilder::delZone(const sint32 posX, const sint32 posY) { - if (m_builderZoneRegions.empty()) + if ((m_listZonesWidget == 0) || (m_undoStack == 0)) + return; + + if (m_landscapeItems.empty()) return; m_titleAction = QString("Del zone %1,%2").arg(posX).arg(posY); m_createdAction = false; - BuilderZoneRegion *builderZoneRegion = m_builderZoneRegions.at(m_currentZoneRegion); - std::string error; - nlinfo("---------"); - builderZoneRegion->init(this, error); + BuilderZoneRegion *builderZoneRegion = m_landscapeItems.at(m_currentZoneRegion).builderZoneRegion; + + builderZoneRegion->init(this); builderZoneRegion->del(posX, posY); checkEndMacro(); } int ZoneBuilder::createZoneRegion() { - ZoneRegionObject *newZoneRegion = new ZoneRegionObject(); - m_zoneRegions.push_back(newZoneRegion); - if (m_currentZoneRegion == -1) - m_currentZoneRegion = m_zoneRegions.indexOf(newZoneRegion); + int newId = m_landscapeItems.size(); + LandscapeItem landItem; + landItem.zoneRegionObject = new ZoneRegionObject(); + landItem.builderZoneRegion = new BuilderZoneRegion(newId); + landItem.builderZoneRegion->init(this); + landItem.rectItem = 0; newZone(); - return m_zoneRegions.indexOf(newZoneRegion); + m_landscapeItems.push_back(landItem); + if (m_currentZoneRegion == -1) + setCurrentZoneRegion(newId); + + return newId; +} + +int ZoneBuilder::createZoneRegion(const QString &fileName) +{ + int newId = m_landscapeItems.size(); + LandscapeItem landItem; + landItem.zoneRegionObject = new ZoneRegionObject(); + landItem.zoneRegionObject->load(fileName.toStdString()); + + if (!checkOverlaps(landItem.zoneRegionObject->ligoZoneRegion())) + { + delete landItem.zoneRegionObject; + return -1; + } + landItem.builderZoneRegion = new BuilderZoneRegion(newId); + landItem.builderZoneRegion->init(this); + + newZone(); + m_landscapeItems.push_back(landItem); + + m_landscapeScene->addZoneRegion(landItem.zoneRegionObject->ligoZoneRegion()); + m_landscapeItems.at(newId).rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); + + if (m_currentZoneRegion == -1) + setCurrentZoneRegion(newId); + + return newId; } void ZoneBuilder::deleteZoneRegion(int id) { - if ((0 <= id) && (id < m_zoneRegions.size())) - delete m_zoneRegions.takeAt(id); + if ((0 <= id) && (id < int(m_landscapeItems.size()))) + { + m_landscapeScene->delZoneRegion(m_landscapeItems.at(id).zoneRegionObject->ligoZoneRegion()); + delete m_landscapeItems.at(id).zoneRegionObject; + delete m_landscapeItems.at(id).builderZoneRegion; + delete m_landscapeItems.at(id).rectItem; + m_landscapeItems.erase(m_landscapeItems.begin() + id); + calcMask(); + } } void ZoneBuilder::setCurrentZoneRegion(int id) { - if ((0 <= id) && (id < m_zoneRegions.size())) + if ((0 <= id) && (id < int(m_landscapeItems.size()))) + { + if (currentIdZoneRegion() != -1) + m_landscapeItems.at(m_currentZoneRegion).rectItem = m_landscapeScene->createLayerBlackout(currentZoneRegion()->ligoZoneRegion()); m_currentZoneRegion = id; + delete m_landscapeItems.at(id).rectItem; + m_landscapeItems.at(id).rectItem = 0; + } } int ZoneBuilder::currentIdZoneRegion() const @@ -188,27 +250,27 @@ int ZoneBuilder::currentIdZoneRegion() const ZoneRegionObject *ZoneBuilder::currentZoneRegion() const { - return m_zoneRegions.at(m_currentZoneRegion); + return m_landscapeItems.at(m_currentZoneRegion).zoneRegionObject; } int ZoneBuilder::countZoneRegion() const { - return m_zoneRegions.size(); + return m_landscapeItems.size(); } ZoneRegionObject *ZoneBuilder::zoneRegion(int id) const { - return m_zoneRegions.at(id); + return m_landscapeItems.at(id).zoneRegionObject; } void ZoneBuilder::ligoData(LigoData &data, const ZonePosition &zonePos) { - m_zoneRegions.at(zonePos.region)->ligoData(data, zonePos.x, zonePos.y); + m_landscapeItems.at(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y); } void ZoneBuilder::setLigoData(LigoData &data, const ZonePosition &zonePos) { - m_zoneRegions.at(zonePos.region)->setLigoData(data, zonePos.x, zonePos.y); + m_landscapeItems.at(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y); } bool ZoneBuilder::initZoneBank (const QString &pathName) @@ -243,16 +305,13 @@ QString ZoneBuilder::dataPath() const void ZoneBuilder::newZone() { - BuilderZoneRegion *builderZoneRegion = new BuilderZoneRegion(m_builderZoneRegions.size()); - m_builderZoneRegions.push_back(builderZoneRegion); - // Select starting point for the moment 0,0 sint32 x = 0, y = 0; // If there are some zone already present increase x until free - for (int i = 0; i < m_zoneRegions.size(); ++i) + for (size_t i = 0; i < m_landscapeItems.size(); ++i) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneRegions.at(i)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion(); const std::string &zoneName = zoneRegion.getName (x, y); if ((zoneName != STRING_OUT_OF_BOUND) && (zoneName != STRING_UNUSED)) { @@ -278,18 +337,17 @@ bool ZoneBuilder::getZoneMask(sint32 x, sint32 y) void ZoneBuilder::calcMask() { - sint32 i; sint32 x, y; m_minY = m_minX = 1000000; m_maxY = m_maxX = -1000000; - if (m_builderZoneRegions.size() == 0) + if (m_landscapeItems.size() == 0) return; - for (i = 0; i < (sint32)m_builderZoneRegions.size(); ++i) + for (size_t i = 0; i < m_landscapeItems.size(); ++i) { - const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->zoneRegion(); + const NLLIGO::CZoneRegion ®ion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion(); if (m_minX > region.getMinX()) m_minX = region.getMinX(); @@ -308,10 +366,10 @@ void ZoneBuilder::calcMask() { m_zoneMask[x - m_minX + (y - m_minY) * stride] = true; - for (i = 0; i < (sint32)m_builderZoneRegions.size(); ++i) - if (i != m_currentZoneRegion) + for (size_t i = 0; i < m_landscapeItems.size(); ++i) + if (int(i) != m_currentZoneRegion) { - const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->zoneRegion(); + const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->ligoZoneRegion(); const std::string &rSZone = region.getName (x, y); if ((rSZone != STRING_OUT_OF_BOUND) && (rSZone != STRING_UNUSED)) @@ -322,25 +380,24 @@ void ZoneBuilder::calcMask() } } -bool ZoneBuilder::getZoneAmongRegions (ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y) +bool ZoneBuilder::getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y) { - Q_FOREACH(ZoneRegionObject *zoneRegion, m_zoneRegions) + for (size_t i = 0; i < m_landscapeItems.size(); ++i) { - const NLLIGO::CZoneRegion ®ion = zoneRegion->zoneRegion(); + const NLLIGO::CZoneRegion ®ion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion(); if ((x < region.getMinX()) || (x > region.getMaxX()) || (y < region.getMinY()) || (y > region.getMaxY())) continue; if (region.getName(x, y) != STRING_UNUSED) { - int index = m_zoneRegions.indexOf(zoneRegion); - builderZoneRegionFrom = m_builderZoneRegions.at(index); - zonePos = ZonePosition(x, y, index); + builderZoneRegionFrom = m_landscapeItems.at(i).builderZoneRegion; + zonePos = ZonePosition(x, y, i); return true; } } // The zone is not present in other region so it is an empty or oob zone of the current region - const NLLIGO::CZoneRegion ®ion = zoneRegion(builderZoneRegionFrom->getRegionId())->zoneRegion(); + const NLLIGO::CZoneRegion ®ion = zoneRegion(builderZoneRegionFrom->getRegionId())->ligoZoneRegion(); if ((x < region.getMinX()) || (x > region.getMaxX()) || (y < region.getMinY()) || (y > region.getMaxY())) return false; // Out Of Bound @@ -372,4 +429,24 @@ void ZoneBuilder::checkEndMacro() } } +bool ZoneBuilder::checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion) +{ + for (size_t j = 0; j < m_landscapeItems.size(); ++j) + { + const NLLIGO::CZoneRegion &zoneRegion = m_landscapeItems.at(j).zoneRegionObject->ligoZoneRegion(); + for (sint32 y = zoneRegion.getMinY(); y <= zoneRegion.getMaxY(); ++y) + for (sint32 x = zoneRegion.getMinX(); x <= zoneRegion.getMaxX(); ++x) + { + const std::string &refZoneName = zoneRegion.getName(x, y); + if (refZoneName != STRING_UNUSED) + { + const std::string &zoneName = newZoneRegion.getName(x, y); + if ((zoneName != STRING_UNUSED) && (zoneName != STRING_OUT_OF_BOUND)) + return false; + } + } + } + return true; +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index da5c2901f..17d5a6f7e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -38,6 +38,7 @@ #include #include #include +#include namespace LandscapeEditor { @@ -77,7 +78,7 @@ PixmapDatabase contains the graphics for the zones class ZoneBuilder { public: - ZoneBuilder(ListZonesWidget *listZonesWidget, LandscapeScene *landscapeScene, QUndoStack *undoStack); + ZoneBuilder(LandscapeScene *landscapeScene, ListZonesWidget *listZonesWidget = 0, QUndoStack *undoStack = 0); ~ZoneBuilder(); /// Init zoneBank and init zone pixmap database @@ -88,18 +89,24 @@ public: bool getZoneMask (sint32 x, sint32 y); bool getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y); - // Ligo Actions + /// Ligo Actions + /// @{ void actionLigoTile(const LigoData &data, const ZonePosition &zonePos); void actionLigoMove(uint index, sint32 deltaX, sint32 deltaY); void actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY); + /// @} - // Zone Bricks + /// Zone Bricks + /// @{ void addZone(sint32 posX, sint32 posY); void addTransition(const sint32 posX, const sint32 posY); void delZone(const sint32 posX, const sint32 posY); + /// @} - // Zone Region + /// Zone Region + /// @{ int createZoneRegion(); + int createZoneRegion(const QString &fileName); void deleteZoneRegion(int id); void setCurrentZoneRegion(int id); int currentIdZoneRegion() const; @@ -108,6 +115,7 @@ public: ZoneRegionObject *zoneRegion(int id) const; void ligoData(LigoData &data, const ZonePosition &zonePos); void setLigoData(LigoData &data, const ZonePosition &zonePos); + /// @} // Accessors NLLIGO::CZoneBank &getZoneBank() @@ -127,15 +135,22 @@ private: void checkBeginMacro(); void checkEndMacro(); + bool checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion); + + struct LandscapeItem + { + BuilderZoneRegion *builderZoneRegion; + ZoneRegionObject *zoneRegionObject; + QGraphicsRectItem *rectItem; + }; + sint32 m_minX, m_maxX, m_minY, m_maxY; std::vector m_zoneMask; QString m_lastPathName; - QList m_zoneRegions; int m_currentZoneRegion; - - std::vector m_builderZoneRegions; + std::vector m_landscapeItems; bool m_createdAction; QString m_titleAction; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp index 2a4fc204a..b294ce97b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp @@ -35,7 +35,7 @@ BuilderZoneRegion::BuilderZoneRegion(uint regionId) { } -bool BuilderZoneRegion::init(ZoneBuilder *zoneBuilder, std::string &error) +bool BuilderZoneRegion::init(ZoneBuilder *zoneBuilder) { if (m_firstInit) return true; @@ -264,7 +264,7 @@ void BuilderZoneRegion::add(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::C void BuilderZoneRegion::invertCutEdge(sint32 x, sint32 y, uint8 cePos) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); if ((x < zoneRegion.getMinX ()) || (x > zoneRegion.getMaxX ()) || (y < zoneRegion.getMinY ()) || (y > zoneRegion.getMaxY ())) return; @@ -371,7 +371,7 @@ void BuilderZoneRegion::invertCutEdge(sint32 x, sint32 y, uint8 cePos) void BuilderZoneRegion::cycleTransition(sint32 x, sint32 y) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); if ((x < zoneRegion.getMinX ()) || (x > zoneRegion.getMaxX ()) || (y < zoneRegion.getMinY ()) || (y > zoneRegion.getMaxY ())) return; @@ -391,7 +391,7 @@ void BuilderZoneRegion::cycleTransition(sint32 x, sint32 y) bool BuilderZoneRegion::addNotPropagate (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); sint32 sizeX = zoneBankElement->getSizeX(), sizeY = zoneBankElement->getSizeY(); sint32 i, j; NLLIGO::SPiece sMask, sPosX, sPosY; @@ -472,7 +472,7 @@ bool BuilderZoneRegion::addNotPropagate (sint32 x, sint32 y, uint8 rot, uint8 fl void BuilderZoneRegion::addForce (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); sint32 sizeX = zoneBankElement->getSizeX(), sizeY = zoneBankElement->getSizeY(); sint32 i, j; NLLIGO::SPiece sMask, sPosX, sPosY; @@ -636,7 +636,7 @@ uint8 TransToEdge[72][4] = void BuilderZoneRegion::addTransition (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); uint32 i; // Check that we write in an already defined place if ((x < zoneRegion.getMinX ()) || (x > zoneRegion.getMaxX ()) || @@ -806,7 +806,7 @@ void BuilderZoneRegion::addTransition (sint32 x, sint32 y, uint8 rot, uint8 flip void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion* builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); ToUpdate *ptCreate = reinterpret_cast(pInt1); ToUpdate *ptUpdate = reinterpret_cast(pInt2); sint32 stride = (1 + zoneRegion.getMaxX() - zoneRegion.getMinX()); @@ -831,7 +831,7 @@ void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion* builderZoneRegio void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SPiece &mask, const std::string &matName, void *pInternal) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); ToUpdate tCreate; // Transition to create ToUpdate *ptUpdate = reinterpret_cast(pInternal); // Transition to update @@ -984,7 +984,7 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP // For all transition to update choose the cut edge for (m = 0; m < (sint32)tCreate.size(); ++m) { - const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->ligoZoneRegion(); x = tCreate.getX(m); y = tCreate.getY(m); @@ -1145,7 +1145,7 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP // Finally update all transition for (m = 0; m < (sint32)tCreate.size(); ++m) { - const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->ligoZoneRegion(); x = tCreate.getX(m); y = tCreate.getY(m); @@ -1155,7 +1155,7 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP } for (m = 0; m < (sint32)ptUpdate->size(); ++m) { - const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->ligoZoneRegion(); x = ptUpdate->getX(m); y = ptUpdate->getY(m); if ((x >= zoneRegion2.getMinX()) && (x <= zoneRegion2.getMaxX()) && @@ -1166,7 +1166,7 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP // Cross material for (m = 0; m < (sint32)tCreate.size(); ++m) { - const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion2 = m_zoneBuilder->zoneRegion(tCreate.getBuilderZoneRegion(m)->getRegionId())->ligoZoneRegion(); x = tCreate.getX(m); y = tCreate.getY(m); @@ -1363,7 +1363,7 @@ STrans TranConvTable[128] = void BuilderZoneRegion::updateTrans (sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); if ((x < zoneRegion.getMinX()) || (x > zoneRegion.getMaxX()) || (y < zoneRegion.getMinY()) || (y > zoneRegion.getMaxY())) return; @@ -1564,7 +1564,7 @@ void BuilderZoneRegion::updateTrans (sint32 x, sint32 y, NLLIGO::CZoneBankElemen std::string BuilderZoneRegion::getNextMatInTree (const std::string &matA, const std::string &matB) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); uint32 i, posA = 10000, posB = 10000; if (matA == matB) @@ -1600,7 +1600,7 @@ struct SNode void BuilderZoneRegion::tryPath(uint32 posA, uint32 posB, std::vector &path) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); // Build the adjascence matrix std::vector matAdj; @@ -1662,7 +1662,7 @@ void BuilderZoneRegion::tryPath(uint32 posA, uint32 posB, std::vector &p void BuilderZoneRegion::del(sint32 x, sint32 y, bool transition, void *pInternal) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); if (!m_zoneBuilder->getZoneMask(x, y)) return; @@ -1783,7 +1783,7 @@ void BuilderZoneRegion::move (sint32 x, sint32 y) uint32 BuilderZoneRegion::countZones () { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); sint32 x, y; uint32 counter = 0; @@ -1799,7 +1799,7 @@ uint32 BuilderZoneRegion::countZones () void BuilderZoneRegion::set(sint32 x, sint32 y, sint32 posX, sint32 posY, const std::string &zoneName, bool transition) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); // Do we need to resize ? if ((x < zoneRegion.getMinX()) || (x > zoneRegion.getMaxX()) || @@ -1988,7 +1988,7 @@ void BuilderZoneRegion::setFlip(sint32 x, sint32 y, uint8 flip) void BuilderZoneRegion::reduceMin () { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); sint32 i, j; sint32 newMinX = zoneRegion.getMinX(), newMinY = zoneRegion.getMinY (); @@ -2099,7 +2099,7 @@ uint BuilderZoneRegion::getRegionId() const void BuilderZoneRegion::resize (sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY) { - const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->zoneRegion(); + const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); if ((zoneRegion.getMinX ()!= newMinX) || (zoneRegion.getMaxX ()!= newMaxX) || (zoneRegion.getMinY ()!= newMinY) || diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h index 7322e47b6..63656d643 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h @@ -43,7 +43,7 @@ public: BuilderZoneRegion(uint regionId); // New interface - bool init(ZoneBuilder *zoneBuilder, std::string &error); + bool init(ZoneBuilder *zoneBuilder); void add(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement); void invertCutEdge(sint32 x, sint32 y, uint8 cePos); void cycleTransition(sint32 x, sint32 y); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp index 8aea79933..4fcf36efe 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp @@ -114,7 +114,6 @@ void UndoScanRegionCommand::undo() { for (int i = 0; i < m_zonePositionList.size(); ++i) m_scene->deleteItemZone(m_zonePositionList.at(i)); - nlinfo("------"); for (int i = 0; i < m_zonePositionList.size(); ++i) { LigoData data; @@ -152,7 +151,6 @@ void RedoScanRegionCommand::redo() { for (int i = 0; i < m_zonePositionList.size(); ++i) m_scene->deleteItemZone(m_zonePositionList.at(i)); - nlinfo("------"); for (int i = 0; i < m_zonePositionList.size(); ++i) { LigoData data; @@ -174,7 +172,7 @@ LigoResizeCommand::LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX, m_newMaxY = newMaxY; // Backup old region zone - m_oldZoneRegion = m_zoneBuilder->zoneRegion(m_index)->zoneRegion(); + m_oldZoneRegion = m_zoneBuilder->zoneRegion(m_index)->ligoZoneRegion(); } LigoResizeCommand::~LigoResizeCommand() @@ -184,13 +182,13 @@ LigoResizeCommand::~LigoResizeCommand() void LigoResizeCommand::undo () { // Restore old region zone - m_zoneBuilder->zoneRegion(m_index)->setZoneRegion(m_oldZoneRegion); + m_zoneBuilder->zoneRegion(m_index)->setLigoZoneRegion(m_oldZoneRegion); } void LigoResizeCommand::redo () { // Get the zone region - NLLIGO::CZoneRegion ®ion = m_zoneBuilder->zoneRegion(m_index)->zoneRegion(); + NLLIGO::CZoneRegion ®ion = m_zoneBuilder->zoneRegion(m_index)->ligoZoneRegion(); sint32 i, j; std::vector newZones; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index abfdcbd35..f2e2773be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -34,6 +34,7 @@ // Qt includes #include #include +#include namespace LandscapeEditor { @@ -51,7 +52,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_undoStack = new QUndoStack(this); m_landscapeScene = new LandscapeScene(this); - m_zoneBuilder = new ZoneBuilder(m_ui.zoneListWidget, m_landscapeScene, m_undoStack); + m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack); m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", true); m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); m_ui.zoneListWidget->updateUi(); @@ -96,12 +97,15 @@ void LandscapeEditorWindow::open() _lastDir = QFileInfo(list.front()).absolutePath(); Q_FOREACH(QString fileName, fileNames) { - int id = m_zoneBuilder->createZoneRegion(); + int id = m_zoneBuilder->createZoneRegion(fileName); + if (id == -1) + { + QMessageBox::critical(this, "Landscape Editor", "Cannot add this zone because it overlaps existing ones"); + continue; + } ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id); - zoneRegion->load(fileName.toStdString()); - m_landscapeScene->processZoneRegion(zoneRegion->zoneRegion()); - m_ui.graphicsView->centerOn(zoneRegion->zoneRegion().getMinX() * m_landscapeScene->cellSize(), - abs(zoneRegion->zoneRegion().getMinY()) * m_landscapeScene->cellSize()); + m_ui.graphicsView->centerOn(zoneRegion->ligoZoneRegion().getMinX() * m_landscapeScene->cellSize(), + abs(zoneRegion->ligoZoneRegion().getMinY()) * m_landscapeScene->cellSize()); m_zoneBuilder->setCurrentZoneRegion(id); } @@ -157,7 +161,8 @@ void LandscapeEditorWindow::openSnapshotDialog() void LandscapeEditorWindow::showEvent(QShowEvent *showEvent) { QMainWindow::showEvent(showEvent); - m_oglWidget->makeCurrent(); + if (m_oglWidget != 0) + m_oglWidget->makeCurrent(); } void LandscapeEditorWindow::createMenus() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 65316d9f7..82606f74a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -17,6 +17,7 @@ // Project includes #include "landscape_scene.h" +#include "pixmap_database.h" // NeL includes #include @@ -29,7 +30,10 @@ namespace LandscapeEditor { -static const int ZoneName = 0; +static const int ZONE_NAME = 0; +static const int LAYER_ZONES = 2; +static const int LAYER_EMPTY_ZONES = 3; +static const int LAYER_BLACKOUT = 4; LandscapeScene::LandscapeScene(QObject *parent) : QGraphicsScene(parent), @@ -78,19 +82,18 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo if (data.flip == 0) { - item = new QGraphicsPixmapItem(pixmap->transformed(matrix, Qt::SmoothTransformation), 0, this); + item = addPixmap(pixmap->transformed(matrix, Qt::SmoothTransformation)); } else { // mirror image QImage mirrorImage = pixmap->toImage(); QPixmap mirrorPixmap = QPixmap::fromImage(mirrorImage.mirrored(true, false)); - item = new QGraphicsPixmapItem(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation), 0, this); + item = addPixmap(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation)); } // Enable bilinear filtering item->setTransformationMode(Qt::SmoothTransformation); - // Set position graphics item with offset for large piece NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName); sint32 deltaX = 0, deltaY = 0; @@ -145,16 +148,16 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo } } - // set position graphics item with taking into account the offset + // Set position graphics item with offset for large piece item->setPos((zonePos.x + deltaX) * m_cellSize, (abs(int(zonePos.y + deltaY))) * m_cellSize); // The size graphics item should be equal or proportional m_cellSize item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); - item->setData(ZoneName, QString(data.zoneName.c_str())); + //item->setData(ZONE_NAME, QString(data.zoneName.c_str())); // for not full item zone - item->setZValue(0); + item->setZValue(LAYER_ZONES); return item; } @@ -169,7 +172,7 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos) if (pixmap == 0) return 0; - QGraphicsPixmapItem *item = new QGraphicsPixmapItem(*pixmap, 0, this); + QGraphicsPixmapItem *item = addPixmap(*pixmap); // Enable bilinear filtering item->setTransformationMode(Qt::SmoothTransformation); @@ -181,11 +184,23 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos) item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); // for not full item zone - item->setZValue(1); + item->setZValue(LAYER_EMPTY_ZONES); return item; } +QGraphicsRectItem *LandscapeScene::createLayerBlackout(const NLLIGO::CZoneRegion &zoneRegion) +{ + QGraphicsRectItem *rectItem = addRect(zoneRegion.getMinX() * m_cellSize, + abs(zoneRegion.getMaxY()) * m_cellSize, + (abs(zoneRegion.getMaxX() - zoneRegion.getMinX()) + 1) * m_cellSize, + (abs(zoneRegion.getMaxY() - zoneRegion.getMinY()) + 1) * m_cellSize, + Qt::NoPen, QBrush(QColor(0, 0, 0, 50))); + + rectItem->setZValue(LAYER_BLACKOUT); + return rectItem; +} + void LandscapeScene::deleteItemZone(const ZonePosition &zonePos) { QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize); @@ -196,12 +211,13 @@ void LandscapeScene::deleteItemZone(const ZonePosition &zonePos) } } -void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) +void LandscapeScene::addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) { for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) { for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) { + //nlinfo(QString("%1 %2 %3").arg(i).arg(j).arg(zoneRegion.getName(i, j).c_str()).toStdString().c_str()); std::string zoneName = zoneRegion.getName(i, j); if (zoneName == STRING_UNUSED) @@ -224,6 +240,17 @@ void LandscapeScene::processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) } } +void LandscapeScene::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) +{ + for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) + { + for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) + { + deleteItemZone(ZonePosition(i, -j, -1)); + } + } +} + void LandscapeScene::snapshot(const QString &fileName, int sizeSource) { /* if (m_zoneRegion == 0) @@ -305,7 +332,9 @@ bool LandscapeScene::checkUnderZone(const int posX, const int posY) { QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize); if (item != 0) + { return true; + } return false; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index 525971999..7e60febaf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -21,6 +21,7 @@ // Project includes #include "zone_region_editor.h" #include "builder_zone.h" +#include "landscape_editor_global.h" // NeL includes #include @@ -32,7 +33,12 @@ namespace LandscapeEditor { -class LandscapeScene : public QGraphicsScene +/** +@class LandscapeScene +@brief +@details +*/ +class LANDSCAPE_EDITOR_EXPORT LandscapeScene : public QGraphicsScene { Q_OBJECT @@ -45,15 +51,18 @@ public: QGraphicsItem *createItemZone(const LigoData &data, const ZonePosition &zonePos); QGraphicsItem *createItemEmptyZone(const ZonePosition &zonePos); + QGraphicsRectItem *createLayerBlackout(const NLLIGO::CZoneRegion &zoneRegion); void deleteItemZone(const ZonePosition &zonePos); - void processZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); + + void addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); + void delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); void snapshot(const QString &fileName, int sizeSource); void snapshot(const QString &fileName, int width, int height); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); virtual void drawForeground(QPainter *painter, const QRectF &rect); private: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index e32f4ae6d..84bc4b47d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -41,6 +41,7 @@ LandscapeView::LandscapeView(QWidget *parent) setBackgroundBrush(QBrush(Qt::lightGray)); //setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); //setRenderHints(QPainter::Antialiasing); + //setCacheMode(QGraphicsView::CacheBackground); m_cellSize = 160; m_numSteps = 0; m_maxSteps = 20; @@ -83,6 +84,7 @@ void LandscapeView::wheelEvent(QWheelEvent *event) --m_numSteps; } scale(factor, factor); + QGraphicsView::wheelEvent(event); } void LandscapeView::mousePressEvent(QMouseEvent *event) From 46b4ff3a6dad79a4da5eda46b53a55cc6f28c7f3 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 6 Jul 2011 04:38:38 +0300 Subject: [PATCH 018/747] Changed: #1301 Completed snapshot dialog. --- .../landscape_editor_window.cpp | 28 +++++++++- .../landscape_editor/landscape_scene.cpp | 54 +++++-------------- .../landscape_editor/landscape_scene.h | 3 +- .../landscape_editor/shapshot_dialog.ui | 40 +++++++++----- .../landscape_editor/snapshot_dialog.cpp | 26 +++++++++ .../landscape_editor/snapshot_dialog.h | 6 +++ 6 files changed, 100 insertions(+), 57 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index f2e2773be..5f5fad552 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -152,7 +152,33 @@ void LandscapeEditorWindow::openSnapshotDialog() tr("Image file (*.png)")); setCursor(Qt::WaitCursor); - m_landscapeScene->snapshot(fileName, 128); + + NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->currentZoneRegion()->ligoZoneRegion(); + sint32 regionMinX = zoneRegion.getMinX(); + sint32 regionMaxX = zoneRegion.getMaxX(); + sint32 regionMinY = zoneRegion.getMinY(); + sint32 regionMaxY = zoneRegion.getMaxY(); + + int regionWidth = (regionMaxX - regionMinX + 1); + int regionHeight = (regionMaxY - regionMinY + 1); + + int cellSize = m_landscapeScene->cellSize(); + QRectF rect(regionMinX * cellSize, abs(regionMaxY) * cellSize, regionWidth * cellSize, regionHeight * cellSize); + + if (dialog->isCustomSize()) + { + int widthSnapshot = dialog->widthSnapshot(); + int heightSnapshot = dialog->heightSnapshot(); + if (dialog->isKeepRatio()) + heightSnapshot = (widthSnapshot / regionWidth) * regionHeight; + + m_landscapeScene->snapshot(fileName, widthSnapshot, heightSnapshot, rect); + } + else + { + m_landscapeScene->snapshot(fileName, regionWidth * dialog->resolutionZone(), + regionHeight * dialog->resolutionZone(), rect); + } setCursor(Qt::ArrowCursor); } delete dialog; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 82606f74a..81a94fb1f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -218,7 +218,6 @@ void LandscapeScene::addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) { - //nlinfo(QString("%1 %2 %3").arg(i).arg(j).arg(zoneRegion.getName(i, j).c_str()).toStdString().c_str()); std::string zoneName = zoneRegion.getName(i, j); if (zoneName == STRING_UNUSED) { @@ -251,53 +250,26 @@ void LandscapeScene::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) } } -void LandscapeScene::snapshot(const QString &fileName, int sizeSource) -{ - /* if (m_zoneRegion == 0) - return; - - sint32 regionMinX = m_zoneRegion->getMinX(); - sint32 regionMaxX = m_zoneRegion->getMaxX(); - sint32 regionMinY = m_zoneRegion->getMinY(); - sint32 regionMaxY = m_zoneRegion->getMaxY(); - - int regionWidth = (regionMaxX - regionMinX + 1); - int regionHeight = (regionMaxY - regionMinY + 1); - - snapshot(fileName, regionWidth * sizeSource, regionHeight * sizeSource); - */ -} - -void LandscapeScene::snapshot(const QString &fileName, int width, int height) +void LandscapeScene::snapshot(const QString &fileName, int width, int height, const QRectF &landRect) { if (m_zoneBuilder == 0) return; - /* if (m_zoneRegion == 0) - return; + // Create image + QImage image(landRect.width(), landRect.height(), QImage::Format_RGB888); + QPainter painter(&image); + painter.setRenderHint(QPainter::Antialiasing, true); - sint32 regionMinX = m_zoneRegion->getMinX(); - sint32 regionMaxX = m_zoneRegion->getMaxX(); - sint32 regionMinY = m_zoneRegion->getMinY(); - sint32 regionMaxY = m_zoneRegion->getMaxY(); + // Add white background + painter.setBrush(QBrush(Qt::white)); + painter.setPen(Qt::NoPen); + painter.drawRect(0, 0, landRect.width(), landRect.height()); - int regionWidth = (regionMaxX - regionMinX + 1); - int regionHeight = (regionMaxY - regionMinY + 1); + // Paint landscape + render(&painter, QRectF(0, 0, landRect.width(), landRect.height()), landRect); - QImage image(width, height, QImage::Format_RGB888); - QPainter painter(&image); - painter.setRenderHint(QPainter::Antialiasing, true); - - // add white background - painter.setBrush(QBrush(Qt::white)); - painter.setPen(Qt::NoPen); - painter.drawRect(0, 0, width, height); - - render(&painter, QRectF(0, 0, width, height), - QRectF(regionMinX * m_cellSize, abs(regionMaxY) * m_cellSize, regionWidth * m_cellSize, regionHeight * m_cellSize)); - - image.save(fileName); - */ + QImage scaledImage = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + scaledImage.save(fileName); } void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index 7e60febaf..34fe50e05 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -57,8 +57,7 @@ public: void addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); void delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); - void snapshot(const QString &fileName, int sizeSource); - void snapshot(const QString &fileName, int width, int height); + void snapshot(const QString &fileName, int width, int height, const QRectF &landRect); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui index 792d9f7a4..1c25a2ace 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui @@ -6,8 +6,8 @@ 0 0 - 286 - 182 + 230 + 187 @@ -15,19 +15,33 @@ - - - Original size - - - true - - + + + + + Original size + + + true + + + + + + + 1024 + + + 128 + + + + - false + true Custom size @@ -59,7 +73,7 @@ false - TextLabel + Height: heightSpinBox @@ -82,7 +96,7 @@ - TextLabel + Width: widthSpinBox diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp index ff6ef1673..ab2579722 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp @@ -36,10 +36,36 @@ SnapshotDialog::SnapshotDialog(QWidget *parent) : QDialog(parent) { m_ui.setupUi(this); + setFixedHeight(sizeHint().height()); } SnapshotDialog::~SnapshotDialog() { } +bool SnapshotDialog::isCustomSize() const +{ + return m_ui.customSizeRadioButton->isChecked(); +} + +bool SnapshotDialog::isKeepRatio() const +{ + return m_ui.keepRatioCheckBox->isChecked(); +} + +int SnapshotDialog::resolutionZone() const +{ + return m_ui.resSpinBox->value(); +} + +int SnapshotDialog::widthSnapshot() const +{ + return m_ui.widthSpinBox->value(); +} + +int SnapshotDialog::heightSnapshot() const +{ + return m_ui.heightSpinBox->value(); +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h index 906d59498..b66133a07 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h @@ -34,6 +34,12 @@ public: SnapshotDialog(QWidget *parent = 0); ~SnapshotDialog(); + bool isCustomSize() const; + bool isKeepRatio() const; + int resolutionZone() const; + int widthSnapshot() const; + int heightSnapshot() const; + private Q_SLOTS: From 90464fa2f288bf6b567d934ac909b9e7bcf0a468 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 6 Jul 2011 18:52:10 +0300 Subject: [PATCH 019/747] Changed: #1301 Added dialog with a list of landscapes and operations (setActive, save, saveAs, delete). --- .../plugins/landscape_editor/builder_zone.cpp | 10 +- .../landscape_editor_window.cpp | 191 ++++++++++++++++-- .../landscape_editor_window.h | 11 + .../landscape_editor_window.ui | 81 +++++++- 4 files changed, 265 insertions(+), 28 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 265e380ca..9550b1f76 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -222,10 +222,11 @@ void ZoneBuilder::deleteZoneRegion(int id) { if ((0 <= id) && (id < int(m_landscapeItems.size()))) { + if (m_landscapeItems.at(id).rectItem != 0) + delete m_landscapeItems.at(id).rectItem; m_landscapeScene->delZoneRegion(m_landscapeItems.at(id).zoneRegionObject->ligoZoneRegion()); delete m_landscapeItems.at(id).zoneRegionObject; delete m_landscapeItems.at(id).builderZoneRegion; - delete m_landscapeItems.at(id).rectItem; m_landscapeItems.erase(m_landscapeItems.begin() + id); calcMask(); } @@ -236,10 +237,13 @@ void ZoneBuilder::setCurrentZoneRegion(int id) if ((0 <= id) && (id < int(m_landscapeItems.size()))) { if (currentIdZoneRegion() != -1) - m_landscapeItems.at(m_currentZoneRegion).rectItem = m_landscapeScene->createLayerBlackout(currentZoneRegion()->ligoZoneRegion()); - m_currentZoneRegion = id; + { + NLLIGO::CZoneRegion &ligoRegion = m_landscapeItems.at(m_currentZoneRegion).zoneRegionObject->ligoZoneRegion(); + m_landscapeItems.at(m_currentZoneRegion).rectItem = m_landscapeScene->createLayerBlackout(ligoRegion); + } delete m_landscapeItems.at(id).rectItem; m_landscapeItems.at(id).rectItem = 0; + m_currentZoneRegion = id; } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 5f5fad552..da949fea5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -33,15 +33,20 @@ // Qt includes #include +#include #include #include namespace LandscapeEditor { + +static const int LANDSCAPE_ID = 32; +int NewLandCounter = 0; QString _lastDir; LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) : QMainWindow(parent), + m_currentRow(-1), m_landscapeScene(0), m_zoneBuilder(0), m_undoStack(0), @@ -53,7 +58,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_landscapeScene = new LandscapeScene(this); m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack); - m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", true); + m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); m_ui.zoneListWidget->updateUi(); @@ -63,6 +68,12 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers)); m_ui.graphicsView->setViewport(m_oglWidget); + m_ui.newLandAction->setIcon(QIcon(Core::Constants::ICON_NEW)); + m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); + m_ui.saveLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); + m_ui.saveAsLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS)); + m_ui.deleteLandAction->setEnabled(false); + createMenus(); createToolBars(); readSettings(); @@ -71,6 +82,16 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) connect(m_ui.projectSettingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings())); connect(m_ui.snapshotAction, SIGNAL(triggered()), this, SLOT(openSnapshotDialog())); connect(m_ui.enableGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool))); + + connect(m_ui.newLandAction, SIGNAL(triggered()), this, SLOT(newLand())); + connect(m_ui.setActiveLandAction, SIGNAL(triggered()), this, SLOT(setActiveLand())); + connect(m_ui.saveLandAction, SIGNAL(triggered()), this, SLOT(saveSelectedLand())); + connect(m_ui.saveAsLandAction, SIGNAL(triggered()), this, SLOT(saveAsSelectedLand())); + connect(m_ui.deleteLandAction, SIGNAL(triggered()), this, SLOT(deleteSelectedLand())); + + connect(m_ui.landscapesListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu())); + m_ui.landscapesListWidget->setContextMenuPolicy(Qt::CustomContextMenu); + } LandscapeEditorWindow::~LandscapeEditorWindow() @@ -97,17 +118,9 @@ void LandscapeEditorWindow::open() _lastDir = QFileInfo(list.front()).absolutePath(); Q_FOREACH(QString fileName, fileNames) { - int id = m_zoneBuilder->createZoneRegion(fileName); - if (id == -1) - { - QMessageBox::critical(this, "Landscape Editor", "Cannot add this zone because it overlaps existing ones"); - continue; - } - ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id); - m_ui.graphicsView->centerOn(zoneRegion->ligoZoneRegion().getMinX() * m_landscapeScene->cellSize(), - abs(zoneRegion->ligoZoneRegion().getMinY()) * m_landscapeScene->cellSize()); - - m_zoneBuilder->setCurrentZoneRegion(id); + int row = createLandscape(fileName); + if (row != -1) + setActiveLandscape(row); } } setCursor(Qt::ArrowCursor); @@ -115,16 +128,7 @@ void LandscapeEditorWindow::open() void LandscapeEditorWindow::save() { - ZoneRegionObject *zoneRegion = m_zoneBuilder->currentZoneRegion(); - if (zoneRegion->fileName().empty()) - { - QString fileName = QFileDialog::getSaveFileName(this, - tr("Save NeL Ligo land file"), _lastDir, - tr("NeL Ligo land file (*.land)")); - if (!fileName.isEmpty()) - zoneRegion->setFileName(fileName.toStdString()); - } - zoneRegion->save(); + saveLandscape(m_currentRow, true); } void LandscapeEditorWindow::openProjectSettings() @@ -184,6 +188,133 @@ void LandscapeEditorWindow::openSnapshotDialog() delete dialog; } +void LandscapeEditorWindow::customContextMenu() +{ + if (m_ui.landscapesListWidget->currentRow() == -1) + return; + QMenu *popurMenu = new QMenu(this); + popurMenu->addAction(m_ui.setActiveLandAction); + popurMenu->addAction(m_ui.saveLandAction); + popurMenu->addAction(m_ui.saveAsLandAction); + popurMenu->addAction(m_ui.deleteLandAction); + popurMenu->exec(QCursor::pos()); + delete popurMenu; +} + +void LandscapeEditorWindow::newLand() +{ + createLandscape(QString()); +} + +void LandscapeEditorWindow::setActiveLand() +{ + setActiveLandscape(m_ui.landscapesListWidget->currentRow()); +} + +void LandscapeEditorWindow::saveSelectedLand() +{ + saveLandscape(m_ui.landscapesListWidget->currentRow(), true); +} + +void LandscapeEditorWindow::saveAsSelectedLand() +{ + saveLandscape(m_ui.landscapesListWidget->currentRow(), false); +} + +void LandscapeEditorWindow::deleteSelectedLand() +{ + int row = m_ui.landscapesListWidget->currentRow(); + QListWidgetItem *item = m_ui.landscapesListWidget->item(row); + if (row == m_currentRow) + { + if (row == 0) + ++row; + else + --row; + setActiveLandscape(row); + } + m_zoneBuilder->deleteZoneRegion(item->data(LANDSCAPE_ID).toInt()); + m_ui.landscapesListWidget->removeItemWidget(item); + delete item; + if (m_ui.landscapesListWidget->count() == 1) + m_ui.deleteLandAction->setEnabled(false); +} + +int LandscapeEditorWindow::createLandscape(const QString &fileName) +{ + int id; + if (fileName.isEmpty()) + id = m_zoneBuilder->createZoneRegion(); + else + id = m_zoneBuilder->createZoneRegion(fileName); + + if (id == -1) + { + QMessageBox::critical(this, "Landscape Editor", "Cannot add this zone because it overlaps existing ones"); + return -1; + } + ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id); + m_ui.graphicsView->centerOn(zoneRegion->ligoZoneRegion().getMinX() * m_landscapeScene->cellSize(), + abs(zoneRegion->ligoZoneRegion().getMinY()) * m_landscapeScene->cellSize()); + + QListWidgetItem *item; + if (fileName.isEmpty()) + item = new QListWidgetItem(QString("NewLandscape%1").arg(NewLandCounter++), m_ui.landscapesListWidget); + else + item = new QListWidgetItem(fileName, m_ui.landscapesListWidget); + + item->setData(LANDSCAPE_ID, id); + item->setFont(QFont("SansSerif", 9, QFont::Normal)); + + if (m_ui.landscapesListWidget->count() > 1) + m_ui.deleteLandAction->setEnabled(true); + + return m_ui.landscapesListWidget->count() - 1; +} + +void LandscapeEditorWindow::setActiveLandscape(int row) +{ + if ((0 <= row) && (row < m_ui.landscapesListWidget->count())) + { + if (m_currentRow != -1) + { + QListWidgetItem *item = m_ui.landscapesListWidget->item(m_currentRow); + item->setFont(QFont("SansSerif", 9, QFont::Normal)); + } + QListWidgetItem *item = m_ui.landscapesListWidget->item(row); + item->setFont(QFont("SansSerif", 9, QFont::Bold)); + m_zoneBuilder->setCurrentZoneRegion(item->data(LANDSCAPE_ID).toInt()); + m_currentRow = row; + } +} + +void LandscapeEditorWindow::saveLandscape(int row, bool force) +{ + if ((0 <= row) && (row < m_ui.landscapesListWidget->count())) + { + QListWidgetItem *item = m_ui.landscapesListWidget->item(row); + ZoneRegionObject *regionObject = m_zoneBuilder->zoneRegion(item->data(LANDSCAPE_ID).toInt()); + if ((!force) || (regionObject->fileName().empty())) + { + QString fileName = QFileDialog::getSaveFileName(this, + tr("Save NeL Ligo land file"), _lastDir, + tr("NeL Ligo land file (*.land)")); + if (!fileName.isEmpty()) + { + regionObject->setFileName(fileName.toStdString()); + regionObject->save(); + regionObject->setModified(false); + item->setText(fileName); + } + } + else + { + regionObject->save(); + regionObject->setModified(false); + } + } +} + void LandscapeEditorWindow::showEvent(QShowEvent *showEvent) { QMainWindow::showEvent(showEvent); @@ -202,7 +333,23 @@ void LandscapeEditorWindow::createToolBars() //QAction *action = menuManager->action(Core::Constants::NEW); //m_ui.fileToolBar->addAction(action); QAction *action = menuManager->action(Core::Constants::OPEN); + m_ui.fileToolBar->addAction(m_ui.newLandAction); m_ui.fileToolBar->addAction(action); + m_ui.fileToolBar->addAction(m_ui.saveAction); + + const char * const UNDO = "ObjectViewerQt.Undo"; + const char * const REDO = "ObjectViewerQt.Redo"; + + //action = menuManager->action(Core::Constants::UNDO); + action = menuManager->action(UNDO); + if (action != 0) + m_ui.undoToolBar->addAction(action); + + //action = menuManager->action(Core::Constants::REDO); + action = menuManager->action(REDO); + if (action != 0) + m_ui.undoToolBar->addAction(action); + //action = menuManager->action(Core::Constants::SAVE); //m_ui.fileToolBar->addAction(action); //action = menuManager->action(Core::Constants::SAVE_AS); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index ff9cfd273..f3421f120 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -49,6 +49,12 @@ public Q_SLOTS: private Q_SLOTS: void openProjectSettings(); void openSnapshotDialog(); + void customContextMenu(); + void newLand(); + void setActiveLand(); + void saveSelectedLand(); + void saveAsSelectedLand(); + void deleteSelectedLand(); protected: virtual void showEvent(QShowEvent *showEvent); @@ -59,6 +65,11 @@ private: void readSettings(); void writeSettings(); + void setActiveLandscape(int row); + void saveLandscape(int row, bool force); + int createLandscape(const QString &fileName); + + int m_currentRow; LandscapeScene *m_landscapeScene; ZoneBuilder *m_zoneBuilder; QUndoStack *m_undoStack; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index 57eadda73..7d71acd49 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -62,7 +62,7 @@ - + toolBar_2 @@ -72,9 +72,40 @@ false - - + + + + Landscapes + + + 1 + + + + + 3 + + + 3 + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + @@ -113,6 +144,50 @@ Save + + + + :/icons/ic_nel_zone.png:/icons/ic_nel_zone.png + + + Set active + + + Set active selected landscape + + + + + Save + + + Save selected landscape + + + + + Save As landscape + + + Save as selected landscape + + + + + Delete + + + Delete selected landscape + + + + + New + + + Create new landscape + + From 005e576b22d185066952c112c0e84341904e5d9c Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 11 Jul 2011 00:23:28 +0300 Subject: [PATCH 020/747] Changed: #1302 Added basic shell of World editor plugin. --- .../src/plugins/world_editor/CMakeLists.txt | 48 +++++++ .../icons/ic_nel_world_editor.png | Bin 0 -> 44031 bytes .../src/plugins/world_editor/world_editor.qrc | 5 + .../world_editor/world_editor_constants.h | 39 ++++++ .../world_editor/world_editor_global.h | 30 ++++ .../world_editor/world_editor_plugin.cpp | 128 ++++++++++++++++++ .../world_editor/world_editor_plugin.h | 108 +++++++++++++++ .../world_editor/world_editor_window.cpp | 119 ++++++++++++++++ .../world_editor/world_editor_window.h | 57 ++++++++ .../world_editor/world_editor_window.ui | 54 ++++++++ 10 files changed, 588 insertions(+) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_world_editor.png create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor.qrc create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_global.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt new file mode 100644 index 000000000..784dd6139 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt @@ -0,0 +1,48 @@ +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${QT_INCLUDES}) + +FILE(GLOB SRC *.cpp *.h) + +SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) + +SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h + world_editor_window.h +) + +SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui +) + +SET(OVQT_PLUGIN_WORLD_EDITOR_RCS world_editor.qrc) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTOPENGL TRUE) + +QT4_ADD_RESOURCES(OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS ${OVQT_PLUGIN_WORLD_EDITOR_RCS}) +QT4_WRAP_CPP(OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC ${OVQT_PLUGIN_WORLD_EDITOR_HDR}) +QT4_WRAP_UI(OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS ${OVQT_PLUGIN_WORLD_EDITOR_UIS}) + +SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_WORLD_EDITOR_UIS}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS}) +SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC} OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS) +SOURCE_GROUP("World Editor Plugin" FILES ${SRC}) +SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) + +ADD_LIBRARY(ovqt_plugin_world_editor MODULE ${SRC} + ${OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC} + ${OVQT_EXT_SYS_SRC} + ${OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS} + ${OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS}) + +TARGET_LINK_LIBRARIES(ovqt_plugin_world_editor ovqt_plugin_core ovqt_plugin_landscape_editor nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) + +NL_DEFAULT_PROPS(ovqt_plugin_world_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: World Editor") +NL_ADD_RUNTIME_FLAGS(ovqt_plugin_world_editor) +NL_ADD_LIB_SUFFIX(ovqt_plugin_world_editor) + +ADD_DEFINITIONS(-DWORLD_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) + +INSTALL(TARGETS ovqt_plugin_world_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_world_editor.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_world_editor.png new file mode 100644 index 0000000000000000000000000000000000000000..d41f64e2fa43da9d64f9b528cc173593d4a94c59 GIT binary patch literal 44031 zcmbSy z1H=5hzt4a0yf~k8)_HOET6@Lb`&!qD*Vk1iC88$+005+#8Y+eW0Px=<5I}(U?`G*; z>G+@IW2mkKs2gY8{U?B(6m=8)Dk{n+I?b-sRHCt8L@5d)PDrAiSmkim=m;iY zfq4JluLR~vRMh+{^Rs4qpQUqtdYdch`5VVh=v!do^RXOpi^#*^SF~a-Q?HcL4-R@s z86@~$%{K(CUtgnzJ9ha5=aXWgQvWGYIZpC*8lMlshZlN?D;wy_+Cr~dvDZTw}L=^v&#Uh`d8MX5;}_Sx3i&u$NAw$w)U zmD+Cl9dgX*un>4-qyk!=#&wg9FNU$M@zxziz+AE86mm z@x_`)^(m(Rp6a|Mp_6oJuC)x&o_!_7Git(=%E8B+a`W~$bBX3R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_y`@o$xJ#4aMz><*n$Ev zr6mA67{Zw3{(Mx>uzz(b!u%85^rT`3X>qM0OrTE)Tx$y;fs{((!*qr`SvYTKzsusw zK{g*~0vP-J^qfltC`CW{mvGAUJcwF(9@`>`X}tmnn65X-TvuQE&_i?)1fup-%EPAx z2Nhc7Y+f^8Fg_mW*6&qsJ-Ac}i}9BcBbuu zpAl#l@*yY9>EJTF19^AId+aS;byToL@B6_^0hm@`)^J27|sfFn--Ve^tDo+F@pJ zjc7z5nT={k?*c!G68vzXyZQa?zng9k*jg3S?&?ZHeS!MX&QnSm@(uVYftwiJ_yixQwWpz<MSP0W;jh+Ww98^OdjL#f7egXUQpU4b2C#Ufm5~_sAKg^Bvh=NRfH-I#X%DbN3Zl;HB zmj&JD8&TyVP?cA2WMX|d4Ko-O+bAr~SX39ghA&S(!LB+%nDvbh6z3Y+==j<%K*GG#l9`@ghErdb{@r}mnQ+wU;A#Fwg{$=pMRJTFf GHST}F+s82g literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor.qrc b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor.qrc new file mode 100644 index 000000000..f7c54fd5f --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor.qrc @@ -0,0 +1,5 @@ + + + icons/ic_nel_world_editor.png + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h new file mode 100644 index 000000000..644f79b53 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -0,0 +1,39 @@ +// 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 WORLD_EDITOR_CONSTANTS_H +#define WORLD_EDITOR_CONSTANTS_H + +namespace WorldEditor +{ +namespace Constants +{ +const char * const WORLD_EDITOR_PLUGIN = "WorldEditor"; + +//settings +const char * const WORLD_EDITOR_SECTION = "WorldEditor"; +const char * const WORLD_WINDOW_STATE = "WorldWindowState"; +const char * const WORLD_WINDOW_GEOMETRY = "WorldWindowGeometry"; + +//resources +const char * const ICON_WORLD_EDITOR = ":/icons/ic_nel_world_editor.png"; + + +} // namespace Constants +} // namespace WorldEditor + +#endif // WORLD_EDITOR_CONSTANTS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_global.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_global.h new file mode 100644 index 000000000..a7a94ca75 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_global.h @@ -0,0 +1,30 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef WORLD_EDITOR_GLOBAL_H +#define WORLD_EDITOR_GLOBAL_H + +#include + +#if defined(WORLD_EDITOR_LIBRARY) +# define WORLD_EDITOR_EXPORT Q_DECL_EXPORT +#else +# define WORLD_EDITOR_EXPORT Q_DECL_IMPORT +#endif + +#endif // WORLD_EDITOR_GLOBAL_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp new file mode 100644 index 000000000..494f6e2b6 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp @@ -0,0 +1,128 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "world_editor_plugin.h" +#include "world_editor_window.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +// NeL includes +#include "nel/misc/debug.h" + +// Qt includes +#include + +namespace WorldEditor +{ + +WorldEditorPlugin::~WorldEditorPlugin() +{ + Q_FOREACH(QObject *obj, m_autoReleaseObjects) + { + m_plugMan->removeObject(obj); + } + qDeleteAll(m_autoReleaseObjects); + m_autoReleaseObjects.clear(); +} + +bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) +{ + Q_UNUSED(errorString); + m_plugMan = pluginManager; + + addAutoReleasedObject(new WorldEditorContext(this)); + return true; +} + +void WorldEditorPlugin::extensionsInitialized() +{ +} + +void WorldEditorPlugin::shutdown() +{ +} + +void WorldEditorPlugin::setNelContext(NLMISC::INelContext *nelContext) +{ +#ifdef NL_OS_WINDOWS + // Ensure that a context doesn't exist yet. + // This only applies to platforms without PIC, e.g. Windows. + nlassert(!NLMISC::INelContext::isContextInitialised()); +#endif // NL_OS_WINDOWS + m_libContext = new NLMISC::CLibraryContext(*nelContext); +} + +QString WorldEditorPlugin::name() const +{ + return tr("WorldEditor"); +} + +QString WorldEditorPlugin::version() const +{ + return "0.0.1"; +} + +QString WorldEditorPlugin::vendor() const +{ + return "GSoC2011_dnk-88"; +} + +QString WorldEditorPlugin::description() const +{ + return "World editor ovqt plugin."; +} + +QStringList WorldEditorPlugin::dependencies() const +{ + QStringList list; + list.append(Core::Constants::OVQT_CORE_PLUGIN); + return list; +} + +void WorldEditorPlugin::addAutoReleasedObject(QObject *obj) +{ + m_plugMan->addObject(obj); + m_autoReleaseObjects.prepend(obj); +} + +WorldEditorContext::WorldEditorContext(QObject *parent) + : IContext(parent), + m_worldEditorWindow(0) +{ + m_worldEditorWindow = new WorldEditorWindow(); +} + +QUndoStack *WorldEditorContext::undoStack() +{ + return m_worldEditorWindow->undoStack(); +} + +void WorldEditorContext::open() +{ + //m_worldEditorWindow->open(); +} + +QWidget *WorldEditorContext::widget() +{ + return m_worldEditorWindow; +} + +} + +Q_EXPORT_PLUGIN(WorldEditor::WorldEditorPlugin) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h new file mode 100644 index 000000000..fdfff7eff --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h @@ -0,0 +1,108 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef WORLD_EDITOR_PLUGIN_H +#define WORLD_EDITOR_PLUGIN_H + +// Project includes +#include "world_editor_constants.h" +#include "../../extension_system/iplugin.h" +#include "../core/icontext.h" + +// NeL includes +#include "nel/misc/app_context.h" + +// Qt includes +#include +#include + +namespace NLMISC +{ +class CLibraryContext; +} + +namespace ExtensionSystem +{ +class IPluginSpec; +} + +namespace WorldEditor +{ +class WorldEditorWindow; + +class WorldEditorPlugin : public QObject, public ExtensionSystem::IPlugin +{ + Q_OBJECT + Q_INTERFACES(ExtensionSystem::IPlugin) +public: + + virtual ~WorldEditorPlugin(); + + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); + void extensionsInitialized(); + void shutdown(); + + void setNelContext(NLMISC::INelContext *nelContext); + + QString name() const; + QString version() const; + QString vendor() const; + QString description() const; + QStringList dependencies() const; + + void addAutoReleasedObject(QObject *obj); + +protected: + NLMISC::CLibraryContext *m_libContext; + +private: + ExtensionSystem::IPluginManager *m_plugMan; + QList m_autoReleaseObjects; +}; + +class WorldEditorContext: public Core::IContext +{ + Q_OBJECT +public: + WorldEditorContext(QObject *parent = 0); + virtual ~WorldEditorContext() {} + + virtual QString id() const + { + return QLatin1String("WorldEditorContext"); + } + virtual QString trName() const + { + return tr("World Editor"); + } + virtual QIcon icon() const + { + return QIcon(Constants::ICON_WORLD_EDITOR); + } + + virtual void open(); + + virtual QUndoStack *undoStack(); + + virtual QWidget *widget(); + + WorldEditorWindow *m_worldEditorWindow; +}; + +} // namespace WorldEditor + +#endif // WORLD_EDITOR_PLUGIN_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp new file mode 100644 index 000000000..7d6f9dcfd --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -0,0 +1,119 @@ +// 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 "world_editor_window.h" +#include "world_editor_constants.h" + +#include "../core/icore.h" +#include "../core/imenu_manager.h" +#include "../core/core_constants.h" + +// Qt includes +#include + +namespace WorldEditor +{ +QString _lastDir; + +WorldEditorWindow::WorldEditorWindow(QWidget *parent) + : QMainWindow(parent), + m_undoStack(0) +{ + m_ui.setupUi(this); + m_undoStack = new QUndoStack(this); + + createMenus(); + createToolBars(); +// readSettings(); +} + +WorldEditorWindow::~WorldEditorWindow() +{ +// writeSettings(); +} + +QUndoStack *WorldEditorWindow::undoStack() const +{ + return m_undoStack; +} + +void WorldEditorWindow::open() +{ + /* QStringList fileNames = QFileDialog::getOpenFileNames(this, + tr("Open NeL Ligo land file"), _lastDir, + tr("All NeL Ligo land files (*.land)")); + + setCursor(Qt::WaitCursor); + if (!fileNames.isEmpty()) + { + QStringList list = fileNames; + _lastDir = QFileInfo(list.front()).absolutePath(); + Q_FOREACH(QString fileName, fileNames) + { + } + } + setCursor(Qt::ArrowCursor);*/ +} + +void WorldEditorWindow::createMenus() +{ + Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); +} + +void WorldEditorWindow::createToolBars() +{ + Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); + //QAction *action = menuManager->action(Core::Constants::NEW); + //m_ui.fileToolBar->addAction(action); + QAction *action = menuManager->action(Core::Constants::OPEN); + m_ui.fileToolBar->addAction(action); + + action = menuManager->action(Core::Constants::UNDO); + if (action != 0) + m_ui.undoToolBar->addAction(action); + + action = menuManager->action(Core::Constants::REDO); + if (action != 0) + m_ui.undoToolBar->addAction(action); + + //action = menuManager->action(Core::Constants::SAVE); + //m_ui.fileToolBar->addAction(action); + //action = menuManager->action(Core::Constants::SAVE_AS); + //m_ui.fileToolBar->addAction(action); +} + +void WorldEditorWindow::readSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::WORLD_EDITOR_SECTION); + restoreState(settings->value(Constants::WORLD_WINDOW_STATE).toByteArray()); + restoreGeometry(settings->value(Constants::WORLD_WINDOW_GEOMETRY).toByteArray()); + settings->endGroup(); +} + +void WorldEditorWindow::writeSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::WORLD_EDITOR_SECTION); + settings->setValue(Constants::WORLD_WINDOW_STATE, saveState()); + settings->setValue(Constants::WORLD_WINDOW_GEOMETRY, saveGeometry()); + settings->endGroup(); + settings->sync(); +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h new file mode 100644 index 000000000..8efafc48b --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -0,0 +1,57 @@ +// 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 WORLD_EDITOR_WINDOW_H +#define WORLD_EDITOR_WINDOW_H + +// Project includes +#include "ui_world_editor_window.h" + +// Qt includes +#include + +namespace WorldEditor +{ + +class WorldEditorWindow: public QMainWindow +{ + Q_OBJECT + +public: + WorldEditorWindow(QWidget *parent = 0); + ~WorldEditorWindow(); + + QUndoStack *undoStack() const; + +Q_SIGNALS: +public Q_SLOTS: + void open(); + +private Q_SLOTS: +private: + void createMenus(); + void createToolBars(); + void readSettings(); + void writeSettings(); + + QUndoStack *m_undoStack; + Ui::WorldEditorWindow m_ui; +}; /* class WorldEditorWindow */ + +} /* namespace WorldEditor */ + +#endif // WORLD_EDITOR_WINDOW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui new file mode 100644 index 000000000..86c8a2b11 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -0,0 +1,54 @@ + + + WorldEditorWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + :/icons/ic_nel_world_editor.png:/icons/ic_nel_world_editor.png + + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + From 64a4373a8d10d71dc6fe6e391106196c9a56a7a3 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 11 Jul 2011 02:06:14 +0300 Subject: [PATCH 021/747] Changed: #1301 Improved Landscape plugin. --- .../src/plugins/CMakeLists.txt | 1 + .../plugins/landscape_editor/CMakeLists.txt | 2 +- .../plugins/landscape_editor/builder_zone.cpp | 129 +++++++++--------- .../plugins/landscape_editor/builder_zone.h | 4 +- .../landscape_editor_plugin.cpp | 2 +- .../landscape_editor_window.cpp | 34 ++--- .../landscape_editor_window.h | 2 +- .../landscape_editor_window.ui | 12 ++ .../landscape_editor/landscape_scene.cpp | 48 ++++++- .../landscape_editor/landscape_scene.h | 3 + 10 files changed, 138 insertions(+), 99 deletions(-) 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 bec71cf94..880f49c74 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 @@ -7,3 +7,4 @@ ADD_SUBDIRECTORY(disp_sheet_id) ADD_SUBDIRECTORY(object_viewer) ADD_SUBDIRECTORY(zone_painter) ADD_SUBDIRECTORY(georges_editor) +ADD_SUBDIRECTORY(world_editor) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index 2f1d58c66..7ef0a11bf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -40,7 +40,7 @@ SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC} SOURCE_GROUP("Landscape Editor Plugin" FILES ${SRC}) SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) -ADD_LIBRARY(ovqt_plugin_landscape_editor MODULE ${SRC} +ADD_LIBRARY(ovqt_plugin_landscape_editor SHARED ${SRC} ${OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 9550b1f76..b9ffe7151 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -26,11 +26,11 @@ // Qt includes #include #include -#include #include namespace LandscapeEditor { +int LandCounter = 0; ZoneBuilder::ZoneBuilder(LandscapeScene *landscapeScene, ListZonesWidget *listZonesWidget, QUndoStack *undoStack) : m_currentZoneRegion(-1), @@ -117,7 +117,7 @@ void ZoneBuilder::addZone(sint32 posX, sint32 posY) if ((m_listZonesWidget == 0) || (m_undoStack == 0)) return; - if (m_landscapeItems.empty()) + if (m_landscapeMap.empty()) return; // Check zone name @@ -125,7 +125,7 @@ void ZoneBuilder::addZone(sint32 posX, sint32 posY) if (zoneName.empty()) return; - BuilderZoneRegion *builderZoneRegion = m_landscapeItems.at(m_currentZoneRegion).builderZoneRegion; + BuilderZoneRegion *builderZoneRegion = m_landscapeMap.value(m_currentZoneRegion).builderZoneRegion; builderZoneRegion->init(this); uint8 rot = uint8(m_listZonesWidget->currentRot()); @@ -161,13 +161,13 @@ void ZoneBuilder::delZone(const sint32 posX, const sint32 posY) if ((m_listZonesWidget == 0) || (m_undoStack == 0)) return; - if (m_landscapeItems.empty()) + if (m_landscapeMap.empty()) return; m_titleAction = QString("Del zone %1,%2").arg(posX).arg(posY); m_createdAction = false; - BuilderZoneRegion *builderZoneRegion = m_landscapeItems.at(m_currentZoneRegion).builderZoneRegion; + BuilderZoneRegion *builderZoneRegion = m_landscapeMap.value(m_currentZoneRegion).builderZoneRegion; builderZoneRegion->init(this); builderZoneRegion->del(posX, posY); @@ -176,24 +176,22 @@ void ZoneBuilder::delZone(const sint32 posX, const sint32 posY) int ZoneBuilder::createZoneRegion() { - int newId = m_landscapeItems.size(); LandscapeItem landItem; landItem.zoneRegionObject = new ZoneRegionObject(); - landItem.builderZoneRegion = new BuilderZoneRegion(newId); + landItem.builderZoneRegion = new BuilderZoneRegion(LandCounter); landItem.builderZoneRegion->init(this); - landItem.rectItem = 0; + landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); - newZone(); - m_landscapeItems.push_back(landItem); + m_landscapeMap.insert(LandCounter, landItem); if (m_currentZoneRegion == -1) - setCurrentZoneRegion(newId); + setCurrentZoneRegion(LandCounter); - return newId; + calcMask(); + return LandCounter++; } int ZoneBuilder::createZoneRegion(const QString &fileName) { - int newId = m_landscapeItems.size(); LandscapeItem landItem; landItem.zoneRegionObject = new ZoneRegionObject(); landItem.zoneRegionObject->load(fileName.toStdString()); @@ -203,48 +201,52 @@ int ZoneBuilder::createZoneRegion(const QString &fileName) delete landItem.zoneRegionObject; return -1; } - landItem.builderZoneRegion = new BuilderZoneRegion(newId); + landItem.builderZoneRegion = new BuilderZoneRegion(LandCounter); landItem.builderZoneRegion->init(this); - newZone(); - m_landscapeItems.push_back(landItem); - m_landscapeScene->addZoneRegion(landItem.zoneRegionObject->ligoZoneRegion()); - m_landscapeItems.at(newId).rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); + landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); + m_landscapeMap.insert(LandCounter, landItem); if (m_currentZoneRegion == -1) - setCurrentZoneRegion(newId); + setCurrentZoneRegion(LandCounter); - return newId; + calcMask(); + return LandCounter++; } void ZoneBuilder::deleteZoneRegion(int id) { - if ((0 <= id) && (id < int(m_landscapeItems.size()))) + if (m_landscapeMap.contains(id)) { - if (m_landscapeItems.at(id).rectItem != 0) - delete m_landscapeItems.at(id).rectItem; - m_landscapeScene->delZoneRegion(m_landscapeItems.at(id).zoneRegionObject->ligoZoneRegion()); - delete m_landscapeItems.at(id).zoneRegionObject; - delete m_landscapeItems.at(id).builderZoneRegion; - m_landscapeItems.erase(m_landscapeItems.begin() + id); + if (m_landscapeMap.value(id).rectItem != 0) + delete m_landscapeMap.value(id).rectItem; + m_landscapeScene->delZoneRegion(m_landscapeMap.value(id).zoneRegionObject->ligoZoneRegion()); + delete m_landscapeMap.value(id).zoneRegionObject; + delete m_landscapeMap.value(id).builderZoneRegion; + m_landscapeMap.remove(id); calcMask(); } + else + nlwarning("Landscape (id %i) not found", id); } void ZoneBuilder::setCurrentZoneRegion(int id) { - if ((0 <= id) && (id < int(m_landscapeItems.size()))) + if (m_landscapeMap.contains(id)) { if (currentIdZoneRegion() != -1) { - NLLIGO::CZoneRegion &ligoRegion = m_landscapeItems.at(m_currentZoneRegion).zoneRegionObject->ligoZoneRegion(); - m_landscapeItems.at(m_currentZoneRegion).rectItem = m_landscapeScene->createLayerBlackout(ligoRegion); + NLLIGO::CZoneRegion &ligoRegion = m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject->ligoZoneRegion(); + m_landscapeMap[m_currentZoneRegion].rectItem = m_landscapeScene->createLayerBlackout(ligoRegion); } - delete m_landscapeItems.at(id).rectItem; - m_landscapeItems.at(id).rectItem = 0; + delete m_landscapeMap.value(id).rectItem; + m_landscapeMap[id].rectItem = 0; m_currentZoneRegion = id; + calcMask(); } + else + nlwarning("Landscape (id %i) not found", id); } int ZoneBuilder::currentIdZoneRegion() const @@ -254,27 +256,27 @@ int ZoneBuilder::currentIdZoneRegion() const ZoneRegionObject *ZoneBuilder::currentZoneRegion() const { - return m_landscapeItems.at(m_currentZoneRegion).zoneRegionObject; + return m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject; } int ZoneBuilder::countZoneRegion() const { - return m_landscapeItems.size(); + return m_landscapeMap.size(); } ZoneRegionObject *ZoneBuilder::zoneRegion(int id) const { - return m_landscapeItems.at(id).zoneRegionObject; + return m_landscapeMap.value(id).zoneRegionObject; } void ZoneBuilder::ligoData(LigoData &data, const ZonePosition &zonePos) { - m_landscapeItems.at(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y); + m_landscapeMap.value(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y); } void ZoneBuilder::setLigoData(LigoData &data, const ZonePosition &zonePos) { - m_landscapeItems.at(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y); + m_landscapeMap.value(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y); } bool ZoneBuilder::initZoneBank (const QString &pathName) @@ -307,25 +309,6 @@ QString ZoneBuilder::dataPath() const return m_lastPathName; } -void ZoneBuilder::newZone() -{ - // Select starting point for the moment 0,0 - sint32 x = 0, y = 0; - - // If there are some zone already present increase x until free - for (size_t i = 0; i < m_landscapeItems.size(); ++i) - { - const NLLIGO::CZoneRegion &zoneRegion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion(); - const std::string &zoneName = zoneRegion.getName (x, y); - if ((zoneName != STRING_OUT_OF_BOUND) && (zoneName != STRING_UNUSED)) - { - ++x; - i = -1; - } - } - calcMask(); -} - bool ZoneBuilder::getZoneMask(sint32 x, sint32 y) { if ((x < m_minX) || (x > m_maxX) || @@ -346,12 +329,14 @@ void ZoneBuilder::calcMask() m_minY = m_minX = 1000000; m_maxY = m_maxX = -1000000; - if (m_landscapeItems.size() == 0) + if (m_landscapeMap.size() == 0) return; - for (size_t i = 0; i < m_landscapeItems.size(); ++i) + QMapIterator i(m_landscapeMap); + while (i.hasNext()) { - const NLLIGO::CZoneRegion ®ion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion(); + i.next(); + const NLLIGO::CZoneRegion ®ion = i.value().zoneRegionObject->ligoZoneRegion(); if (m_minX > region.getMinX()) m_minX = region.getMinX(); @@ -370,10 +355,13 @@ void ZoneBuilder::calcMask() { m_zoneMask[x - m_minX + (y - m_minY) * stride] = true; - for (size_t i = 0; i < m_landscapeItems.size(); ++i) - if (int(i) != m_currentZoneRegion) + QMapIterator it(m_landscapeMap); + while (it.hasNext()) + { + it.next(); + if (int(it.key()) != m_currentZoneRegion) { - const NLLIGO::CZoneRegion ®ion = zoneRegion(i)->ligoZoneRegion(); + const NLLIGO::CZoneRegion ®ion = it.value().zoneRegionObject->ligoZoneRegion(); const std::string &rSZone = region.getName (x, y); if ((rSZone != STRING_OUT_OF_BOUND) && (rSZone != STRING_UNUSED)) @@ -381,21 +369,24 @@ void ZoneBuilder::calcMask() m_zoneMask[x - m_minX + (y - m_minY) * stride] = false; } } + } } } bool ZoneBuilder::getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y) { - for (size_t i = 0; i < m_landscapeItems.size(); ++i) + QMapIterator it(m_landscapeMap); + while (it.hasNext()) { - const NLLIGO::CZoneRegion ®ion = m_landscapeItems.at(i).zoneRegionObject->ligoZoneRegion(); + it.next(); + const NLLIGO::CZoneRegion ®ion = it.value().zoneRegionObject->ligoZoneRegion(); if ((x < region.getMinX()) || (x > region.getMaxX()) || (y < region.getMinY()) || (y > region.getMaxY())) continue; if (region.getName(x, y) != STRING_UNUSED) { - builderZoneRegionFrom = m_landscapeItems.at(i).builderZoneRegion; - zonePos = ZonePosition(x, y, i); + builderZoneRegionFrom = it.value().builderZoneRegion; + zonePos = ZonePosition(x, y, it.key()); return true; } } @@ -435,9 +426,11 @@ void ZoneBuilder::checkEndMacro() bool ZoneBuilder::checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion) { - for (size_t j = 0; j < m_landscapeItems.size(); ++j) + QMapIterator it(m_landscapeMap); + while (it.hasNext()) { - const NLLIGO::CZoneRegion &zoneRegion = m_landscapeItems.at(j).zoneRegionObject->ligoZoneRegion(); + it.next(); + const NLLIGO::CZoneRegion &zoneRegion = it.value().zoneRegionObject->ligoZoneRegion(); for (sint32 y = zoneRegion.getMinY(); y <= zoneRegion.getMaxY(); ++y) for (sint32 x = zoneRegion.getMinX(); x <= zoneRegion.getMaxX(); ++x) { diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index 17d5a6f7e..5fbd80832 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -85,7 +85,6 @@ public: bool init(const QString &pathName, bool bMakeAZone); void calcMask(); - void newZone(); bool getZoneMask (sint32 x, sint32 y); bool getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y); @@ -150,7 +149,8 @@ private: QString m_lastPathName; int m_currentZoneRegion; - std::vector m_landscapeItems; + //std::vector m_landscapeItems; + QMap m_landscapeMap; bool m_createdAction; QString m_titleAction; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp index ac7782343..401256ce6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp @@ -75,7 +75,7 @@ QString LandscapeEditorPlugin::name() const QString LandscapeEditorPlugin::version() const { - return "0.0.1"; + return "0.1"; } QString LandscapeEditorPlugin::vendor() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index da949fea5..4dd3163ba 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -46,7 +46,7 @@ QString _lastDir; LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) : QMainWindow(parent), - m_currentRow(-1), + m_currentItem(0), m_landscapeScene(0), m_zoneBuilder(0), m_undoStack(0), @@ -65,8 +65,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_landscapeScene->setZoneBuilder(m_zoneBuilder); m_ui.graphicsView->setScene(m_landscapeScene); //m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); - m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers)); - m_ui.graphicsView->setViewport(m_oglWidget); + //m_ui.graphicsView->setViewport(m_oglWidget); m_ui.newLandAction->setIcon(QIcon(Core::Constants::ICON_NEW)); m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); @@ -128,7 +127,7 @@ void LandscapeEditorWindow::open() void LandscapeEditorWindow::save() { - saveLandscape(m_currentRow, true); + saveLandscape(m_ui.landscapesListWidget->row(m_currentItem), true); } void LandscapeEditorWindow::openProjectSettings() @@ -203,7 +202,9 @@ void LandscapeEditorWindow::customContextMenu() void LandscapeEditorWindow::newLand() { - createLandscape(QString()); + int row = createLandscape(QString()); + if (row != -1) + setActiveLandscape(row); } void LandscapeEditorWindow::setActiveLand() @@ -224,8 +225,9 @@ void LandscapeEditorWindow::saveAsSelectedLand() void LandscapeEditorWindow::deleteSelectedLand() { int row = m_ui.landscapesListWidget->currentRow(); + int current_row = m_ui.landscapesListWidget->row(m_currentItem); QListWidgetItem *item = m_ui.landscapesListWidget->item(row); - if (row == m_currentRow) + if (row == current_row) { if (row == 0) ++row; @@ -236,6 +238,7 @@ void LandscapeEditorWindow::deleteSelectedLand() m_zoneBuilder->deleteZoneRegion(item->data(LANDSCAPE_ID).toInt()); m_ui.landscapesListWidget->removeItemWidget(item); delete item; + if (m_ui.landscapesListWidget->count() == 1) m_ui.deleteLandAction->setEnabled(false); } @@ -276,15 +279,13 @@ void LandscapeEditorWindow::setActiveLandscape(int row) { if ((0 <= row) && (row < m_ui.landscapesListWidget->count())) { - if (m_currentRow != -1) - { - QListWidgetItem *item = m_ui.landscapesListWidget->item(m_currentRow); - item->setFont(QFont("SansSerif", 9, QFont::Normal)); - } + if (m_currentItem != 0) + m_currentItem->setFont(QFont("SansSerif", 9, QFont::Normal)); + QListWidgetItem *item = m_ui.landscapesListWidget->item(row); item->setFont(QFont("SansSerif", 9, QFont::Bold)); m_zoneBuilder->setCurrentZoneRegion(item->data(LANDSCAPE_ID).toInt()); - m_currentRow = row; + m_currentItem = item; } } @@ -337,16 +338,11 @@ void LandscapeEditorWindow::createToolBars() m_ui.fileToolBar->addAction(action); m_ui.fileToolBar->addAction(m_ui.saveAction); - const char * const UNDO = "ObjectViewerQt.Undo"; - const char * const REDO = "ObjectViewerQt.Redo"; - - //action = menuManager->action(Core::Constants::UNDO); - action = menuManager->action(UNDO); + action = menuManager->action(Core::Constants::UNDO); if (action != 0) m_ui.undoToolBar->addAction(action); - //action = menuManager->action(Core::Constants::REDO); - action = menuManager->action(REDO); + action = menuManager->action(Core::Constants::REDO); if (action != 0) m_ui.undoToolBar->addAction(action); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index f3421f120..18ce670b7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -69,7 +69,7 @@ private: void saveLandscape(int row, bool force); int createLandscape(const QString &fileName); - int m_currentRow; + QListWidgetItem *m_currentItem; LandscapeScene *m_landscapeScene; ZoneBuilder *m_zoneBuilder; QUndoStack *m_undoStack; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index 7d71acd49..b2db9dc42 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -38,6 +38,18 @@ QGraphicsView::NoDrag + + QGraphicsView::AnchorUnderMouse + + + QGraphicsView::AnchorUnderMouse + + + QGraphicsView::FullViewportUpdate + + + QGraphicsView::DontSavePainterState + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 81a94fb1f..3b10d4fed 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace LandscapeEditor { @@ -34,11 +35,13 @@ static const int ZONE_NAME = 0; static const int LAYER_ZONES = 2; static const int LAYER_EMPTY_ZONES = 3; static const int LAYER_BLACKOUT = 4; +const char * const LAYER_BLACKOUT_NAME = "blackout"; LandscapeScene::LandscapeScene(QObject *parent) : QGraphicsScene(parent), m_mouseX(0.0), m_mouseY(0.0), + m_mouseButton(Qt::NoButton), m_zoneBuilder(0) { m_cellSize = 160; @@ -154,7 +157,7 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo // The size graphics item should be equal or proportional m_cellSize item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); - //item->setData(ZONE_NAME, QString(data.zoneName.c_str())); + item->setData(ZONE_NAME, QString(data.zoneName.c_str())); // for not full item zone item->setZValue(LAYER_ZONES); @@ -198,13 +201,14 @@ QGraphicsRectItem *LandscapeScene::createLayerBlackout(const NLLIGO::CZoneRegion Qt::NoPen, QBrush(QColor(0, 0, 0, 50))); rectItem->setZValue(LAYER_BLACKOUT); + rectItem->setData(ZONE_NAME, QString(LAYER_BLACKOUT_NAME)); return rectItem; } void LandscapeScene::deleteItemZone(const ZonePosition &zonePos) { QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize); - if (item != 0) + if ((item != 0) && (item->data(ZONE_NAME).toString() != QString(LAYER_BLACKOUT_NAME))) { removeItem(item); delete item; @@ -282,30 +286,60 @@ void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) if ((x < 0) || (y < 0)) return; - sint32 posX = sint32(floor(x / m_cellSize)); - sint32 posY = sint32(-floor(y / m_cellSize)); + m_posX = sint32(floor(x / m_cellSize)); + m_posY = sint32(-floor(y / m_cellSize)); if (mouseEvent->button() == Qt::LeftButton) - m_zoneBuilder->addZone(posX, posY); + m_zoneBuilder->addZone(m_posX, m_posY); else if (mouseEvent->button() == Qt::RightButton) - m_zoneBuilder->delZone(posX, posY); + m_zoneBuilder->delZone(m_posX, m_posY); + + m_mouseButton = mouseEvent->button(); QGraphicsScene::mousePressEvent(mouseEvent); } void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) { + qreal x = mouseEvent->scenePos().rx(); + qreal y = mouseEvent->scenePos().ry(); + + sint32 posX = sint32(floor(x / m_cellSize)); + sint32 posY = sint32(-floor(y / m_cellSize)); + + if ((m_posX != posX || m_posY != posY) && + (m_mouseButton == Qt::LeftButton || + m_mouseButton == Qt::RightButton)) + { + if (m_mouseButton == Qt::LeftButton) + m_zoneBuilder->addZone(posX, posY); + else if (m_mouseButton == Qt::RightButton) + m_zoneBuilder->delZone(posX, posY); + + m_posX = posX; + m_posY = posY; + QApplication::processEvents(); + } + m_mouseX = mouseEvent->scenePos().x(); m_mouseY = mouseEvent->scenePos().y(); QGraphicsScene::mouseMoveEvent(mouseEvent); } +void LandscapeScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + m_mouseButton = Qt::NoButton; +} + bool LandscapeScene::checkUnderZone(const int posX, const int posY) { QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize); if (item != 0) { - return true; + if (item->data(ZONE_NAME) == QString(LAYER_BLACKOUT_NAME)) + return false; + else + return true; } return false; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index 34fe50e05..39f81bf98 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -62,6 +62,7 @@ public: protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); virtual void drawForeground(QPainter *painter, const QRectF &rect); private: @@ -69,6 +70,8 @@ private: int m_cellSize; qreal m_mouseX, m_mouseY; + sint32 m_posX, m_posY; + Qt::MouseButton m_mouseButton; ZoneBuilder *m_zoneBuilder; }; From beb9d7867e34550a2437b875f2944af5d53e5221 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 12 Jul 2011 01:14:25 +0300 Subject: [PATCH 022/747] Changed: #1301 Removed a hard coded value. --- .../plugins/landscape_editor/builder_zone.cpp | 15 +++++++------- .../plugins/landscape_editor/builder_zone.h | 2 +- .../landscape_editor_constants.h | 2 ++ .../landscape_editor_window.cpp | 20 ++++++++++++++----- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index b9ffe7151..cb97c20ea 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -49,9 +49,10 @@ ZoneBuilder::~ZoneBuilder() delete m_pixmapDatabase; } -bool ZoneBuilder::init(const QString &pathName, bool makeAZone) +bool ZoneBuilder::init(const QString &pathName, bool displayProgress) { - bool bRet = true; + if (pathName.isEmpty()) + return false; if (pathName != m_lastPathName) { m_lastPathName = pathName; @@ -59,25 +60,23 @@ bool ZoneBuilder::init(const QString &pathName, bool makeAZone) zoneBankPath += "/zoneligos/"; // Init the ZoneBank - m_zoneBank.reset (); + m_zoneBank.reset(); if (!initZoneBank (zoneBankPath)) { - m_zoneBank.reset (); + m_zoneBank.reset(); return false; } // Construct the DataBase from the ZoneBank QString zoneBitmapPath = pathName; zoneBitmapPath += "/zonebitmaps/"; m_pixmapDatabase->reset(); - if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank)) + if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank, displayProgress)) { m_zoneBank.reset(); return false; } } - if ((makeAZone) && (bRet)) - createZoneRegion(); - return bRet; + return true; } void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zonePos) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index 5fbd80832..213ba9b13 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -82,7 +82,7 @@ public: ~ZoneBuilder(); /// Init zoneBank and init zone pixmap database - bool init(const QString &pathName, bool bMakeAZone); + bool init(const QString &pathName, bool displayProgress = false); void calcMask(); bool getZoneMask (sint32 x, sint32 y); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h index 6875ddfab..9ab2dbfbc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h @@ -28,6 +28,8 @@ const char * const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor"; const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor"; const char * const LANDSCAPE_WINDOW_STATE = "LandscapeWindowState"; const char * const LANDSCAPE_WINDOW_GEOMETRY = "LandscapeWindowGeometry"; +const char * const LANDSCAPE_DATA_DIRECTORY = "LandscapeDataDirectory"; +const char * const LANDSCAPE_USE_OPENGL = "LandscapeUseOpenGL"; //resources const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png"; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 4dd3163ba..3483766f9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -58,14 +58,11 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_landscapeScene = new LandscapeScene(this); m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack); - m_zoneBuilder->init("e:/-nel-/install/continents/newbieland", false); m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); m_ui.zoneListWidget->updateUi(); m_landscapeScene->setZoneBuilder(m_zoneBuilder); m_ui.graphicsView->setScene(m_landscapeScene); - //m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); - //m_ui.graphicsView->setViewport(m_oglWidget); m_ui.newLandAction->setIcon(QIcon(Core::Constants::ICON_NEW)); m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); @@ -95,8 +92,8 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) LandscapeEditorWindow::~LandscapeEditorWindow() { - delete m_zoneBuilder; writeSettings(); + delete m_zoneBuilder; } QUndoStack *LandscapeEditorWindow::undoStack() const @@ -137,7 +134,7 @@ void LandscapeEditorWindow::openProjectSettings() int ok = dialog->exec(); if (ok == QDialog::Accepted) { - m_zoneBuilder->init(dialog->dataPath(), false); + m_zoneBuilder->init(dialog->dataPath(), true); m_ui.zoneListWidget->updateUi(); } delete dialog; @@ -358,6 +355,18 @@ void LandscapeEditorWindow::readSettings() settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); restoreState(settings->value(Constants::LANDSCAPE_WINDOW_STATE).toByteArray()); restoreGeometry(settings->value(Constants::LANDSCAPE_WINDOW_GEOMETRY).toByteArray()); + + // Read landscape data directory (contains sub-paths: zone logos, zone bitmaps) + m_zoneBuilder->init(settings->value(Constants::LANDSCAPE_DATA_DIRECTORY).toString()); + m_ui.zoneListWidget->updateUi(); + + // Use OpenGL graphics system instead raster graphics system + if (settings->value(Constants::LANDSCAPE_USE_OPENGL, false).toBool()) + { + m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); + m_ui.graphicsView->setViewport(m_oglWidget); + } + settings->endGroup(); } @@ -367,6 +376,7 @@ void LandscapeEditorWindow::writeSettings() settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION); settings->setValue(Constants::LANDSCAPE_WINDOW_STATE, saveState()); settings->setValue(Constants::LANDSCAPE_WINDOW_GEOMETRY, saveGeometry()); + settings->setValue(Constants::LANDSCAPE_DATA_DIRECTORY, m_zoneBuilder->dataPath()); settings->endGroup(); settings->sync(); } From c7203a635c38d89a398acf62bec0d7e71e133447 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 13 Jul 2011 03:34:45 +0300 Subject: [PATCH 023/747] Changed: #1301 Added status info and each zone tile has small text in graphics view. --- .../landscape_editor_window.cpp | 21 +++++++++++ .../landscape_editor_window.h | 7 ++++ .../landscape_editor/landscape_scene.cpp | 35 +++++++++++++------ .../landscape_editor/landscape_scene.h | 2 ++ .../landscape_editor/landscape_view.cpp | 21 +++++++++++ 5 files changed, 75 insertions(+), 11 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 3483766f9..662c1d9c9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -36,6 +36,7 @@ #include #include #include +#include namespace LandscapeEditor { @@ -88,6 +89,12 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) connect(m_ui.landscapesListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu())); m_ui.landscapesListWidget->setContextMenuPolicy(Qt::CustomContextMenu); + m_statusBarTimer = new QTimer(this); + connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); + + m_statusInfo = new QLabel(this); + m_statusInfo->hide(); + Core::ICore::instance()->mainWindow()->statusBar()->addPermanentWidget(m_statusInfo); } LandscapeEditorWindow::~LandscapeEditorWindow() @@ -318,6 +325,20 @@ void LandscapeEditorWindow::showEvent(QShowEvent *showEvent) QMainWindow::showEvent(showEvent); if (m_oglWidget != 0) m_oglWidget->makeCurrent(); + m_statusInfo->show(); + m_statusBarTimer->start(100); +} + +void LandscapeEditorWindow::hideEvent(QHideEvent *hideEvent) +{ + QMainWindow::hideEvent(hideEvent); + m_statusInfo->hide(); + m_statusBarTimer->stop(); +} + +void LandscapeEditorWindow::updateStatusBar() +{ + m_statusInfo->setText(m_landscapeScene->zoneNameFromMousePos()); } void LandscapeEditorWindow::createMenus() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index 18ce670b7..67768e39a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -24,6 +24,8 @@ // Qt includes #include #include +#include +#include namespace LandscapeEditor { @@ -50,6 +52,7 @@ private Q_SLOTS: void openProjectSettings(); void openSnapshotDialog(); void customContextMenu(); + void updateStatusBar(); void newLand(); void setActiveLand(); void saveSelectedLand(); @@ -58,6 +61,7 @@ private Q_SLOTS: protected: virtual void showEvent(QShowEvent *showEvent); + virtual void hideEvent(QHideEvent *hideEvent); private: void createMenus(); @@ -69,6 +73,9 @@ private: void saveLandscape(int row, bool force); int createLandscape(const QString &fileName); + QLabel *m_statusInfo; + QTimer *m_statusBarTimer; + QListWidgetItem *m_currentItem; LandscapeScene *m_landscapeScene; ZoneBuilder *m_zoneBuilder; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 3b10d4fed..b2dc9dd5d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -39,8 +39,6 @@ const char * const LAYER_BLACKOUT_NAME = "blackout"; LandscapeScene::LandscapeScene(QObject *parent) : QGraphicsScene(parent), - m_mouseX(0.0), - m_mouseY(0.0), m_mouseButton(Qt::NoButton), m_zoneBuilder(0) { @@ -170,6 +168,9 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos) if (m_zoneBuilder == 0) return 0; + if (checkUnderZone(zonePos.x, zonePos.y)) + return 0; + // Get image from pixmap database QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED)); if (pixmap == 0) @@ -276,11 +277,17 @@ void LandscapeScene::snapshot(const QString &fileName, int width, int height, co scaledImage.save(fileName); } +QString LandscapeScene::zoneNameFromMousePos() const +{ + if ((m_posY > 0) || (m_posY < -255) || + (m_posX < 0) || (m_posX > 255)) + return "NOT A VALID ZONE"; + + return QString("%1_%2%3").arg(-m_posY).arg(QChar('A' + (m_posX/26))).arg(QChar('A' + (m_posX%26))); +} + void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { - if (m_zoneBuilder == 0) - return; - qreal x = mouseEvent->scenePos().rx(); qreal y = mouseEvent->scenePos().ry(); if ((x < 0) || (y < 0)) @@ -289,6 +296,9 @@ void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) m_posX = sint32(floor(x / m_cellSize)); m_posY = sint32(-floor(y / m_cellSize)); + if (m_zoneBuilder == 0) + return; + if (mouseEvent->button() == Qt::LeftButton) m_zoneBuilder->addZone(m_posX, m_posY); else if (mouseEvent->button() == Qt::RightButton) @@ -321,8 +331,11 @@ void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) QApplication::processEvents(); } - m_mouseX = mouseEvent->scenePos().x(); - m_mouseY = mouseEvent->scenePos().y(); + m_posX = posX; + m_posY = posY; + + m_mouseX = mouseEvent->scenePos().rx(); + m_mouseY = mouseEvent->scenePos().ry(); QGraphicsScene::mouseMoveEvent(mouseEvent); } @@ -336,10 +349,10 @@ bool LandscapeScene::checkUnderZone(const int posX, const int posY) QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize); if (item != 0) { - if (item->data(ZONE_NAME) == QString(LAYER_BLACKOUT_NAME)) - return false; - else - return true; + //if (item->data(ZONE_NAME) == QString(LAYER_BLACKOUT_NAME)) + // return false; + //else + return true; } return false; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index 39f81bf98..71d4c512e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -59,6 +59,8 @@ public: void snapshot(const QString &fileName, int width, int height, const QRectF &landRect); + QString zoneNameFromMousePos() const; + protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index 84bc4b47d..40074292d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -137,6 +137,27 @@ void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect) painter->drawLine(int(rect.left()), int(top), int(rect.right()), int(top)); top += m_cellSize; } + + // Render text (slow!) + if (m_numSteps > -m_maxSteps / 4) + { + painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); + + //painter->setFont(QFont("Helvetica [Cronyx]", 12)); + int leftSide = int(floor(rect.left() / m_cellSize)); + int rightSide = int(floor(rect.right() / m_cellSize)); + int topSide = int(floor(rect.top() / m_cellSize)); + int bottomSide = int(floor(rect.bottom() / m_cellSize)); + + for (int i = leftSide; i < rightSide + 1; ++i) + { + for (int j = topSide; j < bottomSide + 1; ++j) + { + QString text = QString("%1_%2%3").arg(j).arg(QChar('A' + (i / 26))).arg(QChar('A' + (i % 26))); + painter->drawText(i * m_cellSize + 5, j * m_cellSize + 15, text); + } + } + } } } /* namespace LandscapeEditor */ From 97bfc60c6b1d8cc067d272caa873e7477fd38d69 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 13 Jul 2011 04:49:09 +0300 Subject: [PATCH 024/747] Fixed: #1301 A temporary fix instead of the future of undo command delete landscape. --- .../src/plugins/landscape_editor/landscape_editor_window.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 662c1d9c9..62feaec48 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -245,6 +245,8 @@ void LandscapeEditorWindow::deleteSelectedLand() if (m_ui.landscapesListWidget->count() == 1) m_ui.deleteLandAction->setEnabled(false); + + m_undoStack->clear(); } int LandscapeEditorWindow::createLandscape(const QString &fileName) From 06e90bbc6920a26ae5c9b15dbd7a0f0107312f22 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 18 Jul 2011 14:25:16 +0300 Subject: [PATCH 025/747] Changed: #1301 Added the add transition method. --- .../plugins/landscape_editor/builder_zone.cpp | 79 +++++++++++++++++++ .../plugins/landscape_editor/builder_zone.h | 2 +- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index cb97c20ea..62ed76e89 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -151,8 +151,87 @@ void ZoneBuilder::addZone(sint32 posX, sint32 posY) void ZoneBuilder::addTransition(const sint32 posX, const sint32 posY) { + // Read-only mode if ((m_listZonesWidget == 0) || (m_undoStack == 0)) return; + + if (m_landscapeMap.empty()) + return; + + m_titleAction = QString("Transition zone %1,%2").arg(posX).arg(posY); + m_createdAction = false; + m_zonePositionList.clear(); + + nlinfo(QString("trans %1,%2").arg(posX).arg(posY).toStdString().c_str()); + + sint32 x = (sint32)floor(float(posX) / m_landscapeScene->cellSize()); + sint32 y = (sint32)floor(float(posY) / m_landscapeScene->cellSize()); + sint32 k; + + // Detect if we are in a transition square to switch + BuilderZoneRegion *builderZoneRegion = m_landscapeMap.value(m_currentZoneRegion).builderZoneRegion; + builderZoneRegion->init(this); + const NLLIGO::CZoneRegion &zoneRegion = currentZoneRegion()->ligoZoneRegion(); + bool bCutEdgeTouched = false; + for (uint8 transPos = 0; transPos < 4; ++transPos) + { + uint ce = zoneRegion.getCutEdge(x, y, transPos); + + if ((ce > 0) && (ce < 3)) + for (k = 0; k < 2; ++k) + { + float xTrans, yTrans; + + if ((transPos == 0) || (transPos == 1)) + { + if (ce == 1) + xTrans = m_landscapeScene->cellSize() / 3.0f; + else + xTrans = 2.0f * m_landscapeScene->cellSize() / 3.0f; + } + else + { + if (transPos == 2) + xTrans = 0; + else + xTrans = m_landscapeScene->cellSize(); + } + xTrans += x * m_landscapeScene->cellSize(); + + if ((transPos == 2) || (transPos == 3)) + { + if (ce == 1) + yTrans = m_landscapeScene->cellSize() / 3.0f; + else + yTrans = 2.0f * m_landscapeScene->cellSize() / 3.0f; + } + else + { + if (transPos == 1) + yTrans = 0; + else + yTrans = m_landscapeScene->cellSize(); + } + yTrans += y * m_landscapeScene->cellSize(); + + if ((posX >= (xTrans - m_landscapeScene->cellSize() / 12.0f)) && + (posX <= (xTrans + m_landscapeScene->cellSize() / 12.0f)) && + (posY >= (yTrans - m_landscapeScene->cellSize() / 12.0f)) && + (posY <= (yTrans + m_landscapeScene->cellSize() / 12.0f))) + { + builderZoneRegion->invertCutEdge (x, y, transPos); + bCutEdgeTouched = true; + } + ce = 3 - ce; + } + } + + // If not clicked to change the cutEdge so the user want to change the transition + if (!bCutEdgeTouched) + { + builderZoneRegion->cycleTransition (x, y); + } + checkEndMacro(); } void ZoneBuilder::delZone(const sint32 posX, const sint32 posY) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index 213ba9b13..789af03f7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -97,7 +97,7 @@ public: /// Zone Bricks /// @{ - void addZone(sint32 posX, sint32 posY); + void addZone(const sint32 posX, const sint32 posY); void addTransition(const sint32 posX, const sint32 posY); void delZone(const sint32 posX, const sint32 posY); /// @} From 3b014d55abbfa449a32d0e3d00664d9b4b77c27e Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 18 Jul 2011 14:26:06 +0300 Subject: [PATCH 026/747] Changed: #1301 Added new icons. --- .../plugins/landscape_editor/icons/ic_grid.png | Bin 0 -> 4204 bytes .../icons/ic_nel_transition_land.png | Bin 0 -> 55628 bytes .../landscape_editor/icons/ic_nel_zones.png | Bin 0 -> 30995 bytes .../landscape_editor/icons/ic_snapshot.png | Bin 0 -> 5390 bytes .../landscape_editor/landscape_editor.qrc | 4 ++++ .../landscape_editor_constants.h | 2 ++ 6 files changed, 6 insertions(+) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_grid.png create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_transition_land.png create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_zones.png create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_snapshot.png diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_grid.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_grid.png new file mode 100644 index 0000000000000000000000000000000000000000..3534b70aece091d0f41a4adaed4aaf35e3b7fc5a GIT binary patch literal 4204 zcmZuzbzIZm_kPpqV1RT>x1fX~A&!vlPKALYLum$VfJg{RNJ=A)7^PCuP_5jkN)w;Z+2|JcBeAe4uY(3;^*=0FX?w3sO+D763$s0l@l808n2A0IuNx^|%lK zpjY$J(J?dgh6Ta`ykY)=20A)|{?A}uKE9p+ppPlY3bC@9Vvir`2njFwu0U?_Vxg@Y z7>8%LK-_b<+$1PKN;evWO3A^HdwIh8X8p)9GZCA64a{s-^)w>164yB)Rx&W%$(Ob0 z_T#-h!U`I;{qeY!u+=f*zyYMAG>4ari!vEpOZ^Vh*?=7C!Pl8oOCDG3!PEQ{|dQ zl5)7SWxO~=y*eed!9$5^?rB#v2r?haa(-2+Hzf?Hp*~vv^4Pihx5-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/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_nel_transition_land.png new file mode 100644 index 0000000000000000000000000000000000000000..99da545b1d20535d43518ce0672fee91fbc9f3ba GIT binary patch literal 55628 zcmdp-`9DaFr+yHqt$@5&t>bbd( z>+_(;{w{#&V|VZ8GR8U>nJ6aaO_FJvA&-o?~)hpx`UT>=m z%*oZJUVPI1Et*AT;Ox@pb9G()uAeLF;_8j@bRaQS&9&wG;8g=w%6H<6I){9S)VAl9 zV?6p-tCwyNsAY(v%Gcf@c@ zUqs;CL(=P(wov6eMBbGus^eIV^xOK<3lDF74Shm<`Ka#3nGZwKYvnU2UXQFtm?h$vr;4iKLs>+ zU&@pEW?dWes7tX~OzHZ`*9);mK8eO2{sF1WYc{;acQ9rsuT<3yQRTL84|4A+Pw2V( zJJmlp@Tqt|NBC|K%j_eG`LST+va~U0aqH`ZkqF1;f^~&XUM`dFWJ|eY>qf(J)xp$N z_Ji`39-AM}|JknebN42rEGRKd>9SPEe|^k&R2BTMI&0n9^UNyineDbm{N4v5q6_i( z1G=feNq7{MdP?VQhU~+Io%iiyMW;1hZ>UNE8)`U=vl$WMvCP-5ga0y6-Em z92hl=j5Yu`lew(P1_oT1_d5drOa7)C1^CWw_O`Kxl_T}QFgPY;?r5$uxebSZv)>v| za_HEpoV^l(|EYn#QGoq6>^G?C(~BcbN{2*X7V+dadk&7M4ockQ1>5qiiBpY5FWahk zobr-hM?I*)=ciNnT+3Yt63o3I%`3&k;}=)vE$M!P)}rnrEq^X6=CaAp34h!t?|2l6 z>i-&=FA6ST;JEoT`wk1TY>5%2!(1~w?w7rcM_F7s8Ol^^{j9(6k5j}UQ9q?*780w+ zC(Ca4+AvwBwb&qc)l9l9LGh`zSxzTcMpmQksQfCsetZZlB^Ps5V({Ou9U1qrQx^9U z=@TXQv1KLq+5HzTUO97@EBP>AD=e3qMZW!3AFcTv!7;hU?mi(`qUgaU5$MUC^yP-3 zesK<0(eu1evpW5n^Y^yIXjS7=qVmM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#8>C6_1kCAFb!4xES2CVcib=vL#XO?kxLEgPc=AOzV?F?@yfmzedph h|M~lJS#a;9gVl*}#>h5wkPk2hloZtED`hQ0{};u%Cv5-# literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_snapshot.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/icons/ic_snapshot.png new file mode 100644 index 0000000000000000000000000000000000000000..a45143aa4ccb7497fbe2da7481837ed539bdaf5d GIT binary patch literal 5390 zcmV+p74hncP)YYKw8SHDJhR&NGOzKU`ku2 zEuo#l421w;LfX=HT85BJfoYmh2n}fn&BL!acH*}!Th?<|yW01?_x$?Dy?ghel`JWt z?U`Ba-gEBbe81=S`<~zV-6JI;%%>UDl zhUOwL9DL5t@_Sh1XzrEo_A6IrB|xdczXA3D7CptI?nL$D8uJRNKGV}oSYyv znIt)pWGa~?l}zC}^TH*-2ykY$kI2#KR|4=1oO2Lx7})&8)Bnbju1-#!&#<(kg@L{f z1P}ocK}676C^;^rvPZG(QYyI=9sfHum0@&rg3*yNMutb37@uS+nPe)NA~Q8bI+-Fn zJ==0X~+ zB?Miu1TDIzUXZ%u+VlKltp%mPw4$sY7+_%IMwCGvNv`KHoz9S)Ofot=%J|qAnPiGg z%D1Aa@o`gYy$RR^{7wacQiG$w?IK4XSTq5y<6)S7haFb~LayKh$1W3NUHlj)&GluIQk(FgZTXm;Ut6S+SxA zLBgv9L3<*^682N)ZHbwC+7wg>_|V)!HFxGo~Td5UOU*Q0mk z3ij-IH%8#|3LmVeHHCbULZL*ySfY?GQ7D!u6pBn|a-=iUrx#bOaHV3-!|OS|Y=(aVzV zZrZz+f>N}$cVL(%+LPsAM!<_NlmHD-E;}d)%u#SX9kT5OqUgFF&pi7Azj*3kD0CtO z)1^;X#Wh4EtS3BAs@DYHAeg3!9kJ+H(S_EXc%J7!-}7)?56=@k&n1^DkQzG4=|cxt zvZ9Y|J9i-hZJnK@CngjmdLf-(C;@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ogMtfTR+5}kG+puKltu2 zA!3R`OofPnHVIyw_;sK-@Z3SZ@>gHwimP7Bp5MC#t7clRJmtdB5K55~DW(=gfXLAU zN~s&5{X@`xHCTOM^a3WBYhKuQfUB?&l+)x`TnijZL3k$Q3y8;!7gpoT=2! z`G14Wic;!wppUw|*P1&~Em!~9m+xlF_H9jIOB3MLwq{-MT}62EKYz}Xk3G(bqsM7$ zOR#nOC2SlVU})$9hhI3#@VQ}Dty#_XD=y=vo8L~vj?7B@x4v=@KmU)%fQhd{>LC$% ze8B_+B*cJT{LRO4NVFKn$_HYt@uhn{b%)w@?bR0rDfNHq>zn)#U~F`hlP{g%?CH}i zTi(O^!2$YK_xs8&4VTp%74k*?;am6flZPJ#3Qxefe*&Hqkrx(4K(nIMh8;?&ABm`y zgPRB0v}H4^2iEz^&{@X5wxhGGl^RcLXm0kaS~BT0CypNH(7uC`N~RPPe*qW13vLPc zzKA4WF#-UTimroY-&CsQRU&3L^Gy%`3X4)WBJNqpJOYykgX-r+T=*p zuwoGJVYcw?f2DW@$c_^H_e)UD0Y4TI7k&i<04Sxpf!6`c`9CF~uB3s3B66g*@>fDY scypx;po=E|sPMm7G>{aLa + icons/ic_nel_zones.png + icons/ic_snapshot.png + icons/ic_grid.png + icons/ic_nel_transition_land.png icons/ic_nel_landscape_item.png icons/ic_nel_landscape_settings.png icons/ic_nel_world_editor.png diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h index 9ab2dbfbc..0cdf6d3cd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h @@ -33,6 +33,8 @@ const char * const LANDSCAPE_USE_OPENGL = "LandscapeUseOpenGL"; //resources const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png"; +const char * const ICON_ZONE_ITEM = ":/icons/ic_nel_zone.png"; +const char * const ICON_LANDSCAPE_ZONES = ":/icons/ic_nel_zones.png"; } // namespace Constants From 2df08d6548701891c751061df80321c29e519748 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 18 Jul 2011 14:30:24 +0300 Subject: [PATCH 027/747] Changed: #1301 Added transition mode. --- .../landscape_editor/landscape_scene.cpp | 171 +++++++++++++++--- .../landscape_editor/landscape_scene.h | 9 +- 2 files changed, 158 insertions(+), 22 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index b2dc9dd5d..67485158d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -37,12 +37,17 @@ static const int LAYER_EMPTY_ZONES = 3; static const int LAYER_BLACKOUT = 4; const char * const LAYER_BLACKOUT_NAME = "blackout"; -LandscapeScene::LandscapeScene(QObject *parent) +const int MAX_SCENE_WIDTH = 256; +const int MAX_SCENE_HEIGHT = 256; + +LandscapeScene::LandscapeScene(int sizeCell, QObject *parent) : QGraphicsScene(parent), + m_cellSize(sizeCell), + m_transitionMode(false), m_mouseButton(Qt::NoButton), m_zoneBuilder(0) { - m_cellSize = 160; + setSceneRect(QRectF(0, m_cellSize, MAX_SCENE_WIDTH * m_cellSize, MAX_SCENE_HEIGHT * m_cellSize)); } LandscapeScene::~LandscapeScene() @@ -279,17 +284,18 @@ void LandscapeScene::snapshot(const QString &fileName, int width, int height, co QString LandscapeScene::zoneNameFromMousePos() const { - if ((m_posY > 0) || (m_posY < -255) || - (m_posX < 0) || (m_posX > 255)) + if ((m_posY > 0) || (m_posY < -MAX_SCENE_HEIGHT) || + (m_posX < 0) || (m_posX > MAX_SCENE_WIDTH)) return "NOT A VALID ZONE"; - return QString("%1_%2%3").arg(-m_posY).arg(QChar('A' + (m_posX/26))).arg(QChar('A' + (m_posX%26))); + return QString("%1_%2%3 %4 %5 ").arg(-m_posY).arg(QChar('A' + (m_posX/26))). + arg(QChar('A' + (m_posX%26))).arg(m_mouseX, 0,'f',2).arg(-m_mouseY, 0,'f',2); } void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { - qreal x = mouseEvent->scenePos().rx(); - qreal y = mouseEvent->scenePos().ry(); + qreal x = mouseEvent->scenePos().x(); + qreal y = mouseEvent->scenePos().y(); if ((x < 0) || (y < 0)) return; @@ -298,12 +304,20 @@ void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) if (m_zoneBuilder == 0) return; + if (m_transitionMode) + { + if (mouseEvent->button() == Qt::LeftButton) - if (mouseEvent->button() == Qt::LeftButton) - m_zoneBuilder->addZone(m_posX, m_posY); - else if (mouseEvent->button() == Qt::RightButton) - m_zoneBuilder->delZone(m_posX, m_posY); - + // Need add offset(= cellSize) on y axes + m_zoneBuilder->addTransition(sint(x), sint(-y + m_cellSize)); + } + else + { + if (mouseEvent->button() == Qt::LeftButton) + m_zoneBuilder->addZone(m_posX, m_posY); + else if (mouseEvent->button() == Qt::RightButton) + m_zoneBuilder->delZone(m_posX, m_posY); + } m_mouseButton = mouseEvent->button(); QGraphicsScene::mousePressEvent(mouseEvent); @@ -311,8 +325,8 @@ void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) { - qreal x = mouseEvent->scenePos().rx(); - qreal y = mouseEvent->scenePos().ry(); + qreal x = mouseEvent->scenePos().x(); + qreal y = mouseEvent->scenePos().y(); sint32 posX = sint32(floor(x / m_cellSize)); sint32 posY = sint32(-floor(y / m_cellSize)); @@ -321,11 +335,16 @@ void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) (m_mouseButton == Qt::LeftButton || m_mouseButton == Qt::RightButton)) { - if (m_mouseButton == Qt::LeftButton) - m_zoneBuilder->addZone(posX, posY); - else if (m_mouseButton == Qt::RightButton) - m_zoneBuilder->delZone(posX, posY); - + if (m_transitionMode) + { + } + else + { + if (m_mouseButton == Qt::LeftButton) + m_zoneBuilder->addZone(posX, posY); + else if (m_mouseButton == Qt::RightButton) + m_zoneBuilder->delZone(posX, posY); + } m_posX = posX; m_posY = posY; QApplication::processEvents(); @@ -334,8 +353,8 @@ void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) m_posX = posX; m_posY = posY; - m_mouseX = mouseEvent->scenePos().rx(); - m_mouseY = mouseEvent->scenePos().ry(); + m_mouseX = mouseEvent->scenePos().x(); + m_mouseY = mouseEvent->scenePos().y() - m_cellSize; QGraphicsScene::mouseMoveEvent(mouseEvent); } @@ -357,9 +376,23 @@ bool LandscapeScene::checkUnderZone(const int posX, const int posY) return false; } +bool LandscapeScene::transitionMode() const +{ + return m_transitionMode; +} + +void LandscapeScene::setTransitionMode(bool enabled) +{ + m_transitionMode = enabled; + update(); +} + void LandscapeScene::drawForeground(QPainter *painter, const QRectF &rect) { QGraphicsScene::drawForeground(painter, rect); + if ((m_zoneBuilder->currentIdZoneRegion() != -1) && (m_transitionMode)) + drawTransition(painter, rect); + /* // Render debug text (slow!) painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); @@ -381,4 +414,100 @@ void LandscapeScene::drawForeground(QPainter *painter, const QRectF &rect) */ } +void LandscapeScene::drawTransition(QPainter *painter, const QRectF &rect) +{ + int left = int(floor(rect.left() / m_cellSize)); + int right = int(floor(rect.right() / m_cellSize)); + int top = int(floor(rect.top() / m_cellSize)); + int bottom = int(floor(rect.bottom() / m_cellSize)); + + QVector redLines; + QVector whiteLines; + + for (int i = left; i < right + 1; ++i) + { + for (int j = top; j < bottom + 1; ++j) + { + // Get LIGO data + NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->currentZoneRegion()->ligoZoneRegion(); + uint8 ceUp = zoneRegion.getCutEdge (i, -j, 0); + uint8 ceLeft = zoneRegion.getCutEdge (i, -j, 2); + if ((ceUp > 0) && (ceUp < 3)) + { + // Calculate position vertical lines + int x1, x2, y1, y2; + + y1 = j * m_cellSize + m_cellSize / 12.0f; + y2 = y1 - (m_cellSize / 6.0f); + + x1 = i * m_cellSize + 3.0f * m_cellSize / 12.0f; + x2 = i * m_cellSize + 5.0f * m_cellSize / 12.0f; + if (ceUp == 1) + { + whiteLines.push_back(QLine(x1, y1, x1, y2)); + whiteLines.push_back(QLine(x2, y1, x2, y2)); + } + else + { + redLines.push_back(QLine(x1, y1, x1, y2)); + redLines.push_back(QLine(x2, y1, x2, y2)); + } + + x1 = i * m_cellSize + 7.0f * m_cellSize / 12.0f; + x2 = i * m_cellSize + 9.0f * m_cellSize / 12.0f; + if (ceUp == 1) + { + redLines.push_back(QLine(x1, y1, x1, y2)); + redLines.push_back(QLine(x2, y1, x2, y2)); + } + else + { + whiteLines.push_back(QLine(x1, y1, x1, y2)); + whiteLines.push_back(QLine(x2, y1, x2, y2)); + } + } + if ((ceLeft > 0) && (ceLeft < 3)) + { + // Calculate position horizontal lines + int x1, x2, y1, y2; + + x1 = i * m_cellSize - m_cellSize / 12.0f; + x2 = x1 + (m_cellSize / 6.0f); + + y1 = j * m_cellSize + 3.0f * m_cellSize / 12.0f; + y2 = j * m_cellSize + 5.0f * m_cellSize / 12.0f; + if (ceLeft == 1) + { + redLines.push_back(QLine(x1, y1, x2, y1)); + redLines.push_back(QLine(x1, y2, x2, y2)); + } + else + { + whiteLines.push_back(QLine(x1, y1, x2, y1)); + whiteLines.push_back(QLine(x1, y2, x2, y2)); + } + + y1 = j * m_cellSize + 7.0f * m_cellSize / 12.0f; + y2 = j * m_cellSize + 9.0f * m_cellSize / 12.0f; + if (ceLeft == 1) + { + whiteLines.push_back(QLine(x1, y1, x2, y1)); + whiteLines.push_back(QLine(x1, y2, x2, y2)); + } + else + { + redLines.push_back(QLine(x1, y1, x2, y1)); + redLines.push_back(QLine(x1, y2, x2, y2)); + } + } + } + } + + // Draw lines + painter->setPen(QPen(Qt::red, 0, Qt::SolidLine)); + painter->drawLines(redLines); + painter->setPen(QPen(Qt::white, 0, Qt::SolidLine)); + painter->drawLines(whiteLines); +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index 71d4c512e..8a31ed15d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -43,7 +43,7 @@ class LANDSCAPE_EDITOR_EXPORT LandscapeScene : public QGraphicsScene Q_OBJECT public: - LandscapeScene(QObject *parent = 0); + LandscapeScene(int sizeCell = 160, QObject *parent = 0); virtual ~LandscapeScene(); int cellSize() const; @@ -60,6 +60,10 @@ public: void snapshot(const QString &fileName, int width, int height, const QRectF &landRect); QString zoneNameFromMousePos() const; + bool transitionMode() const; + +public Q_SLOTS: + void setTransitionMode(bool enabled); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); @@ -67,10 +71,13 @@ protected: virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); virtual void drawForeground(QPainter *painter, const QRectF &rect); + void drawTransition(QPainter *painter, const QRectF &rect); + private: bool checkUnderZone(const int posX, const int posY); int m_cellSize; + bool m_transitionMode; qreal m_mouseX, m_mouseY; sint32 m_posX, m_posY; Qt::MouseButton m_mouseButton; From 2d01de720775b220d4eac8417f721217c6a0962b Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 18 Jul 2011 14:32:54 +0300 Subject: [PATCH 028/747] Changed: #1301 Improved appearance of landscape editor. --- .../landscape_editor_window.cpp | 36 +++++---- .../landscape_editor_window.ui | 52 +++++++++---- .../landscape_editor/landscape_view.cpp | 76 ++++++++++--------- .../plugins/landscape_editor/landscape_view.h | 2 + .../landscape_editor/shapshot_dialog.ui | 8 +- 5 files changed, 110 insertions(+), 64 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 62feaec48..a97dcf380 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -56,7 +56,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); - m_landscapeScene = new LandscapeScene(this); + m_landscapeScene = new LandscapeScene(160, this); m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack); m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder); @@ -69,6 +69,9 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); m_ui.saveLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); m_ui.saveAsLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS)); + m_ui.zonesDockWidget->toggleViewAction()->setIcon(QIcon(Constants::ICON_LANDSCAPE_ZONES)); + m_ui.landscapesDockWidget->toggleViewAction()->setIcon(QIcon(Constants::ICON_ZONE_ITEM)); + m_ui.deleteLandAction->setEnabled(false); createMenus(); @@ -85,6 +88,7 @@ LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent) connect(m_ui.saveLandAction, SIGNAL(triggered()), this, SLOT(saveSelectedLand())); connect(m_ui.saveAsLandAction, SIGNAL(triggered()), this, SLOT(saveAsSelectedLand())); connect(m_ui.deleteLandAction, SIGNAL(triggered()), this, SLOT(deleteSelectedLand())); + connect(m_ui.transitionModeAction, SIGNAL(toggled(bool)), m_landscapeScene, SLOT(setTransitionMode(bool))); connect(m_ui.landscapesListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu())); m_ui.landscapesListWidget->setContextMenuPolicy(Qt::CustomContextMenu); @@ -353,23 +357,27 @@ void LandscapeEditorWindow::createToolBars() Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); //QAction *action = menuManager->action(Core::Constants::NEW); //m_ui.fileToolBar->addAction(action); - QAction *action = menuManager->action(Core::Constants::OPEN); - m_ui.fileToolBar->addAction(m_ui.newLandAction); - m_ui.fileToolBar->addAction(action); - m_ui.fileToolBar->addAction(m_ui.saveAction); - - action = menuManager->action(Core::Constants::UNDO); - if (action != 0) - m_ui.undoToolBar->addAction(action); - - action = menuManager->action(Core::Constants::REDO); - if (action != 0) - m_ui.undoToolBar->addAction(action); - //action = menuManager->action(Core::Constants::SAVE); //m_ui.fileToolBar->addAction(action); //action = menuManager->action(Core::Constants::SAVE_AS); //m_ui.fileToolBar->addAction(action); + + QAction *action = menuManager->action(Core::Constants::OPEN); + m_ui.fileToolBar->addAction(m_ui.newLandAction); + m_ui.fileToolBar->addAction(action); + m_ui.fileToolBar->addAction(m_ui.saveAction); + m_ui.fileToolBar->addSeparator(); + + action = menuManager->action(Core::Constants::UNDO); + if (action != 0) + m_ui.fileToolBar->addAction(action); + + action = menuManager->action(Core::Constants::REDO); + if (action != 0) + m_ui.fileToolBar->addAction(action); + + m_ui.zoneToolBar->insertAction(m_ui.enableGridAction, m_ui.landscapesDockWidget->toggleViewAction()); + m_ui.zoneToolBar->insertAction(m_ui.enableGridAction, m_ui.zonesDockWidget->toggleViewAction()); } void LandscapeEditorWindow::readSettings() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui index b2db9dc42..77133c593 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.ui @@ -31,8 +31,8 @@ 0.000000000000000 0.000000000000000 - 99999.000000000000000 - 99999.000000000000000 + 0.000000000000000 + 0.000000000000000 @@ -65,7 +65,11 @@ false - + + + + :/icons/ic_nel_zones.png:/icons/ic_nel_zones.png + Zones @@ -74,18 +78,11 @@ - - - toolBar_2 - - - TopToolBarArea - - - false - - + + + :/icons/ic_nel_zone.png:/icons/ic_nel_zone.png + Landscapes @@ -116,9 +113,10 @@ false + + - @@ -136,6 +134,10 @@ true + + + :/icons/ic_grid.png:/icons/ic_grid.png + EnableGrid @@ -147,6 +149,10 @@ + + + :/icons/ic_snapshot.png:/icons/ic_snapshot.png + snapshot @@ -200,6 +206,22 @@ Create new landscape + + + true + + + + :/icons/ic_nel_landscape_item.png + :/icons/ic_nel_transition_land.png:/icons/ic_nel_landscape_item.png + + + Transition mode + + + Enable transition mode + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index 40074292d..263417204 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -59,9 +59,7 @@ bool LandscapeView::isVisibleGrid() const void LandscapeView::setVisibleGrid(bool visible) { m_visibleGrid = visible; - - // hack for repaint view - translate(0.0001, 0.0001); + scene()->update(); } void LandscapeView::wheelEvent(QWheelEvent *event) @@ -117,45 +115,55 @@ void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect) if (!m_visibleGrid) return; - qreal scaleFactor = transform().m11(); painter->setPen(QPen(Qt::white, 0, Qt::SolidLine)); + drawGrid(painter, rect); - // draw grid - qreal left = m_cellSize * floor(rect.left() / m_cellSize); - qreal top = m_cellSize * floor(rect.top() / m_cellSize); - - // draw vertical lines - while (left < rect.right()) - { - painter->drawLine(int(left), int(rect.bottom()), int(left), int(rect.top())); - left += m_cellSize; - } - - // draw horizontal lines - while (top < rect.bottom()) - { - painter->drawLine(int(rect.left()), int(top), int(rect.right()), int(top)); - top += m_cellSize; - } - - // Render text (slow!) if (m_numSteps > -m_maxSteps / 4) { painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); - //painter->setFont(QFont("Helvetica [Cronyx]", 12)); - int leftSide = int(floor(rect.left() / m_cellSize)); - int rightSide = int(floor(rect.right() / m_cellSize)); - int topSide = int(floor(rect.top() / m_cellSize)); - int bottomSide = int(floor(rect.bottom() / m_cellSize)); + drawZoneNames(painter, rect); + } +} - for (int i = leftSide; i < rightSide + 1; ++i) +void LandscapeView::drawGrid(QPainter *painter, const QRectF &rect) +{ + qreal left = m_cellSize * floor(rect.left() / m_cellSize); + qreal top = m_cellSize * floor(rect.top() / m_cellSize); + + QVector lines; + + // Calculate vertical lines + while (left < rect.right()) + { + lines.push_back(QLine(int(left), int(rect.bottom()), int(left), int(rect.top()))); + left += m_cellSize; + } + + // Calculate horizontal lines + while (top < rect.bottom()) + { + lines.push_back(QLine(int(rect.left()), int(top), int(rect.right()), int(top))); + top += m_cellSize; + } + + // Draw lines + painter->drawLines(lines); +} + +void LandscapeView::drawZoneNames(QPainter *painter, const QRectF &rect) +{ + int leftSide = int(floor(rect.left() / m_cellSize)); + int rightSide = int(floor(rect.right() / m_cellSize)); + int topSide = int(floor(rect.top() / m_cellSize)); + int bottomSide = int(floor(rect.bottom() / m_cellSize)); + + for (int i = leftSide; i < rightSide + 1; ++i) + { + for (int j = topSide; j < bottomSide + 1; ++j) { - for (int j = topSide; j < bottomSide + 1; ++j) - { - QString text = QString("%1_%2%3").arg(j).arg(QChar('A' + (i / 26))).arg(QChar('A' + (i % 26))); - painter->drawText(i * m_cellSize + 5, j * m_cellSize + 15, text); - } + QString text = QString("%1_%2%3").arg(j).arg(QChar('A' + (i / 26))).arg(QChar('A' + (i % 26))); + painter->drawText(i * m_cellSize + 5, j * m_cellSize + 15, text); } } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h index 2ae251fee..0673db82c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -49,6 +49,8 @@ protected: virtual void mouseReleaseEvent(QMouseEvent *event); virtual void drawForeground(QPainter *painter, const QRectF &rect); + void drawGrid(QPainter *painter, const QRectF &rect); + void drawZoneNames(QPainter *painter, const QRectF &rect); private: bool m_visibleGrid; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui index 1c25a2ace..66f657012 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/shapshot_dialog.ui @@ -13,6 +13,10 @@ Snapshot + + + :/icons/ic_snapshot.png:/icons/ic_snapshot.png + @@ -136,7 +140,9 @@ keepRatioCheckBox buttonBox - + + + buttonBox From 899132aaf641054792104bd2766eaf00bc835103 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 20 Jul 2011 18:07:46 +0300 Subject: [PATCH 029/747] Changed: #1302 Added initial database of primitives (model/view) (loading of *. primitive file) --- .../src/plugins/world_editor/CMakeLists.txt | 1 + .../plugins/world_editor/primitive_item.cpp | 145 +++++++++++++++ .../src/plugins/world_editor/primitive_item.h | 99 ++++++++++ .../plugins/world_editor/primitives_model.cpp | 172 ++++++++++++++++++ .../plugins/world_editor/primitives_model.h | 65 +++++++ .../world_editor/world_editor_actions.cpp | 47 +++++ .../world_editor/world_editor_actions.h | 48 +++++ .../world_editor/world_editor_constants.h | 4 + .../world_editor/world_editor_plugin.cpp | 34 +++- .../world_editor/world_editor_plugin.h | 2 + .../world_editor/world_editor_window.cpp | 56 ++++-- .../world_editor/world_editor_window.h | 4 + .../world_editor/world_editor_window.ui | 41 ++++- 13 files changed, 701 insertions(+), 17 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt index 784dd6139..c8b034444 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt @@ -11,6 +11,7 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h world_editor_window.h + primitives_model.h ) SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp new file mode 100644 index 000000000..9ec95bdaa --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -0,0 +1,145 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "primitive_item.h" + +// Qt includes +#include + +namespace WorldEditor +{ + +BaseTreeItem::BaseTreeItem(BaseTreeItem *parent) +{ + m_parentItem = parent; + m_itemData << QIcon() << "" << "" << ""; +} + +BaseTreeItem::BaseTreeItem(const QList &data, BaseTreeItem *parent) +{ + m_parentItem = parent; + m_itemData = data; +} + +BaseTreeItem::~BaseTreeItem() +{ + qDeleteAll(m_childItems); +} + +void BaseTreeItem::appendChild(BaseTreeItem *item) +{ + m_childItems.append(item); +} + +BaseTreeItem *BaseTreeItem::child(int row) +{ + return m_childItems.value(row); +} + +int BaseTreeItem::childCount() const +{ + return m_childItems.count(); +} + +int BaseTreeItem::columnCount() const +{ + return m_itemData.count(); +} + +QVariant BaseTreeItem::data(int column) const +{ + return m_itemData.value(column); +} + +void BaseTreeItem::setData(int column, const QVariant &data) +{ + m_itemData[column] = data; +} + +BaseTreeItem *BaseTreeItem::parent() +{ + return m_parentItem; +} + +int BaseTreeItem::row() const +{ + if (m_parentItem) + return m_parentItem->m_childItems.indexOf(const_cast(this)); + + return 0; +} + +void BaseTreeItem::setModified(bool value) +{ + m_modified = value; +} + +bool BaseTreeItem::isModified() const +{ + return m_modified; +} + +PrimitiveItem::PrimitiveItem(NLLIGO::IPrimitive *primitive, BaseTreeItem *parent) + : BaseTreeItem(parent), + m_primitive(primitive) +{ + setData(1, QString(m_primitive->getName().c_str())); + setData(2, QString(m_primitive->getClassName().c_str())); + + std::string className; + m_primitive->getPropertyByName("class", className); + + // Set Icon + QIcon icon(QString("./old_ico/%1.ico").arg(className.c_str())); + if (primitive->getParent() == NULL) + icon = QIcon("./old_ico/root.ico"); + if (icon.isNull()) + { + if (primitive->getNumChildren() == 0) + icon = QIcon("./old_ico/property.ico"); + else + icon = QIcon("./old_ico/folder_h.ico"); + } + setData(0, icon); + + setData(3, QString(className.c_str())); +} +/* +PrimitiveItem::PrimitiveItem(const PrimitiveItem &other) +{ +} +*/ +PrimitiveItem::~PrimitiveItem() +{ +} + +PrimitivesItem::PrimitivesItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent) + : PrimitiveItem(primitives->RootNode, parent), + m_primitives(primitives) +{ + setData(1, name); +} +/* +PrimitivesItem::PrimitivesItem(const PrimitiveItem &other) +{ +} +*/ +PrimitivesItem::~PrimitivesItem() +{ +} + +} /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h new file mode 100644 index 000000000..26ca70670 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -0,0 +1,99 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef PRIMITIVE_ITEM_H +#define PRIMITIVE_ITEM_H + +// Project includes + +// NeL includes +#include + +// Qt includes +#include +#include +#include + +namespace WorldEditor +{ + +/* +@class BaseTreeItem +@brief +@details +*/ +class BaseTreeItem +{ +public: + BaseTreeItem(BaseTreeItem *parent = 0); + BaseTreeItem(const QList &data, BaseTreeItem *parent = 0); + virtual ~BaseTreeItem(); + + void appendChild(BaseTreeItem *child); + + BaseTreeItem *child(int row); + int childCount() const; + int columnCount() const; + QVariant data(int column) const; + void setData(int column, const QVariant &data); + int row() const; + BaseTreeItem *parent(); + void setModified(bool value); + bool isModified() const; + +private: + + bool m_modified; + QList m_childItems; + QList m_itemData; + BaseTreeItem *m_parentItem; +}; + +/* +@class PrimitiveItem +@brief +@details +*/ +class PrimitiveItem: public BaseTreeItem +{ +public: + PrimitiveItem(NLLIGO::IPrimitive *primitive, BaseTreeItem *parent); + PrimitiveItem(const PrimitiveItem &other); + virtual ~PrimitiveItem(); + +private: + NLLIGO::IPrimitive *m_primitive; +}; + +/* +@class PrimitivesItem +@brief +@details +*/ +class PrimitivesItem: public PrimitiveItem +{ +public: + PrimitivesItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent); + PrimitivesItem(const PrimitiveItem &other); + virtual ~PrimitivesItem(); + +private: + NLLIGO::CPrimitives *m_primitives; +}; + +} /* namespace WorldEditor */ + +#endif // PRIMITIVE_ITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp new file mode 100644 index 000000000..8c5af6229 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp @@ -0,0 +1,172 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include +#include +#include + +#include + +#include "primitive_item.h" +#include "primitives_model.h" + +namespace WorldEditor +{ + +PrimitivesTreeModel::PrimitivesTreeModel(QObject *parent) + : QAbstractItemModel(parent) +{ + QList rootData; + rootData << "Name" << "Class" << "Class"; + m_rootItem = new BaseTreeItem(rootData); +} + +PrimitivesTreeModel::~PrimitivesTreeModel() +{ + delete m_rootItem; +} + +int PrimitivesTreeModel::columnCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return static_cast(parent.internalPointer())->columnCount(); + else + return m_rootItem->columnCount(); +} + +QVariant PrimitivesTreeModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + BaseTreeItem *item = static_cast(index.internalPointer()); + switch (role) + { +// case Qt::TextAlignmentRole: +// return int(Qt::AlignLeft | Qt::AlignVCenter); + case Qt::DisplayRole: + return item->data(index.column() + 1); + case Qt::DecorationRole: + { + if (index.column() == 0) + return qVariantFromValue(item->data(0)); + else + return QVariant(); + } + default: + return QVariant(); + } +} + +Qt::ItemFlags PrimitivesTreeModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return 0; + + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +QVariant PrimitivesTreeModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + return m_rootItem->data(section); + + return QVariant(); +} + +QModelIndex PrimitivesTreeModel::index(int row, int column, const QModelIndex &parent) +const +{ + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + BaseTreeItem *parentItem; + + if (!parent.isValid()) + parentItem = m_rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + BaseTreeItem *childItem = parentItem->child(row); + if (childItem) + return createIndex(row, column, childItem); + else + return QModelIndex(); +} + +QModelIndex PrimitivesTreeModel::parent(const QModelIndex &index) const +{ + if (!index.isValid()) + return QModelIndex(); + + BaseTreeItem *childItem = static_cast(index.internalPointer()); + BaseTreeItem *parentItem = childItem->parent(); + + if (parentItem == m_rootItem) + return QModelIndex(); + + return createIndex(parentItem->row(), 0, parentItem); +} + +int PrimitivesTreeModel::rowCount(const QModelIndex &parent) const +{ + BaseTreeItem *parentItem; + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) + parentItem = m_rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + return parentItem->childCount(); +} + +void PrimitivesTreeModel::addPrimitives(const QString &name, NLLIGO::CPrimitives *primitives) +{ + beginResetModel(); + PrimitivesItem *newPrimitives = new PrimitivesItem(name, primitives, m_rootItem); + m_rootItem->appendChild(newPrimitives); + for (uint i = 0; i < primitives->RootNode->getNumChildren(); ++i) + { + NLLIGO::IPrimitive *childPrim; + primitives->RootNode->getChild(childPrim, i); + scanPrimitive(childPrim, newPrimitives); + } + endResetModel(); +} + +void PrimitivesTreeModel::scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem *parent) +{ +// const NLLIGO::CPrimitiveClass *primClass = NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*prim); +// nlassert (primClass); +// if (primClass->Type == NLLIGO::CPrimitiveClass::Alias) +// return; + if (prim->getClassName() == "CPrimAlias") + return; + + PrimitiveItem *newItem = new PrimitiveItem(prim, parent); + parent->appendChild(newItem); + for (uint i = 0; i < prim->getNumChildren(); ++i) + { + NLLIGO::IPrimitive *childPrim; + prim->getChild(childPrim, i); + scanPrimitive(childPrim, newItem); + } +} + +} /* namespace WorldEditor */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h new file mode 100644 index 000000000..5098d1e5e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h @@ -0,0 +1,65 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef PRIMITIVES_MODEL_H +#define PRIMITIVES_MODEL_H + +#include + +#include +#include +#include + +namespace WorldEditor +{ + +class BaseTreeItem; + +/** +@class PrimitivesTreeModel +@brief +@details +*/ +class PrimitivesTreeModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + PrimitivesTreeModel(QObject *parent = 0); + ~PrimitivesTreeModel(); + + QVariant data(const QModelIndex &index, int role) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + + void addPrimitives(const QString &name, NLLIGO::CPrimitives *primitives); + +private: + void scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem *parent = 0); + + BaseTreeItem *m_rootItem; +}; + +} /* namespace WorldEditor */ + +#endif // PRIMITIVES_MODEL_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp new file mode 100644 index 000000000..cae402d27 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -0,0 +1,47 @@ +// 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 "world_editor_actions.h" + +// NeL includes +#include + +// Qt includes + +namespace WorldEditor +{ + +OpenLandscapeCommand::OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent) + : QUndoCommand(parent), + m_fileName(fileName) +{ +} + +OpenLandscapeCommand::~OpenLandscapeCommand() +{ +} + +void OpenLandscapeCommand::undo() +{ +} + +void OpenLandscapeCommand::redo() +{ +} + +} /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h new file mode 100644 index 000000000..5a1c1ea49 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -0,0 +1,48 @@ +// 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 WORLD_EDITOR_ACTIONS_H +#define WORLD_EDITOR_ACTIONS_H + +// Project includes + +// NeL includes + +// Qt includes +#include +#include +#include + +namespace WorldEditor +{ + +class OpenLandscapeCommand: public QUndoCommand +{ +public: + OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent = 0); + virtual ~OpenLandscapeCommand(); + + virtual void undo(); + virtual void redo(); +private: + + QString m_fileName; +}; + +} /* namespace WorldEditor */ + +#endif // WORLD_EDITOR_ACTIONS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index 644f79b53..a54b82cb1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -28,6 +28,10 @@ const char * const WORLD_EDITOR_PLUGIN = "WorldEditor"; const char * const WORLD_EDITOR_SECTION = "WorldEditor"; const char * const WORLD_WINDOW_STATE = "WorldWindowState"; const char * const WORLD_WINDOW_GEOMETRY = "WorldWindowGeometry"; +const char * const WORLD_EDITOR_CELL_SIZE = "WorldEditorCellSize"; +const char * const WORLD_EDITOR_SNAP = "WorldEditorSnap"; +const char * const ZONE_SNAPSHOT_RES = "WorldEditorZoneSnapshotRes"; +const char * const PRIMITIVE_CLASS_FILENAME = "WorldEditorPrimitiveClassFilename"; //resources const char * const ICON_WORLD_EDITOR = ":/icons/ic_nel_world_editor.png"; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp index 494f6e2b6..90d2de6d6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp @@ -24,6 +24,9 @@ // NeL includes #include "nel/misc/debug.h" +#include +#include +#include // Qt includes #include @@ -43,8 +46,35 @@ WorldEditorPlugin::~WorldEditorPlugin() bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) { - Q_UNUSED(errorString); m_plugMan = pluginManager; + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::WORLD_EDITOR_SECTION); + m_ligoConfig.CellSize = settings->value(Constants::WORLD_EDITOR_CELL_SIZE, "160").toFloat(); + m_ligoConfig.Snap = settings->value(Constants::WORLD_EDITOR_SNAP, "1").toFloat(); + m_ligoConfig.ZoneSnapShotRes = settings->value(Constants::ZONE_SNAPSHOT_RES, "128").toUInt(); + QString fileName = settings->value(Constants::PRIMITIVE_CLASS_FILENAME, "world_editor_classes.xml").toString(); + settings->endGroup(); + try + { + // Search path of file world_editor_classes.xml + std::string ligoPath = NLMISC::CPath::lookup(fileName.toStdString()); + // Init LIGO + m_ligoConfig.readPrimitiveClass(ligoPath.c_str(), true); + NLLIGO::Register(); + NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig; + } + catch (NLMISC::Exception &e) + { + *errorString = tr("(%1)").arg(e.what()); + return false; + } + + // Reset + m_ligoConfig.resetPrimitiveConfiguration (); + + // Load + m_ligoConfig.readPrimitiveClass ("world_editor_primitive_configuration.xml", true); + addAutoReleasedObject(new WorldEditorContext(this)); return true; @@ -115,7 +145,7 @@ QUndoStack *WorldEditorContext::undoStack() void WorldEditorContext::open() { - //m_worldEditorWindow->open(); + m_worldEditorWindow->open(); } QWidget *WorldEditorContext::widget() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h index fdfff7eff..11e2c7871 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h @@ -25,6 +25,7 @@ // NeL includes #include "nel/misc/app_context.h" +#include // Qt includes #include @@ -70,6 +71,7 @@ protected: NLMISC::CLibraryContext *m_libContext; private: + NLLIGO::CLigoConfig m_ligoConfig; ExtensionSystem::IPluginManager *m_plugMan; QList m_autoReleaseObjects; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 7d6f9dcfd..8d2c0c7f1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -18,13 +18,25 @@ // Project includes #include "world_editor_window.h" #include "world_editor_constants.h" +#include "primitives_model.h" #include "../core/icore.h" #include "../core/imenu_manager.h" #include "../core/core_constants.h" +// NeL includes +#include +#include +#include + +#include +#include +#include +#include + // Qt includes #include +#include namespace WorldEditor { @@ -32,11 +44,15 @@ QString _lastDir; WorldEditorWindow::WorldEditorWindow(QWidget *parent) : QMainWindow(parent), + m_primitivesModel(0), m_undoStack(0) { m_ui.setupUi(this); m_undoStack = new QUndoStack(this); + m_primitivesModel = new PrimitivesTreeModel(); + m_ui.treePrimitivesView->setModel(m_primitivesModel); + createMenus(); createToolBars(); // readSettings(); @@ -54,20 +70,33 @@ QUndoStack *WorldEditorWindow::undoStack() const void WorldEditorWindow::open() { - /* QStringList fileNames = QFileDialog::getOpenFileNames(this, - tr("Open NeL Ligo land file"), _lastDir, - tr("All NeL Ligo land files (*.land)")); + QStringList fileNames = QFileDialog::getOpenFileNames(this, + tr("Open NeL Ligo primitive file"), _lastDir, + tr("All NeL Ligo primitive files (*.primitive)")); - setCursor(Qt::WaitCursor); - if (!fileNames.isEmpty()) + setCursor(Qt::WaitCursor); + if (!fileNames.isEmpty()) + { + QStringList list = fileNames; + _lastDir = QFileInfo(list.front()).absolutePath(); + Q_FOREACH(QString fileName, fileNames) { - QStringList list = fileNames; - _lastDir = QFileInfo(list.front()).absolutePath(); - Q_FOREACH(QString fileName, fileNames) - { - } + loadPrimitive(fileName); } - setCursor(Qt::ArrowCursor);*/ + } + setCursor(Qt::ArrowCursor); +} + +void WorldEditorWindow::loadPrimitive(const QString &fileName) +{ + NLLIGO::CPrimitives *primitives = new NLLIGO::CPrimitives(); + + // set the primitive context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = primitives; + + NLLIGO::loadXmlPrimitiveFile(*primitives, fileName.toStdString(), *NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); + + m_primitivesModel->addPrimitives(fileName, primitives); } void WorldEditorWindow::createMenus() @@ -82,14 +111,15 @@ void WorldEditorWindow::createToolBars() //m_ui.fileToolBar->addAction(action); QAction *action = menuManager->action(Core::Constants::OPEN); m_ui.fileToolBar->addAction(action); + m_ui.fileToolBar->addSeparator(); action = menuManager->action(Core::Constants::UNDO); if (action != 0) - m_ui.undoToolBar->addAction(action); + m_ui.fileToolBar->addAction(action); action = menuManager->action(Core::Constants::REDO); if (action != 0) - m_ui.undoToolBar->addAction(action); + m_ui.fileToolBar->addAction(action); //action = menuManager->action(Core::Constants::SAVE); //m_ui.fileToolBar->addAction(action); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 8efafc48b..8311ffcc6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -26,6 +26,7 @@ namespace WorldEditor { +class PrimitivesTreeModel; class WorldEditorWindow: public QMainWindow { @@ -48,6 +49,9 @@ private: void readSettings(); void writeSettings(); + void loadPrimitive(const QString &fileName); + + PrimitivesTreeModel *m_primitivesModel; QUndoStack *m_undoStack; Ui::WorldEditorWindow m_ui; }; /* class WorldEditorWindow */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index 86c8a2b11..6f597ca2a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -20,7 +20,7 @@ - + @@ -35,7 +35,7 @@ false - + toolBar @@ -45,8 +45,45 @@ false + + + + + 2 + + + + + 3 + + + 3 + + + + + + + + + + loadPrimitive + + + + + newPrimitive + + + + + LandscapeEditor::LandscapeView + QGraphicsView +

../landscape_editor/landscape_view.h
+
+
From 6b7cdf00c1132f18730efe1c8381a24c926ccb66 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 27 Jul 2011 19:01:54 +0300 Subject: [PATCH 030/747] Changed: #1301 Added LandscapeSceneBase and ZoneBuilderBase classes for world editor plugin (ZoneBuilder and LandscapeScene classes are being divided on two separatly classes). --- .../plugins/landscape_editor/CMakeLists.txt | 1 + .../plugins/landscape_editor/builder_zone.h | 24 +- .../landscape_editor/builder_zone_base.cpp | 301 ++++++++++++++++ .../landscape_editor/builder_zone_base.h | 139 ++++++++ .../landscape_editor/landscape_scene.h | 2 +- .../landscape_editor/landscape_scene_base.cpp | 320 ++++++++++++++++++ .../landscape_editor/landscape_scene_base.h | 81 +++++ .../project_settings_dialog.h | 3 +- 8 files changed, 846 insertions(+), 25 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt index 7ef0a11bf..4681c5d8b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/CMakeLists.txt @@ -11,6 +11,7 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h landscape_editor_window.h + landscape_scene_base.h landscape_scene.h list_zones_model.h list_zones_widget.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index 789af03f7..d16008a5f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -19,6 +19,7 @@ #define BUILDER_ZONE_H // Project includes +#include "builder_zone_base.h" #include "builder_zone_region.h" #include "zone_region_editor.h" #include "pixmap_database.h" @@ -46,29 +47,6 @@ class ListZonesWidget; class LandscapeScene; class UndoScanRegionCommand; -// Data -struct ZonePosition -{ - // Absolute position - sint32 x; - sint32 y; - int region; - - ZonePosition() - { - x = 0xffffffff; - y = 0xffffffff; - region = -1; - } - - ZonePosition(const sint32 posX, const sint32 posY, const int id) - { - x = posX; - y = posY; - region = id; - } -}; - /** @class ZoneBuilder @brief ZoneBuilder contains all the shared data between the tools and the engine. diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp new file mode 100644 index 000000000..a8fc40cab --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp @@ -0,0 +1,301 @@ +// 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 "builder_zone_base.h" +#include "list_zones_widget.h" +#include "landscape_actions.h" + +// NeL includes +#include + +// Qt includes +#include +#include +#include + +namespace LandscapeEditor +{ +int NewLandId = 0; + +ZoneBuilderBase::ZoneBuilderBase(LandscapeScene *landscapeScene) + : m_currentZoneRegion(-1), + m_pixmapDatabase(0), + m_landscapeScene(landscapeScene) +{ + nlassert(m_landscapeScene); + m_pixmapDatabase = new PixmapDatabase(); + m_lastPathName = ""; +} + +ZoneBuilderBase::~ZoneBuilderBase() +{ + delete m_pixmapDatabase; +} + +bool ZoneBuilderBase::init(const QString &pathName, bool displayProgress) +{ + if (pathName.isEmpty()) + return false; + if (pathName != m_lastPathName) + { + m_lastPathName = pathName; + QString zoneBankPath = pathName; + zoneBankPath += "/zoneligos/"; + + // Init the ZoneBank + m_zoneBank.reset(); + if (!initZoneBank (zoneBankPath)) + { + m_zoneBank.reset(); + return false; + } + // Construct the DataBase from the ZoneBank + QString zoneBitmapPath = pathName; + zoneBitmapPath += "/zonebitmaps/"; + m_pixmapDatabase->reset(); + if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank, displayProgress)) + { + m_zoneBank.reset(); + return false; + } + } + return true; +} + +int ZoneBuilderBase::createZoneRegion() +{ + LandscapeItem landItem; + landItem.zoneRegionObject = new ZoneRegionObject(); +// landItem.builderZoneRegion = new BuilderZoneRegion(LandCounter); +// landItem.builderZoneRegion->init(this); + landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); + + m_landscapeMap.insert(NewLandId, landItem); + if (m_currentZoneRegion == -1) + setCurrentZoneRegion(NewLandId); + + calcMask(); + return NewLandId++; +} + +int ZoneBuilderBase::createZoneRegion(const QString &fileName) +{ + LandscapeItem landItem; + landItem.zoneRegionObject = new ZoneRegionObject(); + landItem.zoneRegionObject->load(fileName.toStdString()); + + if (!checkOverlaps(landItem.zoneRegionObject->ligoZoneRegion())) + { + delete landItem.zoneRegionObject; + return -1; + } +// landItem.builderZoneRegion = new BuilderZoneRegion(LandCounter); +// landItem.builderZoneRegion->init(this); + + m_landscapeScene->addZoneRegion(landItem.zoneRegionObject->ligoZoneRegion()); + landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); + m_landscapeMap.insert(NewLandId, landItem); + + if (m_currentZoneRegion == -1) + setCurrentZoneRegion(NewLandId); + + calcMask(); + return NewLandId++; +} + +void ZoneBuilderBase::deleteZoneRegion(int id) +{ + if (m_landscapeMap.contains(id)) + { + if (m_landscapeMap.value(id).rectItem != 0) + delete m_landscapeMap.value(id).rectItem; + m_landscapeScene->delZoneRegion(m_landscapeMap.value(id).zoneRegionObject->ligoZoneRegion()); + delete m_landscapeMap.value(id).zoneRegionObject; +// delete m_landscapeMap.value(id).builderZoneRegion; + m_landscapeMap.remove(id); + calcMask(); + } + else + nlwarning("Landscape (id %i) not found", id); +} + +void ZoneBuilderBase::setCurrentZoneRegion(int id) +{ + if (m_landscapeMap.contains(id)) + { + if (currentIdZoneRegion() != -1) + { + NLLIGO::CZoneRegion &ligoRegion = m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject->ligoZoneRegion(); + m_landscapeMap[m_currentZoneRegion].rectItem = m_landscapeScene->createLayerBlackout(ligoRegion); + } + delete m_landscapeMap.value(id).rectItem; + m_landscapeMap[id].rectItem = 0; + m_currentZoneRegion = id; + calcMask(); + } + else + nlwarning("Landscape (id %i) not found", id); +} + +int ZoneBuilderBase::currentIdZoneRegion() const +{ + return m_currentZoneRegion; +} + +ZoneRegionObject *ZoneBuilderBase::currentZoneRegion() const +{ + return m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject; +} + +int ZoneBuilderBase::countZoneRegion() const +{ + return m_landscapeMap.size(); +} + +ZoneRegionObject *ZoneBuilderBase::zoneRegion(int id) const +{ + return m_landscapeMap.value(id).zoneRegionObject; +} + +void ZoneBuilderBase::ligoData(LigoData &data, const ZonePosition &zonePos) +{ + m_landscapeMap.value(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y); +} + +void ZoneBuilderBase::setLigoData(LigoData &data, const ZonePosition &zonePos) +{ + m_landscapeMap.value(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y); +} + +bool ZoneBuilderBase::initZoneBank (const QString &pathName) +{ + QDir *dir = new QDir(pathName); + QStringList filters; + filters << "*.ligozone"; + + // Find all ligozone files in dir + QStringList listFiles = dir->entryList(filters, QDir::Files); + + std::string error; + Q_FOREACH(QString file, listFiles) + { + //nlinfo(file.toStdString().c_str()); + if (!m_zoneBank.addElement((pathName + file).toStdString(), error)) + QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok); + } + delete dir; + return true; +} + +PixmapDatabase *ZoneBuilderBase::pixmapDatabase() const +{ + return m_pixmapDatabase; +} + +QString ZoneBuilderBase::dataPath() const +{ + return m_lastPathName; +} + +bool ZoneBuilderBase::getZoneMask(sint32 x, sint32 y) +{ + if ((x < m_minX) || (x > m_maxX) || + (y < m_minY) || (y > m_maxY)) + { + return true; + } + else + { + return m_zoneMask[(x - m_minX) + (y - m_minY) * (1 + m_maxX - m_minX)]; + } +} + +void ZoneBuilderBase::calcMask() +{ + sint32 x, y; + + m_minY = m_minX = 1000000; + m_maxY = m_maxX = -1000000; + + if (m_landscapeMap.size() == 0) + return; + + QMapIterator i(m_landscapeMap); + while (i.hasNext()) + { + i.next(); + const NLLIGO::CZoneRegion ®ion = i.value().zoneRegionObject->ligoZoneRegion(); + + if (m_minX > region.getMinX()) + m_minX = region.getMinX(); + if (m_minY > region.getMinY()) + m_minY = region.getMinY(); + if (m_maxX < region.getMaxX()) + m_maxX = region.getMaxX(); + if (m_maxY < region.getMaxY()) + m_maxY = region.getMaxY(); + } + + m_zoneMask.resize ((1 + m_maxX - m_minX) * (1 + m_maxY - m_minY)); + sint32 stride = (1 + m_maxX - m_minX); + for (y = m_minY; y <= m_maxY; ++y) + for (x = m_minX; x <= m_maxX; ++x) + { + m_zoneMask[x - m_minX + (y - m_minY) * stride] = true; + + QMapIterator it(m_landscapeMap); + while (it.hasNext()) + { + it.next(); + if (int(it.key()) != m_currentZoneRegion) + { + const NLLIGO::CZoneRegion ®ion = it.value().zoneRegionObject->ligoZoneRegion(); + + const std::string &rSZone = region.getName (x, y); + if ((rSZone != STRING_OUT_OF_BOUND) && (rSZone != STRING_UNUSED)) + { + m_zoneMask[x - m_minX + (y - m_minY) * stride] = false; + } + } + } + } +} + +bool ZoneBuilderBase::checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion) +{ + QMapIterator it(m_landscapeMap); + while (it.hasNext()) + { + it.next(); + const NLLIGO::CZoneRegion &zoneRegion = it.value().zoneRegionObject->ligoZoneRegion(); + for (sint32 y = zoneRegion.getMinY(); y <= zoneRegion.getMaxY(); ++y) + for (sint32 x = zoneRegion.getMinX(); x <= zoneRegion.getMaxX(); ++x) + { + const std::string &refZoneName = zoneRegion.getName(x, y); + if (refZoneName != STRING_UNUSED) + { + const std::string &zoneName = newZoneRegion.getName(x, y); + if ((zoneName != STRING_UNUSED) && (zoneName != STRING_OUT_OF_BOUND)) + return false; + } + } + } + return true; +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h new file mode 100644 index 000000000..509181c94 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h @@ -0,0 +1,139 @@ +// 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 BUILDER_ZONE_BASE_H +#define BUILDER_ZONE_BASE_H + +// Project includes +#include "zone_region_editor.h" +#include "pixmap_database.h" +#include "landscape_editor_global.h" + +// NeL includes +#include +#include + +// STL includes +#include +#include + +// Qt includes +#include +#include +#include +#include +#include +#include + +namespace LandscapeEditor +{ +class LandscapeScene; + +// Data +struct ZonePosition +{ + // Absolute position + sint32 x; + sint32 y; + int region; + + ZonePosition() + { + x = 0xffffffff; + y = 0xffffffff; + region = -1; + } + + ZonePosition(const sint32 posX, const sint32 posY, const int id) + { + x = posX; + y = posY; + region = id; + } +}; + +/** +@class ZoneBuilder +@brief ZoneBuilder contains all the shared data between the tools and the engine. +@details ZoneBank contains the macro zones that is composed of several zones plus a mask. +PixmapDatabase contains the graphics for the zones +*/ +class LANDSCAPE_EDITOR_EXPORT ZoneBuilderBase +{ +public: + ZoneBuilderBase(LandscapeScene *landscapeScene); + virtual ~ZoneBuilderBase(); + + /// Init zoneBank and init zone pixmap database + bool init(const QString &pathName, bool displayProgress = false); + + void calcMask(); + bool getZoneMask (sint32 x, sint32 y); + + /// Zone Region + /// @{ + int createZoneRegion(); + int createZoneRegion(const QString &fileName); + void deleteZoneRegion(int id); + void setCurrentZoneRegion(int id); + int currentIdZoneRegion() const; + ZoneRegionObject *currentZoneRegion() const; + int countZoneRegion() const; + ZoneRegionObject *zoneRegion(int id) const; + void ligoData(LigoData &data, const ZonePosition &zonePos); + void setLigoData(LigoData &data, const ZonePosition &zonePos); + /// @} + + // Accessors + NLLIGO::CZoneBank &getZoneBank() + { + return m_zoneBank; + } + + PixmapDatabase *pixmapDatabase() const; + + QString dataPath() const; + +private: + + /// Scan ./zoneligos dir and add all *.ligozone files to zoneBank + bool initZoneBank (const QString &path); + + bool checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion); + + struct LandscapeItem + { + ZoneRegionObject *zoneRegionObject; + QGraphicsRectItem *rectItem; + }; + + sint32 m_minX, m_maxX, m_minY, m_maxY; + std::vector m_zoneMask; + + QString m_lastPathName; + + int m_currentZoneRegion; + QMap m_landscapeMap; + + PixmapDatabase *m_pixmapDatabase; + NLLIGO::CZoneBank m_zoneBank; + LandscapeScene *m_landscapeScene; +}; + +} /* namespace LandscapeEditor */ + +#endif // BUILDER_ZONE_BASE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h index 8a31ed15d..612eaca76 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.h @@ -38,7 +38,7 @@ namespace LandscapeEditor @brief @details */ -class LANDSCAPE_EDITOR_EXPORT LandscapeScene : public QGraphicsScene +class LandscapeScene : public QGraphicsScene { Q_OBJECT diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp new file mode 100644 index 000000000..64d2f1af9 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp @@ -0,0 +1,320 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "landscape_scene_base.h" +#include "pixmap_database.h" + +// NeL includes +#include + +// Qt includes +#include +#include +#include +#include + +namespace LandscapeEditor +{ + +static const int ZONE_NAME = 0; +static const int LAYER_ZONES = 2; +static const int LAYER_EMPTY_ZONES = 3; + +// TODO: delete +const char * const LAYER_BLACKOUT_NAME = "blackout"; + +const int MAX_SCENE_WIDTH = 256; +const int MAX_SCENE_HEIGHT = 256; + +LandscapeSceneBase::LandscapeSceneBase(int sizeCell, QObject *parent) + : QGraphicsScene(parent), + m_cellSize(sizeCell), + m_zoneBuilder(0) +{ + setSceneRect(QRectF(0, m_cellSize, MAX_SCENE_WIDTH * m_cellSize, MAX_SCENE_HEIGHT * m_cellSize)); +} + +LandscapeSceneBase::~LandscapeSceneBase() +{ +} + +int LandscapeSceneBase::cellSize() const +{ + return m_cellSize; +} + +void LandscapeSceneBase::setZoneBuilder(ZoneBuilder *zoneBuilder) +{ + m_zoneBuilder = zoneBuilder; +} + +QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const ZonePosition &zonePos) +{ + if ((data.zoneName == STRING_OUT_OF_BOUND) || (checkUnderZone(zonePos.x, zonePos.y))) + return 0; + + if (data.zoneName == STRING_UNUSED) + return createItemEmptyZone(zonePos); + + if ((m_zoneBuilder == 0) || (data.zoneName.empty())) + return 0; + + // Get image from pixmap database + QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.zoneName.c_str())); + if (pixmap == 0) + return 0; + + // Rotate the image counter clockwise + QMatrix matrix; + matrix.rotate(-data.rot * 90.0); + + QGraphicsPixmapItem *item; + + if (data.flip == 0) + { + item = addPixmap(pixmap->transformed(matrix, Qt::SmoothTransformation)); + } + else + { + // mirror image + QImage mirrorImage = pixmap->toImage(); + QPixmap mirrorPixmap = QPixmap::fromImage(mirrorImage.mirrored(true, false)); + item = addPixmap(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation)); + } + // Enable bilinear filtering + item->setTransformationMode(Qt::SmoothTransformation); + + NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName); + + sint32 deltaX = 0, deltaY = 0; + + // Calculate offset for graphics item (for items with size that are larger than 1) + if ((zoneBankItem->getSizeX() > 1) || (zoneBankItem->getSizeY() > 1)) + { + sint32 sizeX = zoneBankItem->getSizeX(), sizeY = zoneBankItem->getSizeY(); + if (data.flip == 0) + { + switch (data.rot) + { + case 0: + deltaX = -data.posX; + deltaY = -data.posY + sizeY - 1; + break; + case 1: + deltaX = -(sizeY - 1 - data.posY); + deltaY = -data.posX + sizeX - 1; + break; + case 2: + deltaX = -(sizeX - 1 - data.posX); + deltaY = data.posY; + break; + case 3: + deltaX = -data.posY; + deltaY = data.posX; + break; + } + } + else + { + switch (data.rot) + { + case 0: + deltaX = -(sizeX - 1 - data.posX); + deltaY = -data.posY + sizeY - 1; + break; + case 1: + deltaX = -(sizeY - 1 - data.posY); + deltaY = +data.posX; + break; + case 2: + deltaX = -data.posX; + deltaY = data.posY; + break; + case 3: + deltaX = -data.posY; + deltaY = -data.posX + sizeX - 1; + break; + } + } + } + + // Set position graphics item with offset for large piece + item->setPos((zonePos.x + deltaX) * m_cellSize, (abs(int(zonePos.y + deltaY))) * m_cellSize); + + // The size graphics item should be equal or proportional m_cellSize + item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); + + item->setData(ZONE_NAME, QString(data.zoneName.c_str())); + + // for not full item zone + item->setZValue(LAYER_ZONES); + + return item; +} + +QGraphicsItem *LandscapeSceneBase::createItemEmptyZone(const ZonePosition &zonePos) +{ + if (m_zoneBuilder == 0) + return 0; + + if (checkUnderZone(zonePos.x, zonePos.y)) + return 0; + + // Get image from pixmap database + QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED)); + if (pixmap == 0) + return 0; + + QGraphicsPixmapItem *item = addPixmap(*pixmap); + + // Enable bilinear filtering + item->setTransformationMode(Qt::SmoothTransformation); + + // Set position graphics item + item->setPos(zonePos.x * m_cellSize, abs(int(zonePos.y)) * m_cellSize); + + // The size graphics item should be equal or proportional m_cellSize + item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); + + // for not full item zone + item->setZValue(LAYER_EMPTY_ZONES); + + return item; +} + +void LandscapeSceneBase::deleteItemZone(const ZonePosition &zonePos) +{ + QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize); + + // TODO: delete LAYER_BLACKOUT_NAME + if ((item != 0) && (item->data(ZONE_NAME).toString() != QString(LAYER_BLACKOUT_NAME))) + { + removeItem(item); + delete item; + } +} + +void LandscapeSceneBase::addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) +{ + for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) + { + for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) + { + + std::string zoneName = zoneRegion.getName(i, j); + if (zoneName == STRING_UNUSED) + { + ZonePosition zonePos(i, j, -1); + QGraphicsItem *item = createItemEmptyZone(zonePos); + } + else if (!zoneName.empty()) + { + LigoData data; + ZonePosition zonePos(i, j, -1); + data.zoneName = zoneName; + data.rot = zoneRegion.getRot(i, j); + data.flip = zoneRegion.getFlip(i, j); + data.posX = zoneRegion.getPosX(i, j); + data.posY = zoneRegion.getPosY(i, j); + QGraphicsItem *item = createItemZone(data, zonePos); + } + } + } +} + +void LandscapeSceneBase::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) +{ + for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) + { + for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) + { + deleteItemZone(ZonePosition(i, -j, -1)); + } + } +} + +void LandscapeSceneBase::snapshot(const QString &fileName, int width, int height, const QRectF &landRect) +{ + if (m_zoneBuilder == 0) + return; + + // Create image + QImage image(landRect.width(), landRect.height(), QImage::Format_RGB888); + QPainter painter(&image); + painter.setRenderHint(QPainter::Antialiasing, true); + + // Add white background + painter.setBrush(QBrush(Qt::white)); + painter.setPen(Qt::NoPen); + painter.drawRect(0, 0, landRect.width(), landRect.height()); + + // Paint landscape + render(&painter, QRectF(0, 0, landRect.width(), landRect.height()), landRect); + + QImage scaledImage = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + scaledImage.save(fileName); +} + +QString LandscapeSceneBase::zoneNameFromMousePos() const +{ + if ((m_posY > 0) || (m_posY < -MAX_SCENE_HEIGHT) || + (m_posX < 0) || (m_posX > MAX_SCENE_WIDTH)) + return "NOT A VALID ZONE"; + + return QString("%1_%2%3 %4 %5 ").arg(-m_posY).arg(QChar('A' + (m_posX/26))). + arg(QChar('A' + (m_posX%26))).arg(m_mouseX, 0,'f',2).arg(-m_mouseY, 0,'f',2); +} + +void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + QGraphicsScene::mousePressEvent(mouseEvent); + + qreal x = mouseEvent->scenePos().x(); + qreal y = mouseEvent->scenePos().y(); + m_posX = sint32(floor(x / m_cellSize)); + m_posY = sint32(-floor(y / m_cellSize)); + + m_mouseButton = mouseEvent->button(); +} + +void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) +{ + m_mouseX = mouseEvent->scenePos().x(); + m_mouseY = mouseEvent->scenePos().y() - m_cellSize; + + m_posX = sint32(floor(m_mouseX / m_cellSize)); + m_posY = sint32(-floor(m_mouseY / m_cellSize)); + + QGraphicsScene::mouseMoveEvent(mouseEvent); +} + +void LandscapeSceneBase::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + QGraphicsScene::mouseReleaseEvent(mouseEvent); + m_mouseButton = Qt::NoButton; +} + +bool LandscapeSceneBase::checkUnderZone(const int posX, const int posY) +{ + // TODO: it will not work correctly in world editor + QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize); + if (item != 0) + return true; + return false; +} + +} /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h new file mode 100644 index 000000000..45d4d13bf --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h @@ -0,0 +1,81 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef LANDSCAPE_SCENE_BASE_H +#define LANDSCAPE_SCENE_BASE_H + +// Project includes +#include "zone_region_editor.h" +#include "builder_zone.h" +#include "landscape_editor_global.h" + +// NeL includes +#include + +// Qt includes +#include +#include + +namespace LandscapeEditor +{ + +/** +@class LandscapeSceneBase +@brief +@details +*/ +class LANDSCAPE_EDITOR_EXPORT LandscapeSceneBase : public QGraphicsScene +{ + Q_OBJECT + +public: + LandscapeSceneBase(int sizeCell = 160, QObject *parent = 0); + virtual ~LandscapeSceneBase(); + + int cellSize() const; + virtual void setZoneBuilder(ZoneBuilder *zoneBuilder); + + QGraphicsItem *createItemZone(const LigoData &data, const ZonePosition &zonePos); + QGraphicsItem *createItemEmptyZone(const ZonePosition &zonePos); + void deleteItemZone(const ZonePosition &zonePos); + + void addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); + void delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion); + + void snapshot(const QString &fileName, int width, int height, const QRectF &landRect); + + QString zoneNameFromMousePos() const; + +public Q_SLOTS: + +protected: + virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); + +private: + bool checkUnderZone(const int posX, const int posY); + + int m_cellSize; + qreal m_mouseX, m_mouseY; + sint32 m_posX, m_posY; + Qt::MouseButton m_mouseButton; + ZoneBuilder *m_zoneBuilder; +}; + +} /* namespace LandscapeEditor */ + +#endif // LANDSCAPE_SCENE_BASE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h index abb93ab81..e6b2b950a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h @@ -20,13 +20,14 @@ // Project includes #include "ui_project_settings_dialog.h" +#include "landscape_editor_global.h" // Qt includes namespace LandscapeEditor { -class ProjectSettingsDialog: public QDialog +class LANDSCAPE_EDITOR_EXPORT ProjectSettingsDialog: public QDialog { Q_OBJECT From 106633c46a3a1abde855772e89512b20453f76ec Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 27 Jul 2011 19:04:46 +0300 Subject: [PATCH 031/747] Changed: #1302 Added operations creating and deleting primitives without undo/redo. --- .../src/plugins/world_editor/CMakeLists.txt | 1 + .../plugins/world_editor/primitive_item.cpp | 40 +- .../src/plugins/world_editor/primitive_item.h | 13 +- .../plugins/world_editor/primitives_model.cpp | 135 ++++- .../plugins/world_editor/primitives_model.h | 28 +- .../plugins/world_editor/primitives_view.cpp | 197 +++++++ .../plugins/world_editor/primitives_view.h | 74 +++ .../world_editor/world_editor_misc.cpp | 494 ++++++++++++++++++ .../plugins/world_editor/world_editor_misc.h | 55 ++ .../world_editor/world_editor_window.cpp | 28 +- .../world_editor/world_editor_window.h | 2 + .../world_editor/world_editor_window.ui | 23 +- 12 files changed, 1051 insertions(+), 39 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt index c8b034444..8b51838d7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt @@ -12,6 +12,7 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h world_editor_window.h primitives_model.h + primitives_view.h ) SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index 9ec95bdaa..300a30631 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -16,9 +16,14 @@ // Project includes #include "primitive_item.h" +#include "world_editor_misc.h" + +// NeL includes +#include // Qt includes -#include +#include +#include namespace WorldEditor { @@ -45,6 +50,11 @@ void BaseTreeItem::appendChild(BaseTreeItem *item) m_childItems.append(item); } +void BaseTreeItem::deleteChild(int row) +{ + delete m_childItems.takeAt(row); +} + BaseTreeItem *BaseTreeItem::child(int row) { return m_childItems.value(row); @@ -104,12 +114,13 @@ PrimitiveItem::PrimitiveItem(NLLIGO::IPrimitive *primitive, BaseTreeItem *parent m_primitive->getPropertyByName("class", className); // Set Icon - QIcon icon(QString("./old_ico/%1.ico").arg(className.c_str())); - if (primitive->getParent() == NULL) - icon = QIcon("./old_ico/root.ico"); - if (icon.isNull()) + QString nameIcon = QString("./old_ico/%1.ico").arg(className.c_str()); + QIcon icon(nameIcon); + if (!QFile::exists(nameIcon)) { - if (primitive->getNumChildren() == 0) + if (primitive->getParent() == NULL) + icon = QIcon("./old_ico/root.ico"); + else if (primitive->getNumChildren() == 0) icon = QIcon("./old_ico/property.ico"); else icon = QIcon("./old_ico/folder_h.ico"); @@ -127,18 +138,29 @@ PrimitiveItem::~PrimitiveItem() { } -PrimitivesItem::PrimitivesItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent) +NLLIGO::IPrimitive *PrimitiveItem::primitive() const +{ + return m_primitive; +} + +const NLLIGO::CPrimitiveClass *PrimitiveItem::primitiveClass() const +{ + return NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*m_primitive); +} + + +RootPrimitiveItem::RootPrimitiveItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent) : PrimitiveItem(primitives->RootNode, parent), m_primitives(primitives) { setData(1, name); } /* -PrimitivesItem::PrimitivesItem(const PrimitiveItem &other) +RootPrimitiveItem::RootPrimitiveItem(const RootPrimitiveItem &other) { } */ -PrimitivesItem::~PrimitivesItem() +RootPrimitiveItem::~RootPrimitiveItem() { } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 26ca70670..5d00e6c92 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -21,6 +21,7 @@ // NeL includes #include +#include // Qt includes #include @@ -43,6 +44,7 @@ public: virtual ~BaseTreeItem(); void appendChild(BaseTreeItem *child); + void deleteChild(int row); BaseTreeItem *child(int row); int childCount() const; @@ -74,6 +76,9 @@ public: PrimitiveItem(const PrimitiveItem &other); virtual ~PrimitiveItem(); + NLLIGO::IPrimitive *primitive() const; + const NLLIGO::CPrimitiveClass *primitiveClass() const; + private: NLLIGO::IPrimitive *m_primitive; }; @@ -83,12 +88,12 @@ private: @brief @details */ -class PrimitivesItem: public PrimitiveItem +class RootPrimitiveItem: public PrimitiveItem { public: - PrimitivesItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent); - PrimitivesItem(const PrimitiveItem &other); - virtual ~PrimitivesItem(); + RootPrimitiveItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent); + RootPrimitiveItem(const RootPrimitiveItem &other); + virtual ~RootPrimitiveItem(); private: NLLIGO::CPrimitives *m_primitives; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp index 8c5af6229..7a41822ab 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp @@ -14,14 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include -#include -#include - -#include - +// Project includes #include "primitive_item.h" #include "primitives_model.h" +#include "world_editor_misc.h" + +// NeL includes +#include +#include +#include + +// Qt includes +#include namespace WorldEditor { @@ -136,11 +140,77 @@ int PrimitivesTreeModel::rowCount(const QModelIndex &parent) const return parentItem->childCount(); } -void PrimitivesTreeModel::addPrimitives(const QString &name, NLLIGO::CPrimitives *primitives) +NLLIGO::IPrimitive *PrimitivesTreeModel::primitive(const QModelIndex &index) +{ + NLLIGO::IPrimitive *prim = 0; + if (index.isValid()) + { + PrimitiveItem *item = static_cast(index.internalPointer()); + prim = item->primitive(); + } + return prim; +} + +const NLLIGO::CPrimitiveClass *PrimitivesTreeModel::primitiveClass(const QModelIndex &index) +{ + if (index.isValid()) + { + NLLIGO::IPrimitive *prim = primitive(index); + return ligoConfig()->getPrimitiveClass(*prim); + } + return 0; +} + +void PrimitivesTreeModel::loadPrimitive(const QString &fileName) +{ + NLLIGO::CPrimitives *primitives = new NLLIGO::CPrimitives(); + + // set the primitive context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = primitives; + + NLLIGO::loadXmlPrimitiveFile(*primitives, fileName.toStdString(), *NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); + + // unset the context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL; + + addRootPrimitive(fileName, primitives); +} + +void PrimitivesTreeModel::newPrimitiveWithoutUndo(const QString &className, uint id, const QModelIndex &parent) +{ + const NLLIGO::CPrimitiveClass *primClass = primitiveClass(parent); + float delta = 10; + + // TODO: Set the context + //CPrimitiveContext::instance().CurrentPrimitive = &_DataHierarchy[locator._LocateStack[0]].Primitives; + + NLLIGO::IPrimitive *newPrimitive = createPrimitive(className.toStdString().c_str(), className.toStdString().c_str() + , NLMISC::CVector(), delta, primClass->DynamicChildren[id].Parameters, primitive(parent)); + + // unset the context + //CPrimitiveContext::instance().CurrentPrimitive = NULL; + + if (newPrimitive != 0) + { + scanPrimitive(newPrimitive, parent); + } +} + +void PrimitivesTreeModel::deletePrimitiveWithoutUndo(const QModelIndex &index) +{ + deletePrimitive(primitive(index)); + removeRows(index.row(), index.parent()); +} + +void PrimitivesTreeModel::addRootPrimitive(const QString &name, NLLIGO::CPrimitives *primitives) { beginResetModel(); - PrimitivesItem *newPrimitives = new PrimitivesItem(name, primitives, m_rootItem); + + // Create root primitive + RootPrimitiveItem *newPrimitives = new RootPrimitiveItem(name, primitives, m_rootItem); m_rootItem->appendChild(newPrimitives); + + // Scan childs items and add in tree model for (uint i = 0; i < primitives->RootNode->getNumChildren(); ++i) { NLLIGO::IPrimitive *childPrim; @@ -150,17 +220,33 @@ void PrimitivesTreeModel::addPrimitives(const QString &name, NLLIGO::CPrimitives endResetModel(); } -void PrimitivesTreeModel::scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem *parent) +void PrimitivesTreeModel::scanPrimitive(NLLIGO::IPrimitive *prim, const QModelIndex &parentIndex) { -// const NLLIGO::CPrimitiveClass *primClass = NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*prim); -// nlassert (primClass); -// if (primClass->Type == NLLIGO::CPrimitiveClass::Alias) -// return; - if (prim->getClassName() == "CPrimAlias") - return; + PrimitiveItem *parent = static_cast(parentIndex.internalPointer()); + // Add in tree model + beginInsertRows(parentIndex, parent->childCount(), parent->childCount()); PrimitiveItem *newItem = new PrimitiveItem(prim, parent); parent->appendChild(newItem); + endInsertRows(); + + // Scan childs items and add in tree model + QModelIndex childIndex = index(parent->childCount() - 1, 0, parentIndex); + for (uint i = 0; i < prim->getNumChildren(); ++i) + { + NLLIGO::IPrimitive *childPrim; + prim->getChild(childPrim, i); + scanPrimitive(childPrim, childIndex); + } +} + +void PrimitivesTreeModel::scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem *parent) +{ + // Add in tree model + PrimitiveItem *newItem = new PrimitiveItem(prim, parent); + parent->appendChild(newItem); + + // Scan childs items and add in tree model for (uint i = 0; i < prim->getNumChildren(); ++i) { NLLIGO::IPrimitive *childPrim; @@ -169,4 +255,23 @@ void PrimitivesTreeModel::scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem * } } +void PrimitivesTreeModel::removeRows(int position, const QModelIndex &parent) +{ + BaseTreeItem *item = static_cast(parent.internalPointer())->child(position); + + // Delete all child items from tree model + while (item->childCount() != 0) + removeRows(0, parent.child(position, 0)); + + // Delete item + beginRemoveRows(parent, position, position); + static_cast(parent.internalPointer())->deleteChild(position); + endRemoveRows(); +} + +NLLIGO::CLigoConfig *PrimitivesTreeModel::ligoConfig() const +{ + return NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig; +} + } /* namespace WorldEditor */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h index 5098d1e5e..ab4581a30 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h @@ -18,8 +18,13 @@ #ifndef PRIMITIVES_MODEL_H #define PRIMITIVES_MODEL_H +// NeL includes +#include #include +#include +#include +// Qt includes #include #include #include @@ -28,6 +33,7 @@ namespace WorldEditor { class BaseTreeItem; +class PrimitiveItem; /** @class PrimitivesTreeModel @@ -52,11 +58,31 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; - void addPrimitives(const QString &name, NLLIGO::CPrimitives *primitives); + // Get primitive + NLLIGO::IPrimitive *primitive(const QModelIndex &index); + + // Get primitive class + const NLLIGO::CPrimitiveClass *primitiveClass(const QModelIndex &index); + + // Load primitive from file + void loadPrimitive(const QString &fileName); + + // Create new primitive and add in tree model + void newPrimitiveWithoutUndo(const QString &className, uint id, const QModelIndex &parent); + + void deletePrimitiveWithoutUndo(const QModelIndex &index); + + NLLIGO::CLigoConfig *ligoConfig() const; private: + // Add root primitive in tree model and add all its sub-items. + void addRootPrimitive(const QString &name, NLLIGO::CPrimitives *primitives); + + void scanPrimitive(NLLIGO::IPrimitive *prim, const QModelIndex &parentIndex); void scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem *parent = 0); + void removeRows(int position, const QModelIndex &parent); + BaseTreeItem *m_rootItem; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp new file mode 100644 index 000000000..2b36c7446 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -0,0 +1,197 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "primitives_view.h" +//#include "primitive_item.h" +#include "primitives_model.h" + +// NeL includes +#include +#include +#include + +// Qt includes +#include +#include + +namespace WorldEditor +{ + +PrimitivesView::PrimitivesView(QWidget *parent) + : QTreeView(parent), + m_primitivesTreeModel(0) +{ + setContextMenuPolicy(Qt::DefaultContextMenu); + + m_deleteAction = new QAction("Delete", this); + m_selectChildrenAction = new QAction("Select children", this); + m_helpAction = new QAction("Help", this); + m_showAction = new QAction("Show", this); + m_hideAction = new QAction("Hide", this); + + connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deletePrimitives())); + + connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(clickedItem(QModelIndex))); + +#ifdef Q_OS_DARWIN + setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); +#endif +} + +PrimitivesView::~PrimitivesView() +{ +} + +void PrimitivesView::setModel(PrimitivesTreeModel *model) +{ + QTreeView::setModel(model); + m_primitivesTreeModel = model; +} + +void PrimitivesView::clickedItem(const QModelIndex &index) +{ +} + +void PrimitivesView::deletePrimitives() +{ + QModelIndexList indexList = selectionModel()->selectedRows(); + + // TODO: use QPersistentModelIndex for deleting several items + m_primitivesTreeModel->deletePrimitiveWithoutUndo(indexList.first()); +} + +void PrimitivesView::addNewPrimitive(int value) +{ + QModelIndexList indexList = selectionModel()->selectedRows(); + + const NLLIGO::CPrimitiveClass *primClass = m_primitivesTreeModel->primitiveClass(indexList.first()); + + // Get class name + QString className = primClass->DynamicChildren[value].ClassName.c_str(); + + m_primitivesTreeModel->newPrimitiveWithoutUndo(className, value, indexList.first()); +} + +void PrimitivesView::generatePrimitives(int value) +{ +} + +void PrimitivesView::openItem(int value) +{ +} + +void PrimitivesView::contextMenuEvent(QContextMenuEvent *event) +{ + QWidget::contextMenuEvent(event); + QModelIndexList indexList = selectionModel()->selectedRows(); + if (indexList.size() == 0) + return; + + QMenu *popurMenu = new QMenu(this); + popurMenu->addAction(m_deleteAction); + popurMenu->addAction(m_selectChildrenAction); + popurMenu->addAction(m_helpAction); + popurMenu->addSeparator(); + popurMenu->addAction(m_showAction); + popurMenu->addAction(m_hideAction); + popurMenu->addSeparator(); + + QSignalMapper *addSignalMapper = new QSignalMapper(this); + QSignalMapper *generateSignalMapper = new QSignalMapper(this); + QSignalMapper *openSignalMapper = new QSignalMapper(this); + connect(addSignalMapper, SIGNAL(mapped(int)), this, SLOT(addNewPrimitive(int))); + connect(generateSignalMapper, SIGNAL(mapped(int)), this, SLOT(generatePrimitives(int))); + //connect(openSignalMapper, SIGNAL(mapped(int)), this, SLOT(openItem(int))); + + if (indexList.size() == 1) + { + const NLLIGO::CPrimitiveClass *primClass = m_primitivesTreeModel->primitiveClass(indexList.first()); + + // What class is it ? + if (primClass && primClass->DynamicChildren.size()) + { + popurMenu->addSeparator(); + + // For each child, add a create method + for (size_t i = 0; i < primClass->DynamicChildren.size(); i++) + { + // Get class name + QString className = primClass->DynamicChildren[i].ClassName.c_str(); + + // Get icon + QIcon icon(QString("./old_ico/%1.ico").arg(className)); + + // Create and add action in popur menu + QAction *action = popurMenu->addAction(icon, QString("Add %1").arg(className)); + addSignalMapper->setMapping(action, i); + connect(action, SIGNAL(triggered()), addSignalMapper, SLOT(map())); + } + } + + // What class is it ? + if (primClass && primClass->GeneratedChildren.size()) + { + popurMenu->addSeparator(); + + // For each child, add a create method + for (size_t i = 0; i < primClass->GeneratedChildren.size(); i++) + { + // Get class name + QString childName = primClass->GeneratedChildren[i].ClassName.c_str(); + + // Create and add action in popur menu + QAction *action = popurMenu->addAction(QString("Generate %1").arg(childName)); + generateSignalMapper->setMapping(action, i); + connect(generateSignalMapper, SIGNAL(triggered()), addSignalMapper, SLOT(map())); + } + } + /* + // What class is it ? + if (primClass) + { + // Look for files + std::vector filenames; + + // Filenames + buildFilenameVector (*Selection.front (), filenames); + + // File names ? + if (!filenames.empty ()) + { + // Add separator + popurMenu->addSeparator(); + + // Found ? + for (uint i = 0; i < filenames.size(); i++) + { + // Add a menu entry + pMenu->AppendMenu (MF_STRING, ID_EDIT_OPEN_FILE_BEGIN+i, ("Open "+NLMISC::CFile::getFilename (filenames[i])).c_str ()); + } + } + } + */ + } + + popurMenu->exec(event->globalPos()); + delete popurMenu; + delete addSignalMapper; + delete generateSignalMapper; + delete openSignalMapper; + event->accept(); +} + +} /* namespace WorldEditor */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h new file mode 100644 index 000000000..0cfbe0318 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h @@ -0,0 +1,74 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef PRIMITIVES_VIEW_H +#define PRIMITIVES_VIEW_H + +// NeL includes +#include + +// Qt includes +#include +#include +#include +#include +#include +#include + +namespace WorldEditor +{ + +class BaseTreeItem; +class PrimitivesTreeModel; + +/** +@class PrimitivesView +@brief +@details +*/ +class PrimitivesView : public QTreeView +{ + Q_OBJECT + +public: + PrimitivesView(QWidget *parent = 0); + ~PrimitivesView(); + + virtual void setModel(PrimitivesTreeModel *model); + +private Q_SLOTS: + void clickedItem(const QModelIndex &index); + void deletePrimitives(); + void addNewPrimitive(int value); + void generatePrimitives(int value); + void openItem(int value); + +protected: + void contextMenuEvent(QContextMenuEvent *event); + + QAction *m_deleteAction; + QAction *m_selectChildrenAction; + QAction *m_helpAction; + QAction *m_showAction; + QAction *m_hideAction; + + PrimitivesTreeModel *m_primitivesTreeModel; +}; + +} /* namespace WorldEditor */ + +#endif // PRIMITIVES_VIEW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp new file mode 100644 index 000000000..824fe8be6 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp @@ -0,0 +1,494 @@ +// 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 "world_editor_misc.h" + +// NeL includes +#include +#include + +// Qt includes + +namespace WorldEditor +{ + +uint32 getUniqueId() +{ + // Wait 1 ms + sint64 time = NLMISC::CTime::getLocalTime (); + sint64 time2; + while ((time2 = NLMISC::CTime::getLocalTime ()) == time) + { + } + + return (uint32)time2; +} + +NLLIGO::IPrimitive *getRootPrimitive(NLLIGO::IPrimitive *primitive) +{ + nlassert(primitive); + + if (primitive->getParent() == NULL) + return primitive; + else + return getRootPrimitive(primitive->getParent()); +} + +void initPrimitiveParameters(const NLLIGO::CPrimitiveClass &primClass, NLLIGO::IPrimitive &primitive, + const std::vector &initParameters) +{ + // Other parameters + for (uint p = 0; p < initParameters.size(); ++p) + { + // The property + const NLLIGO::CPrimitiveClass::CInitParameters ¶meter = initParameters[p]; + + // Look for it in the class + uint cp; + for (cp = 0; cp < primClass.Parameters.size(); ++cp) + { + // Good one ? + if (primClass.Parameters[cp].Name == initParameters[p].Name) + break; + } + + // The primitive type + NLLIGO::CPrimitiveClass::CParameter::TType type; + + // Found ? + if (cp < primClass.Parameters.size()) + type = primClass.Parameters[cp].Type; + + // Name ? + if (initParameters[p].Name == "name") + type = NLLIGO::CPrimitiveClass::CParameter::String; + + // Continue ? + if (cp 1) + nlerror("Warning: parameter (%s) in class name (%s) has more than 1 default value (%d).", + parameter.Name.c_str(), primClass.Name.c_str(), parameter.DefaultValue.size()); + + if ((cp < primClass.Parameters.size() && !primClass.Parameters[cp].Visible) + || parameter.DefaultValue[0].GenID) + { + // Remove this property + primitive.removePropertyByName(parameter.Name.c_str()); + + // Add this property + primitive.addPropertyByName(parameter.Name.c_str(), + new NLLIGO::CPropertyString((parameter.DefaultValue[0].GenID ? NLMISC::toString(getUniqueId()) : "").c_str ())); + } + break; + } + case NLLIGO::CPrimitiveClass::CParameter::ConstStringArray: + case NLLIGO::CPrimitiveClass::CParameter::StringArray: + { + bool Visible = false; + if (cp < primClass.Parameters.size() && !primClass.Parameters[cp].Visible) + { + Visible = true; + } + for (size_t i = 0; i < parameter.DefaultValue.size(); ++i) + { + // Generate a unique id ? + if (parameter.DefaultValue[i].GenID) + { + Visible = true; + } + } + if (Visible) + { + // Remove this property + primitive.removePropertyByName (parameter.Name.c_str()); + + // Add this property + NLLIGO::CPropertyStringArray *str = new NLLIGO::CPropertyStringArray(); + str->StringArray.resize (parameter.DefaultValue.size()); + for (size_t i = 0; i < parameter.DefaultValue.size(); ++i) + { + // Generate a unique id ? + if (parameter.DefaultValue[i].GenID) + { + str->StringArray[i] = NLMISC::toString(getUniqueId()); + } + else + { + str->StringArray[i] = ""; + } + } + primitive.addPropertyByName(parameter.Name.c_str(), str); + } + break; + } + } + } + } + else + { + // Some feedback + nlerror("Warning: parameter (%s) doesn't exist in class (%s).", + initParameters[p].Name.c_str(), primClass.Name.c_str()); + } + } +} + +NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName, + const NLMISC::CVector &initPos, float deltaPos, + const std::vector &initParameters, + NLLIGO::IPrimitive *parent) +{ + // Get the prim class + const NLLIGO::CPrimitiveClass *primClass = NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(className); + if (primClass) + { + // Create the base primitive + NLLIGO::IPrimitive *primitive = NULL; + switch (primClass->Type) + { + case NLLIGO::CPrimitiveClass::Node: + primitive = new NLLIGO::CPrimNode; + break; + case NLLIGO::CPrimitiveClass::Point: + { + NLLIGO::CPrimPoint *point = new NLLIGO::CPrimPoint; + primitive = point; + point->Point.CVector::operator = (initPos); + } + break; + case NLLIGO::CPrimitiveClass::Path: + primitive = new NLLIGO::CPrimPath; + break; + case NLLIGO::CPrimitiveClass::Zone: + primitive = new NLLIGO::CPrimZone; + break; + case NLLIGO::CPrimitiveClass::Alias: + primitive = new NLLIGO::CPrimAlias; + break; + case NLLIGO::CPrimitiveClass::Bitmap: + primitive = new NLLIGO::CPrimNode; + break; + } + nlassert(primitive); + + // Add properties + primitive->addPropertyByName("class", new NLLIGO::CPropertyString(className)); + primitive->addPropertyByName("name", new NLLIGO::CPropertyString(primName, primName[0] == 0)); + + // Init with default parameters + std::vector tempParam; + tempParam.reserve(primClass->Parameters.size()); + for (size_t i = 0; i < primClass->Parameters.size(); i++) + tempParam.push_back (primClass->Parameters[i]); + initPrimitiveParameters (*primClass, *primitive, tempParam); + + // Init with option parameters + initPrimitiveParameters(*primClass, *primitive, initParameters); + + parent->insertChild(primitive); + /* + // Insert the primitive + insertPrimitive (locator, primitive); + */ + // The new pos + NLMISC::CVector newPos = initPos; + newPos.x += deltaPos; + + // Create static children + uint c; + for (c = 0; c < primClass->StaticChildren.size(); c++) + { + // The child ref + const NLLIGO::CPrimitiveClass::CChild &child = primClass->StaticChildren[c]; + + // Create the child + const NLLIGO::IPrimitive *childPrim = createPrimitive(child.ClassName.c_str(), child.Name.c_str(), + newPos, deltaPos, primClass->StaticChildren[c].Parameters, primitive); + + // The new pos + newPos.y += deltaPos; + } + + // Canceled ? + if (c < primClass->StaticChildren.size()) + { + deletePrimitive(primitive); + return NULL; + } + + // Prim file ? + if (primClass->Type == NLLIGO::CPrimitiveClass::Bitmap) + { + // Create a dialog file + //CFileDialogEx dialog (BASE_REGISTRY_KEY, "image", TRUE, primClass->FileExtension.c_str (), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, + // (primClass->FileType+" (*."+primClass->FileExtension+")|*."+primClass->FileExtension+"|All Files (*.*)|*.*||").c_str (), getMainFrame ()); + //if (dialog.DoModal() == IDOK) + //{ + // Save filename + // static_cast(primitive)->init(dialog.GetPathName ()); + //} + } + + // Continue ? + if (primitive) + { + // Auto init ? + if (!primClass->AutoInit) + { + // Make a vector of locator + //CDatabaseLocatorPointer locatorPtr; + //getLocator (locatorPtr, locator); + std::list locators; + //locators.push_back (const_cast (locatorPtr.Primitive)); + + // Yes, go + //CDialogProperties dialogProperty (locators, getMainFrame ()); + //dialogProperty.DoModal (); + } + + // Eval the default name property + std::string name; + if (!primitive->getPropertyByName ("name", name) || name.empty()) + { + const NLLIGO::CPrimitiveClass *primClass = NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*primitive); + if (primClass) + { + for (size_t i = 0; i < primClass->Parameters.size(); ++i) + { + if (primClass->Parameters[i].Name == "name") + { + std::string result; + primClass->Parameters[i].getDefaultValue(result, *primitive, *primClass, NULL); + if (!result.empty()) + { + primitive->removePropertyByName("name"); + primitive->addPropertyByName("name", new NLLIGO::CPropertyString(result.c_str(), true)); + } + } + } + } + } + + // Init primitive default values + primitive->initDefaultValues(*NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); + } + + // Done + return primitive; + } + else + { + nlerror("Unknown primitive class name : %s", className); + } + return 0; +} + +void deletePrimitive(NLLIGO::IPrimitive *primitive) +{ + // Get the parent + NLLIGO::IPrimitive *parent = primitive->getParent(); + nlassert(parent); + + // Get the child id + uint childId; + nlverify(parent->getChildId(childId, primitive)); + + // Delete the child + nlverify(parent->removeChild(childId)); +} + +bool updateDefaultValues(NLLIGO::IPrimitive *primitive) +{ + // Modified + bool modified = false; + + // Get the prim class + const NLLIGO::CPrimitiveClass *primClass = NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*primitive); + nlassert(primClass); + + if (primClass) + { + // For each parameters + for (uint i = 0; i < primClass->Parameters.size(); i++) + { + // First check the primitive property has to good type + NLLIGO::IProperty *prop; + if (primitive->getPropertyByName(primClass->Parameters[i].Name.c_str(), prop)) + { + // String to array ? + NLLIGO::CPropertyString *propString = dynamic_cast(prop); + const bool classStringArray = primClass->Parameters[i].Type == NLLIGO::CPrimitiveClass::CParameter::StringArray || + primClass->Parameters[i].Type == NLLIGO::CPrimitiveClass::CParameter::ConstStringArray; + if (propString && classStringArray) + { + // Build an array string + std::vector strings; + if (!propString->String.empty()) + strings.push_back(propString->String); + prop = new NLLIGO::CPropertyStringArray(strings); + primitive->removePropertyByName(primClass->Parameters[i].Name.c_str()); + primitive->addPropertyByName(primClass->Parameters[i].Name.c_str(), prop); + modified = true; + } + + // Array to string ? + NLLIGO::CPropertyStringArray *propStringArray = dynamic_cast(prop); + if (propStringArray && !classStringArray) + { + // Build an array string + std::string str; + if (!propStringArray->StringArray.empty()) + str = propStringArray->StringArray[0]; + prop = new NLLIGO::CPropertyString(str); + primitive->removePropertyByName(primClass->Parameters[i].Name.c_str()); + primitive->addPropertyByName(primClass->Parameters[i].Name.c_str(), prop); + modified = true; + } + } + + // String or string array ? + if (primClass->Parameters[i].Type == NLLIGO::CPrimitiveClass::CParameter::String) + { + // Default value available ? + if (!primClass->Parameters[i].DefaultValue.empty ()) + { + // Unique Id ? + if (primClass->Parameters[i].DefaultValue[0].GenID) + { + // The doesn't exist ? + std::string result; + if (!primitive->getPropertyByName(primClass->Parameters[i].Name.c_str(), result)) + { + // Add it ! + primitive->addPropertyByName(primClass->Parameters[i].Name.c_str(), new NLLIGO::CPropertyString(NLMISC::toString(getUniqueId()).c_str())); + modified = true; + } + } + // Hidden ? + else if (!primClass->Parameters[i].Visible) + { + // The doesn't exist ? + std::string result; + if (!primitive->getPropertyByName (primClass->Parameters[i].Name.c_str (), result)) + { + // Add it ! + primitive->addPropertyByName (primClass->Parameters[i].Name.c_str (), new NLLIGO::CPropertyString ("")); + modified = true; + } + } + } + } + else if ((primClass->Parameters[i].Type == NLLIGO::CPrimitiveClass::CParameter::StringArray) || + (primClass->Parameters[i].Type == NLLIGO::CPrimitiveClass::CParameter::ConstStringArray)) + { + for (uint j = 0; j < primClass->Parameters[i].DefaultValue.size(); j++) + { + // Unique Id ? + if (primClass->Parameters[i].DefaultValue[j].GenID) + { + // The doesn't exist ? + std::vector result; + std::vector *resultPtr = NULL; + if (!primitive->getPropertyByName(primClass->Parameters[i].Name.c_str(), resultPtr) || + (resultPtr->size() <= j)) + { + // Copy + if (resultPtr) + result = *resultPtr; + + // Resize + if (result.size() <= j) + result.resize(j + 1); + + // Resize to it + primitive->removePropertyByName(primClass->Parameters[i].Name.c_str()); + + // Set the value + result[j] = NLMISC::toString(getUniqueId()); + + // Add the new property array + primitive->addPropertyByName(primClass->Parameters[i].Name.c_str(), new NLLIGO::CPropertyStringArray(result)); + modified = true; + } + } + // Hidden ? + else if (!primClass->Parameters[i].Visible) + { + // The doesn't exist ? + std::vector result; + std::vector *resultPtr = NULL; + if (!primitive->getPropertyByName(primClass->Parameters[i].Name.c_str(), resultPtr) || (resultPtr->size () <= j)) + { + // Copy + if (resultPtr) + result = *resultPtr; + + // Resize + if (result.size() <= j) + result.resize(j + 1); + + // Resize to it + primitive->removePropertyByName(primClass->Parameters[i].Name.c_str()); + + // Set the value + result[j] = ""; + + // Add the new property array + primitive->addPropertyByName(primClass->Parameters[i].Name.c_str(), new NLLIGO::CPropertyStringArray(result)); + modified = true; + } + } + } + } + else + { + // Default value available ? + if (!primClass->Parameters[i].DefaultValue.empty ()) + { + // Hidden ? + if (!primClass->Parameters[i].Visible) + { + // The doesn't exist ? + std::string result; + if (!primitive->getPropertyByName(primClass->Parameters[i].Name.c_str(), result)) + { + // Add it ! + primitive->addPropertyByName(primClass->Parameters[i].Name.c_str(), new NLLIGO::CPropertyString("")); + modified = true; + } + } + } + } + } + } + return modified; +} + +} /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h new file mode 100644 index 000000000..4e75a3edf --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h @@ -0,0 +1,55 @@ +// 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 WORLD_EDITOR_MISC_H +#define WORLD_EDITOR_MISC_H + +// Project includes + +// NeL includes +#include +#include +#include + +// Qt includes + +namespace WorldEditor +{ + +// Generate unique identificator +uint32 getUniqueId(); + +// Get root primitive +NLLIGO::IPrimitive *getRootPrimitive(NLLIGO::IPrimitive *primitive); + +// Init a primitive parameters +void initPrimitiveParameters(const NLLIGO::CPrimitiveClass &primClass, NLLIGO::IPrimitive &primitive, + const std::vector &initParameters); + +NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName, + const NLMISC::CVector &initPos, float deltaPos, + const std::vector &initParameters, + NLLIGO::IPrimitive *parent); + +// Remove the primitive and don't delete it. +//void takeAtPrimitive(NLLIGO::IPrimitive *primitive); + +void deletePrimitive(NLLIGO::IPrimitive *primitive); + +} /* namespace WorldEditor */ + +#endif // WORLD_EDITOR_MISC_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 8d2c0c7f1..fc1f0e248 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -20,10 +20,14 @@ #include "world_editor_constants.h" #include "primitives_model.h" +// Core #include "../core/icore.h" #include "../core/imenu_manager.h" #include "../core/core_constants.h" +// Lanscape Editor plugin +//#include "../landscape_editor/project_settings_dialog.h" + // NeL includes #include #include @@ -55,12 +59,12 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) createMenus(); createToolBars(); -// readSettings(); + readSettings(); } WorldEditorWindow::~WorldEditorWindow() { -// writeSettings(); + writeSettings(); } QUndoStack *WorldEditorWindow::undoStack() const @@ -89,14 +93,20 @@ void WorldEditorWindow::open() void WorldEditorWindow::loadPrimitive(const QString &fileName) { - NLLIGO::CPrimitives *primitives = new NLLIGO::CPrimitives(); + m_primitivesModel->loadPrimitive(fileName); +} - // set the primitive context - NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = primitives; - - NLLIGO::loadXmlPrimitiveFile(*primitives, fileName.toStdString(), *NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); - - m_primitivesModel->addPrimitives(fileName, primitives); +void WorldEditorWindow::openProjectSettings() +{ + /* + LandscapeEditor::ProjectSettingsDialog *dialog = new LandscapeEditor::ProjectSettingsDialog("", this); + dialog->show(); + int ok = dialog->exec(); + if (ok == QDialog::Accepted) + { + } + delete dialog; + */ } void WorldEditorWindow::createMenus() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 8311ffcc6..39e741716 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -43,6 +43,8 @@ public Q_SLOTS: void open(); private Q_SLOTS: + void openProjectSettings(); + private: void createMenus(); void createToolBars(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index 6f597ca2a..179a78830 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -61,7 +61,23 @@ 3 - + + + true + + + QAbstractItemView::ExtendedSelection + + + true + + + true + + + 250 + + @@ -83,6 +99,11 @@ QGraphicsView
../landscape_editor/landscape_view.h
+ + WorldEditor::PrimitivesView + QTreeView +
primitives_view.h
+
From 3846555e85ec2c844f30c6c3fcecc73a1c57c785 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 30 Jul 2011 21:50:30 +0300 Subject: [PATCH 032/747] Changed: #1301 Updated LandscapeSceneBase and ZoneBuilderBase classes for world editor plugin. --- .../landscape_editor/builder_zone_base.cpp | 120 ++---------------- .../landscape_editor/builder_zone_base.h | 26 ++-- .../landscape_editor/landscape_scene_base.cpp | 27 ++-- .../landscape_editor/landscape_scene_base.h | 8 +- .../landscape_editor/zone_region_editor.cpp | 38 +----- .../landscape_editor/zone_region_editor.h | 38 +++++- 6 files changed, 72 insertions(+), 185 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp index a8fc40cab..eaea3d447 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp @@ -17,8 +17,9 @@ // Project includes #include "builder_zone_base.h" -#include "list_zones_widget.h" -#include "landscape_actions.h" +#include "landscape_scene_base.h" +#include "zone_region_editor.h" +#include "pixmap_database.h" // NeL includes #include @@ -32,12 +33,11 @@ namespace LandscapeEditor { int NewLandId = 0; -ZoneBuilderBase::ZoneBuilderBase(LandscapeScene *landscapeScene) - : m_currentZoneRegion(-1), - m_pixmapDatabase(0), - m_landscapeScene(landscapeScene) +ZoneBuilderBase::ZoneBuilderBase(LandscapeSceneBase *landscapeScene) + : m_pixmapDatabase(0), + m_landscapeSceneBase(landscapeScene) { - nlassert(m_landscapeScene); + nlassert(m_landscapeSceneBase); m_pixmapDatabase = new PixmapDatabase(); m_lastPathName = ""; } @@ -77,23 +77,7 @@ bool ZoneBuilderBase::init(const QString &pathName, bool displayProgress) return true; } -int ZoneBuilderBase::createZoneRegion() -{ - LandscapeItem landItem; - landItem.zoneRegionObject = new ZoneRegionObject(); -// landItem.builderZoneRegion = new BuilderZoneRegion(LandCounter); -// landItem.builderZoneRegion->init(this); - landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); - - m_landscapeMap.insert(NewLandId, landItem); - if (m_currentZoneRegion == -1) - setCurrentZoneRegion(NewLandId); - - calcMask(); - return NewLandId++; -} - -int ZoneBuilderBase::createZoneRegion(const QString &fileName) +int ZoneBuilderBase::loadZoneRegion(const QString &fileName) { LandscapeItem landItem; landItem.zoneRegionObject = new ZoneRegionObject(); @@ -107,13 +91,10 @@ int ZoneBuilderBase::createZoneRegion(const QString &fileName) // landItem.builderZoneRegion = new BuilderZoneRegion(LandCounter); // landItem.builderZoneRegion->init(this); - m_landscapeScene->addZoneRegion(landItem.zoneRegionObject->ligoZoneRegion()); - landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); + m_landscapeSceneBase->addZoneRegion(landItem.zoneRegionObject->ligoZoneRegion()); +// landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); m_landscapeMap.insert(NewLandId, landItem); - if (m_currentZoneRegion == -1) - setCurrentZoneRegion(NewLandId); - calcMask(); return NewLandId++; } @@ -122,9 +103,7 @@ void ZoneBuilderBase::deleteZoneRegion(int id) { if (m_landscapeMap.contains(id)) { - if (m_landscapeMap.value(id).rectItem != 0) - delete m_landscapeMap.value(id).rectItem; - m_landscapeScene->delZoneRegion(m_landscapeMap.value(id).zoneRegionObject->ligoZoneRegion()); + m_landscapeSceneBase->delZoneRegion(m_landscapeMap.value(id).zoneRegionObject->ligoZoneRegion()); delete m_landscapeMap.value(id).zoneRegionObject; // delete m_landscapeMap.value(id).builderZoneRegion; m_landscapeMap.remove(id); @@ -134,34 +113,6 @@ void ZoneBuilderBase::deleteZoneRegion(int id) nlwarning("Landscape (id %i) not found", id); } -void ZoneBuilderBase::setCurrentZoneRegion(int id) -{ - if (m_landscapeMap.contains(id)) - { - if (currentIdZoneRegion() != -1) - { - NLLIGO::CZoneRegion &ligoRegion = m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject->ligoZoneRegion(); - m_landscapeMap[m_currentZoneRegion].rectItem = m_landscapeScene->createLayerBlackout(ligoRegion); - } - delete m_landscapeMap.value(id).rectItem; - m_landscapeMap[id].rectItem = 0; - m_currentZoneRegion = id; - calcMask(); - } - else - nlwarning("Landscape (id %i) not found", id); -} - -int ZoneBuilderBase::currentIdZoneRegion() const -{ - return m_currentZoneRegion; -} - -ZoneRegionObject *ZoneBuilderBase::currentZoneRegion() const -{ - return m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject; -} - int ZoneBuilderBase::countZoneRegion() const { return m_landscapeMap.size(); @@ -172,16 +123,6 @@ ZoneRegionObject *ZoneBuilderBase::zoneRegion(int id) const return m_landscapeMap.value(id).zoneRegionObject; } -void ZoneBuilderBase::ligoData(LigoData &data, const ZonePosition &zonePos) -{ - m_landscapeMap.value(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y); -} - -void ZoneBuilderBase::setLigoData(LigoData &data, const ZonePosition &zonePos) -{ - m_landscapeMap.value(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y); -} - bool ZoneBuilderBase::initZoneBank (const QString &pathName) { QDir *dir = new QDir(pathName); @@ -212,23 +153,8 @@ QString ZoneBuilderBase::dataPath() const return m_lastPathName; } -bool ZoneBuilderBase::getZoneMask(sint32 x, sint32 y) -{ - if ((x < m_minX) || (x > m_maxX) || - (y < m_minY) || (y > m_maxY)) - { - return true; - } - else - { - return m_zoneMask[(x - m_minX) + (y - m_minY) * (1 + m_maxX - m_minX)]; - } -} - void ZoneBuilderBase::calcMask() { - sint32 x, y; - m_minY = m_minX = 1000000; m_maxY = m_maxX = -1000000; @@ -250,30 +176,6 @@ void ZoneBuilderBase::calcMask() if (m_maxY < region.getMaxY()) m_maxY = region.getMaxY(); } - - m_zoneMask.resize ((1 + m_maxX - m_minX) * (1 + m_maxY - m_minY)); - sint32 stride = (1 + m_maxX - m_minX); - for (y = m_minY; y <= m_maxY; ++y) - for (x = m_minX; x <= m_maxX; ++x) - { - m_zoneMask[x - m_minX + (y - m_minY) * stride] = true; - - QMapIterator it(m_landscapeMap); - while (it.hasNext()) - { - it.next(); - if (int(it.key()) != m_currentZoneRegion) - { - const NLLIGO::CZoneRegion ®ion = it.value().zoneRegionObject->ligoZoneRegion(); - - const std::string &rSZone = region.getName (x, y); - if ((rSZone != STRING_OUT_OF_BOUND) && (rSZone != STRING_UNUSED)) - { - m_zoneMask[x - m_minX + (y - m_minY) * stride] = false; - } - } - } - } } bool ZoneBuilderBase::checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h index 509181c94..249f11a73 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h @@ -19,8 +19,6 @@ #define BUILDER_ZONE_BASE_H // Project includes -#include "zone_region_editor.h" -#include "pixmap_database.h" #include "landscape_editor_global.h" // NeL includes @@ -41,7 +39,9 @@ namespace LandscapeEditor { -class LandscapeScene; +class LandscapeSceneBase; +class PixmapDatabase; +class ZoneRegionObject; // Data struct ZonePosition @@ -75,27 +75,18 @@ PixmapDatabase contains the graphics for the zones class LANDSCAPE_EDITOR_EXPORT ZoneBuilderBase { public: - ZoneBuilderBase(LandscapeScene *landscapeScene); + ZoneBuilderBase(LandscapeSceneBase *landscapeScene); virtual ~ZoneBuilderBase(); /// Init zoneBank and init zone pixmap database bool init(const QString &pathName, bool displayProgress = false); - void calcMask(); - bool getZoneMask (sint32 x, sint32 y); - /// Zone Region /// @{ - int createZoneRegion(); - int createZoneRegion(const QString &fileName); + int loadZoneRegion(const QString &fileName); void deleteZoneRegion(int id); - void setCurrentZoneRegion(int id); - int currentIdZoneRegion() const; - ZoneRegionObject *currentZoneRegion() const; int countZoneRegion() const; ZoneRegionObject *zoneRegion(int id) const; - void ligoData(LigoData &data, const ZonePosition &zonePos); - void setLigoData(LigoData &data, const ZonePosition &zonePos); /// @} // Accessors @@ -113,25 +104,24 @@ private: /// Scan ./zoneligos dir and add all *.ligozone files to zoneBank bool initZoneBank (const QString &path); + void calcMask(); + bool checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion); struct LandscapeItem { ZoneRegionObject *zoneRegionObject; - QGraphicsRectItem *rectItem; }; sint32 m_minX, m_maxX, m_minY, m_maxY; - std::vector m_zoneMask; QString m_lastPathName; - int m_currentZoneRegion; QMap m_landscapeMap; PixmapDatabase *m_pixmapDatabase; NLLIGO::CZoneBank m_zoneBank; - LandscapeScene *m_landscapeScene; + LandscapeSceneBase *m_landscapeSceneBase; }; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp index 64d2f1af9..7946fffbc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp @@ -29,13 +29,12 @@ namespace LandscapeEditor { - static const int ZONE_NAME = 0; static const int LAYER_ZONES = 2; static const int LAYER_EMPTY_ZONES = 3; // TODO: delete -const char * const LAYER_BLACKOUT_NAME = "blackout"; +const char *const LAYER_BLACKOUT_NAME = "blackout"; const int MAX_SCENE_WIDTH = 256; const int MAX_SCENE_HEIGHT = 256; @@ -43,7 +42,7 @@ const int MAX_SCENE_HEIGHT = 256; LandscapeSceneBase::LandscapeSceneBase(int sizeCell, QObject *parent) : QGraphicsScene(parent), m_cellSize(sizeCell), - m_zoneBuilder(0) + m_zoneBuilderBase(0) { setSceneRect(QRectF(0, m_cellSize, MAX_SCENE_WIDTH * m_cellSize, MAX_SCENE_HEIGHT * m_cellSize)); } @@ -57,9 +56,9 @@ int LandscapeSceneBase::cellSize() const return m_cellSize; } -void LandscapeSceneBase::setZoneBuilder(ZoneBuilder *zoneBuilder) +void LandscapeSceneBase::setZoneBuilder(ZoneBuilderBase *zoneBuilder) { - m_zoneBuilder = zoneBuilder; + m_zoneBuilderBase = zoneBuilder; } QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const ZonePosition &zonePos) @@ -70,11 +69,11 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo if (data.zoneName == STRING_UNUSED) return createItemEmptyZone(zonePos); - if ((m_zoneBuilder == 0) || (data.zoneName.empty())) + if ((m_zoneBuilderBase == 0) || (data.zoneName.empty())) return 0; // Get image from pixmap database - QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.zoneName.c_str())); + QPixmap *pixmap = m_zoneBuilderBase->pixmapDatabase()->pixmap(QString(data.zoneName.c_str())); if (pixmap == 0) return 0; @@ -98,7 +97,7 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo // Enable bilinear filtering item->setTransformationMode(Qt::SmoothTransformation); - NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName); + NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilderBase->getZoneBank().getElementByZoneName(data.zoneName); sint32 deltaX = 0, deltaY = 0; @@ -156,7 +155,7 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo item->setPos((zonePos.x + deltaX) * m_cellSize, (abs(int(zonePos.y + deltaY))) * m_cellSize); // The size graphics item should be equal or proportional m_cellSize - item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); + item->setScale(float(m_cellSize) / m_zoneBuilderBase->pixmapDatabase()->textureSize()); item->setData(ZONE_NAME, QString(data.zoneName.c_str())); @@ -168,14 +167,14 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo QGraphicsItem *LandscapeSceneBase::createItemEmptyZone(const ZonePosition &zonePos) { - if (m_zoneBuilder == 0) + if (m_zoneBuilderBase == 0) return 0; if (checkUnderZone(zonePos.x, zonePos.y)) return 0; // Get image from pixmap database - QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED)); + QPixmap *pixmap = m_zoneBuilderBase->pixmapDatabase()->pixmap(QString(STRING_UNUSED)); if (pixmap == 0) return 0; @@ -188,7 +187,7 @@ QGraphicsItem *LandscapeSceneBase::createItemEmptyZone(const ZonePosition &zoneP item->setPos(zonePos.x * m_cellSize, abs(int(zonePos.y)) * m_cellSize); // The size graphics item should be equal or proportional m_cellSize - item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize()); + item->setScale(float(m_cellSize) / m_zoneBuilderBase->pixmapDatabase()->textureSize()); // for not full item zone item->setZValue(LAYER_EMPTY_ZONES); @@ -249,7 +248,7 @@ void LandscapeSceneBase::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) void LandscapeSceneBase::snapshot(const QString &fileName, int width, int height, const QRectF &landRect) { - if (m_zoneBuilder == 0) + if (m_zoneBuilderBase == 0) return; // Create image @@ -291,7 +290,7 @@ void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) m_mouseButton = mouseEvent->button(); } -void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) +void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { m_mouseX = mouseEvent->scenePos().x(); m_mouseY = mouseEvent->scenePos().y() - m_cellSize; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h index 45d4d13bf..acfc0f9f7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h @@ -18,9 +18,9 @@ #define LANDSCAPE_SCENE_BASE_H // Project includes -#include "zone_region_editor.h" -#include "builder_zone.h" #include "landscape_editor_global.h" +#include "builder_zone_base.h" +#include "zone_region_editor.h" // NeL includes #include @@ -46,7 +46,7 @@ public: virtual ~LandscapeSceneBase(); int cellSize() const; - virtual void setZoneBuilder(ZoneBuilder *zoneBuilder); + void setZoneBuilder(ZoneBuilderBase *zoneBuilder); QGraphicsItem *createItemZone(const LigoData &data, const ZonePosition &zonePos); QGraphicsItem *createItemEmptyZone(const ZonePosition &zonePos); @@ -73,7 +73,7 @@ private: qreal m_mouseX, m_mouseY; sint32 m_posX, m_posY; Qt::MouseButton m_mouseButton; - ZoneBuilder *m_zoneBuilder; + ZoneBuilderBase *m_zoneBuilderBase; }; } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp index 399d39496..a9699acee 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp @@ -30,40 +30,6 @@ namespace LandscapeEditor { -LigoData::LigoData() -{ - posX = 0; - posY = 0; - zoneName = ""; - rot = 0; - flip = 0; - sharingMatNames[0] = ""; - sharingMatNames[1] = ""; - sharingMatNames[2] = ""; - sharingMatNames[3] = ""; - sharingCutEdges[0] = 0; - sharingCutEdges[1] = 0; - sharingCutEdges[2] = 0; - sharingCutEdges[3] = 0; -} - -bool LigoData::operator!= (const LigoData& other) const -{ - return (posX != other.posX) || - (posY != other.posY) || - (rot != other.rot) || - (flip != other.flip) || - (zoneName != other.zoneName) || - (sharingMatNames[0] != other.sharingMatNames[0]) || - (sharingMatNames[1] != other.sharingMatNames[1]) || - (sharingMatNames[2] != other.sharingMatNames[2]) || - (sharingMatNames[3] != other.sharingMatNames[3]) || - (sharingCutEdges[0] != other.sharingCutEdges[0]) || - (sharingCutEdges[1] != other.sharingCutEdges[1]) || - (sharingCutEdges[2] != other.sharingCutEdges[2]) || - (sharingCutEdges[3] != other.sharingCutEdges[3]); -} - ZoneRegionObject::ZoneRegionObject() { m_fileName = ""; @@ -92,7 +58,7 @@ bool ZoneRegionObject::load(const std::string &fileName) result = false; } } - catch (NLMISC::Exception& e) + catch (NLMISC::Exception &e) { nlwarning("Error reading file %s : %s", fileName.c_str(), e.what ()); result = false; @@ -132,7 +98,7 @@ bool ZoneRegionObject::save() result = false; } } - catch (NLMISC::Exception& e) + catch (NLMISC::Exception &e) { nlwarning("Error writing file %s : %s", m_fileName.c_str(), e.what()); result = false; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h index 9081d7002..91b2d66c1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h @@ -19,6 +19,7 @@ #define LANDSCAPE_EDITOR_H // Project includes +#include "landscape_editor_global.h" // NeL includes #include @@ -43,9 +44,38 @@ struct LigoData std::string sharingMatNames[4]; uint8 sharingCutEdges[4]; - LigoData(); - - bool operator!= (const LigoData& other) const; + LigoData() + { + posX = 0; + posY = 0; + zoneName = ""; + rot = 0; + flip = 0; + sharingMatNames[0] = ""; + sharingMatNames[1] = ""; + sharingMatNames[2] = ""; + sharingMatNames[3] = ""; + sharingCutEdges[0] = 0; + sharingCutEdges[1] = 0; + sharingCutEdges[2] = 0; + sharingCutEdges[3] = 0; + } + bool operator!= (const LigoData &other) const + { + return (posX != other.posX) || + (posY != other.posY) || + (rot != other.rot) || + (flip != other.flip) || + (zoneName != other.zoneName) || + (sharingMatNames[0] != other.sharingMatNames[0]) || + (sharingMatNames[1] != other.sharingMatNames[1]) || + (sharingMatNames[2] != other.sharingMatNames[2]) || + (sharingMatNames[3] != other.sharingMatNames[3]) || + (sharingCutEdges[0] != other.sharingCutEdges[0]) || + (sharingCutEdges[1] != other.sharingCutEdges[1]) || + (sharingCutEdges[2] != other.sharingCutEdges[2]) || + (sharingCutEdges[3] != other.sharingCutEdges[3]); + } }; /** @@ -53,7 +83,7 @@ struct LigoData @brief @details */ -class ZoneRegionObject +class LANDSCAPE_EDITOR_EXPORT ZoneRegionObject { public: ZoneRegionObject(); From 2deab30d05b861b1157df4802452a1aec87a0f64 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 30 Jul 2011 21:52:26 +0300 Subject: [PATCH 033/747] Changed: #1301 Fix typos in comments/code. --- .../landscape_editor/builder_zone_region.cpp | 7 +++---- .../landscape_editor/builder_zone_region.h | 3 +-- .../landscape_editor_constants.h | 18 +++++++++--------- .../landscape_editor/landscape_scene.cpp | 4 ++-- .../landscape_editor/list_zones_model.h | 2 +- .../plugins/landscape_editor/pixmap_database.h | 2 +- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp index b294ce97b..3f787e6b0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp @@ -1,6 +1,5 @@ // 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 @@ -168,12 +167,12 @@ public: return m_elements[m].y; } - BuilderZoneRegion* getBuilderZoneRegion(uint32 m) + BuilderZoneRegion *getBuilderZoneRegion(uint32 m) { return m_elements[m].builderZoneRegion; } - const std::string& getMat (uint32 m) + const std::string &getMat (uint32 m) { return m_elements[m].matPut; } @@ -804,7 +803,7 @@ void BuilderZoneRegion::addTransition (sint32 x, sint32 y, uint8 rot, uint8 flip } } -void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion* builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2) +void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion *builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2) { const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); ToUpdate *ptCreate = reinterpret_cast(pInt1); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h index 63656d643..6de45da50 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h @@ -1,6 +1,5 @@ // 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 @@ -70,7 +69,7 @@ private: void addTransition(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement); - void addToUpdateAndCreate(BuilderZoneRegion* builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2); + void addToUpdateAndCreate(BuilderZoneRegion *builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2); void putTransitions(sint32 x, sint32 y, const NLLIGO::SPiece &mask, const std::string &matName, void *pInternal); void updateTrans(sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement = NULL); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h index 0cdf6d3cd..76b91dad5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h @@ -22,19 +22,19 @@ namespace LandscapeEditor { namespace Constants { -const char * const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor"; +const char *const LANDSCAPE_EDITOR_PLUGIN = "LandscapeEditor"; //settings -const char * const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor"; -const char * const LANDSCAPE_WINDOW_STATE = "LandscapeWindowState"; -const char * const LANDSCAPE_WINDOW_GEOMETRY = "LandscapeWindowGeometry"; -const char * const LANDSCAPE_DATA_DIRECTORY = "LandscapeDataDirectory"; -const char * const LANDSCAPE_USE_OPENGL = "LandscapeUseOpenGL"; +const char *const LANDSCAPE_EDITOR_SECTION = "LandscapeEditor"; +const char *const LANDSCAPE_WINDOW_STATE = "LandscapeWindowState"; +const char *const LANDSCAPE_WINDOW_GEOMETRY = "LandscapeWindowGeometry"; +const char *const LANDSCAPE_DATA_DIRECTORY = "LandscapeDataDirectory"; +const char *const LANDSCAPE_USE_OPENGL = "LandscapeUseOpenGL"; //resources -const char * const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png"; -const char * const ICON_ZONE_ITEM = ":/icons/ic_nel_zone.png"; -const char * const ICON_LANDSCAPE_ZONES = ":/icons/ic_nel_zones.png"; +const char *const ICON_LANDSCAPE_ITEM = ":/icons/ic_nel_landscape_item.png"; +const char *const ICON_ZONE_ITEM = ":/icons/ic_nel_zone.png"; +const char *const ICON_LANDSCAPE_ZONES = ":/icons/ic_nel_zones.png"; } // namespace Constants diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index 67485158d..bdbe54f8c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -35,7 +35,7 @@ static const int ZONE_NAME = 0; static const int LAYER_ZONES = 2; static const int LAYER_EMPTY_ZONES = 3; static const int LAYER_BLACKOUT = 4; -const char * const LAYER_BLACKOUT_NAME = "blackout"; +const char *const LAYER_BLACKOUT_NAME = "blackout"; const int MAX_SCENE_WIDTH = 256; const int MAX_SCENE_HEIGHT = 256; @@ -323,7 +323,7 @@ void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) QGraphicsScene::mousePressEvent(mouseEvent); } -void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) +void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { qreal x = mouseEvent->scenePos().x(); qreal y = mouseEvent->scenePos().y(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h index 475416887..6c53ab4bc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h @@ -70,7 +70,7 @@ private: QPixmap *getPixmap(const QString &zoneName) const; int m_scaleRatio; - QMap m_pixmapMap; + QMap m_pixmapMap; QStringList m_listNames; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h index fc90fe180..85b0f180e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h @@ -61,7 +61,7 @@ public: private: int m_textureSize; - QMap m_pixmapMap; + QMap m_pixmapMap; }; } /* namespace LandscapeEditor */ From 3721da574049aea0b6af1cb2f37ce879c20c8fe8 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 30 Jul 2011 21:56:21 +0300 Subject: [PATCH 034/747] Changed: #1302 Fix typos in comments/code. --- .../plugins/world_editor/primitives_view.cpp | 6 ------ .../src/plugins/world_editor/primitives_view.h | 1 - .../world_editor/world_editor_constants.h | 18 +++++++++--------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index 2b36c7446..0cc4e5e52 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -45,8 +45,6 @@ PrimitivesView::PrimitivesView(QWidget *parent) connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deletePrimitives())); - connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(clickedItem(QModelIndex))); - #ifdef Q_OS_DARWIN setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); #endif @@ -62,10 +60,6 @@ void PrimitivesView::setModel(PrimitivesTreeModel *model) m_primitivesTreeModel = model; } -void PrimitivesView::clickedItem(const QModelIndex &index) -{ -} - void PrimitivesView::deletePrimitives() { QModelIndexList indexList = selectionModel()->selectedRows(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h index 0cfbe0318..b0381b5bf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h @@ -51,7 +51,6 @@ public: virtual void setModel(PrimitivesTreeModel *model); private Q_SLOTS: - void clickedItem(const QModelIndex &index); void deletePrimitives(); void addNewPrimitive(int value); void generatePrimitives(int value); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index a54b82cb1..cb1abf21e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -22,19 +22,19 @@ namespace WorldEditor { namespace Constants { -const char * const WORLD_EDITOR_PLUGIN = "WorldEditor"; +const char *const WORLD_EDITOR_PLUGIN = "WorldEditor"; //settings -const char * const WORLD_EDITOR_SECTION = "WorldEditor"; -const char * const WORLD_WINDOW_STATE = "WorldWindowState"; -const char * const WORLD_WINDOW_GEOMETRY = "WorldWindowGeometry"; -const char * const WORLD_EDITOR_CELL_SIZE = "WorldEditorCellSize"; -const char * const WORLD_EDITOR_SNAP = "WorldEditorSnap"; -const char * const ZONE_SNAPSHOT_RES = "WorldEditorZoneSnapshotRes"; -const char * const PRIMITIVE_CLASS_FILENAME = "WorldEditorPrimitiveClassFilename"; +const char *const WORLD_EDITOR_SECTION = "WorldEditor"; +const char *const WORLD_WINDOW_STATE = "WorldWindowState"; +const char *const WORLD_WINDOW_GEOMETRY = "WorldWindowGeometry"; +const char *const WORLD_EDITOR_CELL_SIZE = "WorldEditorCellSize"; +const char *const WORLD_EDITOR_SNAP = "WorldEditorSnap"; +const char *const ZONE_SNAPSHOT_RES = "WorldEditorZoneSnapshotRes"; +const char *const PRIMITIVE_CLASS_FILENAME = "WorldEditorPrimitiveClassFilename"; //resources -const char * const ICON_WORLD_EDITOR = ":/icons/ic_nel_world_editor.png"; +const char *const ICON_WORLD_EDITOR = ":/icons/ic_nel_world_editor.png"; } // namespace Constants From a02ddb236989cc80a8207e94af74dff4ebae21aa Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 30 Jul 2011 21:58:48 +0300 Subject: [PATCH 035/747] Changed: #1302 Added world edit mode toolbar. --- .../world_editor/icons/ic_nel_move.png | Bin 0 -> 3170 bytes .../world_editor/icons/ic_nel_rotate.png | Bin 0 -> 4089 bytes .../world_editor/icons/ic_nel_scale.png | Bin 0 -> 4299 bytes .../world_editor/icons/ic_nel_select.png | Bin 0 -> 3182 bytes .../world_editor/icons/ic_nel_turn.png | Bin 0 -> 2747 bytes .../src/plugins/world_editor/world_editor.qrc | 5 + .../world_editor/world_editor_window.cpp | 28 +++ .../world_editor/world_editor_window.h | 2 + .../world_editor/world_editor_window.ui | 187 +++++++++++++++++- 9 files changed, 220 insertions(+), 2 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_move.png create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_rotate.png create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_scale.png create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_select.png create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_turn.png diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_move.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_move.png new file mode 100644 index 0000000000000000000000000000000000000000..7039bd070067c121c446c52b291dd1b0a30901e4 GIT binary patch literal 3170 zcmV-o44w0dP)<{98FWQhbW?9;ba!ELWdKlNX>N2bPDNB8 zb~7$DE;i7Ety%y83*SjZK~#8N?OSPVRM!;-LIMSh?HS{J_I*5KkC(9xUd9{V7i?pL zF&NC65S9`W))0b|I6xo^OA-qn=UV^liZyDFV^9|RabCPIwWqR~3r_+*>sKuJTJzqq!gPpz|c#U`8ne?ZWu=Pt}C zs}-8G9AWboi=x_=b8!Yo*;pAQtn1D&rDe4&x&N%r?G-A$U5>np2H`EM{Y$LYVhXD; z;a)68Yf;avYWlFEWr2t@Iz_zMCDaCo{9Mt}DFDi^r)u<*!!1`>)|;Mcy2t3rKQV8` zT9N9^63aGh6}z5$Ni=jW6YvU=>c|px9o>Gl!QMMH-Y_97LWOe?mBGHGu48F`M$v3h z)wW3NfAvi{_Pz3k=vcL0Bv{c@B97op6Gw3($My|7|Hc?E>PtHK8Y zuOv#zcF&I@L5~s30IpxHNz3l{R@4UtK(V|6fX!PZ;{m=OAMxUm@FJMq1Sqiv9`G%d z8f<+MpuwJC$jB4EhPKa;7B|Oet%;GKM@TYEiq{f^F1Yjsra(nuc!tdXrp%ew#0Id$ z^KkuHAuSqdFHefsOn~C6b1U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/src/plugins/world_editor/icons/ic_nel_rotate.png new file mode 100644 index 0000000000000000000000000000000000000000..73a0be2fe53e26e96b41a42c442c5462de39bd95 GIT binary patch literal 4089 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGh)&Kwv)&Y=jd7JeSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+*LgRNQs01s(NL_t(|UhP^5P?T4;?u}l6ZZ_E$*_(Y4 z6a^7fc0ptl5Cue*Agzrk20_^u*+f)8A~Yt(n28zROJ>Yu@}^=I$2Tv=M3cD0Brj%W zk~m}K)nt-P>Zvc^JGa|~Bp}$`I5kyRb*u6J?>+Z?-#zEtbI<)boY{Y~49qex%fKuH zkDdXqmJyfvwLOtxb-haxyGMgnDwQ=g;iK2&5zQFWK4hI4N6 zAid-R>18h%pZA6FTLCaW;|HVv2!!F$V2C?CAzI@Ak*^uV7E(BRxgsfV4eGjj|4Q=L z>Q`euN+ad+SC?=2USg>+b5W25Bzp<)N8XTq=|1fy{cjpW#2CHg4^cglv3L%|Rx)@7 z`Cy%56WaC-(o`ym9#z*}6e(1@G$-{3u^FwpwG5&>Ct7ho$i5)pfA)avk9XRi==byK zlOg-u1IB0lAa3`7DA*jvR%VDwPDFKk_v_5nbk|%D5=K>{9ZOOZG^_4HtKaAe>3hDA zUXhc@letgS-lymEUiKLgGEM6+dea-CTzj=O_(z1Id{@h9B0;PN2-=GnRjFDcS0!q| z2be)}zz@=Q$iF88KEZPtvx;ewApOJ>;_a>w+sNR)Fc?L(^-pTAy^bS^{f*IU(lp>h z%pp1K59zz)zYhUk-S-k%0s)g<)3}NBQ!@Jx=o$Mza~I}D;|cmBk+9PpVoNDpqa#q< z(4MCwl!qTq;Nw{}h$$e6yi6b&CV!vC zsvDmPfZ?;6$S%yZhcJ@H2bn-5r#4rnHfymJ1yS1i)Qy6v*q#EaD>Xmrv(Oa6Br^yV zPB46dc8M1PAxf}?*wGr%+jnex_+`{`#Ew0ECyi;J7deq)&9oX*ti18-0gwz5a01N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Eb`2ivOWRWZx^GJ2P0=0TB3nxcGFO9pVt1klQJcO3vfI80q63CPQ1 zr@omfi%&%Wd%vlrQy~uzrJEy10#7FU?swpv`5*9~I|V^aJq&WvsZbIMVSt=`+6_Wa zR|tLSL#N142+~p^C|7{jISlTxGvK`XrDi+>&)UnMgY(=+;JkPZoL9a8=fo9oE1SU! zjZlNPN{IhU)q$>m?w6!2hp%X8`cG5ZhJ^lJ;E%mXAimWAc!z%9_$xTSx(d$m^WZ&m z8oZ-#kXch%>o^@=eof$BBQrnu&3({!!H@r?_uOYsgPT`Q=Y9G%fRY~bq@)jv_B8+V zR(`y75D9a0tGC}UBC{9KXRiE#W8l2?^@Bl81oWrR$QrmWT?KDvFZhe2AhNen?+o(% zwa*QVj_JSpI~|jstPhb8mReo)jUg*zxj2BotqI&$KGTi_vLNoupMc*!071-h%Jb>l zAX;^KYRdQdEsaWD^qkSLL_$PfZOvCkR0?O?6F(^x+yj)v{MX;6N5t8`gZsjHiXBZ5 zM$A{sVAUOu_+?n%xa%azcbicF`Vh_{@}|zt3(oYlH`^TyJiWkOy@8_pzk~CKuO=jd z`^Gi!4jiL^nN2~`MRSEl)nLDrL{xONvTuG;^`YA%lR*lLTlWvOttc=1Zf-Dr)k#-Z z0=W;k%U6P;{n^)WY{cU1uG)MIy@3KR9kfOlVf2*9M)G?f3thw;4vDf)%DpU zTj7VDh^50DyZ6TwY~8UtN3rF#qK%4ck5wqH7i_A$Qd(VevZA%SV_2n%r+!-9AU&); rv;Aiom}Ov=fmsG-8JK0@9s~amo&Eo6sVezt00000NkvXXu0mjf7NoxM literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_scale.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_scale.png new file mode 100644 index 0000000000000000000000000000000000000000..e76150ab4b4e0043d081774fd2f4e9d25fab1233 GIT binary patch literal 4299 zcmV;+5H#N2bPDNB8 zb~7$DE;i7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P>2_e}3aoFcj t?0W=4h`ML*JYX~pKY8W}1AluA{15ua?Dq5n2!H?p002ovPDHLkV1n=*|J48h literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_select.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_select.png new file mode 100644 index 0000000000000000000000000000000000000000..9a677b8a668b175260825db8a6614c1d456c17f2 GIT binary patch literal 3182 zcmV-!43YDRP)N2bPDNB8 zb~7$DE;i7Ety%y83+qWlK~#8N?V1U6Q&k$r-}}d~Z_~Y{Eo;HjotCaimvl*& zqzma@C>b?K$6hNt(R({=e^k|L@+H5X8{m5P=~ALj(pH0ZLL#(Xw)$<}0Ox?9^|;=~6iq zuWt>P`*zqBA=B*?S47@|y^4DmjE9ZngSs@Dn7OH%=sC-kLERr}gQxz7^KN~IATud( zpZzU3J4N6WjXa>!F7vkUX5{5(w0?GoO<4_^z^+edm2LDbIE46iL9)e+GHj+n7q_TM z6FK{Jt)cthLBr=clFPS2{i2VdeCFE_p0x5fqiwK?@9b~-jM7MDaCfpIpmUwnqwXlD ztZ>96ErWuVebBi070KWhG~a= zqGw%5$o>tK-FXmNSAFIb-ub{8XEm=l0fEC8Tw*nKZH%gR@aKTszdcYM(9y*Ew7e|U z)}Hr^oCawX+n@$@x_!+lmv8|<+nO&RWb_gTr>$=$=mNPon)s8?B9%lbuA=$UOx~yY zF;!5~4yL(48t%H9 zQJBp#uZEqPpw2TPiA%30*X{t*^g~cS`yWs>??bRHItKRTC$0;k1!q9q?8}^&{a)6y zfxg`hy@BIrkPKhy$>|ykWj-xE$nqETv9lpAcLQYD_d>z6LtvcoHWbf%2TJdL4=U!o z?*vh|_&7AJIO%kQP}l*jt3C&OS>&{~$&{>Ac>^bKo8LlZ@e)nVB$@Z5ecG^T=OWYB z!Fbyq$m;kDOq_fGa=YGy{O*HLIQ_3K5awPG)$@-+{gO|hdF5x&h5`|Tu+9GvqLNo# z;5<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AE^33LGKZuV0T~`0tg(S=tc?-!ELnK7A$fHWU>@zvTBu4I5~!@aLh)s7q@;)!rvoHL9U(C-K)I z0`6E1GF{yl$N_f~M8<&2TauY5CE5HSlF2o(9(8LJe(hqs1SXM`G|$YcD~{+B=0mix z$0Z(%6-495g81;fC((*=`X#iA+%47Cgx*+J)6jjuH1XM=_ z7eoufap!UQk6#ODntX~?*H~FqC3j;0MEEX>%i(BQel@EuKaa29?t;9c~7anDL3L*-&fcNl4K&h?o z6WRtN$s5II=^Hf~Eh*p_zPO#&)t?9)x6*0t{(`Y+p(2gjAUI<^$OAjSA+?Pw33(-R zqsJ2E`)JM>%c(3oJi=$7?r(C5cNdKxW8t_W3b&%}FLbaT4F?f`8w@^CN+$@4$>kYY zNi(l&JRgJtt-ok@;R1k=%nhIj=r}FW*}G^><6!-TM{h^S>@Zqcb<8v3uB#FGoBIF| z1b^T89tg|b1iIL{S9tHH?NVKHJi(X;Z}6dCXYjPLVj23{`+RWvuaUibTsC(XA5qwY zY~KUnDEI=#KL85f=FgSBtxW`B9K>UvO(uD*d8|Tj+wV65PkOfei1@7#n)3u`!)IPb z-x<7!e%mv+tuOJ+mMMJ9ExNGwuVV`~LNvPDgB>7r`}?kMMV-G^eu=9#pS zh-?vjqjM9%s_>h@s)9^U%d}-z!%|m4RKepAS-8a|RuC<0L$V$Pb=a(P5>NZDXjz%& zCJrr*kE(n}aTq=oX{rpYSb@&g)Q%SCPAB=AN{U<2xQSl%@^U;x1rHlj&S_cw&X zx`1GevR{JsYZ|19B%{hysr|CY`A1}J^f6R^#(Ua;_ill})Q7;3^CTE@H-j#IF`Dn! zA0)W)D1tHlGP>{HMbZB)bN~PV07*qoM6N<$g7&Em4gdfE literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_turn.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/icons/ic_nel_turn.png new file mode 100644 index 0000000000000000000000000000000000000000..b03cb0fd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Bjm6gQ`;tj7f*O5U{+Mg|=>Tk-- zL^v&jBCY?lyOXNC*=&{!=H%pn6}?RA!;G`)&&)H8A3q)$85!VtzJEua=XHIk282`O z-;0jc!(y>WMw!@aw&T<3bnRx_OtY3jVv3HAhQr}teRN)Dt`h@N(4i)hs(B4*Kj|XP zYfP9hK{8iRK!+kyety1`1#xk4&}y~q5ZFBeVCuy4yuT~0?E?u!Dro_k+e*E z(}BoW-VVA(-$kH{Ko2v4ITgh002ovPDHLkV1kJ? BBOd?& literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor.qrc b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor.qrc index f7c54fd5f..02ffcbe00 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor.qrc +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor.qrc @@ -1,5 +1,10 @@ + icons/ic_nel_select.png + icons/ic_nel_scale.png + icons/ic_nel_rotate.png + icons/ic_nel_move.png + icons/ic_nel_turn.png icons/ic_nel_world_editor.png diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index fc1f0e248..7ddb5484c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -40,6 +40,7 @@ // Qt includes #include +#include #include namespace WorldEditor @@ -54,12 +55,28 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); + QActionGroup *sceneModeGroup = new QActionGroup(this); + sceneModeGroup->addAction(m_ui.selectAction); + sceneModeGroup->addAction(m_ui.moveAction); + sceneModeGroup->addAction(m_ui.rotateAction); + sceneModeGroup->addAction(m_ui.scaleAction); + sceneModeGroup->addAction(m_ui.turnAction); + sceneModeGroup->addAction(m_ui.radiusAction); + m_ui.selectAction->setChecked(true); + + m_ui.newWorldEditAction->setIcon(QIcon(Core::Constants::ICON_NEW)); + m_ui.saveWorldEditAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); + m_primitivesModel = new PrimitivesTreeModel(); m_ui.treePrimitivesView->setModel(m_primitivesModel); createMenus(); createToolBars(); readSettings(); + + connect(m_ui.newWorldEditAction, SIGNAL(triggered()), this, SLOT(newWorldEditFile())); + connect(m_ui.saveWorldEditAction, SIGNAL(triggered()), this, SLOT(saveAllWorldEditFiles())); + } WorldEditorWindow::~WorldEditorWindow() @@ -96,6 +113,14 @@ void WorldEditorWindow::loadPrimitive(const QString &fileName) m_primitivesModel->loadPrimitive(fileName); } +void WorldEditorWindow::newWorldEditFile() +{ +} + +void WorldEditorWindow::saveAllWorldEditFiles() +{ +} + void WorldEditorWindow::openProjectSettings() { /* @@ -119,8 +144,11 @@ void WorldEditorWindow::createToolBars() Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); //QAction *action = menuManager->action(Core::Constants::NEW); //m_ui.fileToolBar->addAction(action); + + m_ui.fileToolBar->addAction(m_ui.newWorldEditAction); QAction *action = menuManager->action(Core::Constants::OPEN); m_ui.fileToolBar->addAction(action); + m_ui.fileToolBar->addAction(m_ui.saveWorldEditAction); m_ui.fileToolBar->addSeparator(); action = menuManager->action(Core::Constants::UNDO); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 39e741716..1b2937dad 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -43,6 +43,8 @@ public Q_SLOTS: void open(); private Q_SLOTS: + void newWorldEditFile(); + void saveAllWorldEditFiles(); void openProjectSettings(); private: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index 179a78830..331dc34ff 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -45,10 +45,19 @@ false - - + + + + + + + + + + Primitives + 2 @@ -82,6 +91,23 @@ + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + loadPrimitive @@ -92,6 +118,162 @@ newPrimitive + + + + :/icons/ic_nel_zonel.png:/icons/ic_nel_zonel.png + + + loadLand + + + + + + :/icons/ic_nel_landscape_settings.png:/icons/ic_nel_landscape_settings.png + + + LandSettings + + + + + true + + + S/H Land + + + + + true + + + S/H Primitives + + + + + true + + + S/H Layers + + + + + true + + + S/H Details + + + + + true + + + + :/icons/ic_grid.png:/icons/ic_grid.png + + + S/H Grid + + + + + true + + + S/H Grid points + + + + + New World Edit file + + + + + Save World Edit file + + + + + true + + + + :/icons/ic_nel_select.png:/icons/ic_nel_select.png + + + Select + + + + + true + + + + :/icons/ic_nel_move.png:/icons/ic_nel_move.png + + + Move + + + + + true + + + + :/icons/ic_nel_rotate.png:/icons/ic_nel_rotate.png + + + Rotate + + + + + true + + + + :/icons/ic_nel_scale.png:/icons/ic_nel_scale.png + + + Scale + + + + + true + + + + :/icons/ic_nel_turn.png:/icons/ic_nel_turn.png + + + Turn + + + + + true + + + Radius + + + + + true + + + Edit points + + @@ -107,6 +289,7 @@ + From 5edc56cf1512da9683c845e10788815846a7a9fe Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 30 Jul 2011 22:32:06 +0300 Subject: [PATCH 036/747] Changed: #1302 Added 2d render in world editor plugin. --- .../src/plugins/world_editor/CMakeLists.txt | 1 + .../world_editor/world_editor_scene.cpp | 71 +++++++++++++++++++ .../plugins/world_editor/world_editor_scene.h | 57 +++++++++++++++ .../world_editor/world_editor_window.cpp | 10 +++ .../world_editor/world_editor_window.h | 8 +++ 5 files changed, 147 insertions(+) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt index 8b51838d7..1e41175bd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt @@ -11,6 +11,7 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h world_editor_window.h + world_editor_scene.h primitives_model.h primitives_view.h ) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp new file mode 100644 index 000000000..2c4c41065 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -0,0 +1,71 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "world_editor_scene.h" + +// NeL includes +#include + +// Qt includes +#include +#include +#include +#include + +namespace WorldEditor +{ + +WorldEditorScene::WorldEditorScene(int sizeCell, QObject *parent) + : LandscapeEditor::LandscapeSceneBase(sizeCell, parent) +{ +} + +WorldEditorScene::~WorldEditorScene() +{ +} +/* +void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + QGraphicsScene::mousePressEvent(mouseEvent); + + qreal x = mouseEvent->scenePos().x(); + qreal y = mouseEvent->scenePos().y(); + m_posX = sint32(floor(x / m_cellSize)); + m_posY = sint32(-floor(y / m_cellSize)); + + m_mouseButton = mouseEvent->button(); +} + +void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + m_mouseX = mouseEvent->scenePos().x(); + m_mouseY = mouseEvent->scenePos().y() - m_cellSize; + + m_posX = sint32(floor(m_mouseX / m_cellSize)); + m_posY = sint32(-floor(m_mouseY / m_cellSize)); + + QGraphicsScene::mouseMoveEvent(mouseEvent); +} + +void LandscapeSceneBase::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + QGraphicsScene::mouseReleaseEvent(mouseEvent); + m_mouseButton = Qt::NoButton; +} +*/ + +} /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h new file mode 100644 index 000000000..84dba333c --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -0,0 +1,57 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef WORLD_EDITOR_SCENE_H +#define WORLD_EDITOR_SCENE_H + +// Project includes +#include "world_editor_global.h" + +#include "../landscape_editor/landscape_scene_base.h" + +// NeL includes + +// Qt includes + +namespace WorldEditor +{ + +/* +@class WorldEditorScene +@brief +@details +*/ +class WORLD_EDITOR_EXPORT WorldEditorScene : public LandscapeEditor::LandscapeSceneBase +{ + Q_OBJECT + +public: + WorldEditorScene(int sizeCell = 160, QObject *parent = 0); + virtual ~WorldEditorScene(); + +public Q_SLOTS: + +protected: +// virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); +// virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); +// virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); + +private: +}; + +} /* namespace WorldEditor */ + +#endif // WORLD_EDITOR_SCENE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 7ddb5484c..fd9f9c755 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -19,6 +19,7 @@ #include "world_editor_window.h" #include "world_editor_constants.h" #include "primitives_model.h" +#include "world_editor_scene.h" // Core #include "../core/icore.h" @@ -26,6 +27,7 @@ #include "../core/core_constants.h" // Lanscape Editor plugin +#include "../landscape_editor/builder_zone_base.h" //#include "../landscape_editor/project_settings_dialog.h" // NeL includes @@ -55,6 +57,12 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); + m_worldEditorScene = new WorldEditorScene(160, this); + m_zoneBuilderBase = new LandscapeEditor::ZoneBuilderBase(m_worldEditorScene); + + m_worldEditorScene->setZoneBuilder(m_zoneBuilderBase); + m_ui.graphicsView->setScene(m_worldEditorScene); + QActionGroup *sceneModeGroup = new QActionGroup(this); sceneModeGroup->addAction(m_ui.selectAction); sceneModeGroup->addAction(m_ui.moveAction); @@ -82,6 +90,8 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) WorldEditorWindow::~WorldEditorWindow() { writeSettings(); + + delete m_zoneBuilderBase; } QUndoStack *WorldEditorWindow::undoStack() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 1b2937dad..99768736b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -24,9 +24,15 @@ // Qt includes #include +namespace LandscapeEditor +{ +class ZoneBuilderBase; +} + namespace WorldEditor { class PrimitivesTreeModel; +class WorldEditorScene; class WorldEditorWindow: public QMainWindow { @@ -57,6 +63,8 @@ private: PrimitivesTreeModel *m_primitivesModel; QUndoStack *m_undoStack; + WorldEditorScene *m_worldEditorScene; + LandscapeEditor::ZoneBuilderBase *m_zoneBuilderBase; Ui::WorldEditorWindow m_ui; }; /* class WorldEditorWindow */ From 71a2a7393ccac1d78a1a000081feb6717332d873 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 2 Aug 2011 16:10:12 +0300 Subject: [PATCH 037/747] Changed: #1301 Improved ZoneBuilderBase for using in undo/redo commands. --- .../plugins/landscape_editor/builder_zone_base.cpp | 9 ++++++--- .../plugins/landscape_editor/builder_zone_base.h | 2 +- .../src/plugins/landscape_editor/landscape_view.cpp | 13 +++++++++++-- .../src/plugins/landscape_editor/landscape_view.h | 4 ++-- .../plugins/landscape_editor/pixmap_database.cpp | 4 +--- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp index eaea3d447..958aee640 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.cpp @@ -77,7 +77,7 @@ bool ZoneBuilderBase::init(const QString &pathName, bool displayProgress) return true; } -int ZoneBuilderBase::loadZoneRegion(const QString &fileName) +int ZoneBuilderBase::loadZoneRegion(const QString &fileName, int defaultId) { LandscapeItem landItem; landItem.zoneRegionObject = new ZoneRegionObject(); @@ -88,15 +88,18 @@ int ZoneBuilderBase::loadZoneRegion(const QString &fileName) delete landItem.zoneRegionObject; return -1; } + int id = defaultId; + if (id == -1) + id = NewLandId++; // landItem.builderZoneRegion = new BuilderZoneRegion(LandCounter); // landItem.builderZoneRegion->init(this); m_landscapeSceneBase->addZoneRegion(landItem.zoneRegionObject->ligoZoneRegion()); // landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion()); - m_landscapeMap.insert(NewLandId, landItem); + m_landscapeMap.insert(id, landItem); calcMask(); - return NewLandId++; + return id; } void ZoneBuilderBase::deleteZoneRegion(int id) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h index 249f11a73..4c9e501eb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h @@ -83,7 +83,7 @@ public: /// Zone Region /// @{ - int loadZoneRegion(const QString &fileName); + int loadZoneRegion(const QString &fileName, int defaultId = -1); void deleteZoneRegion(int id); int countZoneRegion() const; ZoneRegionObject *zoneRegion(int id) const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index 263417204..c254fd65d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -1,5 +1,4 @@ // 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 @@ -34,9 +33,10 @@ namespace LandscapeEditor LandscapeView::LandscapeView(QWidget *parent) : QGraphicsView(parent), m_visibleGrid(true), + m_visibleText(true), m_moveMouse(false) { - setDragMode(ScrollHandDrag); + //setDragMode(ScrollHandDrag); setTransformationAnchor(AnchorUnderMouse); setBackgroundBrush(QBrush(Qt::lightGray)); //setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); @@ -62,6 +62,12 @@ void LandscapeView::setVisibleGrid(bool visible) scene()->update(); } +void LandscapeView::setVisibleText(bool visible) +{ + m_visibleText = visible; + scene()->update(); +} + void LandscapeView::wheelEvent(QWheelEvent *event) { double numDegrees = event->delta() / 8.0; @@ -118,6 +124,9 @@ void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect) painter->setPen(QPen(Qt::white, 0, Qt::SolidLine)); drawGrid(painter, rect); + if (!m_visibleText) + return; + if (m_numSteps > -m_maxSteps / 4) { painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h index 0673db82c..20e7ee1bc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -1,5 +1,4 @@ // 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 @@ -40,6 +39,7 @@ public: public Q_SLOTS: void setVisibleGrid(bool visible); + void setVisibleText(bool visible); private Q_SLOTS: protected: @@ -53,7 +53,7 @@ protected: void drawZoneNames(QPainter *painter, const QRectF &rect); private: - bool m_visibleGrid; + bool m_visibleGrid, m_visibleText; int m_numSteps, m_maxSteps; int m_cellSize; bool m_moveMouse; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp index f0e2859f6..52d8e04f3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp @@ -1,5 +1,4 @@ // 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 @@ -52,9 +51,8 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon zoneBank.getCategoryValues ("zone", listNames); if (displayProgress) { - progressDialog = new QProgressDialog(); + progressDialog = new QProgressDialog("Loading ligo zones.", "Cancel", 0, listNames.size()); progressDialog->show(); - progressDialog->setRange(0, listNames.size()); } for (uint i = 0; i < listNames.size(); ++i) From 7a0564bdf2f6e9583ffdbe4da4dc9b236a6556d2 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 3 Aug 2011 18:43:00 +0300 Subject: [PATCH 038/747] Changed: #1302 Added new utils functions. --- .../world_editor/world_editor_misc.cpp | 200 +++++++++++++++++- .../plugins/world_editor/world_editor_misc.h | 27 ++- 2 files changed, 225 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp index 824fe8be6..e06332deb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp @@ -20,12 +20,51 @@ // NeL includes #include +#include +#include +#include +#include +#include #include + // Qt includes namespace WorldEditor { +namespace Utils +{ + +void syntaxError(const char *filename, xmlNodePtr xmlNode, const char *format, ...) +{ + char buffer[1024]; + + if (format) + { + va_list args; + va_start( args, format ); + sint ret = vsnprintf( buffer, 1024, format, args ); + va_end( args ); + } + else + { + strcpy(buffer, "Unknown error"); + } + + nlerror("(%s), node (%s), line (%d) :\n%s", filename, xmlNode->name, (int)xmlNode->content, buffer); +} + +bool getPropertyString(std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName) +{ + // Call the CIXml version + if (!NLMISC::CIXml::getPropertyString(result, xmlNode, propName)) + { + // Output a formated error + syntaxError(filename, xmlNode, "Missing XML node property (%s)", propName); + return false; + } + return true; +} uint32 getUniqueId() { @@ -39,6 +78,148 @@ uint32 getUniqueId() return (uint32)time2; } +bool loadWorldEditFile(const std::string &fileName, WorldEditList &worldEditList) +{ + bool result = false; + + // Load the document + NLMISC::CIFile file; + if (file.open(fileName)) + { + try + { + // Load the document in XML + NLMISC::CIXml xml; + xml.init(file); + + // Get root node + xmlNodePtr rootNode = xml.getRootNode(); + if (rootNode) + { + // Good header ? + if (strcmp((const char *)(rootNode->name), "NEL_WORLD_EDITOR_PROJECT") == 0) + { + // Read the version + int version = -1; + + // Read the parameters + xmlNodePtr node = NLMISC::CIXml::getFirstChildNode(rootNode, "VERSION"); + if (node) + { + std::string versionString; + if (NLMISC::CIXml::getContentString (versionString, node)) + version = atoi(versionString.c_str ()); + } + + if (version == -1) + { + // Error + syntaxError(fileName.c_str(), rootNode, "No version node"); + } + else + { + // Old format, + if (version <= 1) + { + syntaxError(fileName.c_str(), rootNode, "Old version node"); + } + else + { + // Read it + if (version > WORLD_EDITOR_FILE_VERSION) + { + syntaxError(fileName.c_str(), node, "Unknown file version"); + } + else + { + // Read data directory + node = NLMISC::CIXml::getFirstChildNode(rootNode, "DATA_DIRECTORY"); + if (node) + { + std::string dataDir; + NLMISC::CIXml::getPropertyString(dataDir, node, "VALUE"); + worldEditList.push_back(WorldEditItem(DataDirectoryType, dataDir)); + } + + // Read data directory + node = NLMISC::CIXml::getFirstChildNode(rootNode, "CONTEXT"); + if (node) + { + std::string context; + NLMISC::CIXml::getPropertyString(context, node, "VALUE"); + worldEditList.push_back(WorldEditItem(ContextType, context)); + } + + // Read the database element + node = NLMISC::CIXml::getFirstChildNode(rootNode, "DATABASE_ELEMENT"); + if (node) + { + do + { + // Get the type + std::string type; + if (getPropertyString(type, fileName.c_str(), node, "TYPE")) + { + // Read the filename + std::string filenameChild; + if (getPropertyString(filenameChild, fileName.c_str(), node, "FILENAME")) + { + // Is it a landscape ? + if (type == "landscape") + { + worldEditList.push_back(WorldEditItem(LandscapeType, filenameChild)); + + // Get the primitives + xmlNodePtr primitives = NLMISC::CIXml::getFirstChildNode(node, "PRIMITIVES"); + if (primitives) + { + NLLIGO::CPrimitives ligoPrimitives; + + // Read it + ligoPrimitives.read(primitives, fileName.c_str(), *NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); + //_DataHierarchy.back ().Primitives.read (primitives, filename, theApp.Config); + + // Set the filename + //_DataHierarchy.back ().Filename = filenameChild; + } + } + else + { + worldEditList.push_back(WorldEditItem(PrimitiveType, filenameChild)); + } + + } + } + } + while (node = NLMISC::CIXml::getNextChildNode(node, "DATABASE_ELEMENT")); + } + + // Done + result = true; + } + } + } + } + else + { + // Error + syntaxError(fileName.c_str(), rootNode, "Unknown file header : %s", rootNode->name); + } + } + } + catch (NLMISC::Exception &e) + { + nlerror("Error reading file %s : %s", fileName.c_str(), e.what()); + } + } + else + { + nlerror("Can't open the file %s for reading.", fileName.c_str()); + } + + return result; +} + NLLIGO::IPrimitive *getRootPrimitive(NLLIGO::IPrimitive *primitive) { nlassert(primitive); @@ -265,7 +446,7 @@ NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName, // Make a vector of locator //CDatabaseLocatorPointer locatorPtr; //getLocator (locatorPtr, locator); - std::list locators; + std::list locators; //locators.push_back (const_cast (locatorPtr.Primitive)); // Yes, go @@ -491,4 +672,21 @@ bool updateDefaultValues(NLLIGO::IPrimitive *primitive) return modified; } +bool recursiveUpdateDefaultValues(NLLIGO::IPrimitive *primitive) +{ + bool modified = updateDefaultValues(primitive); + + const uint count = primitive->getNumChildren(); + for (uint i = 0; i < count; ++i) + { + // Get the child + NLLIGO::IPrimitive *child; + nlverify(primitive->getChild(child, i)); + modified |= recursiveUpdateDefaultValues(child); + } + + return modified; +} + +} /* namespace Utils */ } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h index 4e75a3edf..ea6a59f58 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h @@ -25,14 +25,34 @@ #include #include -// Qt includes +// STL includes +#include +#include + +#define WORLD_EDITOR_FILE_VERSION 2 +#define WORLD_EDITOR_DATABASE_SIZE 100 namespace WorldEditor { +namespace Utils +{ +enum ItemType +{ + DataDirectoryType = 0, + ContextType, + LandscapeType, + PrimitiveType +}; + +typedef std::pair WorldEditItem; +typedef std::vector WorldEditList; // Generate unique identificator uint32 getUniqueId(); +// Load *.worldedit file and return list primitives and landscapes. +bool loadWorldEditFile(const std::string &fileName, WorldEditList &worldEditList); + // Get root primitive NLLIGO::IPrimitive *getRootPrimitive(NLLIGO::IPrimitive *primitive); @@ -50,6 +70,11 @@ NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName, void deletePrimitive(NLLIGO::IPrimitive *primitive); +bool updateDefaultValues(NLLIGO::IPrimitive *primitive); + +bool recursiveUpdateDefaultValues(NLLIGO::IPrimitive *primitive); + +} /* namespace Utils */ } /* namespace WorldEditor */ #endif // WORLD_EDITOR_MISC_H From b9732cb5bb6bc0037ba3c5c25ad09a4acd644678 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 3 Aug 2011 18:45:14 +0300 Subject: [PATCH 039/747] Changed: #1302 Redesigned the primitives database and added undo\redo commands for database. --- .../plugins/world_editor/primitive_item.cpp | 196 ++++++--- .../src/plugins/world_editor/primitive_item.h | 131 ++++-- .../plugins/world_editor/primitives_model.cpp | 277 ++++++------- .../plugins/world_editor/primitives_model.h | 46 ++- .../plugins/world_editor/primitives_view.cpp | 372 +++++++++++++----- .../plugins/world_editor/primitives_view.h | 34 +- .../world_editor/world_editor_actions.cpp | 191 ++++++++- .../world_editor/world_editor_actions.h | 100 ++++- .../world_editor/world_editor_window.cpp | 78 ++-- .../world_editor/world_editor_window.h | 8 +- .../world_editor/world_editor_window.ui | 12 +- 11 files changed, 1070 insertions(+), 375 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index 300a30631..e948f8b0f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -17,6 +17,9 @@ // Project includes #include "primitive_item.h" #include "world_editor_misc.h" +#include "world_editor_constants.h" + +#include "../landscape_editor/landscape_editor_constants.h" // NeL includes #include @@ -28,87 +31,160 @@ namespace WorldEditor { -BaseTreeItem::BaseTreeItem(BaseTreeItem *parent) +Node::Node() + : m_parent(0) { - m_parentItem = parent; - m_itemData << QIcon() << "" << "" << ""; } -BaseTreeItem::BaseTreeItem(const QList &data, BaseTreeItem *parent) +Node::~Node() { - m_parentItem = parent; - m_itemData = data; + if (m_parent) + m_parent->removeChildNode(this); + + qDeleteAll(m_children); + nlassert(m_children.isEmpty()); + m_data.clear(); } -BaseTreeItem::~BaseTreeItem() +void Node::prependChildNode(Node *node) { - qDeleteAll(m_childItems); + // Node is already a child + nlassert(!m_children.contains(node)); + + // Node already has a parent + nlassert(!m_children.contains(node)); + + m_children.prepend(node); + node->m_parent = this; } -void BaseTreeItem::appendChild(BaseTreeItem *item) +void Node::appendChildNode(Node *node) { - m_childItems.append(item); + // Node is already a child + nlassert(!m_children.contains(node)); + + // Node already has a parent + nlassert(!m_children.contains(node)); + + m_children.append(node); + node->m_parent = this; } -void BaseTreeItem::deleteChild(int row) +void Node::insertChildNodeBefore(Node *node, Node *before) { - delete m_childItems.takeAt(row); + // Node is already a child + nlassert(!m_children.contains(node)); + + // Node already has a parent + nlassert(!m_children.contains(node)); + + int idx = before ? m_children.indexOf(before) : -1; + if (idx == -1) + m_children.append(node); + else + m_children.insert(idx, node); + node->m_parent = this; } -BaseTreeItem *BaseTreeItem::child(int row) +void Node::insertChildNodeAfter(Node *node, Node *after) { - return m_childItems.value(row); + // Node is already a child + nlassert(!m_children.contains(node)); + + // Node already has a parent + nlassert(!m_children.contains(node)); + + int idx = after ? m_children.indexOf(after) : -1; + if (idx == -1) + m_children.append(node); + else + m_children.insert(idx + 1, node); + node->m_parent = this; } -int BaseTreeItem::childCount() const +void Node::removeChildNode(Node *node) { - return m_childItems.count(); + nlassert(m_children.contains(node)); + nlassert(node->parent() == this); + + m_children.removeOne(node); + + node->m_parent = 0; } -int BaseTreeItem::columnCount() const +Node *Node::child(int row) { - return m_itemData.count(); + return m_children.at(row); } -QVariant BaseTreeItem::data(int column) const +int Node::childCount() const { - return m_itemData.value(column); + return m_children.count(); } -void BaseTreeItem::setData(int column, const QVariant &data) +QVariant Node::data(int key) const { - m_itemData[column] = data; + return m_data[key]; } -BaseTreeItem *BaseTreeItem::parent() +void Node::setData(int key, const QVariant &data) { - return m_parentItem; + m_data[key] = data; } -int BaseTreeItem::row() const +Node *Node::parent() { - if (m_parentItem) - return m_parentItem->m_childItems.indexOf(const_cast(this)); + return m_parent; +} + +int Node::row() const +{ + if (m_parent) + return m_parent->m_children.indexOf(const_cast(this)); return 0; } -void BaseTreeItem::setModified(bool value) +Node::NodeType Node::type() const { - m_modified = value; + return BasicNodeType; } -bool BaseTreeItem::isModified() const +WorldEditNode::WorldEditNode(const QString &name) { - return m_modified; + setData(Qt::DisplayRole, name); + setData(Qt::DecorationRole, QIcon(Constants::ICON_WORLD_EDITOR)); } -PrimitiveItem::PrimitiveItem(NLLIGO::IPrimitive *primitive, BaseTreeItem *parent) - : BaseTreeItem(parent), - m_primitive(primitive) +WorldEditNode::~WorldEditNode() { - setData(1, QString(m_primitive->getName().c_str())); - setData(2, QString(m_primitive->getClassName().c_str())); +} + +Node::NodeType WorldEditNode::type() const +{ + return WorldEditNodeType; +} + +LandscapeNode::LandscapeNode(const QString &name) +{ + setData(Qt::DisplayRole, name); + setData(Qt::DecorationRole, QIcon(LandscapeEditor::Constants::ICON_ZONE_ITEM)); +} + +LandscapeNode::~LandscapeNode() +{ +} + +Node::NodeType LandscapeNode::type() const +{ + return LandscapeNodeType; +} + +PrimitiveNode::PrimitiveNode(NLLIGO::IPrimitive *primitive) + : m_primitive(primitive) +{ + setData(Qt::DisplayRole, QString(m_primitive->getName().c_str())); + setData(Qt::ToolTipRole, QString(m_primitive->getClassName().c_str())); std::string className; m_primitive->getPropertyByName("class", className); @@ -125,43 +201,57 @@ PrimitiveItem::PrimitiveItem(NLLIGO::IPrimitive *primitive, BaseTreeItem *parent else icon = QIcon("./old_ico/folder_h.ico"); } - setData(0, icon); + setData(Qt::DecorationRole, icon); - setData(3, QString(className.c_str())); + //setData(3, QString(className.c_str())); } -/* -PrimitiveItem::PrimitiveItem(const PrimitiveItem &other) -{ -} -*/ -PrimitiveItem::~PrimitiveItem() + +PrimitiveNode::~PrimitiveNode() { } -NLLIGO::IPrimitive *PrimitiveItem::primitive() const +NLLIGO::IPrimitive *PrimitiveNode::primitive() const { return m_primitive; } -const NLLIGO::CPrimitiveClass *PrimitiveItem::primitiveClass() const +const NLLIGO::CPrimitiveClass *PrimitiveNode::primitiveClass() const { return NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*m_primitive); } +RootPrimitiveNode *PrimitiveNode::rootPrimitiveNode() +{ + Node *node = this; + while (node && (node->type() != Node::RootPrimitiveNodeType)) + node = node->parent(); + return (RootPrimitiveNode *)node; +} -RootPrimitiveItem::RootPrimitiveItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent) - : PrimitiveItem(primitives->RootNode, parent), +Node::NodeType PrimitiveNode::type() const +{ + return PrimitiveNodeType; +} + +RootPrimitiveNode::RootPrimitiveNode(const QString &name, NLLIGO::CPrimitives *primitives) + : PrimitiveNode(primitives->RootNode), m_primitives(primitives) { - setData(1, name); + setData(Qt::DisplayRole, name); } -/* -RootPrimitiveItem::RootPrimitiveItem(const RootPrimitiveItem &other) + +RootPrimitiveNode::~RootPrimitiveNode() { } -*/ -RootPrimitiveItem::~RootPrimitiveItem() + +NLLIGO::CPrimitives *RootPrimitiveNode::primitives() const { + return m_primitives; +} + +Node::NodeType RootPrimitiveNode::type() const +{ + return RootPrimitiveNodeType; } } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 5d00e6c92..01c63962c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -31,69 +31,144 @@ namespace WorldEditor { +class WorldEditNode; +class RootPrimitiveNode; +class LandscapeNode; +class PrimitiveNode; + /* -@class BaseTreeItem +@class Node @brief @details */ -class BaseTreeItem +class Node { public: - BaseTreeItem(BaseTreeItem *parent = 0); - BaseTreeItem(const QList &data, BaseTreeItem *parent = 0); - virtual ~BaseTreeItem(); - void appendChild(BaseTreeItem *child); - void deleteChild(int row); + enum NodeType + { + BasicNodeType, + WorldEditNodeType, + RootPrimitiveNodeType, + LandscapeNodeType, + PrimitiveNodeType, + UserNodeType = 1024 + }; - BaseTreeItem *child(int row); + Node(); + virtual ~Node(); + + /// Remove child node from the child list. + void removeChildNode(Node *node); + + /// Insert node at the beginning of the list. + void prependChildNode(Node *node); + + /// Insert node at the end of the list. + void appendChildNode(Node *node); + + /// Insert node in front of the node pointed to by the pointer before. + void insertChildNodeBefore(Node *node, Node *before); + + /// Insert node in back of the node pointed to by the pointer after. + void insertChildNodeAfter(Node *node, Node *after); + + /// Return the node at index position row in the child list. + Node *child(int row); + + /// Return the number of nodes in the list. int childCount() const; - int columnCount() const; - QVariant data(int column) const; - void setData(int column, const QVariant &data); + + /// Return a row index this node. int row() const; - BaseTreeItem *parent(); - void setModified(bool value); - bool isModified() const; + + /// Return a pointer to this node's parent item. If this node does not have a parent, 0 is returned. + Node *parent(); + + /// Set this node's custom data for the key key to value. + void setData(int key, const QVariant &data); + + /// Return this node's custom data for the key key as a QVariant. + QVariant data(int key) const; + + /// Return a type this node. + virtual NodeType type() const; private: + Q_DISABLE_COPY(Node) - bool m_modified; - QList m_childItems; - QList m_itemData; - BaseTreeItem *m_parentItem; + Node *m_parent; + QList m_children; + QHash m_data; }; /* -@class PrimitiveItem +@class WorldEditNode @brief @details */ -class PrimitiveItem: public BaseTreeItem +class WorldEditNode: public Node { public: - PrimitiveItem(NLLIGO::IPrimitive *primitive, BaseTreeItem *parent); - PrimitiveItem(const PrimitiveItem &other); - virtual ~PrimitiveItem(); + WorldEditNode(const QString &name); + virtual ~WorldEditNode(); + + virtual NodeType type() const; + +private: +}; + +/* +@class LandscapeNode +@brief +@details +*/ +class LandscapeNode: public Node +{ +public: + LandscapeNode(const QString &name); + virtual ~LandscapeNode(); + + virtual NodeType type() const; + +private: +}; + +/* +@class PrimitiveNode +@brief +@details +*/ +class PrimitiveNode: public Node +{ +public: + PrimitiveNode(NLLIGO::IPrimitive *primitive); + virtual ~PrimitiveNode(); NLLIGO::IPrimitive *primitive() const; const NLLIGO::CPrimitiveClass *primitiveClass() const; + RootPrimitiveNode *rootPrimitiveNode(); + + virtual NodeType type() const; private: NLLIGO::IPrimitive *m_primitive; }; /* -@class PrimitivesItem +@class RootPrimitiveNode @brief @details */ -class RootPrimitiveItem: public PrimitiveItem +class RootPrimitiveNode: public PrimitiveNode { public: - RootPrimitiveItem(const QString &name, NLLIGO::CPrimitives *primitives, BaseTreeItem *parent); - RootPrimitiveItem(const RootPrimitiveItem &other); - virtual ~RootPrimitiveItem(); + RootPrimitiveNode(const QString &name, NLLIGO::CPrimitives *primitives); + virtual ~RootPrimitiveNode(); + + NLLIGO::CPrimitives *primitives() const; + + virtual NodeType type() const; private: NLLIGO::CPrimitives *m_primitives; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp index 7a41822ab..bc8925175 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp @@ -31,24 +31,26 @@ namespace WorldEditor { PrimitivesTreeModel::PrimitivesTreeModel(QObject *parent) - : QAbstractItemModel(parent) + : QAbstractItemModel(parent), + m_worldEditNode(0) { - QList rootData; - rootData << "Name" << "Class" << "Class"; - m_rootItem = new BaseTreeItem(rootData); + m_rootNode = new Node(); + m_rootNode->setData(Qt::DisplayRole, "Name"); } PrimitivesTreeModel::~PrimitivesTreeModel() { - delete m_rootItem; + delete m_rootNode; } int PrimitivesTreeModel::columnCount(const QModelIndex &parent) const { - if (parent.isValid()) - return static_cast(parent.internalPointer())->columnCount(); - else - return m_rootItem->columnCount(); + /* if (parent.isValid()) + return static_cast(parent.internalPointer())->columnCount(); + else + return m_rootItem->columnCount(); + */ + return 1; } QVariant PrimitivesTreeModel::data(const QModelIndex &index, int role) const @@ -56,20 +58,15 @@ QVariant PrimitivesTreeModel::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); - BaseTreeItem *item = static_cast(index.internalPointer()); + Node *item = static_cast(index.internalPointer()); switch (role) { // case Qt::TextAlignmentRole: // return int(Qt::AlignLeft | Qt::AlignVCenter); case Qt::DisplayRole: - return item->data(index.column() + 1); + return item->data(Qt::DisplayRole); case Qt::DecorationRole: - { - if (index.column() == 0) - return qVariantFromValue(item->data(0)); - else - return QVariant(); - } + return item->data(Qt::DecorationRole); default: return QVariant(); } @@ -83,31 +80,30 @@ Qt::ItemFlags PrimitivesTreeModel::flags(const QModelIndex &index) const return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } -QVariant PrimitivesTreeModel::headerData(int section, Qt::Orientation orientation, - int role) const +QVariant PrimitivesTreeModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - return m_rootItem->data(section); +// return m_rootNode->data(section); + return m_rootNode->data(Qt::DisplayRole); return QVariant(); } -QModelIndex PrimitivesTreeModel::index(int row, int column, const QModelIndex &parent) -const +QModelIndex PrimitivesTreeModel::index(int row, int column, const QModelIndex &parent) const { if (!hasIndex(row, column, parent)) return QModelIndex(); - BaseTreeItem *parentItem; + Node *parentNode; if (!parent.isValid()) - parentItem = m_rootItem; + parentNode = m_rootNode; else - parentItem = static_cast(parent.internalPointer()); + parentNode = static_cast(parent.internalPointer()); - BaseTreeItem *childItem = parentItem->child(row); - if (childItem) - return createIndex(row, column, childItem); + Node *childNode = parentNode->child(row); + if (childNode) + return createIndex(row, column, childNode); else return QModelIndex(); } @@ -117,161 +113,166 @@ QModelIndex PrimitivesTreeModel::parent(const QModelIndex &index) const if (!index.isValid()) return QModelIndex(); - BaseTreeItem *childItem = static_cast(index.internalPointer()); - BaseTreeItem *parentItem = childItem->parent(); + Node *childNode = static_cast(index.internalPointer()); + Node *parentNode = childNode->parent(); - if (parentItem == m_rootItem) + if (parentNode == m_rootNode) return QModelIndex(); - return createIndex(parentItem->row(), 0, parentItem); + return createIndex(parentNode->row(), 0, parentNode); } int PrimitivesTreeModel::rowCount(const QModelIndex &parent) const { - BaseTreeItem *parentItem; + Node *parentNode; if (parent.column() > 0) return 0; if (!parent.isValid()) - parentItem = m_rootItem; + parentNode = m_rootNode; else - parentItem = static_cast(parent.internalPointer()); + parentNode = static_cast(parent.internalPointer()); - return parentItem->childCount(); + return parentNode->childCount(); } -NLLIGO::IPrimitive *PrimitivesTreeModel::primitive(const QModelIndex &index) +Path PrimitivesTreeModel::pathFromIndex(const QModelIndex &index) { - NLLIGO::IPrimitive *prim = 0; - if (index.isValid()) + QModelIndex iter = index; + Path path; + while(iter.isValid()) { - PrimitiveItem *item = static_cast(index.internalPointer()); - prim = item->primitive(); + path.prepend(PathItem(iter.row(), iter.column())); + iter = iter.parent(); } - return prim; + return path; } -const NLLIGO::CPrimitiveClass *PrimitivesTreeModel::primitiveClass(const QModelIndex &index) +QModelIndex PrimitivesTreeModel::pathToIndex(const Path &path) { - if (index.isValid()) + QModelIndex iter; + for(int i = 0; i < path.size(); i++) { - NLLIGO::IPrimitive *prim = primitive(index); - return ligoConfig()->getPrimitiveClass(*prim); + iter = index(path[i].first, path[i].second, iter); } - return 0; + return iter; } -void PrimitivesTreeModel::loadPrimitive(const QString &fileName) -{ - NLLIGO::CPrimitives *primitives = new NLLIGO::CPrimitives(); - - // set the primitive context - NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = primitives; - - NLLIGO::loadXmlPrimitiveFile(*primitives, fileName.toStdString(), *NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); - - // unset the context - NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL; - - addRootPrimitive(fileName, primitives); -} - -void PrimitivesTreeModel::newPrimitiveWithoutUndo(const QString &className, uint id, const QModelIndex &parent) -{ - const NLLIGO::CPrimitiveClass *primClass = primitiveClass(parent); - float delta = 10; - - // TODO: Set the context - //CPrimitiveContext::instance().CurrentPrimitive = &_DataHierarchy[locator._LocateStack[0]].Primitives; - - NLLIGO::IPrimitive *newPrimitive = createPrimitive(className.toStdString().c_str(), className.toStdString().c_str() - , NLMISC::CVector(), delta, primClass->DynamicChildren[id].Parameters, primitive(parent)); - - // unset the context - //CPrimitiveContext::instance().CurrentPrimitive = NULL; - - if (newPrimitive != 0) - { - scanPrimitive(newPrimitive, parent); - } -} - -void PrimitivesTreeModel::deletePrimitiveWithoutUndo(const QModelIndex &index) -{ - deletePrimitive(primitive(index)); - removeRows(index.row(), index.parent()); -} - -void PrimitivesTreeModel::addRootPrimitive(const QString &name, NLLIGO::CPrimitives *primitives) +void PrimitivesTreeModel::createWorldEditNode(const QString &fileName) { beginResetModel(); + m_worldEditNode = new WorldEditNode(fileName); + m_rootNode->appendChildNode(m_worldEditNode); + endResetModel(); +} - // Create root primitive - RootPrimitiveItem *newPrimitives = new RootPrimitiveItem(name, primitives, m_rootItem); - m_rootItem->appendChild(newPrimitives); - - // Scan childs items and add in tree model - for (uint i = 0; i < primitives->RootNode->getNumChildren(); ++i) +void PrimitivesTreeModel::deleteWorldEditNode() +{ + beginResetModel(); + if (m_worldEditNode != 0) { - NLLIGO::IPrimitive *childPrim; - primitives->RootNode->getChild(childPrim, i); - scanPrimitive(childPrim, newPrimitives); + delete m_worldEditNode; + m_worldEditNode = 0; } endResetModel(); } -void PrimitivesTreeModel::scanPrimitive(NLLIGO::IPrimitive *prim, const QModelIndex &parentIndex) +Path PrimitivesTreeModel::createLandscapeNode(const QString &fileName) { - PrimitiveItem *parent = static_cast(parentIndex.internalPointer()); + if (m_worldEditNode == 0) + createWorldEditNode("NewWorldEdit"); - // Add in tree model - beginInsertRows(parentIndex, parent->childCount(), parent->childCount()); - PrimitiveItem *newItem = new PrimitiveItem(prim, parent); - parent->appendChild(newItem); + QModelIndex parentIndex = index(0, 0, QModelIndex()); + beginInsertRows(parentIndex, 0, 0); + LandscapeNode *newNode = new LandscapeNode(fileName); + m_worldEditNode->prependChildNode(newNode); + endInsertRows(); + return pathFromIndex(index(0, 0, index(0, 0, QModelIndex()))); +} + + +Path PrimitivesTreeModel::createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives) +{ + if (m_worldEditNode == 0) + createWorldEditNode("NewWorldEdit"); + + // Get position + int pos = m_worldEditNode->childCount(); + + QModelIndex parentIndex = index(0, 0, QModelIndex()); + + // Add root node in tree model + beginInsertRows(parentIndex, pos, pos); + RootPrimitiveNode *newNode = new RootPrimitiveNode(fileName, primitives); + m_worldEditNode->appendChildNode(newNode); endInsertRows(); - // Scan childs items and add in tree model - QModelIndex childIndex = index(parent->childCount() - 1, 0, parentIndex); - for (uint i = 0; i < prim->getNumChildren(); ++i) + QModelIndex rootPrimIndex = index(pos, 0, parentIndex); + + // Scan childs items and add in the tree model + for (uint i = 0; i < primitives->RootNode->getNumChildren(); ++i) { NLLIGO::IPrimitive *childPrim; - prim->getChild(childPrim, i); - scanPrimitive(childPrim, childIndex); + primitives->RootNode->getChild(childPrim, i); + createChildNodes(childPrim, rootPrimIndex); + } + + return pathFromIndex(rootPrimIndex); +} + +Path PrimitivesTreeModel::createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent) +{ + QModelIndex parentIndex = pathToIndex(parent); + Node *parentNode = static_cast(parentIndex.internalPointer()); + int pos = parentNode->childCount(); + + createChildNodes(primitive, parentIndex); + + return pathFromIndex(index(pos, 0, parentIndex)); +} + +void PrimitivesTreeModel::deleteNode(const Path &path) +{ + QModelIndex nodeIndex = pathToIndex(path); + QModelIndex parentIndex = nodeIndex.parent(); + Node *node = static_cast(nodeIndex.internalPointer()); + + // Scan childs items and delete from the tree model + removeChildNodes(node, parentIndex); +} + +void PrimitivesTreeModel::createChildNodes(NLLIGO::IPrimitive *primitive, const QModelIndex &parent) +{ + Node *parentNode = static_cast(parent.internalPointer()); + + int pos = parentNode->childCount(); + + // Add node in the tree model + beginInsertRows(parent, pos, pos); + PrimitiveNode *newNode = new PrimitiveNode(primitive); + parentNode->appendChildNode(newNode); + endInsertRows(); + + // Scan childs items and add in the tree model + QModelIndex childIndex = index(pos, 0, parent); + for (uint i = 0; i < primitive->getNumChildren(); ++i) + { + NLLIGO::IPrimitive *childPrim; + primitive->getChild(childPrim, i); + createChildNodes(childPrim, childIndex); } } -void PrimitivesTreeModel::scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem *parent) +void PrimitivesTreeModel::removeChildNodes(Node *node, const QModelIndex &parent) { - // Add in tree model - PrimitiveItem *newItem = new PrimitiveItem(prim, parent); - parent->appendChild(newItem); + // Delete all child nodes from the tree model + while (node->childCount() != 0) + removeChildNodes(node->child(node->childCount() - 1), parent.child(node->row(), 0)); - // Scan childs items and add in tree model - for (uint i = 0; i < prim->getNumChildren(); ++i) - { - NLLIGO::IPrimitive *childPrim; - prim->getChild(childPrim, i); - scanPrimitive(childPrim, newItem); - } -} - -void PrimitivesTreeModel::removeRows(int position, const QModelIndex &parent) -{ - BaseTreeItem *item = static_cast(parent.internalPointer())->child(position); - - // Delete all child items from tree model - while (item->childCount() != 0) - removeRows(0, parent.child(position, 0)); - - // Delete item - beginRemoveRows(parent, position, position); - static_cast(parent.internalPointer())->deleteChild(position); + // Delete node from the tree model + beginRemoveRows(parent, node->row(), node->row()); + delete node; endRemoveRows(); } -NLLIGO::CLigoConfig *PrimitivesTreeModel::ligoConfig() const -{ - return NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig; -} - } /* namespace WorldEditor */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h index ab4581a30..d2b6509ad 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h @@ -31,9 +31,15 @@ namespace WorldEditor { +class Node; +class WorldEditNode; -class BaseTreeItem; -class PrimitiveItem; +typedef QPair PathItem; +/* +@typedef Path +@brief It store a list of row and column numbers which have to walk through from the root index of the model to reach the need item +*/ +typedef QList Path; /** @class PrimitivesTreeModel @@ -58,32 +64,34 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; - // Get primitive - NLLIGO::IPrimitive *primitive(const QModelIndex &index); + /// Convert QModelIndex to the persistent index - @Path. + /// @Path is a list of [row,column] pairs showing us the way through the model. + Path pathFromIndex(const QModelIndex &index); - // Get primitive class - const NLLIGO::CPrimitiveClass *primitiveClass(const QModelIndex &index); + QModelIndex pathToIndex(const Path &path); - // Load primitive from file - void loadPrimitive(const QString &fileName); + void createWorldEditNode(const QString &fileName); + void deleteWorldEditNode(); - // Create new primitive and add in tree model - void newPrimitiveWithoutUndo(const QString &className, uint id, const QModelIndex &parent); + /// Add new landscape node in tree model. + Path createLandscapeNode(const QString &fileName); - void deletePrimitiveWithoutUndo(const QModelIndex &index); + /// Add new root primitive node and all sub-primitives in the tree model. + Path createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives); - NLLIGO::CLigoConfig *ligoConfig() const; + /// Add new primitive node and all sub-primitives in the tree model. + Path createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent); + + /// Delete node and all child nodes from the tree model + void deleteNode(const Path &path); private: - // Add root primitive in tree model and add all its sub-items. - void addRootPrimitive(const QString &name, NLLIGO::CPrimitives *primitives); + void createChildNodes(NLLIGO::IPrimitive *primitive, const QModelIndex &parent); - void scanPrimitive(NLLIGO::IPrimitive *prim, const QModelIndex &parentIndex); - void scanPrimitive(NLLIGO::IPrimitive *prim, BaseTreeItem *parent = 0); + void removeChildNodes(Node *node, const QModelIndex &parent); - void removeRows(int position, const QModelIndex &parent); - - BaseTreeItem *m_rootItem; + Node *m_rootNode; + WorldEditNode *m_worldEditNode; }; } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index 0cc4e5e52..517dcee43 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -16,8 +16,13 @@ // Project includes #include "primitives_view.h" -//#include "primitive_item.h" +#include "primitive_item.h" #include "primitives_model.h" +#include "world_editor_actions.h" + +#include "../core/core_constants.h" +#include "../landscape_editor/landscape_editor_constants.h" +#include "../landscape_editor/builder_zone_base.h" // NeL includes #include @@ -27,22 +32,56 @@ // Qt includes #include #include +#include namespace WorldEditor { PrimitivesView::PrimitivesView(QWidget *parent) : QTreeView(parent), + m_undoStack(0), + m_zoneBuilder(0), m_primitivesTreeModel(0) { setContextMenuPolicy(Qt::DefaultContextMenu); - m_deleteAction = new QAction("Delete", this); - m_selectChildrenAction = new QAction("Select children", this); - m_helpAction = new QAction("Help", this); - m_showAction = new QAction("Show", this); - m_hideAction = new QAction("Hide", this); + m_unloadAction = new QAction("Unload", this); + m_unloadAction->setEnabled(false); + m_saveAction = new QAction("Save", this); + m_saveAction->setEnabled(false); + m_saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); + + m_saveAsAction = new QAction("Save As...", this); + m_saveAsAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS)); + m_saveAsAction->setEnabled(false); + + m_loadLandAction = new QAction("Load landscape file", this); + m_loadLandAction->setIcon(QIcon(LandscapeEditor::Constants::ICON_ZONE_ITEM)); + + m_loadPrimitiveAction = new QAction("Load primitive file", this); + m_loadPrimitiveAction->setIcon(QIcon("./old_ico/root.ico")); + + m_newPrimitiveAction = new QAction("New primitive", this); + + m_deleteAction = new QAction("Delete", this); + m_deleteAction->setEnabled(false); + + m_selectChildrenAction = new QAction("Select children", this); + + m_helpAction = new QAction("Help", this); + m_helpAction->setEnabled(false); + + m_showAction = new QAction("Show", this); + m_showAction->setEnabled(false); + + m_hideAction = new QAction("Hide", this); + m_hideAction->setEnabled(false); + + connect(m_loadLandAction, SIGNAL(triggered()), this, SLOT(loadLandscape())); + connect(m_loadPrimitiveAction, SIGNAL(triggered()), this, SLOT(loadRootPrimitive())); + connect(m_newPrimitiveAction, SIGNAL(triggered()), this, SLOT(createRootPrimitive())); + connect(m_selectChildrenAction, SIGNAL(triggered()), this, SLOT(selectChildren())); connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deletePrimitives())); #ifdef Q_OS_DARWIN @@ -54,30 +93,116 @@ PrimitivesView::~PrimitivesView() { } +void PrimitivesView::setUndoStack(QUndoStack *undoStack) +{ + m_undoStack = undoStack; +} + +void PrimitivesView::setZoneBuilder(LandscapeEditor::ZoneBuilderBase *zoneBuilder) +{ + m_zoneBuilder = zoneBuilder; +} + void PrimitivesView::setModel(PrimitivesTreeModel *model) { QTreeView::setModel(model); m_primitivesTreeModel = model; } -void PrimitivesView::deletePrimitives() +void PrimitivesView::loadRootPrimitive() { - QModelIndexList indexList = selectionModel()->selectedRows(); + nlassert(m_undoStack); + nlassert(m_primitivesTreeModel); - // TODO: use QPersistentModelIndex for deleting several items - m_primitivesTreeModel->deletePrimitiveWithoutUndo(indexList.first()); + QStringList fileNames = QFileDialog::getOpenFileNames(this, + tr("Open NeL Ligo primitive file"), m_lastDir, + tr("All NeL Ligo primitive files (*.primitive)")); + + setCursor(Qt::WaitCursor); + if (!fileNames.isEmpty()) + { + if (fileNames.count() > 1) + m_undoStack->beginMacro("Load primitive files"); + + Q_FOREACH(QString fileName, fileNames) + { + m_lastDir = QFileInfo(fileName).absolutePath(); + m_undoStack->push(new LoadRootPrimitiveCommand(fileName, m_primitivesTreeModel)); + } + + if (fileNames.count() > 1) + m_undoStack->endMacro(); + } + setCursor(Qt::ArrowCursor); } -void PrimitivesView::addNewPrimitive(int value) +void PrimitivesView::loadLandscape() +{ + nlassert(m_undoStack); + nlassert(m_zoneBuilder); + nlassert(m_primitivesTreeModel); + + QStringList fileNames = QFileDialog::getOpenFileNames(this, + tr("Open NeL Ligo land file"), m_lastDir, + tr("All NeL Ligo land files (*.land)")); + + setCursor(Qt::WaitCursor); + if (!fileNames.isEmpty()) + { + if (fileNames.count() > 1) + m_undoStack->beginMacro("Load land files"); + + Q_FOREACH(QString fileName, fileNames) + { + m_lastDir = QFileInfo(fileName).absolutePath(); + m_undoStack->push(new LoadLandscapeCommand(fileName, m_primitivesTreeModel, m_zoneBuilder)); + } + + if (fileNames.count() > 1) + m_undoStack->endMacro(); + } + setCursor(Qt::ArrowCursor); +} + +void PrimitivesView::createRootPrimitive() +{ + nlassert(m_undoStack); + nlassert(m_primitivesTreeModel); + + m_undoStack->push(new CreateRootPrimitiveCommand("NewPrimitive", m_primitivesTreeModel)); +} + +void PrimitivesView::selectChildren() { QModelIndexList indexList = selectionModel()->selectedRows(); + QModelIndex parentIndex = indexList.first(); - const NLLIGO::CPrimitiveClass *primClass = m_primitivesTreeModel->primitiveClass(indexList.first()); + selectionModel()->clearSelection(); + selectChildren(parentIndex); +} + +void PrimitivesView::deletePrimitives() +{ + nlassert(m_undoStack); + nlassert(m_primitivesTreeModel); + + QModelIndexList indexList = selectionModel()->selectedRows(); +} + +void PrimitivesView::addNewPrimitiveByClass(int value) +{ + nlassert(m_undoStack); + nlassert(m_primitivesTreeModel); + + QModelIndexList indexList = selectionModel()->selectedRows(); + + PrimitiveNode *node = static_cast(indexList.first().internalPointer()); // Get class name - QString className = primClass->DynamicChildren[value].ClassName.c_str(); + QString className = node->primitiveClass()->DynamicChildren[value].ClassName.c_str(); - m_primitivesTreeModel->newPrimitiveWithoutUndo(className, value, indexList.first()); + m_undoStack->push(new AddPrimitiveByClassCommand(className, m_primitivesTreeModel->pathFromIndex(indexList.first()), + m_primitivesTreeModel)); } void PrimitivesView::generatePrimitives(int value) @@ -96,96 +221,153 @@ void PrimitivesView::contextMenuEvent(QContextMenuEvent *event) return; QMenu *popurMenu = new QMenu(this); - popurMenu->addAction(m_deleteAction); - popurMenu->addAction(m_selectChildrenAction); - popurMenu->addAction(m_helpAction); - popurMenu->addSeparator(); - popurMenu->addAction(m_showAction); - popurMenu->addAction(m_hideAction); - popurMenu->addSeparator(); - - QSignalMapper *addSignalMapper = new QSignalMapper(this); - QSignalMapper *generateSignalMapper = new QSignalMapper(this); - QSignalMapper *openSignalMapper = new QSignalMapper(this); - connect(addSignalMapper, SIGNAL(mapped(int)), this, SLOT(addNewPrimitive(int))); - connect(generateSignalMapper, SIGNAL(mapped(int)), this, SLOT(generatePrimitives(int))); - //connect(openSignalMapper, SIGNAL(mapped(int)), this, SLOT(openItem(int))); if (indexList.size() == 1) { - const NLLIGO::CPrimitiveClass *primClass = m_primitivesTreeModel->primitiveClass(indexList.first()); - - // What class is it ? - if (primClass && primClass->DynamicChildren.size()) + Node *node = static_cast(indexList.first().internalPointer()); + switch (node->type()) { - popurMenu->addSeparator(); - - // For each child, add a create method - for (size_t i = 0; i < primClass->DynamicChildren.size(); i++) - { - // Get class name - QString className = primClass->DynamicChildren[i].ClassName.c_str(); - - // Get icon - QIcon icon(QString("./old_ico/%1.ico").arg(className)); - - // Create and add action in popur menu - QAction *action = popurMenu->addAction(icon, QString("Add %1").arg(className)); - addSignalMapper->setMapping(action, i); - connect(action, SIGNAL(triggered()), addSignalMapper, SLOT(map())); - } - } - - // What class is it ? - if (primClass && primClass->GeneratedChildren.size()) - { - popurMenu->addSeparator(); - - // For each child, add a create method - for (size_t i = 0; i < primClass->GeneratedChildren.size(); i++) - { - // Get class name - QString childName = primClass->GeneratedChildren[i].ClassName.c_str(); - - // Create and add action in popur menu - QAction *action = popurMenu->addAction(QString("Generate %1").arg(childName)); - generateSignalMapper->setMapping(action, i); - connect(generateSignalMapper, SIGNAL(triggered()), addSignalMapper, SLOT(map())); - } - } - /* - // What class is it ? - if (primClass) - { - // Look for files - std::vector filenames; - - // Filenames - buildFilenameVector (*Selection.front (), filenames); - - // File names ? - if (!filenames.empty ()) - { - // Add separator - popurMenu->addSeparator(); - - // Found ? - for (uint i = 0; i < filenames.size(); i++) - { - // Add a menu entry - pMenu->AppendMenu (MF_STRING, ID_EDIT_OPEN_FILE_BEGIN+i, ("Open "+NLMISC::CFile::getFilename (filenames[i])).c_str ()); - } - } - } - */ + case Node::WorldEditNodeType: + fillMenu_WorldEdit(popurMenu); + break; + case Node::RootPrimitiveNodeType: + fillMenu_RootPrimitive(popurMenu, indexList.first()); + break; + case Node::LandscapeNodeType: + fillMenu_Landscape(popurMenu); + break; + case Node::PrimitiveNodeType: + fillMenu_Primitive(popurMenu, indexList.first()); + break; + }; } popurMenu->exec(event->globalPos()); delete popurMenu; - delete addSignalMapper; - delete generateSignalMapper; - delete openSignalMapper; event->accept(); } +void PrimitivesView::selectChildren(const QModelIndex &parent) +{ + const int rowCount = model()->rowCount(parent); + + for (int i = 0; i < rowCount; ++i) + { + QModelIndex childIndex = parent.child(i, 0); + selectionModel()->select(childIndex, QItemSelectionModel::Select); + selectChildren(childIndex); + } +} + +void PrimitivesView::fillMenu_WorldEdit(QMenu *menu) +{ + menu->addAction(m_unloadAction); + menu->addAction(m_saveAction); + menu->addAction(m_saveAsAction); + menu->addSeparator(); + menu->addAction(m_loadLandAction); + menu->addAction(m_loadPrimitiveAction); + menu->addAction(m_newPrimitiveAction); + menu->addSeparator(); + menu->addAction(m_helpAction); +} + +void PrimitivesView::fillMenu_Landscape(QMenu *menu) +{ + menu->addAction(m_deleteAction); + menu->addSeparator(); + menu->addAction(m_showAction); + menu->addAction(m_hideAction); +} + +void PrimitivesView::fillMenu_RootPrimitive(QMenu *menu, const QModelIndex &index) +{ + menu->addAction(m_saveAction); + menu->addAction(m_saveAsAction); + fillMenu_Primitive(menu, index); +} + +void PrimitivesView::fillMenu_Primitive(QMenu *menu, const QModelIndex &index) +{ + menu->addAction(m_deleteAction); + menu->addAction(m_selectChildrenAction); + menu->addAction(m_helpAction); + menu->addSeparator(); + menu->addAction(m_showAction); + menu->addAction(m_hideAction); + + QSignalMapper *addSignalMapper = new QSignalMapper(menu); + QSignalMapper *generateSignalMapper = new QSignalMapper(menu); + QSignalMapper *openSignalMapper = new QSignalMapper(menu); + connect(addSignalMapper, SIGNAL(mapped(int)), this, SLOT(addNewPrimitiveByClass(int))); + connect(generateSignalMapper, SIGNAL(mapped(int)), this, SLOT(generatePrimitives(int))); + //connect(openSignalMapper, SIGNAL(mapped(int)), this, SLOT(openItem(int))); + + PrimitiveNode *node = static_cast(index.internalPointer()); + const NLLIGO::CPrimitiveClass *primClass = node->primitiveClass(); + + // What class is it ? + if (primClass && primClass->DynamicChildren.size()) + { + menu->addSeparator(); + + // For each child, add a create method + for (size_t i = 0; i < primClass->DynamicChildren.size(); i++) + { + // Get class name + QString className = primClass->DynamicChildren[i].ClassName.c_str(); + + // Get icon + QIcon icon(QString("./old_ico/%1.ico").arg(className)); + + // Create and add action in popur menu + QAction *action = menu->addAction(icon, QString("Add %1").arg(className)); + addSignalMapper->setMapping(action, i); + connect(action, SIGNAL(triggered()), addSignalMapper, SLOT(map())); + } + } + + // What class is it ? + if (primClass && primClass->GeneratedChildren.size()) + { + menu->addSeparator(); + + // For each child, add a create method + for (size_t i = 0; i < primClass->GeneratedChildren.size(); i++) + { + // Get class name + QString childName = primClass->GeneratedChildren[i].ClassName.c_str(); + + // Create and add action in popur menu + QAction *action = menu->addAction(QString("Generate %1").arg(childName)); + generateSignalMapper->setMapping(action, i); + connect(generateSignalMapper, SIGNAL(triggered()), addSignalMapper, SLOT(map())); + } + } + /* + // What class is it ? + if (primClass) + { + // Look for files + std::vector filenames; + + // Filenames + buildFilenameVector (*Selection.front (), filenames); + + // File names ? + if (!filenames.empty ()) + { + // Add separator + popurMenu->addSeparator(); + + // Found ? + for (uint i = 0; i < filenames.size(); i++) + { + // Add a menu entry + pMenu->AppendMenu (MF_STRING, ID_EDIT_OPEN_FILE_BEGIN+i, ("Open "+NLMISC::CFile::getFilename (filenames[i])).c_str ()); + } + } + */ +} + } /* namespace WorldEditor */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h index b0381b5bf..67c3ffba0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h @@ -28,11 +28,15 @@ #include #include #include +#include + +namespace LandscapeEditor +{ +class ZoneBuilderBase; +} namespace WorldEditor { - -class BaseTreeItem; class PrimitivesTreeModel; /** @@ -48,23 +52,47 @@ public: PrimitivesView(QWidget *parent = 0); ~PrimitivesView(); + void setUndoStack(QUndoStack *undoStack); + void setZoneBuilder(LandscapeEditor::ZoneBuilderBase *zoneBuilder); virtual void setModel(PrimitivesTreeModel *model); private Q_SLOTS: + void loadLandscape(); + void loadRootPrimitive(); + void createRootPrimitive(); + void selectChildren(); + void deletePrimitives(); - void addNewPrimitive(int value); + void addNewPrimitiveByClass(int value); void generatePrimitives(int value); void openItem(int value); protected: void contextMenuEvent(QContextMenuEvent *event); +private: + void selectChildren(const QModelIndex &parent); + void fillMenu_WorldEdit(QMenu *menu); + void fillMenu_Landscape(QMenu *menu); + void fillMenu_RootPrimitive(QMenu *menu, const QModelIndex &index); + void fillMenu_Primitive(QMenu *menu, const QModelIndex &index); + + QString m_lastDir; + + QAction *m_unloadAction; + QAction *m_saveAction; + QAction *m_saveAsAction; + QAction *m_loadLandAction; + QAction *m_loadPrimitiveAction; + QAction *m_newPrimitiveAction; QAction *m_deleteAction; QAction *m_selectChildrenAction; QAction *m_helpAction; QAction *m_showAction; QAction *m_hideAction; + QUndoStack *m_undoStack; + LandscapeEditor::ZoneBuilderBase *m_zoneBuilder; PrimitivesTreeModel *m_primitivesTreeModel; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index cae402d27..fb8299c23 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -1,5 +1,4 @@ // 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 @@ -17,31 +16,211 @@ // Project includes #include "world_editor_actions.h" +#include "world_editor_misc.h" +#include "primitive_item.h" + +// Lanscape Editor plugin +#include "../landscape_editor/builder_zone_base.h" + +// STL includes +#include // NeL includes #include +#include +#include +#include +#include // Qt includes +#include namespace WorldEditor { -OpenLandscapeCommand::OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent) +CreateWorldCommand::CreateWorldCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), - m_fileName(fileName) + m_fileName(fileName), + m_model(model) +{ + setText("Create new world"); +} + +CreateWorldCommand::~CreateWorldCommand() { } -OpenLandscapeCommand::~OpenLandscapeCommand() +void CreateWorldCommand::undo() +{ + m_model->deleteWorldEditNode(); +} + +void CreateWorldCommand::redo() +{ + m_model->createWorldEditNode(m_fileName); +} + +LoadLandscapeCommand::LoadLandscapeCommand(const QString &fileName, PrimitivesTreeModel *model, + LandscapeEditor::ZoneBuilderBase *zoneBuilder, QUndoCommand *parent) + : QUndoCommand(parent), + m_id(-1), + m_fileName(fileName), + m_model(model), + m_zoneBuilder(zoneBuilder) +{ + setText("Load land file"); +} + +LoadLandscapeCommand::~LoadLandscapeCommand() { } -void OpenLandscapeCommand::undo() +void LoadLandscapeCommand::undo() +{ + m_zoneBuilder->deleteZoneRegion(m_id); + m_model->deleteNode(landIndex); +} + +void LoadLandscapeCommand::redo() +{ + if (m_id == -1) + m_id = m_zoneBuilder->loadZoneRegion(m_fileName); + else + m_zoneBuilder->loadZoneRegion(m_fileName, m_id); + + landIndex = m_model->createLandscapeNode(m_fileName); +} + +CreateRootPrimitiveCommand::CreateRootPrimitiveCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) + : QUndoCommand(parent), + m_fileName(fileName), + m_model(model) +{ + setText("Create new primitive"); +} + +CreateRootPrimitiveCommand::~CreateRootPrimitiveCommand() { } -void OpenLandscapeCommand::redo() +void CreateRootPrimitiveCommand::undo() { + QModelIndex index = m_model->pathToIndex(m_rootPrimIndex); + + RootPrimitiveNode *node = static_cast(index.internalPointer()); + + delete node->primitives(); + + m_model->deleteNode(m_rootPrimIndex); +} + +void CreateRootPrimitiveCommand::redo() +{ + NLLIGO::CPrimitives *newRootPrim = new NLLIGO::CPrimitives(); + m_rootPrimIndex = m_model->createRootPrimitiveNode(m_fileName, newRootPrim); +} + + +LoadRootPrimitiveCommand::LoadRootPrimitiveCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) + : QUndoCommand(parent), + m_fileName(fileName), + m_model(model) +{ + setText("Load primitive file"); +} + +LoadRootPrimitiveCommand::~LoadRootPrimitiveCommand() +{ +} + +void LoadRootPrimitiveCommand::undo() +{ + QModelIndex index = m_model->pathToIndex(m_rootPrimIndex); + + RootPrimitiveNode *node = static_cast(index.internalPointer()); + + delete node->primitives(); + + m_model->deleteNode(m_rootPrimIndex); +} + +void LoadRootPrimitiveCommand::redo() +{ + NLLIGO::CPrimitives *primitives = new NLLIGO::CPrimitives(); + + // set the primitive context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = primitives; + + NLLIGO::loadXmlPrimitiveFile(*primitives, m_fileName.toStdString(), *NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); + + // unset the context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL; + + + // Initialize default values + Utils::recursiveUpdateDefaultValues(primitives->RootNode); + + // Check property types + if (Utils::recursiveUpdateDefaultValues(primitives->RootNode)) + { + nlwarning("In file (%s) : Some primitives have been modified to initialise their default values\nor to change their properties type.", m_fileName.toStdString().c_str()); + } + + m_rootPrimIndex = m_model->createRootPrimitiveNode(m_fileName, primitives); +} + +AddPrimitiveByClassCommand::AddPrimitiveByClassCommand(const QString &className, const Path &parentIndex, + PrimitivesTreeModel *model, QUndoCommand *parent) + : QUndoCommand(parent), + m_className(className), + m_parentIndex(parentIndex), + m_model(model) +{ + setText(QString("Add %1").arg(m_className)); +} + +AddPrimitiveByClassCommand::~AddPrimitiveByClassCommand() +{ +} + +void AddPrimitiveByClassCommand::undo() +{ + QModelIndex index = m_model->pathToIndex(m_newPrimIndex); + PrimitiveNode *node = static_cast(index.internalPointer()); + + // set the primitive context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = node->rootPrimitiveNode()->primitives(); + + Utils::deletePrimitive(node->primitive()); + + // unset the context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL; + + m_model->deleteNode(m_newPrimIndex); +} + +void AddPrimitiveByClassCommand::redo() +{ + QModelIndex parentIndex = m_model->pathToIndex(m_parentIndex); + PrimitiveNode *parentNode = static_cast(parentIndex.internalPointer()); + const NLLIGO::CPrimitiveClass *primClass = parentNode->primitiveClass(); + + float delta = 10; + int id = 0; + while (primClass->DynamicChildren[id].ClassName != m_className.toStdString()) + ++id; + + // set the primitive context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = parentNode->rootPrimitiveNode()->primitives(); + + QString namePrimititve = QString("%1_%2").arg(m_className).arg(parentNode->childCount()); + NLLIGO::IPrimitive *newPrimitive = Utils::createPrimitive(m_className.toStdString().c_str(), namePrimititve.toStdString().c_str(), + NLMISC::CVector(), delta, primClass->DynamicChildren[id].Parameters, parentNode->primitive()); + + // unset the context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL; + + m_newPrimIndex = m_model->createPrimitiveNode(newPrimitive, m_parentIndex); } } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 5a1c1ea49..00951dd9e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -1,5 +1,4 @@ // 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 @@ -19,6 +18,7 @@ #define WORLD_EDITOR_ACTIONS_H // Project includes +#include "primitives_model.h" // NeL includes @@ -27,20 +27,110 @@ #include #include +namespace LandscapeEditor +{ +class ZoneBuilderBase; +} + namespace WorldEditor { -class OpenLandscapeCommand: public QUndoCommand +/** +@class CreateWorldCommand +@brief +@details +*/ +class CreateWorldCommand: public QUndoCommand { public: - OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent = 0); - virtual ~OpenLandscapeCommand(); + CreateWorldCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~CreateWorldCommand(); virtual void undo(); virtual void redo(); private: - QString m_fileName; + const QString m_fileName; + PrimitivesTreeModel *const m_model; +}; + +/** +@class LoadLandscapeCommand +@brief +@details +*/ +class LoadLandscapeCommand: public QUndoCommand +{ +public: + LoadLandscapeCommand(const QString &fileName, PrimitivesTreeModel *model, + LandscapeEditor::ZoneBuilderBase *zoneBuilder, QUndoCommand *parent = 0); + virtual ~LoadLandscapeCommand(); + + virtual void undo(); + virtual void redo(); +private: + + Path landIndex; + int m_id; + const QString m_fileName; + PrimitivesTreeModel *const m_model; + LandscapeEditor::ZoneBuilderBase *const m_zoneBuilder; +}; + +class CreateRootPrimitiveCommand: public QUndoCommand +{ +public: + CreateRootPrimitiveCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~CreateRootPrimitiveCommand(); + + virtual void undo(); + virtual void redo(); +private: + + const QString m_fileName; + Path m_rootPrimIndex; + PrimitivesTreeModel *const m_model; +}; + +/** +@class LoadPrimitiveCommand +@brief +@details +*/ +class LoadRootPrimitiveCommand: public QUndoCommand +{ +public: + LoadRootPrimitiveCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~LoadRootPrimitiveCommand(); + + virtual void undo(); + virtual void redo(); +private: + + Path m_rootPrimIndex; + const QString m_fileName; + PrimitivesTreeModel *const m_model; +}; + +/** +@class AddPrimitiveCommand +@brief +@details +*/ +class AddPrimitiveByClassCommand: public QUndoCommand +{ +public: + AddPrimitiveByClassCommand(const QString &className, const Path &parentIndex, + PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~AddPrimitiveByClassCommand(); + + virtual void undo(); + virtual void redo(); +private: + + const QString m_className; + Path m_parentIndex, m_newPrimIndex; + PrimitivesTreeModel *m_model; }; } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index fd9f9c755..132b52b70 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -1,5 +1,4 @@ // 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 @@ -20,6 +19,8 @@ #include "world_editor_constants.h" #include "primitives_model.h" #include "world_editor_scene.h" +#include "world_editor_misc.h" +#include "world_editor_actions.h" // Core #include "../core/icore.h" @@ -28,17 +29,12 @@ // Lanscape Editor plugin #include "../landscape_editor/builder_zone_base.h" -//#include "../landscape_editor/project_settings_dialog.h" // NeL includes #include #include #include - -#include -#include -#include -#include +#include // Qt includes #include @@ -47,7 +43,6 @@ namespace WorldEditor { -QString _lastDir; WorldEditorWindow::WorldEditorWindow(QWidget *parent) : QMainWindow(parent), @@ -57,9 +52,9 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); - m_worldEditorScene = new WorldEditorScene(160, this); + m_worldEditorScene = new WorldEditorScene(NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->CellSize, this); m_zoneBuilderBase = new LandscapeEditor::ZoneBuilderBase(m_worldEditorScene); - + m_worldEditorScene->setZoneBuilder(m_zoneBuilderBase); m_ui.graphicsView->setScene(m_worldEditorScene); @@ -78,12 +73,16 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_primitivesModel = new PrimitivesTreeModel(); m_ui.treePrimitivesView->setModel(m_primitivesModel); + // TODO: ? + m_ui.treePrimitivesView->setUndoStack(m_undoStack); + m_ui.treePrimitivesView->setZoneBuilder(m_zoneBuilderBase); + createMenus(); createToolBars(); readSettings(); connect(m_ui.newWorldEditAction, SIGNAL(triggered()), this, SLOT(newWorldEditFile())); - connect(m_ui.saveWorldEditAction, SIGNAL(triggered()), this, SLOT(saveAllWorldEditFiles())); + connect(m_ui.saveWorldEditAction, SIGNAL(triggered()), this, SLOT(saveWorldEditFile())); } @@ -101,33 +100,64 @@ QUndoStack *WorldEditorWindow::undoStack() const void WorldEditorWindow::open() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, - tr("Open NeL Ligo primitive file"), _lastDir, - tr("All NeL Ligo primitive files (*.primitive)")); + QString fileName = QFileDialog::getOpenFileName(this, + tr("Open NeL World Edit file"), m_lastDir, + tr("All NeL World Editor file (*.worldedit)")); setCursor(Qt::WaitCursor); - if (!fileNames.isEmpty()) + if (!fileName.isEmpty()) { - QStringList list = fileNames; - _lastDir = QFileInfo(list.front()).absolutePath(); - Q_FOREACH(QString fileName, fileNames) - { - loadPrimitive(fileName); - } + m_lastDir = QFileInfo(fileName).absolutePath(); + loadWorldEditFile(fileName); } setCursor(Qt::ArrowCursor); } -void WorldEditorWindow::loadPrimitive(const QString &fileName) +void WorldEditorWindow::loadWorldEditFile(const QString &fileName) +{ + Utils::WorldEditList worldEditList; + if (!Utils::loadWorldEditFile(fileName.toStdString(), worldEditList)) + { + return; + } + + m_undoStack->beginMacro(QString("Load %1").arg(fileName)); + + checkCurrentWorld(); + + m_undoStack->push(new CreateWorldCommand(fileName, m_primitivesModel)); + for (size_t i = 0; i < worldEditList.size(); ++i) + { + switch (worldEditList[i].first) + { + case Utils::DataDirectoryType: + m_zoneBuilderBase->init(QString(worldEditList[i].second.c_str()), true); + break; + case Utils::ContextType: + break; + case Utils::LandscapeType: + m_undoStack->push(new LoadLandscapeCommand(QString(worldEditList[i].second.c_str()), m_primitivesModel, m_zoneBuilderBase)); + break; + case Utils::PrimitiveType: + m_undoStack->push(new LoadRootPrimitiveCommand(QString(worldEditList[i].second.c_str()), m_primitivesModel)); + break; + }; + } + m_undoStack->endMacro(); +} + +void WorldEditorWindow::checkCurrentWorld() { - m_primitivesModel->loadPrimitive(fileName); } void WorldEditorWindow::newWorldEditFile() { + checkCurrentWorld(); + + m_undoStack->push(new CreateWorldCommand("NewWorldEdit", m_primitivesModel)); } -void WorldEditorWindow::saveAllWorldEditFiles() +void WorldEditorWindow::saveWorldEditFile() { } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 99768736b..2536bcc1c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -1,5 +1,4 @@ // 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 @@ -50,7 +49,7 @@ public Q_SLOTS: private Q_SLOTS: void newWorldEditFile(); - void saveAllWorldEditFiles(); + void saveWorldEditFile(); void openProjectSettings(); private: @@ -59,7 +58,10 @@ private: void readSettings(); void writeSettings(); - void loadPrimitive(const QString &fileName); + void loadWorldEditFile(const QString &fileName); + void checkCurrentWorld(); + + QString m_lastDir; PrimitivesTreeModel *m_primitivesModel; QUndoStack *m_undoStack; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index 331dc34ff..80e4e5ace 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -20,7 +20,17 @@ - + + + QGraphicsView::RubberBandDrag + + + QGraphicsView::AnchorUnderMouse + + + QGraphicsView::AnchorUnderMouse + + From e809eba015c7b591678a18e9d7f4fd4231e23907 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 6 Aug 2011 02:20:57 +0300 Subject: [PATCH 040/747] Fixed: #1301 Now works correctly with translucent tiles. --- .../landscape_editor/landscape_scene.cpp | 13 ++++++--- .../landscape_editor/landscape_scene_base.cpp | 11 ++++++-- .../landscape_editor/pixmap_database.cpp | 28 +++++++++++++++++-- .../landscape_editor/pixmap_database.h | 2 +- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index bdbe54f8c..bb2605b80 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -1,5 +1,4 @@ // 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 @@ -100,14 +99,15 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo // Enable bilinear filtering item->setTransformationMode(Qt::SmoothTransformation); - NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName); + sint32 sizeX = 1, sizeY = 1; + sizeX = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize(); + sizeY = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize(); sint32 deltaX = 0, deltaY = 0; // Calculate offset for graphics item (for items with size that are larger than 1) - if ((zoneBankItem->getSizeX() > 1) || (zoneBankItem->getSizeY() > 1)) + if ((sizeX > 1) || (sizeY > 1)) { - sint32 sizeX = zoneBankItem->getSizeX(), sizeY = zoneBankItem->getSizeY(); if (data.flip == 0) { switch (data.rot) @@ -165,6 +165,8 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo // for not full item zone item->setZValue(LAYER_ZONES); + item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape); + return item; } @@ -178,6 +180,7 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos) // Get image from pixmap database QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED)); + if (pixmap == 0) return 0; @@ -195,6 +198,8 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos) // for not full item zone item->setZValue(LAYER_EMPTY_ZONES); + item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape); + return item; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp index 7946fffbc..473b1ad95 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp @@ -97,14 +97,15 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo // Enable bilinear filtering item->setTransformationMode(Qt::SmoothTransformation); - NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilderBase->getZoneBank().getElementByZoneName(data.zoneName); + sint32 sizeX = 1, sizeY = 1; + sizeX = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize(); + sizeY = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize(); sint32 deltaX = 0, deltaY = 0; // Calculate offset for graphics item (for items with size that are larger than 1) - if ((zoneBankItem->getSizeX() > 1) || (zoneBankItem->getSizeY() > 1)) + if ((sizeX > 1) || (sizeY > 1)) { - sint32 sizeX = zoneBankItem->getSizeX(), sizeY = zoneBankItem->getSizeY(); if (data.flip == 0) { switch (data.rot) @@ -162,6 +163,8 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo // for not full item zone item->setZValue(LAYER_ZONES); + item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape); + return item; } @@ -192,6 +195,8 @@ QGraphicsItem *LandscapeSceneBase::createItemEmptyZone(const ZonePosition &zoneP // for not full item zone item->setZValue(LAYER_EMPTY_ZONES); + item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape); + return item; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp index 52d8e04f3..d3dbd646d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp @@ -27,6 +27,7 @@ // Qt includes #include +#include #include #include #include @@ -35,12 +36,23 @@ namespace LandscapeEditor { PixmapDatabase::PixmapDatabase(int textureSize) - : m_textureSize(textureSize) + : m_textureSize(textureSize), + m_errorPixmap(0) { + m_errorPixmap = new QPixmap(QSize(m_textureSize, m_textureSize)); + QPainter painter(m_errorPixmap); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.fillRect(m_errorPixmap->rect(), QBrush(QColor(Qt::black))); + painter.setFont(QFont("Helvetica [Cronyx]", 14)); + painter.setPen(QPen(Qt::red, 2, Qt::SolidLine)); + painter.drawText(m_errorPixmap->rect(), Qt::AlignCenter | Qt::TextWordWrap, + QObject::tr("Pixmap and LIGO files not found. Set the correct data path and reload landscape.")); + painter.end(); } PixmapDatabase::~PixmapDatabase() { + delete m_errorPixmap; reset(); } @@ -73,9 +85,19 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon if (pixmap->isNull()) { // Generate filled pixmap + QPixmap *emptyPixmap = new QPixmap(QSize(sizeX * m_textureSize, sizeY * m_textureSize)); + QPainter painter(emptyPixmap); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.fillRect(emptyPixmap->rect(), QBrush(QColor(Qt::black))); + painter.setFont(QFont("Helvetica [Cronyx]", 18)); + painter.setPen(QPen(Qt::red, 2, Qt::SolidLine)); + painter.drawText(emptyPixmap->rect(), Qt::AlignCenter, QObject::tr("Pixmap not found")); + painter.end(); + delete pixmap; + m_pixmapMap.insert(zonePixmapName, emptyPixmap); } // All pixmaps must be have same size - if (pixmap->width() != sizeX * m_textureSize) + else if (pixmap->width() != sizeX * m_textureSize) { QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); delete pixmap; @@ -114,7 +136,7 @@ QStringList PixmapDatabase::listPixmaps() const QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const { - QPixmap *result = 0; + QPixmap *result = m_errorPixmap; if (!m_pixmapMap.contains(zoneName)) nlwarning("QPixmap %s not found", zoneName.toStdString().c_str()); else diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h index 85b0f180e..a9d4383ad 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h @@ -1,5 +1,4 @@ // 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 @@ -61,6 +60,7 @@ public: private: int m_textureSize; + QPixmap *m_errorPixmap; QMap m_pixmapMap; }; From 52c4aca5ea723cd6cdcf01c3b63a967a05ed6a65 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 8 Aug 2011 21:57:28 +0300 Subject: [PATCH 041/747] Fixed: #1301 Smooth Panning and Zooming. --- .../landscape_editor_window.cpp | 4 +- .../landscape_editor/landscape_view.cpp | 157 +++++++++++++++--- .../plugins/landscape_editor/landscape_view.h | 12 +- 3 files changed, 149 insertions(+), 24 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index a97dcf380..b3110a0e5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -267,8 +267,8 @@ int LandscapeEditorWindow::createLandscape(const QString &fileName) return -1; } ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id); - m_ui.graphicsView->centerOn(zoneRegion->ligoZoneRegion().getMinX() * m_landscapeScene->cellSize(), - abs(zoneRegion->ligoZoneRegion().getMinY()) * m_landscapeScene->cellSize()); + m_ui.graphicsView->setCenter(QPointF(zoneRegion->ligoZoneRegion().getMinX() * m_landscapeScene->cellSize(), + abs(zoneRegion->ligoZoneRegion().getMinY()) * m_landscapeScene->cellSize())); QListWidgetItem *item; if (fileName.isEmpty()) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index c254fd65d..cad51d7cc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -33,8 +33,7 @@ namespace LandscapeEditor LandscapeView::LandscapeView(QWidget *parent) : QGraphicsView(parent), m_visibleGrid(true), - m_visibleText(true), - m_moveMouse(false) + m_visibleText(false) { //setDragMode(ScrollHandDrag); setTransformationAnchor(AnchorUnderMouse); @@ -45,6 +44,9 @@ LandscapeView::LandscapeView(QWidget *parent) m_cellSize = 160; m_numSteps = 0; m_maxSteps = 20; + + //A modified version of centerOn(), handles special cases + setCenter(QPointF(500.0, 500.0)); } LandscapeView::~LandscapeView() @@ -70,25 +72,54 @@ void LandscapeView::setVisibleText(bool visible) void LandscapeView::wheelEvent(QWheelEvent *event) { - double numDegrees = event->delta() / 8.0; - double numSteps = numDegrees / 15.0; - double factor = std::pow(1.125, numSteps); - if (factor > 1.0) + /* double numDegrees = event->delta() / 8.0; + double numSteps = numDegrees / 15.0; + double factor = std::pow(1.125, numSteps); + if (factor > 1.0) + { + // check max scale view + if (m_numSteps > m_maxSteps) + return; + ++m_numSteps; + } + else + { + // check min scale view + if (m_numSteps < -m_maxSteps) + return; + --m_numSteps; + } + scale(factor, factor); + QGraphicsView::wheelEvent(event);*/ + + //Get the position of the mouse before scaling, in scene coords + QPointF pointBeforeScale(mapToScene(event->pos())); + + //Get the original screen centerpoint + QPointF screenCenter = getCenter(); //CurrentCenterPoint; //(visRect.center()); + + //Scale the view ie. do the zoom + double scaleFactor = 1.15; //How fast we zoom + if(event->delta() > 0) { - // check max scale view - if (m_numSteps > m_maxSteps) - return; - ++m_numSteps; + //Zoom in + scale(scaleFactor, scaleFactor); } else { - // check min scale view - if (m_numSteps < -m_maxSteps) - return; - --m_numSteps; + //Zooming out + scale(1.0 / scaleFactor, 1.0 / scaleFactor); } - scale(factor, factor); - QGraphicsView::wheelEvent(event); + + //Get the position after scaling, in scene coords + QPointF pointAfterScale(mapToScene(event->pos())); + + //Get the offset of how the screen moved + QPointF offset = pointBeforeScale - pointAfterScale; + + //Adjust to the new center for correct zooming + QPointF newCenter = screenCenter + offset; + setCenter(newCenter); } void LandscapeView::mousePressEvent(QMouseEvent *event) @@ -96,24 +127,108 @@ void LandscapeView::mousePressEvent(QMouseEvent *event) QGraphicsView::mousePressEvent(event); if (event->button() != Qt::MiddleButton) return; - m_moveMouse = true; - QApplication::setOverrideCursor(Qt::ClosedHandCursor); + + //For panning the view + m_lastPanPoint = event->pos(); + setCursor(Qt::ClosedHandCursor); } void LandscapeView::mouseMoveEvent(QMouseEvent *event) { - if (m_moveMouse) - translate(0.001, 0.001); + if(!m_lastPanPoint.isNull()) + { + //Get how much we panned + QPointF delta = mapToScene(m_lastPanPoint) - mapToScene(event->pos()); + m_lastPanPoint = event->pos(); + + //Update the center ie. do the pan + setCenter(getCenter() + delta); + } + QGraphicsView::mouseMoveEvent(event); } void LandscapeView::mouseReleaseEvent(QMouseEvent *event) { + m_lastPanPoint = QPoint(); QApplication::restoreOverrideCursor(); - m_moveMouse = false; QGraphicsView::mouseReleaseEvent(event); } +void LandscapeView::resizeEvent(QResizeEvent *event) +{ + //Get the rectangle of the visible area in scene coords + QRectF visibleArea = mapToScene(rect()).boundingRect(); + setCenter(visibleArea.center()); + + //Call the subclass resize so the scrollbars are updated correctly + QGraphicsView::resizeEvent(event); +} + +void LandscapeView::setCenter(const QPointF ¢erPoint) +{ + //Get the rectangle of the visible area in scene coords + QRectF visibleArea = mapToScene(rect()).boundingRect(); + + //Get the scene area + QRectF sceneBounds = sceneRect(); + + double boundX = visibleArea.width() / 2.0; + double boundY = visibleArea.height() / 2.0; + double boundWidth = sceneBounds.width() - 2.0 * boundX; + double boundHeight = sceneBounds.height() - 2.0 * boundY; + + //The max boundary that the centerPoint can be to + QRectF bounds(boundX, boundY, boundWidth, boundHeight); + + if(bounds.contains(centerPoint)) + { + //We are within the bounds + m_currentCenterPoint = centerPoint; + } + else + { + //We need to clamp or use the center of the screen + if(visibleArea.contains(sceneBounds)) + { + //Use the center of scene ie. we can see the whole scene + m_currentCenterPoint = sceneBounds.center(); + } + else + { + m_currentCenterPoint = centerPoint; + + //We need to clamp the center. The centerPoint is too large + if (centerPoint.x() > bounds.x() + bounds.width()) + { + m_currentCenterPoint.setX(bounds.x() + bounds.width()); + } + else if(centerPoint.x() < bounds.x()) + { + m_currentCenterPoint.setX(bounds.x()); + } + + if(centerPoint.y() > bounds.y() + bounds.height()) + { + m_currentCenterPoint.setY(bounds.y() + bounds.height()); + } + else if(centerPoint.y() < bounds.y()) + { + m_currentCenterPoint.setY(bounds.y()); + } + + } + } + + //Update the scrollbars + centerOn(m_currentCenterPoint); +} + +QPointF LandscapeView::getCenter() const +{ + return m_currentCenterPoint; +} + void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect) { QGraphicsView::drawForeground(painter, rect); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h index 20e7ee1bc..607afe60f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -35,6 +35,10 @@ public: LandscapeView(QWidget *parent = 0); virtual ~LandscapeView(); + //Set the current centerpoint in the + void setCenter(const QPointF ¢erPoint); + QPointF getCenter() const; + bool isVisibleGrid() const; public Q_SLOTS: @@ -48,6 +52,7 @@ protected: virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); virtual void drawForeground(QPainter *painter, const QRectF &rect); + virtual void resizeEvent(QResizeEvent *event); void drawGrid(QPainter *painter, const QRectF &rect); void drawZoneNames(QPainter *painter, const QRectF &rect); @@ -56,7 +61,12 @@ private: bool m_visibleGrid, m_visibleText; int m_numSteps, m_maxSteps; int m_cellSize; - bool m_moveMouse; + + //Holds the current centerpoint for the view, used for panning and zooming + QPointF m_currentCenterPoint; + + //From panning the view + QPoint m_lastPanPoint; }; /* class LandscapeView */ } /* namespace LandscapeEditor */ From 79b9e6d3db224fb5281d77cbd0c98098698be686 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 8 Aug 2011 21:59:09 +0300 Subject: [PATCH 042/747] Changed: #1302 Landscape scene works correctly in world editor plugin. --- .../landscape_editor/landscape_scene_base.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp index 473b1ad95..3a8383ff1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp @@ -202,13 +202,16 @@ QGraphicsItem *LandscapeSceneBase::createItemEmptyZone(const ZonePosition &zoneP void LandscapeSceneBase::deleteItemZone(const ZonePosition &zonePos) { - QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize); - - // TODO: delete LAYER_BLACKOUT_NAME - if ((item != 0) && (item->data(ZONE_NAME).toString() != QString(LAYER_BLACKOUT_NAME))) + QList listItems = items(QPointF(zonePos.x * m_cellSize + 10, abs(zonePos.y) * m_cellSize + 10), + Qt::IntersectsItemBoundingRect, Qt::AscendingOrder); + Q_FOREACH(QGraphicsItem *item, listItems) { - removeItem(item); - delete item; + if (dynamic_cast(item) != 0) + { + removeItem(item); + delete item; + return; + } } } @@ -246,6 +249,7 @@ void LandscapeSceneBase::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion) { for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) { + deleteItemZone(ZonePosition(i, -j, -1)); } } @@ -314,10 +318,13 @@ void LandscapeSceneBase::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) bool LandscapeSceneBase::checkUnderZone(const int posX, const int posY) { - // TODO: it will not work correctly in world editor - QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize); - if (item != 0) - return true; + QList listItems = items(QPointF(posX * m_cellSize + 10, abs(posY) * m_cellSize + 10), + Qt::IntersectsItemBoundingRect, Qt::AscendingOrder); + Q_FOREACH(QGraphicsItem *item, listItems) + { + if (dynamic_cast(item) != 0) + return true; + } return false; } From a4ef4082fa12fd2ae623ca10d137c41e895c5cf9 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 8 Aug 2011 22:07:04 +0300 Subject: [PATCH 043/747] Changed: #1302 Added methods for keeping graphics data (QGraphicsItem and future the 3d_WorldEditor classes). --- .../src/plugins/world_editor/primitive_item.cpp | 10 ++++++++++ .../src/plugins/world_editor/primitive_item.h | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index e948f8b0f..672bd2954 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -132,6 +132,16 @@ void Node::setData(int key, const QVariant &data) m_data[key] = data; } +void Node::setGraphicsData(int key, void *pointerToData) +{ + m_graphicsData[key] = pointerToData; +} + +void *Node::graphicsData(int key) const +{ + return m_graphicsData[key]; +} + Node *Node::parent() { return m_parent; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 01c63962c..01c96c9d2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -30,12 +30,14 @@ namespace WorldEditor { - class WorldEditNode; class RootPrimitiveNode; class LandscapeNode; class PrimitiveNode; +const int GRAPHICS_DATA_QT2D = 0; +const int GRAPHICS_DATA_NEL3D = 1; + /* @class Node @brief @@ -91,6 +93,10 @@ public: /// Return this node's custom data for the key key as a QVariant. QVariant data(int key) const; + void setGraphicsData(int key, void *pointerToData); + + void *graphicsData(int key) const; + /// Return a type this node. virtual NodeType type() const; @@ -100,6 +106,7 @@ private: Node *m_parent; QList m_children; QHash m_data; + QHash m_graphicsData; }; /* From b400efa6f1566c48190f1490d166f48bdd67e016 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 9 Aug 2011 23:31:14 +0300 Subject: [PATCH 044/747] Changed: #1302 Landscape scene works correctly in world editor plugin. Replaced dynamic_cast on more faster qgraphicsitem_cast. --- .../landscape_editor/landscape_scene_base.cpp | 26 +++++++++---------- .../landscape_editor/landscape_scene_base.h | 2 -- .../landscape_editor/landscape_view.cpp | 2 +- .../project_settings_dialog.h | 3 +-- .../project_settings_dialog.ui | 17 ++---------- 5 files changed, 17 insertions(+), 33 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp index 3a8383ff1..9ae8d9bbd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp @@ -206,7 +206,7 @@ void LandscapeSceneBase::deleteItemZone(const ZonePosition &zonePos) Qt::IntersectsItemBoundingRect, Qt::AscendingOrder); Q_FOREACH(QGraphicsItem *item, listItems) { - if (dynamic_cast(item) != 0) + if (qgraphicsitem_cast(item) != 0) { removeItem(item); delete item; @@ -295,8 +295,6 @@ void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) qreal y = mouseEvent->scenePos().y(); m_posX = sint32(floor(x / m_cellSize)); m_posY = sint32(-floor(y / m_cellSize)); - - m_mouseButton = mouseEvent->button(); } void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) @@ -310,20 +308,22 @@ void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) QGraphicsScene::mouseMoveEvent(mouseEvent); } -void LandscapeSceneBase::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) -{ - QGraphicsScene::mouseReleaseEvent(mouseEvent); - m_mouseButton = Qt::NoButton; -} - bool LandscapeSceneBase::checkUnderZone(const int posX, const int posY) { - QList listItems = items(QPointF(posX * m_cellSize + 10, abs(posY) * m_cellSize + 10), - Qt::IntersectsItemBoundingRect, Qt::AscendingOrder); + // TODO: Why crash program? + // QList listItems = items(QPointF(posX * m_cellSize + 10, abs(posY) * m_cellSize + 10), + // Qt::IntersectsItemBoundingRect, Qt::AscendingOrder); + + QList listItems = items(); + + QPointF point(posX, abs(posY)); Q_FOREACH(QGraphicsItem *item, listItems) { - if (dynamic_cast(item) != 0) - return true; + if (item->pos() == point) + { + if (qgraphicsitem_cast(item) != 0) + return true; + } } return false; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h index acfc0f9f7..b392b8a85 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.h @@ -64,7 +64,6 @@ public Q_SLOTS: protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); private: bool checkUnderZone(const int posX, const int posY); @@ -72,7 +71,6 @@ private: int m_cellSize; qreal m_mouseX, m_mouseY; sint32 m_posX, m_posY; - Qt::MouseButton m_mouseButton; ZoneBuilderBase *m_zoneBuilderBase; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index cad51d7cc..6cc6b159e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -151,7 +151,7 @@ void LandscapeView::mouseMoveEvent(QMouseEvent *event) void LandscapeView::mouseReleaseEvent(QMouseEvent *event) { m_lastPanPoint = QPoint(); - QApplication::restoreOverrideCursor(); + setCursor(Qt::ArrowCursor); QGraphicsView::mouseReleaseEvent(event); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h index e6b2b950a..abb93ab81 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h @@ -20,14 +20,13 @@ // Project includes #include "ui_project_settings_dialog.h" -#include "landscape_editor_global.h" // Qt includes namespace LandscapeEditor { -class LANDSCAPE_EDITOR_EXPORT ProjectSettingsDialog: public QDialog +class ProjectSettingsDialog: public QDialog { Q_OBJECT diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui index 8be20c9aa..a666cb71c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.ui @@ -7,7 +7,7 @@ 0 0 419 - 93 + 67 @@ -38,20 +38,7 @@
- - - - Context: - - - contextComboBox - - - - - - - + Qt::Horizontal From b37b0b8d6095bcd826d7d058b1ae376fe4afa13e Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 9 Aug 2011 23:56:26 +0300 Subject: [PATCH 045/747] Changed: #1302 Added additional visual elements (Point, Path, Zone) in 2d render without undo/redo operations(move, rotate, scale). --- .../src/plugins/world_editor/CMakeLists.txt | 3 + .../plugins/world_editor/primitives_model.h | 2 + .../plugins/world_editor/primitives_view.cpp | 8 +- .../plugins/world_editor/primitives_view.h | 4 +- .../world_editor/project_settings_dialog.cpp | 59 ++ .../world_editor/project_settings_dialog.h | 48 ++ .../world_editor/project_settings_dialog.ui | 103 +++ .../world_editor/world_editor_actions.cpp | 97 ++- .../world_editor/world_editor_actions.h | 8 +- .../world_editor/world_editor_constants.h | 1 + .../world_editor/world_editor_misc.cpp | 5 + .../plugins/world_editor/world_editor_misc.h | 2 + .../world_editor/world_editor_scene.cpp | 294 +++++++- .../plugins/world_editor/world_editor_scene.h | 46 +- .../world_editor/world_editor_scene_item.cpp | 649 ++++++++++++++++++ .../world_editor/world_editor_scene_item.h | 237 +++++++ .../world_editor/world_editor_window.cpp | 99 ++- .../world_editor/world_editor_window.h | 10 + .../world_editor/world_editor_window.ui | 59 +- 19 files changed, 1688 insertions(+), 46 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt index 1e41175bd..07d7fa5d1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt @@ -12,11 +12,14 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h world_editor_window.h world_editor_scene.h + world_editor_scene_item.h primitives_model.h primitives_view.h + project_settings_dialog.h ) SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui + project_settings_dialog.ui ) SET(OVQT_PLUGIN_WORLD_EDITOR_RCS world_editor.qrc) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h index d2b6509ad..7f9a90aa7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h @@ -68,6 +68,8 @@ public: /// @Path is a list of [row,column] pairs showing us the way through the model. Path pathFromIndex(const QModelIndex &index); + //Path pathFromNode(Node *index); + QModelIndex pathToIndex(const Path &path); void createWorldEditNode(const QString &fileName); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index 517dcee43..f324da9b9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -40,6 +40,7 @@ namespace WorldEditor PrimitivesView::PrimitivesView(QWidget *parent) : QTreeView(parent), m_undoStack(0), + m_worldEditorScene(0), m_zoneBuilder(0), m_primitivesTreeModel(0) { @@ -103,6 +104,11 @@ void PrimitivesView::setZoneBuilder(LandscapeEditor::ZoneBuilderBase *zoneBuilde m_zoneBuilder = zoneBuilder; } +void PrimitivesView::setWorldScene(WorldEditorScene *worldEditorScene) +{ + m_worldEditorScene = worldEditorScene; +} + void PrimitivesView::setModel(PrimitivesTreeModel *model) { QTreeView::setModel(model); @@ -127,7 +133,7 @@ void PrimitivesView::loadRootPrimitive() Q_FOREACH(QString fileName, fileNames) { m_lastDir = QFileInfo(fileName).absolutePath(); - m_undoStack->push(new LoadRootPrimitiveCommand(fileName, m_primitivesTreeModel)); + m_undoStack->push(new LoadRootPrimitiveCommand(fileName, m_worldEditorScene, m_primitivesTreeModel)); } if (fileNames.count() > 1) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h index 67c3ffba0..18785b909 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h @@ -27,7 +27,6 @@ #include #include #include -#include #include namespace LandscapeEditor @@ -38,6 +37,7 @@ class ZoneBuilderBase; namespace WorldEditor { class PrimitivesTreeModel; +class WorldEditorScene; /** @class PrimitivesView @@ -54,6 +54,7 @@ public: void setUndoStack(QUndoStack *undoStack); void setZoneBuilder(LandscapeEditor::ZoneBuilderBase *zoneBuilder); + void setWorldScene(WorldEditorScene *worldEditorScene); virtual void setModel(PrimitivesTreeModel *model); private Q_SLOTS: @@ -92,6 +93,7 @@ private: QAction *m_hideAction; QUndoStack *m_undoStack; + WorldEditorScene *m_worldEditorScene; LandscapeEditor::ZoneBuilderBase *m_zoneBuilder; PrimitivesTreeModel *m_primitivesTreeModel; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.cpp new file mode 100644 index 000000000..28654864c --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.cpp @@ -0,0 +1,59 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "project_settings_dialog.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +// NeL includes +#include + +// Qt includes +#include +#include +#include + +namespace WorldEditor +{ + +ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *parent) + : QDialog(parent) +{ + m_ui.setupUi(this); + m_ui.pathLineEdit->setText(dataPath); + setFixedHeight(sizeHint().height()); + connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath())); +} + +ProjectSettingsDialog::~ProjectSettingsDialog() +{ +} + +QString ProjectSettingsDialog::dataPath() const +{ + return m_ui.pathLineEdit->text(); +} + +void ProjectSettingsDialog::selectPath() +{ + QString dataPath = QFileDialog::getExistingDirectory(this, tr("Select data path"), m_ui.pathLineEdit->text()); + if (!dataPath.isEmpty()) + m_ui.pathLineEdit->setText(dataPath); +} + +} /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.h new file mode 100644 index 000000000..b9a54b9ed --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.h @@ -0,0 +1,48 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef PROJECT_SETTINGS_DIALOG_WE_H +#define PROJECT_SETTINGS_DIALOG_WE_H + +// Project includes +#include "ui_project_settings_dialog.h" + +// Qt includes + +namespace WorldEditor +{ + +class ProjectSettingsDialog: public QDialog +{ + Q_OBJECT + +public: + ProjectSettingsDialog(const QString &dataPath, QWidget *parent = 0); + ~ProjectSettingsDialog(); + + QString dataPath() const; + +private Q_SLOTS: + void selectPath(); + +private: + + Ui::ProjectSettingsDialog m_ui; +}; /* class ProjectSettingsDialog */ + +} /* namespace WorldEditor */ + +#endif // PROJECT_SETTINGS_DIALOG_WE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.ui new file mode 100644 index 000000000..6904a57a2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.ui @@ -0,0 +1,103 @@ + + + ProjectSettingsDialog + + + + 0 + 0 + 419 + 93 + + + + Project settings + + + + :/icons/ic_nel_landscape_settings.png:/icons/ic_nel_landscape_settings.png + + + + + + Data directory: + + + pathLineEdit + + + + + + + + + + ... + + + + + + + Context: + + + contextComboBox + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + ProjectSettingsDialog + accept() + + + 257 + 83 + + + 157 + 274 + + + + + buttonBox + rejected() + ProjectSettingsDialog + reject() + + + 325 + 83 + + + 286 + 274 + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index fb8299c23..a654e8f31 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -18,6 +18,8 @@ #include "world_editor_actions.h" #include "world_editor_misc.h" #include "primitive_item.h" +#include "world_editor_scene.h" +#include "world_editor_scene_item.h" // Lanscape Editor plugin #include "../landscape_editor/builder_zone_base.h" @@ -30,6 +32,7 @@ #include #include #include +#include #include // Qt includes @@ -38,6 +41,92 @@ namespace WorldEditor { +void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene) +{ + PrimitiveNode *node = static_cast(primIndex.internalPointer()); + + float cellSize = Utils::ligoConfig()->CellSize; + if (node != 0) + { + NLLIGO::IPrimitive *primitive = node->primitive(); + NLLIGO::CPrimVector *vec = 0; + QGraphicsItem *item; + switch (node->primitiveClass()->Type) + { + case NLLIGO::CPrimitiveClass::Point: + { + vec = primitive->getPrimVector(); + item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), 0); + break; + } + case NLLIGO::CPrimitiveClass::Path: + { + QPolygonF polygon; + vec = primitive->getPrimVector(); + int sizeVec = primitive->getNumVector(); + + for (int i = 0; i < sizeVec; ++i) + { + polygon << QPointF(vec->x, -vec->y + cellSize); + ++vec; + } + + item = scene->addWorldItemPath(polygon); + break; + } + case NLLIGO::CPrimitiveClass::Zone: + { + QPolygonF polygon; + vec = primitive->getPrimVector(); + int sizeVec = primitive->getNumVector(); + + for (int i = 0; i < sizeVec; ++i) + { + polygon << QPointF(vec->x, -vec->y + cellSize); + ++vec; + } + item = scene->addWorldItemZone(polygon); + break; + } + } + + node->setGraphicsData(GRAPHICS_DATA_QT2D, item); + } + + int count = model->rowCount(primIndex); + for (int i = 0; i < count; ++i) + { + addNewGraphicsItems(primIndex.child(i, 0), model, scene); + } +} + +void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene) +{ + PrimitiveNode *node = static_cast(primIndex.internalPointer()); + + if (node != 0) + { + switch (node->primitiveClass()->Type) + { + case NLLIGO::CPrimitiveClass::Point: + case NLLIGO::CPrimitiveClass::Path: + case NLLIGO::CPrimitiveClass::Zone: + { + QGraphicsItem *item = static_cast(node->graphicsData(GRAPHICS_DATA_QT2D)); + if (item != 0) + delete item; + break; + } + } + } + + int count = model->rowCount(primIndex); + for (int i = 0; i < count; ++i) + { + removeGraphicsItems(primIndex.child(i, 0), model, scene); + } +} + CreateWorldCommand::CreateWorldCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_fileName(fileName), @@ -121,9 +210,11 @@ void CreateRootPrimitiveCommand::redo() } -LoadRootPrimitiveCommand::LoadRootPrimitiveCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) +LoadRootPrimitiveCommand::LoadRootPrimitiveCommand(const QString &fileName, WorldEditorScene *scene, + PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_fileName(fileName), + m_scene(scene), m_model(model) { setText("Load primitive file"); @@ -137,6 +228,8 @@ void LoadRootPrimitiveCommand::undo() { QModelIndex index = m_model->pathToIndex(m_rootPrimIndex); + removeGraphicsItems(index, m_model, m_scene); + RootPrimitiveNode *node = static_cast(index.internalPointer()); delete node->primitives(); @@ -167,6 +260,8 @@ void LoadRootPrimitiveCommand::redo() } m_rootPrimIndex = m_model->createRootPrimitiveNode(m_fileName, primitives); + + addNewGraphicsItems(m_model->pathToIndex(m_rootPrimIndex), m_model, m_scene); } AddPrimitiveByClassCommand::AddPrimitiveByClassCommand(const QString &className, const Path &parentIndex, diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 00951dd9e..7393861b0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -34,6 +34,10 @@ class ZoneBuilderBase; namespace WorldEditor { +class WorldEditorScene; + +void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene); +void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene); /** @class CreateWorldCommand @@ -100,7 +104,8 @@ private: class LoadRootPrimitiveCommand: public QUndoCommand { public: - LoadRootPrimitiveCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent = 0); + LoadRootPrimitiveCommand(const QString &fileName, WorldEditorScene *scene, + PrimitivesTreeModel *model, QUndoCommand *parent = 0); virtual ~LoadRootPrimitiveCommand(); virtual void undo(); @@ -109,6 +114,7 @@ private: Path m_rootPrimIndex; const QString m_fileName; + WorldEditorScene *const m_scene; PrimitivesTreeModel *const m_model; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index cb1abf21e..5c1d32908 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -30,6 +30,7 @@ const char *const WORLD_WINDOW_STATE = "WorldWindowState"; const char *const WORLD_WINDOW_GEOMETRY = "WorldWindowGeometry"; const char *const WORLD_EDITOR_CELL_SIZE = "WorldEditorCellSize"; const char *const WORLD_EDITOR_SNAP = "WorldEditorSnap"; +const char *const WORLD_EDITOR_USE_OPENGL = "WorldEditorUseOpenGL"; const char *const ZONE_SNAPSHOT_RES = "WorldEditorZoneSnapshotRes"; const char *const PRIMITIVE_CLASS_FILENAME = "WorldEditorPrimitiveClassFilename"; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp index e06332deb..1f77ee63d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp @@ -688,5 +688,10 @@ bool recursiveUpdateDefaultValues(NLLIGO::IPrimitive *primitive) return modified; } +NLLIGO::CLigoConfig *ligoConfig() +{ + return NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig; +} + } /* namespace Utils */ } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h index ea6a59f58..2e7fc93b1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h @@ -74,6 +74,8 @@ bool updateDefaultValues(NLLIGO::IPrimitive *primitive); bool recursiveUpdateDefaultValues(NLLIGO::IPrimitive *primitive); +NLLIGO::CLigoConfig *ligoConfig(); + } /* namespace Utils */ } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 2c4c41065..fd2d85a24 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -30,42 +30,304 @@ namespace WorldEditor { WorldEditorScene::WorldEditorScene(int sizeCell, QObject *parent) - : LandscapeEditor::LandscapeSceneBase(sizeCell, parent) + : LandscapeEditor::LandscapeSceneBase(sizeCell, parent), + m_editedSelectedItems(false), + m_lastPickedPrimitive(0), + m_mode(SelectMode), + m_editMode(false) { + setItemIndexMethod(NoIndex); + + m_pen.setColor(QColor(50, 255, 155)); + m_pen.setWidth(0); + + m_brush.setColor(QColor(50, 255, 155, 80)); + m_brush.setStyle(Qt::SolidPattern); } WorldEditorScene::~WorldEditorScene() { } -/* -void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) + +QGraphicsItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, const float angle) { - QGraphicsScene::mousePressEvent(mouseEvent); + WorldItemPoint *item = new WorldItemPoint(point, angle); + addItem(item); + return item; +} + +QGraphicsItem *WorldEditorScene::addWorldItemPath(const QPolygonF &polyline) +{ + WorldItemPath *item = new WorldItemPath(polyline); + addItem(item); + return item; +} + +QGraphicsItem *WorldEditorScene::addWorldItemZone(const QPolygonF &polygon) +{ + WorldItemZone *item = new WorldItemZone(polygon); + addItem(item); + return item; +} + +void WorldEditorScene::setModeEdit(WorldEditorScene::ModeEdit mode) +{ + if (mode == WorldEditorScene::SelectMode) + m_editedSelectedItems = false; + + m_selectionArea = QRectF(); + + m_mode = mode; +} + +WorldEditorScene::ModeEdit WorldEditorScene::editMode() const +{ + return m_mode; +} + +bool WorldEditorScene::isEnabledEditPoint() const +{ + return m_editMode; +} + +void WorldEditorScene::setEnabledEditPoint(bool enabled) +{ + m_editMode = enabled; +} + +void WorldEditorScene::drawForeground(QPainter *painter, const QRectF &rect) +{ + QGraphicsScene::drawForeground(painter, rect); + + if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) + { + painter->setPen(m_pen); + painter->setBrush(m_brush); + painter->drawRect(m_selectionArea); + } +} + +void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) +{ + LandscapeEditor::LandscapeSceneBase::mousePressEvent(mouseEvent); qreal x = mouseEvent->scenePos().x(); qreal y = mouseEvent->scenePos().y(); - m_posX = sint32(floor(x / m_cellSize)); - m_posY = sint32(-floor(y / m_cellSize)); - m_mouseButton = mouseEvent->button(); + if (mouseEvent->button() != Qt::LeftButton) + return; + +// if ((!m_editedSelectedItems) && (m_mode != WorldEditorScene::SelectMode)) + if ((!m_editedSelectedItems && m_selectedItems.isEmpty()) || + (!calcBoundingShape(m_selectedItems).contains(mouseEvent->scenePos()))) + { + updatePickSelection(mouseEvent->scenePos()); + m_firstSelection = true; + } + + m_editedSelectedItems = false; + + switch (m_mode) + { + case WorldEditorScene::SelectMode: + { + m_selectionArea.setTopLeft(mouseEvent->scenePos()); + break; + } + case WorldEditorScene::MoveMode: + { + break; + } + case WorldEditorScene::RotateMode: + break; + case WorldEditorScene::ScaleMode: + break; + case WorldEditorScene::TurnMode: + break; + case WorldEditorScene::RadiusMode: + break; + }; + +// if (m_selectedItems.isEmpty()) +// m_selectionArea.setTopLeft(mouseEvent->scenePos()); } -void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) +void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { - m_mouseX = mouseEvent->scenePos().x(); + if (QApplication::mouseButtons() == Qt::LeftButton) + { + + QPointF offset(mouseEvent->scenePos() - mouseEvent->lastScenePos()); + + m_selectionArea.setBottomRight(mouseEvent->scenePos()); + + switch (m_mode) + { + case WorldEditorScene::SelectMode: + break; + case WorldEditorScene::MoveMode: + { + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->moveOn(offset); + } + break; + } + case WorldEditorScene::RotateMode: + { + QRectF pivot = calcBoundingRect(m_selectedItems); + + // Caluculate angle between two line + QLineF firstLine(pivot.center(), mouseEvent->lastScenePos()); + QLineF secondLine(pivot.center(), mouseEvent->scenePos()); + qreal angle = secondLine.angleTo(firstLine); + + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->rotateOn(pivot.center(), angle); + } + break; + } + case WorldEditorScene::ScaleMode: + { + // float scale = (_SelectionMin.x - _SelectionMax.x + _SelectionMax.y - _SelectionMin.y) * SCALE_PER_PIXEL + 1.f; + // moveAction->setScale (std::max (0.001f, scale), _MainFrame->getTransformMode ()==CMainFrame::Scale, radius); + + // TODO: perfomance + QRectF pivot = calcBoundingRect(m_selectedItems); + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->scaleOn(pivot.center(), offset); + } + break; + } + case WorldEditorScene::TurnMode: + break; + case WorldEditorScene::RadiusMode: + break; + }; + + if ((editMode() != WorldEditorScene::SelectMode) && (!m_selectedItems.isEmpty())) + m_editedSelectedItems = true; + else + m_editedSelectedItems = false; + + update(); + } + /*m_mouseX = mouseEvent->scenePos().x(); m_mouseY = mouseEvent->scenePos().y() - m_cellSize; - - m_posX = sint32(floor(m_mouseX / m_cellSize)); - m_posY = sint32(-floor(m_mouseY / m_cellSize)); - + */ QGraphicsScene::mouseMoveEvent(mouseEvent); } -void LandscapeSceneBase::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) +void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) { + if (mouseEvent->button() != Qt::LeftButton) + return; + + if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) + { + QList listItems; + + // Clear selection + updateSelectedItems(false); + m_selectedItems.clear(); + + if (m_selectionArea.left() < m_selectionArea.right()) + { + listItems = items(m_selectionArea, Qt::IntersectsItemShape, + Qt::AscendingOrder); + } + else + { + listItems = items(m_selectionArea, Qt::ContainsItemShape, + Qt::AscendingOrder); + } + + Q_FOREACH(QGraphicsItem *item, listItems) + { + if (qgraphicsitem_cast(item) == 0) + continue; + + m_selectedItems.push_back(item); + } + updateSelectedItems(true); + m_selectionArea = QRectF(); + update(); + } + else + { + if ((!m_editedSelectedItems) && (!m_firstSelection)) + updatePickSelection(mouseEvent->scenePos()); + else + m_firstSelection = false; + } +// Huck for standart selection model +// clearSelection(); +// updateSelectedItems(true); + QGraphicsScene::mouseReleaseEvent(mouseEvent); - m_mouseButton = Qt::NoButton; } -*/ + +QRectF WorldEditorScene::calcBoundingRect(const QList &listItems) +{ + QRectF rect; + Q_FOREACH(QGraphicsItem *item, listItems) + { + QRectF itemRect = item->boundingRect(); + rect = rect.united(itemRect.translated(item->pos())); + } + return rect; +} + +QPainterPath WorldEditorScene::calcBoundingShape(const QList &listItems) +{ + QPainterPath painterPath; + Q_FOREACH(QGraphicsItem *item, listItems) + { + QPainterPath itemPath = item->shape(); + painterPath = painterPath.united(itemPath.translated(item->pos())); + } + return painterPath; +} + +void WorldEditorScene::updateSelectedItems(bool value) +{ + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + if (value) + { + item->setFlag(QGraphicsItem::ItemIsSelectable); + //item->setZValue(SELECTED_LAYER); + } + else + { + item->setFlag(QGraphicsItem::ItemIsSelectable, false); + //item->setZValue(UNSELECTED_LAYER); + } + item->setSelected(value); + } +} + +void WorldEditorScene::updatePickSelection(const QPointF &point) +{ + //clearSelection(); + updateSelectedItems(false); + m_selectedItems.clear(); + + QList listItems = items(point, Qt::ContainsItemShape, + Qt::AscendingOrder); + if (!listItems.isEmpty()) + { + // Next primitives + m_lastPickedPrimitive++; + m_lastPickedPrimitive %= listItems.size(); + QGraphicsItem *selectedItem = listItems.at(m_lastPickedPrimitive); + if (qgraphicsitem_cast(selectedItem) != 0) + m_selectedItems.push_back(selectedItem); + + updateSelectedItems(true); + } +} } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index 84dba333c..36f27b9b4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -19,6 +19,7 @@ // Project includes #include "world_editor_global.h" +#include "world_editor_scene_item.h" #include "../landscape_editor/landscape_scene_base.h" @@ -39,17 +40,56 @@ class WORLD_EDITOR_EXPORT WorldEditorScene : public LandscapeEditor::LandscapeSc Q_OBJECT public: + enum ModeEdit + { + SelectMode = 0, + MoveMode, + RotateMode, + ScaleMode, + TurnMode, + RadiusMode + }; + WorldEditorScene(int sizeCell = 160, QObject *parent = 0); virtual ~WorldEditorScene(); + QGraphicsItem *addWorldItemPoint(const QPointF &point, const float angle); + QGraphicsItem *addWorldItemPath(const QPolygonF &polyline); + QGraphicsItem *addWorldItemZone(const QPolygonF &polygon); + + void setModeEdit(WorldEditorScene::ModeEdit mode); + WorldEditorScene::ModeEdit editMode() const; + + bool isEnabledEditPoint() const; + public Q_SLOTS: + void setEnabledEditPoint(bool enabled); protected: -// virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); -// virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); -// virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void drawForeground(QPainter *painter, const QRectF &rect); + + virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); private: + + QRectF calcBoundingRect(const QList &listItems); + QPainterPath calcBoundingShape(const QList &listItems); + void updateSelectedItems(bool value); + + void updatePickSelection(const QPointF &point); + + QPen m_pen; + QBrush m_brush; + + QRectF m_selectionArea; + qreal m_firstPickX, m_firstPickY; + QList m_selectedItems; + bool m_editedSelectedItems, m_firstSelection; + uint m_lastPickedPrimitive; + ModeEdit m_mode; + bool m_editMode; }; } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp new file mode 100644 index 000000000..f88c95b9a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -0,0 +1,649 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "world_editor_scene_item.h" + +// NeL includes +#include + +// Qt includes +#include +#include +#include +#include +#include +#include + +namespace WorldEditor +{ + +static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, const QPen &pen) +{ + // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0 + // if we pass a value of 0.0 to QPainterPathStroker::setWidth() + const qreal penWidthZero = qreal(0.00000001); + + if (path == QPainterPath()) + return path; + QPainterPathStroker ps; + ps.setCapStyle(pen.capStyle()); + if (pen.widthF() <= 0.0) + ps.setWidth(penWidthZero); + else + ps.setWidth(pen.widthF()); + ps.setJoinStyle(pen.joinStyle()); + ps.setMiterLimit(pen.miterLimit()); + QPainterPath p = ps.createStroke(path); + p.addPath(path); + return p; +} +/* +GraphicsItemNode::GraphicsItemNode(GraphicsItemZone *itemZone, QGraphicsItem *parent) + : QGraphicsObject(parent) +{ + m_itemZone = itemZone; + m_color = QColor(12, 150, 215); + //setFlag(ItemIgnoresTransformations, true); + //setFlag(ItemClipsToShape); + + QPropertyAnimation *animation = new QPropertyAnimation(this, "colorNode"); + animation->setDuration(3000); + animation->setStartValue(QColor(10, 0, 50)); + animation->setKeyValueAt(0.5, QColor(155, 255, 0)); + animation->setEndValue(QColor(10, 0, 50)); + animation->setLoopCount(2000); + animation->setEasingCurve(QEasingCurve::OutInExpo); + animation->start(); + + setFlag(ItemIsSelectable); + setFlag(ItemIsMovable); + setFlag(ItemSendsScenePositionChanges); + m_type = EdgeType; + + setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); + setZValue(10000000); +} + +GraphicsItemNode::~GraphicsItemNode() +{ +} + +void GraphicsItemNode::setColorNode(const QColor &color) +{ + m_color = color; + update(); +} + +void GraphicsItemNode::setNodeType(NodeType nodeType) +{ + m_type = nodeType; + if (m_type == EdgeType) + { + setFlag(ItemIsSelectable); + setFlag(ItemIsMovable); + setFlag(ItemSendsScenePositionChanges); + setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); + setZValue(10000); + } + else if (m_type == MiddleType) + { + setFlag(ItemIsSelectable, false); + setFlag(ItemIsMovable, false); + setFlag(ItemSendsScenePositionChanges, false); + setAcceptedMouseButtons(Qt::LeftButton); + setZValue(10001); + } + update(); +} + +QRectF GraphicsItemNode::boundingRect() const +{ + return QRectF(QPointF(0, 0), QSizeF(20, 20)); +} + +void GraphicsItemNode::paint(QPainter *painter, + const QStyleOptionGraphicsItem *option, + QWidget *) +{ + // Here comes the magic: + //painter->setClipRect(option->exposedRect); + + painter->setPen(Qt::NoPen); + + if (m_type == EdgeType) + { + painter->setBrush(QColor(255, 0, 0)); + } + else if (m_type == MiddleType) + { + painter->setBrush(QColor(0, 0, 255)); + } + if (option->state & QStyle::State_Selected) + { + painter->setBrush(QColor(0, 255, 0)); + } + + painter->drawRect(2, 2, 18, 18); +} + +QVariant GraphicsItemNode::itemChange(GraphicsItemChange change, + const QVariant &value) +{ + if (change == ItemPositionHasChanged) + { + m_itemZone->updateZone(); + } + return QGraphicsItem::itemChange(change, value); +} + +void GraphicsItemNode::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if ((m_type == MiddleType) && (event->button() == Qt::LeftButton)) + { + m_itemZone->updateMiddleNode(this); + setNodeType(EdgeType); + } + else if ((m_type == EdgeType) && (event->button() == Qt::RightButton)) + { + if (m_itemZone->deleteEdgePoint(this)) + setNodeType(MiddleType); + } +} + +GraphicsItemZone::GraphicsItemZone(QGraphicsScene *scene, QGraphicsItem *parent) + : QGraphicsPolygonItem(parent) +{ + m_scene = scene; + + m_color = QColor(12, 150, 215); + + setBrush(QBrush(QColor(100, 100, 255, 128))); + updateZone(); + setZValue(100); + //setFlag(ItemClipsToShape); + //setFlag(ItemIsSelectable, true); + //setFlag(ItemIsMovable, true); + //setFlag(ItemHasNoContents, true); +} + +GraphicsItemZone::~GraphicsItemZone() +{ +} + +void GraphicsItemZone::updateMiddleNode(GraphicsItemNode *node) +{ + for (int i = 0; i < m_listLines.size(); ++i) + { + if (node == m_listLines.at(i).itemPoint) + { + LineItem oldLineItem = m_listLines[i]; + + GraphicsItemNode *newNode1 = new GraphicsItemNode(this); + newNode1->setPos((oldLineItem.lineNode.first->pos() + node->pos()) / 2); + newNode1->setNodeType(GraphicsItemNode::MiddleType); + m_scene->addItem(newNode1); + + GraphicsItemNode *newNode2 = new GraphicsItemNode(this); + newNode2->setPos((oldLineItem.lineNode.second->pos() + node->pos()) / 2); + newNode2->setNodeType(GraphicsItemNode::MiddleType); + m_scene->addItem(newNode2); + + LineItem newLineItem1; + newLineItem1.itemPoint = newNode1; + newLineItem1.lineNode = LineNode(oldLineItem.lineNode.first, node); + m_listLines.push_back(newLineItem1); + + LineItem newLineItem2; + newLineItem2.itemPoint = newNode2; + newLineItem2.lineNode = LineNode(node, oldLineItem.lineNode.second); + m_listLines.push_back(newLineItem2); + + m_listLines.removeAt(i); + + int pos = m_listItems.indexOf(oldLineItem.lineNode.second); + m_listItems.insert(pos, node); + + break; + } + } +} + +bool GraphicsItemZone::deleteEdgePoint(GraphicsItemNode *node) +{ + if (m_listItems.size() < 4) + return false; + + int pos = m_listItems.indexOf(node); + m_listItems.takeAt(pos); + + LineItem newLineItem; + + newLineItem.itemPoint = node; + + for (int i = 0; i < m_listLines.size(); ++i) + { + if (node == m_listLines.at(i).lineNode.first) + { + // Saving second point for new line + newLineItem.lineNode.second = m_listLines.at(i).lineNode.second; + delete m_listLines.at(i).itemPoint; + m_listLines.removeAt(i); + break; + } + } + + for (int i = 0; i < m_listLines.size(); ++i) + { + if (node == m_listLines.at(i).lineNode.second) + { + newLineItem.lineNode.first = m_listLines.at(i).lineNode.first; + delete m_listLines.at(i).itemPoint; + m_listLines.removeAt(i); + break; + } + } + node->setPos((newLineItem.lineNode.first->pos() + newLineItem.lineNode.second->pos()) / 2); + m_listLines.push_back(newLineItem); + + return true; +} + +void GraphicsItemZone::scanPolygon(const QPolygonF &polygon) +{ + GraphicsItemNode *node1; + node1 = new GraphicsItemNode(this); + node1->setPos(*polygon.begin()); + m_listItems.push_back(node1); + m_scene->addItem(node1); + for (int i = 1; i < polygon.count(); ++i) + { + GraphicsItemNode *node2 = new GraphicsItemNode(this); + node2->setPos(polygon.at(i)); + m_listItems.push_back(node2); + + GraphicsItemNode *node3 = new GraphicsItemNode(this); + node3->setPos((node1->pos() + node2->pos()) / 2); + node3->setNodeType(GraphicsItemNode::MiddleType); + m_scene->addItem(node3); + + LineItem newLineItem; + newLineItem.itemPoint = node3; + newLineItem.lineNode = LineNode(node1, node2); + m_listLines.push_back(newLineItem); + + node1 = node2; + m_scene->addItem(node1); + } + setPolygon(polygon); +} + +void GraphicsItemZone::updateZone() +{ + QPolygonF polygon; + Q_FOREACH(GraphicsItemNode *node, m_listItems) + { + polygon << node->pos(); + } + + for (int i = 0; i < m_listLines.size(); ++i) + { + m_listLines.at(i).itemPoint->setPos((m_listLines.at(i).lineNode.first->pos() + m_listLines.at(i).lineNode.second->pos()) / 2); + } + + setPolygon(polygon); +} +*/ + +AbstractWorldItem::AbstractWorldItem(QGraphicsItem *parent) + : QGraphicsItem(parent) +{ +} + +AbstractWorldItem::~AbstractWorldItem() +{ +} + +int AbstractWorldItem::type() const +{ + return Type; +} + +WorldItemPoint::WorldItemPoint(const QPointF &point, const float angle, QGraphicsItem *parent) + : AbstractWorldItem(parent), + m_angle(angle) +{ + setZValue(WORLD_POINT_LAYER); + + setPos(point); + + m_rect.setCoords(-SIZE_POINT, -SIZE_POINT, SIZE_POINT, SIZE_POINT); + + m_pen.setColor(QColor(255, 100, 10)); + m_pen.setWidth(5); + + m_selectedPen.setColor(QColor(0, 255, 0)); + m_selectedPen.setWidth(5); + + m_brush.setColor(QColor(255, 100, 10)); + m_brush.setStyle(Qt::SolidPattern); + + m_selectedBrush.setColor(QColor(0, 255, 0)); + m_selectedBrush.setStyle(Qt::SolidPattern); + + //setFlag(ItemIsSelectable); +} + +WorldItemPoint::~WorldItemPoint() +{ +} + +void WorldItemPoint::moveOn(const QPointF &offset) +{ + prepareGeometryChange(); + + setPos(pos() + offset); +} + +void WorldItemPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle) +{ + prepareGeometryChange(); + + QPolygonF rotatedPolygon(m_rect); + + // TODO + rotatedPolygon.translate(pos()); + rotatedPolygon.translate(-pivot); + + QTransform trans; + trans = trans.rotate(deltaAngle); + rotatedPolygon = trans.map(rotatedPolygon); + rotatedPolygon.translate(pivot); + + setPos(rotatedPolygon.boundingRect().center()); +} + +void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &offset) +{ + prepareGeometryChange(); + + QPolygonF scaledPolygon(m_rect); + + // TODO + scaledPolygon.translate(pos()); + scaledPolygon.translate(-pivot); + + QTransform trans; + trans = trans.scale(1.0 + (offset.x() / 5000), 1.0 + (-offset.y() / 5000)); + scaledPolygon = trans.map(scaledPolygon); + scaledPolygon.translate(pivot); + + setPos(scaledPolygon.boundingRect().center()); +} + +void WorldItemPoint::turnOn(const QPointF &offset) +{ +} + +void WorldItemPoint::radiusOn(const qreal radius) +{ +} + +QPainterPath WorldItemPoint::shape() const +{ + QPainterPath path; + + path.addRect(m_rect); + + return qt_graphicsItem_shapeFromPath(path, m_pen); +} + +QRectF WorldItemPoint::boundingRect() const +{ + return m_rect; +} + +void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) +{ + // Here comes the magic: + //painter->setClipRect(option->exposedRect); + + painter->setPen(Qt::NoPen); + + if (option->state & QStyle::State_Selected) + { + painter->setBrush(m_selectedBrush); + } + else + { + painter->setBrush(m_brush); + } + + painter->drawRect(m_rect); +} + +QVariant WorldItemPoint::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemPositionHasChanged) + { + } + return QGraphicsItem::itemChange(change, value); +} + +WorldItemPath::WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent) + : AbstractWorldItem(parent), + m_polygon(polygon) +{ + //setFlag(ItemIsSelectable); + + setZValue(WORLD_PATH_LAYER); + + m_pen.setColor(QColor(0, 0, 0)); + m_pen.setWidth(5); + + m_selectedPen.setColor(QColor(255, 0, 0)); + m_selectedPen.setWidth(5); +} + +WorldItemPath::~WorldItemPath() +{ +} + +void WorldItemPath::moveOn(const QPointF &offset) +{ + prepareGeometryChange(); + + m_polygon.translate(offset); +} + +void WorldItemPath::rotateOn(const QPointF &pivot, const qreal deltaAngle) +{ + prepareGeometryChange(); + + QPolygonF rotatedPolygon(m_polygon); + rotatedPolygon.translate(-pivot); + + QTransform trans; + trans = trans.rotate(deltaAngle); + m_polygon = trans.map(rotatedPolygon); + + m_polygon.translate(pivot); +} + +void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &offset) +{ + prepareGeometryChange(); + + QPolygonF scaledPolygon(m_polygon); + scaledPolygon.translate(-pivot); + + QTransform trans; + trans = trans.scale(1.0 + (offset.x() / 5000), 1.0 + (-offset.y() / 5000)); + m_polygon = trans.map(scaledPolygon); + + m_polygon.translate(pivot); +} + +void WorldItemPath::turnOn(const QPointF &offset) +{ +} + +void WorldItemPath::radiusOn(const qreal radius) +{ +} + +QPainterPath WorldItemPath::shape() const +{ + QPainterPath path; + + path.moveTo(m_polygon.first()); + for (int i = 1; i < m_polygon.count(); ++i) + path.lineTo(m_polygon.at(i)); + + return qt_graphicsItem_shapeFromPath(path, m_pen); +} + +QRectF WorldItemPath::boundingRect() const +{ + return m_polygon.boundingRect(); +} + +void WorldItemPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) +{ + // Here comes the magic: + //painter->setClipRect(option->exposedRect); + + if (option->state & QStyle::State_Selected) + painter->setPen(m_selectedPen); + else + painter->setPen(m_pen); + + painter->drawPolyline(m_polygon); +} + +QVariant WorldItemPath::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemPositionHasChanged) + { + } + return QGraphicsItem::itemChange(change, value); +} + +WorldItemZone::WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent) + : AbstractWorldItem(parent), + m_polygon(polygon) +{ + //setFlag(ItemIsSelectable); + + setZValue(WORLD_ZONE_LAYER); + + m_pen.setColor(QColor(20, 100, 255)); + m_pen.setWidth(0); + + m_selectedPen.setColor(QColor(255, 0, 0)); + m_selectedPen.setWidth(0); + + m_brush.setColor(QColor(20, 100, 255, 28)); + m_brush.setStyle(Qt::SolidPattern); + + m_selectedBrush.setColor(QColor(255, 0, 0, 128)); + m_selectedBrush.setStyle(Qt::SolidPattern); +} + +WorldItemZone::~WorldItemZone() +{ +} + +void WorldItemZone::moveOn(const QPointF &offset) +{ + prepareGeometryChange(); + + m_polygon.translate(offset); +} + +void WorldItemZone::rotateOn(const QPointF &pivot, const qreal deltaAngle) +{ + prepareGeometryChange(); + + QPolygonF rotatedPolygon(m_polygon); + rotatedPolygon.translate(-pivot); + + QTransform trans; + trans = trans.rotate(deltaAngle); + m_polygon = trans.map(rotatedPolygon); + + m_polygon.translate(pivot); +} + +void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &offset) +{ + prepareGeometryChange(); + + QPolygonF scaledPolygon(m_polygon); + scaledPolygon.translate(-pivot); + + QTransform trans; + trans = trans.scale(1.0 + (offset.x() / 5000), 1.0 + (-offset.y() / 5000)); + m_polygon = trans.map(scaledPolygon); + + m_polygon.translate(pivot); +} + +void WorldItemZone::turnOn(const QPointF &offset) +{ +} + +void WorldItemZone::radiusOn(const qreal radius) +{ +} + +QRectF WorldItemZone::boundingRect() const +{ + return m_polygon.boundingRect(); +} + +QPainterPath WorldItemZone::shape() const +{ + QPainterPath path; + path.addPolygon(m_polygon); + return qt_graphicsItem_shapeFromPath(path, m_pen); +} + +void WorldItemZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) +{ + if (option->state & QStyle::State_Selected) + { + painter->setPen(m_selectedPen); + painter->setBrush(m_selectedBrush); + } + else + { + painter->setPen(m_pen); + painter->setBrush(m_brush); + } + + painter->drawPolygon(m_polygon); +} + +QVariant WorldItemZone::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemPositionHasChanged) + { + } + return QGraphicsItem::itemChange(change, value); +} + +} /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h new file mode 100644 index 000000000..6c144518c --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -0,0 +1,237 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef WORLD_EDITOR_SCENE_ITEM_H +#define WORLD_EDITOR_SCENE_ITEM_H + +// Project includes +#include "world_editor_global.h" + +// NeL includes + +// Qt includes +#include +#include +#include +#include +#include +#include + +namespace WorldEditor +{ +class GraphicsItemZone; +class GraphicsItemNode; + +typedef QPair LineNode; + +const int SELECTED_LAYER = 200; +const int UNSELECTED_LAYER = 100; +const int WORLD_ZONE_LAYER = 100; +const int WORLD_POINT_LAYER = 200; +const int WORLD_PATH_LAYER = 200; +const int MIDDLE_POINT_LAYER = 201; +const int EDGE_POINT_LAYER = 201; + +/* +// Deprecated +class GraphicsItemNode: public QGraphicsObject +{ + Q_OBJECT + Q_PROPERTY(QColor colorNode READ colorNode WRITE setColorNode) +public: + enum NodeType + { + EdgeType = 0, + MiddleType + }; + + GraphicsItemNode(GraphicsItemZone *itemZone, QGraphicsItem *parent = 0); + virtual ~GraphicsItemNode(); + + void setColorNode(const QColor &color); + QColor colorNode() const + { + return m_color; + } + + void setNodeType(NodeType nodeType); + + virtual QRectF boundingRect() const; + //QPainterPath shape() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +protected: + virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); + +private: + + NodeType m_type; + GraphicsItemZone *m_itemZone; + QColor m_color; +}; + +// Deprecated +class GraphicsItemZone: public QGraphicsPolygonItem +{ +public: + GraphicsItemZone(QGraphicsScene *scene, QGraphicsItem *parent = 0); + virtual ~GraphicsItemZone(); + + void scanPolygon(const QPolygonF &polygon); + void updateMiddleNode(GraphicsItemNode *node); + bool deleteEdgePoint(GraphicsItemNode *node); + //void addNode(GraphicsItemNode *node); + void updateZone(); + //QRectF boundingRect() const; + //void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +protected: + // QVariant itemChange(GraphicsItemChange change, const QVariant &value); + +private: + struct LineItem + { + GraphicsItemNode *itemPoint; + LineNode lineNode; + }; + QGraphicsScene *m_scene; + QColor m_color; + QList m_listItems; + QList m_listLines; +}; +*/ + +/* +@class WorldItemPoint +@brief +@details +*/ +class AbstractWorldItem: public QGraphicsItem +{ +public: + AbstractWorldItem(QGraphicsItem *parent = 0); + virtual ~AbstractWorldItem(); + + enum { Type = QGraphicsItem::UserType + 1 }; + + virtual void moveOn(const QPointF &offset) = 0; + virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) = 0; + // TODO: add modes: IgnoreAspectRatio, KeepAspectRatio + virtual void scaleOn(const QPointF &pivot, const QPointF &offset) = 0; + virtual void turnOn(const QPointF &offset) = 0; + virtual void radiusOn(const qreal radius) = 0; + + // Enable the use of qgraphicsitem_cast with this item. + int type() const; +}; + +/* +@class WorldItemPoint +@brief +@details +*/ +class WorldItemPoint: public AbstractWorldItem +{ +public: + WorldItemPoint(const QPointF &point, const float angle, QGraphicsItem *parent = 0); + virtual ~WorldItemPoint(); + + virtual void moveOn(const QPointF &offset); + virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); + virtual void scaleOn(const QPointF &pivot, const QPointF &offset); + virtual void turnOn(const QPointF &offset); + virtual void radiusOn(const qreal radius); + + virtual QRectF boundingRect() const; + virtual QPainterPath shape() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +protected: + virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); + +private: + + // TODO + static const int SIZE_POINT = 7; + + QPen m_pen, m_selectedPen; + QBrush m_brush, m_selectedBrush; + + QRectF m_rect; + float m_angle; +}; + +/* +@class WorldItemPath +@brief +@details +*/ +class WorldItemPath: public AbstractWorldItem +{ +public: + WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent = 0); + virtual ~WorldItemPath(); + + virtual void moveOn(const QPointF &offset); + virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); + virtual void scaleOn(const QPointF &pivot, const QPointF &offset); + virtual void turnOn(const QPointF &offset); + virtual void radiusOn(const qreal radius); + + virtual QRectF boundingRect() const; + virtual QPainterPath shape() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +protected: + virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); + + QPen m_pen, m_selectedPen; + QPolygonF m_polygon; +}; + +/* +@class WorldItemZone +@brief +@details +*/ +class WorldItemZone: public AbstractWorldItem +{ +public: + WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent = 0); + virtual ~WorldItemZone(); + + virtual void moveOn(const QPointF &offset); + virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); + virtual void scaleOn(const QPointF &pivot, const QPointF &offset); + virtual void turnOn(const QPointF &offset); + virtual void radiusOn(const qreal radius); + + virtual QRectF boundingRect() const; + virtual QPainterPath shape() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +protected: + virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); + + QPen m_pen, m_selectedPen; + QBrush m_brush, m_selectedBrush; + QPolygonF m_polygon; +}; + +} /* namespace WorldEditor */ + +#endif // WORLD_EDITOR_SCENE_ITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 132b52b70..ac46491f3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -21,6 +21,8 @@ #include "world_editor_scene.h" #include "world_editor_misc.h" #include "world_editor_actions.h" +#include "world_editor_scene_item.h" +#include "project_settings_dialog.h" // Core #include "../core/icore.h" @@ -31,14 +33,9 @@ #include "../landscape_editor/builder_zone_base.h" // NeL includes -#include -#include -#include -#include // Qt includes #include -#include #include namespace WorldEditor @@ -57,6 +54,7 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_worldEditorScene->setZoneBuilder(m_zoneBuilderBase); m_ui.graphicsView->setScene(m_worldEditorScene); + m_ui.graphicsView->setVisibleText(false); QActionGroup *sceneModeGroup = new QActionGroup(this); sceneModeGroup->addAction(m_ui.selectAction); @@ -70,20 +68,38 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_ui.newWorldEditAction->setIcon(QIcon(Core::Constants::ICON_NEW)); m_ui.saveWorldEditAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); - m_primitivesModel = new PrimitivesTreeModel(); + m_primitivesModel = new PrimitivesTreeModel(this); m_ui.treePrimitivesView->setModel(m_primitivesModel); // TODO: ? m_ui.treePrimitivesView->setUndoStack(m_undoStack); m_ui.treePrimitivesView->setZoneBuilder(m_zoneBuilderBase); + m_ui.treePrimitivesView->setWorldScene(m_worldEditorScene); createMenus(); createToolBars(); readSettings(); + QSignalMapper *m_modeMapper = new QSignalMapper(this); + connect(m_ui.selectAction, SIGNAL(triggered()), m_modeMapper, SLOT(map())); + m_modeMapper->setMapping(m_ui.selectAction, 0); + connect(m_ui.moveAction, SIGNAL(triggered()), m_modeMapper, SLOT(map())); + m_modeMapper->setMapping(m_ui.moveAction, 1); + connect(m_ui.rotateAction, SIGNAL(triggered()), m_modeMapper, SLOT(map())); + m_modeMapper->setMapping(m_ui.rotateAction, 2); + connect(m_ui.scaleAction, SIGNAL(triggered()), m_modeMapper, SLOT(map())); + m_modeMapper->setMapping(m_ui.scaleAction, 3); + connect(m_ui.turnAction, SIGNAL(triggered()), m_modeMapper, SLOT(map())); + m_modeMapper->setMapping(m_ui.turnAction, 4); + connect(m_ui.radiusAction, SIGNAL(triggered()), m_modeMapper, SLOT(map())); + m_modeMapper->setMapping(m_ui.radiusAction, 5); + + connect(m_modeMapper, SIGNAL(mapped(int)), this, SLOT(setMode(int))); + connect(m_ui.pointsAction, SIGNAL(triggered(bool)), m_worldEditorScene, SLOT(setEnabledEditPoint(bool))); + + connect(m_ui.settingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings())); connect(m_ui.newWorldEditAction, SIGNAL(triggered()), this, SLOT(newWorldEditFile())); connect(m_ui.saveWorldEditAction, SIGNAL(triggered()), this, SLOT(saveWorldEditFile())); - } WorldEditorWindow::~WorldEditorWindow() @@ -118,6 +134,7 @@ void WorldEditorWindow::loadWorldEditFile(const QString &fileName) Utils::WorldEditList worldEditList; if (!Utils::loadWorldEditFile(fileName.toStdString(), worldEditList)) { + // TODO: add the message box return; } @@ -139,7 +156,7 @@ void WorldEditorWindow::loadWorldEditFile(const QString &fileName) m_undoStack->push(new LoadLandscapeCommand(QString(worldEditList[i].second.c_str()), m_primitivesModel, m_zoneBuilderBase)); break; case Utils::PrimitiveType: - m_undoStack->push(new LoadRootPrimitiveCommand(QString(worldEditList[i].second.c_str()), m_primitivesModel)); + m_undoStack->push(new LoadRootPrimitiveCommand(QString(worldEditList[i].second.c_str()), m_worldEditorScene, m_primitivesModel)); break; }; } @@ -163,15 +180,55 @@ void WorldEditorWindow::saveWorldEditFile() void WorldEditorWindow::openProjectSettings() { - /* - LandscapeEditor::ProjectSettingsDialog *dialog = new LandscapeEditor::ProjectSettingsDialog("", this); - dialog->show(); - int ok = dialog->exec(); - if (ok == QDialog::Accepted) - { - } - delete dialog; - */ + ProjectSettingsDialog *dialog = new ProjectSettingsDialog(m_zoneBuilderBase->dataPath(), this); + dialog->show(); + int ok = dialog->exec(); + if (ok == QDialog::Accepted) + { + m_zoneBuilderBase->init(dialog->dataPath(), true); + } + delete dialog; +} + +void WorldEditorWindow::setMode(int value) +{ + switch (value) + { + case 0: + m_worldEditorScene->setModeEdit(WorldEditorScene::SelectMode); + break; + case 1: + m_worldEditorScene->setModeEdit(WorldEditorScene::MoveMode); + break; + case 2: + m_worldEditorScene->setModeEdit(WorldEditorScene::RotateMode); + break; + case 3: + m_worldEditorScene->setModeEdit(WorldEditorScene::ScaleMode); + break; + case 4: + m_worldEditorScene->setModeEdit(WorldEditorScene::TurnMode); + break; + case 5: + m_worldEditorScene->setModeEdit(WorldEditorScene::RadiusMode); + break; + } +} + +void WorldEditorWindow::showEvent(QShowEvent *showEvent) +{ + QMainWindow::showEvent(showEvent); + if (m_oglWidget != 0) + m_oglWidget->makeCurrent(); + //m_statusInfo->show(); + //m_statusBarTimer->start(100); +} + +void WorldEditorWindow::hideEvent(QHideEvent *hideEvent) +{ + QMainWindow::hideEvent(hideEvent); + //m_statusInfo->hide(); + //m_statusBarTimer->stop(); } void WorldEditorWindow::createMenus() @@ -211,6 +268,14 @@ void WorldEditorWindow::readSettings() settings->beginGroup(Constants::WORLD_EDITOR_SECTION); restoreState(settings->value(Constants::WORLD_WINDOW_STATE).toByteArray()); restoreGeometry(settings->value(Constants::WORLD_WINDOW_GEOMETRY).toByteArray()); + + // Use OpenGL graphics system instead raster graphics system + if (settings->value(Constants::WORLD_EDITOR_USE_OPENGL, true).toBool()) + { + m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); + m_ui.graphicsView->setViewport(m_oglWidget); + } + settings->endGroup(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 2536bcc1c..321c46c3e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -22,6 +22,8 @@ // Qt includes #include +#include +#include namespace LandscapeEditor { @@ -52,6 +54,12 @@ private Q_SLOTS: void saveWorldEditFile(); void openProjectSettings(); + void setMode(int value); + +protected: + virtual void showEvent(QShowEvent *showEvent); + virtual void hideEvent(QHideEvent *hideEvent); + private: void createMenus(); void createToolBars(); @@ -67,6 +75,8 @@ private: QUndoStack *m_undoStack; WorldEditorScene *m_worldEditorScene; LandscapeEditor::ZoneBuilderBase *m_zoneBuilderBase; + QSignalMapper m_modeMapper; + QGLWidget *m_oglWidget; Ui::WorldEditorWindow m_ui; }; /* class WorldEditorWindow */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index 80e4e5ace..37f56ca11 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -21,8 +21,14 @@ + + true + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + - QGraphicsView::RubberBandDrag + QGraphicsView::NoDrag QGraphicsView::AnchorUnderMouse @@ -30,6 +36,12 @@ QGraphicsView::AnchorUnderMouse + + QGraphicsView::BoundingRectViewportUpdate + + + QGraphicsView::DontAdjustForAntialiasing|QGraphicsView::DontClipPainter + @@ -87,9 +99,6 @@ QAbstractItemView::ExtendedSelection - - true - true @@ -117,6 +126,8 @@ + + @@ -137,19 +148,22 @@ loadLand - + :/icons/ic_nel_landscape_settings.png:/icons/ic_nel_landscape_settings.png - LandSettings + Settings true + + false + S/H Land @@ -158,6 +172,9 @@ true + + false + S/H Primitives @@ -166,6 +183,9 @@ true + + false + S/H Layers @@ -174,6 +194,9 @@ true + + false + S/H Details @@ -182,6 +205,9 @@ true + + false + :/icons/ic_grid.png:/icons/ic_grid.png @@ -194,6 +220,9 @@ true + + false + S/H Grid points @@ -260,6 +289,9 @@ true + + false + :/icons/ic_nel_turn.png:/icons/ic_nel_turn.png @@ -272,6 +304,9 @@ true + + false + Radius @@ -280,10 +315,22 @@ true + + false + Edit points + + + + :/icons/ic_nel_landscape_settings.png:/icons/ic_nel_landscape_settings.png + + + Project settings + + From 974c5a0c52b8eb7259485fa7fa36b5ee4d3da7c6 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 10 Aug 2011 03:04:31 +0300 Subject: [PATCH 046/747] Fixed: #1301 Added max and min zooming. --- .../landscape_editor/landscape_view.cpp | 39 ++++++------------- .../plugins/landscape_editor/landscape_view.h | 2 +- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index 6cc6b159e..10e1348df 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -33,17 +33,15 @@ namespace LandscapeEditor LandscapeView::LandscapeView(QWidget *parent) : QGraphicsView(parent), m_visibleGrid(true), - m_visibleText(false) + m_visibleText(true) { - //setDragMode(ScrollHandDrag); setTransformationAnchor(AnchorUnderMouse); setBackgroundBrush(QBrush(Qt::lightGray)); - //setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - //setRenderHints(QPainter::Antialiasing); - //setCacheMode(QGraphicsView::CacheBackground); + m_cellSize = 160; - m_numSteps = 0; - m_maxSteps = 20; + m_maxView = 0.06; + m_minView = 32.0; + m_maxViewText = 0.6; //A modified version of centerOn(), handles special cases setCenter(QPointF(500.0, 500.0)); @@ -72,25 +70,7 @@ void LandscapeView::setVisibleText(bool visible) void LandscapeView::wheelEvent(QWheelEvent *event) { - /* double numDegrees = event->delta() / 8.0; - double numSteps = numDegrees / 15.0; - double factor = std::pow(1.125, numSteps); - if (factor > 1.0) - { - // check max scale view - if (m_numSteps > m_maxSteps) - return; - ++m_numSteps; - } - else - { - // check min scale view - if (m_numSteps < -m_maxSteps) - return; - --m_numSteps; - } - scale(factor, factor); - QGraphicsView::wheelEvent(event);*/ + //nlinfo(QString("%1").arg(transform().m11()).toStdString().c_str()); //Get the position of the mouse before scaling, in scene coords QPointF pointBeforeScale(mapToScene(event->pos())); @@ -102,11 +82,16 @@ void LandscapeView::wheelEvent(QWheelEvent *event) double scaleFactor = 1.15; //How fast we zoom if(event->delta() > 0) { + if (transform().m11() > m_minView ) + return; //Zoom in scale(scaleFactor, scaleFactor); } else { + if (transform().m11() < m_maxView ) + return; + //Zooming out scale(1.0 / scaleFactor, 1.0 / scaleFactor); } @@ -242,7 +227,7 @@ void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect) if (!m_visibleText) return; - if (m_numSteps > -m_maxSteps / 4) + if (transform().m11() > m_maxViewText) { painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); //painter->setFont(QFont("Helvetica [Cronyx]", 12)); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h index 607afe60f..5ce1fb3a7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -59,7 +59,7 @@ protected: private: bool m_visibleGrid, m_visibleText; - int m_numSteps, m_maxSteps; + qreal m_maxView, m_minView, m_maxViewText; int m_cellSize; //Holds the current centerpoint for the view, used for panning and zooming From 619fd9c9975928b334c3413c499df3c3073224ac Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 10 Aug 2011 14:59:23 +0300 Subject: [PATCH 047/747] Changed: #1302 Added status bar and inactive world editor settings page. --- .../landscape_editor/landscape_scene_base.cpp | 2 +- .../src/plugins/world_editor/CMakeLists.txt | 2 + .../colors_workspace_settings_page.ui | 44 ++++++ .../world_editor/world_editor_plugin.cpp | 5 + .../world_editor_settings_page.cpp | 71 +++++++++ .../world_editor/world_editor_settings_page.h | 59 ++++++++ .../world_editor_settings_page.ui | 137 ++++++++++++++++++ .../world_editor/world_editor_window.cpp | 24 ++- .../world_editor/world_editor_window.h | 6 + .../world_editor/world_editor_window.ui | 5 +- 10 files changed, 348 insertions(+), 7 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp index 9ae8d9bbd..2027831ae 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene_base.cpp @@ -283,7 +283,7 @@ QString LandscapeSceneBase::zoneNameFromMousePos() const (m_posX < 0) || (m_posX > MAX_SCENE_WIDTH)) return "NOT A VALID ZONE"; - return QString("%1_%2%3 %4 %5 ").arg(-m_posY).arg(QChar('A' + (m_posX/26))). + return QString("%1_%2%3 %4 %5 ").arg(-m_posY+1).arg(QChar('A' + (m_posX/26))). arg(QChar('A' + (m_posX%26))).arg(m_mouseX, 0,'f',2).arg(-m_mouseY, 0,'f',2); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt index 07d7fa5d1..7b9387c44 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt @@ -16,10 +16,12 @@ SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h primitives_model.h primitives_view.h project_settings_dialog.h + world_editor_settings_page.h ) SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui project_settings_dialog.ui + world_editor_settings_page.ui ) SET(OVQT_PLUGIN_WORLD_EDITOR_RCS world_editor.qrc) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui new file mode 100644 index 000000000..de6e77901 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui @@ -0,0 +1,44 @@ + + + WorldEditorSettingsPage + + + + 0 + 0 + 329 + 239 + + + + Form + + + + + + Colors + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp index 90d2de6d6..051d403ea 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp @@ -18,6 +18,7 @@ // Project includes #include "world_editor_plugin.h" #include "world_editor_window.h" +#include "world_editor_settings_page.h" #include "../core/icore.h" #include "../core/core_constants.h" @@ -47,6 +48,10 @@ WorldEditorPlugin::~WorldEditorPlugin() bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) { m_plugMan = pluginManager; + + WorldEditorSettingsPage *weSettings = new WorldEditorSettingsPage(this); + addAutoReleasedObject(weSettings); + QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(Constants::WORLD_EDITOR_SECTION); m_ligoConfig.CellSize = settings->value(Constants::WORLD_EDITOR_CELL_SIZE, "160").toFloat(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.cpp new file mode 100644 index 000000000..f3b3e6551 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.cpp @@ -0,0 +1,71 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "world_editor_settings_page.h" +#include "world_editor_constants.h" + +// Qt includes +#include + +// NeL includes + +namespace WorldEditor +{ + +WorldEditorSettingsPage::WorldEditorSettingsPage(QObject *parent) + : IOptionsPage(parent), + m_currentPage(NULL) +{ +} + +QString WorldEditorSettingsPage::id() const +{ + return QLatin1String(Constants::WORLD_EDITOR_PLUGIN); +} + +QString WorldEditorSettingsPage::trName() const +{ + return tr("General"); +} + +QString WorldEditorSettingsPage::category() const +{ + return QLatin1String(Constants::WORLD_EDITOR_PLUGIN); +} + +QString WorldEditorSettingsPage::trCategory() const +{ + return tr("World Editor"); +} + +QIcon WorldEditorSettingsPage::categoryIcon() const +{ + return QIcon(); +} + +QWidget *WorldEditorSettingsPage::createPage(QWidget *parent) +{ + m_currentPage = new QWidget(parent); + m_ui.setupUi(m_currentPage); + return m_currentPage; +} + +void WorldEditorSettingsPage::apply() +{ +} + +} /* namespace WorldEditor */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.h new file mode 100644 index 000000000..27cda963e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.h @@ -0,0 +1,59 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef WORLD_EDITOR_SETTINGS_PAGE_H +#define WORLD_EDITOR_SETTINGS_PAGE_H + +#include + +#include "../core/ioptions_page.h" + +#include "ui_world_editor_settings_page.h" + +class QWidget; + +namespace WorldEditor +{ + +/** +@class WorldEditorSettingsPage +*/ +class WorldEditorSettingsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + WorldEditorSettingsPage(QObject *parent = 0); + virtual ~WorldEditorSettingsPage() {} + + virtual QString id() const; + virtual QString trName() const; + virtual QString category() const; + virtual QString trCategory() const; + QIcon categoryIcon() const; + virtual QWidget *createPage(QWidget *parent); + + virtual void apply(); + virtual void finish() {} + +private: + QWidget *m_currentPage; + Ui::WorldEditorSettingsPage m_ui; +}; + +} // namespace WorldEditor + +#endif // WORLD_EDITOR_SETTINGS_PAGE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.ui new file mode 100644 index 000000000..9219da6c4 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.ui @@ -0,0 +1,137 @@ + + + WorldEditorSettingsPage + + + false + + + + 0 + 0 + 329 + 239 + + + + Form + + + + 6 + + + 3 + + + + + Workspace + + + + + + Top Left + + + + + + + + + + + + + Bottom Right + + + + + + + + + + + + + Use OpenGL + + + + + + + + + + Ligoscape + + + + + + Cell size + + + + + + + + + + Snap + + + + + + + + + + Ligo class + + + + + + + + + + + + ... + + + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index ac46491f3..52c4cd460 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -37,6 +37,7 @@ // Qt includes #include #include +#include namespace WorldEditor { @@ -54,7 +55,7 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_worldEditorScene->setZoneBuilder(m_zoneBuilderBase); m_ui.graphicsView->setScene(m_worldEditorScene); - m_ui.graphicsView->setVisibleText(false); + //m_ui.graphicsView->setVisibleText(false); QActionGroup *sceneModeGroup = new QActionGroup(this); sceneModeGroup->addAction(m_ui.selectAction); @@ -100,6 +101,14 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) connect(m_ui.settingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings())); connect(m_ui.newWorldEditAction, SIGNAL(triggered()), this, SLOT(newWorldEditFile())); connect(m_ui.saveWorldEditAction, SIGNAL(triggered()), this, SLOT(saveWorldEditFile())); + connect(m_ui.visibleGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool))); + + m_statusBarTimer = new QTimer(this); + connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); + + m_statusInfo = new QLabel(this); + m_statusInfo->hide(); + Core::ICore::instance()->mainWindow()->statusBar()->addPermanentWidget(m_statusInfo); } WorldEditorWindow::~WorldEditorWindow() @@ -215,20 +224,25 @@ void WorldEditorWindow::setMode(int value) } } +void WorldEditorWindow::updateStatusBar() +{ + m_statusInfo->setText(m_worldEditorScene->zoneNameFromMousePos()); +} + void WorldEditorWindow::showEvent(QShowEvent *showEvent) { QMainWindow::showEvent(showEvent); if (m_oglWidget != 0) m_oglWidget->makeCurrent(); - //m_statusInfo->show(); - //m_statusBarTimer->start(100); + m_statusInfo->show(); + m_statusBarTimer->start(100); } void WorldEditorWindow::hideEvent(QHideEvent *hideEvent) { QMainWindow::hideEvent(hideEvent); - //m_statusInfo->hide(); - //m_statusBarTimer->stop(); + m_statusInfo->hide(); + m_statusBarTimer->stop(); } void WorldEditorWindow::createMenus() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 321c46c3e..65d39ac58 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -22,6 +22,8 @@ // Qt includes #include +#include +#include #include #include @@ -55,6 +57,7 @@ private Q_SLOTS: void openProjectSettings(); void setMode(int value); + void updateStatusBar(); protected: virtual void showEvent(QShowEvent *showEvent); @@ -71,6 +74,9 @@ private: QString m_lastDir; + QLabel *m_statusInfo; + QTimer *m_statusBarTimer; + PrimitivesTreeModel *m_primitivesModel; QUndoStack *m_undoStack; WorldEditorScene *m_worldEditorScene; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index 37f56ca11..f5dc5f408 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -205,8 +205,11 @@ true + + true + - false + true From f6143832005bca38b4dc67db0c9307778e7ddd58 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 10 Aug 2011 15:00:47 +0300 Subject: [PATCH 048/747] Changed: #1302 Improved selection model. --- .../world_editor/world_editor_scene.cpp | 60 +++++++++++++------ .../plugins/world_editor/world_editor_scene.h | 5 +- .../world_editor/world_editor_scene_item.cpp | 2 + 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index fd2d85a24..1e21ee0ec 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -38,11 +38,17 @@ WorldEditorScene::WorldEditorScene(int sizeCell, QObject *parent) { setItemIndexMethod(NoIndex); - m_pen.setColor(QColor(50, 255, 155)); - m_pen.setWidth(0); + m_pen1.setColor(QColor(50, 255, 155)); + m_pen1.setWidth(0); - m_brush.setColor(QColor(50, 255, 155, 80)); - m_brush.setStyle(Qt::SolidPattern); + m_brush1.setColor(QColor(50, 255, 155, 80)); + m_brush1.setStyle(Qt::SolidPattern); + + m_pen2.setColor(QColor(100, 0, 255)); + m_pen2.setWidth(0); + + m_brush2.setColor(QColor(100, 0, 255, 80)); + m_brush2.setStyle(Qt::SolidPattern); } WorldEditorScene::~WorldEditorScene() @@ -75,8 +81,6 @@ void WorldEditorScene::setModeEdit(WorldEditorScene::ModeEdit mode) if (mode == WorldEditorScene::SelectMode) m_editedSelectedItems = false; - m_selectionArea = QRectF(); - m_mode = mode; } @@ -101,9 +105,18 @@ void WorldEditorScene::drawForeground(QPainter *painter, const QRectF &rect) if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) { - painter->setPen(m_pen); - painter->setBrush(m_brush); + if (m_selectionArea.left() < m_selectionArea.right()) + { + painter->setPen(m_pen1); + painter->setBrush(m_brush1); + } + else + { + painter->setPen(m_pen2); + painter->setBrush(m_brush2); + } painter->drawRect(m_selectionArea); + } } @@ -117,6 +130,8 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) if (mouseEvent->button() != Qt::LeftButton) return; + m_firstPick = mouseEvent->scenePos(); + // if ((!m_editedSelectedItems) && (m_mode != WorldEditorScene::SelectMode)) if ((!m_editedSelectedItems && m_selectedItems.isEmpty()) || (!calcBoundingShape(m_selectedItems).contains(mouseEvent->scenePos()))) @@ -217,7 +232,7 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) /*m_mouseX = mouseEvent->scenePos().x(); m_mouseY = mouseEvent->scenePos().y() - m_cellSize; */ - QGraphicsScene::mouseMoveEvent(mouseEvent); + LandscapeEditor::LandscapeSceneBase::mouseMoveEvent(mouseEvent); } void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) @@ -261,12 +276,11 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) updatePickSelection(mouseEvent->scenePos()); else m_firstSelection = false; - } -// Huck for standart selection model -// clearSelection(); -// updateSelectedItems(true); - QGraphicsScene::mouseReleaseEvent(mouseEvent); + m_selectionArea = QRectF(); + } + + LandscapeEditor::LandscapeSceneBase::mouseReleaseEvent(mouseEvent); } QRectF WorldEditorScene::calcBoundingRect(const QList &listItems) @@ -317,15 +331,23 @@ void WorldEditorScene::updatePickSelection(const QPointF &point) QList listItems = items(point, Qt::ContainsItemShape, Qt::AscendingOrder); - if (!listItems.isEmpty()) + + QList worldItemsItems; + + Q_FOREACH(QGraphicsItem *item, listItems) + { + AbstractWorldItem *worldItem = qgraphicsitem_cast(item); + if (worldItem != 0) + worldItemsItems.push_back(worldItem); + } + + if (!worldItemsItems.isEmpty()) { // Next primitives m_lastPickedPrimitive++; - m_lastPickedPrimitive %= listItems.size(); - QGraphicsItem *selectedItem = listItems.at(m_lastPickedPrimitive); - if (qgraphicsitem_cast(selectedItem) != 0) - m_selectedItems.push_back(selectedItem); + m_lastPickedPrimitive %= worldItemsItems.size(); + m_selectedItems.push_back(worldItemsItems.at(m_lastPickedPrimitive)); updateSelectedItems(true); } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index 36f27b9b4..b97b9672c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -80,9 +80,10 @@ private: void updatePickSelection(const QPointF &point); - QPen m_pen; - QBrush m_brush; + QPen m_pen1, m_pen2; + QBrush m_brush1, m_brush2; + QPointF m_firstPick; QRectF m_selectionArea; qreal m_firstPickX, m_firstPickY; QList m_selectedItems; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index f88c95b9a..d428aed51 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -328,6 +328,8 @@ WorldItemPoint::WorldItemPoint(const QPointF &point, const float angle, QGraphic { setZValue(WORLD_POINT_LAYER); + //setFlag(ItemIgnoresTransformations); + setPos(point); m_rect.setCoords(-SIZE_POINT, -SIZE_POINT, SIZE_POINT, SIZE_POINT); From 9f1befe46686aa29176786b887b7fdb5105c7d17 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 10 Aug 2011 17:13:06 +0300 Subject: [PATCH 049/747] Changed: #1302 Used setData(QVariant) instead setGraphicsData(). --- .../src/plugins/world_editor/primitive_item.cpp | 10 ---------- .../src/plugins/world_editor/primitive_item.h | 10 ++-------- .../src/plugins/world_editor/world_editor_actions.cpp | 11 +++++++++-- .../src/plugins/world_editor/world_editor_constants.h | 7 ++++++- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index 672bd2954..e948f8b0f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -132,16 +132,6 @@ void Node::setData(int key, const QVariant &data) m_data[key] = data; } -void Node::setGraphicsData(int key, void *pointerToData) -{ - m_graphicsData[key] = pointerToData; -} - -void *Node::graphicsData(int key) const -{ - return m_graphicsData[key]; -} - Node *Node::parent() { return m_parent; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 01c96c9d2..4940a622b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -35,9 +35,6 @@ class RootPrimitiveNode; class LandscapeNode; class PrimitiveNode; -const int GRAPHICS_DATA_QT2D = 0; -const int GRAPHICS_DATA_NEL3D = 1; - /* @class Node @brief @@ -93,10 +90,6 @@ public: /// Return this node's custom data for the key key as a QVariant. QVariant data(int key) const; - void setGraphicsData(int key, void *pointerToData); - - void *graphicsData(int key) const; - /// Return a type this node. virtual NodeType type() const; @@ -106,7 +99,6 @@ private: Node *m_parent; QList m_children; QHash m_data; - QHash m_graphicsData; }; /* @@ -183,4 +175,6 @@ private: } /* namespace WorldEditor */ +Q_DECLARE_METATYPE(WorldEditor::Node *) + #endif // PRIMITIVE_ITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index a654e8f31..4f69181c8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -16,6 +16,7 @@ // Project includes #include "world_editor_actions.h" +#include "world_editor_constants.h" #include "world_editor_misc.h" #include "primitive_item.h" #include "world_editor_scene.h" @@ -37,6 +38,7 @@ // Qt includes #include +#include namespace WorldEditor { @@ -89,8 +91,13 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode break; } } + QVariant variantNode; + variantNode.setValue(node); + item->setData(Constants::WORLD_EDITOR_NODE, variantNode); - node->setGraphicsData(GRAPHICS_DATA_QT2D, item); + QVariant graphicsData; + graphicsData.setValue(item); + node->setData(Constants::GRAPHICS_DATA_QT4_2D, graphicsData); } int count = model->rowCount(primIndex); @@ -112,7 +119,7 @@ void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode case NLLIGO::CPrimitiveClass::Path: case NLLIGO::CPrimitiveClass::Zone: { - QGraphicsItem *item = static_cast(node->graphicsData(GRAPHICS_DATA_QT2D)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); if (item != 0) delete item; break; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index 5c1d32908..e0bdc4705 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -1,5 +1,4 @@ // 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 @@ -24,6 +23,12 @@ namespace Constants { const char *const WORLD_EDITOR_PLUGIN = "WorldEditor"; +const int USER_TYPE = 65536; +const int NODE_PERISTENT_INDEX = USER_TYPE + 1; +const int WORLD_EDITOR_NODE = USER_TYPE + 2; +const int GRAPHICS_DATA_QT4_2D = USER_TYPE + 3; +const int GRAPHICS_DATA_NEL3D = USER_TYPE + 4; + //settings const char *const WORLD_EDITOR_SECTION = "WorldEditor"; const char *const WORLD_WINDOW_STATE = "WorldWindowState"; From bd39049113aa6a8fe16e7640deec37654645017d Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 10 Aug 2011 23:58:55 +0300 Subject: [PATCH 050/747] Changed: #1302 Added undo command (move, rotate, scale) --- .../plugins/world_editor/primitives_model.cpp | 22 +++ .../plugins/world_editor/primitives_model.h | 4 +- .../world_editor/world_editor_actions.cpp | 138 ++++++++++++++++++ .../world_editor/world_editor_actions.h | 73 ++++++++- .../world_editor/world_editor_scene.cpp | 82 +++++++++-- .../plugins/world_editor/world_editor_scene.h | 8 +- .../world_editor/world_editor_scene_item.cpp | 12 +- .../world_editor/world_editor_scene_item.h | 10 +- .../world_editor/world_editor_window.cpp | 20 +-- 9 files changed, 333 insertions(+), 36 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp index bc8925175..f59cb8d67 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp @@ -148,6 +148,18 @@ Path PrimitivesTreeModel::pathFromIndex(const QModelIndex &index) return path; } +Path PrimitivesTreeModel::pathFromNode(Node *node) +{ + Node *iter = node; + Path path; + while(iter != 0) + { + path.prepend(PathItem(iter->row(), 1)); + iter = iter->parent(); + } + return path; +} + QModelIndex PrimitivesTreeModel::pathToIndex(const Path &path) { QModelIndex iter; @@ -158,6 +170,16 @@ QModelIndex PrimitivesTreeModel::pathToIndex(const Path &path) return iter; } +Node *PrimitivesTreeModel::pathToNode(const Path &path) +{ + Node *node = m_rootNode; + for(int i = 1; i < path.size(); i++) + { + node = node->child(path[i].first); + } + return node; +} + void PrimitivesTreeModel::createWorldEditNode(const QString &fileName) { beginResetModel(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h index 7f9a90aa7..c3c6a3e51 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h @@ -68,10 +68,12 @@ public: /// @Path is a list of [row,column] pairs showing us the way through the model. Path pathFromIndex(const QModelIndex &index); - //Path pathFromNode(Node *index); + Path pathFromNode(Node *node); QModelIndex pathToIndex(const Path &path); + Node *pathToNode(const Path &path); + void createWorldEditNode(const QString &fileName); void deleteWorldEditNode(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 4f69181c8..c6ed1ee3e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -134,6 +134,24 @@ void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode } } +QList graphicsItemsToPaths(const QList &items, PrimitivesTreeModel *model) +{ + QList result; + Q_FOREACH(QGraphicsItem *item, items) + { + Node *node = qvariant_cast(item->data(Constants::WORLD_EDITOR_NODE)); + result.push_back(model->pathFromNode(node)); + } + return result; +} + +/* +QList pathsToGraphicsItems(const QList &items, PrimitivesTreeModel *model) +{ + QList result; +} +*/ + CreateWorldCommand::CreateWorldCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_fileName(fileName), @@ -325,4 +343,124 @@ void AddPrimitiveByClassCommand::redo() m_newPrimIndex = m_model->createPrimitiveNode(newPrimitive, m_parentIndex); } +MoveWorldItemsCommand::MoveWorldItemsCommand(const QList &items, const QPointF &offset, + PrimitivesTreeModel *model, QUndoCommand *parent) + : QUndoCommand(parent), + m_listPaths(graphicsItemsToPaths(items, model)), + m_offset(offset), + m_model(model), + m_firstRun(true) +{ + setText("Move item(s)"); +} + +MoveWorldItemsCommand::~MoveWorldItemsCommand() +{ +} + +void MoveWorldItemsCommand::undo() +{ + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + qgraphicsitem_cast(item)->moveOn(-m_offset); + } +} + +void MoveWorldItemsCommand::redo() +{ + if (!m_firstRun) + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + qgraphicsitem_cast(item)->moveOn(m_offset); + } + } + m_firstRun = false; +} + +RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &items, const qreal &angle, + const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent) + : QUndoCommand(parent), + m_listPaths(graphicsItemsToPaths(items, model)), + m_angle(angle), + m_pivot(pivot), + m_model(model), + m_firstRun(true) +{ + setText("Rotate item(s)"); +} + +RotateWorldItemsCommand::~RotateWorldItemsCommand() +{ +} + +void RotateWorldItemsCommand::undo() +{ + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + qgraphicsitem_cast(item)->rotateOn(m_pivot, -m_angle); + } +} + +void RotateWorldItemsCommand::redo() +{ + if (!m_firstRun) + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + qgraphicsitem_cast(item)->rotateOn(m_pivot, m_angle); + } + } + m_firstRun = false; +} + +ScaleWorldItemsCommand::ScaleWorldItemsCommand(const QList &items, const QPointF &factor, + const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent) + : QUndoCommand(parent), + m_listPaths(graphicsItemsToPaths(items, model)), + m_factor(factor), + m_pivot(pivot), + m_model(model), + m_firstRun(true) +{ + setText("Scale item(s)"); +} + +ScaleWorldItemsCommand::~ScaleWorldItemsCommand() +{ +} + +void ScaleWorldItemsCommand::undo() +{ + QPointF m_invertFactor(1 / m_factor.x(), 1 / m_factor.y()); + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + qgraphicsitem_cast(item)->scaleOn(m_pivot, m_invertFactor); + } +} + +void ScaleWorldItemsCommand::redo() +{ + if (!m_firstRun) + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + qgraphicsitem_cast(item)->scaleOn(m_pivot, m_factor); + } + } + m_firstRun = false; +} + } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 7393861b0..7fd2015e0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -38,6 +38,8 @@ class WorldEditorScene; void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene); void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene); +QList graphicsItemsToPaths(const QList &items, PrimitivesTreeModel *model); +//QList pathsToGraphicsItems(const QList &items, PrimitivesTreeModel *model); /** @class CreateWorldCommand @@ -84,7 +86,8 @@ private: class CreateRootPrimitiveCommand: public QUndoCommand { public: - CreateRootPrimitiveCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent = 0); + CreateRootPrimitiveCommand(const QString &fileName, PrimitivesTreeModel *model, + QUndoCommand *parent = 0); virtual ~CreateRootPrimitiveCommand(); virtual void undo(); @@ -139,6 +142,74 @@ private: PrimitivesTreeModel *m_model; }; +/** +@class MoveWorldItemsCommand +@brief +@details +*/ +class MoveWorldItemsCommand: public QUndoCommand +{ +public: + MoveWorldItemsCommand(const QList &items, const QPointF &offset, + PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~MoveWorldItemsCommand(); + + virtual void undo(); + virtual void redo(); +private: + + const QList m_listPaths; + const QPointF m_offset; + PrimitivesTreeModel *const m_model; + bool m_firstRun; +}; + +/** +@class RotateWorldItemsCommand +@brief +@details +*/ +class RotateWorldItemsCommand: public QUndoCommand +{ +public: + RotateWorldItemsCommand(const QList &items, const qreal &angle, + const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~RotateWorldItemsCommand(); + + virtual void undo(); + virtual void redo(); +private: + + const QList m_listPaths; + const qreal m_angle; + const QPointF m_pivot; + PrimitivesTreeModel *const m_model; + bool m_firstRun; +}; + +/** +@class ScaleWorldItemsCommand +@brief +@details +*/ +class ScaleWorldItemsCommand: public QUndoCommand +{ +public: + ScaleWorldItemsCommand(const QList &items, const QPointF &factor, + const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~ScaleWorldItemsCommand(); + + virtual void undo(); + virtual void redo(); +private: + + const QList m_listPaths; + const QPointF m_factor; + const QPointF m_pivot; + PrimitivesTreeModel *const m_model; + bool m_firstRun; +}; + } /* namespace WorldEditor */ #endif // WORLD_EDITOR_ACTIONS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 1e21ee0ec..f722bea25 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -16,6 +16,8 @@ // Project includes #include "world_editor_scene.h" +#include "world_editor_scene_item.h" +#include "world_editor_actions.h" // NeL includes #include @@ -29,12 +31,14 @@ namespace WorldEditor { -WorldEditorScene::WorldEditorScene(int sizeCell, QObject *parent) +WorldEditorScene::WorldEditorScene(int sizeCell, PrimitivesTreeModel *model, QUndoStack *undoStack, QObject *parent) : LandscapeEditor::LandscapeSceneBase(sizeCell, parent), m_editedSelectedItems(false), m_lastPickedPrimitive(0), m_mode(SelectMode), - m_editMode(false) + m_editMode(false), + m_undoStack(undoStack), + m_model(model) { setItemIndexMethod(NoIndex); @@ -134,7 +138,7 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) // if ((!m_editedSelectedItems) && (m_mode != WorldEditorScene::SelectMode)) if ((!m_editedSelectedItems && m_selectedItems.isEmpty()) || - (!calcBoundingShape(m_selectedItems).contains(mouseEvent->scenePos()))) + (!calcBoundingRect(m_selectedItems).contains(mouseEvent->scenePos()))) { updatePickSelection(mouseEvent->scenePos()); m_firstSelection = true; @@ -190,29 +194,38 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) } case WorldEditorScene::RotateMode: { - QRectF pivot = calcBoundingRect(m_selectedItems); + QPointF pivot = calcBoundingRect(m_selectedItems).center(); // Caluculate angle between two line - QLineF firstLine(pivot.center(), mouseEvent->lastScenePos()); - QLineF secondLine(pivot.center(), mouseEvent->scenePos()); + QLineF firstLine(pivot, mouseEvent->lastScenePos()); + QLineF secondLine(pivot, mouseEvent->scenePos()); qreal angle = secondLine.angleTo(firstLine); Q_FOREACH(QGraphicsItem *item, m_selectedItems) { - qgraphicsitem_cast(item)->rotateOn(pivot.center(), angle); + qgraphicsitem_cast(item)->rotateOn(pivot, angle); } break; } case WorldEditorScene::ScaleMode: { - // float scale = (_SelectionMin.x - _SelectionMax.x + _SelectionMax.y - _SelectionMin.y) * SCALE_PER_PIXEL + 1.f; - // moveAction->setScale (std::max (0.001f, scale), _MainFrame->getTransformMode ()==CMainFrame::Scale, radius); - // TODO: perfomance - QRectF pivot = calcBoundingRect(m_selectedItems); + QPointF pivot = calcBoundingRect(m_selectedItems).center(); + + // Calculate scale factor + if (offset.x() > 0) + offset.setX(1.0 + (offset.x() / 5000)); + else + offset.setX(1.0 / (1.0 + (-offset.x() / 5000))); + + if (offset.y() < 0) + offset.setY(1.0 + (-offset.y() / 5000)); + else + offset.setY(1.0 / (1.0 + (offset.y() / 5000))); + Q_FOREACH(QGraphicsItem *item, m_selectedItems) { - qgraphicsitem_cast(item)->scaleOn(pivot.center(), offset); + qgraphicsitem_cast(item)->scaleOn(pivot, offset); } break; } @@ -240,6 +253,51 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) if (mouseEvent->button() != Qt::LeftButton) return; + if (m_editedSelectedItems) + { + switch (m_mode) + { + case WorldEditorScene::SelectMode: + break; + + case WorldEditorScene::MoveMode: + { + QPointF offset = mouseEvent->scenePos() - m_firstPick; + + m_undoStack->push(new MoveWorldItemsCommand(m_selectedItems, offset, m_model)); + break; + } + case WorldEditorScene::RotateMode: + { + QPointF pivot = calcBoundingRect(m_selectedItems).center(); + + // Caluculate angle between two line + QLineF firstLine(pivot, m_firstPick); + QLineF secondLine(pivot, mouseEvent->scenePos()); + qreal angle = secondLine.angleTo(firstLine); + + m_undoStack->push(new RotateWorldItemsCommand(m_selectedItems, angle, pivot, m_model)); + break; + } + case WorldEditorScene::ScaleMode: + { + QPointF pivot = calcBoundingRect(m_selectedItems).center(); + QPointF offset = mouseEvent->scenePos() - m_firstPick; + + // Calculate scale factor + offset.setX(1.0 + (offset.x() / 5000)); + offset.setY(1.0 + (-offset.y() / 5000)); + + m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, offset, pivot, m_model)); + break; + } + case WorldEditorScene::TurnMode: + break; + case WorldEditorScene::RadiusMode: + break; + }; + } + if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) { QList listItems; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index b97b9672c..defd59651 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -19,16 +19,17 @@ // Project includes #include "world_editor_global.h" -#include "world_editor_scene_item.h" #include "../landscape_editor/landscape_scene_base.h" // NeL includes // Qt includes +#include namespace WorldEditor { +class PrimitivesTreeModel; /* @class WorldEditorScene @@ -50,7 +51,8 @@ public: RadiusMode }; - WorldEditorScene(int sizeCell = 160, QObject *parent = 0); + WorldEditorScene(int sizeCell, PrimitivesTreeModel *model, + QUndoStack *undoStack, QObject *parent = 0); virtual ~WorldEditorScene(); QGraphicsItem *addWorldItemPoint(const QPointF &point, const float angle); @@ -91,6 +93,8 @@ private: uint m_lastPickedPrimitive; ModeEdit m_mode; bool m_editMode; + QUndoStack *m_undoStack; + PrimitivesTreeModel *m_model; }; } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index d428aed51..31f63dc05 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -378,7 +378,7 @@ void WorldItemPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle) setPos(rotatedPolygon.boundingRect().center()); } -void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &offset) +void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &factor) { prepareGeometryChange(); @@ -389,7 +389,7 @@ void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &offset) scaledPolygon.translate(-pivot); QTransform trans; - trans = trans.scale(1.0 + (offset.x() / 5000), 1.0 + (-offset.y() / 5000)); + trans = trans.scale(factor.x(), factor.y()); scaledPolygon = trans.map(scaledPolygon); scaledPolygon.translate(pivot); @@ -485,7 +485,7 @@ void WorldItemPath::rotateOn(const QPointF &pivot, const qreal deltaAngle) m_polygon.translate(pivot); } -void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &offset) +void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &factor) { prepareGeometryChange(); @@ -493,7 +493,7 @@ void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &offset) scaledPolygon.translate(-pivot); QTransform trans; - trans = trans.scale(1.0 + (offset.x() / 5000), 1.0 + (-offset.y() / 5000)); + trans = trans.scale(factor.x(), factor.y()); m_polygon = trans.map(scaledPolygon); m_polygon.translate(pivot); @@ -590,7 +590,7 @@ void WorldItemZone::rotateOn(const QPointF &pivot, const qreal deltaAngle) m_polygon.translate(pivot); } -void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &offset) +void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &factor) { prepareGeometryChange(); @@ -598,7 +598,7 @@ void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &offset) scaledPolygon.translate(-pivot); QTransform trans; - trans = trans.scale(1.0 + (offset.x() / 5000), 1.0 + (-offset.y() / 5000)); + trans = trans.scale(factor.x(), factor.y()); m_polygon = trans.map(scaledPolygon); m_polygon.translate(pivot); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index 6c144518c..6f1669786 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -131,7 +131,7 @@ public: virtual void moveOn(const QPointF &offset) = 0; virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) = 0; // TODO: add modes: IgnoreAspectRatio, KeepAspectRatio - virtual void scaleOn(const QPointF &pivot, const QPointF &offset) = 0; + virtual void scaleOn(const QPointF &pivot, const QPointF &factor) = 0; virtual void turnOn(const QPointF &offset) = 0; virtual void radiusOn(const qreal radius) = 0; @@ -152,7 +152,7 @@ public: virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); - virtual void scaleOn(const QPointF &pivot, const QPointF &offset); + virtual void scaleOn(const QPointF &pivot, const QPointF &factor); virtual void turnOn(const QPointF &offset); virtual void radiusOn(const qreal radius); @@ -188,7 +188,7 @@ public: virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); - virtual void scaleOn(const QPointF &pivot, const QPointF &offset); + virtual void scaleOn(const QPointF &pivot, const QPointF &factor); virtual void turnOn(const QPointF &offset); virtual void radiusOn(const qreal radius); @@ -216,7 +216,7 @@ public: virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); - virtual void scaleOn(const QPointF &pivot, const QPointF &offset); + virtual void scaleOn(const QPointF &pivot, const QPointF &factor); virtual void turnOn(const QPointF &offset); virtual void radiusOn(const qreal radius); @@ -234,4 +234,6 @@ protected: } /* namespace WorldEditor */ +Q_DECLARE_METATYPE(WorldEditor::AbstractWorldItem *) + #endif // WORLD_EDITOR_SCENE_ITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 52c4cd460..fb0f1463d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -50,12 +50,20 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_ui.setupUi(this); m_undoStack = new QUndoStack(this); - m_worldEditorScene = new WorldEditorScene(NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->CellSize, this); + m_primitivesModel = new PrimitivesTreeModel(this); + + m_worldEditorScene = new WorldEditorScene(Utils::ligoConfig()->CellSize, m_primitivesModel, m_undoStack, this); m_zoneBuilderBase = new LandscapeEditor::ZoneBuilderBase(m_worldEditorScene); m_worldEditorScene->setZoneBuilder(m_zoneBuilderBase); m_ui.graphicsView->setScene(m_worldEditorScene); - //m_ui.graphicsView->setVisibleText(false); + m_ui.graphicsView->setVisibleText(false); + + m_ui.treePrimitivesView->setModel(m_primitivesModel); + // TODO: ? + m_ui.treePrimitivesView->setUndoStack(m_undoStack); + m_ui.treePrimitivesView->setZoneBuilder(m_zoneBuilderBase); + m_ui.treePrimitivesView->setWorldScene(m_worldEditorScene); QActionGroup *sceneModeGroup = new QActionGroup(this); sceneModeGroup->addAction(m_ui.selectAction); @@ -69,14 +77,6 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_ui.newWorldEditAction->setIcon(QIcon(Core::Constants::ICON_NEW)); m_ui.saveWorldEditAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); - m_primitivesModel = new PrimitivesTreeModel(this); - m_ui.treePrimitivesView->setModel(m_primitivesModel); - - // TODO: ? - m_ui.treePrimitivesView->setUndoStack(m_undoStack); - m_ui.treePrimitivesView->setZoneBuilder(m_zoneBuilderBase); - m_ui.treePrimitivesView->setWorldScene(m_worldEditorScene); - createMenus(); createToolBars(); readSettings(); From db2186293701f7542c74f3bc7e8e6d4c9f0facfc Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 11 Aug 2011 14:05:06 +0300 Subject: [PATCH 051/747] Fixed: #1302 Fixed undo/redo zoom items. --- .../src/plugins/world_editor/world_editor_scene.cpp | 11 +++++------ .../src/plugins/world_editor/world_editor_scene.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index f722bea25..6fba9f628 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -160,6 +160,7 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) case WorldEditorScene::RotateMode: break; case WorldEditorScene::ScaleMode: + m_scaleFactor = QPointF(1.0, 1.0); break; case WorldEditorScene::TurnMode: break; @@ -223,6 +224,9 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) else offset.setY(1.0 / (1.0 + (offset.y() / 5000))); + m_scaleFactor.setX(offset.x() * m_scaleFactor.x()); + m_scaleFactor.setY(offset.y() * m_scaleFactor.y()); + Q_FOREACH(QGraphicsItem *item, m_selectedItems) { qgraphicsitem_cast(item)->scaleOn(pivot, offset); @@ -282,13 +286,8 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) case WorldEditorScene::ScaleMode: { QPointF pivot = calcBoundingRect(m_selectedItems).center(); - QPointF offset = mouseEvent->scenePos() - m_firstPick; + m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, pivot, m_model)); - // Calculate scale factor - offset.setX(1.0 + (offset.x() / 5000)); - offset.setY(1.0 + (-offset.y() / 5000)); - - m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, offset, pivot, m_model)); break; } case WorldEditorScene::TurnMode: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index defd59651..408ba99b6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -85,7 +85,7 @@ private: QPen m_pen1, m_pen2; QBrush m_brush1, m_brush2; - QPointF m_firstPick; + QPointF m_firstPick, m_scaleFactor; QRectF m_selectionArea; qreal m_firstPickX, m_firstPickY; QList m_selectedItems; From fa774b51c7a85560cc271f41815a193dea9f4cd6 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 11 Aug 2011 14:14:56 +0300 Subject: [PATCH 052/747] Fixed: #1302 Fixed crash program. --- .../src/plugins/world_editor/world_editor_actions.cpp | 2 +- .../src/plugins/world_editor/world_editor_scene.cpp | 9 +++++++++ .../src/plugins/world_editor/world_editor_scene.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index c6ed1ee3e..440382b15 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -121,7 +121,7 @@ void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode { QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); if (item != 0) - delete item; + scene->removeWorldItem(item); break; } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 6fba9f628..7e2ac9c20 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -80,6 +80,15 @@ QGraphicsItem *WorldEditorScene::addWorldItemZone(const QPolygonF &polygon) return item; } +void WorldEditorScene::removeWorldItem(QGraphicsItem *item) +{ + updateSelectedItems(true); + m_selectedItems.clear(); + m_editedSelectedItems = false; + m_firstSelection = false; + delete item; +} + void WorldEditorScene::setModeEdit(WorldEditorScene::ModeEdit mode) { if (mode == WorldEditorScene::SelectMode) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index 408ba99b6..aa813c5c5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -59,6 +59,8 @@ public: QGraphicsItem *addWorldItemPath(const QPolygonF &polyline); QGraphicsItem *addWorldItemZone(const QPolygonF &polygon); + void removeWorldItem(QGraphicsItem *item); + void setModeEdit(WorldEditorScene::ModeEdit mode); WorldEditorScene::ModeEdit editMode() const; From c78e3c80fd27cd3a1652ef5517fa4b9a02ba1bc6 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 11 Aug 2011 22:58:45 +0300 Subject: [PATCH 053/747] Changed: #1302 Added the turn undo command. --- .../colors_workspace_settings_page.ui | 44 ------- .../world_editor/world_editor_actions.cpp | 108 +++++++++++++++--- .../world_editor/world_editor_actions.h | 25 +++- .../world_editor/world_editor_plugin.cpp | 4 +- .../world_editor/world_editor_scene.cpp | 59 +++++----- .../plugins/world_editor/world_editor_scene.h | 11 +- .../world_editor/world_editor_scene_item.cpp | 52 +++++++-- .../world_editor/world_editor_scene_item.h | 25 ++-- .../world_editor/world_editor_window.ui | 2 +- 9 files changed, 213 insertions(+), 117 deletions(-) delete mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui deleted file mode 100644 index de6e77901..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui +++ /dev/null @@ -1,44 +0,0 @@ - - - WorldEditorSettingsPage - - - - 0 - 0 - 329 - 239 - - - - Form - - - - - - Colors - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - - - diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 440382b15..780ea47a9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -52,13 +52,14 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode { NLLIGO::IPrimitive *primitive = node->primitive(); NLLIGO::CPrimVector *vec = 0; - QGraphicsItem *item; + AbstractWorldItem *item = 0; switch (node->primitiveClass()->Type) { case NLLIGO::CPrimitiveClass::Point: { vec = primitive->getPrimVector(); - item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), 0); + NLLIGO::CPrimPoint *primPoint = static_cast(primitive); + item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), primPoint->Angle); break; } case NLLIGO::CPrimitiveClass::Path: @@ -91,12 +92,44 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode break; } } + + if (item != 0) + { + // Get color from world_editor_classes.xml + NLMISC::CRGBA color = Utils::ligoConfig()->getPrimitiveColor(*primitive); + + /* + // Configurations (from world_editor_primitive_configuration.xml) + const std::vector &configurations = Utils::ligoConfig()->getPrimitiveConfiguration(); + + // Look for the configuration + sint search = 0; + bool colorFound = false; + while ((search = theApp.getActiveConfiguration (*primitive, search)) != -1) + { + // Configuration activated ? + if (theApp.Configurations[search].Activated) + { + colorFound = true; + mainColor = configurations[search].Color; + break; + } + search++; + } + + // try to get the primitive color ? + //if (!colorFound)*/ + primitive->getPropertyByName ("Color", color); + + item->setColor(QColor(color.R, color.G, color.B)); + } + QVariant variantNode; variantNode.setValue(node); item->setData(Constants::WORLD_EDITOR_NODE, variantNode); QVariant graphicsData; - graphicsData.setValue(item); + graphicsData.setValue(item); node->setData(Constants::GRAPHICS_DATA_QT4_2D, graphicsData); } @@ -119,7 +152,7 @@ void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode case NLLIGO::CPrimitiveClass::Path: case NLLIGO::CPrimitiveClass::Zone: { - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); if (item != 0) scene->removeWorldItem(item); break; @@ -363,8 +396,8 @@ void MoveWorldItemsCommand::undo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->moveOn(-m_offset); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->moveOn(-m_offset); } } @@ -375,14 +408,14 @@ void MoveWorldItemsCommand::redo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->moveOn(m_offset); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->moveOn(m_offset); } } m_firstRun = false; } -RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &items, const qreal &angle, +RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &items, const qreal angle, const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_listPaths(graphicsItemsToPaths(items, model)), @@ -391,7 +424,7 @@ RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &i m_model(model), m_firstRun(true) { - setText("Rotate item(s)"); + setText(QString("Rotate item(s) %1").arg(m_angle)); } RotateWorldItemsCommand::~RotateWorldItemsCommand() @@ -403,8 +436,8 @@ void RotateWorldItemsCommand::undo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->rotateOn(m_pivot, -m_angle); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->rotateOn(m_pivot, -m_angle); } } @@ -415,8 +448,8 @@ void RotateWorldItemsCommand::redo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->rotateOn(m_pivot, m_angle); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->rotateOn(m_pivot, m_angle); } } m_firstRun = false; @@ -444,8 +477,8 @@ void ScaleWorldItemsCommand::undo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->scaleOn(m_pivot, m_invertFactor); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->scaleOn(m_pivot, m_invertFactor); } } @@ -456,8 +489,47 @@ void ScaleWorldItemsCommand::redo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->scaleOn(m_pivot, m_factor); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->scaleOn(m_pivot, m_factor); + } + } + m_firstRun = false; +} + +TurnWorldItemsCommand::TurnWorldItemsCommand(const QList &items, const qreal angle, + PrimitivesTreeModel *model, QUndoCommand *parent) + : QUndoCommand(parent), + m_listPaths(graphicsItemsToPaths(items, model)), + m_angle(angle), + m_model(model), + m_firstRun(true) +{ + setText(QString("Turn item(s) %1").arg(m_angle)); +} + +TurnWorldItemsCommand::~TurnWorldItemsCommand() +{ +} + +void TurnWorldItemsCommand::undo() +{ + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->turnOn(-m_angle); + } +} + +void TurnWorldItemsCommand::redo() +{ + if (!m_firstRun) + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->turnOn(m_angle); } } m_firstRun = false; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 7fd2015e0..2eda788b4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -172,7 +172,7 @@ private: class RotateWorldItemsCommand: public QUndoCommand { public: - RotateWorldItemsCommand(const QList &items, const qreal &angle, + RotateWorldItemsCommand(const QList &items, const qreal angle, const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent = 0); virtual ~RotateWorldItemsCommand(); @@ -210,6 +210,29 @@ private: bool m_firstRun; }; +/** +@class TurnWorldItemsCommand +@brief +@details +*/ +class TurnWorldItemsCommand: public QUndoCommand +{ +public: + TurnWorldItemsCommand(const QList &items, const qreal angle, + PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~TurnWorldItemsCommand(); + + virtual void undo(); + virtual void redo(); +private: + + const QList m_listPaths; + const qreal m_angle; + PrimitivesTreeModel *const m_model; + bool m_firstRun; +}; + + } /* namespace WorldEditor */ #endif // WORLD_EDITOR_ACTIONS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp index 051d403ea..8699bfb67 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp @@ -77,8 +77,8 @@ bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManage // Reset m_ligoConfig.resetPrimitiveConfiguration (); - // Load - m_ligoConfig.readPrimitiveClass ("world_editor_primitive_configuration.xml", true); + // TODO: get file names! from settings + m_ligoConfig.readPrimitiveClass("world_editor_primitive_configuration.xml", true); addAutoReleasedObject(new WorldEditorContext(this)); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 7e2ac9c20..d02c047b1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -59,21 +59,21 @@ WorldEditorScene::~WorldEditorScene() { } -QGraphicsItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, const float angle) +AbstractWorldItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, const float angle) { WorldItemPoint *item = new WorldItemPoint(point, angle); addItem(item); return item; } -QGraphicsItem *WorldEditorScene::addWorldItemPath(const QPolygonF &polyline) +AbstractWorldItem *WorldEditorScene::addWorldItemPath(const QPolygonF &polyline) { WorldItemPath *item = new WorldItemPath(polyline); addItem(item); return item; } -QGraphicsItem *WorldEditorScene::addWorldItemZone(const QPolygonF &polygon) +AbstractWorldItem *WorldEditorScene::addWorldItemZone(const QPolygonF &polygon) { WorldItemZone *item = new WorldItemZone(polygon); addItem(item); @@ -167,11 +167,16 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) break; } case WorldEditorScene::RotateMode: + m_angle = 0; + m_pivot = calcBoundingRect(m_selectedItems).center(); break; case WorldEditorScene::ScaleMode: m_scaleFactor = QPointF(1.0, 1.0); + m_pivot = calcBoundingRect(m_selectedItems).center(); break; case WorldEditorScene::TurnMode: + m_angle = 0; + m_pivot = calcBoundingRect(m_selectedItems).center(); break; case WorldEditorScene::RadiusMode: break; @@ -204,24 +209,21 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) } case WorldEditorScene::RotateMode: { - QPointF pivot = calcBoundingRect(m_selectedItems).center(); - // Caluculate angle between two line - QLineF firstLine(pivot, mouseEvent->lastScenePos()); - QLineF secondLine(pivot, mouseEvent->scenePos()); + QLineF firstLine(m_pivot, mouseEvent->lastScenePos()); + QLineF secondLine(m_pivot, mouseEvent->scenePos()); qreal angle = secondLine.angleTo(firstLine); + m_angle += angle; + Q_FOREACH(QGraphicsItem *item, m_selectedItems) { - qgraphicsitem_cast(item)->rotateOn(pivot, angle); + qgraphicsitem_cast(item)->rotateOn(m_pivot, angle); } break; } case WorldEditorScene::ScaleMode: { - // TODO: perfomance - QPointF pivot = calcBoundingRect(m_selectedItems).center(); - // Calculate scale factor if (offset.x() > 0) offset.setX(1.0 + (offset.x() / 5000)); @@ -238,12 +240,26 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) Q_FOREACH(QGraphicsItem *item, m_selectedItems) { - qgraphicsitem_cast(item)->scaleOn(pivot, offset); + qgraphicsitem_cast(item)->scaleOn(m_pivot, offset); } break; } case WorldEditorScene::TurnMode: + { + // Caluculate angle between two line + QLineF firstLine(m_pivot, mouseEvent->lastScenePos()); + QLineF secondLine(m_pivot, mouseEvent->scenePos()); + qreal angle = secondLine.angleTo(firstLine); + + m_angle += angle; + + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->turnOn(angle); + } + break; + } case WorldEditorScene::RadiusMode: break; }; @@ -276,30 +292,17 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) case WorldEditorScene::MoveMode: { QPointF offset = mouseEvent->scenePos() - m_firstPick; - m_undoStack->push(new MoveWorldItemsCommand(m_selectedItems, offset, m_model)); break; } case WorldEditorScene::RotateMode: - { - QPointF pivot = calcBoundingRect(m_selectedItems).center(); - - // Caluculate angle between two line - QLineF firstLine(pivot, m_firstPick); - QLineF secondLine(pivot, mouseEvent->scenePos()); - qreal angle = secondLine.angleTo(firstLine); - - m_undoStack->push(new RotateWorldItemsCommand(m_selectedItems, angle, pivot, m_model)); + m_undoStack->push(new RotateWorldItemsCommand(m_selectedItems, m_angle, m_pivot, m_model)); break; - } case WorldEditorScene::ScaleMode: - { - QPointF pivot = calcBoundingRect(m_selectedItems).center(); - m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, pivot, m_model)); - + m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, m_pivot, m_model)); break; - } case WorldEditorScene::TurnMode: + m_undoStack->push(new TurnWorldItemsCommand(m_selectedItems, m_angle, m_model)); break; case WorldEditorScene::RadiusMode: break; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index aa813c5c5..265067469 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -30,6 +30,7 @@ namespace WorldEditor { class PrimitivesTreeModel; +class AbstractWorldItem; /* @class WorldEditorScene @@ -55,9 +56,9 @@ public: QUndoStack *undoStack, QObject *parent = 0); virtual ~WorldEditorScene(); - QGraphicsItem *addWorldItemPoint(const QPointF &point, const float angle); - QGraphicsItem *addWorldItemPath(const QPolygonF &polyline); - QGraphicsItem *addWorldItemZone(const QPolygonF &polygon); + AbstractWorldItem *addWorldItemPoint(const QPointF &point, const float angle); + AbstractWorldItem *addWorldItemPath(const QPolygonF &polyline); + AbstractWorldItem *addWorldItemZone(const QPolygonF &polygon); void removeWorldItem(QGraphicsItem *item); @@ -87,9 +88,9 @@ private: QPen m_pen1, m_pen2; QBrush m_brush1, m_brush2; - QPointF m_firstPick, m_scaleFactor; + QPointF m_firstPick, m_scaleFactor, m_pivot; QRectF m_selectionArea; - qreal m_firstPickX, m_firstPickY; + qreal m_firstPickX, m_firstPickY, m_angle; QList m_selectedItems; bool m_editedSelectedItems, m_firstSelection; uint m_lastPickedPrimitive; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index 31f63dc05..249ad15e3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -322,9 +322,9 @@ int AbstractWorldItem::type() const return Type; } -WorldItemPoint::WorldItemPoint(const QPointF &point, const float angle, QGraphicsItem *parent) +WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, QGraphicsItem *parent) : AbstractWorldItem(parent), - m_angle(angle) + m_angle((2 * NLMISC::Pi - angle) * 180 / NLMISC::Pi) { setZValue(WORLD_POINT_LAYER); @@ -343,7 +343,7 @@ WorldItemPoint::WorldItemPoint(const QPointF &point, const float angle, QGraphic m_brush.setColor(QColor(255, 100, 10)); m_brush.setStyle(Qt::SolidPattern); - m_selectedBrush.setColor(QColor(0, 255, 0)); + m_selectedBrush.setColor(Qt::NoPen); m_selectedBrush.setStyle(Qt::SolidPattern); //setFlag(ItemIsSelectable); @@ -396,14 +396,21 @@ void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &factor) setPos(scaledPolygon.boundingRect().center()); } -void WorldItemPoint::turnOn(const QPointF &offset) +void WorldItemPoint::turnOn(const qreal angle) { + m_angle += angle; + update(); } void WorldItemPoint::radiusOn(const qreal radius) { } +void WorldItemPoint::setColor(const QColor &color) +{ + m_brush.setColor(color); +} + QPainterPath WorldItemPoint::shape() const { QPainterPath path; @@ -435,6 +442,14 @@ void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *op } painter->drawRect(m_rect); + + painter->setPen(Qt::red); + + painter->rotate(m_angle); + + painter->drawLine(0, 0, SIZE_ARROW, 0); + painter->drawLine(SIZE_ARROW - 2, -2, SIZE_ARROW, 0); + painter->drawLine(SIZE_ARROW - 2, 2, SIZE_ARROW, 0); } QVariant WorldItemPoint::itemChange(GraphicsItemChange change, const QVariant &value) @@ -453,10 +468,10 @@ WorldItemPath::WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent) setZValue(WORLD_PATH_LAYER); - m_pen.setColor(QColor(0, 0, 0)); + m_pen.setColor(Qt::black); m_pen.setWidth(5); - m_selectedPen.setColor(QColor(255, 0, 0)); + m_selectedPen.setColor(Qt::white); m_selectedPen.setWidth(5); } @@ -499,7 +514,7 @@ void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &factor) m_polygon.translate(pivot); } -void WorldItemPath::turnOn(const QPointF &offset) +void WorldItemPath::turnOn(const qreal angle) { } @@ -507,6 +522,11 @@ void WorldItemPath::radiusOn(const qreal radius) { } +void WorldItemPath::setColor(const QColor &color) +{ + m_pen.setColor(color); +} + QPainterPath WorldItemPath::shape() const { QPainterPath path; @@ -555,13 +575,13 @@ WorldItemZone::WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent) m_pen.setColor(QColor(20, 100, 255)); m_pen.setWidth(0); - m_selectedPen.setColor(QColor(255, 0, 0)); + m_selectedPen.setColor(Qt::white); m_selectedPen.setWidth(0); - m_brush.setColor(QColor(20, 100, 255, 28)); + m_brush.setColor(QColor(20, 100, 255, TRANSPARENCY)); m_brush.setStyle(Qt::SolidPattern); - m_selectedBrush.setColor(QColor(255, 0, 0, 128)); + m_selectedBrush.setColor(QColor(255, 255, 255, 100)); m_selectedBrush.setStyle(Qt::SolidPattern); } @@ -604,7 +624,7 @@ void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &factor) m_polygon.translate(pivot); } -void WorldItemZone::turnOn(const QPointF &offset) +void WorldItemZone::turnOn(const qreal angle) { } @@ -612,6 +632,16 @@ void WorldItemZone::radiusOn(const qreal radius) { } +void WorldItemZone::setColor(const QColor &color) +{ + m_pen.setColor(color); + + QColor brushColor(color); + brushColor.setAlpha(TRANSPARENCY); + + m_brush.setColor(brushColor); +} + QRectF WorldItemZone::boundingRect() const { return m_polygon.boundingRect(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index 6f1669786..cdc9691b4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -45,6 +45,7 @@ const int WORLD_PATH_LAYER = 200; const int MIDDLE_POINT_LAYER = 201; const int EDGE_POINT_LAYER = 201; +const int SIZE_ARROW = 20; /* // Deprecated class GraphicsItemNode: public QGraphicsObject @@ -132,9 +133,11 @@ public: virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) = 0; // TODO: add modes: IgnoreAspectRatio, KeepAspectRatio virtual void scaleOn(const QPointF &pivot, const QPointF &factor) = 0; - virtual void turnOn(const QPointF &offset) = 0; + virtual void turnOn(const qreal angle) = 0; virtual void radiusOn(const qreal radius) = 0; + virtual void setColor(const QColor &color) = 0; + // Enable the use of qgraphicsitem_cast with this item. int type() const; }; @@ -147,15 +150,17 @@ public: class WorldItemPoint: public AbstractWorldItem { public: - WorldItemPoint(const QPointF &point, const float angle, QGraphicsItem *parent = 0); + WorldItemPoint(const QPointF &point, const qreal angle, QGraphicsItem *parent = 0); virtual ~WorldItemPoint(); virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); - virtual void turnOn(const QPointF &offset); + virtual void turnOn(const qreal angle); virtual void radiusOn(const qreal radius); + virtual void setColor(const QColor &color); + virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -166,13 +171,13 @@ protected: private: // TODO - static const int SIZE_POINT = 7; + static const int SIZE_POINT = 4; QPen m_pen, m_selectedPen; QBrush m_brush, m_selectedBrush; QRectF m_rect; - float m_angle; + qreal m_angle; }; /* @@ -189,9 +194,11 @@ public: virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); - virtual void turnOn(const QPointF &offset); + virtual void turnOn(const qreal angle); virtual void radiusOn(const qreal radius); + virtual void setColor(const QColor &color); + virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -217,9 +224,11 @@ public: virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); - virtual void turnOn(const QPointF &offset); + virtual void turnOn(const qreal angle); virtual void radiusOn(const qreal radius); + virtual void setColor(const QColor &color); + virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -227,6 +236,8 @@ public: protected: virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); + static const int TRANSPARENCY = 28; + QPen m_pen, m_selectedPen; QBrush m_brush, m_selectedBrush; QPolygonF m_polygon; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index f5dc5f408..c556514b7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -293,7 +293,7 @@ true - false + true From 63a755f83e2c6d4bea8d5b5b937e5d8ddb3d6401 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Fri, 12 Aug 2011 13:38:13 +0300 Subject: [PATCH 054/747] Changed: #1302 Added drawing of circle for point primitive --- .../world_editor/world_editor_actions.cpp | 17 ++- .../world_editor/world_editor_scene.cpp | 7 +- .../plugins/world_editor/world_editor_scene.h | 3 +- .../world_editor/world_editor_scene_item.cpp | 132 ++++++++++-------- .../world_editor/world_editor_scene_item.h | 14 +- .../world_editor/world_editor_window.cpp | 23 ++- .../world_editor/world_editor_window.h | 1 + 7 files changed, 125 insertions(+), 72 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 780ea47a9..41de05f85 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -59,7 +59,18 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode { vec = primitive->getPrimVector(); NLLIGO::CPrimPoint *primPoint = static_cast(primitive); - item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), primPoint->Angle); + + // Draw arrow ? + bool showArrow = node->primitiveClass()->ShowArrow; + + // Have a radius ? + std::string strRadius; + qreal radius = 0; + if (primitive->getPropertyByName ("radius", strRadius)) + radius = atof(strRadius.c_str()); + + item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), + primPoint->Angle, radius, showArrow); break; } case NLLIGO::CPrimitiveClass::Path: @@ -397,7 +408,7 @@ void MoveWorldItemsCommand::undo() { Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->moveOn(-m_offset); + item->moveBy(-m_offset.x(), -m_offset.y()); } } @@ -409,7 +420,7 @@ void MoveWorldItemsCommand::redo() { Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->moveOn(m_offset); + item->moveBy(m_offset.x(), m_offset.y()); } } m_firstRun = false; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index d02c047b1..b986d7c0c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -59,9 +59,10 @@ WorldEditorScene::~WorldEditorScene() { } -AbstractWorldItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, const float angle) +AbstractWorldItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, const qreal angle, + const qreal radius, bool showArrow) { - WorldItemPoint *item = new WorldItemPoint(point, angle); + WorldItemPoint *item = new WorldItemPoint(point, angle, radius, showArrow); addItem(item); return item; } @@ -203,7 +204,7 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { Q_FOREACH(QGraphicsItem *item, m_selectedItems) { - qgraphicsitem_cast(item)->moveOn(offset); + item->moveBy(offset.x(), offset.y()); } break; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index 265067469..c7868b15a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -56,7 +56,8 @@ public: QUndoStack *undoStack, QObject *parent = 0); virtual ~WorldEditorScene(); - AbstractWorldItem *addWorldItemPoint(const QPointF &point, const float angle); + AbstractWorldItem *addWorldItemPoint(const QPointF &point, const qreal angle, + const qreal radius, bool showArrow); AbstractWorldItem *addWorldItemPath(const QPolygonF &polyline); AbstractWorldItem *addWorldItemZone(const QPolygonF &polygon); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index 249ad15e3..0e65e6455 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -322,9 +322,12 @@ int AbstractWorldItem::type() const return Type; } -WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, QGraphicsItem *parent) +WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, const qreal radius, + bool showArrow, QGraphicsItem *parent) : AbstractWorldItem(parent), - m_angle((2 * NLMISC::Pi - angle) * 180 / NLMISC::Pi) + m_angle((2 * NLMISC::Pi - angle) * 180 / NLMISC::Pi), + m_radius(radius), + m_showArrow(showArrow) { setZValue(WORLD_POINT_LAYER); @@ -335,17 +338,41 @@ WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, QGraphic m_rect.setCoords(-SIZE_POINT, -SIZE_POINT, SIZE_POINT, SIZE_POINT); m_pen.setColor(QColor(255, 100, 10)); - m_pen.setWidth(5); + //m_pen.setWidth(0); - m_selectedPen.setColor(QColor(0, 255, 0)); - m_selectedPen.setWidth(5); + m_selectedPen.setColor(Qt::white); + //m_selectedPen.setWidth(0); m_brush.setColor(QColor(255, 100, 10)); m_brush.setStyle(Qt::SolidPattern); - m_selectedBrush.setColor(Qt::NoPen); + m_selectedBrush.setColor(Qt::white); m_selectedBrush.setStyle(Qt::SolidPattern); + + if (m_radius != 0) + { + // Create circle + int segmentCount = 30; + QPointF circlePoint(m_radius, 0); + m_circle << circlePoint; + for (int i = 1; i < segmentCount + 1; ++i) + { + qreal angle = i * (2 * NLMISC::Pi / segmentCount); + circlePoint.setX(cos(angle) * m_radius); + circlePoint.setY(sin(angle) * m_radius); + m_circle << circlePoint; + } + } + + // Create arrow + if (showArrow) + { + m_arrow.push_back(QLine(0, 0, SIZE_ARROW, 0)); + m_arrow.push_back(QLine(SIZE_ARROW - 2, -2, SIZE_ARROW, 0)); + m_arrow.push_back(QLine(SIZE_ARROW - 2, 2, SIZE_ARROW, 0)); + } + //setFlag(ItemIsSelectable); } @@ -353,13 +380,6 @@ WorldItemPoint::~WorldItemPoint() { } -void WorldItemPoint::moveOn(const QPointF &offset) -{ - prepareGeometryChange(); - - setPos(pos() + offset); -} - void WorldItemPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle) { prepareGeometryChange(); @@ -367,8 +387,8 @@ void WorldItemPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle) QPolygonF rotatedPolygon(m_rect); // TODO - rotatedPolygon.translate(pos()); - rotatedPolygon.translate(-pivot); + rotatedPolygon.translate(pos() - pivot); + //rotatedPolygon.translate(-pivot); QTransform trans; trans = trans.rotate(deltaAngle); @@ -385,8 +405,8 @@ void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &factor) QPolygonF scaledPolygon(m_rect); // TODO - scaledPolygon.translate(pos()); - scaledPolygon.translate(-pivot); + scaledPolygon.translate(pos() - pivot); + //scaledPolygon.translate(-pivot); QTransform trans; trans = trans.scale(factor.x(), factor.y()); @@ -408,6 +428,7 @@ void WorldItemPoint::radiusOn(const qreal radius) void WorldItemPoint::setColor(const QColor &color) { + m_pen.setColor(color); m_brush.setColor(color); } @@ -430,26 +451,26 @@ void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *op // Here comes the magic: //painter->setClipRect(option->exposedRect); - painter->setPen(Qt::NoPen); + painter->setPen(m_pen); - if (option->state & QStyle::State_Selected) - { - painter->setBrush(m_selectedBrush); - } - else - { - painter->setBrush(m_brush); - } - - painter->drawRect(m_rect); - - painter->setPen(Qt::red); + // Draw circle + // Draws artefacts with using opengl painter + // painter->drawEllipse(-m_radius / 2, -m_radius / 2, m_radius, m_radius); + painter->drawPolygon(m_circle); painter->rotate(m_angle); - painter->drawLine(0, 0, SIZE_ARROW, 0); - painter->drawLine(SIZE_ARROW - 2, -2, SIZE_ARROW, 0); - painter->drawLine(SIZE_ARROW - 2, 2, SIZE_ARROW, 0); + // Draw arrow + painter->drawLines(m_arrow); + + painter->setPen(Qt::NoPen); + if (option->state & QStyle::State_Selected) + painter->setBrush(m_selectedBrush); + else + painter->setBrush(m_brush); + + // Draw point + painter->drawRect(m_rect); } QVariant WorldItemPoint::itemChange(GraphicsItemChange change, const QVariant &value) @@ -469,35 +490,34 @@ WorldItemPath::WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent) setZValue(WORLD_PATH_LAYER); m_pen.setColor(Qt::black); - m_pen.setWidth(5); + m_pen.setWidth(3); + m_pen.setJoinStyle(Qt::MiterJoin); m_selectedPen.setColor(Qt::white); - m_selectedPen.setWidth(5); + m_selectedPen.setWidth(3); + m_selectedPen.setJoinStyle(Qt::MiterJoin); + + QPointF center = m_polygon.boundingRect().center(); + m_polygon.translate(-center); + setPos(center); } WorldItemPath::~WorldItemPath() { } -void WorldItemPath::moveOn(const QPointF &offset) -{ - prepareGeometryChange(); - - m_polygon.translate(offset); -} - void WorldItemPath::rotateOn(const QPointF &pivot, const qreal deltaAngle) { prepareGeometryChange(); QPolygonF rotatedPolygon(m_polygon); - rotatedPolygon.translate(-pivot); + rotatedPolygon.translate(pos() - pivot); QTransform trans; trans = trans.rotate(deltaAngle); m_polygon = trans.map(rotatedPolygon); - m_polygon.translate(pivot); + m_polygon.translate(pivot - pos()); } void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &factor) @@ -505,13 +525,13 @@ void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &factor) prepareGeometryChange(); QPolygonF scaledPolygon(m_polygon); - scaledPolygon.translate(-pivot); + scaledPolygon.translate(pos() - pivot); QTransform trans; trans = trans.scale(factor.x(), factor.y()); m_polygon = trans.map(scaledPolygon); - m_polygon.translate(pivot); + m_polygon.translate(pivot - pos()); } void WorldItemPath::turnOn(const qreal angle) @@ -583,31 +603,28 @@ WorldItemZone::WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent) m_selectedBrush.setColor(QColor(255, 255, 255, 100)); m_selectedBrush.setStyle(Qt::SolidPattern); + + QPointF center = m_polygon.boundingRect().center(); + m_polygon.translate(-center); + setPos(center); } WorldItemZone::~WorldItemZone() { } -void WorldItemZone::moveOn(const QPointF &offset) -{ - prepareGeometryChange(); - - m_polygon.translate(offset); -} - void WorldItemZone::rotateOn(const QPointF &pivot, const qreal deltaAngle) { prepareGeometryChange(); QPolygonF rotatedPolygon(m_polygon); - rotatedPolygon.translate(-pivot); + rotatedPolygon.translate(pos() - pivot); QTransform trans; trans = trans.rotate(deltaAngle); m_polygon = trans.map(rotatedPolygon); - m_polygon.translate(pivot); + m_polygon.translate(pivot - pos()); } void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &factor) @@ -615,13 +632,14 @@ void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &factor) prepareGeometryChange(); QPolygonF scaledPolygon(m_polygon); - scaledPolygon.translate(-pivot); + + scaledPolygon.translate(pos() - pivot); QTransform trans; trans = trans.scale(factor.x(), factor.y()); m_polygon = trans.map(scaledPolygon); - m_polygon.translate(pivot); + m_polygon.translate(pivot - pos()); } void WorldItemZone::turnOn(const qreal angle) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index cdc9691b4..af30c3470 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -129,7 +129,6 @@ public: enum { Type = QGraphicsItem::UserType + 1 }; - virtual void moveOn(const QPointF &offset) = 0; virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) = 0; // TODO: add modes: IgnoreAspectRatio, KeepAspectRatio virtual void scaleOn(const QPointF &pivot, const QPointF &factor) = 0; @@ -150,10 +149,10 @@ public: class WorldItemPoint: public AbstractWorldItem { public: - WorldItemPoint(const QPointF &point, const qreal angle, QGraphicsItem *parent = 0); + WorldItemPoint(const QPointF &point, const qreal angle, const qreal radius, + bool showArrow, QGraphicsItem *parent = 0); virtual ~WorldItemPoint(); - virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); virtual void turnOn(const qreal angle); @@ -171,13 +170,16 @@ protected: private: // TODO - static const int SIZE_POINT = 4; + static const int SIZE_POINT = 3; QPen m_pen, m_selectedPen; QBrush m_brush, m_selectedBrush; + QPolygonF m_circle; + QVector m_arrow; QRectF m_rect; - qreal m_angle; + qreal m_angle, m_radius; + bool m_showArrow; }; /* @@ -191,7 +193,6 @@ public: WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent = 0); virtual ~WorldItemPath(); - virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); virtual void turnOn(const qreal angle); @@ -221,7 +222,6 @@ public: WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent = 0); virtual ~WorldItemZone(); - virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); virtual void turnOn(const qreal angle); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index fb0f1463d..1e8a65506 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -38,6 +38,7 @@ #include #include #include +#include namespace WorldEditor { @@ -45,7 +46,8 @@ namespace WorldEditor WorldEditorWindow::WorldEditorWindow(QWidget *parent) : QMainWindow(parent), m_primitivesModel(0), - m_undoStack(0) + m_undoStack(0), + m_oglWidget(0) { m_ui.setupUi(this); m_undoStack = new QUndoStack(this); @@ -123,6 +125,25 @@ QUndoStack *WorldEditorWindow::undoStack() const return m_undoStack; } +void WorldEditorWindow::maybeSave() +{ + QMessageBox *messageBox = new QMessageBox(tr("SDI"), + tr("The data has been modified.\n" + "Do you want to save your changes?"), + QMessageBox::Warning, + QMessageBox::Yes | QMessageBox::Default, + QMessageBox::No, + QMessageBox::Cancel | QMessageBox::Escape, + this, Qt::Sheet); + + messageBox->setButtonText(QMessageBox::Yes, + tr("Save")); + + messageBox->setButtonText(QMessageBox::No, tr("Dont Save")); + + messageBox->show(); +} + void WorldEditorWindow::open() { QString fileName = QFileDialog::getOpenFileName(this, diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 65d39ac58..58cd3a532 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -46,6 +46,7 @@ public: ~WorldEditorWindow(); QUndoStack *undoStack() const; + void maybeSave(); Q_SIGNALS: public Q_SLOTS: From 353847a489f2d8734cb200112e9f7712fb5401bd Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 13 Aug 2011 13:07:06 +0300 Subject: [PATCH 055/747] Changed: #1302 When selecting primitives in the primitives dialog will be selected the appropriate graphics items in scene. --- .../src/plugins/world_editor/primitive_item.h | 2 + .../plugins/world_editor/primitives_view.cpp | 3 +- .../plugins/world_editor/primitives_view.h | 7 ++ .../world_editor/world_editor_actions.cpp | 52 +++++++++----- .../world_editor/world_editor_actions.h | 12 +++- .../world_editor/world_editor_scene.cpp | 68 ++++++++++++++----- .../plugins/world_editor/world_editor_scene.h | 7 +- .../world_editor/world_editor_scene_item.cpp | 50 +++++++++----- .../world_editor/world_editor_scene_item.h | 6 +- .../world_editor/world_editor_window.cpp | 44 ++++++++++++ .../world_editor/world_editor_window.h | 2 + 11 files changed, 193 insertions(+), 60 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 4940a622b..204068db0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -173,6 +173,8 @@ private: NLLIGO::CPrimitives *m_primitives; }; +typedef QList NodeList; + } /* namespace WorldEditor */ Q_DECLARE_METATYPE(WorldEditor::Node *) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index f324da9b9..896218a54 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -16,7 +16,6 @@ // Project includes #include "primitives_view.h" -#include "primitive_item.h" #include "primitives_model.h" #include "world_editor_actions.h" @@ -208,7 +207,7 @@ void PrimitivesView::addNewPrimitiveByClass(int value) QString className = node->primitiveClass()->DynamicChildren[value].ClassName.c_str(); m_undoStack->push(new AddPrimitiveByClassCommand(className, m_primitivesTreeModel->pathFromIndex(indexList.first()), - m_primitivesTreeModel)); + m_worldEditorScene, m_primitivesTreeModel)); } void PrimitivesView::generatePrimitives(int value) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h index 18785b909..df317a93b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h @@ -18,6 +18,9 @@ #ifndef PRIMITIVES_VIEW_H #define PRIMITIVES_VIEW_H +// Project includes +#include "primitive_item.h" + // NeL includes #include @@ -28,6 +31,7 @@ #include #include #include +#include namespace LandscapeEditor { @@ -57,6 +61,9 @@ public: void setWorldScene(WorldEditorScene *worldEditorScene); virtual void setModel(PrimitivesTreeModel *model); +public Q_SLOTS: + //void selectPrimitives(); + private Q_SLOTS: void loadLandscape(); void loadRootPrimitive(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 41de05f85..db4abcaa8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -43,6 +43,29 @@ namespace WorldEditor { +QGraphicsItem *getGraphicsItem(Node *node) +{ + QGraphicsItem *result = 0; + if (node->type() == Node::PrimitiveNodeType) + { + PrimitiveNode *primitiveNode = static_cast(node); + if (primitiveNode != 0) + { + switch (primitiveNode->primitiveClass()->Type) + { + case NLLIGO::CPrimitiveClass::Point: + case NLLIGO::CPrimitiveClass::Path: + case NLLIGO::CPrimitiveClass::Zone: + { + result = qvariant_cast(primitiveNode->data(Constants::GRAPHICS_DATA_QT4_2D)); + break; + } + } + } + } + return result; +} + void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene) { PrimitiveNode *node = static_cast(primIndex.internalPointer()); @@ -53,6 +76,10 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode NLLIGO::IPrimitive *primitive = node->primitive(); NLLIGO::CPrimVector *vec = 0; AbstractWorldItem *item = 0; + + // Draw arrow ? + bool showArrow = node->primitiveClass()->ShowArrow; + switch (node->primitiveClass()->Type) { case NLLIGO::CPrimitiveClass::Point: @@ -60,9 +87,6 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode vec = primitive->getPrimVector(); NLLIGO::CPrimPoint *primPoint = static_cast(primitive); - // Draw arrow ? - bool showArrow = node->primitiveClass()->ShowArrow; - // Have a radius ? std::string strRadius; qreal radius = 0; @@ -85,7 +109,7 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode ++vec; } - item = scene->addWorldItemPath(polygon); + item = scene->addWorldItemPath(polygon, showArrow); break; } case NLLIGO::CPrimitiveClass::Zone: @@ -153,22 +177,13 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene) { - PrimitiveNode *node = static_cast(primIndex.internalPointer()); + Node *node = static_cast(primIndex.internalPointer()); if (node != 0) { - switch (node->primitiveClass()->Type) - { - case NLLIGO::CPrimitiveClass::Point: - case NLLIGO::CPrimitiveClass::Path: - case NLLIGO::CPrimitiveClass::Zone: - { - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - if (item != 0) - scene->removeWorldItem(item); - break; - } - } + QGraphicsItem *item = getGraphicsItem(node); + if (item != 0) + scene->removeWorldItem(item); } int count = model->rowCount(primIndex); @@ -334,10 +349,11 @@ void LoadRootPrimitiveCommand::redo() } AddPrimitiveByClassCommand::AddPrimitiveByClassCommand(const QString &className, const Path &parentIndex, - PrimitivesTreeModel *model, QUndoCommand *parent) + WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_className(className), m_parentIndex(parentIndex), + m_scene(scene), m_model(model) { setText(QString("Add %1").arg(m_className)); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 2eda788b4..a76e49466 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -36,7 +36,15 @@ namespace WorldEditor { class WorldEditorScene; +// Auxiliary operations + +// Return QGraphicsItem if node contains it +QGraphicsItem *getGraphicsItem(Node *node); + +// Scan primitives model for create/add necessary QGraphicsItems void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene); + +// Recursive scan primitives model for delete Graphics Items void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene); QList graphicsItemsToPaths(const QList &items, PrimitivesTreeModel *model); //QList pathsToGraphicsItems(const QList &items, PrimitivesTreeModel *model); @@ -130,7 +138,8 @@ class AddPrimitiveByClassCommand: public QUndoCommand { public: AddPrimitiveByClassCommand(const QString &className, const Path &parentIndex, - PrimitivesTreeModel *model, QUndoCommand *parent = 0); + WorldEditorScene *scene, PrimitivesTreeModel *model, + QUndoCommand *parent = 0); virtual ~AddPrimitiveByClassCommand(); virtual void undo(); @@ -139,6 +148,7 @@ private: const QString m_className; Path m_parentIndex, m_newPrimIndex; + WorldEditorScene *m_scene; PrimitivesTreeModel *m_model; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index b986d7c0c..7ec656f85 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -42,6 +42,9 @@ WorldEditorScene::WorldEditorScene(int sizeCell, PrimitivesTreeModel *model, QUn { setItemIndexMethod(NoIndex); + // TODO: get params from settings + setSceneRect(QRectF(-20 * 160, -20 * 160, 256 * 160, 256 * 160)); + m_pen1.setColor(QColor(50, 255, 155)); m_pen1.setWidth(0); @@ -67,7 +70,7 @@ AbstractWorldItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, con return item; } -AbstractWorldItem *WorldEditorScene::addWorldItemPath(const QPolygonF &polyline) +AbstractWorldItem *WorldEditorScene::addWorldItemPath(const QPolygonF &polyline, bool showArrow) { WorldItemPath *item = new WorldItemPath(polyline); addItem(item); @@ -113,6 +116,31 @@ void WorldEditorScene::setEnabledEditPoint(bool enabled) m_editMode = enabled; } +void WorldEditorScene::updateSelection(const QList &selected, const QList &deselected) +{ + // Deselect and remove from list graphics items. + Q_FOREACH(QGraphicsItem *item, deselected) + { + // Item is selected? + int i = m_selectedItems.indexOf(item); + if (i != -1) + { + updateSelectedItem(item, false); + m_selectedItems.takeAt(i); + } + } + + // Select and add from list graphics items. + Q_FOREACH(QGraphicsItem *item, selected) + { + updateSelectedItem(item, true); + m_selectedItems.push_back(item); + } + + update(); + m_editedSelectedItems = true; +} + void WorldEditorScene::drawForeground(QPainter *painter, const QRectF &rect) { QGraphicsScene::drawForeground(painter, rect); @@ -138,15 +166,11 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { LandscapeEditor::LandscapeSceneBase::mousePressEvent(mouseEvent); - qreal x = mouseEvent->scenePos().x(); - qreal y = mouseEvent->scenePos().y(); - if (mouseEvent->button() != Qt::LeftButton) return; m_firstPick = mouseEvent->scenePos(); -// if ((!m_editedSelectedItems) && (m_mode != WorldEditorScene::SelectMode)) if ((!m_editedSelectedItems && m_selectedItems.isEmpty()) || (!calcBoundingRect(m_selectedItems).contains(mouseEvent->scenePos()))) { @@ -183,12 +207,19 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) break; }; + m_selectHack = true; // if (m_selectedItems.isEmpty()) // m_selectionArea.setTopLeft(mouseEvent->scenePos()); } void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { + if (m_selectHack) + { + m_selectHack = false; + updateSelectedItems(true); + } + if (QApplication::mouseButtons() == Qt::LeftButton) { @@ -379,20 +410,25 @@ void WorldEditorScene::updateSelectedItems(bool value) { Q_FOREACH(QGraphicsItem *item, m_selectedItems) { - if (value) - { - item->setFlag(QGraphicsItem::ItemIsSelectable); - //item->setZValue(SELECTED_LAYER); - } - else - { - item->setFlag(QGraphicsItem::ItemIsSelectable, false); - //item->setZValue(UNSELECTED_LAYER); - } - item->setSelected(value); + updateSelectedItem(item, value); } } +void WorldEditorScene::updateSelectedItem(QGraphicsItem *item, bool value) +{ + if (value) + { + item->setFlag(QGraphicsItem::ItemIsSelectable); + //item->setZValue(SELECTED_LAYER); + } + else + { + item->setFlag(QGraphicsItem::ItemIsSelectable, false); + //item->setZValue(UNSELECTED_LAYER); + } + item->setSelected(value); +} + void WorldEditorScene::updatePickSelection(const QPointF &point) { //clearSelection(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index c7868b15a..3ca055786 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -58,9 +58,8 @@ public: AbstractWorldItem *addWorldItemPoint(const QPointF &point, const qreal angle, const qreal radius, bool showArrow); - AbstractWorldItem *addWorldItemPath(const QPolygonF &polyline); + AbstractWorldItem *addWorldItemPath(const QPolygonF &polyline, bool showArrow); AbstractWorldItem *addWorldItemZone(const QPolygonF &polygon); - void removeWorldItem(QGraphicsItem *item); void setModeEdit(WorldEditorScene::ModeEdit mode); @@ -70,6 +69,7 @@ public: public Q_SLOTS: void setEnabledEditPoint(bool enabled); + void updateSelection(const QList &selected, const QList &deselected); protected: virtual void drawForeground(QPainter *painter, const QRectF &rect); @@ -83,12 +83,13 @@ private: QRectF calcBoundingRect(const QList &listItems); QPainterPath calcBoundingShape(const QList &listItems); void updateSelectedItems(bool value); - + void updateSelectedItem(QGraphicsItem *item, bool value); void updatePickSelection(const QPointF &point); QPen m_pen1, m_pen2; QBrush m_brush1, m_brush2; + bool m_selectHack; QPointF m_firstPick, m_scaleFactor, m_pivot; QRectF m_selectionArea; qreal m_firstPickX, m_firstPickY, m_angle; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index 0e65e6455..89ddd80a5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -349,21 +349,7 @@ WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, const qr m_selectedBrush.setColor(Qt::white); m_selectedBrush.setStyle(Qt::SolidPattern); - - if (m_radius != 0) - { - // Create circle - int segmentCount = 30; - QPointF circlePoint(m_radius, 0); - m_circle << circlePoint; - for (int i = 1; i < segmentCount + 1; ++i) - { - qreal angle = i * (2 * NLMISC::Pi / segmentCount); - circlePoint.setX(cos(angle) * m_radius); - circlePoint.setY(sin(angle) * m_radius); - m_circle << circlePoint; - } - } + createCircle(); // Create arrow if (showArrow) @@ -373,6 +359,7 @@ WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, const qr m_arrow.push_back(QLine(SIZE_ARROW - 2, 2, SIZE_ARROW, 0)); } + updateBoundingRect(); //setFlag(ItemIsSelectable); } @@ -424,6 +411,8 @@ void WorldItemPoint::turnOn(const qreal angle) void WorldItemPoint::radiusOn(const qreal radius) { + if (m_radius == 0) + return; } void WorldItemPoint::setColor(const QColor &color) @@ -432,18 +421,43 @@ void WorldItemPoint::setColor(const QColor &color) m_brush.setColor(color); } +void WorldItemPoint::createCircle() +{ + if (m_radius != 0) + { + // Create circle + int segmentCount = 30; + QPointF circlePoint(m_radius, 0); + m_circle << circlePoint; + for (int i = 1; i < segmentCount + 1; ++i) + { + qreal angle = i * (2 * NLMISC::Pi / segmentCount); + circlePoint.setX(cos(angle) * m_radius); + circlePoint.setY(sin(angle) * m_radius); + m_circle << circlePoint; + } + } +} + +void WorldItemPoint::updateBoundingRect() +{ + m_boundingRect.setCoords(-SIZE_POINT, -SIZE_POINT, SIZE_POINT, SIZE_POINT); + QRectF circleBoundingRect; + circleBoundingRect.setCoords(-m_radius, -m_radius, m_radius, m_radius); + m_boundingRect = m_boundingRect.united(circleBoundingRect); +} + QPainterPath WorldItemPoint::shape() const { QPainterPath path; - path.addRect(m_rect); - + path.addRect(m_boundingRect); return qt_graphicsItem_shapeFromPath(path, m_pen); } QRectF WorldItemPoint::boundingRect() const { - return m_rect; + return m_boundingRect; } void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index af30c3470..0625084bd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -168,6 +168,8 @@ protected: virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); private: + void createCircle(); + void updateBoundingRect(); // TODO static const int SIZE_POINT = 3; @@ -177,7 +179,7 @@ private: QPolygonF m_circle; QVector m_arrow; - QRectF m_rect; + QRectF m_rect, m_boundingRect; qreal m_angle, m_radius; bool m_showArrow; }; @@ -236,7 +238,7 @@ public: protected: virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); - static const int TRANSPARENCY = 28; + static const int TRANSPARENCY = 38; QPen m_pen, m_selectedPen; QBrush m_brush, m_selectedBrush; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 1e8a65506..e00e804f3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -105,6 +105,9 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) connect(m_ui.saveWorldEditAction, SIGNAL(triggered()), this, SLOT(saveWorldEditFile())); connect(m_ui.visibleGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool))); + connect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, SLOT(updateSelection(QItemSelection, QItemSelection))); + m_statusBarTimer = new QTimer(this); connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); @@ -250,6 +253,47 @@ void WorldEditorWindow::updateStatusBar() m_statusInfo->setText(m_worldEditorScene->zoneNameFromMousePos()); } +void WorldEditorWindow::updateSelection(const QItemSelection &selected, const QItemSelection &deselected) +{ + m_ui.pointsAction->setChecked(false); + + NodeList nodesSelected; + Q_FOREACH(QModelIndex modelIndex, selected.indexes()) + { + Node *node = static_cast(modelIndex.internalPointer()); + nodesSelected.push_back(node); + } + + NodeList nodesDeselected; + Q_FOREACH(QModelIndex modelIndex, deselected.indexes()) + { + Node *node = static_cast(modelIndex.internalPointer()); + nodesDeselected.push_back(node); + } + + // TODO: update property editor + // ... + + QList itemSelected; + Q_FOREACH(Node *node, nodesSelected) + { + QGraphicsItem *item = getGraphicsItem(node); + if (item != 0) + itemSelected.push_back(item); + } + + QList itemDeselected; + Q_FOREACH(Node *node, nodesDeselected) + { + QGraphicsItem *item = getGraphicsItem(node); + if (item != 0) + itemDeselected.push_back(item); + } + + // Update world editor scene + m_worldEditorScene->updateSelection(itemSelected, itemDeselected); +} + void WorldEditorWindow::showEvent(QShowEvent *showEvent) { QMainWindow::showEvent(showEvent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 58cd3a532..5844489f6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -60,6 +60,8 @@ private Q_SLOTS: void setMode(int value); void updateStatusBar(); + void updateSelection(const QItemSelection &selected, const QItemSelection &deselected); + protected: virtual void showEvent(QShowEvent *showEvent); virtual void hideEvent(QHideEvent *hideEvent); From 834ef7fe2a3a323e2cf1206e6b648178f365387f Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 15 Aug 2011 17:03:28 +0300 Subject: [PATCH 056/747] Changed: #1302 Added edit points mode with undo/redo commands and turn undo/redo command for PointWorldItem. --- .../src/plugins/world_editor/primitive_item.h | 1 + .../plugins/world_editor/primitives_view.h | 3 - .../world_editor/world_editor_actions.cpp | 108 ++- .../world_editor/world_editor_actions.h | 43 +- .../world_editor/world_editor_scene.cpp | 438 +++++++--- .../plugins/world_editor/world_editor_scene.h | 23 +- .../world_editor/world_editor_scene_item.cpp | 818 +++++++++++------- .../world_editor/world_editor_scene_item.h | 208 +++-- .../world_editor/world_editor_window.cpp | 3 +- .../world_editor/world_editor_window.ui | 19 +- 10 files changed, 1111 insertions(+), 553 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 204068db0..1b2a89d4c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -177,6 +177,7 @@ typedef QList NodeList; } /* namespace WorldEditor */ +// Enable the use of QVariant with this class. Q_DECLARE_METATYPE(WorldEditor::Node *) #endif // PRIMITIVE_ITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h index df317a93b..eae9187ac 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h @@ -61,9 +61,6 @@ public: void setWorldScene(WorldEditorScene *worldEditorScene); virtual void setModel(PrimitivesTreeModel *model); -public Q_SLOTS: - //void selectPrimitives(); - private Q_SLOTS: void loadLandscape(); void loadRootPrimitive(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index db4abcaa8..45adf49ce 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -204,12 +204,16 @@ QList graphicsItemsToPaths(const QList &items, Primitives return result; } -/* -QList pathsToGraphicsItems(const QList &items, PrimitivesTreeModel *model) +QList polygonsFromItems(const QList &items) { - QList result; + QList result; + Q_FOREACH(QGraphicsItem *item, items) + { + AbstractWorldItem *worldItem = qgraphicsitem_cast(item); + result.push_back(worldItem->polygon()); + } + return result; } -*/ CreateWorldCommand::CreateWorldCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), @@ -310,6 +314,8 @@ LoadRootPrimitiveCommand::~LoadRootPrimitiveCommand() void LoadRootPrimitiveCommand::undo() { + m_scene->setEnabledEditPoints(false); + QModelIndex index = m_model->pathToIndex(m_rootPrimIndex); removeGraphicsItems(index, m_model, m_scene); @@ -323,6 +329,8 @@ void LoadRootPrimitiveCommand::undo() void LoadRootPrimitiveCommand::redo() { + m_scene->setEnabledEditPoints(false); + NLLIGO::CPrimitives *primitives = new NLLIGO::CPrimitives(); // set the primitive context @@ -365,6 +373,8 @@ AddPrimitiveByClassCommand::~AddPrimitiveByClassCommand() void AddPrimitiveByClassCommand::undo() { + m_scene->setEnabledEditPoints(false); + QModelIndex index = m_model->pathToIndex(m_newPrimIndex); PrimitiveNode *node = static_cast(index.internalPointer()); @@ -381,6 +391,8 @@ void AddPrimitiveByClassCommand::undo() void AddPrimitiveByClassCommand::redo() { + m_scene->setEnabledEditPoints(false); + QModelIndex parentIndex = m_model->pathToIndex(m_parentIndex); PrimitiveNode *parentNode = static_cast(parentIndex.internalPointer()); const NLLIGO::CPrimitiveClass *primClass = parentNode->primitiveClass(); @@ -404,11 +416,12 @@ void AddPrimitiveByClassCommand::redo() } MoveWorldItemsCommand::MoveWorldItemsCommand(const QList &items, const QPointF &offset, - PrimitivesTreeModel *model, QUndoCommand *parent) + WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_listPaths(graphicsItemsToPaths(items, model)), m_offset(offset), m_model(model), + m_scene(scene), m_firstRun(true) { setText("Move item(s)"); @@ -420,35 +433,42 @@ MoveWorldItemsCommand::~MoveWorldItemsCommand() void MoveWorldItemsCommand::undo() { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->moveBy(-m_offset.x(), -m_offset.y()); } + m_scene->setEnabledEditPoints(pointsMode); } void MoveWorldItemsCommand::redo() { if (!m_firstRun) { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->moveBy(m_offset.x(), m_offset.y()); } + m_scene->setEnabledEditPoints(pointsMode); } m_firstRun = false; } RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &items, const qreal angle, - const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent) + const QPointF &pivot, WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_listPaths(graphicsItemsToPaths(items, model)), m_angle(angle), m_pivot(pivot), m_model(model), + m_scene(scene), m_firstRun(true) { setText(QString("Rotate item(s) %1").arg(m_angle)); @@ -460,35 +480,42 @@ RotateWorldItemsCommand::~RotateWorldItemsCommand() void RotateWorldItemsCommand::undo() { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->rotateOn(m_pivot, -m_angle); } + m_scene->setEnabledEditPoints(pointsMode); } void RotateWorldItemsCommand::redo() { if (!m_firstRun) { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->rotateOn(m_pivot, m_angle); } + m_scene->setEnabledEditPoints(pointsMode); } m_firstRun = false; } ScaleWorldItemsCommand::ScaleWorldItemsCommand(const QList &items, const QPointF &factor, - const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent) + const QPointF &pivot, WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_listPaths(graphicsItemsToPaths(items, model)), m_factor(factor), m_pivot(pivot), m_model(model), + m_scene(scene), m_firstRun(true) { setText("Scale item(s)"); @@ -500,6 +527,8 @@ ScaleWorldItemsCommand::~ScaleWorldItemsCommand() void ScaleWorldItemsCommand::undo() { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); QPointF m_invertFactor(1 / m_factor.x(), 1 / m_factor.y()); for (int i = 0; i < m_listPaths.count(); ++i) { @@ -507,28 +536,33 @@ void ScaleWorldItemsCommand::undo() AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->scaleOn(m_pivot, m_invertFactor); } + m_scene->setEnabledEditPoints(pointsMode); } void ScaleWorldItemsCommand::redo() { if (!m_firstRun) { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->scaleOn(m_pivot, m_factor); } + m_scene->setEnabledEditPoints(pointsMode); } m_firstRun = false; } TurnWorldItemsCommand::TurnWorldItemsCommand(const QList &items, const qreal angle, - PrimitivesTreeModel *model, QUndoCommand *parent) + WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_listPaths(graphicsItemsToPaths(items, model)), m_angle(angle), m_model(model), + m_scene(scene), m_firstRun(true) { setText(QString("Turn item(s) %1").arg(m_angle)); @@ -540,24 +574,82 @@ TurnWorldItemsCommand::~TurnWorldItemsCommand() void TurnWorldItemsCommand::undo() { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->turnOn(-m_angle); } + m_scene->setEnabledEditPoints(pointsMode); } void TurnWorldItemsCommand::redo() { if (!m_firstRun) { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->turnOn(m_angle); } + m_scene->setEnabledEditPoints(pointsMode); + } + + m_firstRun = false; +} + +ShapeWorldItemsCommand::ShapeWorldItemsCommand(const QList &items, const QList &polygons, + WorldEditorScene *scene, PrimitivesTreeModel *model, + QUndoCommand *parent) + : QUndoCommand(parent), + m_listPaths(graphicsItemsToPaths(items, model)), + m_redoPolygons(polygons), + m_undoPolygons(polygonsFromItems(items)), + m_model(model), + m_scene(scene), + m_firstRun(true) +{ + setText("Change shape"); +} + +ShapeWorldItemsCommand::~ShapeWorldItemsCommand() +{ +} + +void ShapeWorldItemsCommand::undo() +{ + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); + + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->setPolygon(m_redoPolygons.at(i)); + } + + m_scene->setEnabledEditPoints(pointsMode); +} + +void ShapeWorldItemsCommand::redo() +{ + if (!m_firstRun) + { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); + + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->setPolygon(m_undoPolygons.at(i)); + } + m_scene->setEnabledEditPoints(pointsMode); } m_firstRun = false; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index a76e49466..fcb510605 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -47,7 +47,8 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode // Recursive scan primitives model for delete Graphics Items void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene); QList graphicsItemsToPaths(const QList &items, PrimitivesTreeModel *model); -//QList pathsToGraphicsItems(const QList &items, PrimitivesTreeModel *model); + +QList polygonsFromItems(const QList &items); /** @class CreateWorldCommand @@ -161,7 +162,8 @@ class MoveWorldItemsCommand: public QUndoCommand { public: MoveWorldItemsCommand(const QList &items, const QPointF &offset, - PrimitivesTreeModel *model, QUndoCommand *parent = 0); + WorldEditorScene *scene, PrimitivesTreeModel *model, + QUndoCommand *parent = 0); virtual ~MoveWorldItemsCommand(); virtual void undo(); @@ -171,6 +173,7 @@ private: const QList m_listPaths; const QPointF m_offset; PrimitivesTreeModel *const m_model; + WorldEditorScene *m_scene; bool m_firstRun; }; @@ -183,7 +186,8 @@ class RotateWorldItemsCommand: public QUndoCommand { public: RotateWorldItemsCommand(const QList &items, const qreal angle, - const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent = 0); + const QPointF &pivot, WorldEditorScene *scene, + PrimitivesTreeModel *model, QUndoCommand *parent = 0); virtual ~RotateWorldItemsCommand(); virtual void undo(); @@ -194,6 +198,7 @@ private: const qreal m_angle; const QPointF m_pivot; PrimitivesTreeModel *const m_model; + WorldEditorScene *m_scene; bool m_firstRun; }; @@ -206,7 +211,8 @@ class ScaleWorldItemsCommand: public QUndoCommand { public: ScaleWorldItemsCommand(const QList &items, const QPointF &factor, - const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent = 0); + const QPointF &pivot, WorldEditorScene *scene, + PrimitivesTreeModel *model, QUndoCommand *parent = 0); virtual ~ScaleWorldItemsCommand(); virtual void undo(); @@ -217,6 +223,7 @@ private: const QPointF m_factor; const QPointF m_pivot; PrimitivesTreeModel *const m_model; + WorldEditorScene *m_scene; bool m_firstRun; }; @@ -229,7 +236,8 @@ class TurnWorldItemsCommand: public QUndoCommand { public: TurnWorldItemsCommand(const QList &items, const qreal angle, - PrimitivesTreeModel *model, QUndoCommand *parent = 0); + WorldEditorScene *scene, PrimitivesTreeModel *model, + QUndoCommand *parent = 0); virtual ~TurnWorldItemsCommand(); virtual void undo(); @@ -239,9 +247,34 @@ private: const QList m_listPaths; const qreal m_angle; PrimitivesTreeModel *const m_model; + WorldEditorScene *m_scene; bool m_firstRun; }; +/** +@class TurnWorldItemsCommand +@brief +@details +*/ +class ShapeWorldItemsCommand: public QUndoCommand +{ +public: + ShapeWorldItemsCommand(const QList &items, const QList &polygons, + WorldEditorScene *scene, PrimitivesTreeModel *model, + QUndoCommand *parent = 0); + virtual ~ShapeWorldItemsCommand(); + + virtual void undo(); + virtual void redo(); +private: + + const QList m_listPaths; + const QList m_redoPolygons; + const QList m_undoPolygons; + PrimitivesTreeModel *const m_model; + WorldEditorScene *m_scene; + bool m_firstRun; +}; } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 7ec656f85..749392631 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -36,7 +36,7 @@ WorldEditorScene::WorldEditorScene(int sizeCell, PrimitivesTreeModel *model, QUn m_editedSelectedItems(false), m_lastPickedPrimitive(0), m_mode(SelectMode), - m_editMode(false), + m_pointsMode(false), m_undoStack(undoStack), m_model(model) { @@ -86,7 +86,7 @@ AbstractWorldItem *WorldEditorScene::addWorldItemZone(const QPolygonF &polygon) void WorldEditorScene::removeWorldItem(QGraphicsItem *item) { - updateSelectedItems(true); + updateSelectedWorldItems(true); m_selectedItems.clear(); m_editedSelectedItems = false; m_firstSelection = false; @@ -106,14 +106,26 @@ WorldEditorScene::ModeEdit WorldEditorScene::editMode() const return m_mode; } -bool WorldEditorScene::isEnabledEditPoint() const +bool WorldEditorScene::isEnabledEditPoints() const { - return m_editMode; + return m_pointsMode; } -void WorldEditorScene::setEnabledEditPoint(bool enabled) +void WorldEditorScene::setEnabledEditPoints(bool enabled) { - m_editMode = enabled; + if (m_pointsMode == enabled) + return; + + m_pointsMode = enabled; + + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + AbstractWorldItem *worldItem = qgraphicsitem_cast(item); + if (worldItem != 0) + worldItem->setEnabledSubPoints(enabled); + } + + m_selectedPoints.clear(); } void WorldEditorScene::updateSelection(const QList &selected, const QList &deselected) @@ -125,7 +137,7 @@ void WorldEditorScene::updateSelection(const QList &selected, c int i = m_selectedItems.indexOf(item); if (i != -1) { - updateSelectedItem(item, false); + updateSelectedWorldItem(item, false); m_selectedItems.takeAt(i); } } @@ -133,12 +145,17 @@ void WorldEditorScene::updateSelection(const QList &selected, c // Select and add from list graphics items. Q_FOREACH(QGraphicsItem *item, selected) { - updateSelectedItem(item, true); - m_selectedItems.push_back(item); + // Item is selected? + int i = m_selectedItems.indexOf(item); + if (i == -1) + { + updateSelectedWorldItem(item, true); + m_selectedItems.push_back(item); + } } update(); - m_editedSelectedItems = true; + m_firstSelection = true; } void WorldEditorScene::drawForeground(QPainter *painter, const QRectF &rect) @@ -164,65 +181,68 @@ void WorldEditorScene::drawForeground(QPainter *painter, const QRectF &rect) void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { - LandscapeEditor::LandscapeSceneBase::mousePressEvent(mouseEvent); - - if (mouseEvent->button() != Qt::LeftButton) - return; - m_firstPick = mouseEvent->scenePos(); - if ((!m_editedSelectedItems && m_selectedItems.isEmpty()) || - (!calcBoundingRect(m_selectedItems).contains(mouseEvent->scenePos()))) + if (m_pointsMode) { - updatePickSelection(mouseEvent->scenePos()); - m_firstSelection = true; + m_polygons = polygonsFromItems(m_selectedItems); + + if (mouseEvent->button() == Qt::LeftButton) + { + // Create new sub-points + // Call method mousePressEvent for point located under mouse + LandscapeEditor::LandscapeSceneBase::mousePressEvent(mouseEvent); + + if ((!m_editedSelectedItems && m_selectedPoints.isEmpty()) || + (!calcBoundingRect(m_selectedPoints).contains(mouseEvent->scenePos()))) + { + updatePickSelectionPoints(mouseEvent->scenePos()); + m_firstSelection = true; + } + m_pivot = calcBoundingRect(m_selectedPoints).center(); + } + else if (mouseEvent->button() == Qt::RightButton) + { + updateSelectedPointItems(false); + m_selectedPoints.clear(); + + // Delete sub-points if it located under mouse + // Call method mousePressEvent for point located under mouse + LandscapeEditor::LandscapeSceneBase::mousePressEvent(mouseEvent); + } + } + else + { + LandscapeEditor::LandscapeSceneBase::mousePressEvent(mouseEvent); + + if (mouseEvent->button() != Qt::LeftButton) + return; + + if ((!m_editedSelectedItems && m_selectedItems.isEmpty()) || + (!calcBoundingRect(m_selectedItems).contains(mouseEvent->scenePos()))) + { + updatePickSelection(mouseEvent->scenePos()); + m_firstSelection = true; + } + + m_pivot = calcBoundingRect(m_selectedItems).center(); } m_editedSelectedItems = false; + m_angle = 0; + m_scaleFactor = QPointF(1.0, 1.0); - switch (m_mode) - { - case WorldEditorScene::SelectMode: - { + if (m_mode == WorldEditorScene::SelectMode) m_selectionArea.setTopLeft(mouseEvent->scenePos()); - break; - } - case WorldEditorScene::MoveMode: - { - break; - } - case WorldEditorScene::RotateMode: - m_angle = 0; - m_pivot = calcBoundingRect(m_selectedItems).center(); - break; - case WorldEditorScene::ScaleMode: - m_scaleFactor = QPointF(1.0, 1.0); - m_pivot = calcBoundingRect(m_selectedItems).center(); - break; - case WorldEditorScene::TurnMode: - m_angle = 0; - m_pivot = calcBoundingRect(m_selectedItems).center(); - break; - case WorldEditorScene::RadiusMode: - break; - }; - m_selectHack = true; // if (m_selectedItems.isEmpty()) // m_selectionArea.setTopLeft(mouseEvent->scenePos()); } void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { - if (m_selectHack) - { - m_selectHack = false; - updateSelectedItems(true); - } - if (QApplication::mouseButtons() == Qt::LeftButton) { - QPointF offset(mouseEvent->scenePos() - mouseEvent->lastScenePos()); m_selectionArea.setBottomRight(mouseEvent->scenePos()); @@ -233,9 +253,19 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) break; case WorldEditorScene::MoveMode: { - Q_FOREACH(QGraphicsItem *item, m_selectedItems) + if (m_pointsMode) { - item->moveBy(offset.x(), offset.y()); + Q_FOREACH(QGraphicsItem *item, m_selectedPoints) + { + item->moveBy(offset.x(), offset.y()); + } + } + else + { + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + item->moveBy(offset.x(), offset.y()); + } } break; } @@ -248,9 +278,19 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) m_angle += angle; - Q_FOREACH(QGraphicsItem *item, m_selectedItems) + if (m_pointsMode) { - qgraphicsitem_cast(item)->rotateOn(m_pivot, angle); + Q_FOREACH(QGraphicsItem *item, m_selectedPoints) + { + qgraphicsitem_cast(item)->rotateOn(m_pivot, angle); + } + } + else + { + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->rotateOn(m_pivot, angle); + } } break; } @@ -270,9 +310,19 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) m_scaleFactor.setX(offset.x() * m_scaleFactor.x()); m_scaleFactor.setY(offset.y() * m_scaleFactor.y()); - Q_FOREACH(QGraphicsItem *item, m_selectedItems) + if (m_pointsMode) { - qgraphicsitem_cast(item)->scaleOn(m_pivot, offset); + Q_FOREACH(QGraphicsItem *item, m_selectedPoints) + { + qgraphicsitem_cast(item)->scaleOn(m_pivot, offset); + } + } + else + { + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->scaleOn(m_pivot, offset); + } } break; } @@ -296,91 +346,133 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) break; }; - if ((editMode() != WorldEditorScene::SelectMode) && (!m_selectedItems.isEmpty())) - m_editedSelectedItems = true; + if (m_pointsMode) + { + if ((editMode() != WorldEditorScene::SelectMode) && (!m_selectedPoints.isEmpty())) + m_editedSelectedItems = true; + else + m_editedSelectedItems = false; + } else - m_editedSelectedItems = false; + { + if ((editMode() != WorldEditorScene::SelectMode) && (!m_selectedItems.isEmpty())) + m_editedSelectedItems = true; + else + m_editedSelectedItems = false; + } update(); } - /*m_mouseX = mouseEvent->scenePos().x(); - m_mouseY = mouseEvent->scenePos().y() - m_cellSize; - */ + LandscapeEditor::LandscapeSceneBase::mouseMoveEvent(mouseEvent); } void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) { - if (mouseEvent->button() != Qt::LeftButton) - return; - - if (m_editedSelectedItems) + if (m_pointsMode) { - switch (m_mode) + if (mouseEvent->button() == Qt::LeftButton) { - case WorldEditorScene::SelectMode: - break; + if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) + { + QList listItems; - case WorldEditorScene::MoveMode: - { - QPointF offset = mouseEvent->scenePos() - m_firstPick; - m_undoStack->push(new MoveWorldItemsCommand(m_selectedItems, offset, m_model)); - break; + // Clear selection + updateSelectedPointItems(false); + m_selectedPoints.clear(); + + if (m_selectionArea.left() < m_selectionArea.right()) + listItems = items(m_selectionArea, Qt::IntersectsItemShape, Qt::AscendingOrder); + else + listItems = items(m_selectionArea, Qt::ContainsItemShape, Qt::AscendingOrder); + + Q_FOREACH(QGraphicsItem *item, listItems) + { + if (qgraphicsitem_cast(item) == 0) + continue; + + m_selectedPoints.push_back(item); + } + updateSelectedPointItems(true); + m_selectionArea = QRectF(); + update(); + } + else + { + if ((!m_editedSelectedItems) && (!m_firstSelection)) + updatePickSelectionPoints(mouseEvent->scenePos()); + else + m_firstSelection = false; + } } - case WorldEditorScene::RotateMode: - m_undoStack->push(new RotateWorldItemsCommand(m_selectedItems, m_angle, m_pivot, m_model)); - break; - case WorldEditorScene::ScaleMode: - m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, m_pivot, m_model)); - break; - case WorldEditorScene::TurnMode: - m_undoStack->push(new TurnWorldItemsCommand(m_selectedItems, m_angle, m_model)); - break; - case WorldEditorScene::RadiusMode: - break; - }; - } - - if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) - { - QList listItems; - - // Clear selection - updateSelectedItems(false); - m_selectedItems.clear(); - - if (m_selectionArea.left() < m_selectionArea.right()) - { - listItems = items(m_selectionArea, Qt::IntersectsItemShape, - Qt::AscendingOrder); - } - else - { - listItems = items(m_selectionArea, Qt::ContainsItemShape, - Qt::AscendingOrder); - } - - Q_FOREACH(QGraphicsItem *item, listItems) - { - if (qgraphicsitem_cast(item) == 0) - continue; - - m_selectedItems.push_back(item); - } - updateSelectedItems(true); - m_selectionArea = QRectF(); - update(); + checkUndo(); } else { - if ((!m_editedSelectedItems) && (!m_firstSelection)) - updatePickSelection(mouseEvent->scenePos()); - else - m_firstSelection = false; + if (mouseEvent->button() != Qt::LeftButton) + return; - m_selectionArea = QRectF(); + if (m_editedSelectedItems) + { + switch (m_mode) + { + case WorldEditorScene::SelectMode: + break; + + case WorldEditorScene::MoveMode: + { + QPointF offset = mouseEvent->scenePos() - m_firstPick; + m_undoStack->push(new MoveWorldItemsCommand(m_selectedItems, offset, this, m_model)); + break; + } + case WorldEditorScene::RotateMode: + m_undoStack->push(new RotateWorldItemsCommand(m_selectedItems, m_angle, m_pivot, this, m_model)); + break; + case WorldEditorScene::ScaleMode: + m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, m_pivot, this, m_model)); + break; + case WorldEditorScene::TurnMode: + m_undoStack->push(new TurnWorldItemsCommand(m_selectedItems, m_angle, this, m_model)); + break; + case WorldEditorScene::RadiusMode: + break; + }; + } + + if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) + { + QList listItems; + + // Clear selection + updateSelectedWorldItems(false); + m_selectedItems.clear(); + + if (m_selectionArea.left() < m_selectionArea.right()) + listItems = items(m_selectionArea, Qt::IntersectsItemShape, Qt::AscendingOrder); + else + listItems = items(m_selectionArea, Qt::ContainsItemShape, Qt::AscendingOrder); + + Q_FOREACH(QGraphicsItem *item, listItems) + { + if (qgraphicsitem_cast(item) == 0) + continue; + + m_selectedItems.push_back(item); + } + updateSelectedWorldItems(true); + m_selectionArea = QRectF(); + update(); + } + else + { + if ((!m_editedSelectedItems) && (!m_firstSelection)) + updatePickSelection(mouseEvent->scenePos()); + else + m_firstSelection = false; + } } + m_selectionArea = QRectF(); LandscapeEditor::LandscapeSceneBase::mouseReleaseEvent(mouseEvent); } @@ -390,7 +482,7 @@ QRectF WorldEditorScene::calcBoundingRect(const QList &listItem Q_FOREACH(QGraphicsItem *item, listItems) { QRectF itemRect = item->boundingRect(); - rect = rect.united(itemRect.translated(item->pos())); + rect = rect.united(itemRect.translated(item->scenePos())); } return rect; } @@ -401,38 +493,46 @@ QPainterPath WorldEditorScene::calcBoundingShape(const QList &l Q_FOREACH(QGraphicsItem *item, listItems) { QPainterPath itemPath = item->shape(); - painterPath = painterPath.united(itemPath.translated(item->pos())); + painterPath = painterPath.united(itemPath.translated(item->scenePos())); } return painterPath; } -void WorldEditorScene::updateSelectedItems(bool value) +void WorldEditorScene::updateSelectedWorldItems(bool value) { Q_FOREACH(QGraphicsItem *item, m_selectedItems) { - updateSelectedItem(item, value); + updateSelectedWorldItem(item, value); } + update(); } -void WorldEditorScene::updateSelectedItem(QGraphicsItem *item, bool value) +void WorldEditorScene::updateSelectedWorldItem(QGraphicsItem *item, bool value) { - if (value) + AbstractWorldItem *worldItem = qgraphicsitem_cast(item); + if (worldItem != 0) + worldItem->setActived(value); +} + +void WorldEditorScene::updateSelectedPointItems(bool value) +{ + Q_FOREACH(QGraphicsItem *item, m_selectedPoints) { - item->setFlag(QGraphicsItem::ItemIsSelectable); - //item->setZValue(SELECTED_LAYER); + updateSelectedPointItem(item, value); } - else - { - item->setFlag(QGraphicsItem::ItemIsSelectable, false); - //item->setZValue(UNSELECTED_LAYER); - } - item->setSelected(value); + update(); +} + +void WorldEditorScene::updateSelectedPointItem(QGraphicsItem *item, bool value) +{ + WorldItemSubPoint *worldItem = qgraphicsitem_cast(item); + if (worldItem != 0) + worldItem->setActived(value); } void WorldEditorScene::updatePickSelection(const QPointF &point) { - //clearSelection(); - updateSelectedItems(false); + updateSelectedWorldItems(false); m_selectedItems.clear(); QList listItems = items(point, Qt::ContainsItemShape, @@ -454,7 +554,63 @@ void WorldEditorScene::updatePickSelection(const QPointF &point) m_lastPickedPrimitive %= worldItemsItems.size(); m_selectedItems.push_back(worldItemsItems.at(m_lastPickedPrimitive)); - updateSelectedItems(true); + updateSelectedWorldItems(true); + } +} + +void WorldEditorScene::updatePickSelectionPoints(const QPointF &point) +{ + updateSelectedPointItems(false); + m_selectedPoints.clear(); + + QList listItems = items(point, Qt::IntersectsItemBoundingRect, + Qt::AscendingOrder); + + QList subPointsItems; + + Q_FOREACH(QGraphicsItem *item, listItems) + { + WorldItemSubPoint *subPointItem = qgraphicsitem_cast(item); + if (subPointItem != 0) + { + if (subPointItem->subPointType() == WorldItemSubPoint::EdgeType) + subPointsItems.push_back(subPointItem); + } + } + + if (!subPointsItems.isEmpty()) + { + // Next primitives + m_lastPickedPrimitive++; + m_lastPickedPrimitive %= subPointsItems.size(); + + m_selectedPoints.push_back(subPointsItems.at(m_lastPickedPrimitive)); + updateSelectedPointItems(true); + } +} + +void WorldEditorScene::checkUndo() +{ + if (m_pointsMode) + { + QList items; + QList polygons; + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + AbstractWorldItem *worldItem = qgraphicsitem_cast(item); + if (worldItem->isShapeChanged()) + { + items.push_back(item); + polygons.push_back(m_polygons.at(m_selectedItems.indexOf(item))); + worldItem->setShapeChanged(false); + } + } + + if (!items.isEmpty()) + { + m_undoStack->push(new ShapeWorldItemsCommand(items, polygons, this, m_model)); + m_polygons.clear(); + } } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index 3ca055786..adf491889 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -65,10 +65,13 @@ public: void setModeEdit(WorldEditorScene::ModeEdit mode); WorldEditorScene::ModeEdit editMode() const; - bool isEnabledEditPoint() const; + bool isEnabledEditPoints() const; + +Q_SIGNALS: + void selectionUpdated(const QList &selected, const QList &deselected); public Q_SLOTS: - void setEnabledEditPoint(bool enabled); + void setEnabledEditPoints(bool enabled); void updateSelection(const QList &selected, const QList &deselected); protected: @@ -79,25 +82,31 @@ protected: virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); private: - QRectF calcBoundingRect(const QList &listItems); QPainterPath calcBoundingShape(const QList &listItems); - void updateSelectedItems(bool value); - void updateSelectedItem(QGraphicsItem *item, bool value); + + void updateSelectedWorldItems(bool value); + void updateSelectedWorldItem(QGraphicsItem *item, bool value); + void updateSelectedPointItems(bool value); + void updateSelectedPointItem(QGraphicsItem *item, bool value); void updatePickSelection(const QPointF &point); + void updatePickSelectionPoints(const QPointF &point); + + void checkUndo(); QPen m_pen1, m_pen2; QBrush m_brush1, m_brush2; - bool m_selectHack; QPointF m_firstPick, m_scaleFactor, m_pivot; QRectF m_selectionArea; qreal m_firstPickX, m_firstPickY, m_angle; QList m_selectedItems; + QList m_selectedPoints; + QList m_polygons; bool m_editedSelectedItems, m_firstSelection; uint m_lastPickedPrimitive; ModeEdit m_mode; - bool m_editMode; + bool m_pointsMode; QUndoStack *m_undoStack; PrimitivesTreeModel *m_model; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index 89ddd80a5..056a4f01e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -51,265 +51,11 @@ static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, cons p.addPath(path); return p; } -/* -GraphicsItemNode::GraphicsItemNode(GraphicsItemZone *itemZone, QGraphicsItem *parent) - : QGraphicsObject(parent) -{ - m_itemZone = itemZone; - m_color = QColor(12, 150, 215); - //setFlag(ItemIgnoresTransformations, true); - //setFlag(ItemClipsToShape); - - QPropertyAnimation *animation = new QPropertyAnimation(this, "colorNode"); - animation->setDuration(3000); - animation->setStartValue(QColor(10, 0, 50)); - animation->setKeyValueAt(0.5, QColor(155, 255, 0)); - animation->setEndValue(QColor(10, 0, 50)); - animation->setLoopCount(2000); - animation->setEasingCurve(QEasingCurve::OutInExpo); - animation->start(); - - setFlag(ItemIsSelectable); - setFlag(ItemIsMovable); - setFlag(ItemSendsScenePositionChanges); - m_type = EdgeType; - - setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); - setZValue(10000000); -} - -GraphicsItemNode::~GraphicsItemNode() -{ -} - -void GraphicsItemNode::setColorNode(const QColor &color) -{ - m_color = color; - update(); -} - -void GraphicsItemNode::setNodeType(NodeType nodeType) -{ - m_type = nodeType; - if (m_type == EdgeType) - { - setFlag(ItemIsSelectable); - setFlag(ItemIsMovable); - setFlag(ItemSendsScenePositionChanges); - setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); - setZValue(10000); - } - else if (m_type == MiddleType) - { - setFlag(ItemIsSelectable, false); - setFlag(ItemIsMovable, false); - setFlag(ItemSendsScenePositionChanges, false); - setAcceptedMouseButtons(Qt::LeftButton); - setZValue(10001); - } - update(); -} - -QRectF GraphicsItemNode::boundingRect() const -{ - return QRectF(QPointF(0, 0), QSizeF(20, 20)); -} - -void GraphicsItemNode::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, - QWidget *) -{ - // Here comes the magic: - //painter->setClipRect(option->exposedRect); - - painter->setPen(Qt::NoPen); - - if (m_type == EdgeType) - { - painter->setBrush(QColor(255, 0, 0)); - } - else if (m_type == MiddleType) - { - painter->setBrush(QColor(0, 0, 255)); - } - if (option->state & QStyle::State_Selected) - { - painter->setBrush(QColor(0, 255, 0)); - } - - painter->drawRect(2, 2, 18, 18); -} - -QVariant GraphicsItemNode::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - if (change == ItemPositionHasChanged) - { - m_itemZone->updateZone(); - } - return QGraphicsItem::itemChange(change, value); -} - -void GraphicsItemNode::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - if ((m_type == MiddleType) && (event->button() == Qt::LeftButton)) - { - m_itemZone->updateMiddleNode(this); - setNodeType(EdgeType); - } - else if ((m_type == EdgeType) && (event->button() == Qt::RightButton)) - { - if (m_itemZone->deleteEdgePoint(this)) - setNodeType(MiddleType); - } -} - -GraphicsItemZone::GraphicsItemZone(QGraphicsScene *scene, QGraphicsItem *parent) - : QGraphicsPolygonItem(parent) -{ - m_scene = scene; - - m_color = QColor(12, 150, 215); - - setBrush(QBrush(QColor(100, 100, 255, 128))); - updateZone(); - setZValue(100); - //setFlag(ItemClipsToShape); - //setFlag(ItemIsSelectable, true); - //setFlag(ItemIsMovable, true); - //setFlag(ItemHasNoContents, true); -} - -GraphicsItemZone::~GraphicsItemZone() -{ -} - -void GraphicsItemZone::updateMiddleNode(GraphicsItemNode *node) -{ - for (int i = 0; i < m_listLines.size(); ++i) - { - if (node == m_listLines.at(i).itemPoint) - { - LineItem oldLineItem = m_listLines[i]; - - GraphicsItemNode *newNode1 = new GraphicsItemNode(this); - newNode1->setPos((oldLineItem.lineNode.first->pos() + node->pos()) / 2); - newNode1->setNodeType(GraphicsItemNode::MiddleType); - m_scene->addItem(newNode1); - - GraphicsItemNode *newNode2 = new GraphicsItemNode(this); - newNode2->setPos((oldLineItem.lineNode.second->pos() + node->pos()) / 2); - newNode2->setNodeType(GraphicsItemNode::MiddleType); - m_scene->addItem(newNode2); - - LineItem newLineItem1; - newLineItem1.itemPoint = newNode1; - newLineItem1.lineNode = LineNode(oldLineItem.lineNode.first, node); - m_listLines.push_back(newLineItem1); - - LineItem newLineItem2; - newLineItem2.itemPoint = newNode2; - newLineItem2.lineNode = LineNode(node, oldLineItem.lineNode.second); - m_listLines.push_back(newLineItem2); - - m_listLines.removeAt(i); - - int pos = m_listItems.indexOf(oldLineItem.lineNode.second); - m_listItems.insert(pos, node); - - break; - } - } -} - -bool GraphicsItemZone::deleteEdgePoint(GraphicsItemNode *node) -{ - if (m_listItems.size() < 4) - return false; - - int pos = m_listItems.indexOf(node); - m_listItems.takeAt(pos); - - LineItem newLineItem; - - newLineItem.itemPoint = node; - - for (int i = 0; i < m_listLines.size(); ++i) - { - if (node == m_listLines.at(i).lineNode.first) - { - // Saving second point for new line - newLineItem.lineNode.second = m_listLines.at(i).lineNode.second; - delete m_listLines.at(i).itemPoint; - m_listLines.removeAt(i); - break; - } - } - - for (int i = 0; i < m_listLines.size(); ++i) - { - if (node == m_listLines.at(i).lineNode.second) - { - newLineItem.lineNode.first = m_listLines.at(i).lineNode.first; - delete m_listLines.at(i).itemPoint; - m_listLines.removeAt(i); - break; - } - } - node->setPos((newLineItem.lineNode.first->pos() + newLineItem.lineNode.second->pos()) / 2); - m_listLines.push_back(newLineItem); - - return true; -} - -void GraphicsItemZone::scanPolygon(const QPolygonF &polygon) -{ - GraphicsItemNode *node1; - node1 = new GraphicsItemNode(this); - node1->setPos(*polygon.begin()); - m_listItems.push_back(node1); - m_scene->addItem(node1); - for (int i = 1; i < polygon.count(); ++i) - { - GraphicsItemNode *node2 = new GraphicsItemNode(this); - node2->setPos(polygon.at(i)); - m_listItems.push_back(node2); - - GraphicsItemNode *node3 = new GraphicsItemNode(this); - node3->setPos((node1->pos() + node2->pos()) / 2); - node3->setNodeType(GraphicsItemNode::MiddleType); - m_scene->addItem(node3); - - LineItem newLineItem; - newLineItem.itemPoint = node3; - newLineItem.lineNode = LineNode(node1, node2); - m_listLines.push_back(newLineItem); - - node1 = node2; - m_scene->addItem(node1); - } - setPolygon(polygon); -} - -void GraphicsItemZone::updateZone() -{ - QPolygonF polygon; - Q_FOREACH(GraphicsItemNode *node, m_listItems) - { - polygon << node->pos(); - } - - for (int i = 0; i < m_listLines.size(); ++i) - { - m_listLines.at(i).itemPoint->setPos((m_listLines.at(i).lineNode.first->pos() + m_listLines.at(i).lineNode.second->pos()) / 2); - } - - setPolygon(polygon); -} -*/ AbstractWorldItem::AbstractWorldItem(QGraphicsItem *parent) - : QGraphicsItem(parent) + : QGraphicsItem(parent), + m_active(false), + m_shapeChanged(false) { } @@ -322,6 +68,26 @@ int AbstractWorldItem::type() const return Type; } +void AbstractWorldItem::setActived(bool actived) +{ + m_active = actived; +} + +bool AbstractWorldItem::isActived() const +{ + return m_active; +} + +void AbstractWorldItem::setShapeChanged(bool value) +{ + m_shapeChanged = value; +} + +bool AbstractWorldItem::isShapeChanged() const +{ + return m_shapeChanged; +} + WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, const qreal radius, bool showArrow, QGraphicsItem *parent) : AbstractWorldItem(parent), @@ -360,7 +126,6 @@ WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, const qr } updateBoundingRect(); - //setFlag(ItemIsSelectable); } WorldItemPoint::~WorldItemPoint() @@ -373,9 +138,7 @@ void WorldItemPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle) QPolygonF rotatedPolygon(m_rect); - // TODO rotatedPolygon.translate(pos() - pivot); - //rotatedPolygon.translate(-pivot); QTransform trans; trans = trans.rotate(deltaAngle); @@ -391,9 +154,7 @@ void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &factor) QPolygonF scaledPolygon(m_rect); - // TODO scaledPolygon.translate(pos() - pivot); - //scaledPolygon.translate(-pivot); QTransform trans; trans = trans.scale(factor.x(), factor.y()); @@ -478,7 +239,8 @@ void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *op painter->drawLines(m_arrow); painter->setPen(Qt::NoPen); - if (option->state & QStyle::State_Selected) +// if (option->state & QStyle::State_Selected) + if (isActived()) painter->setBrush(m_selectedBrush); else painter->setBrush(m_brush); @@ -487,17 +249,10 @@ void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *op painter->drawRect(m_rect); } -QVariant WorldItemPoint::itemChange(GraphicsItemChange change, const QVariant &value) -{ - if (change == ItemPositionHasChanged) - { - } - return QGraphicsItem::itemChange(change, value); -} - WorldItemPath::WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent) : AbstractWorldItem(parent), - m_polygon(polygon) + m_polygon(polygon), + m_pointEdit(false) { //setFlag(ItemIsSelectable); @@ -548,19 +303,144 @@ void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &factor) m_polygon.translate(pivot - pos()); } -void WorldItemPath::turnOn(const qreal angle) -{ -} - -void WorldItemPath::radiusOn(const qreal radius) -{ -} - void WorldItemPath::setColor(const QColor &color) { m_pen.setColor(color); } + +void WorldItemPath::setEnabledSubPoints(bool enabled) +{ + m_pointEdit = enabled; + if (m_pointEdit) + createSubPoints(); + else + removeSubPoints(); +} + +void WorldItemPath::moveSubPoint(WorldItemSubPoint *subPoint) +{ + prepareGeometryChange(); + + QPolygonF polygon; + + // Update polygon + Q_FOREACH(WorldItemSubPoint *node, m_listItems) + { + polygon << node->pos(); + } + + // Update middle points + for (int i = 0; i < m_listLines.size(); ++i) + m_listLines.at(i).itemPoint->setPos((m_listLines.at(i).lineItem.first->pos() + m_listLines.at(i).lineItem.second->pos()) / 2); + + m_polygon = polygon; + update(); +} + +void WorldItemPath::addSubPoint(WorldItemSubPoint *subPoint) +{ + prepareGeometryChange(); + + for (int i = 0; i < m_listLines.size(); ++i) + { + if (subPoint == m_listLines.at(i).itemPoint) + { + LineStruct oldLineItem = m_listLines[i]; + + // Create the first middle sub-point + WorldItemSubPoint *firstItem = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); + firstItem->setPos((oldLineItem.lineItem.first->pos() + subPoint->pos()) / 2); + + // Create the second middle sub-point + WorldItemSubPoint *secondItem = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); + secondItem->setPos((oldLineItem.lineItem.second->pos() + subPoint->pos()) / 2); + + // Add first line in the list + LineStruct firstNewLineItem; + firstNewLineItem.itemPoint = firstItem; + firstNewLineItem.lineItem = LineItem(oldLineItem.lineItem.first, subPoint); + m_listLines.push_back(firstNewLineItem); + + // Add second line in the list + LineStruct secondNewLineItem; + secondNewLineItem.itemPoint = secondItem; + secondNewLineItem.lineItem = LineItem(subPoint, oldLineItem.lineItem.second); + m_listLines.push_back(secondNewLineItem); + + m_listLines.removeAt(i); + + int pos = m_listItems.indexOf(oldLineItem.lineItem.second); + m_listItems.insert(pos, subPoint); + subPoint->setFlag(ItemSendsScenePositionChanges); + + break; + } + } +} + +bool WorldItemPath::removeSubPoint(WorldItemSubPoint *subPoint) +{ + int pos = m_listItems.indexOf(subPoint); + + // First and second points can not be removed + if ((pos == 0) || (pos == m_listItems.size() - 1)) + return false; + + prepareGeometryChange(); + + m_listItems.takeAt(pos); + + LineStruct newLineItem; + + newLineItem.itemPoint = subPoint; + + // Delete first line + for (int i = 0; i < m_listLines.size(); ++i) + { + if (subPoint == m_listLines.at(i).lineItem.first) + { + // Saving second point for new line + newLineItem.lineItem.second = m_listLines.at(i).lineItem.second; + delete m_listLines.at(i).itemPoint; + m_listLines.removeAt(i); + break; + } + } + + // Delete second line + for (int i = 0; i < m_listLines.size(); ++i) + { + if (subPoint == m_listLines.at(i).lineItem.second) + { + // Saving first point for new line + newLineItem.lineItem.first = m_listLines.at(i).lineItem.first; + delete m_listLines.at(i).itemPoint; + m_listLines.removeAt(i); + break; + } + } + subPoint->setPos((newLineItem.lineItem.first->pos() + newLineItem.lineItem.second->pos()) / 2); + m_listLines.push_back(newLineItem); + subPoint->setFlag(ItemSendsScenePositionChanges, false); + + return true; +} + +void WorldItemPath::setPolygon(const QPolygonF &polygon) +{ + prepareGeometryChange(); + + m_polygon = polygon; + + update(); +} + +QPolygonF WorldItemPath::polygon() const +{ + return m_polygon; +} + QPainterPath WorldItemPath::shape() const { QPainterPath path; @@ -582,7 +462,8 @@ void WorldItemPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt // Here comes the magic: //painter->setClipRect(option->exposedRect); - if (option->state & QStyle::State_Selected) + //if (option->state & QStyle::State_Selected) + if (isActived()) painter->setPen(m_selectedPen); else painter->setPen(m_pen); @@ -590,17 +471,49 @@ void WorldItemPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt painter->drawPolyline(m_polygon); } -QVariant WorldItemPath::itemChange(GraphicsItemChange change, const QVariant &value) +void WorldItemPath::createSubPoints() { - if (change == ItemPositionHasChanged) + WorldItemSubPoint *firstPoint; + firstPoint = new WorldItemSubPoint(WorldItemSubPoint::EdgeType, this); + firstPoint->setPos(m_polygon.front()); + firstPoint->setFlag(ItemSendsScenePositionChanges); + m_listItems.push_back(firstPoint); + + for (int i = 1; i < m_polygon.count(); ++i) { + WorldItemSubPoint *secondPoint = new WorldItemSubPoint(WorldItemSubPoint::EdgeType, this); + secondPoint->setPos(m_polygon.at(i)); + secondPoint->setFlag(ItemSendsScenePositionChanges); + + WorldItemSubPoint *middlePoint = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); + middlePoint->setPos((firstPoint->pos() + secondPoint->pos()) / 2); + + LineStruct newLineItem; + newLineItem.itemPoint = middlePoint; + newLineItem.lineItem = LineItem(firstPoint, secondPoint); + m_listLines.push_back(newLineItem); + + firstPoint = secondPoint; + m_listItems.push_back(firstPoint); } - return QGraphicsItem::itemChange(change, value); +} + +void WorldItemPath::removeSubPoints() +{ + for (int i = 0; i < m_listLines.count(); ++i) + delete m_listLines.at(i).itemPoint; + + for (int i = 0; i < m_listItems.count(); ++i) + delete m_listItems.at(i); + + m_listItems.clear(); + m_listLines.clear(); } WorldItemZone::WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent) : AbstractWorldItem(parent), - m_polygon(polygon) + m_polygon(polygon), + m_pointEdit(false) { //setFlag(ItemIsSelectable); @@ -646,7 +559,6 @@ void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &factor) prepareGeometryChange(); QPolygonF scaledPolygon(m_polygon); - scaledPolygon.translate(pos() - pivot); QTransform trans; @@ -656,14 +568,6 @@ void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &factor) m_polygon.translate(pivot - pos()); } -void WorldItemZone::turnOn(const qreal angle) -{ -} - -void WorldItemZone::radiusOn(const qreal radius) -{ -} - void WorldItemZone::setColor(const QColor &color) { m_pen.setColor(color); @@ -674,6 +578,143 @@ void WorldItemZone::setColor(const QColor &color) m_brush.setColor(brushColor); } +void WorldItemZone::setEnabledSubPoints(bool enabled) +{ + m_pointEdit = enabled; + if (m_pointEdit) + createSubPoints(); + else + removeSubPoints(); + + setShapeChanged(false); +} + +void WorldItemZone::moveSubPoint(WorldItemSubPoint *subPoint) +{ + prepareGeometryChange(); + + QPolygonF polygon; + + // Update polygon + Q_FOREACH(WorldItemSubPoint *node, m_listItems) + { + polygon << node->pos(); + } + + // Update middle points + for (int i = 0; i < m_listLines.size(); ++i) + m_listLines.at(i).itemPoint->setPos((m_listLines.at(i).lineItem.first->pos() + m_listLines.at(i).lineItem.second->pos()) / 2); + + m_polygon = polygon; + update(); + + setShapeChanged(true); +} + +void WorldItemZone::addSubPoint(WorldItemSubPoint *subPoint) +{ + prepareGeometryChange(); + + for (int i = 0; i < m_listLines.size(); ++i) + { + if (subPoint == m_listLines.at(i).itemPoint) + { + LineStruct oldLineItem = m_listLines[i]; + + // Create the first middle sub-point + WorldItemSubPoint *firstItem = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); + firstItem->setPos((oldLineItem.lineItem.first->pos() + subPoint->pos()) / 2); + + // Create the second middle sub-point + WorldItemSubPoint *secondItem = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); + secondItem->setPos((oldLineItem.lineItem.second->pos() + subPoint->pos()) / 2); + + // Add first line in the list + LineStruct firstNewLineItem; + firstNewLineItem.itemPoint = firstItem; + firstNewLineItem.lineItem = LineItem(oldLineItem.lineItem.first, subPoint); + m_listLines.push_back(firstNewLineItem); + + // Add second line in the list + LineStruct secondNewLineItem; + secondNewLineItem.itemPoint = secondItem; + secondNewLineItem.lineItem = LineItem(subPoint, oldLineItem.lineItem.second); + m_listLines.push_back(secondNewLineItem); + + m_listLines.removeAt(i); + + int pos = m_listItems.indexOf(oldLineItem.lineItem.second); + m_listItems.insert(pos, subPoint); + subPoint->setFlag(ItemSendsScenePositionChanges); + + break; + } + } + setShapeChanged(true); +} + +bool WorldItemZone::removeSubPoint(WorldItemSubPoint *subPoint) +{ + prepareGeometryChange(); + + if (m_listItems.size() < 4) + return false; + + int pos = m_listItems.indexOf(subPoint); + m_listItems.takeAt(pos); + + LineStruct newLineItem; + + newLineItem.itemPoint = subPoint; + + // Delete first line + for (int i = 0; i < m_listLines.size(); ++i) + { + if (subPoint == m_listLines.at(i).lineItem.first) + { + // Saving second point for new line + newLineItem.lineItem.second = m_listLines.at(i).lineItem.second; + delete m_listLines.at(i).itemPoint; + m_listLines.removeAt(i); + break; + } + } + + // Delete second line + for (int i = 0; i < m_listLines.size(); ++i) + { + if (subPoint == m_listLines.at(i).lineItem.second) + { + // Saving first point for new line + newLineItem.lineItem.first = m_listLines.at(i).lineItem.first; + delete m_listLines.at(i).itemPoint; + m_listLines.removeAt(i); + break; + } + } + m_listLines.push_back(newLineItem); + subPoint->setPos((newLineItem.lineItem.first->pos() + newLineItem.lineItem.second->pos()) / 2); + subPoint->setFlag(ItemSendsScenePositionChanges, false); + + setShapeChanged(true); + + return true; +} + +void WorldItemZone::setPolygon(const QPolygonF &polygon) +{ + prepareGeometryChange(); + + m_polygon = polygon; + + update(); +} + +QPolygonF WorldItemZone::polygon() const +{ + return m_polygon; +} + QRectF WorldItemZone::boundingRect() const { return m_polygon.boundingRect(); @@ -688,7 +729,8 @@ QPainterPath WorldItemZone::shape() const void WorldItemZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) { - if (option->state & QStyle::State_Selected) +// if (option->state & QStyle::State_Selected) + if (isActived()) { painter->setPen(m_selectedPen); painter->setBrush(m_selectedBrush); @@ -702,12 +744,192 @@ void WorldItemZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt painter->drawPolygon(m_polygon); } -QVariant WorldItemZone::itemChange(GraphicsItemChange change, const QVariant &value) +void WorldItemZone::createSubPoints() +{ + WorldItemSubPoint *firstPoint; + firstPoint = new WorldItemSubPoint(WorldItemSubPoint::EdgeType, this); + firstPoint->setPos(m_polygon.front()); + firstPoint->setFlag(ItemSendsScenePositionChanges); + m_listItems.push_back(firstPoint); + + for (int i = 1; i < m_polygon.count(); ++i) + { + WorldItemSubPoint *secondPoint = new WorldItemSubPoint(WorldItemSubPoint::EdgeType, this); + secondPoint->setPos(m_polygon.at(i)); + secondPoint->setFlag(ItemSendsScenePositionChanges); + + WorldItemSubPoint *middlePoint = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); + middlePoint->setPos((firstPoint->pos() + secondPoint->pos()) / 2); + + LineStruct newLineItem; + newLineItem.itemPoint = middlePoint; + newLineItem.lineItem = LineItem(firstPoint, secondPoint); + m_listLines.push_back(newLineItem); + + firstPoint = secondPoint; + m_listItems.push_back(firstPoint); + } + + LineStruct endLineItem; + endLineItem.itemPoint = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); + endLineItem.itemPoint->setPos((m_listItems.first()->pos() + m_listItems.last()->pos()) / 2); + endLineItem.lineItem = LineItem(m_listItems.last(), m_listItems.first()); + m_listLines.push_back(endLineItem); +} + +void WorldItemZone::removeSubPoints() +{ + for (int i = 0; i < m_listLines.count(); ++i) + delete m_listLines.at(i).itemPoint; + + for (int i = 0; i < m_listItems.count(); ++i) + delete m_listItems.at(i); + + m_listItems.clear(); + m_listLines.clear(); +} + +//******************************************* + +WorldItemSubPoint::WorldItemSubPoint(SubPointType pointType, AbstractWorldItem *parent) + : QGraphicsObject(parent), + m_type(pointType), + m_active(false), + m_parent(parent) +{ + setZValue(WORLD_POINT_LAYER); + + m_brush.setColor(QColor(20, 100, 255)); + m_brush.setStyle(Qt::SolidPattern); + + m_brushMiddle.setColor(QColor(255, 25, 100)); + m_brushMiddle.setStyle(Qt::SolidPattern); + + m_selectedBrush.setColor(QColor(255, 255, 255, 100)); + m_selectedBrush.setStyle(Qt::SolidPattern); + + m_rect.setCoords(-SIZE_POINT, -SIZE_POINT, SIZE_POINT, SIZE_POINT); + updateBoundingRect(); + + //setFlag(ItemIgnoresTransformations); + //setFlag(ItemSendsScenePositionChanges); +} + +WorldItemSubPoint::~WorldItemSubPoint() +{ +} + +void WorldItemSubPoint::setSubPointType(SubPointType nodeType) +{ + m_type = nodeType; + setFlag(ItemSendsScenePositionChanges); +} + +WorldItemSubPoint::SubPointType WorldItemSubPoint::subPointType() const +{ + return m_type; +} + +void WorldItemSubPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle) +{ + prepareGeometryChange(); + + QPolygonF rotatedPolygon(m_rect); + + // TODO + rotatedPolygon.translate(scenePos() - pivot); + + QTransform trans; + trans = trans.rotate(deltaAngle); + rotatedPolygon = trans.map(rotatedPolygon); + rotatedPolygon.translate(pivot); + + setPos(m_parent->mapFromParent(rotatedPolygon.boundingRect().center())); +} + +void WorldItemSubPoint::scaleOn(const QPointF &pivot, const QPointF &factor) +{ + prepareGeometryChange(); + + QPolygonF scaledPolygon(m_rect); + + // TODO + scaledPolygon.translate(scenePos() - pivot); + //scaledPolygon.translate(-pivot); + + QTransform trans; + trans = trans.scale(factor.x(), factor.y()); + scaledPolygon = trans.map(scaledPolygon); + scaledPolygon.translate(pivot); + + setPos(m_parent->mapFromParent(scaledPolygon.boundingRect().center())); +} + +QRectF WorldItemSubPoint::boundingRect() const +{ + return m_boundingRect; +} + +void WorldItemSubPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->setPen(Qt::NoPen); + + if (m_type == WorldItemSubPoint::EdgeType) + { + if (isActived()) + painter->setBrush(m_selectedBrush); + else + painter->setBrush(m_brush); + } + else + { + painter->setBrush(m_brushMiddle); + } + + // Draw point + painter->drawRect(m_rect); +} + +int WorldItemSubPoint::type() const +{ + return Type; +} + +void WorldItemSubPoint::setActived(bool actived) +{ + m_active = actived; +} + +bool WorldItemSubPoint::isActived() const +{ + return m_active; +} + +QVariant WorldItemSubPoint::itemChange(GraphicsItemChange change, const QVariant &value) { if (change == ItemPositionHasChanged) - { - } + m_parent->moveSubPoint(this); return QGraphicsItem::itemChange(change, value); } +void WorldItemSubPoint::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if ((m_type == MiddleType) && (event->button() == Qt::LeftButton)) + { + m_parent->addSubPoint(this); + setSubPointType(EdgeType); + } + else if ((m_type == EdgeType) && (event->button() == Qt::RightButton)) + { + if (m_parent->removeSubPoint(this)) + setSubPointType(MiddleType); + } + update(); +} + +void WorldItemSubPoint::updateBoundingRect() +{ + m_boundingRect.setCoords(-SIZE_POINT, -SIZE_POINT, SIZE_POINT, SIZE_POINT); +} + } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index 0625084bd..1b934d77b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -32,10 +32,15 @@ namespace WorldEditor { -class GraphicsItemZone; -class GraphicsItemNode; +class WorldItemSubPoint; -typedef QPair LineNode; +typedef QPair LineItem; + +struct LineStruct +{ + WorldItemSubPoint *itemPoint; + LineItem lineItem; +}; const int SELECTED_LAYER = 200; const int UNSELECTED_LAYER = 100; @@ -46,75 +51,6 @@ const int MIDDLE_POINT_LAYER = 201; const int EDGE_POINT_LAYER = 201; const int SIZE_ARROW = 20; -/* -// Deprecated -class GraphicsItemNode: public QGraphicsObject -{ - Q_OBJECT - Q_PROPERTY(QColor colorNode READ colorNode WRITE setColorNode) -public: - enum NodeType - { - EdgeType = 0, - MiddleType - }; - - GraphicsItemNode(GraphicsItemZone *itemZone, QGraphicsItem *parent = 0); - virtual ~GraphicsItemNode(); - - void setColorNode(const QColor &color); - QColor colorNode() const - { - return m_color; - } - - void setNodeType(NodeType nodeType); - - virtual QRectF boundingRect() const; - //QPainterPath shape() const; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - -protected: - virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); - -private: - - NodeType m_type; - GraphicsItemZone *m_itemZone; - QColor m_color; -}; - -// Deprecated -class GraphicsItemZone: public QGraphicsPolygonItem -{ -public: - GraphicsItemZone(QGraphicsScene *scene, QGraphicsItem *parent = 0); - virtual ~GraphicsItemZone(); - - void scanPolygon(const QPolygonF &polygon); - void updateMiddleNode(GraphicsItemNode *node); - bool deleteEdgePoint(GraphicsItemNode *node); - //void addNode(GraphicsItemNode *node); - void updateZone(); - //QRectF boundingRect() const; - //void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - -protected: - // QVariant itemChange(GraphicsItemChange change, const QVariant &value); - -private: - struct LineItem - { - GraphicsItemNode *itemPoint; - LineNode lineNode; - }; - QGraphicsScene *m_scene; - QColor m_color; - QList m_listItems; - QList m_listLines; -}; -*/ /* @class WorldItemPoint @@ -129,16 +65,40 @@ public: enum { Type = QGraphicsItem::UserType + 1 }; - virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) = 0; + virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) {}; // TODO: add modes: IgnoreAspectRatio, KeepAspectRatio - virtual void scaleOn(const QPointF &pivot, const QPointF &factor) = 0; - virtual void turnOn(const qreal angle) = 0; - virtual void radiusOn(const qreal radius) = 0; + virtual void scaleOn(const QPointF &pivot, const QPointF &factor) {}; + virtual void turnOn(const qreal angle) {}; + virtual void radiusOn(const qreal radius) {}; virtual void setColor(const QColor &color) = 0; + virtual void setEnabledSubPoints(bool enabled) = 0; + + virtual void moveSubPoint(WorldItemSubPoint *subPoint) {} + virtual void addSubPoint(WorldItemSubPoint *subPoint) {} + virtual bool removeSubPoint(WorldItemSubPoint *subPoint) + { + return false; + } + + virtual void setPolygon(const QPolygonF &polygon) {} + virtual QPolygonF polygon() const + { + return QPolygonF(); + } + + void setActived(bool actived); + bool isActived() const; + + void setShapeChanged(bool value); + bool isShapeChanged() const; // Enable the use of qgraphicsitem_cast with this item. int type() const; + +protected: + + bool m_active, m_shapeChanged; }; /* @@ -159,19 +119,16 @@ public: virtual void radiusOn(const qreal radius); virtual void setColor(const QColor &color); + virtual void setEnabledSubPoints(bool enabled) {} virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -protected: - virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); - private: void createCircle(); void updateBoundingRect(); - // TODO static const int SIZE_POINT = 3; QPen m_pen, m_selectedPen; @@ -197,20 +154,31 @@ public: virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); - virtual void turnOn(const qreal angle); - virtual void radiusOn(const qreal radius); virtual void setColor(const QColor &color); + virtual void setEnabledSubPoints(bool enabled); + + virtual void moveSubPoint(WorldItemSubPoint *subPoint); + virtual void addSubPoint(WorldItemSubPoint *subPoint); + virtual bool removeSubPoint(WorldItemSubPoint *subPoint); + + virtual void setPolygon(const QPolygonF &polygon); + virtual QPolygonF polygon() const; virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -protected: - virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); +private: + void createSubPoints(); + void removeSubPoints(); QPen m_pen, m_selectedPen; QPolygonF m_polygon; + bool m_pointEdit; + + QList m_listItems; + QList m_listLines; }; /* @@ -226,27 +194,91 @@ public: virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); - virtual void turnOn(const qreal angle); - virtual void radiusOn(const qreal radius); virtual void setColor(const QColor &color); + virtual void setEnabledSubPoints(bool enabled); + + virtual void moveSubPoint(WorldItemSubPoint *subPoint); + virtual void addSubPoint(WorldItemSubPoint *subPoint); + virtual bool removeSubPoint(WorldItemSubPoint *subPoint); + + virtual void setPolygon(const QPolygonF &polygon); + virtual QPolygonF polygon() const; virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -protected: - virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); +private: + void createSubPoints(); + void removeSubPoints(); static const int TRANSPARENCY = 38; QPen m_pen, m_selectedPen; QBrush m_brush, m_selectedBrush; QPolygonF m_polygon; + bool m_pointEdit; + + QList m_listItems; + QList m_listLines; +}; + +/* +@class WorldItemSubPoint +@brief +@details +*/ +class WorldItemSubPoint: public QGraphicsObject +{ + Q_OBJECT +public: + enum SubPointType + { + EdgeType = 0, + MiddleType + }; + + enum { Type = QGraphicsItem::UserType + 2 }; + + WorldItemSubPoint(SubPointType pointType, AbstractWorldItem *parent = 0); + virtual ~WorldItemSubPoint(); + + void setSubPointType(SubPointType nodeType); + SubPointType subPointType() const; + + void rotateOn(const QPointF &pivot, const qreal deltaAngle); + void scaleOn(const QPointF &pivot, const QPointF &factor); + + virtual QRectF boundingRect() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + void setActived(bool actived); + bool isActived() const; + + // Enable the use of qgraphicsitem_cast with this item. + int type() const; + +protected: + virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); + +private: + void updateBoundingRect(); + + static const int SIZE_POINT = 6; + + QBrush m_brush, m_brushMiddle, m_selectedBrush; + + QRectF m_rect, m_boundingRect; + SubPointType m_type; + bool m_active; + AbstractWorldItem *m_parent; }; } /* namespace WorldEditor */ +// Enable the use of QVariant with this class. Q_DECLARE_METATYPE(WorldEditor::AbstractWorldItem *) #endif // WORLD_EDITOR_SCENE_ITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index e00e804f3..009ede2e1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -98,7 +98,7 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_modeMapper->setMapping(m_ui.radiusAction, 5); connect(m_modeMapper, SIGNAL(mapped(int)), this, SLOT(setMode(int))); - connect(m_ui.pointsAction, SIGNAL(triggered(bool)), m_worldEditorScene, SLOT(setEnabledEditPoint(bool))); + connect(m_ui.pointsAction, SIGNAL(triggered(bool)), m_worldEditorScene, SLOT(setEnabledEditPoints(bool))); connect(m_ui.settingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings())); connect(m_ui.newWorldEditAction, SIGNAL(triggered()), this, SLOT(newWorldEditFile())); @@ -256,6 +256,7 @@ void WorldEditorWindow::updateStatusBar() void WorldEditorWindow::updateSelection(const QItemSelection &selected, const QItemSelection &deselected) { m_ui.pointsAction->setChecked(false); + m_worldEditorScene->setEnabledEditPoints(false); NodeList nodesSelected; Q_FOREACH(QModelIndex modelIndex, selected.indexes()) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index c556514b7..1de6cbdc3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -37,7 +37,7 @@ QGraphicsView::AnchorUnderMouse - QGraphicsView::BoundingRectViewportUpdate + QGraphicsView::FullViewportUpdate QGraphicsView::DontAdjustForAntialiasing|QGraphicsView::DontClipPainter @@ -129,6 +129,15 @@ + + + Property Editor + + + 2 + + + loadPrimitive @@ -319,7 +328,7 @@ true - false + true Edit points @@ -346,6 +355,12 @@ QTreeView
primitives_view.h
+ + WorldEditor::PropertyEditorWidget + QWidget +
property_editor_widget.h
+ 1 +
From 2650b86ca81f60ea7942af0b47aecdb5cf256379 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 15 Aug 2011 17:04:09 +0300 Subject: [PATCH 057/747] Changed: #1302 Added empty property dialog. --- .../src/plugins/world_editor/CMakeLists.txt | 16 ++++- .../world_editor/property_editor_widget.cpp | 60 ++++++++++++++++++ .../world_editor/property_editor_widget.h | 63 +++++++++++++++++++ .../world_editor/property_editor_widget.ui | 40 ++++++++++++ 4 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt index 7b9387c44..694467f42 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/CMakeLists.txt @@ -1,7 +1,9 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${LIBXML2_INCLUDE_DIR} - ${QT_INCLUDES}) + ${QT_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/qtpropertybrowser + ) FILE(GLOB SRC *.cpp *.h) @@ -16,11 +18,13 @@ SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h primitives_model.h primitives_view.h project_settings_dialog.h + property_editor_widget.h world_editor_settings_page.h ) SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui project_settings_dialog.ui + property_editor_widget.ui world_editor_settings_page.ui ) @@ -45,7 +49,15 @@ ADD_LIBRARY(ovqt_plugin_world_editor MODULE ${SRC} ${OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS} ${OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS}) -TARGET_LINK_LIBRARIES(ovqt_plugin_world_editor ovqt_plugin_core ovqt_plugin_landscape_editor nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) +TARGET_LINK_LIBRARIES( ovqt_plugin_world_editor + ovqt_plugin_core + ovqt_plugin_landscape_editor + nelmisc + nel3d + qt_property_browser + ${QT_LIBRARIES} + ${QT_QTOPENGL_LIBRARY} +) NL_DEFAULT_PROPS(ovqt_plugin_world_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: World Editor") NL_ADD_RUNTIME_FLAGS(ovqt_plugin_world_editor) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp new file mode 100644 index 000000000..7df0b6d1d --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp @@ -0,0 +1,60 @@ +// 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 "property_editor_widget.h" + +// NeL includes +#include + +// STL includes +#include +#include + +// Qt includes +#include + +namespace WorldEditor +{ + +PropertyEditorWidget::PropertyEditorWidget(QWidget *parent) + : QWidget(parent) +{ + m_ui.setupUi(this); + + m_variantManager = new QtVariantPropertyManager(this); + + connect(m_variantManager, SIGNAL(valueChanged(QtProperty *, const QVariant &)), + this, SLOT(valueChanged(QtProperty *, const QVariant &))); + + QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this); + m_ui.treePropertyBrowser->setFactoryForManager(m_variantManager, variantFactory); +} + +PropertyEditorWidget::~PropertyEditorWidget() +{ +} + +void PropertyEditorWidget::clearProperties() +{ +} + +void PropertyEditorWidget::setCurrentPrimitive(PrimitiveNode *node) +{ +} + +} /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h new file mode 100644 index 000000000..18f72fadc --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h @@ -0,0 +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 . + +#ifndef PROPERTY_EDITOR_WIDGET_H +#define PROPERTY_EDITOR_WIDGET_H + +// Project includes +#include "ui_property_editor_widget.h" +#include "primitives_model.h" +#include "primitive_item.h" + + +// 3rdparty +#include "qtvariantproperty.h" +#include "qtpropertymanager.h" +#include "qteditorfactory.h" + +// NeL includes + +// Qt includes + +namespace WorldEditor +{ +/** +@class PropertyEditorWidget +@brief PropertyEditorWidget +@details +*/ +class PropertyEditorWidget: public QWidget +{ + Q_OBJECT + +public: + PropertyEditorWidget(QWidget *parent = 0); + ~PropertyEditorWidget(); + +public Q_SLOTS: + void clearProperties(); + void setCurrentPrimitive(PrimitiveNode *node); + +private: + + QtVariantPropertyManager *m_variantManager; + Ui::PropertyEditorWidget m_ui; +}; /* PropertyEditorWidget */ + +} /* namespace WorldEditor */ + +#endif // PROPERTY_EDITOR_WIDGET_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.ui new file mode 100644 index 000000000..a703c7aac --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.ui @@ -0,0 +1,40 @@ + + + PropertyEditorWidget + + + + 0 + 0 + 183 + 128 + + + + Form + + + + 3 + + + 3 + + + + + + + + + QtTreePropertyBrowser + QWidget +
qttreepropertybrowser.h
+ 1 +
+
+ + + + +
From 2ccc79a591cab4e9b8a342ed2934e13080178fc7 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 16 Aug 2011 01:10:22 +0300 Subject: [PATCH 058/747] Changed: #1302 When create zone or path initially has minimal 3 points and path 2 points resp. --- .../world_editor/world_editor_actions.cpp | 19 ++++++++--- .../world_editor/world_editor_actions.h | 2 ++ .../world_editor/world_editor_misc.cpp | 18 +++++++++-- .../world_editor/world_editor_scene_item.cpp | 6 +++- .../world_editor/world_editor_scene_item.h | 2 +- .../world_editor/world_editor_window.ui | 32 +++++++++++++++---- 6 files changed, 64 insertions(+), 15 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 45adf49ce..f40e498a1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -38,6 +38,7 @@ // Qt includes #include +#include #include namespace WorldEditor @@ -365,6 +366,13 @@ AddPrimitiveByClassCommand::AddPrimitiveByClassCommand(const QString &className, m_model(model) { setText(QString("Add %1").arg(m_className)); + + QGraphicsView *view = m_scene->views().first(); + + // TODO: returns incorrect position when zoom in + QRectF visibleArea = view->mapToScene(view->rect()).boundingRect(); + m_delta = visibleArea.height() / 10.0; + m_initPos = visibleArea.center(); } AddPrimitiveByClassCommand::~AddPrimitiveByClassCommand() @@ -381,6 +389,8 @@ void AddPrimitiveByClassCommand::undo() // set the primitive context NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = node->rootPrimitiveNode()->primitives(); + removeGraphicsItems(index, m_model, m_scene); + Utils::deletePrimitive(node->primitive()); // unset the context @@ -397,7 +407,6 @@ void AddPrimitiveByClassCommand::redo() PrimitiveNode *parentNode = static_cast(parentIndex.internalPointer()); const NLLIGO::CPrimitiveClass *primClass = parentNode->primitiveClass(); - float delta = 10; int id = 0; while (primClass->DynamicChildren[id].ClassName != m_className.toStdString()) ++id; @@ -407,12 +416,14 @@ void AddPrimitiveByClassCommand::redo() QString namePrimititve = QString("%1_%2").arg(m_className).arg(parentNode->childCount()); NLLIGO::IPrimitive *newPrimitive = Utils::createPrimitive(m_className.toStdString().c_str(), namePrimititve.toStdString().c_str(), - NLMISC::CVector(), delta, primClass->DynamicChildren[id].Parameters, parentNode->primitive()); + NLMISC::CVector(m_initPos.x(), -m_initPos.y(), 0.0), m_delta, primClass->DynamicChildren[id].Parameters, parentNode->primitive()); // unset the context NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL; m_newPrimIndex = m_model->createPrimitiveNode(newPrimitive, m_parentIndex); + + addNewGraphicsItems(m_model->pathToIndex(m_newPrimIndex), m_model, m_scene); } MoveWorldItemsCommand::MoveWorldItemsCommand(const QList &items, const QPointF &offset, @@ -471,7 +482,7 @@ RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &i m_scene(scene), m_firstRun(true) { - setText(QString("Rotate item(s) %1").arg(m_angle)); + setText("Rotate item(s)"); } RotateWorldItemsCommand::~RotateWorldItemsCommand() @@ -565,7 +576,7 @@ TurnWorldItemsCommand::TurnWorldItemsCommand(const QList &items m_scene(scene), m_firstRun(true) { - setText(QString("Turn item(s) %1").arg(m_angle)); + setText("Turn item(s)"); } TurnWorldItemsCommand::~TurnWorldItemsCommand() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index fcb510605..a8352e2e6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -147,6 +147,8 @@ public: virtual void redo(); private: + QPointF m_initPos; + float m_delta; const QString m_className; Path m_parentIndex, m_newPrimIndex; WorldEditorScene *m_scene; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp index 1f77ee63d..5b5b9540d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp @@ -365,11 +365,25 @@ NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName, } break; case NLLIGO::CPrimitiveClass::Path: - primitive = new NLLIGO::CPrimPath; + { + NLLIGO::CPrimPath *path = new NLLIGO::CPrimPath; + primitive = path; + path->VPoints.push_back(NLLIGO::CPrimVector(initPos)); + NLMISC::CVector secondPos = NLMISC::CVector(initPos.x + deltaPos, initPos.y, 0.0); + path->VPoints.push_back(NLLIGO::CPrimVector(secondPos)); break; + } case NLLIGO::CPrimitiveClass::Zone: - primitive = new NLLIGO::CPrimZone; + { + NLLIGO::CPrimZone *zone = new NLLIGO::CPrimZone; + primitive = zone; + zone->VPoints.push_back(NLLIGO::CPrimVector(initPos)); + NLMISC::CVector secondPos = NLMISC::CVector(initPos.x + deltaPos, initPos.y, 0.0); + zone->VPoints.push_back(NLLIGO::CPrimVector(secondPos)); + secondPos.y = initPos.y + deltaPos; + zone->VPoints.push_back(NLLIGO::CPrimVector(secondPos)); break; + } case NLLIGO::CPrimitiveClass::Alias: primitive = new NLLIGO::CPrimAlias; break; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index 056a4f01e..9eb8e0717 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -187,7 +187,7 @@ void WorldItemPoint::createCircle() if (m_radius != 0) { // Create circle - int segmentCount = 30; + int segmentCount = 20; QPointF circlePoint(m_radius, 0); m_circle << circlePoint; for (int i = 1; i < segmentCount + 1; ++i) @@ -241,9 +241,13 @@ void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *op painter->setPen(Qt::NoPen); // if (option->state & QStyle::State_Selected) if (isActived()) + { painter->setBrush(m_selectedBrush); + } else + { painter->setBrush(m_brush); + } // Draw point painter->drawRect(m_rect); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index 1b934d77b..54811e271 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -129,7 +129,7 @@ private: void createCircle(); void updateBoundingRect(); - static const int SIZE_POINT = 3; + static const int SIZE_POINT = 2; QPen m_pen, m_selectedPen; QBrush m_brush, m_selectedBrush; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index 1de6cbdc3..870081d47 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -6,7 +6,7 @@ 0 0 - 800 + 819 600 @@ -121,8 +121,9 @@ false - - + + + @@ -177,7 +178,7 @@ S/H Land
- + true @@ -185,10 +186,13 @@ false - S/H Primitives + S/H Zone primitives + + + S/H Zone Primitives - + true @@ -196,7 +200,7 @@ false - S/H Layers + S/H Path primitives @@ -343,6 +347,20 @@ Project settings + + + true + + + false + + + S/H Points primitives + + + S/H Points primitives + + From 10c5d9183c03d75ee5bc26217d96cdd8b7b40834 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 16 Aug 2011 13:52:06 +0300 Subject: [PATCH 059/747] Changed: #1302 Added save/saveAs action for primitive item. --- .../plugins/world_editor/primitive_item.cpp | 12 ++++ .../src/plugins/world_editor/primitive_item.h | 4 ++ .../plugins/world_editor/primitives_model.cpp | 10 ++- .../plugins/world_editor/primitives_view.cpp | 63 +++++++++++++++++-- .../plugins/world_editor/primitives_view.h | 2 + .../world_editor/world_editor_actions.cpp | 4 +- .../world_editor/world_editor_constants.h | 2 + 7 files changed, 89 insertions(+), 8 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index e948f8b0f..e867f1368 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -235,6 +235,7 @@ Node::NodeType PrimitiveNode::type() const RootPrimitiveNode::RootPrimitiveNode(const QString &name, NLLIGO::CPrimitives *primitives) : PrimitiveNode(primitives->RootNode), + m_fileName(name), m_primitives(primitives) { setData(Qt::DisplayRole, name); @@ -249,6 +250,17 @@ NLLIGO::CPrimitives *RootPrimitiveNode::primitives() const return m_primitives; } +void RootPrimitiveNode::setFileName(const QString &fileName) +{ + setData(Qt::DisplayRole, fileName); + m_fileName = fileName; +} + +QString RootPrimitiveNode::fileName() const +{ + return m_fileName; +} + Node::NodeType RootPrimitiveNode::type() const { return RootPrimitiveNodeType; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 1b2a89d4c..300973c55 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -167,9 +167,13 @@ public: NLLIGO::CPrimitives *primitives() const; + void setFileName(const QString &fileName); + QString fileName() const; virtual NodeType type() const; private: + + QString m_fileName; NLLIGO::CPrimitives *m_primitives; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp index f59cb8d67..9e689066a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp @@ -18,6 +18,7 @@ #include "primitive_item.h" #include "primitives_model.h" #include "world_editor_misc.h" +#include "world_editor_constants.h" // NeL includes #include @@ -218,6 +219,10 @@ Path PrimitivesTreeModel::createRootPrimitiveNode(const QString &fileName, NLLIG if (m_worldEditNode == 0) createWorldEditNode("NewWorldEdit"); + QString name = "NewPrimitive"; + if (!fileName.isEmpty()) + name = fileName; + // Get position int pos = m_worldEditNode->childCount(); @@ -225,10 +230,13 @@ Path PrimitivesTreeModel::createRootPrimitiveNode(const QString &fileName, NLLIG // Add root node in tree model beginInsertRows(parentIndex, pos, pos); - RootPrimitiveNode *newNode = new RootPrimitiveNode(fileName, primitives); + RootPrimitiveNode *newNode = new RootPrimitiveNode(name, primitives); m_worldEditNode->appendChildNode(newNode); endInsertRows(); + newNode->setData(Constants::PRIMITIVE_FILE_IS_CREATED, !fileName.isEmpty()); + newNode->setData(Constants::PRIMITIVE_IS_MODIFIED, false); + QModelIndex rootPrimIndex = index(pos, 0, parentIndex); // Scan childs items and add in the tree model diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index 896218a54..0a2851e65 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -18,6 +18,7 @@ #include "primitives_view.h" #include "primitives_model.h" #include "world_editor_actions.h" +#include "world_editor_constants.h" #include "../core/core_constants.h" #include "../landscape_editor/landscape_editor_constants.h" @@ -27,9 +28,11 @@ #include #include #include +#include // Qt includes #include +#include #include #include @@ -49,12 +52,10 @@ PrimitivesView::PrimitivesView(QWidget *parent) m_unloadAction->setEnabled(false); m_saveAction = new QAction("Save", this); - m_saveAction->setEnabled(false); m_saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); m_saveAsAction = new QAction("Save As...", this); m_saveAsAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS)); - m_saveAsAction->setEnabled(false); m_loadLandAction = new QAction("Load landscape file", this); m_loadLandAction->setIcon(QIcon(LandscapeEditor::Constants::ICON_ZONE_ITEM)); @@ -83,6 +84,8 @@ PrimitivesView::PrimitivesView(QWidget *parent) connect(m_newPrimitiveAction, SIGNAL(triggered()), this, SLOT(createRootPrimitive())); connect(m_selectChildrenAction, SIGNAL(triggered()), this, SLOT(selectChildren())); connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deletePrimitives())); + connect(m_saveAction, SIGNAL(triggered()), this, SLOT(save())); + connect(m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); #ifdef Q_OS_DARWIN setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); @@ -186,6 +189,54 @@ void PrimitivesView::selectChildren() selectChildren(parentIndex); } +void PrimitivesView::save() +{ + nlassert(m_primitivesTreeModel); + + QModelIndexList indexList = selectionModel()->selectedRows(); + QModelIndex index = indexList.first(); + + RootPrimitiveNode *node = static_cast(index.internalPointer()); + + if (node->data(Constants::PRIMITIVE_FILE_IS_CREATED).toBool()) + { + if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), node->fileName().toStdString())) + QMessageBox::warning(this, "World Editor Qt", QString("Error writing output file: %1").arg(node->fileName())); + else + node->setData(Constants::PRIMITIVE_IS_MODIFIED, false); + } + else + saveAs(); +} + +void PrimitivesView::saveAs() +{ + nlassert(m_primitivesTreeModel); + + QString fileName = QFileDialog::getSaveFileName(this, + tr("Save NeL Ligo primitive file"), m_lastDir, + tr("NeL Ligo primitive file (*.primitive)")); + + setCursor(Qt::WaitCursor); + if (!fileName.isEmpty()) + { + QModelIndexList indexList = selectionModel()->selectedRows(); + QModelIndex index = indexList.first(); + + RootPrimitiveNode *node = static_cast(index.internalPointer()); + + if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), fileName.toStdString())) + QMessageBox::warning(this, "World Editor Qt", QString("Error writing output file: %1").arg(fileName)); + else + { + node->setFileName(fileName); + node->setData(Constants::PRIMITIVE_FILE_IS_CREATED, true); + node->setData(Constants::PRIMITIVE_IS_MODIFIED, false); + } + } + setCursor(Qt::ArrowCursor); +} + void PrimitivesView::deletePrimitives() { nlassert(m_undoStack); @@ -267,8 +318,8 @@ void PrimitivesView::selectChildren(const QModelIndex &parent) void PrimitivesView::fillMenu_WorldEdit(QMenu *menu) { menu->addAction(m_unloadAction); - menu->addAction(m_saveAction); - menu->addAction(m_saveAsAction); + //menu->addAction(m_saveAction); + //menu->addAction(m_saveAsAction); menu->addSeparator(); menu->addAction(m_loadLandAction); menu->addAction(m_loadPrimitiveAction); @@ -279,7 +330,7 @@ void PrimitivesView::fillMenu_WorldEdit(QMenu *menu) void PrimitivesView::fillMenu_Landscape(QMenu *menu) { - menu->addAction(m_deleteAction); + menu->addAction(m_unloadAction); menu->addSeparator(); menu->addAction(m_showAction); menu->addAction(m_hideAction); @@ -289,7 +340,9 @@ void PrimitivesView::fillMenu_RootPrimitive(QMenu *menu, const QModelIndex &inde { menu->addAction(m_saveAction); menu->addAction(m_saveAsAction); + menu->addAction(m_unloadAction); fillMenu_Primitive(menu, index); + menu->removeAction(m_deleteAction); } void PrimitivesView::fillMenu_Primitive(QMenu *menu, const QModelIndex &index) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h index eae9187ac..3fce65ae7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h @@ -67,6 +67,8 @@ private Q_SLOTS: void createRootPrimitive(); void selectChildren(); + void save(); + void saveAs(); void deletePrimitives(); void addNewPrimitiveByClass(int value); void generatePrimitives(int value); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index f40e498a1..2eaa2a488 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -295,7 +295,7 @@ void CreateRootPrimitiveCommand::undo() void CreateRootPrimitiveCommand::redo() { NLLIGO::CPrimitives *newRootPrim = new NLLIGO::CPrimitives(); - m_rootPrimIndex = m_model->createRootPrimitiveNode(m_fileName, newRootPrim); + m_rootPrimIndex = m_model->createRootPrimitiveNode("", newRootPrim); } @@ -337,7 +337,7 @@ void LoadRootPrimitiveCommand::redo() // set the primitive context NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = primitives; - NLLIGO::loadXmlPrimitiveFile(*primitives, m_fileName.toStdString(), *NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); + NLLIGO::loadXmlPrimitiveFile(*primitives, m_fileName.toStdString(), *Utils::ligoConfig()); // unset the context NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index e0bdc4705..9a7a834d6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -28,6 +28,8 @@ const int NODE_PERISTENT_INDEX = USER_TYPE + 1; const int WORLD_EDITOR_NODE = USER_TYPE + 2; const int GRAPHICS_DATA_QT4_2D = USER_TYPE + 3; const int GRAPHICS_DATA_NEL3D = USER_TYPE + 4; +const int PRIMITIVE_IS_MODIFIED = USER_TYPE + 5; +const int PRIMITIVE_FILE_IS_CREATED = USER_TYPE + 6; //settings const char *const WORLD_EDITOR_SECTION = "WorldEditor"; From 4786379e85132866c45f8d62acf1afbd5f173265 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 16 Aug 2011 19:34:21 +0300 Subject: [PATCH 060/747] Changed: #1302 Added save/saveAs action for primitive item. --- .../plugins/world_editor/primitives_view.cpp | 8 +- .../world_editor/world_editor_actions.cpp | 104 +++++++++++++++++- .../world_editor/world_editor_actions.h | 3 + .../world_editor/world_editor_scene_item.cpp | 14 +++ .../world_editor/world_editor_scene_item.h | 3 + 5 files changed, 127 insertions(+), 5 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index 0a2851e65..6620411ca 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -197,7 +197,7 @@ void PrimitivesView::save() QModelIndex index = indexList.first(); RootPrimitiveNode *node = static_cast(index.internalPointer()); - + if (node->data(Constants::PRIMITIVE_FILE_IS_CREATED).toBool()) { if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), node->fileName().toStdString())) @@ -214,8 +214,8 @@ void PrimitivesView::saveAs() nlassert(m_primitivesTreeModel); QString fileName = QFileDialog::getSaveFileName(this, - tr("Save NeL Ligo primitive file"), m_lastDir, - tr("NeL Ligo primitive file (*.primitive)")); + tr("Save NeL Ligo primitive file"), m_lastDir, + tr("NeL Ligo primitive file (*.primitive)")); setCursor(Qt::WaitCursor); if (!fileName.isEmpty()) @@ -224,7 +224,7 @@ void PrimitivesView::saveAs() QModelIndex index = indexList.first(); RootPrimitiveNode *node = static_cast(index.internalPointer()); - + if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), fileName.toStdString())) QMessageBox::warning(this, "World Editor Qt", QString("Error writing output file: %1").arg(fileName)); else diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 2eaa2a488..2e538748c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -121,7 +121,7 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode for (int i = 0; i < sizeVec; ++i) { - polygon << QPointF(vec->x, -vec->y + cellSize); + polygon << QPointF(vec->x, cellSize - vec->y); ++vec; } item = scene->addWorldItemZone(polygon); @@ -216,6 +216,49 @@ QList polygonsFromItems(const QList &items) return result; } +void updateGraphicsData(AbstractWorldItem *item) +{ + float cellSize = Utils::ligoConfig()->CellSize; + Node *node = qvariant_cast(item->data(Constants::WORLD_EDITOR_NODE)); + PrimitiveNode *primitiveNode = static_cast(node); + if (primitiveNode != 0) + { + NLLIGO::IPrimitive *primitive = primitiveNode->primitive(); + + std::vector vPoints; + QPolygonF polygon = item->polygon(); + polygon.translate(item->pos()); + + for (int i = 0; i < polygon.size(); ++i) + { + NLMISC::CVector vec(polygon.at(i).x(), cellSize - polygon.at(i).y(), 0.0); + vPoints.push_back(NLLIGO::CPrimVector(vec)); + } + + switch (primitiveNode->primitiveClass()->Type) + { + case NLLIGO::CPrimitiveClass::Point: + { + NLLIGO::CPrimPoint *point = static_cast(primitive); + point->Point = vPoints.front(); + break; + } + case NLLIGO::CPrimitiveClass::Path: + { + NLLIGO::CPrimPath *path = static_cast(primitive); + path->VPoints = vPoints; + break; + } + case NLLIGO::CPrimitiveClass::Zone: + { + NLLIGO::CPrimZone *zone = static_cast(primitive); + zone->VPoints = vPoints; + break; + } + } + } +} + CreateWorldCommand::CreateWorldCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_fileName(fileName), @@ -451,6 +494,7 @@ void MoveWorldItemsCommand::undo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->moveBy(-m_offset.x(), -m_offset.y()); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); } @@ -466,9 +510,20 @@ void MoveWorldItemsCommand::redo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->moveBy(m_offset.x(), m_offset.y()); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); } + else + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + updateGraphicsData(item); + } + } + m_firstRun = false; } @@ -498,6 +553,7 @@ void RotateWorldItemsCommand::undo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->rotateOn(m_pivot, -m_angle); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); } @@ -513,9 +569,20 @@ void RotateWorldItemsCommand::redo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->rotateOn(m_pivot, m_angle); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); } + else + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + updateGraphicsData(item); + } + } + m_firstRun = false; } @@ -546,6 +613,7 @@ void ScaleWorldItemsCommand::undo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->scaleOn(m_pivot, m_invertFactor); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); } @@ -561,9 +629,20 @@ void ScaleWorldItemsCommand::redo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->scaleOn(m_pivot, m_factor); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); } + else + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + updateGraphicsData(item); + } + } + m_firstRun = false; } @@ -592,6 +671,7 @@ void TurnWorldItemsCommand::undo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->turnOn(-m_angle); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); } @@ -607,9 +687,19 @@ void TurnWorldItemsCommand::redo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->turnOn(m_angle); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); } + else + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + updateGraphicsData(item); + } + } m_firstRun = false; } @@ -642,6 +732,7 @@ void ShapeWorldItemsCommand::undo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->setPolygon(m_redoPolygons.at(i)); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); @@ -659,9 +750,20 @@ void ShapeWorldItemsCommand::redo() Node *node = m_model->pathToNode(m_listPaths.at(i)); AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); item->setPolygon(m_undoPolygons.at(i)); + updateGraphicsData(item); } m_scene->setEnabledEditPoints(pointsMode); } + else + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + updateGraphicsData(item); + } + } + m_firstRun = false; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index a8352e2e6..1c77a4ba5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -35,6 +35,7 @@ class ZoneBuilderBase; namespace WorldEditor { class WorldEditorScene; +class AbstractWorldItem; // Auxiliary operations @@ -50,6 +51,8 @@ QList graphicsItemsToPaths(const QList &items, Primitives QList polygonsFromItems(const QList &items); +void updateGraphicsData(AbstractWorldItem *item); + /** @class CreateWorldCommand @brief diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index 9eb8e0717..28c933d39 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -182,6 +182,17 @@ void WorldItemPoint::setColor(const QColor &color) m_brush.setColor(color); } +void WorldItemPoint::setPolygon(const QPolygonF &polygon) +{ +} + +QPolygonF WorldItemPoint::polygon() const +{ + QPolygonF polygon; + polygon << QPointF(0, 0); + return polygon; +} + void WorldItemPoint::createCircle() { if (m_radius != 0) @@ -339,6 +350,7 @@ void WorldItemPath::moveSubPoint(WorldItemSubPoint *subPoint) m_listLines.at(i).itemPoint->setPos((m_listLines.at(i).lineItem.first->pos() + m_listLines.at(i).lineItem.second->pos()) / 2); m_polygon = polygon; + setShapeChanged(true); update(); } @@ -381,6 +393,7 @@ void WorldItemPath::addSubPoint(WorldItemSubPoint *subPoint) break; } } + setShapeChanged(true); } bool WorldItemPath::removeSubPoint(WorldItemSubPoint *subPoint) @@ -427,6 +440,7 @@ bool WorldItemPath::removeSubPoint(WorldItemSubPoint *subPoint) subPoint->setPos((newLineItem.lineItem.first->pos() + newLineItem.lineItem.second->pos()) / 2); m_listLines.push_back(newLineItem); subPoint->setFlag(ItemSendsScenePositionChanges, false); + setShapeChanged(true); return true; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index 54811e271..b42138833 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -121,6 +121,9 @@ public: virtual void setColor(const QColor &color); virtual void setEnabledSubPoints(bool enabled) {} + virtual void setPolygon(const QPolygonF &polygon); + virtual QPolygonF polygon() const; + virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); From 8362d0b123de8631cd76e7f89bfc1d5ba65dd498 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 16 Aug 2011 21:18:10 +0300 Subject: [PATCH 061/747] Changed: #1302 When selecting graphics items in scene will be selected the appropriate primitives in the primitives dialog. --- .../plugins/world_editor/primitives_model.cpp | 2 +- .../world_editor/world_editor_actions.cpp | 8 +++++ .../world_editor/world_editor_actions.h | 4 +++ .../world_editor/world_editor_scene.cpp | 5 +++ .../plugins/world_editor/world_editor_scene.h | 2 +- .../world_editor/world_editor_window.cpp | 33 +++++++++++++++++++ .../world_editor/world_editor_window.h | 1 + 7 files changed, 53 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp index 9e689066a..690e7db08 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp @@ -155,7 +155,7 @@ Path PrimitivesTreeModel::pathFromNode(Node *node) Path path; while(iter != 0) { - path.prepend(PathItem(iter->row(), 1)); + path.prepend(PathItem(iter->row(), 0)); iter = iter->parent(); } return path; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 2e538748c..eb1921596 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -167,6 +167,11 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode QVariant graphicsData; graphicsData.setValue(item); node->setData(Constants::GRAPHICS_DATA_QT4_2D, graphicsData); + + QVariant persistenVariant; + QPersistentModelIndex *persistentIndex = new QPersistentModelIndex(primIndex); + persistenVariant.setValue(persistentIndex); + item->setData(Constants::NODE_PERISTENT_INDEX, persistenVariant); } int count = model->rowCount(primIndex); @@ -185,6 +190,8 @@ void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode QGraphicsItem *item = getGraphicsItem(node); if (item != 0) scene->removeWorldItem(item); + + delete qvariant_cast(item->data(Constants::NODE_PERISTENT_INDEX)); } int count = model->rowCount(primIndex); @@ -358,6 +365,7 @@ LoadRootPrimitiveCommand::~LoadRootPrimitiveCommand() void LoadRootPrimitiveCommand::undo() { + // Disable edit points mode m_scene->setEnabledEditPoints(false); QModelIndex index = m_model->pathToIndex(m_rootPrimIndex); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 1c77a4ba5..8aae8b8dd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace LandscapeEditor { @@ -283,4 +284,7 @@ private: } /* namespace WorldEditor */ +// Enable the use of QVariant with this class. +Q_DECLARE_METATYPE(QPersistentModelIndex *) + #endif // WORLD_EDITOR_ACTIONS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 749392631..356f6589a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -459,6 +459,9 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) m_selectedItems.push_back(item); } + + Q_EMIT updateSelectedItems(m_selectedItems); + updateSelectedWorldItems(true); m_selectionArea = QRectF(); update(); @@ -556,6 +559,8 @@ void WorldEditorScene::updatePickSelection(const QPointF &point) m_selectedItems.push_back(worldItemsItems.at(m_lastPickedPrimitive)); updateSelectedWorldItems(true); } + + Q_EMIT updateSelectedItems(m_selectedItems); } void WorldEditorScene::updatePickSelectionPoints(const QPointF &point) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index adf491889..c9da223a7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -68,7 +68,7 @@ public: bool isEnabledEditPoints() const; Q_SIGNALS: - void selectionUpdated(const QList &selected, const QList &deselected); + void updateSelectedItems(const QList &selected); public Q_SLOTS: void setEnabledEditPoints(bool enabled); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 009ede2e1..97d99f82c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -39,6 +39,7 @@ #include #include #include +#include namespace WorldEditor { @@ -108,6 +109,9 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) connect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(updateSelection(QItemSelection, QItemSelection))); + connect(m_worldEditorScene, SIGNAL(updateSelectedItems(QList)), + this, SLOT(selectedItemsInScene(QList))); + m_statusBarTimer = new QTimer(this); connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); @@ -295,6 +299,35 @@ void WorldEditorWindow::updateSelection(const QItemSelection &selected, const QI m_worldEditorScene->updateSelection(itemSelected, itemDeselected); } +void WorldEditorWindow::selectedItemsInScene(const QList &selected) +{ + QItemSelectionModel *selectionModel = m_ui.treePrimitivesView->selectionModel(); + disconnect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, SLOT(updateSelection(QItemSelection, QItemSelection))); + + selectionModel->clear(); + QItemSelection itemSelection; + Q_FOREACH(QGraphicsItem *item, selected) + { + QPersistentModelIndex *index = qvariant_cast(item->data(Constants::NODE_PERISTENT_INDEX)); + if (index->isValid()) + { + QModelIndex modelIndex = index->operator const QModelIndex &(); + QItemSelection mergeItemSelection(modelIndex, modelIndex); + itemSelection.merge(mergeItemSelection, QItemSelectionModel::Select); + } + QApplication::processEvents(); + } + + selectionModel->select(itemSelection, QItemSelectionModel::Select); + + // TODO: update property editor + // ... + + connect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, SLOT(updateSelection(QItemSelection, QItemSelection))); +} + void WorldEditorWindow::showEvent(QShowEvent *showEvent) { QMainWindow::showEvent(showEvent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index 5844489f6..d6e3dd593 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -61,6 +61,7 @@ private Q_SLOTS: void updateStatusBar(); void updateSelection(const QItemSelection &selected, const QItemSelection &deselected); + void selectedItemsInScene(const QList &selected); protected: virtual void showEvent(QShowEvent *showEvent); From b6db3ccfc7cf870db5690301bbdb5e2ec0481418 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 16 Aug 2011 22:30:45 +0300 Subject: [PATCH 062/747] Fixed: #1302 Fixed crash program(LoadRootPrimitiveCommand and AddPrimitiveByClassCommand do not work with selection model, and edit points mode does not work with mouse panning). --- .../plugins/world_editor/primitives_view.cpp | 4 ++-- .../world_editor/world_editor_actions.cpp | 23 ++++++++++++------- .../world_editor/world_editor_actions.h | 8 +++++-- .../world_editor/world_editor_scene.cpp | 3 +++ .../world_editor/world_editor_window.cpp | 5 ++-- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index 6620411ca..ca329b25b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -135,7 +135,7 @@ void PrimitivesView::loadRootPrimitive() Q_FOREACH(QString fileName, fileNames) { m_lastDir = QFileInfo(fileName).absolutePath(); - m_undoStack->push(new LoadRootPrimitiveCommand(fileName, m_worldEditorScene, m_primitivesTreeModel)); + m_undoStack->push(new LoadRootPrimitiveCommand(fileName, m_worldEditorScene, m_primitivesTreeModel, this)); } if (fileNames.count() > 1) @@ -258,7 +258,7 @@ void PrimitivesView::addNewPrimitiveByClass(int value) QString className = node->primitiveClass()->DynamicChildren[value].ClassName.c_str(); m_undoStack->push(new AddPrimitiveByClassCommand(className, m_primitivesTreeModel->pathFromIndex(indexList.first()), - m_worldEditorScene, m_primitivesTreeModel)); + m_worldEditorScene, m_primitivesTreeModel, this)); } void PrimitivesView::generatePrimitives(int value) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index eb1921596..9a70cebe6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -189,9 +189,10 @@ void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode { QGraphicsItem *item = getGraphicsItem(node); if (item != 0) + { + delete qvariant_cast(item->data(Constants::NODE_PERISTENT_INDEX)); scene->removeWorldItem(item); - - delete qvariant_cast(item->data(Constants::NODE_PERISTENT_INDEX)); + } } int count = model->rowCount(primIndex); @@ -350,11 +351,12 @@ void CreateRootPrimitiveCommand::redo() LoadRootPrimitiveCommand::LoadRootPrimitiveCommand(const QString &fileName, WorldEditorScene *scene, - PrimitivesTreeModel *model, QUndoCommand *parent) + PrimitivesTreeModel *model, QTreeView *view, QUndoCommand *parent) : QUndoCommand(parent), m_fileName(fileName), m_scene(scene), - m_model(model) + m_model(model), + m_view(view) { setText("Load primitive file"); } @@ -368,6 +370,8 @@ void LoadRootPrimitiveCommand::undo() // Disable edit points mode m_scene->setEnabledEditPoints(false); + m_view->selectionModel()->clearSelection(); + QModelIndex index = m_model->pathToIndex(m_rootPrimIndex); removeGraphicsItems(index, m_model, m_scene); @@ -409,19 +413,20 @@ void LoadRootPrimitiveCommand::redo() } AddPrimitiveByClassCommand::AddPrimitiveByClassCommand(const QString &className, const Path &parentIndex, - WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) + WorldEditorScene *scene, PrimitivesTreeModel *model, QTreeView *view, QUndoCommand *parent) : QUndoCommand(parent), m_className(className), m_parentIndex(parentIndex), m_scene(scene), - m_model(model) + m_model(model), + m_view(view) { setText(QString("Add %1").arg(m_className)); - QGraphicsView *view = m_scene->views().first(); + QGraphicsView *graphicsView = m_scene->views().first(); // TODO: returns incorrect position when zoom in - QRectF visibleArea = view->mapToScene(view->rect()).boundingRect(); + QRectF visibleArea = graphicsView->mapToScene(view->rect()).boundingRect(); m_delta = visibleArea.height() / 10.0; m_initPos = visibleArea.center(); } @@ -434,6 +439,8 @@ void AddPrimitiveByClassCommand::undo() { m_scene->setEnabledEditPoints(false); + m_view->selectionModel()->clearSelection(); + QModelIndex index = m_model->pathToIndex(m_newPrimIndex); PrimitiveNode *node = static_cast(index.internalPointer()); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 8aae8b8dd..ad66d0e3d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -25,6 +25,7 @@ // Qt includes #include #include +#include #include #include @@ -121,7 +122,8 @@ class LoadRootPrimitiveCommand: public QUndoCommand { public: LoadRootPrimitiveCommand(const QString &fileName, WorldEditorScene *scene, - PrimitivesTreeModel *model, QUndoCommand *parent = 0); + PrimitivesTreeModel *model, QTreeView *view, + QUndoCommand *parent = 0); virtual ~LoadRootPrimitiveCommand(); virtual void undo(); @@ -132,6 +134,7 @@ private: const QString m_fileName; WorldEditorScene *const m_scene; PrimitivesTreeModel *const m_model; + QTreeView *m_view; }; /** @@ -144,7 +147,7 @@ class AddPrimitiveByClassCommand: public QUndoCommand public: AddPrimitiveByClassCommand(const QString &className, const Path &parentIndex, WorldEditorScene *scene, PrimitivesTreeModel *model, - QUndoCommand *parent = 0); + QTreeView *view, QUndoCommand *parent = 0); virtual ~AddPrimitiveByClassCommand(); virtual void undo(); @@ -157,6 +160,7 @@ private: Path m_parentIndex, m_newPrimIndex; WorldEditorScene *m_scene; PrimitivesTreeModel *m_model; + QTreeView *m_view; }; /** diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 356f6589a..967f6651d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -369,6 +369,9 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) { + if (mouseEvent->button() == Qt::MidButton) + return; + if (m_pointsMode) { if (mouseEvent->button() == Qt::LeftButton) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 97d99f82c..2df27d7c7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -193,7 +193,8 @@ void WorldEditorWindow::loadWorldEditFile(const QString &fileName) m_undoStack->push(new LoadLandscapeCommand(QString(worldEditList[i].second.c_str()), m_primitivesModel, m_zoneBuilderBase)); break; case Utils::PrimitiveType: - m_undoStack->push(new LoadRootPrimitiveCommand(QString(worldEditList[i].second.c_str()), m_worldEditorScene, m_primitivesModel)); + m_undoStack->push(new LoadRootPrimitiveCommand(QString(worldEditList[i].second.c_str()), + m_worldEditorScene, m_primitivesModel, m_ui.treePrimitivesView)); break; }; } @@ -383,7 +384,7 @@ void WorldEditorWindow::readSettings() restoreGeometry(settings->value(Constants::WORLD_WINDOW_GEOMETRY).toByteArray()); // Use OpenGL graphics system instead raster graphics system - if (settings->value(Constants::WORLD_EDITOR_USE_OPENGL, true).toBool()) + if (settings->value(Constants::WORLD_EDITOR_USE_OPENGL, false).toBool()) { m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); m_ui.graphicsView->setViewport(m_oglWidget); From 08ae84ed19505533ea86896d77fcfc1526e26bb7 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 17 Aug 2011 02:49:32 +0300 Subject: [PATCH 063/747] Changed: #1302 Clean up code for undo commands. --- .../world_editor/world_editor_actions.cpp | 403 ++++++------------ .../world_editor/world_editor_actions.h | 91 ++-- 2 files changed, 193 insertions(+), 301 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 9a70cebe6..b0a201980 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -202,17 +202,6 @@ void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode } } -QList graphicsItemsToPaths(const QList &items, PrimitivesTreeModel *model) -{ - QList result; - Q_FOREACH(QGraphicsItem *item, items) - { - Node *node = qvariant_cast(item->data(Constants::WORLD_EDITOR_NODE)); - result.push_back(model->pathFromNode(node)); - } - return result; -} - QList polygonsFromItems(const QList &items) { QList result; @@ -224,49 +213,6 @@ QList polygonsFromItems(const QList &items) return result; } -void updateGraphicsData(AbstractWorldItem *item) -{ - float cellSize = Utils::ligoConfig()->CellSize; - Node *node = qvariant_cast(item->data(Constants::WORLD_EDITOR_NODE)); - PrimitiveNode *primitiveNode = static_cast(node); - if (primitiveNode != 0) - { - NLLIGO::IPrimitive *primitive = primitiveNode->primitive(); - - std::vector vPoints; - QPolygonF polygon = item->polygon(); - polygon.translate(item->pos()); - - for (int i = 0; i < polygon.size(); ++i) - { - NLMISC::CVector vec(polygon.at(i).x(), cellSize - polygon.at(i).y(), 0.0); - vPoints.push_back(NLLIGO::CPrimVector(vec)); - } - - switch (primitiveNode->primitiveClass()->Type) - { - case NLLIGO::CPrimitiveClass::Point: - { - NLLIGO::CPrimPoint *point = static_cast(primitive); - point->Point = vPoints.front(); - break; - } - case NLLIGO::CPrimitiveClass::Path: - { - NLLIGO::CPrimPath *path = static_cast(primitive); - path->VPoints = vPoints; - break; - } - case NLLIGO::CPrimitiveClass::Zone: - { - NLLIGO::CPrimZone *zone = static_cast(primitive); - zone->VPoints = vPoints; - break; - } - } - } -} - CreateWorldCommand::CreateWorldCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_fileName(fileName), @@ -484,14 +430,122 @@ void AddPrimitiveByClassCommand::redo() addNewGraphicsItems(m_model->pathToIndex(m_newPrimIndex), m_model, m_scene); } -MoveWorldItemsCommand::MoveWorldItemsCommand(const QList &items, const QPointF &offset, - WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) +AbstractWorldItemCommand::AbstractWorldItemCommand(const QList &items, + WorldEditorScene *scene, + PrimitivesTreeModel *model, + QUndoCommand *parent) : QUndoCommand(parent), m_listPaths(graphicsItemsToPaths(items, model)), - m_offset(offset), m_model(model), m_scene(scene), m_firstRun(true) +{ +} + +AbstractWorldItemCommand::~AbstractWorldItemCommand() +{ +} + +void AbstractWorldItemCommand::undo() +{ + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + undoChangeItem(i, item); + updatePrimitiveData(item); + } + m_scene->setEnabledEditPoints(pointsMode); +} + +void AbstractWorldItemCommand::redo() +{ + if (!m_firstRun) + { + bool pointsMode = m_scene->isEnabledEditPoints(); + m_scene->setEnabledEditPoints(false); + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + redoChangeItem(i, item); + updatePrimitiveData(item); + } + m_scene->setEnabledEditPoints(pointsMode); + } + else + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + updatePrimitiveData(item); + } + } + + m_firstRun = false; +} + +void AbstractWorldItemCommand::updatePrimitiveData(AbstractWorldItem *item) +{ + float cellSize = Utils::ligoConfig()->CellSize; + Node *node = qvariant_cast(item->data(Constants::WORLD_EDITOR_NODE)); + PrimitiveNode *primitiveNode = static_cast(node); + if (primitiveNode != 0) + { + NLLIGO::IPrimitive *primitive = primitiveNode->primitive(); + + std::vector vPoints; + QPolygonF polygon = item->polygon(); + polygon.translate(item->pos()); + + for (int i = 0; i < polygon.size(); ++i) + { + NLMISC::CVector vec(polygon.at(i).x(), cellSize - polygon.at(i).y(), 0.0); + vPoints.push_back(NLLIGO::CPrimVector(vec)); + } + + switch (primitiveNode->primitiveClass()->Type) + { + case NLLIGO::CPrimitiveClass::Point: + { + NLLIGO::CPrimPoint *point = static_cast(primitive); + point->Point = vPoints.front(); + break; + } + case NLLIGO::CPrimitiveClass::Path: + { + NLLIGO::CPrimPath *path = static_cast(primitive); + path->VPoints = vPoints; + break; + } + case NLLIGO::CPrimitiveClass::Zone: + { + NLLIGO::CPrimZone *zone = static_cast(primitive); + zone->VPoints = vPoints; + break; + } + } + } +} + +QList AbstractWorldItemCommand::graphicsItemsToPaths(const QList &items, PrimitivesTreeModel *model) +{ + QList result; + Q_FOREACH(QGraphicsItem *item, items) + { + Node *node = qvariant_cast(item->data(Constants::WORLD_EDITOR_NODE)); + result.push_back(model->pathFromNode(node)); + } + return result; +} + +MoveWorldItemsCommand::MoveWorldItemsCommand(const QList &items, const QPointF &offset, + WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) + : AbstractWorldItemCommand(items, scene, model, parent), + m_offset(offset) { setText("Move item(s)"); } @@ -500,57 +554,21 @@ MoveWorldItemsCommand::~MoveWorldItemsCommand() { } -void MoveWorldItemsCommand::undo() +void MoveWorldItemsCommand::undoChangeItem(int i, AbstractWorldItem *item) { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->moveBy(-m_offset.x(), -m_offset.y()); - updateGraphicsData(item); - } - m_scene->setEnabledEditPoints(pointsMode); + item->moveBy(-m_offset.x(), -m_offset.y()); } -void MoveWorldItemsCommand::redo() +void MoveWorldItemsCommand::redoChangeItem(int i, AbstractWorldItem *item) { - if (!m_firstRun) - { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->moveBy(m_offset.x(), m_offset.y()); - updateGraphicsData(item); - } - m_scene->setEnabledEditPoints(pointsMode); - } - else - { - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - updateGraphicsData(item); - } - } - - m_firstRun = false; + item->moveBy(m_offset.x(), m_offset.y()); } RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &items, const qreal angle, const QPointF &pivot, WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) - : QUndoCommand(parent), - m_listPaths(graphicsItemsToPaths(items, model)), + : AbstractWorldItemCommand(items, scene, model, parent), m_angle(angle), - m_pivot(pivot), - m_model(model), - m_scene(scene), - m_firstRun(true) + m_pivot(pivot) { setText("Rotate item(s)"); } @@ -559,57 +577,21 @@ RotateWorldItemsCommand::~RotateWorldItemsCommand() { } -void RotateWorldItemsCommand::undo() +void RotateWorldItemsCommand::undoChangeItem(int i, AbstractWorldItem *item) { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->rotateOn(m_pivot, -m_angle); - updateGraphicsData(item); - } - m_scene->setEnabledEditPoints(pointsMode); + item->rotateOn(m_pivot, -m_angle); } -void RotateWorldItemsCommand::redo() +void RotateWorldItemsCommand::redoChangeItem(int i, AbstractWorldItem *item) { - if (!m_firstRun) - { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->rotateOn(m_pivot, m_angle); - updateGraphicsData(item); - } - m_scene->setEnabledEditPoints(pointsMode); - } - else - { - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - updateGraphicsData(item); - } - } - - m_firstRun = false; + item->rotateOn(m_pivot, m_angle); } ScaleWorldItemsCommand::ScaleWorldItemsCommand(const QList &items, const QPointF &factor, const QPointF &pivot, WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) - : QUndoCommand(parent), - m_listPaths(graphicsItemsToPaths(items, model)), + : AbstractWorldItemCommand(items, scene, model, parent), m_factor(factor), - m_pivot(pivot), - m_model(model), - m_scene(scene), - m_firstRun(true) + m_pivot(pivot) { setText("Scale item(s)"); } @@ -618,57 +600,21 @@ ScaleWorldItemsCommand::~ScaleWorldItemsCommand() { } -void ScaleWorldItemsCommand::undo() +void ScaleWorldItemsCommand::undoChangeItem(int i, AbstractWorldItem *item) { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); QPointF m_invertFactor(1 / m_factor.x(), 1 / m_factor.y()); - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->scaleOn(m_pivot, m_invertFactor); - updateGraphicsData(item); - } - m_scene->setEnabledEditPoints(pointsMode); + item->scaleOn(m_pivot, m_invertFactor); } -void ScaleWorldItemsCommand::redo() +void ScaleWorldItemsCommand::redoChangeItem(int i, AbstractWorldItem *item) { - if (!m_firstRun) - { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->scaleOn(m_pivot, m_factor); - updateGraphicsData(item); - } - m_scene->setEnabledEditPoints(pointsMode); - } - else - { - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - updateGraphicsData(item); - } - } - - m_firstRun = false; + item->scaleOn(m_pivot, m_factor); } TurnWorldItemsCommand::TurnWorldItemsCommand(const QList &items, const qreal angle, WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) - : QUndoCommand(parent), - m_listPaths(graphicsItemsToPaths(items, model)), - m_angle(angle), - m_model(model), - m_scene(scene), - m_firstRun(true) + : AbstractWorldItemCommand(items, scene, model, parent), + m_angle(angle) { setText("Turn item(s)"); } @@ -677,58 +623,22 @@ TurnWorldItemsCommand::~TurnWorldItemsCommand() { } -void TurnWorldItemsCommand::undo() +void TurnWorldItemsCommand::undoChangeItem(int i, AbstractWorldItem *item) { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->turnOn(-m_angle); - updateGraphicsData(item); - } - m_scene->setEnabledEditPoints(pointsMode); + item->turnOn(-m_angle); } -void TurnWorldItemsCommand::redo() +void TurnWorldItemsCommand::redoChangeItem(int i, AbstractWorldItem *item) { - if (!m_firstRun) - { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->turnOn(m_angle); - updateGraphicsData(item); - } - m_scene->setEnabledEditPoints(pointsMode); - } - else - { - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - updateGraphicsData(item); - } - } - - m_firstRun = false; + item->turnOn(m_angle); } ShapeWorldItemsCommand::ShapeWorldItemsCommand(const QList &items, const QList &polygons, WorldEditorScene *scene, PrimitivesTreeModel *model, QUndoCommand *parent) - : QUndoCommand(parent), - m_listPaths(graphicsItemsToPaths(items, model)), + : AbstractWorldItemCommand(items, scene, model, parent), m_redoPolygons(polygons), - m_undoPolygons(polygonsFromItems(items)), - m_model(model), - m_scene(scene), - m_firstRun(true) + m_undoPolygons(polygonsFromItems(items)) { setText("Change shape"); } @@ -737,49 +647,14 @@ ShapeWorldItemsCommand::~ShapeWorldItemsCommand() { } -void ShapeWorldItemsCommand::undo() +void ShapeWorldItemsCommand::undoChangeItem(int i, AbstractWorldItem *item) { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); - - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->setPolygon(m_redoPolygons.at(i)); - updateGraphicsData(item); - } - - m_scene->setEnabledEditPoints(pointsMode); + item->setPolygon(m_redoPolygons.at(i)); } -void ShapeWorldItemsCommand::redo() +void ShapeWorldItemsCommand::redoChangeItem(int i, AbstractWorldItem *item) { - if (!m_firstRun) - { - bool pointsMode = m_scene->isEnabledEditPoints(); - m_scene->setEnabledEditPoints(false); - - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - item->setPolygon(m_undoPolygons.at(i)); - updateGraphicsData(item); - } - m_scene->setEnabledEditPoints(pointsMode); - } - else - { - for (int i = 0; i < m_listPaths.count(); ++i) - { - Node *node = m_model->pathToNode(m_listPaths.at(i)); - AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - updateGraphicsData(item); - } - } - - m_firstRun = false; + item->setPolygon(m_undoPolygons.at(i)); } } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index ad66d0e3d..17f19fbca 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -49,11 +49,9 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode // Recursive scan primitives model for delete Graphics Items void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *model, WorldEditorScene *scene); -QList graphicsItemsToPaths(const QList &items, PrimitivesTreeModel *model); QList polygonsFromItems(const QList &items); -void updateGraphicsData(AbstractWorldItem *item); /** @class CreateWorldCommand @@ -163,12 +161,41 @@ private: QTreeView *m_view; }; +/** +@class AbstractWorldItemCommand +@brief +@details +*/ +class AbstractWorldItemCommand: public QUndoCommand +{ +public: + AbstractWorldItemCommand(const QList &items, WorldEditorScene *scene, + PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~AbstractWorldItemCommand(); + + virtual void undo(); + virtual void redo(); + +protected: + virtual void undoChangeItem(int i, AbstractWorldItem *item) = 0; + virtual void redoChangeItem(int i, AbstractWorldItem *item) = 0; + void updatePrimitiveData(AbstractWorldItem *item); + +private: + QList graphicsItemsToPaths(const QList &items, PrimitivesTreeModel *model); + + const QList m_listPaths; + PrimitivesTreeModel *const m_model; + WorldEditorScene *m_scene; + bool m_firstRun; +}; + /** @class MoveWorldItemsCommand @brief @details */ -class MoveWorldItemsCommand: public QUndoCommand +class MoveWorldItemsCommand: public AbstractWorldItemCommand { public: MoveWorldItemsCommand(const QList &items, const QPointF &offset, @@ -176,15 +203,13 @@ public: QUndoCommand *parent = 0); virtual ~MoveWorldItemsCommand(); - virtual void undo(); - virtual void redo(); +protected: + virtual void undoChangeItem(int i, AbstractWorldItem *item); + virtual void redoChangeItem(int i, AbstractWorldItem *item); + private: - const QList m_listPaths; const QPointF m_offset; - PrimitivesTreeModel *const m_model; - WorldEditorScene *m_scene; - bool m_firstRun; }; /** @@ -192,7 +217,7 @@ private: @brief @details */ -class RotateWorldItemsCommand: public QUndoCommand +class RotateWorldItemsCommand: public AbstractWorldItemCommand { public: RotateWorldItemsCommand(const QList &items, const qreal angle, @@ -200,16 +225,14 @@ public: PrimitivesTreeModel *model, QUndoCommand *parent = 0); virtual ~RotateWorldItemsCommand(); - virtual void undo(); - virtual void redo(); +protected: + virtual void undoChangeItem(int i, AbstractWorldItem *item); + virtual void redoChangeItem(int i, AbstractWorldItem *item); + private: - const QList m_listPaths; const qreal m_angle; const QPointF m_pivot; - PrimitivesTreeModel *const m_model; - WorldEditorScene *m_scene; - bool m_firstRun; }; /** @@ -217,7 +240,7 @@ private: @brief @details */ -class ScaleWorldItemsCommand: public QUndoCommand +class ScaleWorldItemsCommand: public AbstractWorldItemCommand { public: ScaleWorldItemsCommand(const QList &items, const QPointF &factor, @@ -225,16 +248,14 @@ public: PrimitivesTreeModel *model, QUndoCommand *parent = 0); virtual ~ScaleWorldItemsCommand(); - virtual void undo(); - virtual void redo(); +protected: + virtual void undoChangeItem(int i, AbstractWorldItem *item); + virtual void redoChangeItem(int i, AbstractWorldItem *item); + private: - const QList m_listPaths; const QPointF m_factor; const QPointF m_pivot; - PrimitivesTreeModel *const m_model; - WorldEditorScene *m_scene; - bool m_firstRun; }; /** @@ -242,7 +263,7 @@ private: @brief @details */ -class TurnWorldItemsCommand: public QUndoCommand +class TurnWorldItemsCommand: public AbstractWorldItemCommand { public: TurnWorldItemsCommand(const QList &items, const qreal angle, @@ -250,15 +271,13 @@ public: QUndoCommand *parent = 0); virtual ~TurnWorldItemsCommand(); - virtual void undo(); - virtual void redo(); +protected: + virtual void undoChangeItem(int i, AbstractWorldItem *item); + virtual void redoChangeItem(int i, AbstractWorldItem *item); + private: - const QList m_listPaths; const qreal m_angle; - PrimitivesTreeModel *const m_model; - WorldEditorScene *m_scene; - bool m_firstRun; }; /** @@ -266,7 +285,7 @@ private: @brief @details */ -class ShapeWorldItemsCommand: public QUndoCommand +class ShapeWorldItemsCommand: public AbstractWorldItemCommand { public: ShapeWorldItemsCommand(const QList &items, const QList &polygons, @@ -274,16 +293,14 @@ public: QUndoCommand *parent = 0); virtual ~ShapeWorldItemsCommand(); - virtual void undo(); - virtual void redo(); +protected: + virtual void undoChangeItem(int i, AbstractWorldItem *item); + virtual void redoChangeItem(int i, AbstractWorldItem *item); + private: - const QList m_listPaths; const QList m_redoPolygons; const QList m_undoPolygons; - PrimitivesTreeModel *const m_model; - WorldEditorScene *m_scene; - bool m_firstRun; }; } /* namespace WorldEditor */ From d8d6ed53848e4244d0e8ca483180ee212c352e12 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 18 Aug 2011 01:37:39 +0300 Subject: [PATCH 064/747] Changed: #1302 The value angle can save in file. --- .../src/plugins/world_editor/world_editor_actions.cpp | 5 ++++- .../src/plugins/world_editor/world_editor_plugin.cpp | 2 +- .../src/plugins/world_editor/world_editor_scene_item.cpp | 9 +++++++-- .../src/plugins/world_editor/world_editor_scene_item.h | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index b0a201980..b22e3fe64 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -93,7 +93,7 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode qreal radius = 0; if (primitive->getPropertyByName ("radius", strRadius)) radius = atof(strRadius.c_str()); - + qreal angle = ((2 * NLMISC::Pi - primPoint->Angle) * 180 / NLMISC::Pi); item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), primPoint->Angle, radius, showArrow); break; @@ -511,8 +511,11 @@ void AbstractWorldItemCommand::updatePrimitiveData(AbstractWorldItem *item) { case NLLIGO::CPrimitiveClass::Point: { + qreal angle = static_cast(item)->angle(); + angle = 2 * NLMISC::Pi - (angle * NLMISC::Pi / 180.0); NLLIGO::CPrimPoint *point = static_cast(primitive); point->Point = vPoints.front(); + point->Angle = angle; break; } case NLLIGO::CPrimitiveClass::Path: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp index 8699bfb67..23b51e9e3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp @@ -110,7 +110,7 @@ QString WorldEditorPlugin::name() const QString WorldEditorPlugin::version() const { - return "0.0.1"; + return "0.1"; } QString WorldEditorPlugin::vendor() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index 28c933d39..b4d01be65 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -91,7 +91,7 @@ bool AbstractWorldItem::isShapeChanged() const WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, const qreal radius, bool showArrow, QGraphicsItem *parent) : AbstractWorldItem(parent), - m_angle((2 * NLMISC::Pi - angle) * 180 / NLMISC::Pi), + m_angle(angle), m_radius(radius), m_showArrow(showArrow) { @@ -132,6 +132,11 @@ WorldItemPoint::~WorldItemPoint() { } +qreal WorldItemPoint::angle() const +{ + return m_angle; +} + void WorldItemPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle) { prepareGeometryChange(); @@ -167,6 +172,7 @@ void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &factor) void WorldItemPoint::turnOn(const qreal angle) { m_angle += angle; + m_angle -= floor(m_angle / 360) * 360; update(); } @@ -873,7 +879,6 @@ void WorldItemSubPoint::scaleOn(const QPointF &pivot, const QPointF &factor) // TODO scaledPolygon.translate(scenePos() - pivot); - //scaledPolygon.translate(-pivot); QTransform trans; trans = trans.scale(factor.x(), factor.y()); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index b42138833..7268b6d03 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -113,6 +113,8 @@ public: bool showArrow, QGraphicsItem *parent = 0); virtual ~WorldItemPoint(); + qreal angle() const; + virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); virtual void turnOn(const qreal angle); From 74ca89ab38c320d3cbded391e84b06b3421c610c Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Fri, 19 Aug 2011 00:14:40 +0300 Subject: [PATCH 065/747] Changed: #1301 Fix typos in comments/code. --- .../plugins/landscape_editor/builder_zone.cpp | 43 +++++++----- .../plugins/landscape_editor/builder_zone.h | 31 ++++++++- .../landscape_editor/builder_zone_base.h | 4 +- .../landscape_editor/landscape_actions.cpp | 39 +++-------- .../landscape_editor/landscape_actions.h | 65 ++++++++----------- .../landscape_editor_constants.h | 1 - .../landscape_editor_plugin.cpp | 3 +- .../landscape_editor_plugin.h | 1 - .../landscape_editor_window.cpp | 1 - .../landscape_editor_window.h | 1 - .../plugins/landscape_editor/landscape_view.h | 10 +++ .../landscape_editor/list_zones_model.h | 6 +- .../landscape_editor/list_zones_widget.h | 9 ++- .../landscape_editor/pixmap_database.cpp | 5 +- .../landscape_editor/pixmap_database.h | 3 +- .../project_settings_dialog.cpp | 1 - .../project_settings_dialog.h | 1 - .../landscape_editor/snapshot_dialog.cpp | 1 - .../landscape_editor/snapshot_dialog.h | 4 -- .../landscape_editor/zone_region_editor.h | 6 +- 20 files changed, 117 insertions(+), 118 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index 62ed76e89..f9aec3e3b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -85,7 +85,7 @@ void ZoneBuilder::actionLigoTile(const LigoData &data, const ZonePosition &zoneP return; checkBeginMacro(); - nlinfo(QString("%1 %2 %3 (%4 %5)").arg(data.zoneName.c_str()).arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).toStdString().c_str()); + // nlinfo(QString("%1 %2 %3 (%4 %5)").arg(data.zoneName.c_str()).arg(zonePos.x).arg(zonePos.y).arg(data.posX).arg(data.posY).toStdString().c_str()); m_zonePositionList.push_back(zonePos); m_undoStack->push(new LigoTileCommand(data, zonePos, this, m_landscapeScene)); } @@ -96,7 +96,6 @@ void ZoneBuilder::actionLigoMove(uint index, sint32 deltaX, sint32 deltaY) return; checkBeginMacro(); - nlinfo("ligoMove"); //m_undoStack->push(new LigoMoveCommand(index, deltaX, deltaY, this)); } @@ -106,7 +105,7 @@ void ZoneBuilder::actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, s return; checkBeginMacro(); - nlinfo(QString("minX=%1 maxX=%2 minY=%3 maxY=%4").arg(newMinX).arg(newMaxX).arg(newMinY).arg(newMaxY).toStdString().c_str()); + // nlinfo(QString("minX=%1 maxX=%2 minY=%3 maxY=%4").arg(newMinX).arg(newMaxX).arg(newMinY).arg(newMaxY).toStdString().c_str()); m_undoStack->push(new LigoResizeCommand(index, newMinX, newMaxX, newMinY, newMaxY, this)); } @@ -274,7 +273,7 @@ int ZoneBuilder::createZoneRegion(const QString &fileName) landItem.zoneRegionObject = new ZoneRegionObject(); landItem.zoneRegionObject->load(fileName.toStdString()); - if (!checkOverlaps(landItem.zoneRegionObject->ligoZoneRegion())) + if (checkOverlaps(landItem.zoneRegionObject->ligoZoneRegion())) { delete landItem.zoneRegionObject; return -1; @@ -334,7 +333,11 @@ int ZoneBuilder::currentIdZoneRegion() const ZoneRegionObject *ZoneBuilder::currentZoneRegion() const { - return m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject; + ZoneRegionObject *result = 0; + if (m_landscapeMap.contains(m_currentZoneRegion)) + result = m_landscapeMap.value(m_currentZoneRegion).zoneRegionObject; + + return result; } int ZoneBuilder::countZoneRegion() const @@ -344,17 +347,23 @@ int ZoneBuilder::countZoneRegion() const ZoneRegionObject *ZoneBuilder::zoneRegion(int id) const { - return m_landscapeMap.value(id).zoneRegionObject; + ZoneRegionObject *result = 0; + if (m_landscapeMap.contains(id)) + result = m_landscapeMap.value(id).zoneRegionObject; + + return result; } void ZoneBuilder::ligoData(LigoData &data, const ZonePosition &zonePos) { - m_landscapeMap.value(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y); + if (m_landscapeMap.contains(zonePos.region)) + m_landscapeMap.value(zonePos.region).zoneRegionObject->ligoData(data, zonePos.x, zonePos.y); } void ZoneBuilder::setLigoData(LigoData &data, const ZonePosition &zonePos) { - m_landscapeMap.value(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y); + if (m_landscapeMap.contains(zonePos.region)) + m_landscapeMap.value(zonePos.region).zoneRegionObject->setLigoData(data, zonePos.x, zonePos.y); } bool ZoneBuilder::initZoneBank (const QString &pathName) @@ -390,14 +399,10 @@ QString ZoneBuilder::dataPath() const bool ZoneBuilder::getZoneMask(sint32 x, sint32 y) { if ((x < m_minX) || (x > m_maxX) || - (y < m_minY) || (y > m_maxY)) - { + (y < m_minY) || (y > m_maxY)) return true; - } else - { return m_zoneMask[(x - m_minX) + (y - m_minY) * (1 + m_maxX - m_minX)]; - } } void ZoneBuilder::calcMask() @@ -485,7 +490,7 @@ void ZoneBuilder::checkBeginMacro() { m_createdAction = true; m_undoStack->beginMacro(m_titleAction); - m_undoScanRegionCommand = new UndoScanRegionCommand(this, m_landscapeScene); + m_undoScanRegionCommand = new UndoScanRegionCommand(true, this, m_landscapeScene); m_undoStack->push(m_undoScanRegionCommand); } } @@ -494,9 +499,13 @@ void ZoneBuilder::checkEndMacro() { if (m_createdAction) { - RedoScanRegionCommand *redoScanRegionCommand = new RedoScanRegionCommand(this, m_landscapeScene); + UndoScanRegionCommand *redoScanRegionCommand = new UndoScanRegionCommand(false, this, m_landscapeScene); + + // Sets list positions in which need apply changes m_undoScanRegionCommand->setScanList(m_zonePositionList); redoScanRegionCommand->setScanList(m_zonePositionList); + + // Adds command in the stack m_undoStack->push(redoScanRegionCommand); m_undoStack->endMacro(); } @@ -517,11 +526,11 @@ bool ZoneBuilder::checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion) { const std::string &zoneName = newZoneRegion.getName(x, y); if ((zoneName != STRING_UNUSED) && (zoneName != STRING_OUT_OF_BOUND)) - return false; + return true; } } } - return true; + return false; } } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h index d16008a5f..41983641f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.h @@ -59,17 +59,25 @@ public: ZoneBuilder(LandscapeScene *landscapeScene, ListZonesWidget *listZonesWidget = 0, QUndoStack *undoStack = 0); ~ZoneBuilder(); - /// Init zoneBank and init zone pixmap database + /// Inits zoneBank and init zone pixmap database bool init(const QString &pathName, bool displayProgress = false); void calcMask(); + + /// @return false if in point (x, y) placed zone brick, else true bool getZoneMask (sint32 x, sint32 y); + bool getZoneAmongRegions(ZonePosition &zonePos, BuilderZoneRegion *builderZoneRegionFrom, sint32 x, sint32 y); /// Ligo Actions /// @{ + + /// Adds the LigoTileCommand in undo stack void actionLigoTile(const LigoData &data, const ZonePosition &zonePos); + void actionLigoMove(uint index, sint32 deltaX, sint32 deltaY); + + /// Adds the LigoResizeCommand in undo stack void actionLigoResize(uint index, sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY); /// @} @@ -82,11 +90,24 @@ public: /// Zone Region /// @{ + + /// Creates empty zone region and adds in the workspace + /// @return id zone region int createZoneRegion(); + + /// Loads zone region from file @fileName and adds in the workspace. + /// @return id zone region int createZoneRegion(const QString &fileName); + + /// Unloads zone region from the workspace void deleteZoneRegion(int id); + + /// Sets the current zone region with @id void setCurrentZoneRegion(int id); + + /// @return id the current zone region, if workspace is empty then returns (-1) int currentIdZoneRegion() const; + ZoneRegionObject *currentZoneRegion() const; int countZoneRegion() const; ZoneRegionObject *zoneRegion(int id) const; @@ -106,12 +127,18 @@ public: private: - /// Scan ./zoneligos dir and add all *.ligozone files to zoneBank + /// Scans ./zoneligos dir and add all *.ligozone files to zoneBank bool initZoneBank (const QString &path); + /// Checks enabled beginMacro mode for undo stack, if false, then enables mode void checkBeginMacro(); + + /// Checks enabled on beginMacro mode for undo stack, if true, then adds UndoScanRegionCommand + /// in undo stack and disables beginMacro mode void checkEndMacro(); + /// Checks intersects between them zone regions + /// @return true if newZoneRegion intersects with loaded zone regions, else return false bool checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion); struct LandscapeItem diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h index 4c9e501eb..8ea7f79a3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h @@ -67,8 +67,8 @@ struct ZonePosition }; /** -@class ZoneBuilder -@brief ZoneBuilder contains all the shared data between the tools and the engine. +@class ZoneBuilderBase +@brief ZoneBuilderBase contains all the shared data between the tools and the engine. @details ZoneBank contains the macro zones that is composed of several zones plus a mask. PixmapDatabase contains the graphics for the zones */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp index 4fcf36efe..dc8b003c7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp @@ -93,8 +93,9 @@ void LigoTileCommand::redo () m_zoneBuilder->setLigoData(m_newLigoData, m_zonePos); } -UndoScanRegionCommand::UndoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent) +UndoScanRegionCommand::UndoScanRegionCommand(bool direction, ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent) : QUndoCommand(parent), + m_direction(direction), m_zoneBuilder(zoneBuilder), m_scene(scene) { @@ -112,45 +113,21 @@ void UndoScanRegionCommand::setScanList(const QList &zonePositionL void UndoScanRegionCommand::undo() { - for (int i = 0; i < m_zonePositionList.size(); ++i) - m_scene->deleteItemZone(m_zonePositionList.at(i)); - for (int i = 0; i < m_zonePositionList.size(); ++i) - { - LigoData data; - m_zoneBuilder->ligoData(data, m_zonePositionList.at(i)); - m_scene->createItemZone(data, m_zonePositionList.at(i)); - } + if (m_direction) + applyChanges(); } void UndoScanRegionCommand::redo() { + if (!m_direction) + applyChanges(); } -RedoScanRegionCommand::RedoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent) - : QUndoCommand(parent), - m_zoneBuilder(zoneBuilder), - m_scene(scene) -{ -} - -RedoScanRegionCommand::~RedoScanRegionCommand() -{ - m_zonePositionList.clear(); -} - -void RedoScanRegionCommand::setScanList(const QList &zonePositionList) -{ - m_zonePositionList = zonePositionList; -} - -void RedoScanRegionCommand::undo() -{ -} - -void RedoScanRegionCommand::redo() +void UndoScanRegionCommand::applyChanges() { for (int i = 0; i < m_zonePositionList.size(); ++i) m_scene->deleteItemZone(m_zonePositionList.at(i)); + for (int i = 0; i < m_zonePositionList.size(); ++i) { LigoData data; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h index c4afcc801..a21bece5d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h @@ -32,6 +32,11 @@ namespace LandscapeEditor { +/** +@class OpenLandscapeCommand +@brief +@details +*/ class OpenLandscapeCommand: public QUndoCommand { public: @@ -45,6 +50,11 @@ private: QString m_fileName; }; +/** +@class NewLandscapeCommand +@brief +@details +*/ class NewLandscapeCommand: public QUndoCommand { public: @@ -56,7 +66,11 @@ public: private: }; -// Modify the landscape +/** +@class LigoTileCommand +@brief +@details +*/ class LigoTileCommand: public QUndoCommand { public: @@ -76,10 +90,15 @@ private: LandscapeScene *m_scene; }; +/** +@class UndoScanRegionCommand +@brief +@details +*/ class UndoScanRegionCommand: public QUndoCommand { public: - UndoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0); + UndoScanRegionCommand(bool direction, ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0); virtual ~UndoScanRegionCommand(); void setScanList(const QList &zonePositionList); @@ -87,49 +106,19 @@ public: virtual void redo(); private: + void applyChanges(); + bool m_direction; QList m_zonePositionList; ZoneBuilder *m_zoneBuilder; LandscapeScene *m_scene; }; -class RedoScanRegionCommand: public QUndoCommand -{ -public: - RedoScanRegionCommand(ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent = 0); - virtual ~RedoScanRegionCommand(); - - void setScanList(const QList &zonePositionList); - virtual void undo(); - virtual void redo(); - -private: - - QList m_zonePositionList; - ZoneBuilder *m_zoneBuilder; - LandscapeScene *m_scene; -}; - -/* -// Move the landscape -class LigoMoveCommand: public QUndoCommand -{ -public: - - LigoMoveCommand(int index, sint32 deltaX, sint32 deltaY, ZoneBuilder *zoneBuilder, QUndoCommand *parent = 0); - virtual ~LigoMoveCommand(); - - virtual void undo(); - virtual void redo(); -private: - - int m_index; - sint32 m_deltaX; - sint32 m_deltaY; - ZoneBuilder *m_zoneBuilder; -}; +/** +@class LigoResizeCommand +@brief +@details */ -// Modify the landscape class LigoResizeCommand: public QUndoCommand { public: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h index 76b91dad5..92845abb8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_constants.h @@ -1,5 +1,4 @@ // 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp index 401256ce6..e7665b42f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp @@ -1,5 +1,4 @@ // 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 @@ -75,7 +74,7 @@ QString LandscapeEditorPlugin::name() const QString LandscapeEditorPlugin::version() const { - return "0.1"; + return "0.8"; } QString LandscapeEditorPlugin::vendor() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h index 8f9f811cf..4515da8be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h @@ -1,5 +1,4 @@ // 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index b3110a0e5..69b27c660 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -1,5 +1,4 @@ // 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index 67768e39a..92745365b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -1,5 +1,4 @@ // 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h index 5ce1fb3a7..462e6ecfb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -27,6 +27,11 @@ namespace LandscapeEditor { +/** +@class LandscapeView +@brief Provides graphics view for viewing zone regions. +@details Also provides zooming, panning and displaying grid +*/ class LANDSCAPE_EDITOR_EXPORT LandscapeView: public QGraphicsView { Q_OBJECT @@ -42,11 +47,16 @@ public: bool isVisibleGrid() const; public Q_SLOTS: + + /// Enable/disable displaying grid. void setVisibleGrid(bool visible); + + /// Enable/disable displaying text(coord.) above each zone bricks. void setVisibleText(bool visible); private Q_SLOTS: protected: + //Take over the interaction virtual void wheelEvent(QWheelEvent *event); virtual void mousePressEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h index 6c53ab4bc..e4682ebea 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.h @@ -35,8 +35,8 @@ class PixmapDatabase; /** @class ListZonesModel -@brief ListZonesModel contains the small images for QListView -@details +@brief ListZonesModel is used for managed list bricks by ListZonesWidget +@details ListZonesModel contains the small images for QListView */ class ListZonesModel : public QAbstractListModel { @@ -55,7 +55,7 @@ public: /// Value should be set before calling rebuildModel void setScaleRatio(int scaleRatio); - /// Unload all images and reset model + /// Delete all small images and reset model void resetModel(); /// Set current list zones which will be available in QListView diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h index 7298bbe3c..091c33908 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -1,5 +1,4 @@ // 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 @@ -45,16 +44,16 @@ public: void updateUi(); - // Set zone builder, call this method before using this class + /// Set zone builder, call this method before using this class void setZoneBuilder(ZoneBuilder *zoneBuilder); - // Get current zone name which user selected from list. + /// Get current zone name which user selected from list. QString currentZoneName(); - // Get current rotation value which user selected (Rot 0-0deg, 1-90deg, 2-180deg, 3-270deg). + /// Get current rotation value which user selected (Rot 0-0deg, 1-90deg, 2-180deg, 3-270deg). int currentRot(); - // Get current flip value which user selected (Flip 0-false, 1-true). + /// Get current flip value which user selected (Flip 0-false, 1-true). int currentFlip(); bool isNotPropogate() const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp index d3dbd646d..83e581ff3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp @@ -39,6 +39,7 @@ PixmapDatabase::PixmapDatabase(int textureSize) : m_textureSize(textureSize), m_errorPixmap(0) { + // Create pixmap for case if pixmap and LIGO files not found m_errorPixmap = new QPixmap(QSize(m_textureSize, m_textureSize)); QPainter painter(m_errorPixmap); painter.setRenderHint(QPainter::Antialiasing, true); @@ -46,7 +47,7 @@ PixmapDatabase::PixmapDatabase(int textureSize) painter.setFont(QFont("Helvetica [Cronyx]", 14)); painter.setPen(QPen(Qt::red, 2, Qt::SolidLine)); painter.drawText(m_errorPixmap->rect(), Qt::AlignCenter | Qt::TextWordWrap, - QObject::tr("Pixmap and LIGO files not found. Set the correct data path and reload landscape.")); + QObject::tr("Pixmap and LIGO files not found.")); painter.end(); } @@ -84,7 +85,7 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png"); if (pixmap->isNull()) { - // Generate filled pixmap + // Generate filled pixmap if could not load pixmap QPixmap *emptyPixmap = new QPixmap(QSize(sizeX * m_textureSize, sizeY * m_textureSize)); QPainter painter(emptyPixmap); painter.setRenderHint(QPainter::Antialiasing, true); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h index a9d4383ad..ce0b2a3bf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h @@ -52,7 +52,8 @@ public: QStringList listPixmaps() const; /// Get original pixmap - /// @return QPixmap* if the image is in the database ; otherwise returns 0. + /// @return QPixmap* if the image is in the database ; + /// otherwise returns pixmap which contains error message. QPixmap *pixmap(const QString &zoneName) const; int textureSize() const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp index 3acd3ff66..f3eedb8a6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.cpp @@ -1,5 +1,4 @@ // 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h index abb93ab81..ecad06f58 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/project_settings_dialog.h @@ -1,5 +1,4 @@ // 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp index ab2579722..aeccd21b2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.cpp @@ -1,5 +1,4 @@ // 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h index b66133a07..34db0e4a2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h @@ -1,5 +1,4 @@ // 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 @@ -40,9 +39,6 @@ public: int widthSnapshot() const; int heightSnapshot() const; -private Q_SLOTS: - - private: Ui::SnapshotDialog m_ui; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h index 91b2d66c1..e40aba9d4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.h @@ -28,8 +28,6 @@ // STL includes #include -// Qt includes - namespace LandscapeEditor { @@ -80,7 +78,7 @@ struct LigoData /** @class ZoneRegionObject -@brief +@brief The class contains NLLIGO::CZoneRegion object and provides basic operations above it @details */ class LANDSCAPE_EDITOR_EXPORT ZoneRegionObject @@ -115,7 +113,7 @@ public: /// Check position, it belongs to the landscape bool checkPos(const sint32 x, const sint32 y); - /// Helper flag to know if a ps has been modified + /// Helper flag to know if the zone region has been modified /// @{ bool isModified() const; From 8c14b55871905f6a535ce3755246b07d111b2679 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 20 Aug 2011 16:10:35 +0300 Subject: [PATCH 066/747] Changed: #1302 Added "delete primitive" undo command. --- .../landscape_editor/pixmap_database.h | 2 +- .../object_viewer/object_viewer_plugin.cpp | 2 +- .../plugins/world_editor/primitive_item.cpp | 13 +++ .../src/plugins/world_editor/primitive_item.h | 3 + .../plugins/world_editor/primitives_model.cpp | 34 ++++---- .../plugins/world_editor/primitives_model.h | 8 +- .../plugins/world_editor/primitives_view.cpp | 10 ++- .../world_editor/world_editor_actions.cpp | 81 ++++++++++++++++++- .../world_editor/world_editor_actions.h | 32 +++++++- .../world_editor/world_editor_constants.h | 1 + .../plugins/world_editor/world_editor_misc.h | 3 - .../world_editor/world_editor_window.cpp | 8 +- .../world_editor/world_editor_window.ui | 15 +--- 13 files changed, 166 insertions(+), 46 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h index ce0b2a3bf..15b26e474 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h @@ -52,7 +52,7 @@ public: QStringList listPixmaps() const; /// Get original pixmap - /// @return QPixmap* if the image is in the database ; + /// @return QPixmap* if the image is in the database ; /// otherwise returns pixmap which contains error message. QPixmap *pixmap(const QString &zoneName) const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp index f82789e66..4bc976571 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp @@ -68,7 +68,7 @@ QString ObjectViewerPlugin::version() const QString ObjectViewerPlugin::vendor() const { - return Core::Constants::OVQT_VENDOR; + return "GSoC2010_dnk-88"; } QString ObjectViewerPlugin::description() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index e867f1368..05b200960 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -34,6 +34,7 @@ namespace WorldEditor Node::Node() : m_parent(0) { + setData(Constants::PRIMITIVE_IS_VISIBLE, true); } Node::~Node() @@ -102,6 +103,18 @@ void Node::insertChildNodeAfter(Node *node, Node *after) node->m_parent = this; } +void Node::insertChildNode(int pos, Node *node) +{ + // Node is already a child + nlassert(!m_children.contains(node)); + + // Node already has a parent + nlassert(!m_children.contains(node)); + + m_children.insert(pos, node); + node->m_parent = this; +} + void Node::removeChildNode(Node *node) { nlassert(m_children.contains(node)); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 300973c55..164ee035f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -72,6 +72,9 @@ public: /// Insert node in back of the node pointed to by the pointer after. void insertChildNodeAfter(Node *node, Node *after); + /// Insert node in pos + void insertChildNode(int pos, Node *node); + /// Return the node at index position row in the child list. Node *child(int row); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp index 690e7db08..d40453dee 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp @@ -214,7 +214,7 @@ Path PrimitivesTreeModel::createLandscapeNode(const QString &fileName) } -Path PrimitivesTreeModel::createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives) +Path PrimitivesTreeModel::createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives, int pos) { if (m_worldEditNode == 0) createWorldEditNode("NewWorldEdit"); @@ -223,42 +223,48 @@ Path PrimitivesTreeModel::createRootPrimitiveNode(const QString &fileName, NLLIG if (!fileName.isEmpty()) name = fileName; + int insPos = pos; + // Get position - int pos = m_worldEditNode->childCount(); + if (pos == AtTheEnd) + insPos = m_worldEditNode->childCount(); QModelIndex parentIndex = index(0, 0, QModelIndex()); // Add root node in tree model - beginInsertRows(parentIndex, pos, pos); + beginInsertRows(parentIndex, insPos, insPos); RootPrimitiveNode *newNode = new RootPrimitiveNode(name, primitives); - m_worldEditNode->appendChildNode(newNode); + m_worldEditNode->insertChildNode(insPos, newNode); endInsertRows(); newNode->setData(Constants::PRIMITIVE_FILE_IS_CREATED, !fileName.isEmpty()); newNode->setData(Constants::PRIMITIVE_IS_MODIFIED, false); - QModelIndex rootPrimIndex = index(pos, 0, parentIndex); + QModelIndex rootPrimIndex = index(insPos, 0, parentIndex); // Scan childs items and add in the tree model for (uint i = 0; i < primitives->RootNode->getNumChildren(); ++i) { NLLIGO::IPrimitive *childPrim; primitives->RootNode->getChild(childPrim, i); - createChildNodes(childPrim, rootPrimIndex); + createChildNodes(childPrim, i, rootPrimIndex); } return pathFromIndex(rootPrimIndex); } -Path PrimitivesTreeModel::createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent) +Path PrimitivesTreeModel::createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent, int pos) { QModelIndex parentIndex = pathToIndex(parent); Node *parentNode = static_cast(parentIndex.internalPointer()); - int pos = parentNode->childCount(); - createChildNodes(primitive, parentIndex); + int insPos = pos; + if (pos == AtTheEnd) + insPos = parentNode->childCount(); - return pathFromIndex(index(pos, 0, parentIndex)); + createChildNodes(primitive, insPos, parentIndex); + + return pathFromIndex(index(insPos, 0, parentIndex)); } void PrimitivesTreeModel::deleteNode(const Path &path) @@ -271,16 +277,14 @@ void PrimitivesTreeModel::deleteNode(const Path &path) removeChildNodes(node, parentIndex); } -void PrimitivesTreeModel::createChildNodes(NLLIGO::IPrimitive *primitive, const QModelIndex &parent) +void PrimitivesTreeModel::createChildNodes(NLLIGO::IPrimitive *primitive, int pos, const QModelIndex &parent) { Node *parentNode = static_cast(parent.internalPointer()); - int pos = parentNode->childCount(); - // Add node in the tree model beginInsertRows(parent, pos, pos); PrimitiveNode *newNode = new PrimitiveNode(primitive); - parentNode->appendChildNode(newNode); + parentNode->insertChildNode(pos, newNode); endInsertRows(); // Scan childs items and add in the tree model @@ -289,7 +293,7 @@ void PrimitivesTreeModel::createChildNodes(NLLIGO::IPrimitive *primitive, const { NLLIGO::IPrimitive *childPrim; primitive->getChild(childPrim, i); - createChildNodes(childPrim, childIndex); + createChildNodes(childPrim, i, childIndex); } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h index c3c6a3e51..c9d59e848 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h @@ -34,6 +34,8 @@ namespace WorldEditor class Node; class WorldEditNode; +const int AtTheEnd = -1; + typedef QPair PathItem; /* @typedef Path @@ -81,16 +83,16 @@ public: Path createLandscapeNode(const QString &fileName); /// Add new root primitive node and all sub-primitives in the tree model. - Path createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives); + Path createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives, int pos = AtTheEnd); /// Add new primitive node and all sub-primitives in the tree model. - Path createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent); + Path createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent, int pos = AtTheEnd); /// Delete node and all child nodes from the tree model void deleteNode(const Path &path); private: - void createChildNodes(NLLIGO::IPrimitive *primitive, const QModelIndex &parent); + void createChildNodes(NLLIGO::IPrimitive *primitive, int pos, const QModelIndex &parent); void removeChildNodes(Node *node, const QModelIndex &parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index ca329b25b..b1f5ffda9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -66,7 +66,7 @@ PrimitivesView::PrimitivesView(QWidget *parent) m_newPrimitiveAction = new QAction("New primitive", this); m_deleteAction = new QAction("Delete", this); - m_deleteAction->setEnabled(false); + //m_deleteAction->setEnabled(false); m_selectChildrenAction = new QAction("Select children", this); @@ -243,6 +243,14 @@ void PrimitivesView::deletePrimitives() nlassert(m_primitivesTreeModel); QModelIndexList indexList = selectionModel()->selectedRows(); + + QModelIndex index = indexList.first(); + + PrimitiveNode *node = static_cast(index.internalPointer()); + + if (node->primitiveClass()->Deletable) + m_undoStack->push(new DeletePrimitiveCommand(index, m_primitivesTreeModel, m_worldEditorScene, this)); + } void PrimitivesView::addNewPrimitiveByClass(int value) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index b22e3fe64..635c7342b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -95,7 +95,7 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode radius = atof(strRadius.c_str()); qreal angle = ((2 * NLMISC::Pi - primPoint->Angle) * 180 / NLMISC::Pi); item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), - primPoint->Angle, radius, showArrow); + angle, radius, showArrow); break; } case NLLIGO::CPrimitiveClass::Path: @@ -430,6 +430,85 @@ void AddPrimitiveByClassCommand::redo() addNewGraphicsItems(m_model->pathToIndex(m_newPrimIndex), m_model, m_scene); } +DeletePrimitiveCommand::DeletePrimitiveCommand(const QModelIndex &index, PrimitivesTreeModel *model, + WorldEditorScene *scene, QTreeView *view, QUndoCommand *parent) + : QUndoCommand(parent), + m_scene(scene), + m_model(model), + m_view(view) +{ + setText("Delete primitive"); + + // Save path to primitive + m_path = m_model->pathFromIndex(index); + m_parentPath = m_model->pathFromIndex(index.parent()); + + PrimitiveNode *node = static_cast(index.internalPointer()); + + NLLIGO::IPrimitive *primitive = node->primitive(); + + // Backup primitive + m_oldPrimitive = primitive->copy(); + + // Backup position primitive + primitive->getParent()->getChildId(m_posPrimitive, primitive); +} + +DeletePrimitiveCommand::~DeletePrimitiveCommand() +{ + delete m_oldPrimitive; +} + +void DeletePrimitiveCommand::undo() +{ + m_scene->setEnabledEditPoints(false); + m_view->selectionModel()->clearSelection(); + + QModelIndex parentIndex = m_model->pathToIndex(m_parentPath); + PrimitiveNode *parentNode = static_cast(parentIndex.internalPointer()); + + // set the primitive context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = parentNode->rootPrimitiveNode()->primitives(); + + NLLIGO::IPrimitive *newPrimitive = m_oldPrimitive->copy(); + if (!parentNode->primitive()->insertChild(newPrimitive, m_posPrimitive)) + nlerror("Primitive can't insert, m_posPrimitive is not a valid."); + + // Insert primitive node in tree model + Path newPath = m_model->createPrimitiveNode(newPrimitive, m_parentPath, m_path.back().first); + + // Scan graphics model + addNewGraphicsItems(m_model->pathToIndex(newPath), m_model, m_scene); + + // unset the context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL; +} + +void DeletePrimitiveCommand::redo() +{ + m_scene->setEnabledEditPoints(false); + m_view->selectionModel()->clearSelection(); + + QModelIndex index = m_model->pathToIndex(m_path); + PrimitiveNode *node = static_cast(index.internalPointer()); + NLLIGO::IPrimitive *primitive = node->primitive(); + + // Removes all graphics items + removeGraphicsItems(index, m_model, m_scene); + + // set the primitive context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = node->rootPrimitiveNode()->primitives(); + + // Delete primitive + Utils::deletePrimitive(primitive); + + // unset the context + NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL; + + // Remove primitive from tree model + m_model->deleteNode(m_path); +} + AbstractWorldItemCommand::AbstractWorldItemCommand(const QList &items, WorldEditorScene *scene, PrimitivesTreeModel *model, diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 17f19fbca..15a553822 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -156,9 +156,33 @@ private: float m_delta; const QString m_className; Path m_parentIndex, m_newPrimIndex; - WorldEditorScene *m_scene; - PrimitivesTreeModel *m_model; - QTreeView *m_view; + WorldEditorScene *const m_scene; + PrimitivesTreeModel *const m_model; + QTreeView *const m_view; +}; + +/** +@class DeletePrimitiveCommand +@brief +@details +*/ +class DeletePrimitiveCommand: public QUndoCommand +{ +public: + DeletePrimitiveCommand(const QModelIndex &index, PrimitivesTreeModel *model, + WorldEditorScene *scene, QTreeView *view, QUndoCommand *parent = 0); + virtual ~DeletePrimitiveCommand(); + + virtual void undo(); + virtual void redo(); +private: + + Path m_path, m_parentPath; + uint m_posPrimitive; + NLLIGO::IPrimitive *m_oldPrimitive; + WorldEditorScene *const m_scene; + PrimitivesTreeModel *const m_model; + QTreeView *const m_view; }; /** @@ -186,7 +210,7 @@ private: const QList m_listPaths; PrimitivesTreeModel *const m_model; - WorldEditorScene *m_scene; + WorldEditorScene *const m_scene; bool m_firstRun; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index 9a7a834d6..0e27301d5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -30,6 +30,7 @@ const int GRAPHICS_DATA_QT4_2D = USER_TYPE + 3; const int GRAPHICS_DATA_NEL3D = USER_TYPE + 4; const int PRIMITIVE_IS_MODIFIED = USER_TYPE + 5; const int PRIMITIVE_FILE_IS_CREATED = USER_TYPE + 6; +const int PRIMITIVE_IS_VISIBLE = USER_TYPE + 7; //settings const char *const WORLD_EDITOR_SECTION = "WorldEditor"; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h index 2e7fc93b1..4163ae2e0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h @@ -65,9 +65,6 @@ NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName, const std::vector &initParameters, NLLIGO::IPrimitive *parent); -// Remove the primitive and don't delete it. -//void takeAtPrimitive(NLLIGO::IPrimitive *primitive); - void deletePrimitive(NLLIGO::IPrimitive *primitive); bool updateDefaultValues(NLLIGO::IPrimitive *primitive); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 2df27d7c7..ba5543776 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -74,7 +74,6 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) sceneModeGroup->addAction(m_ui.rotateAction); sceneModeGroup->addAction(m_ui.scaleAction); sceneModeGroup->addAction(m_ui.turnAction); - sceneModeGroup->addAction(m_ui.radiusAction); m_ui.selectAction->setChecked(true); m_ui.newWorldEditAction->setIcon(QIcon(Core::Constants::ICON_NEW)); @@ -95,8 +94,6 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_modeMapper->setMapping(m_ui.scaleAction, 3); connect(m_ui.turnAction, SIGNAL(triggered()), m_modeMapper, SLOT(map())); m_modeMapper->setMapping(m_ui.turnAction, 4); - connect(m_ui.radiusAction, SIGNAL(triggered()), m_modeMapper, SLOT(map())); - m_modeMapper->setMapping(m_ui.radiusAction, 5); connect(m_modeMapper, SIGNAL(mapped(int)), this, SLOT(setMode(int))); connect(m_ui.pointsAction, SIGNAL(triggered(bool)), m_worldEditorScene, SLOT(setEnabledEditPoints(bool))); @@ -384,9 +381,10 @@ void WorldEditorWindow::readSettings() restoreGeometry(settings->value(Constants::WORLD_WINDOW_GEOMETRY).toByteArray()); // Use OpenGL graphics system instead raster graphics system - if (settings->value(Constants::WORLD_EDITOR_USE_OPENGL, false).toBool()) + if (settings->value(Constants::WORLD_EDITOR_USE_OPENGL, true).toBool()) { - m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); + //m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); + m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers)); m_ui.graphicsView->setViewport(m_oglWidget); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index 870081d47..d6d4edb28 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -27,6 +27,9 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + QPainter::Antialiasing|QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing + QGraphicsView::NoDrag @@ -72,7 +75,6 @@ - @@ -316,17 +318,6 @@ Turn - - - true - - - false - - - Radius - - true From 1ad2ff35126b4cca6f5af1320945f108a9bcb003 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 22 Aug 2011 21:53:23 +0300 Subject: [PATCH 067/747] Changed: #1302 Added "unload primitive" and "unload landscape" undo command. Update doxygen comments. --- .../plugins/landscape_editor/builder_zone.cpp | 4 +- .../plugins/world_editor/primitive_item.cpp | 14 ++- .../src/plugins/world_editor/primitive_item.h | 8 +- .../plugins/world_editor/primitives_model.cpp | 22 ++++- .../plugins/world_editor/primitives_model.h | 7 +- .../plugins/world_editor/primitives_view.cpp | 57 +++++++++-- .../plugins/world_editor/primitives_view.h | 5 +- .../world_editor/project_settings_dialog.cpp | 9 ++ .../world_editor/world_editor_actions.cpp | 99 ++++++++++++++++--- .../world_editor/world_editor_actions.h | 57 ++++++++++- .../world_editor/world_editor_scene.cpp | 10 ++ .../plugins/world_editor/world_editor_scene.h | 21 +++- .../world_editor/world_editor_scene_item.h | 19 +++- .../world_editor/world_editor_window.cpp | 3 + 14 files changed, 293 insertions(+), 42 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp index f9aec3e3b..8e3adf415 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone.cpp @@ -399,7 +399,7 @@ QString ZoneBuilder::dataPath() const bool ZoneBuilder::getZoneMask(sint32 x, sint32 y) { if ((x < m_minX) || (x > m_maxX) || - (y < m_minY) || (y > m_maxY)) + (y < m_minY) || (y > m_maxY)) return true; else return m_zoneMask[(x - m_minX) + (y - m_minY) * (1 + m_maxX - m_minX)]; @@ -504,7 +504,7 @@ void ZoneBuilder::checkEndMacro() // Sets list positions in which need apply changes m_undoScanRegionCommand->setScanList(m_zonePositionList); redoScanRegionCommand->setScanList(m_zonePositionList); - + // Adds command in the stack m_undoStack->push(redoScanRegionCommand); m_undoStack->endMacro(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index 05b200960..658231b2c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -178,7 +178,9 @@ Node::NodeType WorldEditNode::type() const return WorldEditNodeType; } -LandscapeNode::LandscapeNode(const QString &name) +LandscapeNode::LandscapeNode(const QString &name, int id) + : m_id(id), + m_fileName(name) { setData(Qt::DisplayRole, name); setData(Qt::DecorationRole, QIcon(LandscapeEditor::Constants::ICON_ZONE_ITEM)); @@ -188,6 +190,16 @@ LandscapeNode::~LandscapeNode() { } +QString LandscapeNode::fileName() const +{ + return m_fileName; +} + +int LandscapeNode::id() const +{ + return m_id; +} + Node::NodeType LandscapeNode::type() const { return LandscapeNodeType; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 164ee035f..f95eff0c0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -128,12 +128,18 @@ private: class LandscapeNode: public Node { public: - LandscapeNode(const QString &name); + LandscapeNode(const QString &name, int id); virtual ~LandscapeNode(); + int id() const; + QString fileName() const; + virtual NodeType type() const; private: + + QString m_fileName; + int m_id; }; /* diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp index d40453dee..46436b699 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp @@ -200,17 +200,29 @@ void PrimitivesTreeModel::deleteWorldEditNode() endResetModel(); } -Path PrimitivesTreeModel::createLandscapeNode(const QString &fileName) +bool PrimitivesTreeModel::isWorldEditNodeLoaded() const +{ + if (m_worldEditNode == 0) + return false; + else + return true; +} + +Path PrimitivesTreeModel::createLandscapeNode(const QString &fileName, int id, int pos) { if (m_worldEditNode == 0) createWorldEditNode("NewWorldEdit"); QModelIndex parentIndex = index(0, 0, QModelIndex()); - beginInsertRows(parentIndex, 0, 0); - LandscapeNode *newNode = new LandscapeNode(fileName); - m_worldEditNode->prependChildNode(newNode); + int insPos = pos; + if (pos == -1) + insPos = 0; + + beginInsertRows(parentIndex, insPos, insPos); + LandscapeNode *newNode = new LandscapeNode(fileName, id); + m_worldEditNode->insertChildNode(insPos, newNode); endInsertRows(); - return pathFromIndex(index(0, 0, index(0, 0, QModelIndex()))); + return pathFromIndex(index(0, 0, index(insPos, 0, QModelIndex()))); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h index c9d59e848..d1a883106 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h @@ -69,18 +69,17 @@ public: /// Convert QModelIndex to the persistent index - @Path. /// @Path is a list of [row,column] pairs showing us the way through the model. Path pathFromIndex(const QModelIndex &index); - - Path pathFromNode(Node *node); - QModelIndex pathToIndex(const Path &path); + Path pathFromNode(Node *node); Node *pathToNode(const Path &path); void createWorldEditNode(const QString &fileName); void deleteWorldEditNode(); + bool isWorldEditNodeLoaded() const; /// Add new landscape node in tree model. - Path createLandscapeNode(const QString &fileName); + Path createLandscapeNode(const QString &fileName, int id, int pos = AtTheEnd); /// Add new root primitive node and all sub-primitives in the tree model. Path createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives, int pos = AtTheEnd); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index b1f5ffda9..6395720c5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -33,6 +33,7 @@ // Qt includes #include #include +#include #include #include @@ -49,7 +50,6 @@ PrimitivesView::PrimitivesView(QWidget *parent) setContextMenuPolicy(Qt::DefaultContextMenu); m_unloadAction = new QAction("Unload", this); - m_unloadAction->setEnabled(false); m_saveAction = new QAction("Save", this); m_saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE)); @@ -66,7 +66,6 @@ PrimitivesView::PrimitivesView(QWidget *parent) m_newPrimitiveAction = new QAction("New primitive", this); m_deleteAction = new QAction("Delete", this); - //m_deleteAction->setEnabled(false); m_selectChildrenAction = new QAction("Select children", this); @@ -86,6 +85,9 @@ PrimitivesView::PrimitivesView(QWidget *parent) connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deletePrimitives())); connect(m_saveAction, SIGNAL(triggered()), this, SLOT(save())); connect(m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); + connect(m_unloadAction, SIGNAL(triggered()), this, SLOT(unload())); + connect(m_showAction, SIGNAL(triggered()), this, SLOT(showPrimitive())); + connect(m_hideAction, SIGNAL(triggered()), this, SLOT(hidePrimitive())); #ifdef Q_OS_DARWIN setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); @@ -186,7 +188,10 @@ void PrimitivesView::selectChildren() QModelIndex parentIndex = indexList.first(); selectionModel()->clearSelection(); - selectChildren(parentIndex); + + QItemSelection itemSelection; + selectChildren(parentIndex, itemSelection); + selectionModel()->select(itemSelection, QItemSelectionModel::Select); } void PrimitivesView::save() @@ -253,6 +258,41 @@ void PrimitivesView::deletePrimitives() } +void PrimitivesView::unload() +{ + nlassert(m_undoStack); + nlassert(m_primitivesTreeModel); + + QModelIndexList indexList = selectionModel()->selectedRows(); + QModelIndex index = indexList.first(); + Node *node = static_cast(index.internalPointer()); + switch (node->type()) + { + case Node::WorldEditNodeType: + { + break; + } + case Node::LandscapeNodeType: + { + m_undoStack->push(new UnloadLandscapeCommand(index, m_primitivesTreeModel, m_zoneBuilder)); + break; + } + case Node::RootPrimitiveNodeType: + { + m_undoStack->push(new UnloadRootPrimitiveCommand(index, m_worldEditorScene, m_primitivesTreeModel, this)); + break; + } + } +} + +void PrimitivesView::showPrimitive() +{ +} + +void PrimitivesView::hidePrimitive() +{ +} + void PrimitivesView::addNewPrimitiveByClass(int value) { nlassert(m_undoStack); @@ -311,21 +351,24 @@ void PrimitivesView::contextMenuEvent(QContextMenuEvent *event) event->accept(); } -void PrimitivesView::selectChildren(const QModelIndex &parent) +void PrimitivesView::selectChildren(const QModelIndex &parent, QItemSelection &itemSelection) { const int rowCount = model()->rowCount(parent); + QItemSelection mergeItemSelection(parent.child(0, 0), parent.child(rowCount - 1, 0)); + itemSelection.merge(mergeItemSelection, QItemSelectionModel::Select); + for (int i = 0; i < rowCount; ++i) { QModelIndex childIndex = parent.child(i, 0); - selectionModel()->select(childIndex, QItemSelectionModel::Select); - selectChildren(childIndex); + if (model()->rowCount(childIndex) != 0) + selectChildren(childIndex, itemSelection); } } void PrimitivesView::fillMenu_WorldEdit(QMenu *menu) { - menu->addAction(m_unloadAction); + //menu->addAction(m_unloadAction); //menu->addAction(m_saveAction); //menu->addAction(m_saveAsAction); menu->addSeparator(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h index 3fce65ae7..2b16bc714 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h @@ -70,6 +70,9 @@ private Q_SLOTS: void save(); void saveAs(); void deletePrimitives(); + void unload(); + void showPrimitive(); + void hidePrimitive(); void addNewPrimitiveByClass(int value); void generatePrimitives(int value); void openItem(int value); @@ -78,7 +81,7 @@ protected: void contextMenuEvent(QContextMenuEvent *event); private: - void selectChildren(const QModelIndex &parent); + void selectChildren(const QModelIndex &parent, QItemSelection &itemSelection); void fillMenu_WorldEdit(QMenu *menu); void fillMenu_Landscape(QMenu *menu); void fillMenu_RootPrimitive(QMenu *menu, const QModelIndex &index); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.cpp index 28654864c..42e921106 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/project_settings_dialog.cpp @@ -16,12 +16,14 @@ // Project includes #include "project_settings_dialog.h" +#include "world_editor_misc.h" #include "../core/icore.h" #include "../core/core_constants.h" // NeL includes #include +#include // Qt includes #include @@ -36,6 +38,13 @@ ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *p { m_ui.setupUi(this); m_ui.pathLineEdit->setText(dataPath); + m_ui.contextComboBox->addItem("empty"); + + // Init the combo box + const std::vector &contexts = Utils::ligoConfig()->getContextString(); + for (uint i = 0; i < contexts.size(); i++) + m_ui.contextComboBox->addItem(QString(contexts[i].c_str())); + setFixedHeight(sizeHint().height()); connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath())); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 635c7342b..1e27c9f12 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -218,7 +218,7 @@ CreateWorldCommand::CreateWorldCommand(const QString &fileName, PrimitivesTreeMo m_fileName(fileName), m_model(model) { - setText("Create new world"); + setText(QObject::tr("Create new world")); } CreateWorldCommand::~CreateWorldCommand() @@ -243,7 +243,7 @@ LoadLandscapeCommand::LoadLandscapeCommand(const QString &fileName, PrimitivesTr m_model(model), m_zoneBuilder(zoneBuilder) { - setText("Load land file"); + setText(QObject::tr("Load land file")); } LoadLandscapeCommand::~LoadLandscapeCommand() @@ -263,7 +263,41 @@ void LoadLandscapeCommand::redo() else m_zoneBuilder->loadZoneRegion(m_fileName, m_id); - landIndex = m_model->createLandscapeNode(m_fileName); + landIndex = m_model->createLandscapeNode(m_fileName, m_id); +} + + +UnloadLandscapeCommand::UnloadLandscapeCommand(const QModelIndex &index, PrimitivesTreeModel *model, + LandscapeEditor::ZoneBuilderBase *zoneBuilder, QUndoCommand *parent) + : QUndoCommand(parent), + m_model(model), + m_zoneBuilder(zoneBuilder) +{ + setText(QObject::tr("Unload land file")); + m_path = m_model->pathFromIndex(index); +} + +UnloadLandscapeCommand::~UnloadLandscapeCommand() +{ +} + +void UnloadLandscapeCommand::undo() +{ + m_zoneBuilder->loadZoneRegion(m_fileName, m_id); + + m_model->createLandscapeNode(m_fileName, m_id, m_path.back().first); +} + +void UnloadLandscapeCommand::redo() +{ + QModelIndex index = m_model->pathToIndex(m_path); + LandscapeNode *node = static_cast(index.internalPointer()); + + m_id = node->id(); + m_fileName = node->fileName(); + + m_zoneBuilder->deleteZoneRegion(m_id); + m_model->deleteNode(m_path); } CreateRootPrimitiveCommand::CreateRootPrimitiveCommand(const QString &fileName, PrimitivesTreeModel *model, QUndoCommand *parent) @@ -271,7 +305,7 @@ CreateRootPrimitiveCommand::CreateRootPrimitiveCommand(const QString &fileName, m_fileName(fileName), m_model(model) { - setText("Create new primitive"); + setText(QObject::tr("Create new primitive")); } CreateRootPrimitiveCommand::~CreateRootPrimitiveCommand() @@ -304,7 +338,7 @@ LoadRootPrimitiveCommand::LoadRootPrimitiveCommand(const QString &fileName, Worl m_model(model), m_view(view) { - setText("Load primitive file"); + setText(QObject::tr("Load primitive file")); } LoadRootPrimitiveCommand::~LoadRootPrimitiveCommand() @@ -358,6 +392,47 @@ void LoadRootPrimitiveCommand::redo() addNewGraphicsItems(m_model->pathToIndex(m_rootPrimIndex), m_model, m_scene); } + +UnloadRootPrimitiveCommand::UnloadRootPrimitiveCommand(const QModelIndex &index, WorldEditorScene *scene, + PrimitivesTreeModel *model, QTreeView *view, QUndoCommand *parent) + : QUndoCommand(parent), + m_scene(scene), + m_model(model), + m_view(view) +{ + setText(QObject::tr("Unload primitive file")); + m_path = m_model->pathFromIndex(index); +} + +UnloadRootPrimitiveCommand::~UnloadRootPrimitiveCommand() +{ +} + +void UnloadRootPrimitiveCommand::undo() +{ + // Disable edit points mode + m_scene->setEnabledEditPoints(false); + + m_path = m_model->createRootPrimitiveNode(m_fileName, m_primitives, m_path.back().first); + + addNewGraphicsItems(m_model->pathToIndex(m_path), m_model, m_scene); +} + +void UnloadRootPrimitiveCommand::redo() +{ + m_scene->setEnabledEditPoints(false); + + m_view->selectionModel()->clearSelection(); + QModelIndex index = m_model->pathToIndex(m_path); + RootPrimitiveNode *node = static_cast(index.internalPointer()); + m_fileName = node->fileName(); + m_primitives = node->primitives(); + + removeGraphicsItems(index, m_model, m_scene); + + m_model->deleteNode(m_path); +} + AddPrimitiveByClassCommand::AddPrimitiveByClassCommand(const QString &className, const Path &parentIndex, WorldEditorScene *scene, PrimitivesTreeModel *model, QTreeView *view, QUndoCommand *parent) : QUndoCommand(parent), @@ -367,7 +442,7 @@ AddPrimitiveByClassCommand::AddPrimitiveByClassCommand(const QString &className, m_model(model), m_view(view) { - setText(QString("Add %1").arg(m_className)); + setText(QObject::tr("Add %1").arg(m_className)); QGraphicsView *graphicsView = m_scene->views().first(); @@ -437,7 +512,7 @@ DeletePrimitiveCommand::DeletePrimitiveCommand(const QModelIndex &index, Primiti m_model(model), m_view(view) { - setText("Delete primitive"); + setText(QObject::tr("Delete primitive")); // Save path to primitive m_path = m_model->pathFromIndex(index); @@ -629,7 +704,7 @@ MoveWorldItemsCommand::MoveWorldItemsCommand(const QList &items : AbstractWorldItemCommand(items, scene, model, parent), m_offset(offset) { - setText("Move item(s)"); + setText(QObject::tr("Move item(s)")); } MoveWorldItemsCommand::~MoveWorldItemsCommand() @@ -652,7 +727,7 @@ RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &i m_angle(angle), m_pivot(pivot) { - setText("Rotate item(s)"); + setText(QObject::tr("Rotate item(s)")); } RotateWorldItemsCommand::~RotateWorldItemsCommand() @@ -675,7 +750,7 @@ ScaleWorldItemsCommand::ScaleWorldItemsCommand(const QList &ite m_factor(factor), m_pivot(pivot) { - setText("Scale item(s)"); + setText(QObject::tr("Scale item(s)")); } ScaleWorldItemsCommand::~ScaleWorldItemsCommand() @@ -698,7 +773,7 @@ TurnWorldItemsCommand::TurnWorldItemsCommand(const QList &items : AbstractWorldItemCommand(items, scene, model, parent), m_angle(angle) { - setText("Turn item(s)"); + setText(QObject::tr("Turn item(s)")); } TurnWorldItemsCommand::~TurnWorldItemsCommand() @@ -722,7 +797,7 @@ ShapeWorldItemsCommand::ShapeWorldItemsCommand(const QList &ite m_redoPolygons(polygons), m_undoPolygons(polygonsFromItems(items)) { - setText("Change shape"); + setText(QObject::tr("Change shape")); } ShapeWorldItemsCommand::~ShapeWorldItemsCommand() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 15a553822..89de14e9a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -95,6 +95,34 @@ private: LandscapeEditor::ZoneBuilderBase *const m_zoneBuilder; }; +/** +@class UnloadLandscapeCommand +@brief +@details +*/ +class UnloadLandscapeCommand: public QUndoCommand +{ +public: + UnloadLandscapeCommand(const QModelIndex &index, PrimitivesTreeModel *model, + LandscapeEditor::ZoneBuilderBase *zoneBuilder, QUndoCommand *parent = 0); + virtual ~UnloadLandscapeCommand(); + + virtual void undo(); + virtual void redo(); +private: + + Path m_path; + int m_id; + QString m_fileName; + PrimitivesTreeModel *const m_model; + LandscapeEditor::ZoneBuilderBase *const m_zoneBuilder; +}; + +/** +@class CreateRootPrimitiveCommand +@brief +@details +*/ class CreateRootPrimitiveCommand: public QUndoCommand { public: @@ -112,7 +140,7 @@ private: }; /** -@class LoadPrimitiveCommand +@class LoadRootPrimitiveCommand @brief @details */ @@ -136,7 +164,32 @@ private: }; /** -@class AddPrimitiveCommand +@class UnloadRootPrimitiveCommand +@brief +@details +*/ +class UnloadRootPrimitiveCommand: public QUndoCommand +{ +public: + UnloadRootPrimitiveCommand(const QModelIndex &index, WorldEditorScene *scene, + PrimitivesTreeModel *model, QTreeView *view, + QUndoCommand *parent = 0); + virtual ~UnloadRootPrimitiveCommand(); + + virtual void undo(); + virtual void redo(); +private: + + Path m_path; + QString m_fileName; + NLLIGO::CPrimitives *m_primitives; + WorldEditorScene *const m_scene; + PrimitivesTreeModel *const m_model; + QTreeView *m_view; +}; + +/** +@class AddPrimitiveByClassCommand @brief @details */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 967f6651d..944372735 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -67,6 +67,8 @@ AbstractWorldItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, con { WorldItemPoint *item = new WorldItemPoint(point, angle, radius, showArrow); addItem(item); + + m_worldItems.push_back(item); return item; } @@ -74,6 +76,8 @@ AbstractWorldItem *WorldEditorScene::addWorldItemPath(const QPolygonF &polyline, { WorldItemPath *item = new WorldItemPath(polyline); addItem(item); + + m_worldItems.push_back(item); return item; } @@ -81,6 +85,8 @@ AbstractWorldItem *WorldEditorScene::addWorldItemZone(const QPolygonF &polygon) { WorldItemZone *item = new WorldItemZone(polygon); addItem(item); + + m_worldItems.push_back(item); return item; } @@ -90,6 +96,10 @@ void WorldEditorScene::removeWorldItem(QGraphicsItem *item) m_selectedItems.clear(); m_editedSelectedItems = false; m_firstSelection = false; + + // TODO + AbstractWorldItem *worldItem = qgraphicsitem_cast(item); + m_worldItems.removeOne(worldItem); delete item; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index c9da223a7..e981a703e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -34,8 +34,8 @@ class AbstractWorldItem; /* @class WorldEditorScene -@brief -@details +@brief The WorldEditorScene provides a surface for managing a large number of 2D world items(point/path/zone). +@details WorldEditorScene also provides 'selections model' functionality, which differs from standart selection model. */ class WORLD_EDITOR_EXPORT WorldEditorScene : public LandscapeEditor::LandscapeSceneBase { @@ -56,22 +56,38 @@ public: QUndoStack *undoStack, QObject *parent = 0); virtual ~WorldEditorScene(); + /// Create WorldItemPoint and add in scene. AbstractWorldItem *addWorldItemPoint(const QPointF &point, const qreal angle, const qreal radius, bool showArrow); + + /// Create WorldItemPath and add in scene. AbstractWorldItem *addWorldItemPath(const QPolygonF &polyline, bool showArrow); + + /// Create WorldItemZone and add in scene. AbstractWorldItem *addWorldItemZone(const QPolygonF &polygon); + + /// Remove a world item from the scene. void removeWorldItem(QGraphicsItem *item); + /// Set current mode editing(select/move/rotate/scale/turn), above world items. void setModeEdit(WorldEditorScene::ModeEdit mode); + WorldEditorScene::ModeEdit editMode() const; + /// @return true if edit points mode is enabled, else false. bool isEnabledEditPoints() const; Q_SIGNALS: + /// This signal is emitted by WorldEditorScene when the selections changes. + /// The @selected value contains a list of all selected items. void updateSelectedItems(const QList &selected); public Q_SLOTS: + /// Enable/disable edit points mode (user can change shape of WorldItemZone and WorldItemPath) + /// void setEnabledEditPoints(bool enabled); + + /// Update of selections void updateSelection(const QList &selected, const QList &deselected); protected: @@ -102,6 +118,7 @@ private: qreal m_firstPickX, m_firstPickY, m_angle; QList m_selectedItems; QList m_selectedPoints; + QList m_worldItems; QList m_polygons; bool m_editedSelectedItems, m_firstSelection; uint m_lastPickedPrimitive; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index 7268b6d03..9136712c5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -53,8 +53,8 @@ const int EDGE_POINT_LAYER = 201; const int SIZE_ARROW = 20; /* -@class WorldItemPoint -@brief +@class AbstractWorldItem +@brief Abstract class for graphics item @details */ class AbstractWorldItem: public QGraphicsItem @@ -65,13 +65,21 @@ public: enum { Type = QGraphicsItem::UserType + 1 }; + /// Rotate item around @pivot point on &deltaAngle (deg). virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) {}; + + /// Scales item relatively @pivot point // TODO: add modes: IgnoreAspectRatio, KeepAspectRatio virtual void scaleOn(const QPointF &pivot, const QPointF &factor) {}; + + /// Rotate arrow on angle (deg). (only for WorldItemPoint) virtual void turnOn(const qreal angle) {}; virtual void radiusOn(const qreal radius) {}; + /// Change color virtual void setColor(const QColor &color) = 0; + + /// Enable/disable the mode edit shape (only for WorldItemPath and WorldItemPath) virtual void setEnabledSubPoints(bool enabled) = 0; virtual void moveSubPoint(WorldItemSubPoint *subPoint) {} @@ -103,7 +111,8 @@ protected: /* @class WorldItemPoint -@brief +@brief WorldItemPoint class provides a dot item with arrow and circle(@radius) +that you can add to a WorldEditorScene. @details */ class WorldItemPoint: public AbstractWorldItem @@ -148,7 +157,7 @@ private: /* @class WorldItemPath -@brief +@brief WorldItemPath class provides a polyline item that you can add to a WorldEditorScene. @details */ class WorldItemPath: public AbstractWorldItem @@ -188,7 +197,7 @@ private: /* @class WorldItemZone -@brief +@brief The WorldItemZone class provides a polygon item that you can add to a WorldEditorScene. @details */ class WorldItemZone: public AbstractWorldItem diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index ba5543776..b2691fba3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -165,6 +165,9 @@ void WorldEditorWindow::open() void WorldEditorWindow::loadWorldEditFile(const QString &fileName) { + if (m_primitivesModel->isWorldEditNodeLoaded()) + return; + Utils::WorldEditList worldEditList; if (!Utils::loadWorldEditFile(fileName.toStdString(), worldEditList)) { From d6d47f63d0605521bf81def3d168ab4cbd45b769 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 23 Aug 2011 18:17:08 +0300 Subject: [PATCH 068/747] GSOC FINAL --- .../src/plugins/landscape_editor/landscape_actions.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h index a21bece5d..61abc4435 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h @@ -35,7 +35,7 @@ namespace LandscapeEditor /** @class OpenLandscapeCommand @brief -@details +@details */ class OpenLandscapeCommand: public QUndoCommand { @@ -53,7 +53,7 @@ private: /** @class NewLandscapeCommand @brief -@details +@details */ class NewLandscapeCommand: public QUndoCommand { @@ -69,7 +69,7 @@ private: /** @class LigoTileCommand @brief -@details +@details */ class LigoTileCommand: public QUndoCommand { @@ -93,7 +93,7 @@ private: /** @class UndoScanRegionCommand @brief -@details +@details */ class UndoScanRegionCommand: public QUndoCommand { @@ -117,7 +117,7 @@ private: /** @class LigoResizeCommand @brief -@details +@details */ class LigoResizeCommand: public QUndoCommand { From ede23b7077c153066378a4a22037acc3cc27407d Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 26 Sep 2011 02:53:15 +0300 Subject: [PATCH 069/747] Changed: #1193 Updated landscape editor and world editor plugins with latest API changes to OVQT plugin system. Added the plugin-spec files for each plugin. --- .../landscape_editor_plugin.cpp | 27 ------------------- .../landscape_editor_plugin.h | 7 ----- .../landscape_editor_window.cpp | 6 ++--- .../ovqt_plugin_landscape_editor.xml | 10 +++++++ .../world_editor/ovqt_plugin_world_editor.xml | 11 ++++++++ .../world_editor/world_editor_actions.cpp | 26 +++++++++--------- .../world_editor/world_editor_plugin.cpp | 27 ------------------- .../world_editor/world_editor_plugin.h | 7 ----- .../world_editor/world_editor_window.cpp | 6 ++--- 9 files changed, 40 insertions(+), 87 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/ovqt_plugin_landscape_editor.xml create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/ovqt_plugin_world_editor.xml diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp index e7665b42f..bbd285adc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.cpp @@ -67,33 +67,6 @@ void LandscapeEditorPlugin::setNelContext(NLMISC::INelContext *nelContext) m_libContext = new NLMISC::CLibraryContext(*nelContext); } -QString LandscapeEditorPlugin::name() const -{ - return tr("LandscapeEditor"); -} - -QString LandscapeEditorPlugin::version() const -{ - return "0.8"; -} - -QString LandscapeEditorPlugin::vendor() const -{ - return "GSoC2011_dnk-88"; -} - -QString LandscapeEditorPlugin::description() const -{ - return "Landscape editor ovqt plugin."; -} - -QStringList LandscapeEditorPlugin::dependencies() const -{ - QStringList list; - list.append(Core::Constants::OVQT_CORE_PLUGIN); - return list; -} - void LandscapeEditorPlugin::addAutoReleasedObject(QObject *obj) { m_plugMan->addObject(obj); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h index 4515da8be..145972e29 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h @@ -54,15 +54,8 @@ public: bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); void extensionsInitialized(); void shutdown(); - void setNelContext(NLMISC::INelContext *nelContext); - QString name() const; - QString version() const; - QString vendor() const; - QString description() const; - QStringList dependencies() const; - void addAutoReleasedObject(QObject *obj); protected: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 69b27c660..6b4377a37 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -24,7 +24,7 @@ #include "snapshot_dialog.h" #include "../core/icore.h" -#include "../core/imenu_manager.h" +#include "../core/menu_manager.h" #include "../core/core_constants.h" // NeL includes @@ -348,12 +348,12 @@ void LandscapeEditorWindow::updateStatusBar() void LandscapeEditorWindow::createMenus() { - Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); + Core::MenuManager *menuManager = Core::ICore::instance()->menuManager(); } void LandscapeEditorWindow::createToolBars() { - Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); + Core::MenuManager *menuManager = Core::ICore::instance()->menuManager(); //QAction *action = menuManager->action(Core::Constants::NEW); //m_ui.fileToolBar->addAction(action); //action = menuManager->action(Core::Constants::SAVE); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/ovqt_plugin_landscape_editor.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/ovqt_plugin_landscape_editor.xml new file mode 100644 index 000000000..ab71b7044 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/ovqt_plugin_landscape_editor.xml @@ -0,0 +1,10 @@ + + ovqt_plugin_landscape_editor + LandscapeEditor + 0.8 + GSoC2011_dnk-88 + Landscape editor ovqt plugin. + + + + \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/ovqt_plugin_world_editor.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/ovqt_plugin_world_editor.xml new file mode 100644 index 000000000..7a37eaf56 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/ovqt_plugin_world_editor.xml @@ -0,0 +1,11 @@ + + ovqt_plugin_world_editor + WorldEditor + 0.6 + GSoC2011_dnk-88 + Landscape editor ovqt plugin. + + + + + \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 1e27c9f12..7e78cdaf5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -158,20 +158,20 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode primitive->getPropertyByName ("Color", color); item->setColor(QColor(color.R, color.G, color.B)); + + QVariant variantNode; + variantNode.setValue(node); + item->setData(Constants::WORLD_EDITOR_NODE, variantNode); + + QVariant graphicsData; + graphicsData.setValue(item); + node->setData(Constants::GRAPHICS_DATA_QT4_2D, graphicsData); + + QVariant persistenVariant; + QPersistentModelIndex *persistentIndex = new QPersistentModelIndex(primIndex); + persistenVariant.setValue(persistentIndex); + item->setData(Constants::NODE_PERISTENT_INDEX, persistenVariant); } - - QVariant variantNode; - variantNode.setValue(node); - item->setData(Constants::WORLD_EDITOR_NODE, variantNode); - - QVariant graphicsData; - graphicsData.setValue(item); - node->setData(Constants::GRAPHICS_DATA_QT4_2D, graphicsData); - - QVariant persistenVariant; - QPersistentModelIndex *persistentIndex = new QPersistentModelIndex(primIndex); - persistenVariant.setValue(persistentIndex); - item->setData(Constants::NODE_PERISTENT_INDEX, persistenVariant); } int count = model->rowCount(primIndex); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp index 23b51e9e3..aa995777a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp @@ -103,33 +103,6 @@ void WorldEditorPlugin::setNelContext(NLMISC::INelContext *nelContext) m_libContext = new NLMISC::CLibraryContext(*nelContext); } -QString WorldEditorPlugin::name() const -{ - return tr("WorldEditor"); -} - -QString WorldEditorPlugin::version() const -{ - return "0.1"; -} - -QString WorldEditorPlugin::vendor() const -{ - return "GSoC2011_dnk-88"; -} - -QString WorldEditorPlugin::description() const -{ - return "World editor ovqt plugin."; -} - -QStringList WorldEditorPlugin::dependencies() const -{ - QStringList list; - list.append(Core::Constants::OVQT_CORE_PLUGIN); - return list; -} - void WorldEditorPlugin::addAutoReleasedObject(QObject *obj) { m_plugMan->addObject(obj); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h index 11e2c7871..4a107d11b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h @@ -56,15 +56,8 @@ public: bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); void extensionsInitialized(); void shutdown(); - void setNelContext(NLMISC::INelContext *nelContext); - QString name() const; - QString version() const; - QString vendor() const; - QString description() const; - QStringList dependencies() const; - void addAutoReleasedObject(QObject *obj); protected: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index b2691fba3..f1b8b17f1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -26,7 +26,7 @@ // Core #include "../core/icore.h" -#include "../core/imenu_manager.h" +#include "../core/menu_manager.h" #include "../core/core_constants.h" // Lanscape Editor plugin @@ -347,12 +347,12 @@ void WorldEditorWindow::hideEvent(QHideEvent *hideEvent) void WorldEditorWindow::createMenus() { - Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); + Core::MenuManager *menuManager = Core::ICore::instance()->menuManager(); } void WorldEditorWindow::createToolBars() { - Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager(); + Core::MenuManager *menuManager = Core::ICore::instance()->menuManager(); //QAction *action = menuManager->action(Core::Constants::NEW); //m_ui.fileToolBar->addAction(action); From 60a4ca7e079a436d3a0229efacf560014fd11add Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 3 Oct 2011 00:40:25 +0300 Subject: [PATCH 070/747] Changed: #1301 Polished code. --- .../landscape_editor/builder_zone_base.h | 2 +- .../landscape_editor/builder_zone_region.cpp | 70 +++++++------------ .../landscape_editor/builder_zone_region.h | 23 +++--- .../landscape_editor/landscape_actions.cpp | 35 ---------- .../landscape_editor/landscape_actions.h | 34 --------- .../landscape_editor_plugin.h | 7 +- .../landscape_editor_window.cpp | 2 +- .../landscape_editor_window.h | 2 +- .../landscape_editor/landscape_scene.cpp | 20 ------ .../landscape_editor/landscape_view.cpp | 10 --- .../plugins/landscape_editor/landscape_view.h | 2 +- .../landscape_editor/list_zones_widget.h | 2 +- .../landscape_editor/pixmap_database.cpp | 2 +- .../landscape_editor/pixmap_database.h | 2 +- .../landscape_editor/snapshot_dialog.h | 2 +- .../landscape_editor/zone_region_editor.cpp | 12 ---- .../plugins/world_editor/primitive_item.cpp | 14 ++-- .../src/plugins/world_editor/primitive_item.h | 5 +- .../plugins/world_editor/primitives_model.cpp | 4 ++ .../plugins/world_editor/primitives_model.h | 6 +- .../plugins/world_editor/primitives_view.cpp | 44 +++--------- .../plugins/world_editor/primitives_view.h | 2 +- .../world_editor/property_editor_widget.h | 2 +- .../world_editor/world_editor_actions.cpp | 26 ------- .../world_editor/world_editor_constants.h | 5 +- .../world_editor/world_editor_misc.cpp | 59 ++-------------- .../plugins/world_editor/world_editor_misc.h | 1 - .../world_editor/world_editor_plugin.h | 5 -- .../world_editor/world_editor_scene.cpp | 38 ++++------ .../plugins/world_editor/world_editor_scene.h | 5 +- .../world_editor/world_editor_settings_page.h | 2 +- .../world_editor/world_editor_window.cpp | 10 ++- .../world_editor/world_editor_window.h | 2 +- 33 files changed, 109 insertions(+), 348 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h index 8ea7f79a3..a8637d463 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_base.h @@ -75,7 +75,7 @@ PixmapDatabase contains the graphics for the zones class LANDSCAPE_EDITOR_EXPORT ZoneBuilderBase { public: - ZoneBuilderBase(LandscapeSceneBase *landscapeScene); + explicit ZoneBuilderBase(LandscapeSceneBase *landscapeScene); virtual ~ZoneBuilderBase(); /// Init zoneBank and init zone pixmap database diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp index 3f787e6b0..e84a81f57 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp @@ -230,34 +230,18 @@ void BuilderZoneRegion::add(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::C } // Delete all around all material that are not from the same as us - const std::string &curMat = zoneBankElement->getCategory ("material"); + const std::string &curMat = zoneBankElement->getCategory("material"); if (curMat != STRING_NO_CAT_TYPE) { // This element is a valid material // Place the piece - const std::string &eltName = zoneBankElement->getName (); - for (j = 0; j < sMask.h; ++j) - for (i = 0; i < sMask.w; ++i) - if (sMask.Tab[i + j * sMask.w]) - { - set(x + i, y + j, sPosX.Tab[i + j * sPosX.w], sPosY.Tab[i + j * sPosY.w], eltName); - setRot(x + i, y + j, rot); - setFlip(x + i, y + j, flip); - } + const std::string &eltName = zoneBankElement->getName(); + placePiece(x, y, rot, flip, sMask, sPosX, sPosY, eltName); // Put all transitions between different materials putTransitions (x, y, sMask, curMat, &tUpdate); - - // Place the piece - for (j = 0; j < sMask.h; ++j) - for (i = 0; i < sMask.w; ++i) - if (sMask.Tab[i + j * sMask.w]) - { - set(x + i, y + j, sPosX.Tab[i + j * sPosX.w], sPosY.Tab[i + j * sPosY.w], eltName); - setRot(x + i, y + j, rot); - setFlip(x + i, y + j, flip); - } + placePiece(x, y, rot, flip, sMask, sPosX, sPosY, eltName); } } @@ -449,21 +433,14 @@ bool BuilderZoneRegion::addNotPropagate (sint32 x, sint32 y, uint8 rot, uint8 fl del(x + i, y + j, true, &tUpdate); } - const std::string &curMat = zoneBankElement->getCategory ("material"); + const std::string &curMat = zoneBankElement->getCategory("material"); if (curMat != STRING_NO_CAT_TYPE) { // This element is a valid material // Place the piece - const std::string &EltName = zoneBankElement->getName (); - for (j = 0; j < sMask.h; ++j) - for (i = 0; i < sMask.w; ++i) - if (sMask.Tab[i + j * sMask.w]) - { - set (x + i, y + j, sPosX.Tab[i + j * sPosX.w], sPosY.Tab[i + j * sPosY.w], EltName); - setRot (x + i, y + j, rot); - setFlip (x + i, y + j, flip); - } + const std::string &eltName = zoneBankElement->getName(); + placePiece(x, y, rot, flip, sMask, sPosX, sPosY, eltName); } return true; @@ -803,11 +780,10 @@ void BuilderZoneRegion::addTransition (sint32 x, sint32 y, uint8 rot, uint8 flip } } -void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion *builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2) +void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion *builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, + const std::string &newMat, ToUpdate *ptCreate, ToUpdate *ptUpdate) { const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); - ToUpdate *ptCreate = reinterpret_cast(pInt1); - ToUpdate *ptUpdate = reinterpret_cast(pInt2); sint32 stride = (1 + zoneRegion.getMaxX() - zoneRegion.getMinX()); ZonePosition zonePos; @@ -828,11 +804,10 @@ void BuilderZoneRegion::addToUpdateAndCreate(BuilderZoneRegion *builderZoneRegio } void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SPiece &mask, const std::string &matName, - void *pInternal) + ToUpdate *ptUpdate) { const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); ToUpdate tCreate; // Transition to create - ToUpdate *ptUpdate = reinterpret_cast(pInternal); // Transition to update sint32 i, j, k, l, m; sint32 x = inX, y = inY; @@ -883,10 +858,8 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP if ( (corner < 4) && (m != 0) ) { // The material can't be paused - dataZoneTemp.sharingMatNames[0] = STRING_UNUSED; - dataZoneTemp.sharingMatNames[1] = STRING_UNUSED; - dataZoneTemp.sharingMatNames[2] = STRING_UNUSED; - dataZoneTemp.sharingMatNames[3] = STRING_UNUSED; + for (int t = 0; i < 4; ++t) + dataZoneTemp.sharingMatNames[t] = STRING_UNUSED; // Don't propagate any more } @@ -1659,16 +1632,13 @@ void BuilderZoneRegion::tryPath(uint32 posA, uint32 posB, std::vector &p } } -void BuilderZoneRegion::del(sint32 x, sint32 y, bool transition, void *pInternal) +void BuilderZoneRegion::del(sint32 x, sint32 y, bool transition, ToUpdate *pUpdate) { const NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->zoneRegion(m_regionId)->ligoZoneRegion(); if (!m_zoneBuilder->getZoneMask(x, y)) return; const std::string &nameZone = zoneRegion.getName(x, y); - - ToUpdate *pUpdate = reinterpret_cast(pInternal); - NLLIGO::CZoneBankElement *zoneBankElement = m_zoneBuilder->getZoneBank().getElementByZoneName(nameZone); if (zoneBankElement != NULL) { @@ -2108,4 +2078,18 @@ void BuilderZoneRegion::resize (sint32 newMinX, sint32 newMaxX, sint32 newMinY, } } +void BuilderZoneRegion::placePiece(sint32 x, sint32 y, uint8 rot, uint8 flip, + NLLIGO::SPiece &sMask, NLLIGO::SPiece &sPosX, NLLIGO::SPiece &sPosY, + const std::string &eltName) +{ + for (int j = 0; j < sMask.h; ++j) + for (int i = 0; i < sMask.w; ++i) + if (sMask.Tab[i + j * sMask.w]) + { + set(x + i, y + j, sPosX.Tab[i + j * sPosX.w], sPosY.Tab[i + j * sPosY.w], eltName); + setRot(x + i, y + j, rot); + setFlip(x + i, y + j, flip); + } +} + } /* namespace LandscapeEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h index 6de45da50..2170c67b9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.h @@ -33,13 +33,15 @@ namespace LandscapeEditor { class ZoneBuilder; +class ToUpdate; -// CZoneRegion contains informations about the zones painted +// CZoneRegion contains informations about the zones painted. +// (Legacy class from old world editor. It needs to refactoring!) class BuilderZoneRegion { public: - BuilderZoneRegion(uint regionId); + explicit BuilderZoneRegion(uint regionId); // New interface bool init(ZoneBuilder *zoneBuilder); @@ -51,7 +53,7 @@ public: /// Brutal adding a zone over empty space do not propagate in any way -> can result /// in inconsistency when trying the propagation mode void addForce (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement); - void del(sint32 x, sint32 y, bool transition = false, void *pInternal = NULL); + void del(sint32 x, sint32 y, bool transition = false, ToUpdate *pUpdate = 0); void move(sint32 x, sint32 y); uint32 countZones(); void reduceMin(); @@ -62,28 +64,33 @@ private: // An element of the graph struct SMatNode { - std::string Name; + std::string Name; // Position in the tree (vector of nodes) std::vector Arcs; }; void addTransition(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement); - void addToUpdateAndCreate(BuilderZoneRegion *builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, const std::string &newMat, void *pInt1, void *pInt2); + void addToUpdateAndCreate(BuilderZoneRegion *builderZoneRegion, sint32 sharePos, sint32 x, sint32 y, + const std::string &newMat, ToUpdate *ptCreate, ToUpdate *ptUpdate); - void putTransitions(sint32 x, sint32 y, const NLLIGO::SPiece &mask, const std::string &matName, void *pInternal); - void updateTrans(sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement = NULL); + void putTransitions(sint32 x, sint32 y, const NLLIGO::SPiece &mask, const std::string &matName, ToUpdate *ptUpdate); + void updateTrans(sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement = 0); std::string getNextMatInTree(const std::string &matA, const std::string &matB); /// Find the fastest way between posA and posB in the MatTree (Dijkstra) void tryPath(uint32 posA, uint32 posB, std::vector &path); - void set(sint32 x, sint32 y, sint32 posX, sint32 posY, const std::string &zoneName, bool transition=false); + void set(sint32 x, sint32 y, sint32 posX, sint32 posY, const std::string &zoneName, bool transition = false); void setRot(sint32 x, sint32 y, uint8 rot); void setFlip(sint32 x, sint32 y, uint8 flip); void resize(sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY); + void placePiece(sint32 x, sint32 y, uint8 rot, uint8 flip, + NLLIGO::SPiece &sMask, NLLIGO::SPiece &sPosX, NLLIGO::SPiece &sPosY, + const std::string &eltName); + uint m_regionId; // To use the global mask diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp index dc8b003c7..e5b3ad4d4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.cpp @@ -27,41 +27,6 @@ namespace LandscapeEditor { -OpenLandscapeCommand::OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent) - : QUndoCommand(parent), - m_fileName(fileName) -{ -} - -OpenLandscapeCommand::~OpenLandscapeCommand() -{ -} - -void OpenLandscapeCommand::undo() -{ -} - -void OpenLandscapeCommand::redo() -{ -} - -NewLandscapeCommand::NewLandscapeCommand(QUndoCommand *parent) - : QUndoCommand(parent) -{ -} - -NewLandscapeCommand::~NewLandscapeCommand() -{ -} - -void NewLandscapeCommand::undo() -{ -} - -void NewLandscapeCommand::redo() -{ -} - LigoTileCommand::LigoTileCommand(const LigoData &data, const ZonePosition &zonePos, ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h index 61abc4435..c976360fa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_actions.h @@ -32,40 +32,6 @@ namespace LandscapeEditor { -/** -@class OpenLandscapeCommand -@brief -@details -*/ -class OpenLandscapeCommand: public QUndoCommand -{ -public: - OpenLandscapeCommand(const QString &fileName, QUndoCommand *parent = 0); - virtual ~OpenLandscapeCommand(); - - virtual void undo(); - virtual void redo(); -private: - - QString m_fileName; -}; - -/** -@class NewLandscapeCommand -@brief -@details -*/ -class NewLandscapeCommand: public QUndoCommand -{ -public: - NewLandscapeCommand(QUndoCommand *parent = 0); - virtual ~NewLandscapeCommand(); - - virtual void undo(); - virtual void redo(); -private: -}; - /** @class LigoTileCommand @brief diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h index 145972e29..a01867894 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h @@ -34,11 +34,6 @@ namespace NLMISC class CLibraryContext; } -namespace ExtensionSystem -{ -class IPluginSpec; -} - namespace LandscapeEditor { class LandscapeEditorWindow; @@ -70,7 +65,7 @@ class LandscapeEditorContext: public Core::IContext { Q_OBJECT public: - LandscapeEditorContext(QObject *parent = 0); + explicit LandscapeEditorContext(QObject *parent = 0); virtual ~LandscapeEditorContext() {} virtual QString id() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp index 6b4377a37..22598c555 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.cpp @@ -262,7 +262,7 @@ int LandscapeEditorWindow::createLandscape(const QString &fileName) if (id == -1) { - QMessageBox::critical(this, "Landscape Editor", "Cannot add this zone because it overlaps existing ones"); + QMessageBox::critical(this, "Landscape Editor", tr("Cannot add this zone because it overlaps existing ones")); return -1; } ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h index 92745365b..6047a9e5e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_window.h @@ -37,7 +37,7 @@ class LandscapeEditorWindow: public QMainWindow Q_OBJECT public: - LandscapeEditorWindow(QWidget *parent = 0); + explicit LandscapeEditorWindow(QWidget *parent = 0); ~LandscapeEditorWindow(); QUndoStack *undoStack() const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp index bb2605b80..0018b4a53 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_scene.cpp @@ -397,26 +397,6 @@ void LandscapeScene::drawForeground(QPainter *painter, const QRectF &rect) QGraphicsScene::drawForeground(painter, rect); if ((m_zoneBuilder->currentIdZoneRegion() != -1) && (m_transitionMode)) drawTransition(painter, rect); - - /* - // Render debug text (slow!) - painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); - - int left = int(floor(rect.left() / m_cellSize)); - int right = int(floor(rect.right() / m_cellSize)); - int top = int(floor(rect.top() / m_cellSize)); - int bottom = int(floor(rect.bottom() / m_cellSize)); - - for (int i = left; i < right; ++i) - { - for (int j = top; j < bottom; ++j) - { - LigoData data; - m_zoneBuilder->currentZoneRegion()->ligoData(data, i, -j); - painter->drawText(i * m_cellSize + 10, j * m_cellSize + 10, QString("%1 %2 %3 %4").arg(i).arg(j).arg(data.posX).arg(data.posY)); - } - } - */ } void LandscapeScene::drawTransition(QPainter *painter, const QRectF &rect) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp index 10e1348df..87a459511 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.cpp @@ -185,23 +185,14 @@ void LandscapeView::setCenter(const QPointF ¢erPoint) //We need to clamp the center. The centerPoint is too large if (centerPoint.x() > bounds.x() + bounds.width()) - { m_currentCenterPoint.setX(bounds.x() + bounds.width()); - } else if(centerPoint.x() < bounds.x()) - { m_currentCenterPoint.setX(bounds.x()); - } if(centerPoint.y() > bounds.y() + bounds.height()) - { m_currentCenterPoint.setY(bounds.y() + bounds.height()); - } else if(centerPoint.y() < bounds.y()) - { m_currentCenterPoint.setY(bounds.y()); - } - } } @@ -230,7 +221,6 @@ void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect) if (transform().m11() > m_maxViewText) { painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine)); - //painter->setFont(QFont("Helvetica [Cronyx]", 12)); drawZoneNames(painter, rect); } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h index 462e6ecfb..158edfaa9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_view.h @@ -37,7 +37,7 @@ class LANDSCAPE_EDITOR_EXPORT LandscapeView: public QGraphicsView Q_OBJECT public: - LandscapeView(QWidget *parent = 0); + explicit LandscapeView(QWidget *parent = 0); virtual ~LandscapeView(); //Set the current centerpoint in the diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h index 091c33908..f33eda706 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_widget.h @@ -39,7 +39,7 @@ class ListZonesWidget: public QWidget Q_OBJECT public: - ListZonesWidget(QWidget *parent = 0); + explicit ListZonesWidget(QWidget *parent = 0); ~ListZonesWidget(); void updateUi(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp index 83e581ff3..0156f5a53 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp @@ -64,7 +64,7 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon zoneBank.getCategoryValues ("zone", listNames); if (displayProgress) { - progressDialog = new QProgressDialog("Loading ligo zones.", "Cancel", 0, listNames.size()); + progressDialog = new QProgressDialog(QObject::tr("Loading ligo zones."), QObject::tr("Cancel"), 0, listNames.size()); progressDialog->show(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h index 15b26e474..282872343 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.h @@ -39,7 +39,7 @@ namespace LandscapeEditor class LANDSCAPE_EDITOR_EXPORT PixmapDatabase { public: - PixmapDatabase(int textureSize = 256); + explicit PixmapDatabase(int textureSize = 256); ~PixmapDatabase(); /// Load all images(png) from zonePath, list images gets from zoneBank diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h index 34db0e4a2..07844ce31 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/snapshot_dialog.h @@ -30,7 +30,7 @@ class SnapshotDialog: public QDialog Q_OBJECT public: - SnapshotDialog(QWidget *parent = 0); + explicit SnapshotDialog(QWidget *parent = 0); ~SnapshotDialog(); bool isCustomSize() const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp index a9699acee..874c5d533 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/zone_region_editor.cpp @@ -118,12 +118,6 @@ void ZoneRegionObject::setFileName(const std::string &fileName) void ZoneRegionObject::ligoData(LigoData &data, const sint32 x, const sint32 y) { - /* - nlassert((x >= m_zoneRegion.getMinX()) && - (x <= m_zoneRegion.getMaxX()) && - (y >= m_zoneRegion.getMinY()) && - (y <= m_zoneRegion.getMaxY())); - */ data.posX = m_zoneRegion.getPosX(x, y); data.posY = m_zoneRegion.getPosY(x, y); data.zoneName = m_zoneRegion.getName(x, y); @@ -141,12 +135,6 @@ void ZoneRegionObject::ligoData(LigoData &data, const sint32 x, const sint32 y) void ZoneRegionObject::setLigoData(const LigoData &data, const sint32 x, const sint32 y) { - /* - nlassert((x >= m_zoneRegion.getMinX()) && - (x <= m_zoneRegion.getMaxX()) && - (y >= m_zoneRegion.getMinY()) && - (y <= m_zoneRegion.getMaxY())); - */ m_zoneRegion.setPosX(x, y, data.posX); m_zoneRegion.setPosY(x, y, data.posY); m_zoneRegion.setName(x, y, data.zoneName); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index 658231b2c..c0d799401 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -215,20 +215,18 @@ PrimitiveNode::PrimitiveNode(NLLIGO::IPrimitive *primitive) m_primitive->getPropertyByName("class", className); // Set Icon - QString nameIcon = QString("./old_ico/%1.ico").arg(className.c_str()); + QString nameIcon = QString("%1/%2.ico").arg(Constants::PATH_TO_OLD_ICONS).arg(className.c_str()); QIcon icon(nameIcon); if (!QFile::exists(nameIcon)) { if (primitive->getParent() == NULL) - icon = QIcon("./old_ico/root.ico"); + icon = QIcon(Constants::ICON_ROOT_PRIMITIVE); else if (primitive->getNumChildren() == 0) - icon = QIcon("./old_ico/property.ico"); + icon = QIcon(Constants::ICON_PROPERTY); else - icon = QIcon("./old_ico/folder_h.ico"); + icon = QIcon(Constants::ICON_FOLDER); } setData(Qt::DecorationRole, icon); - - //setData(3, QString(className.c_str())); } PrimitiveNode::~PrimitiveNode() @@ -242,7 +240,7 @@ NLLIGO::IPrimitive *PrimitiveNode::primitive() const const NLLIGO::CPrimitiveClass *PrimitiveNode::primitiveClass() const { - return NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*m_primitive); + return Utils::ligoConfig()->getPrimitiveClass(*m_primitive); } RootPrimitiveNode *PrimitiveNode::rootPrimitiveNode() @@ -250,7 +248,7 @@ RootPrimitiveNode *PrimitiveNode::rootPrimitiveNode() Node *node = this; while (node && (node->type() != Node::RootPrimitiveNodeType)) node = node->parent(); - return (RootPrimitiveNode *)node; + return static_cast(node); } Node::NodeType PrimitiveNode::type() const diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index f95eff0c0..7ebf4437f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -30,10 +30,7 @@ namespace WorldEditor { -class WorldEditNode; class RootPrimitiveNode; -class LandscapeNode; -class PrimitiveNode; /* @class Node @@ -150,7 +147,7 @@ private: class PrimitiveNode: public Node { public: - PrimitiveNode(NLLIGO::IPrimitive *primitive); + explicit PrimitiveNode(NLLIGO::IPrimitive *primitive); virtual ~PrimitiveNode(); NLLIGO::IPrimitive *primitive() const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp index 46436b699..78313624e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.cpp @@ -183,6 +183,10 @@ Node *PrimitivesTreeModel::pathToNode(const Path &path) void PrimitivesTreeModel::createWorldEditNode(const QString &fileName) { + // World edit node already is created, if yes is showing error message box + if (m_worldEditNode != 0) + nlerror("World edit node already is created."); + beginResetModel(); m_worldEditNode = new WorldEditNode(fileName); m_rootNode->appendChildNode(m_worldEditNode); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h index d1a883106..031317d0c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_model.h @@ -39,7 +39,8 @@ const int AtTheEnd = -1; typedef QPair PathItem; /* @typedef Path -@brief It store a list of row and column numbers which have to walk through from the root index of the model to reach the need item +@brief It store a list of row and column numbers which have to walk through from the root index of the model to reach the need item. +It is used for undo/redo commands. */ typedef QList Path; @@ -53,7 +54,7 @@ class PrimitivesTreeModel : public QAbstractItemModel Q_OBJECT public: - PrimitivesTreeModel(QObject *parent = 0); + explicit PrimitivesTreeModel(QObject *parent = 0); ~PrimitivesTreeModel(); QVariant data(const QModelIndex &index, int role) const; @@ -92,7 +93,6 @@ public: private: void createChildNodes(NLLIGO::IPrimitive *primitive, int pos, const QModelIndex &parent); - void removeChildNodes(Node *node, const QModelIndex &parent); Node *m_rootNode; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp index 6395720c5..e27e824b4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.cpp @@ -61,7 +61,7 @@ PrimitivesView::PrimitivesView(QWidget *parent) m_loadLandAction->setIcon(QIcon(LandscapeEditor::Constants::ICON_ZONE_ITEM)); m_loadPrimitiveAction = new QAction("Load primitive file", this); - m_loadPrimitiveAction->setIcon(QIcon("./old_ico/root.ico")); + m_loadPrimitiveAction->setIcon(QIcon(Constants::ICON_ROOT_PRIMITIVE)); m_newPrimitiveAction = new QAction("New primitive", this); @@ -132,7 +132,7 @@ void PrimitivesView::loadRootPrimitive() if (!fileNames.isEmpty()) { if (fileNames.count() > 1) - m_undoStack->beginMacro("Load primitive files"); + m_undoStack->beginMacro(tr("Load primitive files")); Q_FOREACH(QString fileName, fileNames) { @@ -160,7 +160,7 @@ void PrimitivesView::loadLandscape() if (!fileNames.isEmpty()) { if (fileNames.count() > 1) - m_undoStack->beginMacro("Load land files"); + m_undoStack->beginMacro(tr("Load land files")); Q_FOREACH(QString fileName, fileNames) { @@ -206,7 +206,7 @@ void PrimitivesView::save() if (node->data(Constants::PRIMITIVE_FILE_IS_CREATED).toBool()) { if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), node->fileName().toStdString())) - QMessageBox::warning(this, "World Editor Qt", QString("Error writing output file: %1").arg(node->fileName())); + QMessageBox::warning(this, "World Editor Qt", tr("Error writing output file: %1").arg(node->fileName())); else node->setData(Constants::PRIMITIVE_IS_MODIFIED, false); } @@ -231,7 +231,7 @@ void PrimitivesView::saveAs() RootPrimitiveNode *node = static_cast(index.internalPointer()); if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), fileName.toStdString())) - QMessageBox::warning(this, "World Editor Qt", QString("Error writing output file: %1").arg(fileName)); + QMessageBox::warning(this, "World Editor Qt", tr("Error writing output file: %1").arg(fileName)); else { node->setFileName(fileName); @@ -407,7 +407,7 @@ void PrimitivesView::fillMenu_Primitive(QMenu *menu, const QModelIndex &index) QSignalMapper *addSignalMapper = new QSignalMapper(menu); QSignalMapper *generateSignalMapper = new QSignalMapper(menu); - QSignalMapper *openSignalMapper = new QSignalMapper(menu); + //QSignalMapper *openSignalMapper = new QSignalMapper(menu); connect(addSignalMapper, SIGNAL(mapped(int)), this, SLOT(addNewPrimitiveByClass(int))); connect(generateSignalMapper, SIGNAL(mapped(int)), this, SLOT(generatePrimitives(int))); //connect(openSignalMapper, SIGNAL(mapped(int)), this, SLOT(openItem(int))); @@ -427,10 +427,10 @@ void PrimitivesView::fillMenu_Primitive(QMenu *menu, const QModelIndex &index) QString className = primClass->DynamicChildren[i].ClassName.c_str(); // Get icon - QIcon icon(QString("./old_ico/%1.ico").arg(className)); + QIcon icon(QString("%1/%2.ico").arg(Constants::PATH_TO_OLD_ICONS).arg(className)); // Create and add action in popur menu - QAction *action = menu->addAction(icon, QString("Add %1").arg(className)); + QAction *action = menu->addAction(icon, tr("Add %1").arg(className)); addSignalMapper->setMapping(action, i); connect(action, SIGNAL(triggered()), addSignalMapper, SLOT(map())); } @@ -448,35 +448,11 @@ void PrimitivesView::fillMenu_Primitive(QMenu *menu, const QModelIndex &index) QString childName = primClass->GeneratedChildren[i].ClassName.c_str(); // Create and add action in popur menu - QAction *action = menu->addAction(QString("Generate %1").arg(childName)); + QAction *action = menu->addAction(tr("Generate %1").arg(childName)); generateSignalMapper->setMapping(action, i); - connect(generateSignalMapper, SIGNAL(triggered()), addSignalMapper, SLOT(map())); + connect(action, SIGNAL(triggered()), generateSignalMapper, SLOT(map())); } } - /* - // What class is it ? - if (primClass) - { - // Look for files - std::vector filenames; - - // Filenames - buildFilenameVector (*Selection.front (), filenames); - - // File names ? - if (!filenames.empty ()) - { - // Add separator - popurMenu->addSeparator(); - - // Found ? - for (uint i = 0; i < filenames.size(); i++) - { - // Add a menu entry - pMenu->AppendMenu (MF_STRING, ID_EDIT_OPEN_FILE_BEGIN+i, ("Open "+NLMISC::CFile::getFilename (filenames[i])).c_str ()); - } - } - */ } } /* namespace WorldEditor */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h index 2b16bc714..8da877658 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitives_view.h @@ -53,7 +53,7 @@ class PrimitivesView : public QTreeView Q_OBJECT public: - PrimitivesView(QWidget *parent = 0); + explicit PrimitivesView(QWidget *parent = 0); ~PrimitivesView(); void setUndoStack(QUndoStack *undoStack); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h index 18f72fadc..3ee73a293 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h @@ -45,7 +45,7 @@ class PropertyEditorWidget: public QWidget Q_OBJECT public: - PropertyEditorWidget(QWidget *parent = 0); + explicit PropertyEditorWidget(QWidget *parent = 0); ~PropertyEditorWidget(); public Q_SLOTS: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 7e78cdaf5..0f9d91ef2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -103,13 +103,11 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode QPolygonF polygon; vec = primitive->getPrimVector(); int sizeVec = primitive->getNumVector(); - for (int i = 0; i < sizeVec; ++i) { polygon << QPointF(vec->x, -vec->y + cellSize); ++vec; } - item = scene->addWorldItemPath(polygon, showArrow); break; } @@ -118,7 +116,6 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode QPolygonF polygon; vec = primitive->getPrimVector(); int sizeVec = primitive->getNumVector(); - for (int i = 0; i < sizeVec; ++i) { polygon << QPointF(vec->x, cellSize - vec->y); @@ -133,30 +130,7 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode { // Get color from world_editor_classes.xml NLMISC::CRGBA color = Utils::ligoConfig()->getPrimitiveColor(*primitive); - - /* - // Configurations (from world_editor_primitive_configuration.xml) - const std::vector &configurations = Utils::ligoConfig()->getPrimitiveConfiguration(); - - // Look for the configuration - sint search = 0; - bool colorFound = false; - while ((search = theApp.getActiveConfiguration (*primitive, search)) != -1) - { - // Configuration activated ? - if (theApp.Configurations[search].Activated) - { - colorFound = true; - mainColor = configurations[search].Color; - break; - } - search++; - } - - // try to get the primitive color ? - //if (!colorFound)*/ primitive->getPropertyByName ("Color", color); - item->setColor(QColor(color.R, color.G, color.B)); QVariant variantNode; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index 0e27301d5..a75e2148b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -44,7 +44,10 @@ const char *const PRIMITIVE_CLASS_FILENAME = "WorldEditorPrimitiveClassFilename" //resources const char *const ICON_WORLD_EDITOR = ":/icons/ic_nel_world_editor.png"; - +const char *const ICON_ROOT_PRIMITIVE = "./old_ico/root.ico"; +const char *const ICON_PROPERTY = "./old_ico/property.ico"; +const char *const ICON_FOLDER = "./old_ico/folder_h.ico"; +const char *const PATH_TO_OLD_ICONS = "./old_ico"; } // namespace Constants } // namespace WorldEditor diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp index 5b5b9540d..6db59f9e5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp @@ -1,6 +1,5 @@ // 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 @@ -99,7 +98,6 @@ bool loadWorldEditFile(const std::string &fileName, WorldEditList &worldEditList // Good header ? if (strcmp((const char *)(rootNode->name), "NEL_WORLD_EDITOR_PROJECT") == 0) { - // Read the version int version = -1; // Read the parameters @@ -112,10 +110,7 @@ bool loadWorldEditFile(const std::string &fileName, WorldEditList &worldEditList } if (version == -1) - { - // Error syntaxError(fileName.c_str(), rootNode, "No version node"); - } else { // Old format, @@ -213,9 +208,7 @@ bool loadWorldEditFile(const std::string &fileName, WorldEditList &worldEditList } } else - { nlerror("Can't open the file %s for reading.", fileName.c_str()); - } return result; } @@ -255,12 +248,10 @@ void initPrimitiveParameters(const NLLIGO::CPrimitiveClass &primClass, NLLIGO::I if (cp < primClass.Parameters.size()) type = primClass.Parameters[cp].Type; - // Name ? if (initParameters[p].Name == "name") type = NLLIGO::CPrimitiveClass::CParameter::String; - // Continue ? - if (cpStringArray[i] = NLMISC::toString(getUniqueId()); - } else - { str->StringArray[i] = ""; - } } primitive.addPropertyByName(parameter.Name.c_str(), str); } @@ -347,7 +330,7 @@ NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName, NLLIGO::IPrimitive *parent) { // Get the prim class - const NLLIGO::CPrimitiveClass *primClass = NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(className); + const NLLIGO::CPrimitiveClass *primClass = ligoConfig()->getPrimitiveClass(className); if (primClass) { // Create the base primitive @@ -438,41 +421,18 @@ NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName, return NULL; } - // Prim file ? - if (primClass->Type == NLLIGO::CPrimitiveClass::Bitmap) - { - // Create a dialog file - //CFileDialogEx dialog (BASE_REGISTRY_KEY, "image", TRUE, primClass->FileExtension.c_str (), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, - // (primClass->FileType+" (*."+primClass->FileExtension+")|*."+primClass->FileExtension+"|All Files (*.*)|*.*||").c_str (), getMainFrame ()); - //if (dialog.DoModal() == IDOK) - //{ - // Save filename - // static_cast(primitive)->init(dialog.GetPathName ()); - //} - } - - // Continue ? if (primitive) { - // Auto init ? if (!primClass->AutoInit) { - // Make a vector of locator - //CDatabaseLocatorPointer locatorPtr; - //getLocator (locatorPtr, locator); - std::list locators; - //locators.push_back (const_cast (locatorPtr.Primitive)); - - // Yes, go - //CDialogProperties dialogProperty (locators, getMainFrame ()); - //dialogProperty.DoModal (); + // TODO } // Eval the default name property std::string name; if (!primitive->getPropertyByName ("name", name) || name.empty()) { - const NLLIGO::CPrimitiveClass *primClass = NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*primitive); + const NLLIGO::CPrimitiveClass *primClass = ligoConfig()->getPrimitiveClass(*primitive); if (primClass) { for (size_t i = 0; i < primClass->Parameters.size(); ++i) @@ -491,17 +451,13 @@ NLLIGO::IPrimitive *createPrimitive(const char *className, const char *primName, } } - // Init primitive default values - primitive->initDefaultValues(*NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); + primitive->initDefaultValues(*ligoConfig()); } - - // Done return primitive; } else - { nlerror("Unknown primitive class name : %s", className); - } + return 0; } @@ -521,11 +477,10 @@ void deletePrimitive(NLLIGO::IPrimitive *primitive) bool updateDefaultValues(NLLIGO::IPrimitive *primitive) { - // Modified bool modified = false; // Get the prim class - const NLLIGO::CPrimitiveClass *primClass = NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig->getPrimitiveClass(*primitive); + const NLLIGO::CPrimitiveClass *primClass = ligoConfig()->getPrimitiveClass(*primitive); nlassert(primClass); if (primClass) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h index 4163ae2e0..d29b2553b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.h @@ -1,6 +1,5 @@ // 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h index 4a107d11b..686b87e14 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.h @@ -36,11 +36,6 @@ namespace NLMISC class CLibraryContext; } -namespace ExtensionSystem -{ -class IPluginSpec; -} - namespace WorldEditor { class WorldEditorWindow; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 944372735..f2103031c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -45,17 +45,15 @@ WorldEditorScene::WorldEditorScene(int sizeCell, PrimitivesTreeModel *model, QUn // TODO: get params from settings setSceneRect(QRectF(-20 * 160, -20 * 160, 256 * 160, 256 * 160)); - m_pen1.setColor(QColor(50, 255, 155)); - m_pen1.setWidth(0); + m_greenPen.setColor(QColor(50, 255, 155)); + m_greenPen.setWidth(0); + m_greenBrush.setColor(QColor(50, 255, 155, 80)); + m_greenBrush.setStyle(Qt::SolidPattern); - m_brush1.setColor(QColor(50, 255, 155, 80)); - m_brush1.setStyle(Qt::SolidPattern); - - m_pen2.setColor(QColor(100, 0, 255)); - m_pen2.setWidth(0); - - m_brush2.setColor(QColor(100, 0, 255, 80)); - m_brush2.setStyle(Qt::SolidPattern); + m_purplePen.setColor(QColor(100, 0, 255)); + m_purplePen.setWidth(0); + m_purpleBrush.setColor(QColor(100, 0, 255, 80)); + m_purpleBrush.setStyle(Qt::SolidPattern); } WorldEditorScene::~WorldEditorScene() @@ -67,8 +65,6 @@ AbstractWorldItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, con { WorldItemPoint *item = new WorldItemPoint(point, angle, radius, showArrow); addItem(item); - - m_worldItems.push_back(item); return item; } @@ -76,8 +72,6 @@ AbstractWorldItem *WorldEditorScene::addWorldItemPath(const QPolygonF &polyline, { WorldItemPath *item = new WorldItemPath(polyline); addItem(item); - - m_worldItems.push_back(item); return item; } @@ -85,8 +79,6 @@ AbstractWorldItem *WorldEditorScene::addWorldItemZone(const QPolygonF &polygon) { WorldItemZone *item = new WorldItemZone(polygon); addItem(item); - - m_worldItems.push_back(item); return item; } @@ -96,10 +88,6 @@ void WorldEditorScene::removeWorldItem(QGraphicsItem *item) m_selectedItems.clear(); m_editedSelectedItems = false; m_firstSelection = false; - - // TODO - AbstractWorldItem *worldItem = qgraphicsitem_cast(item); - m_worldItems.removeOne(worldItem); delete item; } @@ -174,18 +162,18 @@ void WorldEditorScene::drawForeground(QPainter *painter, const QRectF &rect) if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) { + // Draw selection area if (m_selectionArea.left() < m_selectionArea.right()) { - painter->setPen(m_pen1); - painter->setBrush(m_brush1); + painter->setPen(m_greenPen); + painter->setBrush(m_greenBrush); } else { - painter->setPen(m_pen2); - painter->setBrush(m_brush2); + painter->setPen(m_purplePen); + painter->setBrush(m_purpleBrush); } painter->drawRect(m_selectionArea); - } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index e981a703e..833412410 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -110,15 +110,14 @@ private: void checkUndo(); - QPen m_pen1, m_pen2; - QBrush m_brush1, m_brush2; + QPen m_greenPen, m_purplePen; + QBrush m_greenBrush, m_purpleBrush; QPointF m_firstPick, m_scaleFactor, m_pivot; QRectF m_selectionArea; qreal m_firstPickX, m_firstPickY, m_angle; QList m_selectedItems; QList m_selectedPoints; - QList m_worldItems; QList m_polygons; bool m_editedSelectedItems, m_firstSelection; uint m_lastPickedPrimitive; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.h index 27cda963e..aa7677b9f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_settings_page.h @@ -36,7 +36,7 @@ class WorldEditorSettingsPage : public Core::IOptionsPage { Q_OBJECT public: - WorldEditorSettingsPage(QObject *parent = 0); + explicit WorldEditorSettingsPage(QObject *parent = 0); virtual ~WorldEditorSettingsPage() {} virtual QString id() const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index f1b8b17f1..40e69d1f2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -63,7 +63,6 @@ WorldEditorWindow::WorldEditorWindow(QWidget *parent) m_ui.graphicsView->setVisibleText(false); m_ui.treePrimitivesView->setModel(m_primitivesModel); - // TODO: ? m_ui.treePrimitivesView->setUndoStack(m_undoStack); m_ui.treePrimitivesView->setZoneBuilder(m_zoneBuilderBase); m_ui.treePrimitivesView->setWorldScene(m_worldEditorScene); @@ -131,7 +130,7 @@ QUndoStack *WorldEditorWindow::undoStack() const void WorldEditorWindow::maybeSave() { - QMessageBox *messageBox = new QMessageBox(tr("SDI"), + QMessageBox *messageBox = new QMessageBox(tr("World Editor"), tr("The data has been modified.\n" "Do you want to save your changes?"), QMessageBox::Warning, @@ -143,7 +142,7 @@ void WorldEditorWindow::maybeSave() messageBox->setButtonText(QMessageBox::Yes, tr("Save")); - messageBox->setButtonText(QMessageBox::No, tr("Dont Save")); + messageBox->setButtonText(QMessageBox::No, tr("Don't Save")); messageBox->show(); } @@ -175,7 +174,7 @@ void WorldEditorWindow::loadWorldEditFile(const QString &fileName) return; } - m_undoStack->beginMacro(QString("Load %1").arg(fileName)); + m_undoStack->beginMacro(tr("Load %1").arg(fileName)); checkCurrentWorld(); @@ -208,7 +207,6 @@ void WorldEditorWindow::checkCurrentWorld() void WorldEditorWindow::newWorldEditFile() { checkCurrentWorld(); - m_undoStack->push(new CreateWorldCommand("NewWorldEdit", m_primitivesModel)); } @@ -347,7 +345,7 @@ void WorldEditorWindow::hideEvent(QHideEvent *hideEvent) void WorldEditorWindow::createMenus() { - Core::MenuManager *menuManager = Core::ICore::instance()->menuManager(); + //Core::MenuManager *menuManager = Core::ICore::instance()->menuManager(); } void WorldEditorWindow::createToolBars() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h index d6e3dd593..f289e6c2a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.h @@ -42,7 +42,7 @@ class WorldEditorWindow: public QMainWindow Q_OBJECT public: - WorldEditorWindow(QWidget *parent = 0); + explicit WorldEditorWindow(QWidget *parent = 0); ~WorldEditorWindow(); QUndoStack *undoStack() const; From ce426214132005fb53a7a385eda9b618d3c86eb9 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 3 Oct 2011 03:35:05 +0300 Subject: [PATCH 071/747] Changed: #1301 Cleanup code. --- .../world_editor/world_editor_scene.cpp | 329 +++++------ .../plugins/world_editor/world_editor_scene.h | 12 +- .../world_editor/world_editor_scene_item.cpp | 535 ++++++------------ .../world_editor/world_editor_scene_item.h | 80 +-- 4 files changed, 364 insertions(+), 592 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index f2103031c..ba67ab9a8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -188,7 +188,7 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) if (mouseEvent->button() == Qt::LeftButton) { // Create new sub-points - // Call method mousePressEvent for point located under mouse + // Call method mousePressEvent for sub-point located under mouse LandscapeEditor::LandscapeSceneBase::mousePressEvent(mouseEvent); if ((!m_editedSelectedItems && m_selectedPoints.isEmpty()) || @@ -205,7 +205,7 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) m_selectedPoints.clear(); // Delete sub-points if it located under mouse - // Call method mousePressEvent for point located under mouse + // Call method mousePressEvent for sub-point located under mouse LandscapeEditor::LandscapeSceneBase::mousePressEvent(mouseEvent); } } @@ -232,119 +232,35 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) if (m_mode == WorldEditorScene::SelectMode) m_selectionArea.setTopLeft(mouseEvent->scenePos()); - -// if (m_selectedItems.isEmpty()) -// m_selectionArea.setTopLeft(mouseEvent->scenePos()); } void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { if (QApplication::mouseButtons() == Qt::LeftButton) { - QPointF offset(mouseEvent->scenePos() - mouseEvent->lastScenePos()); - m_selectionArea.setBottomRight(mouseEvent->scenePos()); - switch (m_mode) { case WorldEditorScene::SelectMode: break; case WorldEditorScene::MoveMode: - { - if (m_pointsMode) - { - Q_FOREACH(QGraphicsItem *item, m_selectedPoints) - { - item->moveBy(offset.x(), offset.y()); - } - } - else - { - Q_FOREACH(QGraphicsItem *item, m_selectedItems) - { - item->moveBy(offset.x(), offset.y()); - } - } + updateWorldItemsMove(mouseEvent); break; - } case WorldEditorScene::RotateMode: - { - // Caluculate angle between two line - QLineF firstLine(m_pivot, mouseEvent->lastScenePos()); - QLineF secondLine(m_pivot, mouseEvent->scenePos()); - qreal angle = secondLine.angleTo(firstLine); - - m_angle += angle; - - if (m_pointsMode) - { - Q_FOREACH(QGraphicsItem *item, m_selectedPoints) - { - qgraphicsitem_cast(item)->rotateOn(m_pivot, angle); - } - } - else - { - Q_FOREACH(QGraphicsItem *item, m_selectedItems) - { - qgraphicsitem_cast(item)->rotateOn(m_pivot, angle); - } - } + updateWorldItemsRotate(mouseEvent); break; - } case WorldEditorScene::ScaleMode: - { - // Calculate scale factor - if (offset.x() > 0) - offset.setX(1.0 + (offset.x() / 5000)); - else - offset.setX(1.0 / (1.0 + (-offset.x() / 5000))); - - if (offset.y() < 0) - offset.setY(1.0 + (-offset.y() / 5000)); - else - offset.setY(1.0 / (1.0 + (offset.y() / 5000))); - - m_scaleFactor.setX(offset.x() * m_scaleFactor.x()); - m_scaleFactor.setY(offset.y() * m_scaleFactor.y()); - - if (m_pointsMode) - { - Q_FOREACH(QGraphicsItem *item, m_selectedPoints) - { - qgraphicsitem_cast(item)->scaleOn(m_pivot, offset); - } - } - else - { - Q_FOREACH(QGraphicsItem *item, m_selectedItems) - { - qgraphicsitem_cast(item)->scaleOn(m_pivot, offset); - } - } + updateWorldItemsScale(mouseEvent); break; - } case WorldEditorScene::TurnMode: - { - // Caluculate angle between two line - QLineF firstLine(m_pivot, mouseEvent->lastScenePos()); - QLineF secondLine(m_pivot, mouseEvent->scenePos()); - qreal angle = secondLine.angleTo(firstLine); - - m_angle += angle; - - Q_FOREACH(QGraphicsItem *item, m_selectedItems) - { - qgraphicsitem_cast(item)->turnOn(angle); - } - + updateWorldItemsTurn(mouseEvent); break; - } case WorldEditorScene::RadiusMode: + updateWorldItemsRadius(mouseEvent); break; }; - if (m_pointsMode) + if (isEnabledEditPoints()) { if ((editMode() != WorldEditorScene::SelectMode) && (!m_selectedPoints.isEmpty())) m_editedSelectedItems = true; @@ -358,7 +274,7 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) else m_editedSelectedItems = false; } - + // Update render update(); } @@ -370,112 +286,63 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) if (mouseEvent->button() == Qt::MidButton) return; - if (m_pointsMode) + if (mouseEvent->button() == Qt::LeftButton) { - if (mouseEvent->button() == Qt::LeftButton) - { - if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) - { - QList listItems; - - // Clear selection - updateSelectedPointItems(false); - m_selectedPoints.clear(); - - if (m_selectionArea.left() < m_selectionArea.right()) - listItems = items(m_selectionArea, Qt::IntersectsItemShape, Qt::AscendingOrder); - else - listItems = items(m_selectionArea, Qt::ContainsItemShape, Qt::AscendingOrder); - - Q_FOREACH(QGraphicsItem *item, listItems) - { - if (qgraphicsitem_cast(item) == 0) - continue; - - m_selectedPoints.push_back(item); - } - updateSelectedPointItems(true); - m_selectionArea = QRectF(); - update(); - } - else - { - if ((!m_editedSelectedItems) && (!m_firstSelection)) - updatePickSelectionPoints(mouseEvent->scenePos()); - else - m_firstSelection = false; - } - } - checkUndo(); - } - else - { - if (mouseEvent->button() != Qt::LeftButton) - return; - - if (m_editedSelectedItems) - { - switch (m_mode) - { - case WorldEditorScene::SelectMode: - break; - - case WorldEditorScene::MoveMode: - { - QPointF offset = mouseEvent->scenePos() - m_firstPick; - m_undoStack->push(new MoveWorldItemsCommand(m_selectedItems, offset, this, m_model)); - break; - } - case WorldEditorScene::RotateMode: - m_undoStack->push(new RotateWorldItemsCommand(m_selectedItems, m_angle, m_pivot, this, m_model)); - break; - case WorldEditorScene::ScaleMode: - m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, m_pivot, this, m_model)); - break; - case WorldEditorScene::TurnMode: - m_undoStack->push(new TurnWorldItemsCommand(m_selectedItems, m_angle, this, m_model)); - break; - case WorldEditorScene::RadiusMode: - break; - }; - } - + // Update selection if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) { QList listItems; // Clear selection - updateSelectedWorldItems(false); - m_selectedItems.clear(); + updateSelectedPointItems(false); + m_selectedPoints.clear(); + // Return list of selected items if (m_selectionArea.left() < m_selectionArea.right()) listItems = items(m_selectionArea, Qt::IntersectsItemShape, Qt::AscendingOrder); else listItems = items(m_selectionArea, Qt::ContainsItemShape, Qt::AscendingOrder); - Q_FOREACH(QGraphicsItem *item, listItems) + if (isEnabledEditPoints()) { - if (qgraphicsitem_cast(item) == 0) - continue; - - m_selectedItems.push_back(item); + Q_FOREACH(QGraphicsItem *item, listItems) + { + if (qgraphicsitem_cast(item) == 0) + continue; + m_selectedPoints.push_back(item); + } + updateSelectedPointItems(true); + } + else + { + Q_FOREACH(QGraphicsItem *item, listItems) + { + if (qgraphicsitem_cast(item) == 0) + continue; + m_selectedItems.push_back(item); + } + Q_EMIT updateSelectedItems(m_selectedItems); + updateSelectedWorldItems(true); } - - Q_EMIT updateSelectedItems(m_selectedItems); - - updateSelectedWorldItems(true); m_selectionArea = QRectF(); update(); } else { if ((!m_editedSelectedItems) && (!m_firstSelection)) - updatePickSelection(mouseEvent->scenePos()); + { + if (isEnabledEditPoints()) + updatePickSelectionPoints(mouseEvent->scenePos()); + else + updatePickSelection(mouseEvent->scenePos()); + } else m_firstSelection = false; } - } + if (isEnabledEditPoints()) + checkUndoPointsMode(); + } m_selectionArea = QRectF(); LandscapeEditor::LandscapeSceneBase::mouseReleaseEvent(mouseEvent); } @@ -596,6 +463,32 @@ void WorldEditorScene::updatePickSelectionPoints(const QPointF &point) } void WorldEditorScene::checkUndo() +{ + if (m_editedSelectedItems) + { + switch (m_mode) + { + case WorldEditorScene::SelectMode: + break; + case WorldEditorScene::MoveMode: + m_undoStack->push(new MoveWorldItemsCommand(m_selectedItems, m_offset, this, m_model)); + break; + case WorldEditorScene::RotateMode: + m_undoStack->push(new RotateWorldItemsCommand(m_selectedItems, m_angle, m_pivot, this, m_model)); + break; + case WorldEditorScene::ScaleMode: + m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, m_pivot, this, m_model)); + break; + case WorldEditorScene::TurnMode: + m_undoStack->push(new TurnWorldItemsCommand(m_selectedItems, m_angle, this, m_model)); + break; + case WorldEditorScene::RadiusMode: + break; + }; + } +} + +void WorldEditorScene::checkUndoPointsMode() { if (m_pointsMode) { @@ -611,7 +504,6 @@ void WorldEditorScene::checkUndo() worldItem->setShapeChanged(false); } } - if (!items.isEmpty()) { m_undoStack->push(new ShapeWorldItemsCommand(items, polygons, this, m_model)); @@ -620,4 +512,89 @@ void WorldEditorScene::checkUndo() } } +void WorldEditorScene::updateWorldItemsMove(QGraphicsSceneMouseEvent *mouseEvent) +{ + QPointF offset(mouseEvent->scenePos() - mouseEvent->lastScenePos()); + if (m_pointsMode) + Q_FOREACH(QGraphicsItem *item, m_selectedPoints) + { + item->moveBy(offset.x(), offset.y()); + } + else + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + item->moveBy(offset.x(), offset.y()); + } +} + +void WorldEditorScene::updateWorldItemsScale(QGraphicsSceneMouseEvent *mouseEvent) +{ + QPointF offset(mouseEvent->scenePos() - mouseEvent->lastScenePos()); + + qreal scaleRatio = 5000; + + // Calculate scale factor + if (offset.x() > 0) + offset.setX(1.0 + (offset.x() / scaleRatio)); + else + offset.setX(1.0 / (1.0 + (-offset.x() / scaleRatio))); + + if (offset.y() < 0) + offset.setY(1.0 - (offset.y() / scaleRatio)); + else + offset.setY(1.0 / (1.0 + (offset.y() / scaleRatio))); + + m_scaleFactor.setX(offset.x() * m_scaleFactor.x()); + m_scaleFactor.setY(offset.y() * m_scaleFactor.y()); + + if (m_pointsMode) + Q_FOREACH(QGraphicsItem *item, m_selectedPoints) + { + qgraphicsitem_cast(item)->scaleOn(m_pivot, offset); + } + else + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->scaleOn(m_pivot, offset); + } +} + +void WorldEditorScene::updateWorldItemsRotate(QGraphicsSceneMouseEvent *mouseEvent) +{ + // Caluculate angle between two line + QLineF firstLine(m_pivot, mouseEvent->lastScenePos()); + QLineF secondLine(m_pivot, mouseEvent->scenePos()); + qreal angle = secondLine.angleTo(firstLine); + m_angle += angle; + + if (m_pointsMode) + Q_FOREACH(QGraphicsItem *item, m_selectedPoints) + { + qgraphicsitem_cast(item)->rotateOn(m_pivot, angle); + } + else + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->rotateOn(m_pivot, angle); + } +} + +void WorldEditorScene::updateWorldItemsTurn(QGraphicsSceneMouseEvent *mouseEvent) +{ + // Caluculate angle between two line + QLineF firstLine(m_pivot, mouseEvent->lastScenePos()); + QLineF secondLine(m_pivot, mouseEvent->scenePos()); + qreal angle = secondLine.angleTo(firstLine); + m_angle += angle; + + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->turnOn(angle); + } +} + +void WorldEditorScene::updateWorldItemsRadius(QGraphicsSceneMouseEvent *mouseEvent) +{ +} + } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index 833412410..7174c69c8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -105,20 +105,30 @@ private: void updateSelectedWorldItem(QGraphicsItem *item, bool value); void updateSelectedPointItems(bool value); void updateSelectedPointItem(QGraphicsItem *item, bool value); + void updatePickSelection(const QPointF &point); void updatePickSelectionPoints(const QPointF &point); void checkUndo(); + void checkUndoPointsMode(); + + void updateWorldItemsMove(QGraphicsSceneMouseEvent *mouseEvent); + void updateWorldItemsScale(QGraphicsSceneMouseEvent *mouseEvent); + void updateWorldItemsRotate(QGraphicsSceneMouseEvent *mouseEvent); + void updateWorldItemsTurn(QGraphicsSceneMouseEvent *mouseEvent); + void updateWorldItemsRadius(QGraphicsSceneMouseEvent *mouseEvent); QPen m_greenPen, m_purplePen; QBrush m_greenBrush, m_purpleBrush; - QPointF m_firstPick, m_scaleFactor, m_pivot; + QPointF m_firstPick, m_scaleFactor, m_pivot, m_offset; QRectF m_selectionArea; qreal m_firstPickX, m_firstPickY, m_angle; + QList m_selectedItems; QList m_selectedPoints; QList m_polygons; + bool m_editedSelectedItems, m_firstSelection; uint m_lastPickedPrimitive; ModeEdit m_mode; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index b4d01be65..1375c40ab 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -180,6 +180,8 @@ void WorldItemPoint::radiusOn(const qreal radius) { if (m_radius == 0) return; + + // TODO: implement } void WorldItemPoint::setColor(const QColor &color) @@ -240,9 +242,6 @@ QRectF WorldItemPoint::boundingRect() const void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) { - // Here comes the magic: - //painter->setClipRect(option->exposedRect); - painter->setPen(m_pen); // Draw circle @@ -256,353 +255,59 @@ void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *op painter->drawLines(m_arrow); painter->setPen(Qt::NoPen); -// if (option->state & QStyle::State_Selected) if (isActived()) - { painter->setBrush(m_selectedBrush); - } else - { painter->setBrush(m_brush); - } // Draw point painter->drawRect(m_rect); } -WorldItemPath::WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent) +BaseWorldItemPolyline::BaseWorldItemPolyline(const QPolygonF &polygon, QGraphicsItem *parent) : AbstractWorldItem(parent), - m_polygon(polygon), + m_polyline(polygon), m_pointEdit(false) { //setFlag(ItemIsSelectable); - - setZValue(WORLD_PATH_LAYER); - - m_pen.setColor(Qt::black); - m_pen.setWidth(3); - m_pen.setJoinStyle(Qt::MiterJoin); - - m_selectedPen.setColor(Qt::white); - m_selectedPen.setWidth(3); - m_selectedPen.setJoinStyle(Qt::MiterJoin); - - QPointF center = m_polygon.boundingRect().center(); - m_polygon.translate(-center); + QPointF center = m_polyline.boundingRect().center(); + m_polyline.translate(-center); setPos(center); } -WorldItemPath::~WorldItemPath() +BaseWorldItemPolyline::~BaseWorldItemPolyline() { } -void WorldItemPath::rotateOn(const QPointF &pivot, const qreal deltaAngle) +void BaseWorldItemPolyline::rotateOn(const QPointF &pivot, const qreal deltaAngle) { prepareGeometryChange(); - QPolygonF rotatedPolygon(m_polygon); + QPolygonF rotatedPolygon(m_polyline); rotatedPolygon.translate(pos() - pivot); QTransform trans; trans = trans.rotate(deltaAngle); - m_polygon = trans.map(rotatedPolygon); + m_polyline = trans.map(rotatedPolygon); - m_polygon.translate(pivot - pos()); + m_polyline.translate(pivot - pos()); } -void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &factor) +void BaseWorldItemPolyline::scaleOn(const QPointF &pivot, const QPointF &factor) { prepareGeometryChange(); - QPolygonF scaledPolygon(m_polygon); + QPolygonF scaledPolygon(m_polyline); scaledPolygon.translate(pos() - pivot); QTransform trans; trans = trans.scale(factor.x(), factor.y()); - m_polygon = trans.map(scaledPolygon); + m_polyline = trans.map(scaledPolygon); - m_polygon.translate(pivot - pos()); + m_polyline.translate(pivot - pos()); } -void WorldItemPath::setColor(const QColor &color) -{ - m_pen.setColor(color); -} - - -void WorldItemPath::setEnabledSubPoints(bool enabled) -{ - m_pointEdit = enabled; - if (m_pointEdit) - createSubPoints(); - else - removeSubPoints(); -} - -void WorldItemPath::moveSubPoint(WorldItemSubPoint *subPoint) -{ - prepareGeometryChange(); - - QPolygonF polygon; - - // Update polygon - Q_FOREACH(WorldItemSubPoint *node, m_listItems) - { - polygon << node->pos(); - } - - // Update middle points - for (int i = 0; i < m_listLines.size(); ++i) - m_listLines.at(i).itemPoint->setPos((m_listLines.at(i).lineItem.first->pos() + m_listLines.at(i).lineItem.second->pos()) / 2); - - m_polygon = polygon; - setShapeChanged(true); - update(); -} - -void WorldItemPath::addSubPoint(WorldItemSubPoint *subPoint) -{ - prepareGeometryChange(); - - for (int i = 0; i < m_listLines.size(); ++i) - { - if (subPoint == m_listLines.at(i).itemPoint) - { - LineStruct oldLineItem = m_listLines[i]; - - // Create the first middle sub-point - WorldItemSubPoint *firstItem = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); - firstItem->setPos((oldLineItem.lineItem.first->pos() + subPoint->pos()) / 2); - - // Create the second middle sub-point - WorldItemSubPoint *secondItem = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); - secondItem->setPos((oldLineItem.lineItem.second->pos() + subPoint->pos()) / 2); - - // Add first line in the list - LineStruct firstNewLineItem; - firstNewLineItem.itemPoint = firstItem; - firstNewLineItem.lineItem = LineItem(oldLineItem.lineItem.first, subPoint); - m_listLines.push_back(firstNewLineItem); - - // Add second line in the list - LineStruct secondNewLineItem; - secondNewLineItem.itemPoint = secondItem; - secondNewLineItem.lineItem = LineItem(subPoint, oldLineItem.lineItem.second); - m_listLines.push_back(secondNewLineItem); - - m_listLines.removeAt(i); - - int pos = m_listItems.indexOf(oldLineItem.lineItem.second); - m_listItems.insert(pos, subPoint); - subPoint->setFlag(ItemSendsScenePositionChanges); - - break; - } - } - setShapeChanged(true); -} - -bool WorldItemPath::removeSubPoint(WorldItemSubPoint *subPoint) -{ - int pos = m_listItems.indexOf(subPoint); - - // First and second points can not be removed - if ((pos == 0) || (pos == m_listItems.size() - 1)) - return false; - - prepareGeometryChange(); - - m_listItems.takeAt(pos); - - LineStruct newLineItem; - - newLineItem.itemPoint = subPoint; - - // Delete first line - for (int i = 0; i < m_listLines.size(); ++i) - { - if (subPoint == m_listLines.at(i).lineItem.first) - { - // Saving second point for new line - newLineItem.lineItem.second = m_listLines.at(i).lineItem.second; - delete m_listLines.at(i).itemPoint; - m_listLines.removeAt(i); - break; - } - } - - // Delete second line - for (int i = 0; i < m_listLines.size(); ++i) - { - if (subPoint == m_listLines.at(i).lineItem.second) - { - // Saving first point for new line - newLineItem.lineItem.first = m_listLines.at(i).lineItem.first; - delete m_listLines.at(i).itemPoint; - m_listLines.removeAt(i); - break; - } - } - subPoint->setPos((newLineItem.lineItem.first->pos() + newLineItem.lineItem.second->pos()) / 2); - m_listLines.push_back(newLineItem); - subPoint->setFlag(ItemSendsScenePositionChanges, false); - setShapeChanged(true); - - return true; -} - -void WorldItemPath::setPolygon(const QPolygonF &polygon) -{ - prepareGeometryChange(); - - m_polygon = polygon; - - update(); -} - -QPolygonF WorldItemPath::polygon() const -{ - return m_polygon; -} - -QPainterPath WorldItemPath::shape() const -{ - QPainterPath path; - - path.moveTo(m_polygon.first()); - for (int i = 1; i < m_polygon.count(); ++i) - path.lineTo(m_polygon.at(i)); - - return qt_graphicsItem_shapeFromPath(path, m_pen); -} - -QRectF WorldItemPath::boundingRect() const -{ - return m_polygon.boundingRect(); -} - -void WorldItemPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) -{ - // Here comes the magic: - //painter->setClipRect(option->exposedRect); - - //if (option->state & QStyle::State_Selected) - if (isActived()) - painter->setPen(m_selectedPen); - else - painter->setPen(m_pen); - - painter->drawPolyline(m_polygon); -} - -void WorldItemPath::createSubPoints() -{ - WorldItemSubPoint *firstPoint; - firstPoint = new WorldItemSubPoint(WorldItemSubPoint::EdgeType, this); - firstPoint->setPos(m_polygon.front()); - firstPoint->setFlag(ItemSendsScenePositionChanges); - m_listItems.push_back(firstPoint); - - for (int i = 1; i < m_polygon.count(); ++i) - { - WorldItemSubPoint *secondPoint = new WorldItemSubPoint(WorldItemSubPoint::EdgeType, this); - secondPoint->setPos(m_polygon.at(i)); - secondPoint->setFlag(ItemSendsScenePositionChanges); - - WorldItemSubPoint *middlePoint = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); - middlePoint->setPos((firstPoint->pos() + secondPoint->pos()) / 2); - - LineStruct newLineItem; - newLineItem.itemPoint = middlePoint; - newLineItem.lineItem = LineItem(firstPoint, secondPoint); - m_listLines.push_back(newLineItem); - - firstPoint = secondPoint; - m_listItems.push_back(firstPoint); - } -} - -void WorldItemPath::removeSubPoints() -{ - for (int i = 0; i < m_listLines.count(); ++i) - delete m_listLines.at(i).itemPoint; - - for (int i = 0; i < m_listItems.count(); ++i) - delete m_listItems.at(i); - - m_listItems.clear(); - m_listLines.clear(); -} - -WorldItemZone::WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent) - : AbstractWorldItem(parent), - m_polygon(polygon), - m_pointEdit(false) -{ - //setFlag(ItemIsSelectable); - - setZValue(WORLD_ZONE_LAYER); - - m_pen.setColor(QColor(20, 100, 255)); - m_pen.setWidth(0); - - m_selectedPen.setColor(Qt::white); - m_selectedPen.setWidth(0); - - m_brush.setColor(QColor(20, 100, 255, TRANSPARENCY)); - m_brush.setStyle(Qt::SolidPattern); - - m_selectedBrush.setColor(QColor(255, 255, 255, 100)); - m_selectedBrush.setStyle(Qt::SolidPattern); - - QPointF center = m_polygon.boundingRect().center(); - m_polygon.translate(-center); - setPos(center); -} - -WorldItemZone::~WorldItemZone() -{ -} - -void WorldItemZone::rotateOn(const QPointF &pivot, const qreal deltaAngle) -{ - prepareGeometryChange(); - - QPolygonF rotatedPolygon(m_polygon); - rotatedPolygon.translate(pos() - pivot); - - QTransform trans; - trans = trans.rotate(deltaAngle); - m_polygon = trans.map(rotatedPolygon); - - m_polygon.translate(pivot - pos()); -} - -void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &factor) -{ - prepareGeometryChange(); - - QPolygonF scaledPolygon(m_polygon); - scaledPolygon.translate(pos() - pivot); - - QTransform trans; - trans = trans.scale(factor.x(), factor.y()); - m_polygon = trans.map(scaledPolygon); - - m_polygon.translate(pivot - pos()); -} - -void WorldItemZone::setColor(const QColor &color) -{ - m_pen.setColor(color); - - QColor brushColor(color); - brushColor.setAlpha(TRANSPARENCY); - - m_brush.setColor(brushColor); -} - -void WorldItemZone::setEnabledSubPoints(bool enabled) +void BaseWorldItemPolyline::setEnabledSubPoints(bool enabled) { m_pointEdit = enabled; if (m_pointEdit) @@ -613,7 +318,7 @@ void WorldItemZone::setEnabledSubPoints(bool enabled) setShapeChanged(false); } -void WorldItemZone::moveSubPoint(WorldItemSubPoint *subPoint) +void BaseWorldItemPolyline::moveSubPoint(WorldItemSubPoint *subPoint) { prepareGeometryChange(); @@ -629,13 +334,12 @@ void WorldItemZone::moveSubPoint(WorldItemSubPoint *subPoint) for (int i = 0; i < m_listLines.size(); ++i) m_listLines.at(i).itemPoint->setPos((m_listLines.at(i).lineItem.first->pos() + m_listLines.at(i).lineItem.second->pos()) / 2); - m_polygon = polygon; - update(); - + m_polyline = polygon; setShapeChanged(true); + update(); } -void WorldItemZone::addSubPoint(WorldItemSubPoint *subPoint) +void BaseWorldItemPolyline::addSubPoint(WorldItemSubPoint *subPoint) { prepareGeometryChange(); @@ -677,18 +381,13 @@ void WorldItemZone::addSubPoint(WorldItemSubPoint *subPoint) setShapeChanged(true); } -bool WorldItemZone::removeSubPoint(WorldItemSubPoint *subPoint) +bool BaseWorldItemPolyline::removeSubPoint(WorldItemSubPoint *subPoint) { prepareGeometryChange(); - if (m_listItems.size() < 4) - return false; - int pos = m_listItems.indexOf(subPoint); m_listItems.takeAt(pos); - LineStruct newLineItem; - newLineItem.itemPoint = subPoint; // Delete first line @@ -716,70 +415,42 @@ bool WorldItemZone::removeSubPoint(WorldItemSubPoint *subPoint) break; } } - m_listLines.push_back(newLineItem); subPoint->setPos((newLineItem.lineItem.first->pos() + newLineItem.lineItem.second->pos()) / 2); + m_listLines.push_back(newLineItem); subPoint->setFlag(ItemSendsScenePositionChanges, false); - setShapeChanged(true); - return true; } -void WorldItemZone::setPolygon(const QPolygonF &polygon) +void BaseWorldItemPolyline::setPolygon(const QPolygonF &polygon) { prepareGeometryChange(); - - m_polygon = polygon; - + m_polyline = polygon; update(); } -QPolygonF WorldItemZone::polygon() const +QPolygonF BaseWorldItemPolyline::polygon() const { - return m_polygon; + return m_polyline; } -QRectF WorldItemZone::boundingRect() const +QRectF BaseWorldItemPolyline::boundingRect() const { - return m_polygon.boundingRect(); + return m_polyline.boundingRect(); } -QPainterPath WorldItemZone::shape() const -{ - QPainterPath path; - path.addPolygon(m_polygon); - return qt_graphicsItem_shapeFromPath(path, m_pen); -} - -void WorldItemZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) -{ -// if (option->state & QStyle::State_Selected) - if (isActived()) - { - painter->setPen(m_selectedPen); - painter->setBrush(m_selectedBrush); - } - else - { - painter->setPen(m_pen); - painter->setBrush(m_brush); - } - - painter->drawPolygon(m_polygon); -} - -void WorldItemZone::createSubPoints() +void BaseWorldItemPolyline::createSubPoints() { WorldItemSubPoint *firstPoint; firstPoint = new WorldItemSubPoint(WorldItemSubPoint::EdgeType, this); - firstPoint->setPos(m_polygon.front()); + firstPoint->setPos(m_polyline.front()); firstPoint->setFlag(ItemSendsScenePositionChanges); m_listItems.push_back(firstPoint); - for (int i = 1; i < m_polygon.count(); ++i) + for (int i = 1; i < m_polyline.count(); ++i) { WorldItemSubPoint *secondPoint = new WorldItemSubPoint(WorldItemSubPoint::EdgeType, this); - secondPoint->setPos(m_polygon.at(i)); + secondPoint->setPos(m_polyline.at(i)); secondPoint->setFlag(ItemSendsScenePositionChanges); WorldItemSubPoint *middlePoint = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); @@ -793,15 +464,9 @@ void WorldItemZone::createSubPoints() firstPoint = secondPoint; m_listItems.push_back(firstPoint); } - - LineStruct endLineItem; - endLineItem.itemPoint = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); - endLineItem.itemPoint->setPos((m_listItems.first()->pos() + m_listItems.last()->pos()) / 2); - endLineItem.lineItem = LineItem(m_listItems.last(), m_listItems.first()); - m_listLines.push_back(endLineItem); } -void WorldItemZone::removeSubPoints() +void BaseWorldItemPolyline::removeSubPoints() { for (int i = 0; i < m_listLines.count(); ++i) delete m_listLines.at(i).itemPoint; @@ -813,6 +478,131 @@ void WorldItemZone::removeSubPoints() m_listLines.clear(); } +WorldItemPath::WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent) + : BaseWorldItemPolyline(polygon, parent) +{ + setZValue(WORLD_PATH_LAYER); + + m_pen.setColor(Qt::black); + m_pen.setWidth(3); + m_pen.setJoinStyle(Qt::MiterJoin); + + m_selectedPen.setColor(Qt::white); + m_selectedPen.setWidth(3); + m_selectedPen.setJoinStyle(Qt::MiterJoin); +} + +WorldItemPath::~WorldItemPath() +{ +} + +void WorldItemPath::setColor(const QColor &color) +{ + m_pen.setColor(color); +} + +bool WorldItemPath::removeSubPoint(WorldItemSubPoint *subPoint) +{ + int pos = m_listItems.indexOf(subPoint); + + // First and second points can not be removed + if ((pos == 0) || (pos == m_listItems.size() - 1)) + return false; + + return BaseWorldItemPolyline::removeSubPoint(subPoint); +} + +QPainterPath WorldItemPath::shape() const +{ + QPainterPath path; + + path.moveTo(m_polyline.first()); + for (int i = 1; i < m_polyline.count(); ++i) + path.lineTo(m_polyline.at(i)); + + return qt_graphicsItem_shapeFromPath(path, m_pen); +} + +void WorldItemPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) +{ + if (isActived()) + painter->setPen(m_selectedPen); + else + painter->setPen(m_pen); + + painter->drawPolyline(m_polyline); +} + + +WorldItemZone::WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent) + : BaseWorldItemPolyline(polygon, parent) +{ + setZValue(WORLD_ZONE_LAYER); + + m_pen.setColor(QColor(20, 100, 255)); + m_pen.setWidth(0); + m_selectedPen.setColor(Qt::white); + m_selectedPen.setWidth(0); + m_brush.setColor(QColor(20, 100, 255, TRANSPARENCY)); + m_brush.setStyle(Qt::SolidPattern); + m_selectedBrush.setColor(QColor(255, 255, 255, 100)); + m_selectedBrush.setStyle(Qt::SolidPattern); +} + +WorldItemZone::~WorldItemZone() +{ +} + +void WorldItemZone::setColor(const QColor &color) +{ + m_pen.setColor(color); + QColor brushColor(color); + brushColor.setAlpha(TRANSPARENCY); + m_brush.setColor(brushColor); +} + +bool WorldItemZone::removeSubPoint(WorldItemSubPoint *subPoint) +{ + if (m_listItems.size() < 4) + return false; + + return BaseWorldItemPolyline::removeSubPoint(subPoint); +} + +QPainterPath WorldItemZone::shape() const +{ + QPainterPath path; + path.addPolygon(m_polyline); + return qt_graphicsItem_shapeFromPath(path, m_pen); +} + +void WorldItemZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) +{ + if (isActived()) + { + painter->setPen(m_selectedPen); + painter->setBrush(m_selectedBrush); + } + else + { + painter->setPen(m_pen); + painter->setBrush(m_brush); + } + + painter->drawPolygon(m_polyline); +} + +void WorldItemZone::createSubPoints() +{ + BaseWorldItemPolyline::createSubPoints(); + + LineStruct endLineItem; + endLineItem.itemPoint = new WorldItemSubPoint(WorldItemSubPoint::MiddleType, this); + endLineItem.itemPoint->setPos((m_listItems.first()->pos() + m_listItems.last()->pos()) / 2); + endLineItem.lineItem = LineItem(m_listItems.last(), m_listItems.first()); + m_listLines.push_back(endLineItem); +} + //******************************************* WorldItemSubPoint::WorldItemSubPoint(SubPointType pointType, AbstractWorldItem *parent) @@ -859,8 +649,6 @@ void WorldItemSubPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle) prepareGeometryChange(); QPolygonF rotatedPolygon(m_rect); - - // TODO rotatedPolygon.translate(scenePos() - pivot); QTransform trans; @@ -876,8 +664,6 @@ void WorldItemSubPoint::scaleOn(const QPointF &pivot, const QPointF &factor) prepareGeometryChange(); QPolygonF scaledPolygon(m_rect); - - // TODO scaledPolygon.translate(scenePos() - pivot); QTransform trans; @@ -896,7 +682,6 @@ QRectF WorldItemSubPoint::boundingRect() const void WorldItemSubPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->setPen(Qt::NoPen); - if (m_type == WorldItemSubPoint::EdgeType) { if (isActived()) @@ -905,9 +690,7 @@ void WorldItemSubPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem painter->setBrush(m_brush); } else - { painter->setBrush(m_brushMiddle); - } // Draw point painter->drawRect(m_rect); @@ -955,4 +738,4 @@ void WorldItemSubPoint::updateBoundingRect() m_boundingRect.setCoords(-SIZE_POINT, -SIZE_POINT, SIZE_POINT, SIZE_POINT); } -} /* namespace WorldEditor */ +} /* namespace WorldEditor */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index 9136712c5..b5584c427 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -66,21 +66,21 @@ public: enum { Type = QGraphicsItem::UserType + 1 }; /// Rotate item around @pivot point on &deltaAngle (deg). - virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) {}; + virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) {} /// Scales item relatively @pivot point // TODO: add modes: IgnoreAspectRatio, KeepAspectRatio - virtual void scaleOn(const QPointF &pivot, const QPointF &factor) {}; + virtual void scaleOn(const QPointF &pivot, const QPointF &factor) {} /// Rotate arrow on angle (deg). (only for WorldItemPoint) - virtual void turnOn(const qreal angle) {}; - virtual void radiusOn(const qreal radius) {}; + virtual void turnOn(const qreal angle) {} + virtual void radiusOn(const qreal radius) {} /// Change color - virtual void setColor(const QColor &color) = 0; + virtual void setColor(const QColor &color) {} /// Enable/disable the mode edit shape (only for WorldItemPath and WorldItemPath) - virtual void setEnabledSubPoints(bool enabled) = 0; + virtual void setEnabledSubPoints(bool enabled) {} virtual void moveSubPoint(WorldItemSubPoint *subPoint) {} virtual void addSubPoint(WorldItemSubPoint *subPoint) {} @@ -156,22 +156,20 @@ private: }; /* -@class WorldItemPath -@brief WorldItemPath class provides a polyline item that you can add to a WorldEditorScene. +@class BaseWorldItemPolyline +@brief @details */ -class WorldItemPath: public AbstractWorldItem +class BaseWorldItemPolyline: public AbstractWorldItem { public: - WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent = 0); - virtual ~WorldItemPath(); + BaseWorldItemPolyline(const QPolygonF &polygon, QGraphicsItem *parent = 0); + virtual ~BaseWorldItemPolyline(); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); - virtual void setColor(const QColor &color); virtual void setEnabledSubPoints(bool enabled); - virtual void moveSubPoint(WorldItemSubPoint *subPoint); virtual void addSubPoint(WorldItemSubPoint *subPoint); virtual bool removeSubPoint(WorldItemSubPoint *subPoint); @@ -180,19 +178,38 @@ public: virtual QPolygonF polygon() const; virtual QRectF boundingRect() const; + +protected: + virtual void createSubPoints(); + virtual void removeSubPoints(); + + bool m_pointEdit; + QPolygonF m_polyline; + QPen m_pen, m_selectedPen; + + QList m_listItems; + QList m_listLines; +}; + +/* +@class WorldItemPath +@brief WorldItemPath class provides a polyline item that you can add to a WorldEditorScene. +@details +*/ +class WorldItemPath: public BaseWorldItemPolyline +{ +public: + WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent = 0); + virtual ~WorldItemPath(); + + virtual void setColor(const QColor &color); + virtual bool removeSubPoint(WorldItemSubPoint *subPoint); virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); private: - void createSubPoints(); - void removeSubPoints(); QPen m_pen, m_selectedPen; - QPolygonF m_polygon; - bool m_pointEdit; - - QList m_listItems; - QList m_listLines; }; /* @@ -200,42 +217,27 @@ private: @brief The WorldItemZone class provides a polygon item that you can add to a WorldEditorScene. @details */ -class WorldItemZone: public AbstractWorldItem +class WorldItemZone: public BaseWorldItemPolyline { public: WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent = 0); virtual ~WorldItemZone(); - virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); - virtual void scaleOn(const QPointF &pivot, const QPointF &factor); virtual void setColor(const QColor &color); - virtual void setEnabledSubPoints(bool enabled); - - virtual void moveSubPoint(WorldItemSubPoint *subPoint); - virtual void addSubPoint(WorldItemSubPoint *subPoint); virtual bool removeSubPoint(WorldItemSubPoint *subPoint); - virtual void setPolygon(const QPolygonF &polygon); - virtual QPolygonF polygon() const; - - virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -private: - void createSubPoints(); - void removeSubPoints(); +protected: + virtual void createSubPoints(); +private: static const int TRANSPARENCY = 38; QPen m_pen, m_selectedPen; QBrush m_brush, m_selectedBrush; - QPolygonF m_polygon; - bool m_pointEdit; - - QList m_listItems; - QList m_listLines; }; /* From 07fb99c5100c75a4691cc89f0769e92b6548a15f Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 11 Oct 2011 13:44:53 +0300 Subject: [PATCH 072/747] Changed: #1302 Fixed undo/redo in world editor qt. --- .../src/plugins/world_editor/world_editor_constants.h | 4 ++++ .../src/plugins/world_editor/world_editor_misc.cpp | 2 +- .../src/plugins/world_editor/world_editor_scene.cpp | 4 +++- .../src/plugins/world_editor/world_editor_scene_item.h | 2 -- .../src/plugins/world_editor/world_editor_window.cpp | 4 ++-- .../src/plugins/world_editor/world_editor_window.ui | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index a75e2148b..d0617373e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -32,6 +32,10 @@ const int PRIMITIVE_IS_MODIFIED = USER_TYPE + 5; const int PRIMITIVE_FILE_IS_CREATED = USER_TYPE + 6; const int PRIMITIVE_IS_VISIBLE = USER_TYPE + 7; +//properties editor +const char *const DIFFERENT_VALUE_STRING = ""; +const char *const DIFFERENT_VALUE_MULTI_STRING = ""; + //settings const char *const WORLD_EDITOR_SECTION = "WorldEditor"; const char *const WORLD_WINDOW_STATE = "WorldWindowState"; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp index 6db59f9e5..dc1ae435f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_misc.cpp @@ -171,7 +171,7 @@ bool loadWorldEditFile(const std::string &fileName, WorldEditList &worldEditList NLLIGO::CPrimitives ligoPrimitives; // Read it - ligoPrimitives.read(primitives, fileName.c_str(), *NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig); + ligoPrimitives.read(primitives, fileName.c_str(), *ligoConfig()); //_DataHierarchy.back ().Primitives.read (primitives, filename, theApp.Config); // Set the filename diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index ba67ab9a8..9922daaf7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -181,7 +181,7 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { m_firstPick = mouseEvent->scenePos(); - if (m_pointsMode) + if (isEnabledEditPoints()) { m_polygons = polygonsFromItems(m_selectedItems); @@ -288,6 +288,8 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) if (mouseEvent->button() == Qt::LeftButton) { + checkUndo(); + // Update selection if ((m_selectionArea.left() != 0) && (m_selectionArea.right() != 0)) { diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index b5584c427..9752d783d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -223,10 +223,8 @@ public: WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent = 0); virtual ~WorldItemZone(); - virtual void setColor(const QColor &color); virtual bool removeSubPoint(WorldItemSubPoint *subPoint); - virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 40e69d1f2..1e6d44ff6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -384,8 +384,8 @@ void WorldEditorWindow::readSettings() // Use OpenGL graphics system instead raster graphics system if (settings->value(Constants::WORLD_EDITOR_USE_OPENGL, true).toBool()) { - //m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); - m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers)); + m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer)); + //m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers)); m_ui.graphicsView->setViewport(m_oglWidget); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index d6d4edb28..d9b6f8ac3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -28,7 +28,7 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - QPainter::Antialiasing|QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing + QPainter::SmoothPixmapTransform QGraphicsView::NoDrag From f4975287a196b321b0a6bfc9fc7bf364c2f1693f Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 21 Dec 2011 00:45:00 +0300 Subject: [PATCH 073/747] Changed: #1302 Added some stuff for weqt property editor. --- .../src/plugins/core/CMakeLists.txt | 1 - .../landscape_editor/list_zones_model.cpp | 4 +- .../world_editor/property_editor_widget.cpp | 111 +++++++++++++++++- .../world_editor/property_editor_widget.h | 7 +- .../world_editor/world_editor_window.cpp | 2 +- 5 files changed, 117 insertions(+), 8 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt index 3140f02fb..927e35eaa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt @@ -11,7 +11,6 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_CORE_PLUGIN_HDR icore.h icontext.h - imenu_manager.h icore_listener.h ioptions_page.h core_plugin.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp index 57e8683c0..103a43052 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp @@ -75,9 +75,7 @@ QVariant ListZonesModel::data(const QModelIndex &index, int role) const } } -QVariant ListZonesModel::headerData(int section, - Qt::Orientation /* orientation */, - int role) const +QVariant ListZonesModel::headerData(int section, Qt::Orientation, int role) const { return QVariant(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp index 7df0b6d1d..7b4224e04 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp @@ -37,12 +37,16 @@ PropertyEditorWidget::PropertyEditorWidget(QWidget *parent) m_ui.setupUi(this); m_variantManager = new QtVariantPropertyManager(this); - + m_enumManager = new QtEnumPropertyManager(this); connect(m_variantManager, SIGNAL(valueChanged(QtProperty *, const QVariant &)), this, SLOT(valueChanged(QtProperty *, const QVariant &))); QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this); + QtEnumEditorFactory *enumFactory = new QtEnumEditorFactory(this); m_ui.treePropertyBrowser->setFactoryForManager(m_variantManager, variantFactory); + m_ui.treePropertyBrowser->setFactoryForManager(m_enumManager, enumFactory); + + m_groupManager = new QtGroupPropertyManager(this); } PropertyEditorWidget::~PropertyEditorWidget() @@ -51,10 +55,113 @@ PropertyEditorWidget::~PropertyEditorWidget() void PropertyEditorWidget::clearProperties() { + m_ui.treePropertyBrowser->clear(); } -void PropertyEditorWidget::setCurrentPrimitive(PrimitiveNode *node) +void PropertyEditorWidget::updateSelection(const NodeList &selected, const NodeList &deselected) { + clearProperties(); + + // The parameter list + std::set parameterList; + + for (int i = 0; i < selected.size(); ++i) + { + if (selected.at(i)->type() == Node::RootPrimitiveNodeType) + { + /* + const_cast(_PropDlgLocators[i].Primitive)->removePropertyByName("name"); + const_cast(_PropDlgLocators[i].Primitive)->removePropertyByName("path"); + //TODO faire une fonction dans CWorldDoc pour recup m_strPathName + string name; + getDocument()->getPrimitiveDisplayName(name,_PropDlgLocators[i].getDatabaseIndex()); + string path; + getDocument()->getFilePath(_PropDlgLocators[i].getDatabaseIndex(),path); + + const_cast(_PropDlgLocators[i].Primitive)->addPropertyByName("name",new CPropertyString (name)); + const_cast(_PropDlgLocators[i].Primitive)->addPropertyByName("path",new CPropertyString (path)); + */ + } + + if (selected.at(i)->type() == Node::PrimitiveNodeType) + { + PrimitiveNode *node = static_cast(selected.at(i)); + const NLLIGO::IPrimitive *primitive = node->primitive(); + const NLLIGO::CPrimitiveClass *primClass = node->primitiveClass(); + + // Use the class or not ? + if (primClass) + { + QtProperty *groupNode; + groupNode = m_groupManager->addProperty(node->data(Qt::DisplayRole).toString()); + m_ui.treePropertyBrowser->addProperty(groupNode); + + // For each properties of the class + for (uint p = 0; p < primClass->Parameters.size(); p++) + { + // Is the parameter visible ? + if (primClass->Parameters[p].Visible) + { + QtProperty *param; + + if (primClass->Parameters[p].Type == NLLIGO::CPrimitiveClass::CParameter::Boolean) + param = m_variantManager->addProperty(QVariant::Bool, primClass->Parameters[p].Name.c_str()); + else if (primClass->Parameters[p].Type == NLLIGO::CPrimitiveClass::CParameter::ConstString) + { + param = m_enumManager->addProperty(primClass->Parameters[p].Name.c_str()); + } + else if (primClass->Parameters[p].Type == NLLIGO::CPrimitiveClass::CParameter::String) + param = m_variantManager->addProperty(QVariant::String, primClass->Parameters[p].Name.c_str()); + else + param = m_variantManager->addProperty(QVariant::String, primClass->Parameters[p].Name.c_str()); + + groupNode->addSubProperty(param); + + parameterList.insert(primClass->Parameters[p]); + } + } + } + else + { + // For each primitive property + uint numProp = primitive->getNumProperty(); + for (uint p = 0; p < numProp; p++) + { + // Get the property + std::string propertyName; + const NLLIGO::IProperty *prop; + nlverify(primitive->getProperty (p, propertyName, prop)); + + // Add a default property + NLLIGO::CPrimitiveClass::CParameter defProp(*prop, propertyName.c_str()); + parameterList.insert(defProp); + } + } + } + } + + // Remove property class + std::set::iterator ite = parameterList.begin (); + while (ite != parameterList.end ()) + { + // Next iterator + std::set::iterator next = ite; + next++; + + // Property name ? + if (ite->Name == "class") + { + // Remove it + parameterList.erase (ite); + } + + ite = next; + } + + // Add the default parameter + NLLIGO::CPrimitiveClass::CParameter defaultParameter; + defaultParameter.Visible = true; + defaultParameter.Filename = false; } } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h index 3ee73a293..3a2506def 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h @@ -50,11 +50,16 @@ public: public Q_SLOTS: void clearProperties(); - void setCurrentPrimitive(PrimitiveNode *node); + + /// Update of selections + void updateSelection(const NodeList &selected, const NodeList &deselected); private: QtVariantPropertyManager *m_variantManager; + QtEnumPropertyManager *m_enumManager; + QtGroupPropertyManager *m_groupManager; + Ui::PropertyEditorWidget m_ui; }; /* PropertyEditorWidget */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 1e6d44ff6..30173b9d9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -276,7 +276,7 @@ void WorldEditorWindow::updateSelection(const QItemSelection &selected, const QI } // TODO: update property editor - // ... + m_ui.propertyEditWidget->updateSelection(nodesSelected, nodesDeselected); QList itemSelected; Q_FOREACH(Node *node, nodesSelected) From 3d1d9d3fca9a70a51fbdd456607221b14c64f28b Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 16 Jan 2012 01:18:27 +0300 Subject: [PATCH 074/747] Fixed: #1301 Fixed crash program --- .../src/plugins/landscape_editor/builder_zone_region.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp index e84a81f57..33b48e04e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/builder_zone_region.cpp @@ -858,7 +858,7 @@ void BuilderZoneRegion::putTransitions (sint32 inX, sint32 inY, const NLLIGO::SP if ( (corner < 4) && (m != 0) ) { // The material can't be paused - for (int t = 0; i < 4; ++t) + for (int t = 0; t < 4; ++t) dataZoneTemp.sharingMatNames[t] = STRING_UNUSED; // Don't propagate any more From 83db0f0adfe7017b51a4697ec520c3a86d3e9138 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sat, 4 Feb 2012 20:58:21 +0300 Subject: [PATCH 075/747] Changed: #1302 Added text edit property in qt property browser for NLLIGO::CPropertyStringArray. --- .../qtpropertybrowser/qteditorfactory.cpp | 232 ++++++++++++++++++ .../qtpropertybrowser/qteditorfactory.h | 22 ++ .../qtpropertybrowserutils.cpp | 4 + .../qtpropertybrowserutils_p.h | 2 + .../qtpropertybrowser/qtpropertymanager.cpp | 15 ++ .../qtpropertybrowser/qtpropertymanager.h | 10 + 6 files changed, 285 insertions(+) diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp index e619cf8cb..3a1e874eb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp @@ -101,6 +101,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -2601,6 +2608,231 @@ void QtFontEditorFactory::disconnectPropertyManager(QtFontPropertyManager *manag disconnect(manager, SIGNAL(valueChanged(QtProperty*,QFont)), this, SLOT(slotPropertyChanged(QtProperty*,QFont))); } +class QtTextEditWidget : public QWidget { + Q_OBJECT + +public: + QtTextEditWidget(QWidget *parent); + + bool eventFilter(QObject *obj, QEvent *ev); + +public Q_SLOTS: + void setValue(const QString &value); + +private Q_SLOTS: + void buttonClicked(); + +Q_SIGNALS: + void valueChanged(const QString &value); + +private: + QLineEdit *m_lineEdit; + QToolButton *m_defaultButton; + QToolButton *m_button; +}; + +QtTextEditWidget::QtTextEditWidget(QWidget *parent) : + QWidget(parent), + m_lineEdit(new QLineEdit), + m_defaultButton(new QToolButton), + m_button(new QToolButton) +{ + QHBoxLayout *lt = new QHBoxLayout(this); + lt->setContentsMargins(0, 0, 0, 0); + lt->setSpacing(0); + lt->addWidget(m_lineEdit); + m_lineEdit->setReadOnly(true); + + m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); + m_button->setFixedWidth(20); + setFocusProxy(m_button); + setFocusPolicy(m_button->focusPolicy()); + m_button->setText(tr("...")); + m_button->installEventFilter(this); + connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); + lt->addWidget(m_button); + lt->addWidget(m_defaultButton); + m_defaultButton->setEnabled(false); +} + +void QtTextEditWidget::setValue(const QString &value) +{ + if (m_lineEdit->text() != value) + m_lineEdit->setText(value); +} + +void QtTextEditWidget::buttonClicked() +{ + QGridLayout *gridLayout; + QPlainTextEdit *plainTextEdit; + QDialogButtonBox *buttonBox; + QDialog *dialog; + + dialog = new QDialog(this); + dialog->resize(400, 300); + gridLayout = new QGridLayout(dialog); + plainTextEdit = new QPlainTextEdit(dialog); + + gridLayout->addWidget(plainTextEdit, 0, 0, 1, 1); + + buttonBox = new QDialogButtonBox(dialog); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + gridLayout->addWidget(buttonBox, 1, 0, 1, 1); + + QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); + + plainTextEdit->textCursor().insertText(m_lineEdit->text()); + + dialog->setModal(true); + dialog->show(); + int result = dialog->exec(); + + if (result == QDialog::Accepted) + { + QString newText = plainTextEdit->document()->toPlainText(); + + setValue(newText); + if (plainTextEdit->document()->isModified()) + Q_EMIT valueChanged(newText); + } + + delete dialog; +} + +bool QtTextEditWidget::eventFilter(QObject *obj, QEvent *ev) +{ + if (obj == m_button) { + switch (ev->type()) { + case QEvent::KeyPress: + case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate + switch (static_cast(ev)->key()) { + case Qt::Key_Escape: + case Qt::Key_Enter: + case Qt::Key_Return: + ev->ignore(); + return true; + default: + break; + } + } + break; + default: + break; + } + } + return QWidget::eventFilter(obj, ev); +} + +// QtLineEditFactory + +class QtTextEditorFactoryPrivate : public EditorFactoryPrivate +{ + QtTextEditorFactory *q_ptr; + Q_DECLARE_PUBLIC(QtTextEditorFactory) +public: + + void slotPropertyChanged(QtProperty *property, const QString &value); + void slotSetValue(const QString &value); +}; + +void QtTextEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, + const QString &value) +{ + const PropertyToEditorListMap::iterator it = m_createdEditors.find(property); + if (it == m_createdEditors.end()) + return; + QListIterator itEditor(it.value()); + + while (itEditor.hasNext()) + itEditor.next()->setValue(value); +} + +void QtTextEditorFactoryPrivate::slotSetValue(const QString &value) +{ + QObject *object = q_ptr->sender(); + const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); + for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtTextPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + manager->setValue(property, value); + return; + } +} +/*! + \class QtTextEditFactory + + \brief The QtTextEditFactory class provides QTextEdit widgets for + properties created by QtStringPropertyManager objects. + + \sa QtAbstractEditorFactory, QtStringPropertyManager +*/ + +/*! + Creates a factory with the given \a parent. +*/ +QtTextEditorFactory::QtTextEditorFactory(QObject *parent) + : QtAbstractEditorFactory(parent) +{ + d_ptr = new QtTextEditorFactoryPrivate(); + d_ptr->q_ptr = this; + +} + +/*! + Destroys this factory, and all the widgets it has created. +*/ +QtTextEditorFactory::~QtTextEditorFactory() +{ + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; +} + +/*! + \internal + + Reimplemented from the QtAbstractEditorFactory class. +*/ +void QtTextEditorFactory::connectPropertyManager(QtTextPropertyManager *manager) +{ + connect(manager, SIGNAL(valueChanged(QtProperty *, const QString &)), + this, SLOT(slotPropertyChanged(QtProperty *, const QString &))); +} + +/*! + \internal + + Reimplemented from the QtAbstractEditorFactory class. +*/ +QWidget *QtTextEditorFactory::createEditor(QtTextPropertyManager *manager, + QtProperty *property, QWidget *parent) +{ + + QtTextEditWidget *editor = d_ptr->createEditor(property, parent); + + editor->setValue(manager->value(property)); + + connect(editor, SIGNAL(valueChanged(QString)), this, SLOT(slotSetValue(QString))); + connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); + return editor; +} + +/*! + \internal + + Reimplemented from the QtAbstractEditorFactory class. +*/ +void QtTextEditorFactory::disconnectPropertyManager(QtTextPropertyManager *manager) +{ + disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QString &)), + this, SLOT(slotPropertyChanged(QtProperty *, const QString &))); +} + #if QT_VERSION >= 0x040400 QT_END_NAMESPACE #endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h index 47e7b507f..de79a7a4a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h @@ -441,6 +441,28 @@ private: Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QFont &)) }; +class QtTextEditorFactoryPrivate; + +class QT_QTPROPERTYBROWSER_EXPORT QtTextEditorFactory : public QtAbstractEditorFactory +{ + Q_OBJECT +public: + QtTextEditorFactory(QObject *parent = 0); + ~QtTextEditorFactory(); +protected: + void connectPropertyManager(QtTextPropertyManager *manager); + QWidget *createEditor(QtTextPropertyManager *manager, QtProperty *property, + QWidget *parent); + void disconnectPropertyManager(QtTextPropertyManager *manager); +private: + QtTextEditorFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtTextEditorFactory) + Q_DISABLE_COPY(QtTextEditorFactory) + Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QString &)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString &)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) +}; + #if QT_VERSION >= 0x040400 QT_END_NAMESPACE #endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils.cpp index ce198bfca..0198c3c5f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils.cpp @@ -91,6 +91,7 @@ #include #include #include +#include #include #include @@ -260,6 +261,7 @@ QString QtPropertyBrowserUtils::fontValueText(const QFont &f) QtBoolEdit::QtBoolEdit(QWidget *parent) : QWidget(parent), m_checkBox(new QCheckBox(this)), + m_defaultButton(new QToolButton(this)), m_textVisible(true) { QHBoxLayout *lt = new QHBoxLayout; @@ -268,6 +270,8 @@ QtBoolEdit::QtBoolEdit(QWidget *parent) : else lt->setContentsMargins(0, 0, 4, 0); lt->addWidget(m_checkBox); + lt->addWidget(m_defaultButton); + m_defaultButton->setEnabled(false); setLayout(lt); connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); setFocusProxy(m_checkBox); diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils_p.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils_p.h index dca4b8c37..9fc851f16 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils_p.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils_p.h @@ -110,6 +110,7 @@ QT_BEGIN_NAMESPACE class QMouseEvent; class QCheckBox; +class QToolButton; class QLineEdit; class QtCursorDatabase @@ -168,6 +169,7 @@ protected: private: QCheckBox *m_checkBox; + QToolButton *m_defaultButton; bool m_textVisible; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp index 20de19786..fe8ea92c9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp @@ -99,6 +99,7 @@ #include #include #include +#include #include #include @@ -6457,6 +6458,20 @@ void QtCursorPropertyManager::uninitializeProperty(QtProperty *property) d_ptr->m_values.remove(property); } +QString QtTextPropertyManager::valueText(const QtProperty *property) const +{ + QString text = QtStringPropertyManager::valueText(property); + for (int i = 0; i < text.size(); i++) + { + if (text.at(i) == '\n') + { + QStringRef ret(&text, 0, i); + return ret.toString() + " ..."; + } + } + return text; +} + #if QT_VERSION >= 0x040400 QT_END_NAMESPACE #endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h index 709f2abf7..21fd57d6f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h @@ -789,6 +789,16 @@ private: Q_DISABLE_COPY(QtCursorPropertyManager) }; +class QT_QTPROPERTYBROWSER_EXPORT QtTextPropertyManager : public QtStringPropertyManager +{ + Q_OBJECT +public: + QtTextPropertyManager(QObject *parent = 0):QtStringPropertyManager(parent) {} + +protected: + virtual QString valueText(const QtProperty *property) const; +}; + #if QT_VERSION >= 0x040400 QT_END_NAMESPACE #endif From 3c09ce3ee85ad6617aac42cdb242968111412fc7 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sun, 5 Feb 2012 02:31:56 +0300 Subject: [PATCH 076/747] Changed: #1302 Added preview properties (except ConstStringArray values). --- .../plugins/world_editor/primitive_item.cpp | 20 ++ .../src/plugins/world_editor/primitive_item.h | 7 + .../world_editor/property_editor_widget.cpp | 294 +++++++++++++----- .../world_editor/property_editor_widget.h | 20 +- .../world_editor/world_editor_constants.h | 7 +- .../world_editor/world_editor_scene.cpp | 2 +- .../world_editor/world_editor_window.cpp | 25 +- 7 files changed, 287 insertions(+), 88 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index c0d799401..12d3b994a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -173,6 +173,26 @@ WorldEditNode::~WorldEditNode() { } +void WorldEditNode::setContext(const QString &name) +{ + m_context = name; +} + +QString WorldEditNode::context() const +{ + return m_context; +} + +void WorldEditNode::setDataPath(const QString &path) +{ + m_dataPath = path; +} + +QString WorldEditNode::dataPath() const +{ + return m_dataPath; +} + Node::NodeType WorldEditNode::type() const { return WorldEditNodeType; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 7ebf4437f..519b40aaf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -112,9 +112,16 @@ public: WorldEditNode(const QString &name); virtual ~WorldEditNode(); + void setContext(const QString &name); + QString context() const; + void setDataPath(const QString &path); + QString dataPath() const; + virtual NodeType type() const; private: + QString m_context; + QString m_dataPath; }; /* diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp index 7b4224e04..c5e2a2e0d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp @@ -17,6 +17,7 @@ // Project includes #include "property_editor_widget.h" +#include "world_editor_misc.h" // NeL includes #include @@ -38,15 +39,20 @@ PropertyEditorWidget::PropertyEditorWidget(QWidget *parent) m_variantManager = new QtVariantPropertyManager(this); m_enumManager = new QtEnumPropertyManager(this); + m_stringArrayManager = new QtTextPropertyManager(this); + connect(m_variantManager, SIGNAL(valueChanged(QtProperty *, const QVariant &)), this, SLOT(valueChanged(QtProperty *, const QVariant &))); QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this); QtEnumEditorFactory *enumFactory = new QtEnumEditorFactory(this); + QtTextEditorFactory *textFactory = new QtTextEditorFactory(this); + m_ui.treePropertyBrowser->setFactoryForManager(m_variantManager, variantFactory); m_ui.treePropertyBrowser->setFactoryForManager(m_enumManager, enumFactory); + m_ui.treePropertyBrowser->setFactoryForManager(m_stringArrayManager, textFactory); - m_groupManager = new QtGroupPropertyManager(this); + m_groupManager = new QtGroupPropertyManager(this); } PropertyEditorWidget::~PropertyEditorWidget() @@ -58,110 +64,238 @@ void PropertyEditorWidget::clearProperties() m_ui.treePropertyBrowser->clear(); } -void PropertyEditorWidget::updateSelection(const NodeList &selected, const NodeList &deselected) +void PropertyEditorWidget::updateSelection(Node *node) { clearProperties(); + if ((node == 0) || (node->type() != Node::PrimitiveNodeType)) + return; + // The parameter list - std::set parameterList; + std::list parameterList; - for (int i = 0; i < selected.size(); ++i) + PrimitiveNode *primNode = static_cast(node); + const NLLIGO::IPrimitive *primitive = primNode->primitive(); + const NLLIGO::CPrimitiveClass *primClass = primNode->primitiveClass(); + + // Use the class or not ? + if (primClass) { - if (selected.at(i)->type() == Node::RootPrimitiveNodeType) + // For each properties of the class + for (uint p = 0; p < primClass->Parameters.size(); p++) { - /* - const_cast(_PropDlgLocators[i].Primitive)->removePropertyByName("name"); - const_cast(_PropDlgLocators[i].Primitive)->removePropertyByName("path"); - //TODO faire une fonction dans CWorldDoc pour recup m_strPathName - string name; - getDocument()->getPrimitiveDisplayName(name,_PropDlgLocators[i].getDatabaseIndex()); - string path; - getDocument()->getFilePath(_PropDlgLocators[i].getDatabaseIndex(),path); - - const_cast(_PropDlgLocators[i].Primitive)->addPropertyByName("name",new CPropertyString (name)); - const_cast(_PropDlgLocators[i].Primitive)->addPropertyByName("path",new CPropertyString (path)); - */ + // Is the parameter visible ? + if (primClass->Parameters[p].Visible) + { + if (primClass->Parameters[p].Name == "name") + parameterList.push_front(primClass->Parameters[p]); + else + parameterList.push_back(primClass->Parameters[p]); + } } - - if (selected.at(i)->type() == Node::PrimitiveNodeType) + } + else + { + // For each primitive property + uint numProp = primitive->getNumProperty(); + for (uint p = 0; p < numProp; p++) { - PrimitiveNode *node = static_cast(selected.at(i)); - const NLLIGO::IPrimitive *primitive = node->primitive(); - const NLLIGO::CPrimitiveClass *primClass = node->primitiveClass(); - - // Use the class or not ? - if (primClass) - { - QtProperty *groupNode; - groupNode = m_groupManager->addProperty(node->data(Qt::DisplayRole).toString()); - m_ui.treePropertyBrowser->addProperty(groupNode); - - // For each properties of the class - for (uint p = 0; p < primClass->Parameters.size(); p++) - { - // Is the parameter visible ? - if (primClass->Parameters[p].Visible) - { - QtProperty *param; + // Get the property + std::string propertyName; + const NLLIGO::IProperty *prop; + nlverify(primitive->getProperty(p, propertyName, prop)); - if (primClass->Parameters[p].Type == NLLIGO::CPrimitiveClass::CParameter::Boolean) - param = m_variantManager->addProperty(QVariant::Bool, primClass->Parameters[p].Name.c_str()); - else if (primClass->Parameters[p].Type == NLLIGO::CPrimitiveClass::CParameter::ConstString) - { - param = m_enumManager->addProperty(primClass->Parameters[p].Name.c_str()); - } - else if (primClass->Parameters[p].Type == NLLIGO::CPrimitiveClass::CParameter::String) - param = m_variantManager->addProperty(QVariant::String, primClass->Parameters[p].Name.c_str()); - else - param = m_variantManager->addProperty(QVariant::String, primClass->Parameters[p].Name.c_str()); + // Add a default property + NLLIGO::CPrimitiveClass::CParameter defProp(*prop, propertyName.c_str()); - groupNode->addSubProperty(param); - - parameterList.insert(primClass->Parameters[p]); - } - } - } + if (defProp.Name == "name") + parameterList.push_front(defProp); else - { - // For each primitive property - uint numProp = primitive->getNumProperty(); - for (uint p = 0; p < numProp; p++) - { - // Get the property - std::string propertyName; - const NLLIGO::IProperty *prop; - nlverify(primitive->getProperty (p, propertyName, prop)); - - // Add a default property - NLLIGO::CPrimitiveClass::CParameter defProp(*prop, propertyName.c_str()); - parameterList.insert(defProp); - } - } + parameterList.push_back(defProp); } } // Remove property class - std::set::iterator ite = parameterList.begin (); + std::list::iterator ite = parameterList.begin (); while (ite != parameterList.end ()) { - // Next iterator - std::set::iterator next = ite; + std::list::iterator next = ite; next++; - - // Property name ? if (ite->Name == "class") { - // Remove it - parameterList.erase (ite); + parameterList.erase(ite); } - ite = next; } - // Add the default parameter - NLLIGO::CPrimitiveClass::CParameter defaultParameter; - defaultParameter.Visible = true; - defaultParameter.Filename = false; + QtProperty *groupNode; + groupNode = m_groupManager->addProperty(QString("%1(%2)").arg(node->data(Qt::DisplayRole).toString()).arg(primClass->Name.c_str())); + m_ui.treePropertyBrowser->addProperty(groupNode); + + ite = parameterList.begin (); + while (ite != parameterList.end ()) + { + NLLIGO::CPrimitiveClass::CParameter ¶meter = (*ite); + QtProperty *prop; + NLLIGO::IProperty *ligoProperty; + primitive->getPropertyByName(parameter.Name.c_str(), ligoProperty); + + if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstString) + prop = addConstStringProperty(ligoProperty, parameter, primitive); + else if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::String) + prop = addStringProperty(ligoProperty, parameter, primitive); + else if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::StringArray) + prop = addStringArrayProperty(ligoProperty, parameter, primitive); + else if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstStringArray) + prop = addConstStringArrayProperty(ligoProperty, parameter, primitive); + else + // hmn? + prop = addBoolProperty(parameter, primitive); + + // Default value ? + if ((ligoProperty == NULL) || (ligoProperty->Default)) + prop->setModified(false); + else + prop->setModified(true); + + bool staticChildSelected = Utils::ligoConfig()->isStaticChild(*primitive); + if (parameter.ReadOnly || (staticChildSelected && (parameter.Name == "name"))) + prop->setEnabled(false); + + groupNode->addSubProperty(prop); + + ite++; + } +} + +QtProperty *PropertyEditorWidget::addBoolProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive) +{ + std::string value; + std::string name = parameter.Name.c_str(); + primitive->getPropertyByName(name.c_str(), value); + QtVariantProperty *prop = m_variantManager->addProperty(QVariant::Bool, name.c_str()); + // if (Default) + { + //DialogProperties->setDefaultValue (this, value); + prop->setValue(bool((value=="true")?1:0)); + } + return prop; +} + +QtProperty *PropertyEditorWidget::addConstStringProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive) +{ + std::string context("default"); + + std::string value; + std::string name = parameter.Name.c_str(); + primitive->getPropertyByName(name.c_str(), value); + QtProperty *prop = m_enumManager->addProperty(parameter.Name.c_str()); + + std::map::const_iterator ite = parameter.ComboValues.find(context.c_str()); + + // TODO + //if (ite != parameter.ComboValues.end()) + { + std::vector pathList; + { + ite->second.appendFilePath(pathList); + + /*std::vector relativePrimPaths; + { + std::vector startPrimPath; + for (uint locIndex = 0; locIndex<_PropDlgLocators.size(); locIndex++) + startPrimPath.push_back(_PropDlgLocators[locIndex].Primitive); + + ite->second.getPrimitivesForPrimPath(relativePrimPaths, startPrimPath); + } + ite->second.appendPrimPath(pathList, relativePrimPaths);*/ + } + + if (parameter.SortEntries) + std::sort(pathList.begin(), pathList.end()); + + int currentValue = 0; + QStringList listEnums; + for (size_t i = 0; i < pathList.size(); ++i) + { + listEnums.append(pathList[i].c_str()); + if (value == pathList[i]) + currentValue = i; + } + if (!pathList.empty()) + { + m_enumManager->setEnumNames(prop, listEnums); + m_enumManager->setValue(prop, currentValue); + } + } + return prop; +} + +QtProperty *PropertyEditorWidget::addStringProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive) +{ + std::string value; + std::string name = parameter.Name.c_str(); + primitive->getPropertyByName(name.c_str(), value); + QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str()); + prop->setValue(QString(value.c_str())); + return prop; +} + +QtProperty *PropertyEditorWidget::addStringArrayProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive) +{ + std::string name = parameter.Name.c_str(); + QtProperty *prop = m_stringArrayManager->addProperty(parameter.Name.c_str()); + + const NLLIGO::IProperty *ligoProperty; + std::vector vectString; + + if (primitive->getPropertyByName (parameter.Name.c_str (), ligoProperty)) + { + const NLLIGO::CPropertyStringArray *const propStringArray = dynamic_cast (ligoProperty); + if (propStringArray) + { + const std::vector &vectString = propStringArray->StringArray; + if (vectString.empty()) + { + //m_stringArrayManager->setValue(prop, "StringArray"); + } + else + { + std::string temp; + for (size_t i = 0; i < vectString.size(); i++) + { + temp += vectString[i]; + if (i != (vectString.size() - 1)) + temp += '\n'; + } + m_stringArrayManager->setValue(prop, temp.c_str()); + prop->setToolTip(temp.c_str()); + } + } + else + { + m_stringArrayManager->setValue(prop, "StringArray :("); + } + } + return prop; +} + +QtProperty *PropertyEditorWidget::addConstStringArrayProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive) +{ + std::string name = parameter.Name.c_str(); + QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str()); + prop->setValue("ConstStringArray"); + return prop; } } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h index 3a2506def..a4ccf9d5f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h @@ -51,14 +51,30 @@ public: public Q_SLOTS: void clearProperties(); - /// Update of selections - void updateSelection(const NodeList &selected, const NodeList &deselected); + /// Update of selections + void updateSelection(Node *node); private: + QtProperty *addBoolProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive); + QtProperty *addConstStringProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive); + QtProperty *addStringProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive); + QtProperty *addStringArrayProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive); + QtProperty *addConstStringArrayProperty(const NLLIGO::IProperty *property, + const NLLIGO::CPrimitiveClass::CParameter ¶meter, + const NLLIGO::IPrimitive *primitive); QtVariantPropertyManager *m_variantManager; QtEnumPropertyManager *m_enumManager; QtGroupPropertyManager *m_groupManager; + QtTextPropertyManager *m_stringArrayManager; Ui::PropertyEditorWidget m_ui; }; /* PropertyEditorWidget */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index d0617373e..7ca698697 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -31,9 +31,14 @@ const int GRAPHICS_DATA_NEL3D = USER_TYPE + 4; const int PRIMITIVE_IS_MODIFIED = USER_TYPE + 5; const int PRIMITIVE_FILE_IS_CREATED = USER_TYPE + 6; const int PRIMITIVE_IS_VISIBLE = USER_TYPE + 7; +const int PRIMITIVE_IS_ENABLD = USER_TYPE + 8; +const int PRIMITIVE_FILE_NAME = USER_TYPE + 9; +const int PRIMITIVE_NON_REMOVABLE = USER_TYPE + 10; +const int ROOT_PRIMITIVE_CONTEXT = USER_TYPE + 20; +const int ROOT_PRIMITIVE_DATA_DIRECTORY = USER_TYPE + 21; //properties editor -const char *const DIFFERENT_VALUE_STRING = ""; +const char *const DIFFERENT_VALUE_STRING = ""; const char *const DIFFERENT_VALUE_MULTI_STRING = ""; //settings diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 9922daaf7..c58102ac2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -274,7 +274,7 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) else m_editedSelectedItems = false; } - // Update render + // Update render (drawing selection area when enabled multiple selection mode) update(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 30173b9d9..382b356c0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -275,8 +275,16 @@ void WorldEditorWindow::updateSelection(const QItemSelection &selected, const QI nodesDeselected.push_back(node); } - // TODO: update property editor - m_ui.propertyEditWidget->updateSelection(nodesSelected, nodesDeselected); + // update property editor + if (nodesSelected.size() > 0) + { + // only single selection + m_ui.propertyEditWidget->updateSelection(nodesSelected.at(0)); + } + else + { + m_ui.propertyEditWidget->clearProperties(); + } QList itemSelected; Q_FOREACH(Node *node, nodesSelected) @@ -320,8 +328,17 @@ void WorldEditorWindow::selectedItemsInScene(const QList &selec selectionModel->select(itemSelection, QItemSelectionModel::Select); - // TODO: update property editor - // ... + // update property editor + if (!selected.isEmpty()) + { + // only single selection + Node *node = qvariant_cast(selected.at(0)->data(Constants::WORLD_EDITOR_NODE)); + m_ui.propertyEditWidget->updateSelection(node); + } + else + { + m_ui.propertyEditWidget->clearProperties(); + } connect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(updateSelection(QItemSelection, QItemSelection))); From a744fa912ef3bb678cbf2afa0811b8a0660adac6 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 3 Apr 2012 16:54:20 +0200 Subject: [PATCH 077/747] Allow compiling max plugins without the other tools --- code/nel/CMakeLists.txt | 10 ++- code/nel/tools/3d/CMakeLists.txt | 115 +++++++++++++++++-------------- code/nel/tools/CMakeLists.txt | 52 +++++++------- 3 files changed, 100 insertions(+), 77 deletions(-) diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 745278cd7..1929135b4 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -68,7 +68,11 @@ IF(WITH_NEL_SAMPLES) ADD_SUBDIRECTORY(samples) ENDIF(WITH_NEL_SAMPLES) -IF(WITH_NEL_TOOLS) - FIND_PACKAGE(Squish) +# Allow to compile only max plugins without other tools. +IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) + IF(WITH_NEL_TOOLS) + FIND_PACKAGE(Squish) + ENDIF(WITH_NEL_TOOLS) ADD_SUBDIRECTORY(tools) -ENDIF(WITH_NEL_TOOLS) +ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) + diff --git a/code/nel/tools/3d/CMakeLists.txt b/code/nel/tools/3d/CMakeLists.txt index 63bf49cf4..441a83800 100644 --- a/code/nel/tools/3d/CMakeLists.txt +++ b/code/nel/tools/3d/CMakeLists.txt @@ -1,62 +1,75 @@ -SUBDIRS( - build_coarse_mesh - build_far_bank - build_smallbank - ig_lighter - zone_dependencies - zone_ig_lighter - zone_lighter - zone_welder - animation_set_builder - anim_builder - build_clod_bank - build_clodtex - build_interface - build_shadow_skin - cluster_viewer - file_info - get_neighbors - ig_add - ig_info - shapes_exporter - tga_cut - tga_resize + +IF(WITH_NEL_TOOLS) + + SUBDIRS( + build_coarse_mesh + build_far_bank + build_smallbank + ig_lighter + zone_dependencies + zone_ig_lighter + zone_lighter + zone_welder + animation_set_builder + anim_builder + build_clod_bank + build_clodtex + build_interface + build_shadow_skin + cluster_viewer + file_info + get_neighbors + ig_add + ig_info + shapes_exporter + tga_cut + tga_resize shape2obj - zone_check_bind - zone_dump - zviewer) + zone_check_bind + zone_dump + zviewer) -IF(WIN32) - ADD_SUBDIRECTORY(ig_elevation) - ADD_SUBDIRECTORY(lightmap_optimizer) +ENDIF(WITH_NEL_TOOLS) +# For tools selection of only max plugins +IF(WIN32) IF(MFC_FOUND) ADD_SUBDIRECTORY(object_viewer) - ADD_SUBDIRECTORY(object_viewer_exe) - ADD_SUBDIRECTORY(tile_edit) + IF(WITH_NEL_MAXPLUGIN) + IF(MAXSDK_FOUND) + ADD_SUBDIRECTORY(plugin_max) + ADD_SUBDIRECTORY(ligo) + ENDIF(MAXSDK_FOUND) + ENDIF(WITH_NEL_MAXPLUGIN) ENDIF(MFC_FOUND) - - IF(WITH_NEL_MAXPLUGIN) - IF(MAXSDK_FOUND) - ADD_SUBDIRECTORY(plugin_max) - ADD_SUBDIRECTORY(ligo) - ENDIF(MAXSDK_FOUND) - ENDIF(WITH_NEL_MAXPLUGIN) - ENDIF(WIN32) -IF(WITH_QT) - ADD_SUBDIRECTORY(tile_edit_qt) - ADD_SUBDIRECTORY(object_viewer_qt) - ADD_SUBDIRECTORY(object_viewer_widget) -ENDIF(WITH_QT) +IF(WITH_NEL_TOOLS) -IF(SQUISH_FOUND) + IF(WIN32) + ADD_SUBDIRECTORY(ig_elevation) + ADD_SUBDIRECTORY(lightmap_optimizer) + IF(MFC_FOUND) + ADD_SUBDIRECTORY(object_viewer_exe) + ADD_SUBDIRECTORY(tile_edit) + ENDIF(MFC_FOUND) + ENDIF(WIN32) + + IF(WITH_QT) + ADD_SUBDIRECTORY(tile_edit_qt) + ADD_SUBDIRECTORY(object_viewer_qt) + ADD_SUBDIRECTORY(object_viewer_widget) + ENDIF(WITH_QT) + + IF(SQUISH_FOUND) ADD_SUBDIRECTORY(s3tc_compressor_lib) - ADD_SUBDIRECTORY(panoply_maker) - ADD_SUBDIRECTORY(tga_2_dds) - ADD_SUBDIRECTORY(hls_bank_maker) -ENDIF(SQUISH_FOUND) + ADD_SUBDIRECTORY(panoply_maker) + ADD_SUBDIRECTORY(tga_2_dds) + ADD_SUBDIRECTORY(hls_bank_maker) + ENDIF(SQUISH_FOUND) + + #crash_log_analyser + #shapes_exporter + +ENDIF(WITH_NEL_TOOLS) -#crash_log_analyser -#shapes_exporter diff --git a/code/nel/tools/CMakeLists.txt b/code/nel/tools/CMakeLists.txt index 49a8abef4..abc5dff02 100644 --- a/code/nel/tools/CMakeLists.txt +++ b/code/nel/tools/CMakeLists.txt @@ -1,28 +1,34 @@ -ADD_SUBDIRECTORY(misc) -ADD_SUBDIRECTORY(memory) +# Don't add other subdirectories if only max plugins are selected. +IF(WITH_NEL_TOOLS) + ADD_SUBDIRECTORY(misc) + ADD_SUBDIRECTORY(memory) +ENDIF(WITH_NEL_TOOLS) + +# Max plugins are under the 3d directory as well. IF(WITH_3D) ADD_SUBDIRECTORY(3d) ENDIF(WITH_3D) -IF(WITH_PACS) - ADD_SUBDIRECTORY(pacs) -ENDIF(WITH_PACS) - -IF(WITH_LOGIC) - ADD_SUBDIRECTORY(logic) -ENDIF(WITH_LOGIC) - -IF(WITH_GEORGES) - ADD_SUBDIRECTORY(georges) -ENDIF(WITH_GEORGES) - -IF(WITH_SOUND) - ADD_SUBDIRECTORY(sound) -ENDIF(WITH_SOUND) - -IF(WITH_NEL_TESTS) - ADD_SUBDIRECTORY(nel_unit_test) -ENDIF(WITH_NEL_TESTS) - -#build_gamedata +# Don't add other subdirectories if only max plugins are selected. +IF(WITH_NEL_TOOLS) + IF(WITH_PACS) + ADD_SUBDIRECTORY(pacs) + ENDIF(WITH_PACS) + + IF(WITH_LOGIC) + ADD_SUBDIRECTORY(logic) + ENDIF(WITH_LOGIC) + + IF(WITH_GEORGES) + ADD_SUBDIRECTORY(georges) + ENDIF(WITH_GEORGES) + + IF(WITH_SOUND) + ADD_SUBDIRECTORY(sound) + ENDIF(WITH_SOUND) + + IF(WITH_NEL_TESTS) + ADD_SUBDIRECTORY(nel_unit_test) + ENDIF(WITH_NEL_TESTS) +ENDIF(WITH_NEL_TOOLS) From c2bd4fabd6dd0a5e0bd4eac1c54c0e162a4993da Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 23 Apr 2012 19:20:09 +0300 Subject: [PATCH 078/747] Changed: #1302 Fixed undo/redo bug (moving primitives). --- .../src/plugins/landscape_editor/pixmap_database.cpp | 1 + .../src/plugins/world_editor/property_editor_widget.cpp | 2 +- .../src/plugins/world_editor/world_editor_scene.cpp | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp index 0156f5a53..15f8760be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/pixmap_database.cpp @@ -96,6 +96,7 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon painter.end(); delete pixmap; m_pixmapMap.insert(zonePixmapName, emptyPixmap); + nlwarning(QString("not found " + zonePath + zonePixmapName + ".png").toStdString().c_str()); } // All pixmaps must be have same size else if (pixmap->width() != sizeX * m_textureSize) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp index c5e2a2e0d..990f4935d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp @@ -150,7 +150,7 @@ void PropertyEditorWidget::updateSelection(Node *node) prop = addConstStringArrayProperty(ligoProperty, parameter, primitive); else // hmn? - prop = addBoolProperty(parameter, primitive); + prop = addBoolProperty(ligoProperty, parameter, primitive); // Default value ? if ((ligoProperty == NULL) || (ligoProperty->Default)) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index c58102ac2..e24ef50e7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -227,6 +227,7 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) } m_editedSelectedItems = false; + m_offset = QPointF(0, 0); m_angle = 0; m_scaleFactor = QPointF(1.0, 1.0); @@ -516,7 +517,8 @@ void WorldEditorScene::checkUndoPointsMode() void WorldEditorScene::updateWorldItemsMove(QGraphicsSceneMouseEvent *mouseEvent) { - QPointF offset(mouseEvent->scenePos() - mouseEvent->lastScenePos()); + QPointF offset = mouseEvent->scenePos() - mouseEvent->lastScenePos(); + m_offset += offset; if (m_pointsMode) Q_FOREACH(QGraphicsItem *item, m_selectedPoints) { From 5fb4de1a211c85e5e1cc9906e040e0d37e018fdc Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sun, 10 Jun 2012 16:56:45 +0300 Subject: [PATCH 079/747] Changed: #1302 Correct fill properties(ConstStringValue) with *both* contexts if the current context is not default and is valid. --- .../world_editor/property_editor_widget.cpp | 102 +++++++++++------- 1 file changed, 65 insertions(+), 37 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp index 990f4935d..c3b9a3ba6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp @@ -132,12 +132,12 @@ void PropertyEditorWidget::updateSelection(Node *node) groupNode = m_groupManager->addProperty(QString("%1(%2)").arg(node->data(Qt::DisplayRole).toString()).arg(primClass->Name.c_str())); m_ui.treePropertyBrowser->addProperty(groupNode); - ite = parameterList.begin (); - while (ite != parameterList.end ()) + ite = parameterList.begin(); + while (ite != parameterList.end()) { NLLIGO::CPrimitiveClass::CParameter ¶meter = (*ite); QtProperty *prop; - NLLIGO::IProperty *ligoProperty; + NLLIGO::IProperty *ligoProperty = 0; primitive->getPropertyByName(parameter.Name.c_str(), ligoProperty); if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstString) @@ -188,50 +188,81 @@ QtProperty *PropertyEditorWidget::addConstStringProperty(const NLLIGO::IProperty const NLLIGO::CPrimitiveClass::CParameter ¶meter, const NLLIGO::IPrimitive *primitive) { - std::string context("default"); + // TODO: get context value from dialog + std::string context("jungle"); + std::string defaultContext("default"); std::string value; std::string name = parameter.Name.c_str(); + + // Get current value primitive->getPropertyByName(name.c_str(), value); + + // Create qt property QtProperty *prop = m_enumManager->addProperty(parameter.Name.c_str()); - std::map::const_iterator ite = parameter.ComboValues.find(context.c_str()); + std::vector listContext; + + if (context != defaultContext) + listContext.push_back(context); + listContext.push_back(defaultContext); - // TODO - //if (ite != parameter.ComboValues.end()) + QStringList listEnums; + + // Correct fill properties with *both* contexts if the current context is not default and is valid. + for (size_t j = 0; j < listContext.size(); j++) { - std::vector pathList; - { - ite->second.appendFilePath(pathList); + std::map::const_iterator ite = parameter.ComboValues.find(listContext[j].c_str()); - /*std::vector relativePrimPaths; + if (ite != parameter.ComboValues.end()) + { + std::vector pathList; { - std::vector startPrimPath; - for (uint locIndex = 0; locIndex<_PropDlgLocators.size(); locIndex++) - startPrimPath.push_back(_PropDlgLocators[locIndex].Primitive); + ite->second.appendFilePath(pathList); - ite->second.getPrimitivesForPrimPath(relativePrimPaths, startPrimPath); + // TODO: what is it? + /*std::vector relativePrimPaths; + { + std::vector startPrimPath; + for (uint locIndex = 0; locIndex<_PropDlgLocators.size(); locIndex++) + startPrimPath.push_back(_PropDlgLocators[locIndex].Primitive); + + ite->second.getPrimitivesForPrimPath(relativePrimPaths, startPrimPath); + } + ite->second.appendPrimPath(pathList, relativePrimPaths);*/ } - ite->second.appendPrimPath(pathList, relativePrimPaths);*/ - } - if (parameter.SortEntries) - std::sort(pathList.begin(), pathList.end()); + if (parameter.SortEntries) + std::sort(pathList.begin(), pathList.end()); - int currentValue = 0; - QStringList listEnums; - for (size_t i = 0; i < pathList.size(); ++i) - { - listEnums.append(pathList[i].c_str()); - if (value == pathList[i]) - currentValue = i; - } - if (!pathList.empty()) - { - m_enumManager->setEnumNames(prop, listEnums); - m_enumManager->setValue(prop, currentValue); + for (size_t i = 0; i < pathList.size(); ++i) + listEnums.append(pathList[i].c_str()); } } + + if (listEnums.isEmpty()) + { + listEnums << tr("WRN: Check leveldesign!"); + m_enumManager->setEnumNames(prop, listEnums); + m_enumManager->setValue(prop, 0); + prop->setEnabled(false); + } + else + { + // Fill qt property + m_enumManager->setEnumNames(prop, listEnums); + + // Find index of current value + for (int i = 0; i < listEnums.size(); i++) + { + if (value == listEnums[i].toStdString()) + { + m_enumManager->setValue(prop, i); + break; + } + } + } + return prop; } @@ -263,11 +294,7 @@ QtProperty *PropertyEditorWidget::addStringArrayProperty(const NLLIGO::IProperty if (propStringArray) { const std::vector &vectString = propStringArray->StringArray; - if (vectString.empty()) - { - //m_stringArrayManager->setValue(prop, "StringArray"); - } - else + if (!vectString.empty()) { std::string temp; for (size_t i = 0; i < vectString.size(); i++) @@ -294,7 +321,8 @@ QtProperty *PropertyEditorWidget::addConstStringArrayProperty(const NLLIGO::IPro { std::string name = parameter.Name.c_str(); QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str()); - prop->setValue("ConstStringArray"); + prop->setValue("TODO: ConstStringArray"); + prop->setEnabled(false); return prop; } From fe361a9ca0854b2a26466d30043d7a53d98506f7 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sun, 10 Jun 2012 18:27:47 +0300 Subject: [PATCH 080/747] Changed: #1302 Fixed undo/redo bug (moving primitives). --- .../src/plugins/world_editor/world_editor_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index e24ef50e7..678b361fe 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -467,7 +467,7 @@ void WorldEditorScene::updatePickSelectionPoints(const QPointF &point) void WorldEditorScene::checkUndo() { - if (m_editedSelectedItems) + if (m_editedSelectedItems && (!isEnabledEditPoints())) { switch (m_mode) { From 07ecce1b455c6f48f0a6438643c71b7b6f138395 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sun, 10 Jun 2012 21:15:22 +0300 Subject: [PATCH 081/747] Changed: #1302 Added signal 'reset bool property' for returning to default value --- .../images/resetproperty.png | Bin 0 -> 169 bytes .../qtpropertybrowser/qteditorfactory.cpp | 29 ++++++++++++++++-- .../qtpropertybrowser/qteditorfactory.h | 1 + .../qtpropertybrowser/qtpropertybrowser.qrc | 1 + .../qtpropertybrowserutils.cpp | 13 +++++++- .../qtpropertybrowserutils_p.h | 2 ++ .../qtpropertybrowser/qtpropertymanager.cpp | 5 +++ .../qtpropertybrowser/qtpropertymanager.h | 4 +++ 8 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/images/resetproperty.png diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/images/resetproperty.png b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/images/resetproperty.png new file mode 100644 index 0000000000000000000000000000000000000000..9048252ec2a51e7ee3461b72ba31fcabb2f10027 GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)M!VDz;D$H~RQtAOdA+G=b|DVXfKoI@;pQ;7a z!c!9D7tA1OVDFM#)bRFI`d!AXvO1u+s;7%%2#0KP!Un;Fgaq5gCk{*~e&)l-9KQS# jBO6=3qr$;M$qWpMPuN;S?ziRvH86O(`njxgN@xNAXMir1 literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp index 3a1e874eb..c1a10ff0a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp @@ -659,6 +659,7 @@ class QtCheckBoxFactoryPrivate : public EditorFactoryPrivate public: void slotPropertyChanged(QtProperty *property, bool value); void slotSetValue(bool value); + void slotReset(); }; void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool value) @@ -669,6 +670,7 @@ void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool va QListIterator itEditor(m_createdEditors[property]); while (itEditor.hasNext()) { QtBoolEdit *editor = itEditor.next(); + editor->setStateResetButton(property->isModified()); editor->blockCheckBoxSignals(true); editor->setChecked(value); editor->blockCheckBoxSignals(false); @@ -691,6 +693,22 @@ void QtCheckBoxFactoryPrivate::slotSetValue(bool value) } } +void QtCheckBoxFactoryPrivate::slotReset() +{ + QObject *object = q_ptr->sender(); + + const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); + for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtBoolPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + manager->setResetProperty(property); + return; + } +} + /*! \class QtCheckBoxFactory @@ -740,8 +758,10 @@ QWidget *QtCheckBoxFactory::createEditor(QtBoolPropertyManager *manager, QtPrope QWidget *parent) { QtBoolEdit *editor = d_ptr->createEditor(property, parent); + editor->setStateResetButton(property->isModified()); editor->setChecked(manager->value(property)); + connect(editor, SIGNAL(resetProperty()), this, SLOT(slotReset())); connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool))); connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); @@ -2645,10 +2665,15 @@ QtTextEditWidget::QtTextEditWidget(QWidget *parent) : m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); m_button->setFixedWidth(20); - setFocusProxy(m_button); - setFocusPolicy(m_button->focusPolicy()); m_button->setText(tr("...")); m_button->installEventFilter(this); + + setFocusProxy(m_button); + setFocusPolicy(m_button->focusPolicy()); + + m_defaultButton->setIcon(QIcon(":/trolltech/qtpropertybrowser/images/resetproperty.png")); + m_defaultButton->setMaximumWidth(16); + connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); lt->addWidget(m_button); lt->addWidget(m_defaultButton); diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h index de79a7a4a..58f64b2af 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h @@ -186,6 +186,7 @@ private: Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool)) Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool)) Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + Q_PRIVATE_SLOT(d_func(), void slotReset()) }; class QtDoubleSpinBoxFactoryPrivate; diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.qrc b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.qrc index 4f91ab782..50c2479f2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.qrc +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.qrc @@ -18,6 +18,7 @@ images/cursor-vsplit.png images/cursor-wait.png images/cursor-whatsthis.png + images/resetproperty.png diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils.cpp index 0198c3c5f..9b482a569 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils.cpp @@ -264,6 +264,10 @@ QtBoolEdit::QtBoolEdit(QWidget *parent) : m_defaultButton(new QToolButton(this)), m_textVisible(true) { + m_defaultButton->setIcon(QIcon(":/trolltech/qtpropertybrowser/images/resetproperty.png")); + m_defaultButton->setMaximumWidth(16); + m_defaultButton->setEnabled(false); + QHBoxLayout *lt = new QHBoxLayout; if (QApplication::layoutDirection() == Qt::LeftToRight) lt->setContentsMargins(4, 0, 0, 0); @@ -271,9 +275,11 @@ QtBoolEdit::QtBoolEdit(QWidget *parent) : lt->setContentsMargins(0, 0, 4, 0); lt->addWidget(m_checkBox); lt->addWidget(m_defaultButton); - m_defaultButton->setEnabled(false); setLayout(lt); + connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); + connect(m_defaultButton, SIGNAL(clicked()), this, SIGNAL(resetProperty())); + setFocusProxy(m_checkBox); m_checkBox->setText(QString()); } @@ -297,6 +303,11 @@ void QtBoolEdit::setCheckState(Qt::CheckState state) m_checkBox->setCheckState(state); } +void QtBoolEdit::setStateResetButton(bool enabled) +{ + m_defaultButton->setEnabled(enabled); +} + bool QtBoolEdit::isChecked() const { return m_checkBox->isChecked(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils_p.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils_p.h index 9fc851f16..66156c5d4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils_p.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowserutils_p.h @@ -155,6 +155,7 @@ public: Qt::CheckState checkState() const; void setCheckState(Qt::CheckState state); + void setStateResetButton(bool enabled); bool isChecked() const; void setChecked(bool c); @@ -163,6 +164,7 @@ public: Q_SIGNALS: void toggled(bool); + void resetProperty(); protected: void mousePressEvent(QMouseEvent * event); diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp index fe8ea92c9..6b2d24c80 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp @@ -1588,6 +1588,11 @@ void QtBoolPropertyManager::setValue(QtProperty *property, bool val) property, val); } +void QtBoolPropertyManager::setResetProperty(QtProperty *property) +{ + emit resetProperty(property); +} + /*! \reimp */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h index 21fd57d6f..958b22dc8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h @@ -160,8 +160,12 @@ public: public Q_SLOTS: void setValue(QtProperty *property, bool val); + void setResetProperty(QtProperty *property); + Q_SIGNALS: void valueChanged(QtProperty *property, bool val); + void resetProperty(QtProperty *property); + protected: QString valueText(const QtProperty *property) const; QIcon valueIcon(const QtProperty *property) const; From 7a37450ace8f5d55c52f9b538fca7e01b4779fc7 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sun, 10 Jun 2012 22:13:19 +0300 Subject: [PATCH 082/747] Changed: #1302 Added signal 'reset text property' for returning to default value --- .../qtpropertybrowser/qteditorfactory.cpp | 39 +++++++++++++++++-- .../qtpropertybrowser/qteditorfactory.h | 1 + .../qtpropertybrowser/qtpropertybrowser.cpp | 5 +++ .../qtpropertybrowser/qtpropertybrowser.h | 2 + .../qtpropertybrowser/qtpropertymanager.cpp | 5 --- .../qtpropertybrowser/qtpropertymanager.h | 2 - 6 files changed, 43 insertions(+), 11 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp index c1a10ff0a..9331959b9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp @@ -704,7 +704,7 @@ void QtCheckBoxFactoryPrivate::slotReset() QtBoolPropertyManager *manager = q_ptr->propertyManager(property); if (!manager) return; - manager->setResetProperty(property); + manager->emitResetProperty(property); return; } } @@ -2638,12 +2638,14 @@ public: public Q_SLOTS: void setValue(const QString &value); + void setStateResetButton(bool enabled); private Q_SLOTS: void buttonClicked(); Q_SIGNALS: void valueChanged(const QString &value); + void resetProperty(); private: QLineEdit *m_lineEdit; @@ -2675,6 +2677,7 @@ QtTextEditWidget::QtTextEditWidget(QWidget *parent) : m_defaultButton->setMaximumWidth(16); connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); + connect(m_defaultButton, SIGNAL(clicked()), this, SIGNAL(resetProperty())); lt->addWidget(m_button); lt->addWidget(m_defaultButton); m_defaultButton->setEnabled(false); @@ -2686,6 +2689,11 @@ void QtTextEditWidget::setValue(const QString &value) m_lineEdit->setText(value); } +void QtTextEditWidget::setStateResetButton(bool enabled) +{ + m_defaultButton->setEnabled(enabled); +} + void QtTextEditWidget::buttonClicked() { QGridLayout *gridLayout; @@ -2761,6 +2769,7 @@ public: void slotPropertyChanged(QtProperty *property, const QString &value); void slotSetValue(const QString &value); + void slotResetProperty(); }; void QtTextEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, @@ -2772,7 +2781,11 @@ void QtTextEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, QListIterator itEditor(it.value()); while (itEditor.hasNext()) - itEditor.next()->setValue(value); + { + QtTextEditWidget *editor = itEditor.next(); + editor->setValue(value); + editor->setStateResetButton(property->isModified()); + } } void QtTextEditorFactoryPrivate::slotSetValue(const QString &value) @@ -2789,6 +2802,22 @@ void QtTextEditorFactoryPrivate::slotSetValue(const QString &value) return; } } + +void QtTextEditorFactoryPrivate::slotResetProperty() +{ + QObject *object = q_ptr->sender(); + const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); + for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtTextPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + manager->emitResetProperty(property); + return; + } +} + /*! \class QtTextEditFactory @@ -2841,8 +2870,10 @@ QWidget *QtTextEditorFactory::createEditor(QtTextPropertyManager *manager, QtTextEditWidget *editor = d_ptr->createEditor(property, parent); editor->setValue(manager->value(property)); - - connect(editor, SIGNAL(valueChanged(QString)), this, SLOT(slotSetValue(QString))); + editor->setStateResetButton(property->isModified()); + + connect(editor, SIGNAL(resetProperty()), this, SLOT(slotResetProperty())); + connect(editor, SIGNAL(valueChanged(QString)), this, SLOT(slotSetValue(QString))); connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); return editor; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h index 58f64b2af..38489684e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h @@ -462,6 +462,7 @@ private: Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QString &)) Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString &)) Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + Q_PRIVATE_SLOT(d_func(), void slotResetProperty()) }; #if QT_VERSION >= 0x040400 diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.cpp index e8c103d9b..9b7d98b09 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.cpp @@ -808,6 +808,11 @@ QtProperty *QtAbstractPropertyManager::addProperty(const QString &name) return property; } +void QtAbstractPropertyManager::emitResetProperty(QtProperty *property) +{ + emit resetProperty(property); +} + /*! Creates a property. diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.h index 35b7ac0f8..5b63d3917 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertybrowser.h @@ -170,6 +170,7 @@ public: void clear() const; QtProperty *addProperty(const QString &name = QString()); + void emitResetProperty(QtProperty *property); Q_SIGNALS: void propertyInserted(QtProperty *property, @@ -177,6 +178,7 @@ Q_SIGNALS: void propertyChanged(QtProperty *property); void propertyRemoved(QtProperty *property, QtProperty *parent); void propertyDestroyed(QtProperty *property); + void resetProperty(QtProperty *property); protected: virtual bool hasValue(const QtProperty *property) const; virtual QIcon valueIcon(const QtProperty *property) const; diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp index 6b2d24c80..fe8ea92c9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.cpp @@ -1588,11 +1588,6 @@ void QtBoolPropertyManager::setValue(QtProperty *property, bool val) property, val); } -void QtBoolPropertyManager::setResetProperty(QtProperty *property) -{ - emit resetProperty(property); -} - /*! \reimp */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h index 958b22dc8..a19dd6e03 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qtpropertymanager.h @@ -160,11 +160,9 @@ public: public Q_SLOTS: void setValue(QtProperty *property, bool val); - void setResetProperty(QtProperty *property); Q_SIGNALS: void valueChanged(QtProperty *property, bool val); - void resetProperty(QtProperty *property); protected: QString valueText(const QtProperty *property) const; From 25ed79ef55224dac31299138e05734a04e246a0e Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Sun, 10 Jun 2012 23:40:48 +0300 Subject: [PATCH 083/747] Changed: #1302 Added signal 'reset enum property' for returning to default value --- .../qtpropertybrowser/qteditorfactory.cpp | 148 +++++++++++++++--- .../qtpropertybrowser/qteditorfactory.h | 3 +- 2 files changed, 124 insertions(+), 27 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp index 9331959b9..e5ac11f81 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.cpp @@ -659,7 +659,7 @@ class QtCheckBoxFactoryPrivate : public EditorFactoryPrivate public: void slotPropertyChanged(QtProperty *property, bool value); void slotSetValue(bool value); - void slotReset(); + void slotResetProperty(); }; void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool value) @@ -693,7 +693,7 @@ void QtCheckBoxFactoryPrivate::slotSetValue(bool value) } } -void QtCheckBoxFactoryPrivate::slotReset() +void QtCheckBoxFactoryPrivate::slotResetProperty() { QObject *object = q_ptr->sender(); @@ -761,7 +761,7 @@ QWidget *QtCheckBoxFactory::createEditor(QtBoolPropertyManager *manager, QtPrope editor->setStateResetButton(property->isModified()); editor->setChecked(manager->value(property)); - connect(editor, SIGNAL(resetProperty()), this, SLOT(slotReset())); + connect(editor, SIGNAL(resetProperty()), this, SLOT(slotResetProperty())); connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool))); connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); @@ -1880,9 +1880,87 @@ void QtCharEditorFactory::disconnectPropertyManager(QtCharPropertyManager *manag this, SLOT(slotPropertyChanged(QtProperty *, const QChar &))); } + +class QtEnumEditWidget : public QWidget { + Q_OBJECT + +public: + QtEnumEditWidget(QWidget *parent); + + bool blockComboBoxSignals(bool block); + void addItems(const QStringList &texts); + void clearComboBox(); + void setItemIcon(int index, const QIcon &icon); + +public Q_SLOTS: + void setValue(int value); + void setStateResetButton(bool enabled); + +Q_SIGNALS: + void valueChanged(int value); + void resetProperty(); + +private: + QComboBox *m_comboBox; + QToolButton *m_defaultButton; +}; + +QtEnumEditWidget::QtEnumEditWidget(QWidget *parent) : + QWidget(parent), + m_comboBox(new QComboBox), + m_defaultButton(new QToolButton) +{ + m_comboBox->view()->setTextElideMode(Qt::ElideRight); + + QHBoxLayout *lt = new QHBoxLayout(this); + lt->setContentsMargins(0, 0, 0, 0); + lt->setSpacing(0); + lt->addWidget(m_comboBox); + + m_defaultButton->setIcon(QIcon(":/trolltech/qtpropertybrowser/images/resetproperty.png")); + m_defaultButton->setMaximumWidth(16); + + connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(valueChanged(int))); + connect(m_defaultButton, SIGNAL(clicked()), this, SIGNAL(resetProperty())); + lt->addWidget(m_defaultButton); + m_defaultButton->setEnabled(false); + setFocusProxy(m_comboBox); +} + +void QtEnumEditWidget::setValue(int value) +{ + if (m_comboBox->currentIndex() != value) + m_comboBox->setCurrentIndex(value); +} + +void QtEnumEditWidget::setStateResetButton(bool enabled) +{ + m_defaultButton->setEnabled(enabled); +} + +bool QtEnumEditWidget::blockComboBoxSignals(bool block) +{ + return m_comboBox->blockSignals(block); +} + +void QtEnumEditWidget::addItems(const QStringList &texts) +{ + m_comboBox->addItems(texts); +} + +void QtEnumEditWidget::clearComboBox() +{ + m_comboBox->clear(); +} + +void QtEnumEditWidget::setItemIcon(int index, const QIcon &icon) +{ + m_comboBox->setItemIcon(index, icon); +} + // QtEnumEditorFactory -class QtEnumEditorFactoryPrivate : public EditorFactoryPrivate +class QtEnumEditorFactoryPrivate : public EditorFactoryPrivate { QtEnumEditorFactory *q_ptr; Q_DECLARE_PUBLIC(QtEnumEditorFactory) @@ -1892,19 +1970,36 @@ public: void slotEnumNamesChanged(QtProperty *property, const QStringList &); void slotEnumIconsChanged(QtProperty *property, const QMap &); void slotSetValue(int value); + void slotResetProperty(); }; +void QtEnumEditorFactoryPrivate::slotResetProperty() +{ + QObject *object = q_ptr->sender(); + const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); + for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtEnumPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + manager->emitResetProperty(property); + return; + } +} + void QtEnumEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, int value) { if (!m_createdEditors.contains(property)) return; - QListIterator itEditor(m_createdEditors[property]); + QListIterator itEditor(m_createdEditors[property]); while (itEditor.hasNext()) { - QComboBox *editor = itEditor.next(); - editor->blockSignals(true); - editor->setCurrentIndex(value); - editor->blockSignals(false); + QtEnumEditWidget *editor = itEditor.next(); + editor->setStateResetButton(property->isModified()); + editor->blockComboBoxSignals(true); + editor->setValue(value); + editor->blockComboBoxSignals(false); } } @@ -1920,17 +2015,17 @@ void QtEnumEditorFactoryPrivate::slotEnumNamesChanged(QtProperty *property, QMap enumIcons = manager->enumIcons(property); - QListIterator itEditor(m_createdEditors[property]); + QListIterator itEditor(m_createdEditors[property]); while (itEditor.hasNext()) { - QComboBox *editor = itEditor.next(); - editor->blockSignals(true); - editor->clear(); + QtEnumEditWidget *editor = itEditor.next(); + editor->blockComboBoxSignals(true); + editor->clearComboBox(); editor->addItems(enumNames); const int nameCount = enumNames.count(); for (int i = 0; i < nameCount; i++) editor->setItemIcon(i, enumIcons.value(i)); - editor->setCurrentIndex(manager->value(property)); - editor->blockSignals(false); + editor->setValue(manager->value(property)); + editor->blockComboBoxSignals(false); } } @@ -1945,23 +2040,23 @@ void QtEnumEditorFactoryPrivate::slotEnumIconsChanged(QtProperty *property, return; const QStringList enumNames = manager->enumNames(property); - QListIterator itEditor(m_createdEditors[property]); + QListIterator itEditor(m_createdEditors[property]); while (itEditor.hasNext()) { - QComboBox *editor = itEditor.next(); - editor->blockSignals(true); + QtEnumEditWidget *editor = itEditor.next(); + editor->blockComboBoxSignals(true); const int nameCount = enumNames.count(); for (int i = 0; i < nameCount; i++) editor->setItemIcon(i, enumIcons.value(i)); - editor->setCurrentIndex(manager->value(property)); - editor->blockSignals(false); + editor->setValue(manager->value(property)); + editor->blockComboBoxSignals(false); } } void QtEnumEditorFactoryPrivate::slotSetValue(int value) { QObject *object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); + for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtEnumPropertyManager *manager = q_ptr->propertyManager(property); @@ -2022,18 +2117,19 @@ void QtEnumEditorFactory::connectPropertyManager(QtEnumPropertyManager *manager) QWidget *QtEnumEditorFactory::createEditor(QtEnumPropertyManager *manager, QtProperty *property, QWidget *parent) { - QComboBox *editor = d_ptr->createEditor(property, parent); + QtEnumEditWidget *editor = d_ptr->createEditor(property, parent); editor->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); - editor->view()->setTextElideMode(Qt::ElideRight); QStringList enumNames = manager->enumNames(property); editor->addItems(enumNames); QMap enumIcons = manager->enumIcons(property); const int enumNamesCount = enumNames.count(); for (int i = 0; i < enumNamesCount; i++) editor->setItemIcon(i, enumIcons.value(i)); - editor->setCurrentIndex(manager->value(property)); + editor->setValue(manager->value(property)); + editor->setStateResetButton(property->isModified()); - connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int))); + connect(editor, SIGNAL(resetProperty()), this, SLOT(slotResetProperty())); + connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); return editor; diff --git a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h index 38489684e..fe47d5f16 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h +++ b/code/nel/tools/3d/object_viewer_qt/src/3rdparty/qtpropertybrowser/qteditorfactory.h @@ -186,7 +186,7 @@ private: Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool)) Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool)) Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) - Q_PRIVATE_SLOT(d_func(), void slotReset()) + Q_PRIVATE_SLOT(d_func(), void slotResetProperty()) }; class QtDoubleSpinBoxFactoryPrivate; @@ -374,6 +374,7 @@ private: const QMap &)) Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + Q_PRIVATE_SLOT(d_func(), void slotResetProperty()) }; class QtCursorEditorFactoryPrivate; From 7977b787f35af7e2b4e04b52ebee4a34595249dd Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 11 Jun 2012 00:41:02 +0300 Subject: [PATCH 084/747] Changed: #1302 Replaced VariantPropertyManager --- .../world_editor/property_editor_widget.cpp | 58 ++++++++++++++----- .../world_editor/property_editor_widget.h | 8 ++- 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp index c3b9a3ba6..5acfe413f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp @@ -37,22 +37,32 @@ PropertyEditorWidget::PropertyEditorWidget(QWidget *parent) { m_ui.setupUi(this); - m_variantManager = new QtVariantPropertyManager(this); + m_stringManager = new QtStringPropertyManager(this); + m_boolManager = new QtBoolPropertyManager(this); m_enumManager = new QtEnumPropertyManager(this); m_stringArrayManager = new QtTextPropertyManager(this); - connect(m_variantManager, SIGNAL(valueChanged(QtProperty *, const QVariant &)), - this, SLOT(valueChanged(QtProperty *, const QVariant &))); - - QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this); + QtLineEditFactory *lineEditFactory = new QtLineEditFactory(this); + QtCheckBoxFactory *boolFactory = new QtCheckBoxFactory(this); QtEnumEditorFactory *enumFactory = new QtEnumEditorFactory(this); QtTextEditorFactory *textFactory = new QtTextEditorFactory(this); - m_ui.treePropertyBrowser->setFactoryForManager(m_variantManager, variantFactory); + m_ui.treePropertyBrowser->setFactoryForManager(m_stringManager, lineEditFactory); + m_ui.treePropertyBrowser->setFactoryForManager(m_boolManager, boolFactory); m_ui.treePropertyBrowser->setFactoryForManager(m_enumManager, enumFactory); m_ui.treePropertyBrowser->setFactoryForManager(m_stringArrayManager, textFactory); m_groupManager = new QtGroupPropertyManager(this); + + connect(m_stringManager, SIGNAL(propertyChanged(QtProperty *)), this, SLOT(propertyChanged(QtProperty *))); + connect(m_boolManager, SIGNAL(propertyChanged(QtProperty *)), this, SLOT(propertyChanged(QtProperty *))); + connect(m_enumManager, SIGNAL(propertyChanged(QtProperty *)), this, SLOT(propertyChanged(QtProperty *))); + connect(m_stringArrayManager, SIGNAL(propertyChanged(QtProperty *)), this, SLOT(propertyChanged(QtProperty *))); + + connect(m_boolManager, SIGNAL(resetProperty(QtProperty *)), this, SLOT(resetProperty(QtProperty *))); + connect(m_stringManager, SIGNAL(resetProperty(QtProperty *)), this, SLOT(resetProperty(QtProperty *))); + connect(m_enumManager, SIGNAL(resetProperty(QtProperty *)), this, SLOT(resetProperty(QtProperty *))); + connect(m_stringArrayManager, SIGNAL(resetProperty(QtProperty *)), this, SLOT(resetProperty(QtProperty *))); } PropertyEditorWidget::~PropertyEditorWidget() @@ -71,6 +81,8 @@ void PropertyEditorWidget::updateSelection(Node *node) if ((node == 0) || (node->type() != Node::PrimitiveNodeType)) return; + blockSignalsOfProperties(true); + // The parameter list std::list parameterList; @@ -149,7 +161,6 @@ void PropertyEditorWidget::updateSelection(Node *node) else if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstStringArray) prop = addConstStringArrayProperty(ligoProperty, parameter, primitive); else - // hmn? prop = addBoolProperty(ligoProperty, parameter, primitive); // Default value ? @@ -166,6 +177,18 @@ void PropertyEditorWidget::updateSelection(Node *node) ite++; } + + blockSignalsOfProperties(false); +} + +void PropertyEditorWidget::propertyChanged(QtProperty *property) +{ + nlinfo(QString("property %1 changed").arg(property->propertyName()).toStdString().c_str()); +} + +void PropertyEditorWidget::resetProperty(QtProperty *property) +{ + nlinfo(QString("property %1 reset").arg(property->propertyName()).toStdString().c_str()); } QtProperty *PropertyEditorWidget::addBoolProperty(const NLLIGO::IProperty *property, @@ -175,11 +198,11 @@ QtProperty *PropertyEditorWidget::addBoolProperty(const NLLIGO::IProperty *prope std::string value; std::string name = parameter.Name.c_str(); primitive->getPropertyByName(name.c_str(), value); - QtVariantProperty *prop = m_variantManager->addProperty(QVariant::Bool, name.c_str()); + QtProperty *prop = m_boolManager->addProperty(name.c_str()); // if (Default) { //DialogProperties->setDefaultValue (this, value); - prop->setValue(bool((value=="true")?1:0)); + m_boolManager->setValue(prop, bool((value=="true")?1:0)); } return prop; } @@ -242,7 +265,7 @@ QtProperty *PropertyEditorWidget::addConstStringProperty(const NLLIGO::IProperty if (listEnums.isEmpty()) { - listEnums << tr("WRN: Check leveldesign!"); + listEnums << QString(value.c_str()) + tr(" (WRN: Check leveldesign!)"); m_enumManager->setEnumNames(prop, listEnums); m_enumManager->setValue(prop, 0); prop->setEnabled(false); @@ -273,8 +296,8 @@ QtProperty *PropertyEditorWidget::addStringProperty(const NLLIGO::IProperty *pro std::string value; std::string name = parameter.Name.c_str(); primitive->getPropertyByName(name.c_str(), value); - QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str()); - prop->setValue(QString(value.c_str())); + QtProperty *prop = m_stringManager->addProperty(parameter.Name.c_str()); + m_stringManager->setValue(prop, QString(value.c_str())); return prop; } @@ -320,10 +343,17 @@ QtProperty *PropertyEditorWidget::addConstStringArrayProperty(const NLLIGO::IPro const NLLIGO::IPrimitive *primitive) { std::string name = parameter.Name.c_str(); - QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str()); - prop->setValue("TODO: ConstStringArray"); + QtProperty *prop = m_stringManager->addProperty(parameter.Name.c_str()); + m_stringManager->setValue(prop, "TODO: ConstStringArray"); prop->setEnabled(false); return prop; } +void PropertyEditorWidget::blockSignalsOfProperties(bool block) +{ + m_stringManager->blockSignals(block); + m_boolManager->blockSignals(block); + m_enumManager->blockSignals(block); + m_stringArrayManager->blockSignals(block); +} } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h index a4ccf9d5f..a9055b5af 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h @@ -54,6 +54,9 @@ public Q_SLOTS: /// Update of selections void updateSelection(Node *node); + void propertyChanged(QtProperty *property); + void resetProperty(QtProperty *property); + private: QtProperty *addBoolProperty(const NLLIGO::IProperty *property, const NLLIGO::CPrimitiveClass::CParameter ¶meter, @@ -71,7 +74,10 @@ private: const NLLIGO::CPrimitiveClass::CParameter ¶meter, const NLLIGO::IPrimitive *primitive); - QtVariantPropertyManager *m_variantManager; + void blockSignalsOfProperties(bool block); + + QtBoolPropertyManager *m_boolManager; + QtStringPropertyManager *m_stringManager; QtEnumPropertyManager *m_enumManager; QtGroupPropertyManager *m_groupManager; QtTextPropertyManager *m_stringArrayManager; From 8795d4bfa2de7620575feb03e7144894d11e4930 Mon Sep 17 00:00:00 2001 From: Matthew Lagoe Date: Tue, 17 Jul 2012 02:48:44 -0700 Subject: [PATCH 085/747] maxlen fix for password and username, also fixed 255 maxlen in email 254 is real max --- .../data/gamedev/interfaces_v3/login_main.xml | 1674 ++++++++--------- 1 file changed, 837 insertions(+), 837 deletions(-) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml b/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml index f6dab0c1e..4b8ebd3a5 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml @@ -1,837 +1,837 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +

Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}

+ +{if !empty($template_data)} +

included templates & config files (load time in seconds)

+ +
+{foreach $template_data as $template} + {$template.name} + + (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}) + +
+{/foreach} +
+{/if} + +

assigned template variables

+ + + {foreach $assigned_vars as $vars} + + + + {/foreach} +
${$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
+ +

assigned config file variables (outer template scope)

+ + + {foreach $config_vars as $vars} + + + + {/foreach} + +
{$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
+ + +{/capture} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/block.textformat.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/block.textformat.php new file mode 100644 index 000000000..b22b104a5 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/block.textformat.php @@ -0,0 +1,113 @@ + + * Name: textformat
+ * Purpose: format text a certain way with preset styles + * or custom wrap/indent settings
+ * Params: + *
+ * - style         - string (email)
+ * - indent        - integer (0)
+ * - wrap          - integer (80)
+ * - wrap_char     - string ("\n")
+ * - indent_char   - string (" ")
+ * - wrap_boundary - boolean (true)
+ * 
+ * + * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} + * (Smarty online manual) + * @param array $params parameters + * @param string $content contents of the block + * @param Smarty_Internal_Template $template template object + * @param boolean &$repeat repeat flag + * @return string content re-formatted + * @author Monte Ohrt + */ +function smarty_block_textformat($params, $content, $template, &$repeat) +{ + if (is_null($content)) { + return; + } + + $style = null; + $indent = 0; + $indent_first = 0; + $indent_char = ' '; + $wrap = 80; + $wrap_char = "\n"; + $wrap_cut = false; + $assign = null; + + foreach ($params as $_key => $_val) { + switch ($_key) { + case 'style': + case 'indent_char': + case 'wrap_char': + case 'assign': + $$_key = (string)$_val; + break; + + case 'indent': + case 'indent_first': + case 'wrap': + $$_key = (int)$_val; + break; + + case 'wrap_cut': + $$_key = (bool)$_val; + break; + + default: + trigger_error("textformat: unknown attribute '$_key'"); + } + } + + if ($style == 'email') { + $wrap = 72; + } + // split into paragraphs + $_paragraphs = preg_split('![\r\n]{2}!', $content); + $_output = ''; + + + foreach ($_paragraphs as &$_paragraph) { + if (!$_paragraph) { + continue; + } + // convert mult. spaces & special chars to single space + $_paragraph = preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), array(' ', ''), $_paragraph); + // indent first line + if ($indent_first > 0) { + $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph; + } + // wordwrap sentences + if (Smarty::$_MBSTRING) { + require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'); + $_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); + } else { + $_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); + } + // indent lines + if ($indent > 0) { + $_paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraph); + } + } + $_output = implode($wrap_char . $wrap_char, $_paragraphs); + + if ($assign) { + $template->assign($assign, $_output); + } else { + return $_output; + } +} + +?> \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.counter.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.counter.php new file mode 100644 index 000000000..3906badf0 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.counter.php @@ -0,0 +1,78 @@ + + * Name: counter
+ * Purpose: print out a counter value + * + * @author Monte Ohrt + * @link http://www.smarty.net/manual/en/language.function.counter.php {counter} + * (Smarty online manual) + * @param array $params parameters + * @param Smarty_Internal_Template $template template object + * @return string|null + */ +function smarty_function_counter($params, $template) +{ + static $counters = array(); + + $name = (isset($params['name'])) ? $params['name'] : 'default'; + if (!isset($counters[$name])) { + $counters[$name] = array( + 'start'=>1, + 'skip'=>1, + 'direction'=>'up', + 'count'=>1 + ); + } + $counter =& $counters[$name]; + + if (isset($params['start'])) { + $counter['start'] = $counter['count'] = (int)$params['start']; + } + + if (!empty($params['assign'])) { + $counter['assign'] = $params['assign']; + } + + if (isset($counter['assign'])) { + $template->assign($counter['assign'], $counter['count']); + } + + if (isset($params['print'])) { + $print = (bool)$params['print']; + } else { + $print = empty($counter['assign']); + } + + if ($print) { + $retval = $counter['count']; + } else { + $retval = null; + } + + if (isset($params['skip'])) { + $counter['skip'] = $params['skip']; + } + + if (isset($params['direction'])) { + $counter['direction'] = $params['direction']; + } + + if ($counter['direction'] == "down") + $counter['count'] -= $counter['skip']; + else + $counter['count'] += $counter['skip']; + + return $retval; + +} + +?> \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.cycle.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.cycle.php new file mode 100644 index 000000000..1778ffb53 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.cycle.php @@ -0,0 +1,106 @@ + + * Name: cycle
+ * Date: May 3, 2002
+ * Purpose: cycle through given values
+ * Params: + *
+ * - name      - name of cycle (optional)
+ * - values    - comma separated list of values to cycle, or an array of values to cycle
+ *               (this can be left out for subsequent calls)
+ * - reset     - boolean - resets given var to true
+ * - print     - boolean - print var or not. default is true
+ * - advance   - boolean - whether or not to advance the cycle
+ * - delimiter - the value delimiter, default is ","
+ * - assign    - boolean, assigns to template var instead of printed.
+ * 
+ * Examples:
+ *
+ * {cycle values="#eeeeee,#d0d0d0d"}
+ * {cycle name=row values="one,two,three" reset=true}
+ * {cycle name=row}
+ * 
+ * + * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle} + * (Smarty online manual) + * @author Monte Ohrt + * @author credit to Mark Priatel + * @author credit to Gerard + * @author credit to Jason Sweat + * @version 1.3 + * @param array $params parameters + * @param Smarty_Internal_Template $template template object + * @return string|null + */ + +function smarty_function_cycle($params, $template) +{ + static $cycle_vars; + + $name = (empty($params['name'])) ? 'default' : $params['name']; + $print = (isset($params['print'])) ? (bool)$params['print'] : true; + $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true; + $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false; + + if (!isset($params['values'])) { + if(!isset($cycle_vars[$name]['values'])) { + trigger_error("cycle: missing 'values' parameter"); + return; + } + } else { + if(isset($cycle_vars[$name]['values']) + && $cycle_vars[$name]['values'] != $params['values'] ) { + $cycle_vars[$name]['index'] = 0; + } + $cycle_vars[$name]['values'] = $params['values']; + } + + if (isset($params['delimiter'])) { + $cycle_vars[$name]['delimiter'] = $params['delimiter']; + } elseif (!isset($cycle_vars[$name]['delimiter'])) { + $cycle_vars[$name]['delimiter'] = ','; + } + + if(is_array($cycle_vars[$name]['values'])) { + $cycle_array = $cycle_vars[$name]['values']; + } else { + $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']); + } + + if(!isset($cycle_vars[$name]['index']) || $reset ) { + $cycle_vars[$name]['index'] = 0; + } + + if (isset($params['assign'])) { + $print = false; + $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); + } + + if($print) { + $retval = $cycle_array[$cycle_vars[$name]['index']]; + } else { + $retval = null; + } + + if($advance) { + if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) { + $cycle_vars[$name]['index'] = 0; + } else { + $cycle_vars[$name]['index']++; + } + } + + return $retval; +} + +?> \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.fetch.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.fetch.php new file mode 100644 index 000000000..eca1182d5 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.fetch.php @@ -0,0 +1,214 @@ + + * Name: fetch
+ * Purpose: fetch file, web or ftp data and display results + * + * @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch} + * (Smarty online manual) + * @author Monte Ohrt + * @param array $params parameters + * @param Smarty_Internal_Template $template template object + * @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable + */ +function smarty_function_fetch($params, $template) +{ + if (empty($params['file'])) { + trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE); + return; + } + + // strip file protocol + if (stripos($params['file'], 'file://') === 0) { + $params['file'] = substr($params['file'], 7); + } + + $protocol = strpos($params['file'], '://'); + if ($protocol !== false) { + $protocol = strtolower(substr($params['file'], 0, $protocol)); + } + + if (isset($template->smarty->security_policy)) { + if ($protocol) { + // remote resource (or php stream, …) + if(!$template->smarty->security_policy->isTrustedUri($params['file'])) { + return; + } + } else { + // local file + if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { + return; + } + } + } + + $content = ''; + if ($protocol == 'http') { + // http fetch + if($uri_parts = parse_url($params['file'])) { + // set defaults + $host = $server_name = $uri_parts['host']; + $timeout = 30; + $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; + $agent = "Smarty Template Engine ". Smarty::SMARTY_VERSION; + $referer = ""; + $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; + $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; + $_is_proxy = false; + if(empty($uri_parts['port'])) { + $port = 80; + } else { + $port = $uri_parts['port']; + } + if(!empty($uri_parts['user'])) { + $user = $uri_parts['user']; + } + if(!empty($uri_parts['pass'])) { + $pass = $uri_parts['pass']; + } + // loop through parameters, setup headers + foreach($params as $param_key => $param_value) { + switch($param_key) { + case "file": + case "assign": + case "assign_headers": + break; + case "user": + if(!empty($param_value)) { + $user = $param_value; + } + break; + case "pass": + if(!empty($param_value)) { + $pass = $param_value; + } + break; + case "accept": + if(!empty($param_value)) { + $accept = $param_value; + } + break; + case "header": + if(!empty($param_value)) { + if(!preg_match('![\w\d-]+: .+!',$param_value)) { + trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE); + return; + } else { + $extra_headers[] = $param_value; + } + } + break; + case "proxy_host": + if(!empty($param_value)) { + $proxy_host = $param_value; + } + break; + case "proxy_port": + if(!preg_match('!\D!', $param_value)) { + $proxy_port = (int) $param_value; + } else { + trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); + return; + } + break; + case "agent": + if(!empty($param_value)) { + $agent = $param_value; + } + break; + case "referer": + if(!empty($param_value)) { + $referer = $param_value; + } + break; + case "timeout": + if(!preg_match('!\D!', $param_value)) { + $timeout = (int) $param_value; + } else { + trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); + return; + } + break; + default: + trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE); + return; + } + } + if(!empty($proxy_host) && !empty($proxy_port)) { + $_is_proxy = true; + $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); + } else { + $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); + } + + if(!$fp) { + trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE); + return; + } else { + if($_is_proxy) { + fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); + } else { + fputs($fp, "GET $uri HTTP/1.0\r\n"); + } + if(!empty($host)) { + fputs($fp, "Host: $host\r\n"); + } + if(!empty($accept)) { + fputs($fp, "Accept: $accept\r\n"); + } + if(!empty($agent)) { + fputs($fp, "User-Agent: $agent\r\n"); + } + if(!empty($referer)) { + fputs($fp, "Referer: $referer\r\n"); + } + if(isset($extra_headers) && is_array($extra_headers)) { + foreach($extra_headers as $curr_header) { + fputs($fp, $curr_header."\r\n"); + } + } + if(!empty($user) && !empty($pass)) { + fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n"); + } + + fputs($fp, "\r\n"); + while(!feof($fp)) { + $content .= fgets($fp,4096); + } + fclose($fp); + $csplit = preg_split("!\r\n\r\n!",$content,2); + + $content = $csplit[1]; + + if(!empty($params['assign_headers'])) { + $template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0])); + } + } + } else { + trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE); + return; + } + } else { + $content = @file_get_contents($params['file']); + if ($content === false) { + throw new SmartyException("{fetch} cannot read resource '" . $params['file'] ."'"); + } + } + + if (!empty($params['assign'])) { + $template->assign($params['assign'], $content); + } else { + return $content; + } +} + +?> \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.html_checkboxes.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.html_checkboxes.php new file mode 100644 index 000000000..1866bc2f3 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.html_checkboxes.php @@ -0,0 +1,233 @@ + + * Type: function
+ * Name: html_checkboxes
+ * Date: 24.Feb.2003
+ * Purpose: Prints out a list of checkbox input types
+ * Examples: + *
+ * {html_checkboxes values=$ids output=$names}
+ * {html_checkboxes values=$ids name='box' separator='
' output=$names} + * {html_checkboxes values=$ids checked=$checked separator='
' output=$names} + *
+ * Params: + *
+ * - name       (optional) - string default "checkbox"
+ * - values     (required) - array
+ * - options    (optional) - associative array
+ * - checked    (optional) - array default not set
+ * - separator  (optional) - ie 
or   + * - output (optional) - the output next to each checkbox + * - assign (optional) - assign the output as an array to this variable + * - escape (optional) - escape the content (not value), defaults to true + *
+ * + * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} + * (Smarty online manual) + * @author Christopher Kvarme + * @author credits to Monte Ohrt + * @version 1.0 + * @param array $params parameters + * @param object $template template object + * @return string + * @uses smarty_function_escape_special_chars() + */ +function smarty_function_html_checkboxes($params, $template) +{ + require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); + + $name = 'checkbox'; + $values = null; + $options = null; + $selected = array(); + $separator = ''; + $escape = true; + $labels = true; + $label_ids = false; + $output = null; + + $extra = ''; + + foreach($params as $_key => $_val) { + switch($_key) { + case 'name': + case 'separator': + $$_key = (string) $_val; + break; + + case 'escape': + case 'labels': + case 'label_ids': + $$_key = (bool) $_val; + break; + + case 'options': + $$_key = (array) $_val; + break; + + case 'values': + case 'output': + $$_key = array_values((array) $_val); + break; + + case 'checked': + case 'selected': + if (is_array($_val)) { + $selected = array(); + foreach ($_val as $_sel) { + if (is_object($_sel)) { + if (method_exists($_sel, "__toString")) { + $_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); + } else { + trigger_error("html_checkboxes: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE); + continue; + } + } else { + $_sel = smarty_function_escape_special_chars((string) $_sel); + } + $selected[$_sel] = true; + } + } elseif (is_object($_val)) { + if (method_exists($_val, "__toString")) { + $selected = smarty_function_escape_special_chars((string) $_val->__toString()); + } else { + trigger_error("html_checkboxes: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE); + } + } else { + $selected = smarty_function_escape_special_chars((string) $_val); + } + break; + + case 'checkboxes': + trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING); + $options = (array) $_val; + break; + + case 'assign': + break; + + case 'strict': break; + + case 'disabled': + case 'readonly': + if (!empty($params['strict'])) { + if (!is_scalar($_val)) { + trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE); + } + + if ($_val === true || $_val === $_key) { + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; + } + + break; + } + // omit break; to fall through! + + default: + if(!is_array($_val)) { + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + } else { + trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; + } + } + + if (!isset($options) && !isset($values)) + return ''; /* raise error here? */ + + $_html_result = array(); + + if (isset($options)) { + foreach ($options as $_key=>$_val) { + $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); + } + } else { + foreach ($values as $_i=>$_key) { + $_val = isset($output[$_i]) ? $output[$_i] : ''; + $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); + } + } + + if(!empty($params['assign'])) { + $template->assign($params['assign'], $_html_result); + } else { + return implode("\n", $_html_result); + } + +} + +function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape=true) { + $_output = ''; + + if (is_object($value)) { + if (method_exists($value, "__toString")) { + $value = (string) $value->__toString(); + } else { + trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); + return ''; + } + } else { + $value = (string) $value; + } + + if (is_object($output)) { + if (method_exists($output, "__toString")) { + $output = (string) $output->__toString(); + } else { + trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); + return ''; + } + } else { + $output = (string) $output; + } + + if ($labels) { + if ($label_ids) { + $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value)); + $_output .= '
'; + $suffix = ''; + break; + + default: + if (!is_array($_val)) { + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; + } else { + throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; + } + } + + if (empty($file)) { + trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); + return; + } + + if ($file[0] == '/') { + $_image_path = $basedir . $file; + } else { + $_image_path = $file; + } + + // strip file protocol + if (stripos($params['file'], 'file://') === 0) { + $params['file'] = substr($params['file'], 7); + } + + $protocol = strpos($params['file'], '://'); + if ($protocol !== false) { + $protocol = strtolower(substr($params['file'], 0, $protocol)); + } + + if (isset($template->smarty->security_policy)) { + if ($protocol) { + // remote resource (or php stream, …) + if(!$template->smarty->security_policy->isTrustedUri($params['file'])) { + return; + } + } else { + // local file + if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { + return; + } + } + } + + if (!isset($params['width']) || !isset($params['height'])) { + // FIXME: (rodneyrehm) getimagesize() loads the complete file off a remote resource, use custom [jpg,png,gif]header reader! + if (!$_image_data = @getimagesize($_image_path)) { + if (!file_exists($_image_path)) { + trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); + return; + } else if (!is_readable($_image_path)) { + trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); + return; + } else { + trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); + return; + } + } + + if (!isset($params['width'])) { + $width = $_image_data[0]; + } + if (!isset($params['height'])) { + $height = $_image_data[1]; + } + } + + if (isset($params['dpi'])) { + if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) { + // FIXME: (rodneyrehm) wrong dpi assumption + // don't know who thought this up… even if it was true in 1998, it's definitely wrong in 2011. + $dpi_default = 72; + } else { + $dpi_default = 96; + } + $_resize = $dpi_default / $params['dpi']; + $width = round($width * $_resize); + $height = round($height * $_resize); + } + + return $prefix . '' . $alt . '' . $suffix; +} + +?> \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.html_options.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.html_options.php new file mode 100644 index 000000000..68fa0524a --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/smarty/libs/plugins/function.html_options.php @@ -0,0 +1,193 @@ + + * Name: html_options
+ * Purpose: Prints the list of