@@ -1378,42 +1378,44 @@ void ShapeAnnotation::updateCornerItemPoint(int index, QPointF point)
13781378 if (dynamic_cast <LineAnnotation*>(this )) {
13791379 LineAnnotation *pLineAnnotation = dynamic_cast <LineAnnotation*>(this );
13801380 if (pLineAnnotation->getLineType () == LineAnnotation::ConnectionType) {
1381- // if moving the 2nd last point then we need to add more points after it to keep the last point manhattanized with connector
1382- int secondLastIndex = mPoints .size () - 2 ;
1383- if (index == secondLastIndex) {
1384- // just check if additional points are really needed or not.
1385- if ((mGeometries [secondLastIndex] == ShapeAnnotation::HorizontalLine && mPoints [index].y () != point.y ()) ||
1386- (mGeometries [secondLastIndex] == ShapeAnnotation::VerticalLine && mPoints [index].x () != point.x ())) {
1387- insertPointsGeometriesAndCornerItems (mPoints .size () - 1 );
1381+ if (mPoints .size () > index) {
1382+ // if moving the 2nd last point then we need to add more points after it to keep the last point manhattanized with connector
1383+ int secondLastIndex = mPoints .size () - 2 ;
1384+ if (index == secondLastIndex) {
1385+ // just check if additional points are really needed or not.
1386+ if ((mGeometries [secondLastIndex] == ShapeAnnotation::HorizontalLine && mPoints [index].y () != point.y ()) ||
1387+ (mGeometries [secondLastIndex] == ShapeAnnotation::VerticalLine && mPoints [index].x () != point.x ())) {
1388+ insertPointsGeometriesAndCornerItems (mPoints .size () - 1 );
1389+ }
13881390 }
1389- }
1390- // if moving the 2nd point then we need to add more points behind it to keep the first point manhattanized with connector
1391- if (index == 1 ) {
1392- // just check if additional points are really needed or not.
1393- if ((mGeometries [0 ] == ShapeAnnotation::HorizontalLine && mPoints [index].y () != point.y ()) ||
1394- (mGeometries [0 ] == ShapeAnnotation::VerticalLine && mPoints [index].x () != point.x ())) {
1395- insertPointsGeometriesAndCornerItems (1 );
1396- index = index + 2 ;
1391+ // if moving the 2nd point then we need to add more points behind it to keep the first point manhattanized with connector
1392+ if (index == 1 ) {
1393+ // just check if additional points are really needed or not.
1394+ if ((mGeometries [0 ] == ShapeAnnotation::HorizontalLine && mPoints [index].y () != point.y ()) ||
1395+ (mGeometries [0 ] == ShapeAnnotation::VerticalLine && mPoints [index].x () != point.x ())) {
1396+ insertPointsGeometriesAndCornerItems (1 );
1397+ index = index + 2 ;
1398+ }
1399+ }
1400+ qreal dx = point.x () - mPoints [index].x ();
1401+ qreal dy = point.y () - mPoints [index].y ();
1402+ mPoints .replace (index, point);
1403+ // update previous point
1404+ if (mGeometries .size () > index - 1 && mGeometries [index - 1 ] == ShapeAnnotation::HorizontalLine && mPoints .size () > index - 1 ) {
1405+ mPoints [index - 1 ] = QPointF (mPoints [index - 1 ].x (), mPoints [index - 1 ].y () + dy);
1406+ updateCornerItem (index - 1 );
1407+ } else if (mGeometries .size () > index - 1 && mGeometries [index - 1 ] == ShapeAnnotation::VerticalLine && mPoints .size () > index - 1 ) {
1408+ mPoints [index - 1 ] = QPointF (mPoints [index - 1 ].x () + dx, mPoints [index - 1 ].y ());
1409+ updateCornerItem (index - 1 );
1410+ }
1411+ // update next point
1412+ if (mGeometries .size () > index && mGeometries [index] == ShapeAnnotation::HorizontalLine && mPoints .size () > index + 1 ) {
1413+ mPoints [index + 1 ] = QPointF (mPoints [index + 1 ].x (), mPoints [index + 1 ].y () + dy);
1414+ updateCornerItem (index + 1 );
1415+ } else if (mGeometries .size () > index && mGeometries [index] == ShapeAnnotation::VerticalLine && mPoints .size () > index + 1 ) {
1416+ mPoints [index + 1 ] = QPointF (mPoints [index + 1 ].x () + dx, mPoints [index + 1 ].y ());
1417+ updateCornerItem (index + 1 );
13971418 }
1398- }
1399- qreal dx = point.x () - mPoints [index].x ();
1400- qreal dy = point.y () - mPoints [index].y ();
1401- mPoints .replace (index, point);
1402- // update previous point
1403- if (mGeometries [index - 1 ] == ShapeAnnotation::HorizontalLine) {
1404- mPoints [index - 1 ] = QPointF (mPoints [index - 1 ].x (), mPoints [index - 1 ].y () + dy);
1405- updateCornerItem (index - 1 );
1406- } else if (mGeometries [index - 1 ] == ShapeAnnotation::VerticalLine) {
1407- mPoints [index - 1 ] = QPointF (mPoints [index - 1 ].x () + dx, mPoints [index - 1 ].y ());
1408- updateCornerItem (index - 1 );
1409- }
1410- // update next point
1411- if (mGeometries [index] == ShapeAnnotation::HorizontalLine) {
1412- mPoints [index + 1 ] = QPointF (mPoints [index + 1 ].x (), mPoints [index + 1 ].y () + dy);
1413- updateCornerItem (index + 1 );
1414- } else if (mGeometries [index] == ShapeAnnotation::VerticalLine) {
1415- mPoints [index + 1 ] = QPointF (mPoints [index + 1 ].x () + dx, mPoints [index + 1 ].y ());
1416- updateCornerItem (index + 1 );
14171419 }
14181420 } else {
14191421 mPoints .replace (index, point);
0 commit comments