diff --git a/src/tools/UBGraphicsRuler.cpp b/src/tools/UBGraphicsRuler.cpp index 046e229b..cd15de78 100644 --- a/src/tools/UBGraphicsRuler.cpp +++ b/src/tools/UBGraphicsRuler.cpp @@ -323,6 +323,10 @@ void UBGraphicsRuler::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QPointF delta = event->pos() - event->lastPos(); if (rect().width() + delta.x() < sMinLength) delta.setX(sMinLength - rect().width()); + + if (rect().width() + delta.x() > sMaxLength) + delta.setX(sMaxLength - rect().width()); + setRect(QRectF(rect().topLeft(), QSizeF(rect().width() + delta.x(), rect().height()))); } else diff --git a/src/tools/UBGraphicsRuler.h b/src/tools/UBGraphicsRuler.h index d3beca82..fb74dd9d 100644 --- a/src/tools/UBGraphicsRuler.h +++ b/src/tools/UBGraphicsRuler.h @@ -90,7 +90,8 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu // Constants static const QRect sDefaultRect; - static const int sMinLength = 150; + static const int sMinLength = 150; // 3sm + static const int sMaxLength = 35000; // 700sm }; #endif /* UBGRAPHICSRULER_H_ */