21#include <QGraphicsItem>
22#include <QTextDocument>
33 enum {Type = UserType + ScaleBar
51 QGraphicsItem* parent =
nullptr,
double length = 1,
52 const QString& text = QString(),
bool visible =
true,
53 bool vertical =
false,
double relSize = 1);
66 QGraphicsItem* parent =
nullptr);
72 inline double length()
const {
return m_length; };
74 virtual void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
75 QWidget* widget =
nullptr)
override;
82 inline void setLength(
double length) { m_length = length; };
94 inline void setText(
const QString& text) { m_text = text; };
99 inline void setVertical(
bool vertical) { m_vertical = vertical; };
101 inline QString
text()
const {
return m_text; };
103 virtual int type()
const override {
return Type; };
107 inline bool vertical()
const {
return m_vertical; };
124 double m_length, l2, wRel;
Decoration item class.
Definition decoitem.h:36
Scale bar item class.
Definition scalebaritem.h:30
void init()
Performs initialization.
void setVertical(bool vertical)
Sets orientation.
Definition scalebaritem.h:99
ScaleBarItem(const ScaleBarItem &a)
Copy constructor.
ScaleBarItem(double x0=0, double y0=0, unsigned color=0, QGraphicsItem *parent=nullptr, double length=1, const QString &text=QString(), bool visible=true, bool vertical=false, double relSize=1)
Constructor.
void setLength(double length)
Sets length.
Definition scalebaritem.h:82
ScaleBarItem(const KConfigGroup *plo, unsigned color=0, QGraphicsItem *parent=nullptr)
Constructor.
void setSize()
Sets size according to transformation matrix.
void setProperties(const QTransform &m)
Sets properties according to transformation matrix.
QPixmap pixmap() const
Returns decoration pixmap for item list.
virtual QRectF boundingRect() const override
Calculates bounding rectangle.
virtual int type() const override
Returns specific QGraphicsItem type number.
Definition scalebaritem.h:103
void setProperties()
Sets properties according to transformation matrix.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
Paints item.
QRectF textRect() const
Returns text rectangle in pixel units.
virtual ~ScaleBarItem()
Destructor.
void update()
Applies changes and forces redrawing.
double length() const
Returns length in cm.
Definition scalebaritem.h:72
void setText(const QString &text)
Sets text.
Definition scalebaritem.h:94
QString text() const
Returns text.
Definition scalebaritem.h:101
bool vertical() const
Returns true for vertical, false for horizontal orientation.
Definition scalebaritem.h:107
void writePlo(KConfigGroup *plo) const
Writes into plot file.
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
Updates position.