Fix saving of polygons' fill rule

Up until now, the fill rule of a polygon was always saved as even-odd,
despite the fact that in most if not all cases, polygons are drawn with
winding fill within OpenBoard.
Saving is now fixed, but there is no way to know upon loading whether
the polygon was correctly saved or whether; so for now, we just set the
fill rule to Winding when loading a polygon.
preferencesAboutTextFull
Craig Watson 8 years ago
parent 1070251d1c
commit 8365f2f7a6
  1. 23
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 1
      src/domain/UBGraphicsPolygonItem.cpp

@ -1599,6 +1599,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgPolygon(UBGraphicsPo
if (polygonItem->fillRule() == Qt::OddEvenFill)
mXmlWriter.writeAttribute("fill-rule", "evenodd");
else
mXmlWriter.writeAttribute("fill-rule", "winding");
if (!groupHoldsInfo)
{
@ -1720,6 +1722,27 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
color.setAlphaF(opacity);
polygonItem->setColorOnLightBackground(color);
}
/*
Unfortunately the fill rule was never saved correctly until OpenBoard v1.4,
before then, it was always saved as even-odd. So we can't load it safely here.
Saving is now fixed, but any old documents would be loaded incorrectly if the code
below is used. It should be activated at some point in the future though.
QStringRef fillRule = mXmlReader.attributes().value("fill-rule");
if (!fillRule.isNull()) {
QString value = fillRule.toString();
if (value == "evenodd")
polygonItem->setFillRule(Qt::OddEvenFill);
else
polygonItem->setFillRule(Qt::WindingFill);
}
*/
polygonItem->setFillRule(Qt::WindingFill);
return polygonItem;
}

@ -171,6 +171,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
cp->setBrush(this->brush());
cp->setPen(this->pen());
cp->mHasAlpha = this->mHasAlpha;
cp->setFillRule(this->fillRule());
cp->setColorOnDarkBackground(this->colorOnDarkBackground());
cp->setColorOnLightBackground(this->colorOnLightBackground());

Loading…
Cancel
Save