mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 17:29:10 +00:00
Fixed: #1302 Fixed undo/redo zoom items.
This commit is contained in:
parent
bd39049113
commit
db21862937
2 changed files with 6 additions and 7 deletions
|
@ -160,6 +160,7 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
case WorldEditorScene::RotateMode:
|
case WorldEditorScene::RotateMode:
|
||||||
break;
|
break;
|
||||||
case WorldEditorScene::ScaleMode:
|
case WorldEditorScene::ScaleMode:
|
||||||
|
m_scaleFactor = QPointF(1.0, 1.0);
|
||||||
break;
|
break;
|
||||||
case WorldEditorScene::TurnMode:
|
case WorldEditorScene::TurnMode:
|
||||||
break;
|
break;
|
||||||
|
@ -223,6 +224,9 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
else
|
else
|
||||||
offset.setY(1.0 / (1.0 + (offset.y() / 5000)));
|
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)
|
Q_FOREACH(QGraphicsItem *item, m_selectedItems)
|
||||||
{
|
{
|
||||||
qgraphicsitem_cast<AbstractWorldItem *>(item)->scaleOn(pivot, offset);
|
qgraphicsitem_cast<AbstractWorldItem *>(item)->scaleOn(pivot, offset);
|
||||||
|
@ -282,13 +286,8 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
case WorldEditorScene::ScaleMode:
|
case WorldEditorScene::ScaleMode:
|
||||||
{
|
{
|
||||||
QPointF pivot = calcBoundingRect(m_selectedItems).center();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case WorldEditorScene::TurnMode:
|
case WorldEditorScene::TurnMode:
|
||||||
|
|
|
@ -85,7 +85,7 @@ private:
|
||||||
QPen m_pen1, m_pen2;
|
QPen m_pen1, m_pen2;
|
||||||
QBrush m_brush1, m_brush2;
|
QBrush m_brush1, m_brush2;
|
||||||
|
|
||||||
QPointF m_firstPick;
|
QPointF m_firstPick, m_scaleFactor;
|
||||||
QRectF m_selectionArea;
|
QRectF m_selectionArea;
|
||||||
qreal m_firstPickX, m_firstPickY;
|
qreal m_firstPickX, m_firstPickY;
|
||||||
QList<QGraphicsItem *> m_selectedItems;
|
QList<QGraphicsItem *> m_selectedItems;
|
||||||
|
|
Loading…
Reference in a new issue