|
|
@ -552,25 +552,23 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsPolygonItem* polygonItem = 0; |
|
|
|
UBGraphicsPolygonItem* polygonItem = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString parentId = mXmlReader.attributes().value(mNamespaceUri, "parent").toString(); |
|
|
|
if (mXmlReader.name() == "polygon") |
|
|
|
if (mXmlReader.name() == "polygon") |
|
|
|
{ |
|
|
|
|
|
|
|
polygonItem = polygonItemFromPolygonSvg(mScene->isDarkBackground() ? Qt::white : Qt::black); |
|
|
|
polygonItem = polygonItemFromPolygonSvg(mScene->isDarkBackground() ? Qt::white : Qt::black); |
|
|
|
} |
|
|
|
|
|
|
|
else if (mXmlReader.name() == "line") |
|
|
|
else if (mXmlReader.name() == "line") |
|
|
|
{ |
|
|
|
|
|
|
|
polygonItem = polygonItemFromLineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black); |
|
|
|
polygonItem = polygonItemFromLineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(parentId.isEmpty() && strokesGroup) |
|
|
|
|
|
|
|
parentId = strokesGroup->uuid().toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_ASSERT(!parentId.isEmpty()); |
|
|
|
|
|
|
|
|
|
|
|
if (polygonItem) |
|
|
|
if (polygonItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mScene->addItem(polygonItem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
polygonItem->setUuid(uuidFromSvg); |
|
|
|
polygonItem->setUuid(uuidFromSvg); |
|
|
|
|
|
|
|
|
|
|
|
if (annotationGroup) |
|
|
|
if (annotationGroup) |
|
|
|
{ |
|
|
|
|
|
|
|
polygonItem->setStroke(annotationGroup); |
|
|
|
polygonItem->setStroke(annotationGroup); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(strokesGroup){ |
|
|
|
if(strokesGroup){ |
|
|
@ -581,7 +579,17 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
|
|
|
|
|
|
|
|
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); |
|
|
|
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsStrokesGroup* group; |
|
|
|
|
|
|
|
if(!mStrokesList.contains(parentId)){ |
|
|
|
|
|
|
|
group = new UBGraphicsStrokesGroup(); |
|
|
|
|
|
|
|
mStrokesList.insert(parentId,group); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
group = mStrokesList.value(parentId); |
|
|
|
|
|
|
|
|
|
|
|
polygonItem->show(); |
|
|
|
polygonItem->show(); |
|
|
|
|
|
|
|
group->addToGroup(polygonItem); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (mXmlReader.name() == "polyline") |
|
|
|
else if (mXmlReader.name() == "polyline") |
|
|
@ -604,6 +612,17 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); |
|
|
|
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString parentId = mXmlReader.attributes().value(mNamespaceUri, "parent").toString(); |
|
|
|
|
|
|
|
Q_ASSERT(!parentId.isEmpty()); |
|
|
|
|
|
|
|
UBGraphicsStrokesGroup* group; |
|
|
|
|
|
|
|
if(!mStrokesList.contains(parentId)){ |
|
|
|
|
|
|
|
group = new UBGraphicsStrokesGroup(); |
|
|
|
|
|
|
|
mStrokesList.insert(parentId,group); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
group = mStrokesList.value(parentId); |
|
|
|
|
|
|
|
|
|
|
|
polygonItem->show(); |
|
|
|
polygonItem->show(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -861,7 +880,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
UBGraphicsAppleWidgetItem* appleWidgetItem = graphicsAppleWidgetFromSvg(); |
|
|
|
UBGraphicsAppleWidgetItem* appleWidgetItem = graphicsAppleWidgetFromSvg(); |
|
|
|
if (appleWidgetItem) |
|
|
|
if (appleWidgetItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// appleWidgetItem->setFlag(QGraphicsItem::ItemIsMovable, true);
|
|
|
|
|
|
|
|
appleWidgetItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
appleWidgetItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
|
|
|
|
|
|
|
|
appleWidgetItem->resize(foreignObjectWidth, foreignObjectHeight); |
|
|
|
appleWidgetItem->resize(foreignObjectWidth, foreignObjectHeight); |
|
|
@ -885,7 +903,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
|
|
|
|
|
|
|
|
if (w3cWidgetItem) |
|
|
|
if (w3cWidgetItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// w3cWidgetItem->setFlag(QGraphicsItem::ItemIsMovable, true);
|
|
|
|
|
|
|
|
w3cWidgetItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
w3cWidgetItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
|
|
|
|
|
|
|
|
w3cWidgetItem->resize(foreignObjectWidth, foreignObjectHeight); |
|
|
|
w3cWidgetItem->resize(foreignObjectWidth, foreignObjectHeight); |
|
|
@ -956,7 +973,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
currentWidget->setDatastoreEntry(key, value); |
|
|
|
currentWidget->setDatastoreEntry(key, value); |
|
|
|
} else if (mXmlReader.name() == tGroups) { |
|
|
|
} else if (mXmlReader.name() == tGroups) { |
|
|
|
//considering groups section at the end of the document
|
|
|
|
//considering groups section at the end of the document
|
|
|
|
|
|
|
|
|
|
|
|
readGroupRoot(); |
|
|
|
readGroupRoot(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -968,10 +984,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mXmlReader.name() == "g") |
|
|
|
if (mXmlReader.name() == "g") |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(strokesGroup && mScene){ |
|
|
|
// if(strokesGroup && mScene){
|
|
|
|
mScene->addItem(strokesGroup); |
|
|
|
// mScene->addItem(strokesGroup);
|
|
|
|
//graphicsItemFromSvg(strokesGroup);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (annotationGroup) |
|
|
|
if (annotationGroup) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -985,11 +1000,19 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mXmlReader.hasError()) |
|
|
|
if (mXmlReader.hasError()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qWarning() << "error parsing Sankore file " << mXmlReader.errorString(); |
|
|
|
qWarning() << "error parsing Sankore file " << mXmlReader.errorString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "Number of detected strokes: " << mStrokesList.count(); |
|
|
|
|
|
|
|
QMapIterator<QString, UBGraphicsStrokesGroup*> iterator(mStrokesList); |
|
|
|
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
|
|
|
iterator.next(); |
|
|
|
|
|
|
|
mScene->addItem(iterator.value()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mScene) { |
|
|
|
if (mScene) { |
|
|
|
mScene->setModified(false); |
|
|
|
mScene->setModified(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -1008,7 +1031,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() |
|
|
|
UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsGroupContainerItem *group = new UBGraphicsGroupContainerItem(); |
|
|
|
UBGraphicsGroupContainerItem *group = new UBGraphicsGroupContainerItem(); |
|
|
|
QMultiMap<QString, UBGraphicsPolygonItem *> strokesGroupsContainer; |
|
|
|
// QMultiMap<QString, UBGraphicsPolygonItem *> strokesGroupsContainer;
|
|
|
|
QList<QGraphicsItem *> groupContainer; |
|
|
|
QList<QGraphicsItem *> groupContainer; |
|
|
|
|
|
|
|
|
|
|
|
mXmlReader.readNext(); |
|
|
|
mXmlReader.readNext(); |
|
|
@ -1017,10 +1040,9 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() |
|
|
|
if (mXmlReader.isEndElement()) { |
|
|
|
if (mXmlReader.isEndElement()) { |
|
|
|
mXmlReader.readNext(); |
|
|
|
mXmlReader.readNext(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} else if (mXmlReader.isStartElement()) |
|
|
|
} |
|
|
|
{ |
|
|
|
else if (mXmlReader.isStartElement()) { |
|
|
|
if (mXmlReader.name() == tGroup) |
|
|
|
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) |
|
|
@ -1028,67 +1050,69 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() |
|
|
|
else |
|
|
|
else |
|
|
|
qDebug() << "this is an error"; |
|
|
|
qDebug() << "this is an error"; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (mXmlReader.name() == tElement) |
|
|
|
else if (mXmlReader.name() == tElement) { |
|
|
|
{ |
|
|
|
|
|
|
|
QString id = mXmlReader.attributes().value(aId).toString(); |
|
|
|
QString id = mXmlReader.attributes().value(aId).toString(); |
|
|
|
QString itemId = id.right(QUuid().toString().size()); |
|
|
|
// QString itemId = id.right(QUuid().toString().size());
|
|
|
|
QString groupId = id.left(QUuid().toString().size()); |
|
|
|
// QString groupId = id.left(QUuid().toString().size());
|
|
|
|
|
|
|
|
|
|
|
|
QGraphicsItem *curItem = readElementFromGroup(); |
|
|
|
QGraphicsItem *curItem = readElementFromGroup(); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsPolygonItem *curPolygon = qgraphicsitem_cast<UBGraphicsPolygonItem *>(curItem); |
|
|
|
// UBGraphicsPolygonItem *curPolygon = qgraphicsitem_cast<UBGraphicsPolygonItem *>(curItem);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (curPolygon && !groupId.isEmpty() && !itemId.isEmpty() && itemId != groupId) {
|
|
|
|
|
|
|
|
// strokesGroupsContainer.insert(groupId, curPolygon);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else {// item
|
|
|
|
|
|
|
|
|
|
|
|
if (curPolygon && !groupId.isEmpty() && !itemId.isEmpty() && itemId != groupId) |
|
|
|
// Explanation: the second condition discriminate the old storage version that should
|
|
|
|
{ |
|
|
|
// not be interpreted anymore
|
|
|
|
strokesGroupsContainer.insert(groupId, curPolygon); |
|
|
|
if(curItem && id.count("{") < 2) |
|
|
|
} |
|
|
|
|
|
|
|
else // item
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(curItem) |
|
|
|
|
|
|
|
groupContainer.append(curItem); |
|
|
|
groupContainer.append(curItem); |
|
|
|
else |
|
|
|
else |
|
|
|
qDebug() << "this is an error"; |
|
|
|
qDebug() << "this is an error"; |
|
|
|
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
else { |
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
mXmlReader.readNext(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
foreach (QString key, strokesGroupsContainer.keys().toSet()) |
|
|
|
mXmlReader.readNext(); |
|
|
|
{ |
|
|
|
|
|
|
|
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) |
|
|
|
// foreach (QString key, strokesGroupsContainer.keys().toSet())
|
|
|
|
{ |
|
|
|
// {
|
|
|
|
QGraphicsItem *strokeGroup = qgraphicsitem_cast<QGraphicsItem *>(pStrokesGroup); |
|
|
|
// UBGraphicsStrokesGroup* pStrokesGroup = new UBGraphicsStrokesGroup();
|
|
|
|
if(strokeGroup) |
|
|
|
// UBGraphicsStroke *currentStroke = new UBGraphicsStroke();
|
|
|
|
groupContainer.append(strokeGroup); |
|
|
|
// foreach(UBGraphicsPolygonItem* poly, strokesGroupsContainer.values(key))
|
|
|
|
else |
|
|
|
// {
|
|
|
|
qDebug() << "this is an error"; |
|
|
|
// 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)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// QGraphicsItem *strokeGroup = qgraphicsitem_cast<QGraphicsItem *>(pStrokesGroup);
|
|
|
|
|
|
|
|
// if(strokeGroup)
|
|
|
|
|
|
|
|
// groupContainer.append(strokeGroup);
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// qDebug() << "this is an error";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
foreach(QGraphicsItem* item, groupContainer) |
|
|
|
foreach(QGraphicsItem* item, groupContainer) |
|
|
|
group->addToGroup(item); |
|
|
|
group->addToGroup(item); |
|
|
@ -1112,16 +1136,19 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroupRoot() |
|
|
|
if (mXmlReader.isEndElement()) { |
|
|
|
if (mXmlReader.isEndElement()) { |
|
|
|
mXmlReader.readNext(); |
|
|
|
mXmlReader.readNext(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} else if (mXmlReader.isStartElement()) { |
|
|
|
} |
|
|
|
|
|
|
|
else if (mXmlReader.isStartElement()) { |
|
|
|
if (mXmlReader.name() == tGroup) { |
|
|
|
if (mXmlReader.name() == tGroup) { |
|
|
|
UBGraphicsGroupContainerItem *curGroup = readGroup(); |
|
|
|
UBGraphicsGroupContainerItem *curGroup = readGroup(); |
|
|
|
if (curGroup) { |
|
|
|
if (curGroup) { |
|
|
|
mScene->addGroup(curGroup); |
|
|
|
mScene->addGroup(curGroup); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
mXmlReader.readNext(); |
|
|
|
mXmlReader.readNext(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1135,7 +1162,9 @@ QGraphicsItem *UBSvgSubsetAdaptor::UBSvgSubsetReader::readElementFromGroup() |
|
|
|
result = mScene->itemForUuid(QUuid(uuid)); |
|
|
|
result = mScene->itemForUuid(QUuid(uuid)); |
|
|
|
|
|
|
|
|
|
|
|
if(!result) |
|
|
|
if(!result) |
|
|
|
qDebug() << "uuid " << uuid; |
|
|
|
result = mStrokesList.take(uuid.replace("}","").replace("{","")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_ASSERT(result); |
|
|
|
|
|
|
|
|
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
|
mXmlReader.skipCurrentElement(); |
|
|
|
mXmlReader.readNext(); |
|
|
|
mXmlReader.readNext(); |
|
|
@ -1239,38 +1268,15 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) |
|
|
|
UBGraphicsStrokesGroup* strokesGroupItem = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item); |
|
|
|
UBGraphicsStrokesGroup* strokesGroupItem = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item); |
|
|
|
|
|
|
|
|
|
|
|
if(strokesGroupItem && strokesGroupItem->isVisible()){ |
|
|
|
if(strokesGroupItem && strokesGroupItem->isVisible()){ |
|
|
|
QDomElement newGroupElement; |
|
|
|
|
|
|
|
if (!strokesGroupItem->parentItem() && strokesGroupItem->childItems().count()) { |
|
|
|
|
|
|
|
newGroupElement = groupDomDocument.createElement(tGroup); |
|
|
|
|
|
|
|
newGroupElement.setAttribute(aId, strokesGroupItem->uuid().toString()); |
|
|
|
|
|
|
|
groupRoot.appendChild(newGroupElement); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//disabling g section parsing as a group of elements. Use groups refs instead
|
|
|
|
|
|
|
|
// mXmlWriter.writeStartElement("g");
|
|
|
|
|
|
|
|
// mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(strokesGroupItem->uuid()));
|
|
|
|
|
|
|
|
// QMatrix matrix = item->sceneMatrix();
|
|
|
|
|
|
|
|
// if (!matrix.isIdentity()){
|
|
|
|
|
|
|
|
// mXmlWriter.writeAttribute("transform", toSvgTransform(matrix));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add the polygons
|
|
|
|
// Add the polygons
|
|
|
|
foreach(QGraphicsItem* item, strokesGroupItem->childItems()){ |
|
|
|
foreach(QGraphicsItem* item, strokesGroupItem->childItems()){ |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsPolygonItem* poly = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); |
|
|
|
UBGraphicsPolygonItem* poly = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); |
|
|
|
if(NULL != poly){ |
|
|
|
if(NULL != poly){ |
|
|
|
polygonItemToSvgPolygon(poly, true); |
|
|
|
polygonItemToSvgPolygon(poly, true); |
|
|
|
if (!newGroupElement.isNull()) { |
|
|
|
|
|
|
|
QDomElement curPolygonElement = groupDomDocument.createElement(tElement); |
|
|
|
|
|
|
|
curPolygonElement.setAttribute(aId, strokesGroupItem->uuid().toString() |
|
|
|
|
|
|
|
+ poly->uuid().toString()); |
|
|
|
|
|
|
|
newGroupElement.appendChild(curPolygonElement); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
items.removeOne(poly); |
|
|
|
items.removeOne(poly); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// mXmlWriter.writeEndElement(); //g
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Is the item a polygon?
|
|
|
|
// Is the item a polygon?
|
|
|
@ -1554,14 +1560,16 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro |
|
|
|
if (!tmpUuid.isNull()) { |
|
|
|
if (!tmpUuid.isNull()) { |
|
|
|
if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) { |
|
|
|
if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) { |
|
|
|
persistGroupToDom(item, curParent, groupDomDocument); |
|
|
|
persistGroupToDom(item, curParent, groupDomDocument); |
|
|
|
} else if (item->type() == UBGraphicsStrokesGroup::Type) { |
|
|
|
|
|
|
|
foreach (QGraphicsItem *polygonItem, item->childItems()) { |
|
|
|
|
|
|
|
QDomElement curPolygonElement = groupDomDocument->createElement(tElement); |
|
|
|
|
|
|
|
curPolygonElement.setAttribute(aId, tmpUuid.toString() |
|
|
|
|
|
|
|
+ UBGraphicsItem::getOwnUuid(polygonItem).toString()); |
|
|
|
|
|
|
|
curGroupElement.appendChild(curPolygonElement); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// else if (item->type() == UBGraphicsStrokesGroup::Type) {
|
|
|
|
|
|
|
|
// foreach (QGraphicsItem *polygonItem, item->childItems()) {
|
|
|
|
|
|
|
|
// QDomElement curPolygonElement = groupDomDocument->createElement(tElement);
|
|
|
|
|
|
|
|
// curPolygonElement.setAttribute(aId, tmpUuid.toString()
|
|
|
|
|
|
|
|
// + UBGraphicsItem::getOwnUuid(polygonItem).toString());
|
|
|
|
|
|
|
|
// curGroupElement.appendChild(curPolygonElement);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
else { |
|
|
|
QDomElement curSubElement = groupDomDocument->createElement(tElement); |
|
|
|
QDomElement curSubElement = groupDomDocument->createElement(tElement); |
|
|
|
|
|
|
|
|
|
|
|
curSubElement.setAttribute(aId, tmpUuid); |
|
|
|
curSubElement.setAttribute(aId, tmpUuid); |
|
|
@ -1572,27 +1580,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistStrokeToDom(QGraphicsItem *strokeItem, QDomElement *curParent, QDomDocument *curDomDocument) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QUuid uuid = UBGraphicsScene::getPersonalUuid(strokeItem); |
|
|
|
|
|
|
|
if (!uuid.isNull()) { |
|
|
|
|
|
|
|
QDomElement curStrokesGroupElement = curDomDocument->createElement(tStrokeGroup); |
|
|
|
|
|
|
|
curStrokesGroupElement.setAttribute(aId, uuid); |
|
|
|
|
|
|
|
curParent->appendChild(curStrokesGroupElement); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (QGraphicsItem *item, strokeItem->childItems()) { |
|
|
|
|
|
|
|
QUuid tmpUuid = UBGraphicsScene::getPersonalUuid(item); |
|
|
|
|
|
|
|
if (!tmpUuid.isNull()) { |
|
|
|
|
|
|
|
if (item->type() == UBGraphicsPolygonItem::Type && item->childItems().count()) { |
|
|
|
|
|
|
|
QDomElement curSubElement = curDomDocument->createElement(tElement); |
|
|
|
|
|
|
|
curSubElement.setAttribute(aId, tmpUuid); |
|
|
|
|
|
|
|
curStrokesGroupElement.appendChild(curSubElement); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) |
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mXmlWriter.writeStartElement("line"); |
|
|
|
mXmlWriter.writeStartElement("line"); |
|
|
|