mirror of
https://github.com/tumic0/QtPBFImagePlugin.git
synced 2025-07-16 20:14:23 +02:00
Use fuzzy text bounding rect computation to improve performance
Do not use QGraphicsScene as it is not thread-safe
This commit is contained in:
17
src/text.h
17
src/text.h
@ -1,18 +1,27 @@
|
||||
#ifndef TEXT_H
|
||||
#define TEXT_H
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include "textitem.h"
|
||||
|
||||
class Text : public QGraphicsScene
|
||||
class Text
|
||||
{
|
||||
public:
|
||||
Text(int size, QObject *parent = 0) : QGraphicsScene(parent)
|
||||
{setSceneRect(0, 0, size, size);}
|
||||
Text(int size) : _sceneRect(QRectF(0, 0, size, size)) {}
|
||||
~Text();
|
||||
|
||||
void render(QPainter *painter);
|
||||
|
||||
void addLabel(const QString &text, const QPointF &pos, const QFont &font,
|
||||
const QPen &pen, qreal maxTextWidth);
|
||||
void addLabel(const QString &text, const QPainterPath &path,
|
||||
const QFont &font, const QPen &pen, qreal maxAngle);
|
||||
|
||||
private:
|
||||
void addItem(TextItem *item) {_items.append(item);}
|
||||
QList<TextItem *> collidingItems(const TextItem *item) const;
|
||||
|
||||
QRectF _sceneRect;
|
||||
QList<TextItem *> _items;
|
||||
};
|
||||
|
||||
#endif // TEXT_H
|
||||
|
Reference in New Issue
Block a user