|
|
@ -97,12 +97,12 @@ QMap<QString,IDataStorage*> UBSvgSubsetAdaptor::additionalElementToStore; |
|
|
|
QString UBSvgSubsetAdaptor::toSvgTransform(const QMatrix& matrix) |
|
|
|
QString UBSvgSubsetAdaptor::toSvgTransform(const QMatrix& matrix) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return QString("matrix(%1, %2, %3, %4, %5, %6)") |
|
|
|
return QString("matrix(%1, %2, %3, %4, %5, %6)") |
|
|
|
.arg(matrix.m11(), 0 , 'g') |
|
|
|
.arg(matrix.m11(), 0 , 'g') |
|
|
|
.arg(matrix.m12(), 0 , 'g') |
|
|
|
.arg(matrix.m12(), 0 , 'g') |
|
|
|
.arg(matrix.m21(), 0 , 'g') |
|
|
|
.arg(matrix.m21(), 0 , 'g') |
|
|
|
.arg(matrix.m22(), 0 , 'g') |
|
|
|
.arg(matrix.m22(), 0 , 'g') |
|
|
|
.arg(matrix.dx(), 0 , 'g') |
|
|
|
.arg(matrix.dx(), 0 , 'g') |
|
|
|
.arg(matrix.dy(), 0 , 'g'); |
|
|
|
.arg(matrix.dy(), 0 , 'g'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -117,12 +117,12 @@ QMatrix UBSvgSubsetAdaptor::fromSvgTransform(const QString& transform) |
|
|
|
if (sl.size() >= 6) |
|
|
|
if (sl.size() >= 6) |
|
|
|
{ |
|
|
|
{ |
|
|
|
matrix.setMatrix( |
|
|
|
matrix.setMatrix( |
|
|
|
sl.at(0).toFloat(), |
|
|
|
sl.at(0).toFloat(), |
|
|
|
sl.at(1).toFloat(), |
|
|
|
sl.at(1).toFloat(), |
|
|
|
sl.at(2).toFloat(), |
|
|
|
sl.at(2).toFloat(), |
|
|
|
sl.at(3).toFloat(), |
|
|
|
sl.at(3).toFloat(), |
|
|
|
sl.at(4).toFloat(), |
|
|
|
sl.at(4).toFloat(), |
|
|
|
sl.at(5).toFloat()); |
|
|
|
sl.at(5).toFloat()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return matrix; |
|
|
|
return matrix; |
|
|
@ -340,7 +340,7 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex) |
|
|
|
mXmlReader.readNext(); |
|
|
|
mXmlReader.readNext(); |
|
|
|
if (mXmlReader.isStartElement()) |
|
|
|
if (mXmlReader.isStartElement()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){ |
|
|
|
if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){ |
|
|
|
result.clear(); |
|
|
|
result.clear(); |
|
|
|
result += "<teacherGuide version=\"" + mXmlReader.attributes().value("version").toString() + "\">"; |
|
|
|
result += "<teacherGuide version=\"" + mXmlReader.attributes().value("version").toString() + "\">"; |
|
|
|
result += "\n"; |
|
|
|
result += "\n"; |
|
|
@ -372,10 +372,10 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBSvgSubsetAdaptor::UBSvgSubsetReader::UBSvgSubsetReader(UBDocumentProxy* pProxy, const QByteArray& pXmlData) |
|
|
|
UBSvgSubsetAdaptor::UBSvgSubsetReader::UBSvgSubsetReader(UBDocumentProxy* pProxy, const QByteArray& pXmlData) |
|
|
|
: mXmlReader(pXmlData) |
|
|
|
: mXmlReader(pXmlData) |
|
|
|
, mProxy(pProxy) |
|
|
|
, mProxy(pProxy) |
|
|
|
, mDocumentPath(pProxy->persistencePath()) |
|
|
|
, mDocumentPath(pProxy->persistencePath()) |
|
|
|
, mGroupHasInfo(false) |
|
|
|
, mGroupHasInfo(false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// NOOP
|
|
|
|
// NOOP
|
|
|
|
} |
|
|
|
} |
|
|
@ -588,7 +588,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() |
|
|
|
else if (mXmlReader.name() == "polyline") |
|
|
|
else if (mXmlReader.name() == "polyline") |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<UBGraphicsPolygonItem*> polygonItems |
|
|
|
QList<UBGraphicsPolygonItem*> polygonItems |
|
|
|
= polygonItemsFromPolylineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black); |
|
|
|
= polygonItemsFromPolylineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black); |
|
|
|
|
|
|
|
|
|
|
|
QString parentId = QUuid::createUuid().toString(); |
|
|
|
QString parentId = QUuid::createUuid().toString(); |
|
|
|
|
|
|
|
|
|
|
@ -1111,9 +1111,9 @@ void UBSvgSubsetAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* p |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBSvgSubsetAdaptor::UBSvgSubsetWriter::UBSvgSubsetWriter(UBDocumentProxy* proxy, UBGraphicsScene* pScene, const int pageIndex) |
|
|
|
UBSvgSubsetAdaptor::UBSvgSubsetWriter::UBSvgSubsetWriter(UBDocumentProxy* proxy, UBGraphicsScene* pScene, const int pageIndex) |
|
|
|
: mScene(pScene) |
|
|
|
: mScene(pScene) |
|
|
|
, mDocumentPath(proxy->persistencePath()) |
|
|
|
, mDocumentPath(proxy->persistencePath()) |
|
|
|
, mPageIndex(pageIndex) |
|
|
|
, mPageIndex(pageIndex) |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// NOOP
|
|
|
|
// NOOP
|
|
|
@ -1216,23 +1216,23 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) |
|
|
|
|
|
|
|
|
|
|
|
foreach(QGraphicsItem* item, strokesGroupItem->childItems()) { |
|
|
|
foreach(QGraphicsItem* item, strokesGroupItem->childItems()) { |
|
|
|
UBGraphicsPolygonItem* poly = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); |
|
|
|
UBGraphicsPolygonItem* poly = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); |
|
|
|
if (!poly) { |
|
|
|
if (!poly) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} else if (!resultPoly) { |
|
|
|
if (!resultPoly) { |
|
|
|
resultPoly = poly; |
|
|
|
resultPoly = poly; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
QPolygonF newPolygon = poly->sceneTransform().map(poly->polygon()); |
|
|
|
|
|
|
|
QPainterPath strokePainterPath; |
|
|
|
QPolygonF unitedPolygon = resultPoly->polygon().united(poly->polygon()); |
|
|
|
strokePainterPath.addPolygon(resultPoly->sceneTransform().map(resultPoly->polygon())); |
|
|
|
resultPoly->setPolygon(unitedPolygon); |
|
|
|
QPolygonF oldPolygons = strokePainterPath.simplified().toFillPolygon(resultPoly->sceneTransform().inverted()); |
|
|
|
|
|
|
|
newPolygon = oldPolygons.united(newPolygon); |
|
|
|
|
|
|
|
resultPoly->setPolygon(newPolygon); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
items.removeOne(poly); |
|
|
|
items.removeOne(poly); |
|
|
|
} |
|
|
|
} |
|
|
|
if (resultPoly) { |
|
|
|
if (resultPoly) { |
|
|
|
|
|
|
|
//Claudio: the painter path simplification remove all the polygons overlap
|
|
|
|
|
|
|
|
QPainterPath painterPath; |
|
|
|
|
|
|
|
painterPath.addPolygon(resultPoly->polygon()); |
|
|
|
|
|
|
|
painterPath = painterPath.simplified(); |
|
|
|
|
|
|
|
resultPoly->setPolygon(painterPath.toFillPolygon()); |
|
|
|
polygonItemToSvgPolygon(resultPoly, true); |
|
|
|
polygonItemToSvgPolygon(resultPoly, true); |
|
|
|
items.removeOne(resultPoly); |
|
|
|
items.removeOne(resultPoly); |
|
|
|
} |
|
|
|
} |
|
|
@ -1242,9 +1242,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) |
|
|
|
UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*> (item); |
|
|
|
UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*> (item); |
|
|
|
if (polygonItem && polygonItem->isVisible()) |
|
|
|
if (polygonItem && polygonItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsStroke* currentStroke = polygonItem->stroke(); |
|
|
|
UBGraphicsStroke* currentStroke = polygonItem->stroke(); |
|
|
|
|
|
|
|
|
|
|
|
if (openStroke && (currentStroke != openStroke)) |
|
|
|
if (openStroke && (currentStroke != openStroke)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mXmlWriter.writeEndElement(); //g
|
|
|
|
mXmlWriter.writeEndElement(); //g
|
|
|
@ -1703,7 +1701,7 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol |
|
|
|
if (!svgPoints.isNull()) |
|
|
|
if (!svgPoints.isNull()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QStringList ts = svgPoints.toString().split(QLatin1Char(' '), |
|
|
|
QStringList ts = svgPoints.toString().split(QLatin1Char(' '), |
|
|
|
QString::SkipEmptyParts); |
|
|
|
QString::SkipEmptyParts); |
|
|
|
|
|
|
|
|
|
|
|
foreach(const QString sPoint, ts) |
|
|
|
foreach(const QString sPoint, ts) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1998,7 +1996,7 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem |
|
|
|
if (!svgPoints.isNull()) |
|
|
|
if (!svgPoints.isNull()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QStringList ts = svgPoints.toString().split(QLatin1Char(' '), |
|
|
|
QStringList ts = svgPoints.toString().split(QLatin1Char(' '), |
|
|
|
QString::SkipEmptyParts); |
|
|
|
QString::SkipEmptyParts); |
|
|
|
|
|
|
|
|
|
|
|
QList<QPointF> points; |
|
|
|
QList<QPointF> points; |
|
|
|
|
|
|
|
|
|
|
@ -2370,9 +2368,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!svgX.isNull() && !svgY.isNull()) |
|
|
|
if (!svgX.isNull() && !svgY.isNull()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef Q_WS_WIN |
|
|
|
#ifdef Q_WS_WIN |
|
|
|
gItem->setPos(svgX.toString().toFloat(), svgY.toString().toFloat()); |
|
|
|
gItem->setPos(svgX.toString().toFloat(), svgY.toString().toFloat()); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2749,7 +2747,7 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
color.setNamedColor(ubFillOnLightBackground.toString()); |
|
|
|
color.setNamedColor(ubFillOnLightBackground.toString()); |
|
|
|
if (!color.isValid()) |
|
|
|
if (!color.isValid()) |
|
|
|
color = Qt::black; |
|
|
|
color = Qt::black; |
|
|
|
textItem->setColorOnLightBackground(color); |
|
|
|
textItem->setColorOnLightBackground(color); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString text; |
|
|
|
QString text; |
|
|
@ -2779,7 +2777,7 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
return textItem; |
|
|
|
return textItem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//tracking for backward capability with older versions
|
|
|
|
//tracking for backward capability with older versions
|
|
|
|
} else if (mXmlReader.name() == "font") { |
|
|
|
} else if (mXmlReader.name() == "font") { |
|
|
|
QFont font = textItem->font(); |
|
|
|
QFont font = textItem->font(); |
|
|
|
|
|
|
|
|
|
|
@ -2794,18 +2792,18 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
styleToken = styleToken.trimmed(); |
|
|
|
styleToken = styleToken.trimmed(); |
|
|
|
if (styleToken.startsWith(sFontSizePrefix) && styleToken.endsWith(sPixelUnit)) { |
|
|
|
if (styleToken.startsWith(sFontSizePrefix) && styleToken.endsWith(sPixelUnit)) { |
|
|
|
int fontSize = styleToken.mid( |
|
|
|
int fontSize = styleToken.mid( |
|
|
|
sFontSizePrefix.length(), |
|
|
|
sFontSizePrefix.length(), |
|
|
|
styleToken.length() - sFontSizePrefix.length() - sPixelUnit.length()).toInt(); |
|
|
|
styleToken.length() - sFontSizePrefix.length() - sPixelUnit.length()).toInt(); |
|
|
|
font.setPixelSize(fontSize); |
|
|
|
font.setPixelSize(fontSize); |
|
|
|
} else if (styleToken.startsWith(sFontWeightPrefix)) { |
|
|
|
} else if (styleToken.startsWith(sFontWeightPrefix)) { |
|
|
|
QString fontWeight = styleToken.mid( |
|
|
|
QString fontWeight = styleToken.mid( |
|
|
|
sFontWeightPrefix.length(), |
|
|
|
sFontWeightPrefix.length(), |
|
|
|
styleToken.length() - sFontWeightPrefix.length()); |
|
|
|
styleToken.length() - sFontWeightPrefix.length()); |
|
|
|
font.setBold(fontWeight.contains("bold")); |
|
|
|
font.setBold(fontWeight.contains("bold")); |
|
|
|
} else if (styleToken.startsWith(sFontStylePrefix)) { |
|
|
|
} else if (styleToken.startsWith(sFontStylePrefix)) { |
|
|
|
QString fontStyle = styleToken.mid( |
|
|
|
QString fontStyle = styleToken.mid( |
|
|
|
sFontStylePrefix.length(), |
|
|
|
sFontStylePrefix.length(), |
|
|
|
styleToken.length() - sFontStylePrefix.length()); |
|
|
|
styleToken.length() - sFontStylePrefix.length()); |
|
|
|
font.setItalic(fontStyle.contains("italic")); |
|
|
|
font.setItalic(fontStyle.contains("italic")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -3159,7 +3157,7 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg() |
|
|
|
UBGraphicsTriangle::UBGraphicsTriangleOrientation orientation = UBGraphicsTriangle::orientationFromStr(orientationStringRef); |
|
|
|
UBGraphicsTriangle::UBGraphicsTriangleOrientation orientation = UBGraphicsTriangle::orientationFromStr(orientationStringRef); |
|
|
|
triangle->setOrientation(orientation); |
|
|
|
triangle->setOrientation(orientation); |
|
|
|
|
|
|
|
|
|
|
|
if (!svgX.isNull() && !svgY.isNull() && !svgWidth.isNull() && !svgHeight.isNull()) |
|
|
|
if (!svgX.isNull() && !svgY.isNull() && !svgWidth.isNull() && !svgHeight.isNull()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
triangle->setRect(svgX.toString().toFloat(), svgY.toString().toFloat(), svgWidth.toString().toFloat(), svgHeight.toString().toFloat(), orientation); |
|
|
|
triangle->setRect(svgX.toString().toFloat(), svgY.toString().toFloat(), svgWidth.toString().toFloat(), svgHeight.toString().toFloat(), orientation); |
|
|
|
} |
|
|
|
} |
|
|
|