Commit 9b8235ed authored by Claudio Valerio's avatar Claudio Valerio

fixed issue for stroke copying

parent 998e074e
......@@ -185,6 +185,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
UBGraphicsPolygonItem *cp = dynamic_cast<UBGraphicsPolygonItem*>(copy);
if (cp)
{
cp->setPolygon(polygon());
cp->mOriginalLine = this->mOriginalLine;
cp->mOriginalWidth = this->mOriginalWidth;
cp->mIsNominalLine = this->mIsNominalLine;
......@@ -198,7 +199,6 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
cp->setColorOnLightBackground(this->colorOnLightBackground());
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setPolygon(polygon());
}
}
......
......@@ -1104,6 +1104,8 @@ UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
QMap<UBGraphicsStroke*, UBGraphicsStroke*> groupClone;
QList<QUuid> groupAlreadyCloned;
while (itItems.hasNext())
{
QGraphicsItem* item = itItems.next();
......@@ -1111,9 +1113,17 @@ UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
UBItem* ubItem = dynamic_cast<UBItem*>(item);
UBGraphicsStroke* stroke = dynamic_cast<UBGraphicsStroke*>(item);
UBGraphicsGroupContainerItem* group = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if (ubItem && !stroke)
{
//horrible hack
if(group && !groupAlreadyCloned.contains(group->uuid())){
cloneItem = dynamic_cast<QGraphicsItem*>(ubItem->deepCopy());
groupAlreadyCloned.append(group->uuid());
}
if(!group)
cloneItem = dynamic_cast<QGraphicsItem*>(ubItem->deepCopy());
}
......
......@@ -26,6 +26,7 @@
#include "UBGraphicsStrokesGroup.h"
#include "UBGraphicsStroke.h"
#include "domain/UBGraphicsPolygonItem.h"
......@@ -140,12 +141,15 @@ void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
UBItem* UBGraphicsStrokesGroup::deepCopy() const
{
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
copyItemParameters(copy);
QTransform groupTransform = transform();
const_cast<UBGraphicsStrokesGroup*>(this)->resetTransform();
QList<QGraphicsItem*> chl = childItems();
UBGraphicsStroke* newStroke = new UBGraphicsStroke;
foreach(QGraphicsItem *child, chl)
{
UBGraphicsPolygonItem *polygon = dynamic_cast<UBGraphicsPolygonItem*>(child);
......@@ -155,14 +159,14 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const
if (polygonCopy)
{
QGraphicsItem* pItem = dynamic_cast<QGraphicsItem*>(polygonCopy);
polygonCopy->setTransform(groupTransform);
copy->addToGroup(pItem);
polygonCopy->setStrokesGroup(copy);
polygonCopy->setStroke(newStroke);
}
}
}
const_cast<UBGraphicsStrokesGroup*>(this)->setTransform(groupTransform);
copyItemParameters(copy);
return copy;
}
......
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