2018-10-29 00:11:23 +01:00
|
|
|
#ifndef TEXT_H
|
|
|
|
#define TEXT_H
|
|
|
|
|
2018-11-22 21:57:21 +01:00
|
|
|
#include <QImage>
|
|
|
|
|
|
|
|
class TextItem;
|
2018-10-29 00:11:23 +01:00
|
|
|
|
2018-11-11 14:10:38 +01:00
|
|
|
class Text
|
2018-10-29 00:11:23 +01:00
|
|
|
{
|
|
|
|
public:
|
2018-11-22 21:57:21 +01:00
|
|
|
enum Anchor {
|
|
|
|
Center,
|
|
|
|
Left,
|
|
|
|
Right,
|
|
|
|
Top,
|
|
|
|
Bottom
|
|
|
|
};
|
|
|
|
|
2018-11-24 10:14:23 +01:00
|
|
|
enum Transform {
|
|
|
|
None,
|
|
|
|
Uppercase,
|
|
|
|
Lowercase
|
|
|
|
};
|
|
|
|
|
2018-11-22 21:57:21 +01:00
|
|
|
struct Properties {
|
|
|
|
int maxWidth;
|
|
|
|
int maxAngle;
|
|
|
|
Anchor anchor;
|
2018-11-24 10:14:23 +01:00
|
|
|
Transform transform;
|
2018-11-22 21:57:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-11-17 21:54:51 +01:00
|
|
|
Text(const QSize &size) : _sceneRect(QRectF(QPointF(0, 0), size)) {}
|
2018-11-11 14:10:38 +01:00
|
|
|
~Text();
|
|
|
|
|
2018-11-22 21:57:21 +01:00
|
|
|
void setProperties(const Properties &prop)
|
|
|
|
{_properties = prop;}
|
2018-10-29 00:11:23 +01:00
|
|
|
|
2018-11-13 18:24:51 +01:00
|
|
|
void addLabel(const QString &text, const QPointF &pos,
|
2018-11-22 21:57:21 +01:00
|
|
|
const QPainter &painter, bool overlap, const QImage &icon);
|
2018-10-29 00:11:23 +01:00
|
|
|
void addLabel(const QString &text, const QPainterPath &path,
|
2018-11-22 21:57:21 +01:00
|
|
|
const QPainter &painter);
|
|
|
|
|
|
|
|
void render(QPainter *painter) const;
|
2018-11-11 14:10:38 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void addItem(TextItem *item) {_items.append(item);}
|
|
|
|
QList<TextItem *> collidingItems(const TextItem *item) const;
|
|
|
|
|
|
|
|
QRectF _sceneRect;
|
|
|
|
QList<TextItem *> _items;
|
2018-11-22 21:57:21 +01:00
|
|
|
Properties _properties;
|
2018-10-29 00:11:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TEXT_H
|