diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 660a2f5a..6533e06a 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -107,7 +107,8 @@ QMatrix UBSvgSubsetAdaptor::fromSvgTransform(const QString& transform) static bool itemZIndexComp(const QGraphicsItem* item1, const QGraphicsItem* item2) { - return item1->zValue() < item2->zValue(); +// return item1->zValue() < item2->zValue(); + return item1->data(UBGraphicsItemData::ItemOwnZValue).toReal() < item2->data(UBGraphicsItemData::ItemOwnZValue).toReal(); } diff --git a/src/domain/UBGraphicsDelegateFrame.cpp b/src/domain/UBGraphicsDelegateFrame.cpp index a6f17114..393353d1 100644 --- a/src/domain/UBGraphicsDelegateFrame.cpp +++ b/src/domain/UBGraphicsDelegateFrame.cpp @@ -531,6 +531,9 @@ void UBGraphicsDelegateFrame::positionHandles() { setBrush(QBrush(UBSettings::paletteColor)); } + + //make frame interact like delegated item when selected. Maybe should be deleted if selection logic will change + setZValue(delegated()->zValue()); } diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 910d001c..ba20e493 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -93,8 +93,8 @@ void UBGraphicsItemDelegate::init() foreach(DelegateButton* button, mButtons) { button->hide(); - button->setZValue(UBGraphicsScene::toolLayerStart + 2); -// UBGraphicsItem::assignZValue(button, UBGraphicsScene::toolLayerStart + 2); +// button->setZValue(UBGraphicsScene::toolLayerStart + 2); + UBGraphicsItem::assignZValue(button, UBGraphicsScene::toolLayerStart + 2); button->setFlag(QGraphicsItem::ItemIsSelectable, true); } } @@ -323,12 +323,10 @@ void UBGraphicsItemDelegate::lock(bool locked) if (locked) { mDelegated->setData(UBGraphicsItemData::ItemLocked, QVariant(true)); - qDebug() << "item's data is called for locked" << mDelegated->data(UBGraphicsItemData::ItemLocked); } else { mDelegated->setData(UBGraphicsItemData::ItemLocked, QVariant(false)); - qDebug() << "item's data is called for unlocked" << mDelegated->data(UBGraphicsItemData::ItemLocked); } mDelegated->update(); diff --git a/src/domain/UBGraphicsItemTransformUndoCommand.cpp b/src/domain/UBGraphicsItemTransformUndoCommand.cpp index e883c8e9..f21355bd 100644 --- a/src/domain/UBGraphicsItemTransformUndoCommand.cpp +++ b/src/domain/UBGraphicsItemTransformUndoCommand.cpp @@ -49,7 +49,7 @@ void UBGraphicsItemTransformUndoCommand::undo() { mItem->setPos(mPreviousPosition); mItem->setTransform(mPreviousTransform); -// mItem->setZValue(mPreviousZValue); + mItem->setZValue(mPreviousZValue); // UBGraphicsItem::assignZValue(mItem, mPreviousZValue); UBResizableGraphicsItem* resizableItem = dynamic_cast(mItem); @@ -62,9 +62,9 @@ void UBGraphicsItemTransformUndoCommand::redo() { mItem->setPos(mCurrentPosition); mItem->setTransform(mCurrentTransform); -// mItem->setZValue(mCurrentZValue); + mItem->setZValue(mCurrentZValue); - UBGraphicsItem::assignZValue(mItem, /*mCurrentZValue*/mItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); +// UBGraphicsItem::assignZValue(mItem, /*mCurrentZValue*/mItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); UBResizableGraphicsItem* resizableItem = dynamic_cast(mItem); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index b5a59ed8..635337a8 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -164,6 +164,7 @@ void UBGraphicsScene::selectionChangedProcessing() QList allItemsList = items(); QtLogger::logger() << "=====all items searching...======" << endl; + qreal maxZ = 0.; for( int i = 0; i < allItemsList.size(); i++ ) { QGraphicsItem *nextItem = allItemsList.at(i); @@ -173,27 +174,29 @@ void UBGraphicsScene::selectionChangedProcessing() continue; //Temporary stub end (sankore 360) // qreal zValue = nextItem->zValue(); -// nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); - nextItem->setZValue(1); + if (nextItem->zValue() > maxZ) + maxZ = nextItem->zValue(); + + nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); +// nextItem->setZValue(qreal(1)); QtLogger::logger() << "own Z " << QString::number(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f') << " next Z " << QString::number(nextItem->zValue(), 'f')<< endl; // qDebug() << QString(" %1 ").arg(i) << QString(" %1 ").arg(zValue); } QList selItemsList = selectedItems(); QtLogger::logger() << "=====selected items searching...======" << endl; - QGraphicsItem *nextItem; +// QGraphicsItem *nextItem; for( int i = 0; i < selItemsList.size(); i++ ) { - nextItem = selItemsList.at(i); + QGraphicsItem *nextItem = selItemsList.at(i); QtLogger::logger() << "own Z " << QString::number(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f') << " next Z " << QString::number(nextItem->zValue(), 'f')<< endl; // qreal zValue = nextItem->zValue(); - nextItem->setZValue(2); + nextItem->setZValue(maxZ + 0.0001); // qDebug() << QString(" >>> %1 <<< ").arg(i) << QString(" >>> %1 <<< ").arg(zValue); } QtLogger::logger() << "\nselection processing finished" << endl; QtLogger::logger().finish(); - } // MARK: - @@ -424,23 +427,23 @@ void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw) if(isFirstDraw) { + qreal maxZ = 0.; QList allItemsList = items(); for( int i = 0; i < allItemsList.size(); i++ ) { QGraphicsItem *nextItem = allItemsList.at(i); qreal zValue = nextItem->zValue(); - nextItem->setZValue(qreal(1)); - qDebug() << QString(" %1 ").arg(i) << QString(" %1 ").arg(zValue); + if (zValue > maxZ) + maxZ = zValue; + nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); } - mEraser->setZValue(2); + mEraser->setZValue(maxZ + 0.0001); mEraser->show(); } - } } - void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw) { qreal pointerDiameter = UBSettings::pointerDiameter / UBApplication::boardController->currentZoom(); @@ -456,19 +459,20 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw) if(isFirstDraw) { + qreal maxZ = 0.; QList allItemsList = items(); for( int i = 0; i < allItemsList.size(); i++ ) { QGraphicsItem *nextItem = allItemsList.at(i); qreal zValue = nextItem->zValue(); - nextItem->setZValue(qreal(1)); - qDebug() << QString(" %1 ").arg(i) << QString(" %1 ").arg(zValue); + if (zValue > maxZ) + maxZ = zValue; + nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); } - mPointer->setZValue(2); + mPointer->setZValue(maxZ + 0.0001); mPointer->show(); } - } }