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