Stroke z-order issue: experimental solution;

- Added a graphical display of stroke z level
- Enabled BSP tree use in the graphicsScene
preferencesAboutTextFull
Craig Watson 8 years ago
parent d021abf3b7
commit 13c29f7175
  1. 6
      src/board/UBBoardView.cpp
  2. 2
      src/domain/UBGraphicsScene.cpp
  3. 23
      src/domain/UBGraphicsStrokesGroup.cpp
  4. 2
      src/domain/UBGraphicsStrokesGroup.h

@ -99,6 +99,12 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent, bool
init ();
mFilterZIndex = false;
/*
mFilterZIndex = true;
mStartLayer = UBItemLayerType::FixedBackground;
mEndLayer = UBItemLayerType::Control;
*/
mLongPressTimer.setInterval(mLongPressInterval);
mLongPressTimer.setSingleShot(true);

@ -322,7 +322,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
, mSelectionFrame(0)
{
UBCoreGraphicsScene::setObjectName("BoardScene");
setItemIndexMethod(NoIndex);
//setItemIndexMethod(NoIndex);
setUuid(QUuid::createUuid());
setDocument(parent);

@ -48,6 +48,9 @@ UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent)
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, true);
mDebugText = NULL;
}
UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup()
@ -81,6 +84,8 @@ void UBGraphicsStrokesGroup::setColor(const QColor &color, colorType pColorType)
}
}
}
mDebugText->setBrush(QBrush(color));
}
QColor UBGraphicsStrokesGroup::color(colorType pColorType) const
@ -201,6 +206,24 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics
QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == ItemZValueChange) {
double newZ = qvariant_cast<double>(value);
UBGraphicsPolygonItem * poly = NULL;
if (childItems().size() > 2)
poly = dynamic_cast<UBGraphicsPolygonItem*>(childItems()[1]);
if (poly) {
if (!mDebugText) {
mDebugText = new QGraphicsSimpleTextItem("None", this);
//mDebugText->setPos(poly->scenePos());
mDebugText->setPos(poly->boundingRect().topLeft() + QPointF(10, 10));
mDebugText->setBrush(QBrush(poly->color()));
}
mDebugText->setText(QString("Z: %1").arg(newZ));
}
}
QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsItemGroup::itemChange(change, newValue);
}

@ -66,6 +66,8 @@ protected:
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
QGraphicsSimpleTextItem * mDebugText;
};
#endif // UBGRAPHICSSTROKESGROUP_H

Loading…
Cancel
Save