From a41a662edbc16c03f5ec0e04a1f3714b9f2b909a Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 2 Aug 2011 16:10:12 +0300 Subject: [PATCH] Changed: #1301 Improved ZoneBuilderBase for using in undo/redo commands. --HG-- branch : gsoc2011-worldeditorqt --- .../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)