From 2d796827a42a3182526d4b9d8930019d3a171b2c Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Tue, 8 Dec 2015 15:00:43 +0100 Subject: [PATCH 1/6] Copy z-Value when deep-copying a UBGraphicsPolygonItem --- src/domain/UBGraphicsPolygonItem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/domain/UBGraphicsPolygonItem.cpp b/src/domain/UBGraphicsPolygonItem.cpp index 1f5b40c3..48530b97 100644 --- a/src/domain/UBGraphicsPolygonItem.cpp +++ b/src/domain/UBGraphicsPolygonItem.cpp @@ -197,6 +197,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const cp->setColorOnDarkBackground(this->colorOnDarkBackground()); cp->setColorOnLightBackground(this->colorOnLightBackground()); + cp->setZValue(this->zValue()); cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); } } From 8ed2e2451dfb08000327e7a07e9a1f376ebda3d3 Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Tue, 8 Dec 2015 16:58:13 +0100 Subject: [PATCH 2/6] Removed export of polygons outside of groups The lines removed in this commit led to (presumably) unintended behavior: when saving a document, pen strokes were saved not as a group, but just as their constituent polygons. This meant that the following block of code, that handles saving pen strokes correctly, was never executed. This doesn't fix the z-Value issue (#12), but it seems to be a step in the right direction. --- src/adaptors/UBSvgSubsetAdaptor.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 376a5f88..2ba03817 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -1077,20 +1077,6 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) { QGraphicsItem *item = items.takeFirst(); - // Is the item a strokes group? - UBGraphicsStrokesGroup* strokesGroupItem = qgraphicsitem_cast(item); - - if(strokesGroupItem && strokesGroupItem->isVisible()){ - // Add the polygons - foreach(QGraphicsItem* item, strokesGroupItem->childItems()){ - UBGraphicsPolygonItem* poly = qgraphicsitem_cast(item); - if(NULL != poly){ - polygonItemToSvgPolygon(poly, true); - items.removeOne(poly); - } - } - } - // Is the item a polygon? UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast (item); if (polygonItem && polygonItem->isVisible()) @@ -2112,6 +2098,7 @@ UBGraphicsMediaItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::videoItemFromSvg() void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* gItem) { + // TODO: check position QStringRef svgTransform = mXmlReader.attributes().value("transform"); QMatrix itemMatrix; From 3c44bfb94a46ac004a3ea340dad3761ff480b1d9 Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Wed, 9 Dec 2015 12:08:45 +0100 Subject: [PATCH 3/6] Removed old debug messages --- src/board/UBBoardView.cpp | 1 - src/domain/UBSelectionFrame.cpp | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 57b61d6f..670ee9e3 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -1083,7 +1083,6 @@ void UBBoardView::mouseMoveEvent (QMouseEvent *event) // QTime mouseMoveTime = QTime::currentTime(); if(!mIsDragInProgress && ((mapToScene(event->pos()) - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())) { - qDebug() << "mouse move event canceled"; return; } diff --git a/src/domain/UBSelectionFrame.cpp b/src/domain/UBSelectionFrame.cpp index 89da1c6d..653e50f2 100644 --- a/src/domain/UBSelectionFrame.cpp +++ b/src/domain/UBSelectionFrame.cpp @@ -243,9 +243,6 @@ void UBSelectionFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/) void UBSelectionFrame::onZoomChanged(qreal pZoom) { - qDebug() << "Pzoom" << pZoom; - qDebug() << "Board current zoom" << UBApplication::boardController->currentZoom(); - qDebug() << "UBApplication::boardController->systemScaleFactor()" << UBApplication::boardController->systemScaleFactor(); mAntiscaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * pZoom); } @@ -458,7 +455,6 @@ QList UBSelectionFrame::sortedByZ(const QList & QList UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) { - qDebug() << "buttons for flags" << QString::number((int)fls, 2); QList result; if (!mDeleteButton) { From 4d74341c689ffad7644c88127f845ea59eb0581a Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Wed, 9 Dec 2015 12:12:01 +0100 Subject: [PATCH 4/6] Fixed pen strokes' zLevels not being saved to file (Issue #12) --- src/adaptors/UBSvgSubsetAdaptor.cpp | 2 +- src/domain/UBGraphicsScene.cpp | 4 ++++ src/domain/UBGraphicsStrokesGroup.cpp | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 2ba03817..bfd1a0b0 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -1111,7 +1111,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) if (colorOnDarkBackground.isValid() && colorOnLightBackground.isValid()) { mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "z-value" - , QString("%1").arg(polygonItem->zValue())); + , QString("%1").arg(polygonItem->strokesGroup()->zValue())); mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri , "fill-on-dark-background", colorOnDarkBackground.name()); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 63197044..a9acebbd 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -262,6 +262,10 @@ qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination de } //Return new z value assigned to item + + // experimental + item->setZValue(item->data(UBGraphicsItemData::ItemOwnZValue).toReal()); + return item->data(UBGraphicsItemData::ItemOwnZValue).toReal(); } diff --git a/src/domain/UBGraphicsStrokesGroup.cpp b/src/domain/UBGraphicsStrokesGroup.cpp index b7eb51c3..e5aa0884 100644 --- a/src/domain/UBGraphicsStrokesGroup.cpp +++ b/src/domain/UBGraphicsStrokesGroup.cpp @@ -185,6 +185,7 @@ void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const cp->setFlag(QGraphicsItem::ItemIsSelectable, true); cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked)); + cp->setZValue(this->zValue()); } } From 67522011547617a272cf2cdb3d23ff92ea5d750c Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Wed, 9 Dec 2015 13:02:14 +0100 Subject: [PATCH 5/6] Fixed saving of all graphicsItems' zValues Simply added copying of zValue to the deep copy functions. As tested on OSX, this does pose any problems when duplicating an item on-page (i.e generating a new item with a zValue equal to its original). --- src/domain/UBGraphicsMediaItem.cpp | 2 ++ src/domain/UBGraphicsPDFItem.cpp | 1 + src/domain/UBGraphicsPixmapItem.cpp | 2 ++ src/domain/UBGraphicsSvgItem.cpp | 1 + src/domain/UBGraphicsTextItem.cpp | 1 + src/domain/UBGraphicsWidgetItem.cpp | 1 + 6 files changed, 8 insertions(+) diff --git a/src/domain/UBGraphicsMediaItem.cpp b/src/domain/UBGraphicsMediaItem.cpp index ec3bcd57..ad9dcfeb 100644 --- a/src/domain/UBGraphicsMediaItem.cpp +++ b/src/domain/UBGraphicsMediaItem.cpp @@ -275,6 +275,8 @@ void UBGraphicsMediaItem::copyItemParameters(UBItem *copy) const cp->setSourceUrl(this->sourceUrl()); cp->resize(this->size()); + cp->setZValue(this->zValue()); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), cp, SLOT(activeSceneChanged())); // TODO UB 4.7 complete all members } diff --git a/src/domain/UBGraphicsPDFItem.cpp b/src/domain/UBGraphicsPDFItem.cpp index 03bb763c..09e68b9a 100644 --- a/src/domain/UBGraphicsPDFItem.cpp +++ b/src/domain/UBGraphicsPDFItem.cpp @@ -122,6 +122,7 @@ void UBGraphicsPDFItem::copyItemParameters(UBItem *copy) const cp->setFlag(QGraphicsItem::ItemIsSelectable, true); cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setSourceUrl(this->sourceUrl()); + cp->setZValue(this->zValue()); } } diff --git a/src/domain/UBGraphicsPixmapItem.cpp b/src/domain/UBGraphicsPixmapItem.cpp index be1a3551..44a532d5 100644 --- a/src/domain/UBGraphicsPixmapItem.cpp +++ b/src/domain/UBGraphicsPixmapItem.cpp @@ -156,6 +156,8 @@ void UBGraphicsPixmapItem::copyItemParameters(UBItem *copy) const cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked)); cp->setSourceUrl(this->sourceUrl()); + + cp->setZValue(this->zValue()); } } diff --git a/src/domain/UBGraphicsSvgItem.cpp b/src/domain/UBGraphicsSvgItem.cpp index 8b8e6b82..172fd0c3 100644 --- a/src/domain/UBGraphicsSvgItem.cpp +++ b/src/domain/UBGraphicsSvgItem.cpp @@ -180,6 +180,7 @@ void UBGraphicsSvgItem::copyItemParameters(UBItem *copy) const cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked)); cp->setSourceUrl(this->sourceUrl()); + cp->setZValue(this->zValue()); } } diff --git a/src/domain/UBGraphicsTextItem.cpp b/src/domain/UBGraphicsTextItem.cpp index a9f949b2..aa389856 100644 --- a/src/domain/UBGraphicsTextItem.cpp +++ b/src/domain/UBGraphicsTextItem.cpp @@ -280,6 +280,7 @@ void UBGraphicsTextItem::copyItemParameters(UBItem *copy) const cp->setTextHeight(this->textHeight()); cp->setSourceUrl(this->sourceUrl()); + cp->setZValue(this->zValue()); } } diff --git a/src/domain/UBGraphicsWidgetItem.cpp b/src/domain/UBGraphicsWidgetItem.cpp index 9ec12d59..757f0c63 100644 --- a/src/domain/UBGraphicsWidgetItem.cpp +++ b/src/domain/UBGraphicsWidgetItem.cpp @@ -744,6 +744,7 @@ void UBGraphicsAppleWidgetItem::copyItemParameters(UBItem *copy) const } cp->setSourceUrl(this->sourceUrl()); + cp->setZValue(this->zValue()); } } From 64002a17063f2068e8af59f5a5cfb76c04681549 Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Wed, 9 Dec 2015 15:03:24 +0100 Subject: [PATCH 6/6] Set zValue during deepCopy for W3C widget and curtain item --- src/domain/UBGraphicsWidgetItem.cpp | 2 ++ src/tools/UBGraphicsCurtainItem.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/domain/UBGraphicsWidgetItem.cpp b/src/domain/UBGraphicsWidgetItem.cpp index 757f0c63..6dabaeec 100644 --- a/src/domain/UBGraphicsWidgetItem.cpp +++ b/src/domain/UBGraphicsWidgetItem.cpp @@ -1229,6 +1229,8 @@ void UBGraphicsW3CWidgetItem::copyItemParameters(UBItem *copy) const { cp->setDatastoreEntry(key, mDatastore.value(key)); } + + cp->setZValue(this->zValue()); } } diff --git a/src/tools/UBGraphicsCurtainItem.cpp b/src/tools/UBGraphicsCurtainItem.cpp index 93389975..9e7c512d 100644 --- a/src/tools/UBGraphicsCurtainItem.cpp +++ b/src/tools/UBGraphicsCurtainItem.cpp @@ -167,6 +167,7 @@ void UBGraphicsCurtainItem::copyItemParameters(UBItem *copy) const cp->setFlag(QGraphicsItem::ItemIsMovable, true); cp->setFlag(QGraphicsItem::ItemIsSelectable, true); cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); + cp->setZValue(this->zValue()); } }