diff --git a/sources/editor/parttext.cpp b/sources/editor/parttext.cpp index 44ed66e29..76cf038dc 100644 --- a/sources/editor/parttext.cpp +++ b/sources/editor/parttext.cpp @@ -240,3 +240,44 @@ QRectF PartText::boundingRect() const { bool PartText::isUseless() const { return(toPlainText().isEmpty()); } + +/** + Dessine le texte statique. + @param painter QPainter a utiliser pour effectuer le rendu + @param qsogi Pptions de dessin + @param widget Widget sur lequel on dessine (facultatif) +*/ +void PartText::paint(QPainter *painter, const QStyleOptionGraphicsItem *qsogi, QWidget *widget) { + QGraphicsTextItem::paint(painter, qsogi, widget); + +#ifdef QET_DEBUG_EDITOR_TEXTS + painter -> setPen(Qt::blue); + painter -> drawRect(boundingRect()); + + painter -> setPen(Qt::red); + drawPoint(painter, QPointF(0, 0)); + + painter -> setPen(Qt::green); + drawPoint(painter, mapFromScene(pos())); +#endif +} + +#ifdef QET_DEBUG_EDITOR_TEXTS +/** + Dessine deux petites fleches pour mettre un point en valeur + @param painter QPainter a utiliser pour effectuer le rendu + @param point Point a dessiner +*/ +void PartText::drawPoint(QPainter *painter, const QPointF &point) { + qreal px = point.x(); + qreal py = point.y(); + qreal size_1 = 5.0; + qreal size_2 = 1.0; + painter -> drawLine(px, py, px + size_1, py); + painter -> drawLine(px + size_1 - size_2, py - size_2, px + size_1, py); + painter -> drawLine(px + size_1 - size_2, py + size_2, px + size_1, py); + painter -> drawLine(px, py, px, py + size_1); + painter -> drawLine(px, py + size_1, px - size_2, py + size_1 - size_2); + painter -> drawLine(px, py + size_1, px + size_2, py + size_1 - size_2); +} +#endif diff --git a/sources/editor/parttext.h b/sources/editor/parttext.h index 5d805a86f..e93bb4f04 100644 --- a/sources/editor/parttext.h +++ b/sources/editor/parttext.h @@ -54,6 +54,7 @@ class PartText : public QGraphicsTextItem, public CustomElementPart { virtual void setProperty(const QString &, const QVariant &); virtual QVariant property(const QString &); virtual bool isUseless() const; + virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 ); protected: virtual void focusOutEvent(QFocusEvent *); @@ -63,6 +64,9 @@ class PartText : public QGraphicsTextItem, public CustomElementPart { private: QPointF margin() const; +#ifdef QET_DEBUG_EDITOR_TEXTS + void drawPoint(QPainter *, const QPointF &); +#endif QString previous_text; }; #endif diff --git a/sources/editor/parttextfield.cpp b/sources/editor/parttextfield.cpp index 7c252d66b..e2df3a0cd 100644 --- a/sources/editor/parttextfield.cpp +++ b/sources/editor/parttextfield.cpp @@ -266,3 +266,44 @@ QRectF PartTextField::boundingRect() const { bool PartTextField::isUseless() const { return(false); } + +/** + Dessine le texte statique. + @param painter QPainter a utiliser pour effectuer le rendu + @param qsogi Pptions de dessin + @param widget Widget sur lequel on dessine (facultatif) +*/ +void PartTextField::paint(QPainter *painter, const QStyleOptionGraphicsItem *qsogi, QWidget *qw) { + QGraphicsTextItem::paint(painter, qsogi, qw); + +#ifdef QET_DEBUG_EDITOR_TEXTS + painter -> setPen(Qt::blue); + painter -> drawRect(boundingRect()); + + painter -> setPen(Qt::red); + drawPoint(painter, QPointF(0, 0)); + + painter -> setPen(Qt::green); + drawPoint(painter, mapFromScene(pos())); +#endif +} + +#ifdef QET_DEBUG_EDITOR_TEXTS +/** + Dessine deux petites fleches pour mettre un point en valeur + @param painter QPainter a utiliser pour effectuer le rendu + @param point Point a dessiner +*/ +void PartTextField::drawPoint(QPainter *painter, const QPointF &point) { + qreal px = point.x(); + qreal py = point.y(); + qreal size_1 = 5.0; + qreal size_2 = 1.0; + painter -> drawLine(px, py, px + size_1, py); + painter -> drawLine(px + size_1 - size_2, py - size_2, px + size_1, py); + painter -> drawLine(px + size_1 - size_2, py + size_2, px + size_1, py); + painter -> drawLine(px, py, px, py + size_1); + painter -> drawLine(px, py + size_1, px - size_2, py + size_1 - size_2); + painter -> drawLine(px, py + size_1, px + size_2, py + size_1 - size_2); +} +#endif diff --git a/sources/editor/parttextfield.h b/sources/editor/parttextfield.h index 636655ca1..af6fe9bfa 100644 --- a/sources/editor/parttextfield.h +++ b/sources/editor/parttextfield.h @@ -60,6 +60,7 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart { virtual void setProperty(const QString &, const QVariant &); virtual QVariant property(const QString &); virtual bool isUseless() const; + virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 ); protected: virtual void focusOutEvent(QFocusEvent *); @@ -69,6 +70,9 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart { private: QPointF margin() const; +#ifdef QET_DEBUG_EDITOR_TEXTS + void drawPoint(QPainter *, const QPointF &); +#endif QString previous_text; }; #endif