Zvalue controller is now finished

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent 4d196a038f
commit b36627aeaa
  1. 40
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 2
      src/board/UBBoardController.cpp
  3. 1
      src/core/UB.h
  4. 2
      src/domain/UBGraphicsAudioItem.cpp
  5. 14
      src/domain/UBGraphicsItemDelegate.cpp
  6. 2
      src/domain/UBGraphicsItemDelegate.h
  7. 4
      src/domain/UBGraphicsPDFItem.cpp
  8. 2
      src/domain/UBGraphicsPixmapItem.cpp
  9. 3
      src/domain/UBGraphicsPolygonItem.cpp
  10. 152
      src/domain/UBGraphicsScene.cpp
  11. 25
      src/domain/UBGraphicsScene.h
  12. 8
      src/domain/UBGraphicsSvgItem.cpp
  13. 2
      src/domain/UBGraphicsTextItem.cpp
  14. 2
      src/domain/UBGraphicsVideoItem.cpp
  15. 4
      src/domain/UBGraphicsVideoItemDelegate.cpp
  16. 1
      src/domain/UBGraphicsWidgetItem.cpp
  17. 2
      src/tools/UBGraphicsCache.cpp
  18. 2
      src/tools/UBGraphicsCompass.cpp
  19. 4
      src/tools/UBGraphicsCurtainItem.cpp
  20. 1
      src/tools/UBGraphicsCurtainItemDelegate.cpp
  21. 2
      src/tools/UBGraphicsProtractor.cpp
  22. 2
      src/tools/UBGraphicsRuler.cpp
  23. 2
      src/tools/UBGraphicsTriangle.cpp

@ -306,9 +306,6 @@ UBSvgSubsetAdaptor::UBSvgSubsetReader::UBSvgSubsetReader(UBDocumentProxy* pProxy
UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{
UBGraphicsScene *scene = 0;
qreal maxDrawingZIndex = 0;
qreal maxObjectZIndex = 0;
UBGraphicsWidgetItem *currentWidget = 0;
mFileVersion = 40100; // default to 4.1.0
@ -481,7 +478,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(polygonItem);
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
maxDrawingZIndex = qMax(polygonItem->zValue(), maxDrawingZIndex);
polygonItem->show();
}
@ -501,8 +497,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(polygonItem);
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
maxDrawingZIndex = qMax(polygonItem->zValue(), maxDrawingZIndex);
polygonItem->show();
}
}
@ -527,8 +521,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(pixmapItem->zValue(), maxObjectZIndex);
scene->addItem(pixmapItem);
if (zFromSvg != UBZLayerController::errorNum())
@ -549,8 +541,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
svgItem->setFlag(QGraphicsItem::ItemIsMovable, true);
svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(svgItem->zValue(), maxObjectZIndex);
scene->addItem(svgItem);
if (zFromSvg != UBZLayerController::errorNum())
@ -577,8 +567,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
audioItem->setFlag(QGraphicsItem::ItemIsMovable, true);
audioItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(audioItem->zValue(), maxObjectZIndex);
scene->addItem(audioItem);
if (zFromSvg != UBZLayerController::errorNum())
@ -600,8 +588,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
videoItem->setFlag(QGraphicsItem::ItemIsMovable, true);
videoItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(videoItem->zValue(), maxObjectZIndex);
scene->addItem(videoItem);
if (zFromSvg != UBZLayerController::errorNum())
@ -623,8 +609,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
textItem->setFlag(QGraphicsItem::ItemIsMovable, true);
textItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(textItem->zValue(), maxObjectZIndex);
scene->addItem(textItem);
if (zFromSvg != UBZLayerController::errorNum())
@ -733,8 +717,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
pdfItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pdfItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(pdfItem->zValue(), maxObjectZIndex);
scene->addItem(pdfItem);
if (zFromSvg != UBZLayerController::errorNum())
@ -758,8 +740,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
appleWidgetItem->resize(foreignObjectWidth, foreignObjectHeight);
maxObjectZIndex = qMax(appleWidgetItem->zValue(), maxObjectZIndex);
scene->addItem(appleWidgetItem);
if (zFromSvg != UBZLayerController::errorNum())
@ -781,8 +761,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
w3cWidgetItem->resize(foreignObjectWidth, foreignObjectHeight);
maxObjectZIndex = qMax(w3cWidgetItem->zValue(), maxObjectZIndex);
scene->addItem(w3cWidgetItem);
if (zFromSvg != UBZLayerController::errorNum())
@ -802,7 +780,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
textItem->setFlag(QGraphicsItem::ItemIsMovable, true);
textItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(textItem->zValue(), maxObjectZIndex);
scene->addItem(textItem);
if (zFromSvg != UBZLayerController::errorNum())
@ -856,10 +833,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
qWarning() << "error parsing Sankore file " << mXmlReader.errorString();
}
if (scene)
{
scene->setObjectZIndex(maxObjectZIndex);
scene->setDrawingZIndex(maxDrawingZIndex);
if (scene) {
scene->setModified(false);
}
@ -1400,12 +1374,10 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
if (!ubZValue.isNull())
{
// polygonItem->setZValue (ubZValue.toString().toFloat());
UBGraphicsItem::assignZValue(polygonItem, ubZValue.toString().toFloat());
}
else
{
// polygonItem->setZValue(mGroupZIndex);
UBGraphicsItem::assignZValue(polygonItem, mGroupZIndex);
}
@ -1509,12 +1481,10 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLin
if (!ubZValue.isNull())
{
// polygonItem->setZValue(ubZValue.toString().toFloat());
UBGraphicsItem::assignZValue(polygonItem, ubZValue.toString().toFloat());
}
else
{
// polygonItem->setZValue(mGroupZIndex);
UBGraphicsItem::assignZValue(polygonItem, mGroupZIndex);
}
@ -1663,7 +1633,6 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem
{
UBGraphicsPolygonItem* polygonItem = new UBGraphicsPolygonItem(QLineF(points.at(i), points.at(i + 1)), lineWidth);
polygonItem->setColor(brushColor);
// polygonItem->setZValue(zValue);
UBGraphicsItem::assignZValue(polygonItem, zValue);
polygonItem->setColorOnDarkBackground(colorOnDarkBackground);
polygonItem->setColorOnLightBackground(colorOnLightBackground);
@ -2008,7 +1977,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g
if (!ubZValue.isNull())
{
// gItem->setZValue(ubZValue.toString().toFloat());
UBGraphicsItem::assignZValue(gItem, ubZValue.toString().toFloat());
}
@ -2591,7 +2559,6 @@ UBGraphicsRuler* UBSvgSubsetAdaptor::UBSvgSubsetReader::rulerFromSvg()
graphicsItemFromSvg(ruler);
// ruler->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler);
UBGraphicsItem::assignZValue(ruler, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler);
ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
@ -2650,7 +2617,6 @@ UBGraphicsCompass* UBSvgSubsetAdaptor::UBSvgSubsetReader::compassFromSvg()
graphicsItemFromSvg(compass);
//compass->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass);
UBGraphicsItem::assignZValue(compass, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass);
compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
@ -2715,7 +2681,6 @@ UBGraphicsProtractor* UBSvgSubsetAdaptor::UBSvgSubsetReader::protractorFromSvg()
{
UBGraphicsProtractor* protractor = new UBGraphicsProtractor();
// protractor->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor);
UBGraphicsItem::assignZValue(protractor, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor);
protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
@ -2786,7 +2751,6 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
{
UBGraphicsTriangle* triangle = new UBGraphicsTriangle();
// triangle->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle);
UBGraphicsItem::assignZValue(triangle, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle);
triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
@ -2813,8 +2777,6 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
UBGraphicsCache* UBSvgSubsetAdaptor::UBSvgSubsetReader::cacheFromSvg()
{
UBGraphicsCache* pCache = new UBGraphicsCache();
pCache->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCache);
// UBGraphicsItem::assignZValue(pCache, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCache);
pCache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
graphicsItemFromSvg(pCache);

@ -1943,8 +1943,6 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if (gi)
{
// gi->setZValue(mActiveScene->getNextObjectZIndex());
UBGraphicsItem::assignZValue(gi, mActiveScene->getNextObjectZIndex());
mActiveScene->addItem(gi);
gi->setPos(gi->pos() + QPointF(50, 50));
}

@ -84,6 +84,7 @@ struct itemLayerType
, Curtain
, Pointer
, Cache
, SelectedItem
};
};

@ -97,8 +97,6 @@ UBItem* UBGraphicsAudioItem::deepCopy() const
UBGraphicsAudioItem *copy = new UBGraphicsAudioItem(audioUrl, parentItem());
copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -73,8 +73,6 @@ void UBGraphicsItemDelegate::init()
{
mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio);
mFrame->hide();
// mFrame->setZValue(UBGraphicsScene::toolLayerStart + 1);
UBGraphicsItem::assignZValue(mFrame, UBGraphicsScene::toolLayerStart + 1);
mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true);
mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection);
@ -102,8 +100,6 @@ void UBGraphicsItemDelegate::init()
foreach(DelegateButton* button, mButtons)
{
button->hide();
// button->setZValue(UBGraphicsScene::toolLayerStart + 2);
UBGraphicsItem::assignZValue(button, UBGraphicsScene::toolLayerStart + 2);
button->setFlag(QGraphicsItem::ItemIsSelectable, true);
}
}
@ -168,18 +164,9 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (!mDelegated->isSelected())
{
mDelegated->setSelected(true);
UBGraphicsScene* scene = static_cast<UBGraphicsScene*>(mDelegated->scene());
qDebug() << mDelegated->zValue();
qDebug() << scene->currentObjectZIndex();
// To investigate. Z value behavior
// if (mDelegated->zValue() < scene->currentObjectZIndex() && !isLocked())
// mDelegated->setZValue(scene->getNextObjectZIndex());
positionHandles();
return true;
}
else
@ -288,6 +275,7 @@ void UBGraphicsItemDelegate::positionHandles()
mDelegated->scene()->addItem(button);
}
button->show();
button->setZValue(delegated()->zValue());
}
} else {
foreach(DelegateButton* button, mButtons)

@ -33,7 +33,7 @@ class DelegateButton: public QGraphicsSvgItem
Q_OBJECT
public:
DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent = 0, Qt::WindowFrameSection section = Qt::NoSection)
DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent = 0, Qt::WindowFrameSection section = Qt::TopLeftSection)
: QGraphicsSvgItem(fileName, parent)
, mDelegated(pDelegated)
, mIsTransparentToMouseEvent(false)

@ -85,8 +85,6 @@ UBItem* UBGraphicsPDFItem::deepCopy() const
UBGraphicsPDFItem *copy = new UBGraphicsPDFItem(mRenderer, mPageNumber, parentItem());
copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -136,8 +134,6 @@ UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const
pixmapItem->setPixmap(pixmap);
pixmapItem->setPos(this->pos());
// pixmapItem->setZValue(this->zValue());
UBGraphicsItem::assignZValue(pixmapItem, this->zValue());
pixmapItem->setTransform(this->transform());
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -103,8 +103,6 @@ UBItem* UBGraphicsPixmapItem::deepCopy() const
copy->setPixmap(this->pixmap());
copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -161,9 +161,6 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
copy->setPen(this->pen());
copy->mHasAlpha = this->mHasAlpha;
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setColorOnDarkBackground(this->colorOnDarkBackground());
copy->setColorOnLightBackground(this->colorOnLightBackground());

@ -61,8 +61,6 @@
#include "core/memcheck.h"
qreal UBGraphicsScene::backgroundLayerStart = -20000000.0;
qreal UBGraphicsScene::objectLayerStart = -10000000.0;
qreal UBGraphicsScene::drawingLayerStart = 0.0;
qreal UBGraphicsScene::toolLayerStart = 10000000.0;
@ -88,10 +86,12 @@ UBZLayerController::UBZLayerController()
scopeMap.insert(itemLayerType::DrawingItem, ItemLayerTypeData( 0.0, 10000000.0 ));
scopeMap.insert(itemLayerType::ToolItem, ItemLayerTypeData( 10000000.0, 10000100.0 ));
scopeMap.insert(itemLayerType::CppTool, ItemLayerTypeData( 10000100.0, 10000200.0 ));
scopeMap.insert(itemLayerType::Eraiser, ItemLayerTypeData( 10000200.0, 10001000.0 ));
scopeMap.insert(itemLayerType::Curtain, ItemLayerTypeData( 10001000.0, 10001100.0 ));
scopeMap.insert(itemLayerType::Curtain, ItemLayerTypeData( 10000200.0, 10001000.0 ));
scopeMap.insert(itemLayerType::Eraiser, ItemLayerTypeData( 10001000.0, 10001100.0 ));
scopeMap.insert(itemLayerType::Pointer, ItemLayerTypeData( 10001100.0, 10001200.0 ));
scopeMap.insert(itemLayerType::Cache, ItemLayerTypeData( 10001300.0, 10001400.0 ));
scopeMap.insert(itemLayerType::SelectedItem, ItemLayerTypeData( 10001000.0, 10001000.0 ));
}
qreal UBZLayerController::generateZLevel(itemLayerType::Enum key)
@ -107,8 +107,8 @@ qreal UBZLayerController::generateZLevel(itemLayerType::Enum key)
result++;
if (result >= top) {
qDebug() << "new values are finished for the scope" << key;
result = top;
qDebug() << "new values are over for the scope" << key;
result = top - 1;
}
scopeMap[key].curValue = result;
@ -145,38 +145,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
#endif
setDocument(parent);
mDrawingZIndex = drawingLayerStart;
mObjectZIndex = objectLayerStart;
mEraser = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene
mEraser->setRect(QRect(0, 0, 0, 0));
mEraser->setVisible(false);
mEraser->setZValue(/*toolLayerStart + toolOffsetEraser*/2);
mEraser->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
// mEraser->setData(UBGraphicsItemData::itemLayerType, QVariant(Eraiser));
// qreal zval = mZLayerController.generateZLevel((itmeLayerType)mEraser->data(UBGraphicsItemData::itemLayerType).toInt());
// qreal zval1 = mZLayerController.generateZLevel(Eraiser);
// qreal zval2 = mZLayerController.generateZLevel(Eraiser);
// mEraser->setZValue(zval);
mTools << mEraser;
addItem(mEraser);
mPointer = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene
mPointer->setRect(QRect(0, 0, 20, 20));
mPointer->setVisible(false);
mPointer->setPen(Qt::NoPen);
mPointer->setBrush(QBrush(QColor(255, 0, 0, 186)));
mPointer->setZValue( /*toolLayerStart + toolOffsetPointer*/ 2);
mPointer->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
mTools << mPointer;
addItem(mPointer);
createEraiser();
createPointer();
if (UBApplication::applicationController)
{
@ -204,23 +174,14 @@ void UBGraphicsScene::selectionChangedProcessing()
+ QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f'));
QList<QGraphicsItem *> allItemsList = items();
qreal maxZ = 0.;
for( int i = 0; i < allItemsList.size(); i++ ) {
QGraphicsItem *nextItem = allItemsList.at(i);
//Temporary stub. Due to ugly z-order implementation I need to do this (sankore 360)
//z-order behavior should be reimplemented and this stub should be deleted
if (nextItem == mBackgroundObject)
continue;
//Temporary stub end (sankore 360)
if (nextItem->zValue() > maxZ)
maxZ = nextItem->zValue();
if (nextItem->isSelected()) {
nextItem->setZValue(mZLayerController.generateZLevel(itemLayerType::SelectedItem));
} else {
nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal());
// nextItem->setZValue(qreal(1));
}
QList<QGraphicsItem *> selItemsList = selectedItems();
for( int i = 0; i < selItemsList.size(); i++ ) {
QGraphicsItem *nextItem = selItemsList.at(i);
nextItem->setZValue(maxZ + 0.0001);
}
}
@ -449,24 +410,10 @@ void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw)
qreal eraserRadius = eraserWidth / 2;
// TODO UB 4.x optimize - no need to do that every time we move it
if (mEraser)
{
if (mEraser) {
mEraser->setRect(QRectF(pPoint.x() - eraserRadius, pPoint.y() - eraserRadius, eraserWidth, eraserWidth));
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();
if (zValue > maxZ)
maxZ = zValue;
nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal());
}
mEraser->setZValue(maxZ + 0.0001);
if(isFirstDraw) {
mEraser->show();
}
}
@ -478,27 +425,12 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw)
qreal pointerRadius = pointerDiameter / 2;
// TODO UB 4.x optimize - no need to do that every time we move it
if (mPointer)
{
if (mPointer) {
mPointer->setRect(QRectF(pPoint.x() - pointerRadius,
pPoint.y() - pointerRadius,
pointerDiameter,
pointerDiameter));
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();
if (zValue > maxZ)
maxZ = zValue;
nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal());
}
mPointer->setZValue(maxZ + 0.0001);
if(isFirstDraw) {
mPointer->show();
}
}
@ -735,21 +667,6 @@ void UBGraphicsScene::drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle)
setDocumentUpdated();
}
qreal UBGraphicsScene::getNextDrawingZIndex()
{
mDrawingZIndex = mDrawingZIndex + 1.0;
return mDrawingZIndex;
}
qreal UBGraphicsScene::getNextObjectZIndex()
{
mObjectZIndex = mObjectZIndex + 1.0;
return mObjectZIndex;
}
void UBGraphicsScene::setBackground(bool pIsDark, bool pIsCrossed)
{
bool needRepaint = false;
@ -912,9 +829,6 @@ UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
UBGraphicsScene* copy = new UBGraphicsScene(this->document());
copy->setBackground(this->isDarkBackground(), this->isCrossedBackground());
copy->mDrawingZIndex = this->mDrawingZIndex;
copy->mObjectZIndex = this->mObjectZIndex;
copy->setSceneRect(this->sceneRect());
if (this->mNominalSize.isValid())
@ -1092,7 +1006,6 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const Q
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
// pixmapItem->setZValue(getNextObjectZIndex());
pixmapItem->setPixmap(pPixmap);
@ -1144,7 +1057,6 @@ UBGraphicsVideoItem* UBGraphicsScene::addVideo(const QUrl& pVideoFileUrl, bool s
videoItem->setFlag(QGraphicsItem::ItemIsMovable, true);
videoItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
// videoItem->setZValue(getNextObjectZIndex());
addItem(videoItem);
@ -1176,7 +1088,6 @@ UBGraphicsAudioItem* UBGraphicsScene::addAudio(const QUrl& pAudioFileUrl, bool s
audioItem->setFlag(QGraphicsItem::ItemIsMovable, true);
audioItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
// audioItem->setZValue(getNextObjectZIndex());
addItem(audioItem);
@ -1495,8 +1406,7 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool
item->setAcceptedMouseButtons(Qt::NoButton);
item->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::FixedBackground);
// item->setZValue(backgroundLayerStart);
UBGraphicsItem::assignZValue(item, generateZLevel(item));
UBGraphicsItem::assignZValue(item, mZLayerController.generateZLevel(itemLayerType::BackgroundItem));
if (pAdaptTransformation)
{
@ -2012,6 +1922,34 @@ void UBGraphicsScene::setDocumentUpdated()
document()->setMetaData(UBSettings::documentUpdatedAt
, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
}
void UBGraphicsScene::createEraiser()
{
mEraser = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene
mEraser->setRect(QRect(0, 0, 0, 0));
mEraser->setVisible(false);
mEraser->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mEraser->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Eraiser)); //Necessary to set if we want z value to be assigned correctly
mTools << mEraser;
addItem(mEraser);
}
void UBGraphicsScene::createPointer()
{
mPointer = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene
mPointer->setRect(QRect(0, 0, 20, 20));
mPointer->setVisible(false);
mPointer->setPen(Qt::NoPen);
mPointer->setBrush(QBrush(QColor(255, 0, 0, 186)));
mPointer->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
mPointer->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Pointer)); //Necessary to set if we want z value to be assigned correctly
mTools << mPointer;
addItem(mPointer);
}
qreal UBGraphicsScene::generateZLevel(QGraphicsItem *item)
{

@ -181,23 +181,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
return mCrossedBackground;
}
void setDrawingZIndex(qreal pDrawingZIndex)
{
mDrawingZIndex = pDrawingZIndex;
}
void setObjectZIndex(qreal pObjectZIndex)
{
mObjectZIndex = pObjectZIndex;
}
bool hasBackground()
{
return (mBackgroundObject != 0);
}
qreal getNextObjectZIndex();
void addRuler(QPointF center);
void addProtractor(QPointF center);
void addCompass(QPointF center);
@ -254,11 +242,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void setNominalSize(int pWidth, int pHeight);
qreal currentObjectZIndex()
{
return mObjectZIndex;
}
enum RenderingContext
{
Screen = 0, NonScreen, PdfExport, Podcast
@ -343,8 +326,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void recolorAllItems();
qreal getNextDrawingZIndex();
virtual void drawItems (QPainter * painter, int numItems,
QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget = 0);
@ -352,10 +333,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
private:
void setDocumentUpdated();
qreal generateZLevel(QGraphicsItem *item);
void createEraiser();
void createPointer();
qreal mDrawingZIndex;
qreal mObjectZIndex;
qreal generateZLevel(QGraphicsItem *item);
QGraphicsEllipseItem* mEraser;
QGraphicsEllipseItem* mPointer;

@ -46,8 +46,6 @@ UBGraphicsSvgItem::UBGraphicsSvgItem(const QByteArray& pFileData, QGraphicsItem*
setSharedRenderer(renderer);
mFileData = pFileData;
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
}
@ -62,6 +60,8 @@ void UBGraphicsSvgItem::init()
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
setMaximumCacheSize(boundingRect().size().toSize() * UB_MAX_ZOOM);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
}
@ -133,8 +133,6 @@ UBItem* UBGraphicsSvgItem::deepCopy() const
UBGraphicsSvgItem* copy = new UBGraphicsSvgItem(this->fileData());
copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -188,8 +186,6 @@ UBGraphicsPixmapItem* UBGraphicsSvgItem::toPixmapItem() const
pixmapItem->setPixmap(QPixmap::fromImage(image));
pixmapItem->setPos(this->pos());
// pixmapItem->setZValue(this->zValue());
UBGraphicsItem::assignZValue(pixmapItem, this->zValue());
pixmapItem->setTransform(this->transform());
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -193,8 +193,6 @@ UBItem* UBGraphicsTextItem::deepCopy() const
copy->setHtml(toHtml());
copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -70,8 +70,6 @@ UBItem* UBGraphicsVideoItem::deepCopy() const
UBGraphicsVideoItem *copy = new UBGraphicsVideoItem(videoUrl, parentItem());
copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -52,8 +52,7 @@ void UBGraphicsVideoItemDelegate::buildButtons()
mMuteButton->hide();
mVideoControl = new DelegateVideoControl(delegated(), mFrame);
// mVideoControl->setZValue(UBGraphicsScene::toolLayerStart + 2);
UBGraphicsItem::assignZValue(mVideoControl, UBGraphicsScene::toolLayerStart + 2);
UBGraphicsItem::assignZValue(mVideoControl, delegated()->zValue());
mVideoControl->setFlag(QGraphicsItem::ItemIsSelectable, true);
connect(mPlayPauseButton, SIGNAL(clicked(bool)), this, SLOT(togglePlayPause()));
@ -106,6 +105,7 @@ void UBGraphicsVideoItemDelegate::positionHandles()
}
mVideoControl->setAntiScale(mAntiScaleRatio);
mVideoControl->setZValue(delegated()->zValue());
mVideoControl->show();
}
else

@ -411,7 +411,6 @@ UBItem* UBGraphicsW3CWidgetItem::deepCopy() const
UBGraphicsW3CWidgetItem *copy = new UBGraphicsW3CWidgetItem(mWebKitWidget->widgetUrl(), parentItem());
copy->setPos(this->pos());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -47,8 +47,6 @@ UBItem* UBGraphicsCache::deepCopy() const
copy->setPos(this->pos());
copy->setRect(this->rect());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ?

@ -87,8 +87,6 @@ UBItem* UBGraphicsCompass::deepCopy() const
copy->setPos(this->pos());
copy->setRect(this->rect());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ?

@ -60,8 +60,6 @@ UBGraphicsCurtainItem::~UBGraphicsCurtainItem()
QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
// if (change == QGraphicsItem::ItemSelectedHasChanged && QGraphicsRectItem::scene() && isSelected())
// setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCurtain);
QVariant newValue = value;
@ -133,8 +131,6 @@ UBItem* UBGraphicsCurtainItem::deepCopy() const
copy->setPos(this->pos());
copy->setBrush(this->brush());
copy->setPen(this->pen());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -52,7 +52,6 @@ bool UBGraphicsCurtainItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *ev
if (!mDelegated->isSelected())
{
mDelegated->setSelected(true);
// mDelegated->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCurtain);
positionHandles();
return true;

@ -581,8 +581,6 @@ UBItem* UBGraphicsProtractor::deepCopy() const
copy->setPos(this->pos());
copy->setRect(this->rect());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
copy->mCurrentAngle = this->mCurrentAngle;

@ -76,8 +76,6 @@ UBItem* UBGraphicsRuler::deepCopy() const
copy->setPos(this->pos());
copy->setRect(this->rect());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ?

@ -95,8 +95,6 @@ UBItem* UBGraphicsTriangle::deepCopy(void) const
copy->setPos(this->pos());
copy->setPolygon(this->polygon());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ?

Loading…
Cancel
Save