From 7c45b593150e4348d886934421554c4312c57e10 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Mon, 15 Apr 2013 16:05:34 +0200 Subject: [PATCH] fix on polyline. Create a stroke group with a polyline --- src/adaptors/UBSvgSubsetAdaptor.cpp | 36 +++-------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 82a31957..def7c8d1 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -389,7 +389,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() mFileVersion = 40100; // default to 4.1.0 - UBGraphicsStroke* annotationGroup = 0; UBGraphicsStrokesGroup* strokesGroup = 0; while (!mXmlReader.atEnd()) @@ -514,16 +513,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() } else if (mXmlReader.name() == "g") { - // Create new stroke, if its NULL or already has polygons - if (annotationGroup) - { - if (!annotationGroup->polygons().empty()) - annotationGroup = new UBGraphicsStroke(); - } - else - annotationGroup = new UBGraphicsStroke(); - - strokesGroup = new UBGraphicsStrokesGroup(); graphicsItemFromSvg(strokesGroup); @@ -568,10 +557,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() { polygonItem->setUuid(uuidFromSvg); - if (annotationGroup) - polygonItem->setStroke(annotationGroup); - - if(strokesGroup){ polygonItem->setTransform(strokesGroup->transform()); strokesGroup->addToGroup(polygonItem); @@ -598,13 +583,10 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() QList polygonItems = polygonItemsFromPolylineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black); + QString parentId = QUuid::createUuid().toString(); + foreach(UBGraphicsPolygonItem* polygonItem, polygonItems) { - if (annotationGroup) - { - polygonItem->setStroke(annotationGroup); - } - if(strokesGroup){ polygonItem->setTransform(strokesGroup->transform()); @@ -614,8 +596,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() 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(); @@ -625,6 +605,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() group = mStrokesList.value(parentId); polygonItem->show(); + group->addToGroup(polygonItem); } } else if (mXmlReader.name() == "image") @@ -985,11 +966,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() { if (mXmlReader.name() == "g") { - if (annotationGroup) - { - if (!annotationGroup->polygons().empty()) - annotationGroup = 0; - } mGroupHasInfo = false; mGroupDarkBackgroundColor = QColor(); mGroupLightBackgroundColor = QColor(); @@ -1014,12 +990,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() mScene->setModified(false); } - if (annotationGroup) - { - if (annotationGroup->polygons().empty()) - delete annotationGroup; - } - mScene->enableUndoRedoStack(); qDebug() << "loadScene() : created scene and read file"; return mScene;