Fixed Mask (curtain item) posision after exporting and importing. (a part of SANKPRE-223?)

preferencesAboutTextFull
Aleksei Kanash 13 years ago
parent 650346f715
commit b891c42a4d
  1. 25
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 15
      src/domain/UBGraphicsScene.cpp

@ -2424,8 +2424,23 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::curtainItemToSvg(UBGraphicsCurtainIt
*/ */
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "curtain"); mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "curtain");
mXmlWriter.writeAttribute("x", QString("%1").arg(curtainItem->boundingRect().center().x()));
mXmlWriter.writeAttribute("y", QString("%1").arg(curtainItem->boundingRect().center().y()));
mXmlWriter.writeAttribute("width", QString("%1").arg(curtainItem->boundingRect().width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(curtainItem->boundingRect().height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(curtainItem->sceneMatrix()));
//graphicsItemToSvg(curtainItem);
QString zs;
zs.setNum(curtainItem->zValue(), 'f'); // 'f' keeps precision
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "z-value", zs);
UBItem* ubItem = dynamic_cast<UBItem*>(curtainItem);
graphicsItemToSvg(curtainItem); if (ubItem)
{
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(ubItem->uuid()));
}
mXmlWriter.writeEndElement(); mXmlWriter.writeEndElement();
} }
@ -2437,13 +2452,17 @@ UBGraphicsCurtainItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::curtainItemFromSvg
graphicsItemFromSvg(curtainItem); graphicsItemFromSvg(curtainItem);
QStringRef svgX = mXmlReader.attributes().value("x");
QStringRef svgY = mXmlReader.attributes().value("y");
QStringRef svgWidth = mXmlReader.attributes().value("width"); QStringRef svgWidth = mXmlReader.attributes().value("width");
QStringRef svgHeight = mXmlReader.attributes().value("height"); QStringRef svgHeight = mXmlReader.attributes().value("height");
QRectF rect = curtainItem->rect();
QRect rect;
rect.setX(svgX.toString().toFloat()-svgWidth.toString().toFloat()/2);
rect.setY(svgY.toString().toFloat()-svgHeight.toString().toFloat()/2);
rect.setWidth(svgWidth.toString().toFloat()); rect.setWidth(svgWidth.toString().toFloat());
rect.setHeight(svgHeight.toString().toFloat()); rect.setHeight(svgHeight.toString().toFloat());
rect.translate(- rect.center());
curtainItem->setRect(rect); curtainItem->setRect(rect);

@ -1771,18 +1771,17 @@ void UBGraphicsScene::addMask(const QPointF &center)
view = (QGraphicsView*)UBApplication::boardController->displayView(); view = (QGraphicsView*)UBApplication::boardController->displayView();
else else
view = (QGraphicsView*)UBApplication::boardController->controlView(); view = (QGraphicsView*)UBApplication::boardController->controlView();
*/
// curtain->setZValue(toolLayerStart + toolOffsetCurtain);
UBGraphicsItem::assignZValue(curtain, toolLayerStart + toolOffsetCurtain);
QRectF rect = UBApplication::boardController->activeScene()->normalizedSceneRect();
rect.setSize(QSizeF(rect.width()/2, rect.height()/2));
QPointF origin = center.isNull() ? rect.bottomRight() : center;
curtain->setRect(rect.translated(origin - rect.topLeft() / 2));
addItem(curtain); addItem(curtain);
QRectF rect = UBApplication::boardController->activeScene()->normalizedSceneRect();
rect.setRect(center.x() - rect.width()/4, center.y() - rect.height()/4, rect.width()/2 , rect.height()/2);
QPointF origin = center.isNull() ? rect.bottomRight() : center;
curtain->setRect(rect);//rect.translated(origin - rect.topLeft() / 2));
UBGraphicsItem::assignZValue(curtain, toolLayerStart + toolOffsetCurtain);
curtain->setVisible(true); curtain->setVisible(true);
curtain->setSelected(true); curtain->setSelected(true);
setModified(true); setModified(true);

Loading…
Cancel
Save