(Optional) graphical display of stroke z level, for debugging

preferencesAboutTextFull
Craig Watson 9 years ago
parent 13c29f7175
commit c956cb0427
  1. 8
      src/domain/UBGraphicsStrokesGroup.cpp
  2. 2
      src/domain/UBGraphicsStrokesGroup.h

@ -49,8 +49,7 @@ UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent)
setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemIsMovable, true);
mDebugText = NULL; mDebugText = NULL;
debugTextEnabled = false; // set to true to get a graphical display of strokes' Z-levels
} }
UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup() UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup()
@ -206,7 +205,7 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics
QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
if (change == ItemZValueChange) { if (debugTextEnabled && change == ItemZValueChange) {
double newZ = qvariant_cast<double>(value); double newZ = qvariant_cast<double>(value);
UBGraphicsPolygonItem * poly = NULL; UBGraphicsPolygonItem * poly = NULL;
@ -216,14 +215,13 @@ QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVa
if (poly) { if (poly) {
if (!mDebugText) { if (!mDebugText) {
mDebugText = new QGraphicsSimpleTextItem("None", this); mDebugText = new QGraphicsSimpleTextItem("None", this);
//mDebugText->setPos(poly->scenePos());
mDebugText->setPos(poly->boundingRect().topLeft() + QPointF(10, 10)); mDebugText->setPos(poly->boundingRect().topLeft() + QPointF(10, 10));
mDebugText->setBrush(QBrush(poly->color())); mDebugText->setBrush(QBrush(poly->color()));
} }
mDebugText->setText(QString("Z: %1").arg(newZ)); mDebugText->setText(QString("Z: %1").arg(newZ));
} }
} }
QVariant newValue = Delegate()->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsItemGroup::itemChange(change, newValue); return QGraphicsItemGroup::itemChange(change, newValue);
} }

@ -67,6 +67,8 @@ protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
// Graphical display of stroke Z-level
bool debugTextEnabled;
QGraphicsSimpleTextItem * mDebugText; QGraphicsSimpleTextItem * mDebugText;
}; };

Loading…
Cancel
Save