From b93f59ae1051721a2e15a3b01f68e47fe5b9fc5d Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 9 Aug 2011 23:31:14 +0300 Subject: [PATCH] Changed: #1302 Landscape scene works correctly in world editor plugin. Replaced dynamic_cast on more faster qgraphicsitem_cast. --HG-- branch : gsoc2011-worldeditorqt --- .../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