@@ -1081,10 +1081,9 @@ void ShapeAnnotation::applyRotation(qreal angle)
1081
1081
if (angle == 360 ) {
1082
1082
angle = 0 ;
1083
1083
}
1084
+ Transformation oldTransformation = mTransformation ;
1084
1085
mTransformation .setRotateAngle (angle);
1085
- setTransform (mTransformation .getTransformationMatrix ());
1086
- mRotation = angle;
1087
- mpGraphicsView->setAddClassAnnotationNeeded (true );
1086
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1088
1087
}
1089
1088
1090
1089
/* !
@@ -1430,7 +1429,10 @@ void ShapeAnnotation::sendBackward()
1430
1429
*/
1431
1430
void ShapeAnnotation::rotateClockwise ()
1432
1431
{
1433
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new RotateShapeCommand (this , true ));
1432
+ qreal oldRotation = StringHandler::getNormalizedAngle (mTransformation .getRotateAngle ());
1433
+ qreal rotateIncrement = -90 ;
1434
+ qreal angle = oldRotation + rotateIncrement;
1435
+ applyRotation (angle);
1434
1436
}
1435
1437
1436
1438
/* !
@@ -1440,7 +1442,10 @@ void ShapeAnnotation::rotateClockwise()
1440
1442
*/
1441
1443
void ShapeAnnotation::rotateAntiClockwise ()
1442
1444
{
1443
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new RotateShapeCommand (this , false ));
1445
+ qreal oldRotation = StringHandler::getNormalizedAngle (mTransformation .getRotateAngle ());
1446
+ qreal rotateIncrement = 90 ;
1447
+ qreal angle = oldRotation + rotateIncrement;
1448
+ applyRotation (angle);
1444
1449
}
1445
1450
1446
1451
/* !
@@ -1451,8 +1456,9 @@ void ShapeAnnotation::rotateAntiClockwise()
1451
1456
*/
1452
1457
void ShapeAnnotation::moveUp ()
1453
1458
{
1454
- qreal y = mpGraphicsView->getCoOrdinateSystem ()->getVerticalGridStep ();
1455
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , 0 , y, mpGraphicsView));
1459
+ Transformation oldTransformation = mTransformation ;
1460
+ mTransformation .adjustPosition (0 , mpGraphicsView->getCoOrdinateSystem ()->getVerticalGridStep ());
1461
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1456
1462
}
1457
1463
1458
1464
/* !
@@ -1463,8 +1469,9 @@ void ShapeAnnotation::moveUp()
1463
1469
*/
1464
1470
void ShapeAnnotation::moveShiftUp ()
1465
1471
{
1466
- qreal y = mpGraphicsView->getCoOrdinateSystem ()->getVerticalGridStep () * 5 ;
1467
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , 0 , y, mpGraphicsView));
1472
+ Transformation oldTransformation = mTransformation ;
1473
+ mTransformation .adjustPosition (0 , mpGraphicsView->getCoOrdinateSystem ()->getVerticalGridStep () * 5 );
1474
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1468
1475
}
1469
1476
1470
1477
/* !
@@ -1475,7 +1482,9 @@ void ShapeAnnotation::moveShiftUp()
1475
1482
*/
1476
1483
void ShapeAnnotation::moveCtrlUp ()
1477
1484
{
1478
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , 0 , 1 , mpGraphicsView));
1485
+ Transformation oldTransformation = mTransformation ;
1486
+ mTransformation .adjustPosition (0 , 1 );
1487
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1479
1488
}
1480
1489
1481
1490
/* !
@@ -1486,8 +1495,9 @@ void ShapeAnnotation::moveCtrlUp()
1486
1495
*/
1487
1496
void ShapeAnnotation::moveDown ()
1488
1497
{
1489
- qreal y = -mpGraphicsView->getCoOrdinateSystem ()->getVerticalGridStep ();
1490
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , 0 , y, mpGraphicsView));
1498
+ Transformation oldTransformation = mTransformation ;
1499
+ mTransformation .adjustPosition (0 , -mpGraphicsView->getCoOrdinateSystem ()->getVerticalGridStep ());
1500
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1491
1501
}
1492
1502
1493
1503
/* !
@@ -1498,8 +1508,9 @@ void ShapeAnnotation::moveDown()
1498
1508
*/
1499
1509
void ShapeAnnotation::moveShiftDown ()
1500
1510
{
1501
- qreal y = -(mpGraphicsView->getCoOrdinateSystem ()->getVerticalGridStep () * 5 );
1502
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , 0 , y, mpGraphicsView));
1511
+ Transformation oldTransformation = mTransformation ;
1512
+ mTransformation .adjustPosition (0 , -(mpGraphicsView->getCoOrdinateSystem ()->getVerticalGridStep () * 5 ));
1513
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1503
1514
}
1504
1515
1505
1516
/* !
@@ -1510,7 +1521,9 @@ void ShapeAnnotation::moveShiftDown()
1510
1521
*/
1511
1522
void ShapeAnnotation::moveCtrlDown ()
1512
1523
{
1513
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , 0 , -1 , mpGraphicsView));
1524
+ Transformation oldTransformation = mTransformation ;
1525
+ mTransformation .adjustPosition (0 , -1 );
1526
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1514
1527
}
1515
1528
1516
1529
/* !
@@ -1521,8 +1534,9 @@ void ShapeAnnotation::moveCtrlDown()
1521
1534
*/
1522
1535
void ShapeAnnotation::moveLeft ()
1523
1536
{
1524
- qreal x = -mpGraphicsView->getCoOrdinateSystem ()->getHorizontalGridStep ();
1525
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , x, 0 , mpGraphicsView));
1537
+ Transformation oldTransformation = mTransformation ;
1538
+ mTransformation .adjustPosition (-mpGraphicsView->getCoOrdinateSystem ()->getHorizontalGridStep (), 0 );
1539
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1526
1540
}
1527
1541
1528
1542
/* !
@@ -1533,8 +1547,9 @@ void ShapeAnnotation::moveLeft()
1533
1547
*/
1534
1548
void ShapeAnnotation::moveShiftLeft ()
1535
1549
{
1536
- qreal x = -(mpGraphicsView->getCoOrdinateSystem ()->getHorizontalGridStep () * 5 );
1537
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , x, 0 , mpGraphicsView));
1550
+ Transformation oldTransformation = mTransformation ;
1551
+ mTransformation .adjustPosition (-(mpGraphicsView->getCoOrdinateSystem ()->getHorizontalGridStep () * 5 ), 0 );
1552
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1538
1553
}
1539
1554
1540
1555
/* !
@@ -1545,7 +1560,9 @@ void ShapeAnnotation::moveShiftLeft()
1545
1560
*/
1546
1561
void ShapeAnnotation::moveCtrlLeft ()
1547
1562
{
1548
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , -1 , 0 , mpGraphicsView));
1563
+ Transformation oldTransformation = mTransformation ;
1564
+ mTransformation .adjustPosition (-1 , 0 );
1565
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1549
1566
}
1550
1567
1551
1568
/* !
@@ -1556,8 +1573,9 @@ void ShapeAnnotation::moveCtrlLeft()
1556
1573
*/
1557
1574
void ShapeAnnotation::moveRight ()
1558
1575
{
1559
- qreal x = mpGraphicsView->getCoOrdinateSystem ()->getHorizontalGridStep ();
1560
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , x, 0 , mpGraphicsView));
1576
+ Transformation oldTransformation = mTransformation ;
1577
+ mTransformation .adjustPosition (mpGraphicsView->getCoOrdinateSystem ()->getHorizontalGridStep (), 0 );
1578
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1561
1579
}
1562
1580
1563
1581
/* !
@@ -1568,8 +1586,9 @@ void ShapeAnnotation::moveRight()
1568
1586
*/
1569
1587
void ShapeAnnotation::moveShiftRight ()
1570
1588
{
1571
- qreal x = mpGraphicsView->getCoOrdinateSystem ()->getHorizontalGridStep () * 5 ;
1572
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , x, 0 , mpGraphicsView));
1589
+ Transformation oldTransformation = mTransformation ;
1590
+ mTransformation .adjustPosition (mpGraphicsView->getCoOrdinateSystem ()->getHorizontalGridStep () * 5 , 0 );
1591
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1573
1592
}
1574
1593
1575
1594
/* !
@@ -1580,7 +1599,9 @@ void ShapeAnnotation::moveShiftRight()
1580
1599
*/
1581
1600
void ShapeAnnotation::moveCtrlRight ()
1582
1601
{
1583
- mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new MoveShapeKeyCommand (this , 1 , 0 , mpGraphicsView));
1602
+ Transformation oldTransformation = mTransformation ;
1603
+ mTransformation .adjustPosition (1 , 0 );
1604
+ mpGraphicsView->getModelWidget ()->getUndoStack ()->push (new UpdateShapeCommand (this , oldTransformation, mTransformation , mpGraphicsView));
1584
1605
}
1585
1606
1586
1607
/* !
0 commit comments