From 9e3fd003d6877bbe5665adc041b64dbcd33da983 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 8 Aug 2011 21:59:09 +0300 Subject: [PATCH] Changed: #1302 Landscape scene works correctly in world editor plugin. --HG-- branch : gsoc2011-worldeditorqt --- .../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; }