UBZLayerController created. Z level implementation restructured

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent a95472cdab
commit a0a0d208a7
  1. 63
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 2
      src/adaptors/UBSvgSubsetAdaptor.h
  3. 24
      src/core/UB.h
  4. 2
      src/domain/UBGraphicsAudioItem.cpp
  5. 53
      src/domain/UBGraphicsItemDelegate.cpp
  6. 18
      src/domain/UBGraphicsItemDelegate.h
  7. 3
      src/domain/UBGraphicsPDFItem.cpp
  8. 1
      src/domain/UBGraphicsPixmapItem.cpp
  9. 8
      src/domain/UBGraphicsPolygonItem.cpp
  10. 2
      src/domain/UBGraphicsPolygonItem.h
  11. 96
      src/domain/UBGraphicsScene.cpp
  12. 35
      src/domain/UBGraphicsScene.h
  13. 3
      src/domain/UBGraphicsSvgItem.cpp
  14. 16
      src/domain/UBGraphicsTextItem.cpp
  15. 8
      src/domain/UBGraphicsTextItemDelegate.cpp
  16. 2
      src/domain/UBGraphicsVideoItem.cpp
  17. 3
      src/domain/UBGraphicsWidgetItem.cpp
  18. 1
      src/domain/UBItem.h
  19. 1
      src/tools/UBAbstractDrawRuler.cpp
  20. 6
      src/tools/UBGraphicsCache.cpp
  21. 2
      src/tools/UBGraphicsCache.h
  22. 2
      src/tools/UBGraphicsCompass.cpp
  23. 2
      src/tools/UBGraphicsCurtainItem.cpp
  24. 1
      src/tools/UBGraphicsProtractor.cpp
  25. 2
      src/tools/UBGraphicsRuler.cpp
  26. 4
      src/tools/UBGraphicsTriangle.cpp

@ -320,6 +320,8 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mXmlReader.readNext(); mXmlReader.readNext();
if (mXmlReader.isStartElement()) if (mXmlReader.isStartElement())
{ {
qreal zFromSvg = getZValueFromSvg();
if (mXmlReader.name() == "svg") if (mXmlReader.name() == "svg")
{ {
if (!scene) if (!scene)
@ -529,6 +531,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(pixmapItem); scene->addItem(pixmapItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(pixmapItem, zFromSvg);
if (isBackground) if (isBackground)
scene->setAsBackgroundObject(pixmapItem); scene->setAsBackgroundObject(pixmapItem);
@ -548,6 +553,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(svgItem); scene->addItem(svgItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(svgItem, zFromSvg);
if (isBackground) if (isBackground)
scene->setAsBackgroundObject(svgItem); scene->setAsBackgroundObject(svgItem);
@ -573,6 +581,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(audioItem); scene->addItem(audioItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(audioItem, zFromSvg);
audioItem->show(); audioItem->show();
//force start to load the video and display the first frame //force start to load the video and display the first frame
@ -593,6 +604,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(videoItem); scene->addItem(videoItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(videoItem, zFromSvg);
videoItem->show(); videoItem->show();
//force start to load the video and display the first frame //force start to load the video and display the first frame
@ -613,6 +627,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(textItem); scene->addItem(textItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(textItem, zFromSvg);
textItem->show(); textItem->show();
} }
} }
@ -624,17 +641,27 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{ {
scene->addItem(mask); scene->addItem(mask);
scene->registerTool(mask); scene->registerTool(mask);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(mask, zFromSvg);
} }
} }
else if (mXmlReader.name() == "ruler") else if (mXmlReader.name() == "ruler")
{ {
QString ubZValue = mXmlReader.attributes().value(mNamespaceUri, "z-value").toString();
UBGraphicsRuler *ruler = rulerFromSvg(); UBGraphicsRuler *ruler = rulerFromSvg();
ubZValue = mXmlReader.attributes().value(mNamespaceUri, "z-value").toString();
if (ruler) if (ruler)
{ {
scene->addItem(ruler); scene->addItem(ruler);
scene->registerTool(ruler); scene->registerTool(ruler);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(ruler, zFromSvg);
} }
} }
else if (mXmlReader.name() == "compass") else if (mXmlReader.name() == "compass")
{ {
@ -644,6 +671,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{ {
scene->addItem(compass); scene->addItem(compass);
scene->registerTool(compass); scene->registerTool(compass);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(compass, zFromSvg);
} }
} }
else if (mXmlReader.name() == "protractor") else if (mXmlReader.name() == "protractor")
@ -654,6 +684,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{ {
scene->addItem(protractor); scene->addItem(protractor);
scene->registerTool(protractor); scene->registerTool(protractor);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(protractor, zFromSvg);
} }
} }
else if (mXmlReader.name() == "triangle") else if (mXmlReader.name() == "triangle")
@ -664,6 +697,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{ {
scene->addItem(triangle); scene->addItem(triangle);
scene->registerTool(triangle); scene->registerTool(triangle);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(triangle, zFromSvg);
} }
} }
else if(mXmlReader.name() == "cache") else if(mXmlReader.name() == "cache")
@ -674,6 +710,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(cache); scene->addItem(cache);
scene->registerTool(cache); scene->registerTool(cache);
UBApplication::boardController->notifyCache(true); UBApplication::boardController->notifyCache(true);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(cache, zFromSvg);
} }
} }
else if (mXmlReader.name() == "foreignObject") else if (mXmlReader.name() == "foreignObject")
@ -698,6 +737,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(pdfItem); scene->addItem(pdfItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(pdfItem, zFromSvg);
if (isBackground) if (isBackground)
scene->setAsBackgroundObject(pdfItem); scene->setAsBackgroundObject(pdfItem);
@ -720,6 +762,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(appleWidgetItem); scene->addItem(appleWidgetItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(appleWidgetItem, zFromSvg);
appleWidgetItem->show(); appleWidgetItem->show();
currentWidget = appleWidgetItem; currentWidget = appleWidgetItem;
@ -740,6 +785,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(w3cWidgetItem); scene->addItem(w3cWidgetItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(w3cWidgetItem, zFromSvg);
w3cWidgetItem->show(); w3cWidgetItem->show();
currentWidget = w3cWidgetItem; currentWidget = w3cWidgetItem;
@ -756,6 +804,10 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
maxObjectZIndex = qMax(textItem->zValue(), maxObjectZIndex); maxObjectZIndex = qMax(textItem->zValue(), maxObjectZIndex);
scene->addItem(textItem); scene->addItem(textItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(textItem, zFromSvg);
textItem->show(); textItem->show();
} }
} }
@ -2009,6 +2061,17 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g
} }
} }
qreal UBSvgSubsetAdaptor::UBSvgSubsetReader::getZValueFromSvg()
{
qreal result = UBZLayerController::errorNum();
QStringRef ubZValue = mXmlReader.attributes().value(mNamespaceUri, "z-value");
if (!ubZValue.isNull()) {
result = ubZValue.toString().toFloat();
}
return result;
}
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsItemToSvg(QGraphicsItem* item) void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsItemToSvg(QGraphicsItem* item)
{ {

@ -134,6 +134,8 @@ class UBSvgSubsetAdaptor
void graphicsItemFromSvg(QGraphicsItem* gItem); void graphicsItemFromSvg(QGraphicsItem* gItem);
qreal getZValueFromSvg();
QXmlStreamReader mXmlReader; QXmlStreamReader mXmlReader;
int mFileVersion; int mFileVersion;
UBDocumentProxy *mProxy; UBDocumentProxy *mProxy;

@ -62,7 +62,7 @@ struct UBSize
}; };
}; };
// Deprecated. Keep it for backward campability with old versions
struct UBItemLayerType struct UBItemLayerType
{ {
enum Enum enum Enum
@ -71,17 +71,37 @@ struct UBItemLayerType
}; };
}; };
struct itemLayerType
{
enum Enum {
NoLayer = 0
, BackgroundItem
, ObjectItem
, DrawingItem
, ToolItem
, CppTool
, Eraiser
, Curtain
, Pointer
, Cache
};
};
struct UBGraphicsItemData struct UBGraphicsItemData
{ {
enum Enum enum Enum
{ {
ItemLayerType ItemLayerType //Deprecated. Keep it for backward campability with old versions. Use itemLayerType instead
, ItemLocked , ItemLocked
, ItemEditable//for text only , ItemEditable//for text only
, ItemOwnZValue , ItemOwnZValue
, itemLayerType //use instead of deprecated ItemLayerType
}; };
}; };
struct UBGraphicsItemType struct UBGraphicsItemType
{ {
enum Enum enum Enum

@ -64,6 +64,8 @@ UBGraphicsAudioItem::UBGraphicsAudioItem(const QUrl& pAudioFileUrl, QGraphicsIte
mDelegate->frame()->setOperationMode ( UBGraphicsDelegateFrame::Resizing ); mDelegate->frame()->setOperationMode ( UBGraphicsDelegateFrame::Resizing );
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
} }
void UBGraphicsAudioItem::onStateChanged(Phonon::State newState, Phonon::State oldState) void UBGraphicsAudioItem::onStateChanged(Phonon::State newState, Phonon::State oldState)

@ -76,18 +76,26 @@ void UBGraphicsItemDelegate::init()
UBGraphicsItem::assignZValue(mFrame, UBGraphicsScene::toolLayerStart + 1); UBGraphicsItem::assignZValue(mFrame, UBGraphicsScene::toolLayerStart + 1);
mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true); mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true);
mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame); mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection);
mButtons << mDeleteButton; mButtons << mDeleteButton;
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove())); connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
if (canDuplicate()){ if (canDuplicate()){
mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame); mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame, Qt::TopLeftSection);
connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate())); connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
mButtons << mDuplicateButton; mButtons << mDuplicateButton;
} }
mMenuButton = new DelegateButton(":/images/menu.svg", mDelegated, mFrame); mMenuButton = new DelegateButton(":/images/menu.svg", mDelegated, mFrame, Qt::TopLeftSection);
connect(mMenuButton, SIGNAL(clicked()), this, SLOT(showMenu())); connect(mMenuButton, SIGNAL(clicked()), this, SLOT(showMenu()));
mButtons << mMenuButton; mButtons << mMenuButton;
mZOrderUpButton = new DelegateButton(":/images/plus.svg", mDelegated, mFrame, Qt::BottomLeftSection);
connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevel()));
mButtons << mZOrderUpButton;
mZOrderDownButton = new DelegateButton(":/images/minus.svg", mDelegated, mFrame, Qt::BottomLeftSection);
connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(decreaseZLevel()));
mButtons << mZOrderDownButton;
buildButtons(); buildButtons();
foreach(DelegateButton* button, mButtons) foreach(DelegateButton* button, mButtons)
@ -238,10 +246,13 @@ void UBGraphicsItemDelegate::positionHandles()
mDeleteButton->setTransform(tr); mDeleteButton->setTransform(tr);
qreal x = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2; qreal topX = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2;
qreal y = mFrame->rect().top() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2; qreal topY = mFrame->rect().top() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2;
mDeleteButton->setPos(x, y); qreal bottomX = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2;
qreal bottomY = mFrame->rect().bottom() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2;
mDeleteButton->setPos(topX, topY);
if (!mDeleteButton->scene()) if (!mDeleteButton->scene())
{ {
@ -257,12 +268,18 @@ void UBGraphicsItemDelegate::positionHandles()
lock(isLocked()); lock(isLocked());
for(int i = 1 ; i < mButtons.length(); i++) int i = 1, j = 0, k = 0;
{ while ((i + j) < mButtons.size()) {
DelegateButton* button = mButtons[i]; DelegateButton* button = mButtons[i + j];
button->setTransform(tr); button->setTransform(tr);
button->setPos(x + (i * 1.6 * mFrameWidth * mAntiScaleRatio), y); if (button->getSection() == Qt::TopLeftSection) {
button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY);
} else if (button->getSection() == Qt::BottomLeftSection) {
button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY);
} else if (button->getSection() == Qt::NoSection) {
++k;
}
if (!button->scene()) if (!button->scene())
{ {
button->setParentItem(mFrame);//update parent for the case the item has been previously removed from scene button->setParentItem(mFrame);//update parent for the case the item has been previously removed from scene
@ -271,9 +288,7 @@ void UBGraphicsItemDelegate::positionHandles()
} }
button->show(); button->show();
} }
} } else {
else
{
foreach(DelegateButton* button, mButtons) foreach(DelegateButton* button, mButtons)
button->hide(); button->hide();
@ -316,7 +331,19 @@ void UBGraphicsItemDelegate::duplicate()
UBApplication::boardController->copy(); UBApplication::boardController->copy();
UBApplication::boardController->paste(); UBApplication::boardController->paste();
} }
void UBGraphicsItemDelegate::increaseZLevel(int delta)
{
qDebug() << delegated()->scene()->items().count();
// UBGraphicsItem::assignZValue(delegated(), )
// int valueCandidate = delegated()->data(UBGraphicsItemData::ItemOwnZValue).toInt();
// if (delta < 0) {
// } else if (delta > 0) {
// }
}
void UBGraphicsItemDelegate::lock(bool locked) void UBGraphicsItemDelegate::lock(bool locked)
{ {

@ -33,10 +33,11 @@ class DelegateButton: public QGraphicsSvgItem
Q_OBJECT Q_OBJECT
public: public:
DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent = 0) DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent = 0, Qt::WindowFrameSection section = Qt::NoSection)
: QGraphicsSvgItem(fileName, parent) : QGraphicsSvgItem(fileName, parent)
, mDelegated(pDelegated) , mDelegated(pDelegated)
, mIsTransparentToMouseEvent(false) , mIsTransparentToMouseEvent(false)
, mButtonAlignmentSection(section)
{ {
setAcceptedMouseButtons(Qt::LeftButton); setAcceptedMouseButtons(Qt::LeftButton);
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
@ -57,6 +58,9 @@ class DelegateButton: public QGraphicsSvgItem
QGraphicsSvgItem::setSharedRenderer(new QSvgRenderer (fileName, this)); QGraphicsSvgItem::setSharedRenderer(new QSvgRenderer (fileName, this));
} }
void setSection(Qt::WindowFrameSection section) {mButtonAlignmentSection = section;}
Qt::WindowFrameSection getSection() const {return mButtonAlignmentSection;}
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
@ -80,7 +84,9 @@ class DelegateButton: public QGraphicsSvgItem
QGraphicsItem* mDelegated; QGraphicsItem* mDelegated;
bool mIsTransparentToMouseEvent; bool mIsTransparentToMouseEvent;
Qt::WindowFrameSection mButtonAlignmentSection;
signals: signals:
void clicked (bool checked = false); void clicked (bool checked = false);
@ -142,6 +148,9 @@ class UBGraphicsItemDelegate : public QObject
virtual void lock(bool lock); virtual void lock(bool lock);
virtual void duplicate(); virtual void duplicate();
virtual void increaseZLevel() {increaseZLevel(1);}
virtual void decreaseZLevel() {increaseZLevel(-1);}
protected: protected:
virtual void buildButtons() {;} virtual void buildButtons() {;}
virtual void decorateMenu(QMenu *menu); virtual void decorateMenu(QMenu *menu);
@ -149,10 +158,15 @@ class UBGraphicsItemDelegate : public QObject
QGraphicsItem* mDelegated; QGraphicsItem* mDelegated;
//buttons from the top left section of delegate frame
DelegateButton* mDeleteButton; DelegateButton* mDeleteButton;
DelegateButton* mDuplicateButton; DelegateButton* mDuplicateButton;
DelegateButton* mMenuButton; DelegateButton* mMenuButton;
//buttons from the bottom left section of delegate frame
DelegateButton *mZOrderUpButton;
DelegateButton *mZOrderDownButton;
QMenu* mMenu; QMenu* mMenu;
QAction* mLockAction; QAction* mLockAction;
@ -171,6 +185,8 @@ protected slots:
private: private:
virtual void increaseZLevel(int delta);
QPointF mOffset; QPointF mOffset;
QTransform mPreviousTransform; QTransform mPreviousTransform;
QPointF mPreviousPosition; QPointF mPreviousPosition;

@ -26,7 +26,8 @@
UBGraphicsPDFItem::UBGraphicsPDFItem(PDFRenderer *renderer, int pageNumber, QGraphicsItem* parent) UBGraphicsPDFItem::UBGraphicsPDFItem(PDFRenderer *renderer, int pageNumber, QGraphicsItem* parent)
: GraphicsPDFItem(renderer, pageNumber, parent) : GraphicsPDFItem(renderer, pageNumber, parent)
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); //deprecated
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::BackgroundItem)); //Necessary to set if we want z value to be assigned correctly
mDelegate = new UBGraphicsItemDelegate(this,0); mDelegate = new UBGraphicsItemDelegate(this,0);
mDelegate->init(); mDelegate->init();
} }

@ -33,6 +33,7 @@ UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setTransformationMode(Qt::SmoothTransformation); setTransformationMode(Qt::SmoothTransformation);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
} }

@ -30,6 +30,7 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (QGraphicsItem * parent)
, mStroke(0) , mStroke(0)
{ {
// NOOP // NOOP
initialize();
} }
@ -40,6 +41,7 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QPolygonF & polygon, QGraphi
, mStroke(0) , mStroke(0)
{ {
// NOOP // NOOP
initialize();
} }
@ -51,6 +53,12 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QLineF& pLine, qreal pWidth)
, mStroke(0) , mStroke(0)
{ {
// NOOP // NOOP
initialize();
}
void UBGraphicsPolygonItem::initialize()
{
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::DrawingItem)); //Necessary to set if we want z value to be assigned correctly
} }
void UBGraphicsPolygonItem::clearStroke() void UBGraphicsPolygonItem::clearStroke()

@ -35,6 +35,8 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
~UBGraphicsPolygonItem(); ~UBGraphicsPolygonItem();
void initialize();
void setColor(const QColor& color); void setColor(const QColor& color);
QColor color() const; QColor color() const;

@ -77,6 +77,45 @@ qreal UBGraphicsScene::toolOffsetPointer = 1100;
qreal UBGraphicsScene::toolOffsetCache = 1000;//Didier please define offset you want qreal UBGraphicsScene::toolOffsetCache = 1000;//Didier please define offset you want
qreal UBZLayerController::errorNumber = -20000001.0;
UBZLayerController::UBZLayerController()
{
scopeMap.insert(itemLayerType::NoLayer, ItemLayerTypeData( errorNumber, errorNumber));
scopeMap.insert(itemLayerType::BackgroundItem, ItemLayerTypeData(-10000000.0, -10000000.0 ));
scopeMap.insert(itemLayerType::ObjectItem, ItemLayerTypeData(-10000000.0, 0.0 ));
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::Pointer, ItemLayerTypeData( 10001100.0, 10001200.0 ));
scopeMap.insert(itemLayerType::Cache, ItemLayerTypeData( 10001300.0, 10001400.0 ));
}
qreal UBZLayerController::generateZLevel(itemLayerType::Enum key)
{
if (!scopeMap.contains(key)) {
qDebug() << "Number is out of layer scope";
return errorNumber;
}
qreal result = scopeMap.value(key).curValue;
qreal top = scopeMap.value(key).topLimit;
result++;
if (result >= top) {
qDebug() << "new values are finished for the scope" << key;
result = top;
}
scopeMap[key].curValue = result;
return result;
}
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
: UBCoreGraphicsScene(parent) : UBCoreGraphicsScene(parent)
, mEraser(0) , mEraser(0)
@ -116,6 +155,12 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
mEraser->setZValue(/*toolLayerStart + toolOffsetEraser*/2); mEraser->setZValue(/*toolLayerStart + toolOffsetEraser*/2);
mEraser->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); 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; mTools << mEraser;
addItem(mEraser); addItem(mEraser);
@ -155,8 +200,8 @@ UBGraphicsScene::~UBGraphicsScene()
void UBGraphicsScene::selectionChangedProcessing() void UBGraphicsScene::selectionChangedProcessing()
{ {
if (selectedItems().count()) if (selectedItems().count())
UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f')); UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is "
+ QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f'));
QList<QGraphicsItem *> allItemsList = items(); QList<QGraphicsItem *> allItemsList = items();
qreal maxZ = 0.; qreal maxZ = 0.;
@ -827,9 +872,6 @@ void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem)
polygonItem->setColorOnLightBackground(colorOnLightBG); polygonItem->setColorOnLightBackground(colorOnLightBG);
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
// polygonItem->setZValue(getNextDrawingZIndex());
UBGraphicsItem::assignZValue(polygonItem, getNextDrawingZIndex());
} }
@ -1051,7 +1093,6 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const Q
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
// pixmapItem->setZValue(getNextObjectZIndex()); // pixmapItem->setZValue(getNextObjectZIndex());
UBGraphicsItem::assignZValue(pixmapItem, getNextObjectZIndex());
pixmapItem->setPixmap(pPixmap); pixmapItem->setPixmap(pPixmap);
@ -1104,7 +1145,6 @@ UBGraphicsVideoItem* UBGraphicsScene::addVideo(const QUrl& pVideoFileUrl, bool s
videoItem->setFlag(QGraphicsItem::ItemIsMovable, true); videoItem->setFlag(QGraphicsItem::ItemIsMovable, true);
videoItem->setFlag(QGraphicsItem::ItemIsSelectable, true); videoItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
// videoItem->setZValue(getNextObjectZIndex()); // videoItem->setZValue(getNextObjectZIndex());
UBGraphicsItem::assignZValue(videoItem, getNextObjectZIndex());
addItem(videoItem); addItem(videoItem);
@ -1137,7 +1177,6 @@ UBGraphicsAudioItem* UBGraphicsScene::addAudio(const QUrl& pAudioFileUrl, bool s
audioItem->setFlag(QGraphicsItem::ItemIsMovable, true); audioItem->setFlag(QGraphicsItem::ItemIsMovable, true);
audioItem->setFlag(QGraphicsItem::ItemIsSelectable, true); audioItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
// audioItem->setZValue(getNextObjectZIndex()); // audioItem->setZValue(getNextObjectZIndex());
UBGraphicsItem::assignZValue(audioItem, getNextObjectZIndex());
addItem(audioItem); addItem(audioItem);
@ -1204,8 +1243,6 @@ UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, c
void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, const QPointF& pPos) void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, const QPointF& pPos)
{ {
graphicsWidget->setFlag(QGraphicsItem::ItemIsSelectable, true); graphicsWidget->setFlag(QGraphicsItem::ItemIsSelectable, true);
// graphicsWidget->setZValue(getNextObjectZIndex());
UBGraphicsItem::assignZValue(graphicsWidget, getNextObjectZIndex());
addItem(graphicsWidget); addItem(graphicsWidget);
@ -1267,8 +1304,6 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint
svgItem->setFlag(QGraphicsItem::ItemIsMovable, true); svgItem->setFlag(QGraphicsItem::ItemIsMovable, true);
svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true); svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
// svgItem->setZValue(getNextObjectZIndex());
UBGraphicsItem::assignZValue(svgItem, getNextObjectZIndex());
qreal sscale = 1 / UBApplication::boardController->systemScaleFactor(); qreal sscale = 1 / UBApplication::boardController->systemScaleFactor();
svgItem->scale(sscale, sscale); svgItem->scale(sscale, sscale);
@ -1303,8 +1338,6 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
{ {
UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); UBGraphicsTextItem *textItem = new UBGraphicsTextItem();
textItem->setPlainText(pString); textItem->setPlainText(pString);
// textItem->setZValue(getNextObjectZIndex());
UBGraphicsItem::assignZValue(textItem, getNextObjectZIndex());
QFont font = textItem->font(); QFont font = textItem->font();
@ -1361,8 +1394,6 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q
UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); UBGraphicsTextItem *textItem = new UBGraphicsTextItem();
textItem->setPlainText(""); textItem->setPlainText("");
textItem->setHtml(pString); textItem->setHtml(pString);
// textItem->setZValue(getNextObjectZIndex());
UBGraphicsItem::assignZValue(textItem, getNextObjectZIndex());
addItem(textItem); addItem(textItem);
textItem->show(); textItem->show();
@ -1388,6 +1419,8 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
setModified(true); setModified(true);
UBCoreGraphicsScene::addItem(item); UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, generateZLevel(item));
if (!mTools.contains(item)) if (!mTools.contains(item))
++mItemCount; ++mItemCount;
@ -1398,8 +1431,10 @@ void UBGraphicsScene::addItems(const QSet<QGraphicsItem*>& items)
{ {
setModified(true); setModified(true);
foreach(QGraphicsItem* item, items) foreach(QGraphicsItem* item, items) {
UBCoreGraphicsScene::addItem(item); UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, generateZLevel(item));
}
mItemCount += items.size(); mItemCount += items.size();
@ -1461,7 +1496,7 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool
item->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::FixedBackground); item->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::FixedBackground);
// item->setZValue(backgroundLayerStart); // item->setZValue(backgroundLayerStart);
UBGraphicsItem::assignZValue(item, backgroundLayerStart); UBGraphicsItem::assignZValue(item, generateZLevel(item));
if (pAdaptTransformation) if (pAdaptTransformation)
{ {
@ -1565,9 +1600,6 @@ void UBGraphicsScene::addRuler(QPointF center)
QRectF rect = ruler->rect(); QRectF rect = ruler->rect();
ruler->setRect(center.x() - rect.width()/2, center.y() - rect.height()/2, rect.width(), rect.height()); ruler->setRect(center.x() - rect.width()/2, center.y() - rect.height()/2, rect.width(), rect.height());
// ruler->setZValue(toolLayerStart + toolOffsetRuler);
UBGraphicsItem::assignZValue(ruler, toolLayerStart + toolOffsetRuler);
ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
addItem(ruler); addItem(ruler);
@ -1584,9 +1616,6 @@ void UBGraphicsScene::addProtractor(QPointF center)
UBGraphicsProtractor* protractor = new UBGraphicsProtractor(); // mem : owned and destroyed by the scene UBGraphicsProtractor* protractor = new UBGraphicsProtractor(); // mem : owned and destroyed by the scene
mTools << protractor; mTools << protractor;
// protractor->setZValue(toolLayerStart + toolOffsetProtractor);
UBGraphicsItem::assignZValue(protractor, toolLayerStart + toolOffsetProtractor);
protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
addItem(protractor); addItem(protractor);
@ -1605,9 +1634,6 @@ void UBGraphicsScene::addTriangle(QPointF center)
UBGraphicsTriangle* triangle = new UBGraphicsTriangle(); // mem : owned and destroyed by the scene UBGraphicsTriangle* triangle = new UBGraphicsTriangle(); // mem : owned and destroyed by the scene
mTools << triangle; mTools << triangle;
// triangle->setZValue(toolLayerStart + toolOffsetProtractor);
UBGraphicsItem::assignZValue(triangle, toolLayerStart + toolOffsetTriangle);
triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
addItem(triangle); addItem(triangle);
@ -1738,9 +1764,6 @@ void UBGraphicsScene::addCompass(QPointF center)
QRectF rect = compass->rect(); QRectF rect = compass->rect();
compass->setRect(center.x() - rect.width() / 2, center.y() - rect.height() / 2, rect.width(), rect.height()); compass->setRect(center.x() - rect.width() / 2, center.y() - rect.height() / 2, rect.width(), rect.height());
// compass->setZValue(toolLayerStart + toolOffsetCompass);
UBGraphicsItem::assignZValue(compass, toolLayerStart + toolOffsetCompass);
compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
compass->setVisible(true); compass->setVisible(true);
@ -1772,8 +1795,6 @@ void UBGraphicsScene::addMask(const QPointF &center)
QRectF rect = UBApplication::boardController->activeScene()->normalizedSceneRect(); QRectF rect = UBApplication::boardController->activeScene()->normalizedSceneRect();
rect.setRect(center.x() - rect.width()/4, center.y() - rect.height()/4, rect.width()/2 , rect.height()/2); rect.setRect(center.x() - rect.width()/4, center.y() - rect.height()/4, rect.width()/2 , rect.height()/2);
curtain->setRect(rect); curtain->setRect(rect);
UBGraphicsItem::assignZValue(curtain, toolLayerStart + toolOffsetCurtain);
curtain->setVisible(true); curtain->setVisible(true);
curtain->setSelected(true); curtain->setSelected(true);
setModified(true); setModified(true);
@ -1992,6 +2013,17 @@ void UBGraphicsScene::setDocumentUpdated()
, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); , UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
} }
qreal UBGraphicsScene::generateZLevel(QGraphicsItem *item)
{
qreal result = UBZLayerController::errorNum();
itemLayerType::Enum type = static_cast<itemLayerType::Enum>(item->data(UBGraphicsItemData::itemLayerType).toInt());
if (mZLayerController.validLayerType(type)) {
result = mZLayerController.generateZLevel(type);
}
return result;
}
void UBGraphicsScene::setToolCursor(int tool) void UBGraphicsScene::setToolCursor(int tool)
{ {

@ -25,7 +25,6 @@
#include "UBItem.h" #include "UBItem.h"
#include "tools/UBGraphicsCurtainItem.h" #include "tools/UBGraphicsCurtainItem.h"
class UBGraphicsPixmapItem; class UBGraphicsPixmapItem;
class UBGraphicsProxyWidget; class UBGraphicsProxyWidget;
class UBGraphicsSvgItem; class UBGraphicsSvgItem;
@ -50,11 +49,41 @@ class UBGraphicsCache;
const double PI = 4.0 * atan(1.0); const double PI = 4.0 * atan(1.0);
class UBZLayerController
{
public:
struct ItemLayerTypeData {
ItemLayerTypeData() : bottomLimit(0), topLimit(0), curValue(0) {;}
ItemLayerTypeData(qreal bot, qreal top) : bottomLimit(bot), topLimit(top), curValue(bot) {;}
qreal bottomLimit;
qreal topLimit;
qreal curValue;
};
typedef QMap<itemLayerType::Enum, ItemLayerTypeData> ScopeMap;
UBZLayerController();
qreal getBottomLimit(itemLayerType::Enum key) const {return scopeMap.value(key).bottomLimit;}
qreal getTopLimit(itemLayerType::Enum key) const {return scopeMap.value(key).topLimit;}
bool validLayerType(itemLayerType::Enum key) const {return scopeMap.contains(key);}
static qreal errorNum() {return errorNumber;}
qreal generateZLevel(itemLayerType::Enum key);
private:
ScopeMap scopeMap;
static qreal errorNumber;
};
class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
{ {
Q_OBJECT Q_OBJECT
public: public:
// tmp stub for divide addings scene objects from undo mechanism implementation // tmp stub for divide addings scene objects from undo mechanism implementation
void setURStackEnable(bool set = true) {enableUndoRedoStack = set;} void setURStackEnable(bool set = true) {enableUndoRedoStack = set;}
@ -323,6 +352,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
private: private:
void setDocumentUpdated(); void setDocumentUpdated();
qreal generateZLevel(QGraphicsItem *item);
qreal mDrawingZIndex; qreal mDrawingZIndex;
qreal mObjectZIndex; qreal mObjectZIndex;
@ -376,7 +406,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBMagnifier *magniferControlViewWidget; UBMagnifier *magniferControlViewWidget;
UBMagnifier *magniferDisplayViewWidget; UBMagnifier *magniferDisplayViewWidget;
UBZLayerController mZLayerController;
}; };
#endif /* UBGRAPHICSSCENE_H_ */ #endif /* UBGRAPHICSSCENE_H_ */

@ -37,7 +37,6 @@ UBGraphicsSvgItem::UBGraphicsSvgItem(const QString& pFilePath, QGraphicsItem* pa
} }
} }
UBGraphicsSvgItem::UBGraphicsSvgItem(const QByteArray& pFileData, QGraphicsItem* parent) UBGraphicsSvgItem::UBGraphicsSvgItem(const QByteArray& pFileData, QGraphicsItem* parent)
: QGraphicsSvgItem(parent) : QGraphicsSvgItem(parent)
{ {
@ -47,6 +46,8 @@ UBGraphicsSvgItem::UBGraphicsSvgItem(const QByteArray& pFileData, QGraphicsItem*
setSharedRenderer(renderer); setSharedRenderer(renderer);
mFileData = pFileData; mFileData = pFileData;
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
} }

@ -40,23 +40,11 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
mTypeTextHereLabel = tr("<Type Text Here>"); mTypeTextHereLabel = tr("<Type Text Here>");
// if (lastUsedTextColor.isValid())
// {
// setDefaultTextColor(lastUsedTextColor);
// setColorOnDarkBackground(lastUsedTextColor);
// setColorOnLightBackground(lastUsedTextColor);
// }
// else
// {
// QColor colorOnDarkBG = UBApplication::boardController->penColorOnDarkBackground();
// QColor colorOnLightBG = UBApplication::boardController->penColorOnLightBackground();
// setColorOnDarkBackground(colorOnDarkBG);
// setColorOnLightBackground(colorOnLightBG);
// }
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
// setData(UBGraphicsItemData::ItemEditable, QVariant(true)); // setData(UBGraphicsItemData::ItemEditable, QVariant(true));
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
// setFlag(QGraphicsItem::ItemIsMovable, true); // setFlag(QGraphicsItem::ItemIsMovable, true);

@ -96,10 +96,10 @@ void UBGraphicsTextItemDelegate::buildButtons()
{ {
UBGraphicsItemDelegate::buildButtons(); UBGraphicsItemDelegate::buildButtons();
mFontButton = new DelegateButton(":/images/font.svg", mDelegated, mFrame); mFontButton = new DelegateButton(":/images/font.svg", mDelegated, mFrame, Qt::TopLeftSection);
mColorButton = new DelegateButton(":/images/color.svg", mDelegated, mFrame); mColorButton = new DelegateButton(":/images/color.svg", mDelegated, mFrame, Qt::TopLeftSection);
mDecreaseSizeButton = new DelegateButton(":/images/minus.svg", mDelegated, mFrame); mDecreaseSizeButton = new DelegateButton(":/images/minus.svg", mDelegated, mFrame, Qt::TopLeftSection);
mIncreaseSizeButton = new DelegateButton(":/images/plus.svg", mDelegated, mFrame); mIncreaseSizeButton = new DelegateButton(":/images/plus.svg", mDelegated, mFrame, Qt::TopLeftSection);
connect(mFontButton, SIGNAL(clicked(bool)), this, SLOT(pickFont())); connect(mFontButton, SIGNAL(clicked(bool)), this, SLOT(pickFont()));
connect(mColorButton, SIGNAL(clicked(bool)), this, SLOT(pickColor())); connect(mColorButton, SIGNAL(clicked(bool)), this, SLOT(pickColor()));

@ -51,6 +51,8 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl& pVideoFileUrl, QGraphicsIte
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
connect(mDelegate, SIGNAL(showOnDisplayChanged(bool)), this, SLOT(showOnDisplayChanged(bool))); connect(mDelegate, SIGNAL(showOnDisplayChanged(bool)), this, SLOT(showOnDisplayChanged(bool)));
connect(mMediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool))); connect(mMediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool)));
} }

@ -39,6 +39,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(QGraphicsItem *parent, int widgetType
UBGraphicsWidgetItemDelegate* delegate = new UBGraphicsWidgetItemDelegate(this, widgetType); UBGraphicsWidgetItemDelegate* delegate = new UBGraphicsWidgetItemDelegate(this, widgetType);
delegate->init(); delegate->init();
setDelegate(delegate); setDelegate(delegate);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
} }
@ -154,6 +155,8 @@ void UBGraphicsWidgetItem::initialize()
if (mDelegate && mDelegate->frame() && mWebKitWidget->resizable()) if (mDelegate && mDelegate->frame() && mWebKitWidget->resizable())
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
} }

@ -17,6 +17,7 @@
#include <QtGui> #include <QtGui>
#include "domain/UBGraphicsItemDelegate.h" #include "domain/UBGraphicsItemDelegate.h"
#include "core/UB.h"
class UBGraphicsScene; class UBGraphicsScene;

@ -48,6 +48,7 @@ UBAbstractDrawRuler::UBAbstractDrawRuler()
QDesktopWidget* desktop = UBApplication::desktop(); QDesktopWidget* desktop = UBApplication::desktop();
int dpiCommon = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; int dpiCommon = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2;
sPixelsPerMillimeter = qRound(dpiCommon / 25.4f);//because 1inch = 25.4 mm sPixelsPerMillimeter = qRound(dpiCommon / 25.4f);//because 1inch = 25.4 mm
} }
void UBAbstractDrawRuler::create(QGraphicsItem& item) void UBAbstractDrawRuler::create(QGraphicsItem& item)

@ -33,14 +33,12 @@ UBGraphicsCache::UBGraphicsCache():QGraphicsRectItem()
// Get the board size and pass it to the shape // Get the board size and pass it to the shape
QRect boardRect = UBApplication::boardController->displayView()->rect(); QRect boardRect = UBApplication::boardController->displayView()->rect();
setRect(-15*boardRect.width(), -15*boardRect.height(), 30*boardRect.width(), 30*boardRect.height()); setRect(-15*boardRect.width(), -15*boardRect.height(), 30*boardRect.width(), 30*boardRect.height());
// setZValue(CACHE_ZVALUE);
UBGraphicsItem::assignZValue(this, CACHE_ZVALUE);
setData(Qt::UserRole, QVariant("Cache")); setData(Qt::UserRole, QVariant("Cache"));
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Cache)); //Necessary to set if we want z value to be assigned correctly
} }
UBGraphicsCache::~UBGraphicsCache() UBGraphicsCache::~UBGraphicsCache()
{ {
} }
UBItem* UBGraphicsCache::deepCopy() const UBItem* UBGraphicsCache::deepCopy() const
@ -92,8 +90,6 @@ void UBGraphicsCache::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);
UBGraphicsItem::assignZValue(this, CACHE_ZVALUE);
painter->setBrush(mMaskColor); painter->setBrush(mMaskColor);
painter->setPen(mMaskColor); painter->setPen(mMaskColor);

@ -21,8 +21,6 @@
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "core/UB.h" #include "core/UB.h"
#define CACHE_ZVALUE 100000
typedef enum typedef enum
{ {
eMaskShape_Circle, eMaskShape_Circle,

@ -70,6 +70,8 @@ UBGraphicsCompass::UBGraphicsCompass()
unsetCursor(); unsetCursor();
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
connect(UBApplication::boardController, SIGNAL(penColorChanged()), this, SLOT(penColorChanged())); connect(UBApplication::boardController, SIGNAL(penColorChanged()), this, SLOT(penColorChanged()));
connect(UBDrawingController::drawingController(), SIGNAL(lineWidthIndexChanged(int)), this, SLOT(lineWidthChanged())); connect(UBDrawingController::drawingController(), SIGNAL(lineWidthIndexChanged(int)), this, SLOT(lineWidthChanged()));
} }

@ -49,6 +49,8 @@ UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent)
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Tool); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Tool);
setPen(Qt::NoPen); setPen(Qt::NoPen);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Curtain)); //Necessary to set if we want z value to be assigned correctly
} }
UBGraphicsCurtainItem::~UBGraphicsCurtainItem() UBGraphicsCurtainItem::~UBGraphicsCurtainItem()

@ -63,6 +63,7 @@ UBGraphicsProtractor::UBGraphicsProtractor()
mRotateSvgItem->setVisible(false); mRotateSvgItem->setVisible(false);
mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
scale(1.5, 1.5); scale(1.5, 1.5);
} }

@ -44,6 +44,8 @@ UBGraphicsRuler::UBGraphicsRuler()
create(*this); create(*this);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
updateResizeCursor(); updateResizeCursor();
} }

@ -43,8 +43,8 @@ UBGraphicsTriangle::UBGraphicsTriangle()
mHFlipSvgItem = new QGraphicsSvgItem(":/images/hflipTool.svg", this); mHFlipSvgItem = new QGraphicsSvgItem(":/images/hflipTool.svg", this);
mHFlipSvgItem->setVisible(false); mHFlipSvgItem->setVisible(false);
mHFlipSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mHFlipSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mVFlipSvgItem = new QGraphicsSvgItem(":/images/vflipTool.svg", this); mVFlipSvgItem = new QGraphicsSvgItem(":/images/vflipTool.svg", this);
mVFlipSvgItem->setVisible(false); mVFlipSvgItem->setVisible(false);
@ -54,6 +54,8 @@ UBGraphicsTriangle::UBGraphicsTriangle()
mRotateSvgItem->setVisible(false); mRotateSvgItem->setVisible(false);
mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
updateResizeCursor(); updateResizeCursor();
} }

Loading…
Cancel
Save