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("Don’t 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;