1 #ifndef SCALEITEM_H 2 #define SCALEITEM_H 3 4 #include <QGraphicsItem> 5 #include "units.h" 6 7 class ScaleItem : public QGraphicsItem 8 { 9 public: 10 ScaleItem(QGraphicsItem *parent = 0); 11 boundingRect()12 QRectF boundingRect() const {return _boundingRect;} 13 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 14 QWidget *widget); 15 16 void setResolution(qreal res); 17 void setUnits(Units units); 18 void setDigitalZoom(qreal zoom); 19 20 private: 21 struct Tick { 22 double value; 23 QRect boundingBox; 24 }; 25 26 void computeScale(); 27 void updateCache(); 28 29 qreal _res; 30 qreal _width; 31 qreal _length; 32 Units _units; 33 bool _scale; 34 qreal _digitalZoom; 35 QRectF _boundingRect; 36 QFont _font; 37 QVector<Tick> _ticks; 38 QRect _unitsBB; 39 QString _unitsStr; 40 }; 41 42 #endif // SCALEITEM_H 43