fix Delegate item

new_vector_item
thomas_lucky13 2 years ago
parent c24904f800
commit fd4852c6a4
  1. 4
      src/domain/UBGraphicsScene.cpp
  2. 9
      src/domain/UBGraphicsVectorItem.cpp
  3. 8
      src/domain/UBGraphicsVectorItem.h

@ -1043,10 +1043,10 @@ void UBGraphicsScene::addVectorItemToCurrentStroke(UBGraphicsVectorItem* vectorI
vectorItem->SetDelegate(); vectorItem->SetDelegate();
mpLastVector = vectorItem; mpLastVector = vectorItem;
mAddedItems.insert(vectorItem); mAddedItems.insert(vectorItem->StrokeGroup());
// Here we add the item to the scene // Here we add the item to the scene
addItem(vectorItem); addItem(vectorItem->StrokeGroup());
} }

@ -59,6 +59,15 @@ void UBGraphicsVectorItem::initialize()
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemIsMovable, true);
setSublines(); setSublines();
mStrokeGroup = new UBGraphicsStrokesGroup();
mStrokeGroup->setTransform(this->transform());
UBGraphicsItem::assignZValue(mStrokeGroup, this->zValue());
if(this->transform().isIdentity())
this->setTransform(mStrokeGroup->transform());
mStrokeGroup->addToGroup(this);
} }
void UBGraphicsVectorItem::setSublines() void UBGraphicsVectorItem::setSublines()

@ -3,6 +3,7 @@
#include <QtGui> #include <QtGui>
#include "core/UB.h" #include "core/UB.h"
#include "domain/UBGraphicsStrokesGroup.h"
#include "UBItem.h" #include "UBItem.h"
class UBItem; class UBItem;
@ -89,6 +90,11 @@ public:
return sublines; return sublines;
} }
UBGraphicsStrokesGroup* StrokeGroup()
{
return mStrokeGroup;
}
protected: protected:
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); 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);
@ -106,6 +112,8 @@ public:
QColor mColorOnLightBackground; QColor mColorOnLightBackground;
QList<QGraphicsLineItem *> sublines; QList<QGraphicsLineItem *> sublines;
UBVectorStyle::Enum style; UBVectorStyle::Enum style;
UBGraphicsStrokesGroup* mStrokeGroup;
}; };
#endif // UBGRAPHICSVECTORITEM_H #endif // UBGRAPHICSVECTORITEM_H

Loading…
Cancel
Save