fixed stroke transformation

preferencesAboutTextFull
Claudio Valerio 11 years ago
parent 5c89e8a752
commit 552df68781
  1. 21
      src/domain/UBGraphicsStrokesGroup.cpp

@ -59,6 +59,7 @@ void UBGraphicsStrokesGroup::setUuid(const QUuid &pUuid)
UBItem::setUuid(pUuid); UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
} }
void UBGraphicsStrokesGroup::setColor(const QColor &color, colorType pColorType) void UBGraphicsStrokesGroup::setColor(const QColor &color, colorType pColorType)
{ {
//TODO Implement common mechanism of managing groups, drop UBGraphicsStroke if it's obsolete //TODO Implement common mechanism of managing groups, drop UBGraphicsStroke if it's obsolete
@ -140,10 +141,16 @@ void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
UBItem* UBGraphicsStrokesGroup::deepCopy() const UBItem* UBGraphicsStrokesGroup::deepCopy() const
{ {
QTransform groupTransform = transform();
qDebug() << "Initial original transform " << groupTransform;
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
copyItemParameters(copy); copyItemParameters(copy);
copy->resetTransform();
qDebug() << "Initial copy transform " << copy->transform();
QTransform groupTransform = transform();
const_cast<UBGraphicsStrokesGroup*>(this)->resetTransform(); const_cast<UBGraphicsStrokesGroup*>(this)->resetTransform();
QList<QGraphicsItem*> chl = childItems(); QList<QGraphicsItem*> chl = childItems();
@ -159,7 +166,6 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const
if (polygonCopy) if (polygonCopy)
{ {
QGraphicsItem* pItem = dynamic_cast<QGraphicsItem*>(polygonCopy); QGraphicsItem* pItem = dynamic_cast<QGraphicsItem*>(polygonCopy);
polygonCopy->setTransform(groupTransform);
copy->addToGroup(pItem); copy->addToGroup(pItem);
polygonCopy->setStrokesGroup(copy); polygonCopy->setStrokesGroup(copy);
polygonCopy->setStroke(newStroke); polygonCopy->setStroke(newStroke);
@ -167,7 +173,16 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const
} }
} }
const_cast<UBGraphicsStrokesGroup*>(this)->setTransform(groupTransform); const_cast<UBGraphicsStrokesGroup*>(this)->setTransform(groupTransform);
copy->setTransform(groupTransform);
for(int i = 0 ; i < childItems().count(); i += 1){
Q_ASSERT(childItems().at(i)->transform().m11() == copy->childItems().at(i)->transform().m11());
Q_ASSERT(childItems().at(i)->transform().m12() == copy->childItems().at(i)->transform().m12());
Q_ASSERT(childItems().at(i)->transform().m21() == copy->childItems().at(i)->transform().m21());
Q_ASSERT(childItems().at(i)->transform().m22() == copy->childItems().at(i)->transform().m22());
Q_ASSERT(childItems().at(i)->transform().m31() == copy->childItems().at(i)->transform().m31());
Q_ASSERT(childItems().at(i)->transform().m32() == copy->childItems().at(i)->transform().m32());
}
return copy; return copy;
} }

Loading…
Cancel
Save