Commit c956cb04 authored by Craig Watson's avatar Craig Watson

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

parent 13c29f71
...@@ -49,8 +49,7 @@ UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent) ...@@ -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 ...@@ -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 ...@@ -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: ...@@ -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;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment