From db2186293701f7542c74f3bc7e8e6d4c9f0facfc Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 11 Aug 2011 14:05:06 +0300 Subject: [PATCH] Fixed: #1302 Fixed undo/redo zoom items. --- .../src/plugins/world_editor/world_editor_scene.cpp | 11 +++++------ .../src/plugins/world_editor/world_editor_scene.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) 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 f722bea25..6fba9f628 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 @@ -160,6 +160,7 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) case WorldEditorScene::RotateMode: break; case WorldEditorScene::ScaleMode: + m_scaleFactor = QPointF(1.0, 1.0); break; case WorldEditorScene::TurnMode: break; @@ -223,6 +224,9 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) else offset.setY(1.0 / (1.0 + (offset.y() / 5000))); + m_scaleFactor.setX(offset.x() * m_scaleFactor.x()); + m_scaleFactor.setY(offset.y() * m_scaleFactor.y()); + Q_FOREACH(QGraphicsItem *item, m_selectedItems) { qgraphicsitem_cast(item)->scaleOn(pivot, offset); @@ -282,13 +286,8 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) case WorldEditorScene::ScaleMode: { QPointF pivot = calcBoundingRect(m_selectedItems).center(); - QPointF offset = mouseEvent->scenePos() - m_firstPick; + m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, pivot, m_model)); - // Calculate scale factor - offset.setX(1.0 + (offset.x() / 5000)); - offset.setY(1.0 + (-offset.y() / 5000)); - - m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, offset, pivot, m_model)); break; } case WorldEditorScene::TurnMode: 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 defd59651..408ba99b6 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 @@ -85,7 +85,7 @@ private: QPen m_pen1, m_pen2; QBrush m_brush1, m_brush2; - QPointF m_firstPick; + QPointF m_firstPick, m_scaleFactor; QRectF m_selectionArea; qreal m_firstPickX, m_firstPickY; QList m_selectedItems;