|
|
@ -555,6 +555,10 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
|
|
|
|
|
|
|
|
if (polygonItem) |
|
|
|
if (polygonItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
mScene->addItem(polygonItem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
polygonItem->setUuid(uuidFromSvg); |
|
|
|
|
|
|
|
|
|
|
|
if (annotationGroup) |
|
|
|
if (annotationGroup) |
|
|
|
{ |
|
|
|
{ |
|
|
|
polygonItem->setStroke(annotationGroup); |
|
|
|
polygonItem->setStroke(annotationGroup); |
|
|
@ -991,31 +995,42 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() |
|
|
|
UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsGroupContainerItem *result = new UBGraphicsGroupContainerItem(); |
|
|
|
UBGraphicsGroupContainerItem *group = new UBGraphicsGroupContainerItem(); |
|
|
|
|
|
|
|
QMultiMap<QString, UBGraphicsPolygonItem *> strokesGroupsContainer;
|
|
|
|
|
|
|
|
QList<QGraphicsItem *> groupContainer;
|
|
|
|
|
|
|
|
QString currentStrokeIdentifier; |
|
|
|
|
|
|
|
|
|
|
|
QUuid groupUuid = QUuid(mXmlReader.attributes().value(aId).toString()); |
|
|
|
QUuid groupUuid = QUuid(mXmlReader.attributes().value(aId).toString()); |
|
|
|
|
|
|
|
|
|
|
|
mXmlReader.readNext(); |
|
|
|
mXmlReader.readNext(); |
|
|
|
while (!mXmlReader.atEnd()) { |
|
|
|
while (!mXmlReader.atEnd())
|
|
|
|
if (mXmlReader.isEndElement()) { |
|
|
|
{ |
|
|
|
mXmlReader.readNext(); |
|
|
|
if (mXmlReader.isStartElement()) |
|
|
|
result->setUuid(groupUuid); |
|
|
|
{ |
|
|
|
if (!result->childItems().count()) { |
|
|
|
if (mXmlReader.name() == tGroup)
|
|
|
|
delete result; |
|
|
|
{ |
|
|
|
result = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} else if (mXmlReader.isStartElement()) { |
|
|
|
|
|
|
|
if (mXmlReader.name() == tGroup) { |
|
|
|
|
|
|
|
qDebug() << "came across the group id is" << mXmlReader.attributes().value(aId); |
|
|
|
qDebug() << "came across the group id is" << mXmlReader.attributes().value(aId); |
|
|
|
UBGraphicsGroupContainerItem *curGroup = readGroup(); |
|
|
|
UBGraphicsGroupContainerItem *curGroup = readGroup(); |
|
|
|
if (curGroup) { |
|
|
|
if (curGroup)
|
|
|
|
result->addToGroup(curGroup); |
|
|
|
group->addToGroup(curGroup); |
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (mXmlReader.name() == tElement) { |
|
|
|
else if (mXmlReader.name() == tElement) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QString id = mXmlReader.attributes().value(aId).toString(); |
|
|
|
|
|
|
|
QString itemId = id.right(QUuid().toString().size()); |
|
|
|
|
|
|
|
QString groupId = id.left(QUuid().toString().size()); |
|
|
|
|
|
|
|
|
|
|
|
QGraphicsItem *curItem = readElementFromGroup(); |
|
|
|
QGraphicsItem *curItem = readElementFromGroup(); |
|
|
|
if (curItem) { |
|
|
|
|
|
|
|
result->addToGroup(curItem); |
|
|
|
UBGraphicsPolygonItem *curPolygon = qgraphicsitem_cast<UBGraphicsPolygonItem *>(curItem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (curPolygon && !groupId.isEmpty() && !itemId.isEmpty() && itemId != groupId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
strokesGroupsContainer.insert(groupId, curPolygon); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else // item
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
group->addToGroup(curItem); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
@ -1025,7 +1040,47 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
foreach (QString key, strokesGroupsContainer.keys()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UBGraphicsStrokesGroup* pStrokesGroup = new UBGraphicsStrokesGroup(); |
|
|
|
|
|
|
|
UBGraphicsStroke *currentStroke = new UBGraphicsStroke(); |
|
|
|
|
|
|
|
foreach(UBGraphicsPolygonItem* poly, strokesGroupsContainer.values(key)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (poly) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mScene->removeItem(poly); |
|
|
|
|
|
|
|
mScene->removeItemFromDeletion(poly); |
|
|
|
|
|
|
|
poly->setStrokesGroup(pStrokesGroup); |
|
|
|
|
|
|
|
poly->setStroke(currentStroke); |
|
|
|
|
|
|
|
pStrokesGroup->addToGroup(poly); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (currentStroke->polygons().empty()) |
|
|
|
|
|
|
|
delete currentStroke; |
|
|
|
|
|
|
|
if (pStrokesGroup->childItems().count()) |
|
|
|
|
|
|
|
mScene->addItem(pStrokesGroup); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
delete pStrokesGroup; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pStrokesGroup) |
|
|
|
|
|
|
|
group->addToGroup(pStrokesGroup); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(QGraphicsItem* item, groupContainer) |
|
|
|
|
|
|
|
group->addToGroup(item); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (group->childItems().count()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mScene->addItem(group); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!groupContainer.count()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
group->destroy(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return group; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroupRoot() |
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroupRoot() |
|
|
@ -1053,8 +1108,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroupRoot() |
|
|
|
QGraphicsItem *UBSvgSubsetAdaptor::UBSvgSubsetReader::readElementFromGroup() |
|
|
|
QGraphicsItem *UBSvgSubsetAdaptor::UBSvgSubsetReader::readElementFromGroup() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QGraphicsItem *result = 0; |
|
|
|
QGraphicsItem *result = 0; |
|
|
|
|
|
|
|
QString id = mXmlReader.attributes().value(aId).toString(); |
|
|
|
result = mScene->itemForUuid(QUuid(mXmlReader.attributes().value(aId).toString())); |
|
|
|
QString uuid = id.right(QUuid().toString().size()); |
|
|
|
|
|
|
|
result = mScene->itemForUuid(QUuid(uuid)); |
|
|
|
|
|
|
|
|
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
|
mXmlReader.readNext(); |
|
|
|
mXmlReader.readNext(); |
|
|
|