Commit e943854c authored by Ivan Ilin's avatar Ivan Ilin

Z-value is now working correct

parent 31ca9eca
......@@ -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();
}
......
......@@ -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());
}
......
......@@ -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();
......
......@@ -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<UBResizableGraphicsItem*>(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<UBResizableGraphicsItem*>(mItem);
......
......@@ -164,6 +164,7 @@ void UBGraphicsScene::selectionChangedProcessing()
QList<QGraphicsItem *> 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<QGraphicsItem *> 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<QGraphicsItem *> 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<QGraphicsItem *> 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();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment