preferencesAboutTextFull
shibakaneki 13 years ago
parent 0dd72f68a2
commit f16c06f9b8
  1. 60
      src/adaptors/UBExportCFF.cpp
  2. 39
      src/adaptors/UBExportCFF.h
  3. 107
      src/adaptors/UBSvgSubsetAdaptor.cpp
  4. 2
      src/adaptors/UBSvgSubsetAdaptor.h
  5. 2
      src/adaptors/adaptors.pri
  6. 7
      src/board/UBBoardController.cpp
  7. 4
      src/board/UBBoardView.cpp
  8. 25
      src/core/UB.h
  9. 3
      src/core/UBApplication.cpp
  10. 21
      src/core/UBApplicationController.cpp
  11. 2
      src/core/UBApplicationController.h
  12. 22
      src/core/UBDisplayManager.cpp
  13. 10
      src/core/UBDisplayManager.h
  14. 3
      src/core/UBDocumentManager.cpp
  15. 2
      src/core/UBPreferencesController.cpp
  16. 1
      src/desktop/UBDesktopAnnotationController.cpp
  17. 4
      src/domain/UBGraphicsAudioItem.cpp
  18. 67
      src/domain/UBGraphicsItemDelegate.cpp
  19. 18
      src/domain/UBGraphicsItemDelegate.h
  20. 7
      src/domain/UBGraphicsPDFItem.cpp
  21. 3
      src/domain/UBGraphicsPixmapItem.cpp
  22. 11
      src/domain/UBGraphicsPolygonItem.cpp
  23. 2
      src/domain/UBGraphicsPolygonItem.h
  24. 302
      src/domain/UBGraphicsScene.cpp
  25. 67
      src/domain/UBGraphicsScene.h
  26. 7
      src/domain/UBGraphicsSvgItem.cpp
  27. 18
      src/domain/UBGraphicsTextItem.cpp
  28. 8
      src/domain/UBGraphicsTextItemDelegate.cpp
  29. 4
      src/domain/UBGraphicsVideoItem.cpp
  30. 4
      src/domain/UBGraphicsVideoItemDelegate.cpp
  31. 4
      src/domain/UBGraphicsWidgetItem.cpp
  32. 1
      src/domain/UBItem.h
  33. 110
      src/gui/UBMagnifer.cpp
  34. 7
      src/gui/UBMagnifer.h
  35. 1
      src/tools/UBAbstractDrawRuler.cpp
  36. 8
      src/tools/UBGraphicsCache.cpp
  37. 2
      src/tools/UBGraphicsCache.h
  38. 4
      src/tools/UBGraphicsCompass.cpp
  39. 6
      src/tools/UBGraphicsCurtainItem.cpp
  40. 1
      src/tools/UBGraphicsCurtainItemDelegate.cpp
  41. 3
      src/tools/UBGraphicsProtractor.cpp
  42. 4
      src/tools/UBGraphicsRuler.cpp
  43. 6
      src/tools/UBGraphicsTriangle.cpp

@ -0,0 +1,60 @@
#include "UBExportCFF.h"
#include "UBCFFAdaptor.h"
#include "document/UBDocumentProxy.h"
#include "core/UBDocumentManager.h"
#include "core/UBApplication.h"
UBExportCFF::UBExportCFF(QObject *parent)
: UBExportAdaptor(parent)
{
}
UBExportCFF::~UBExportCFF()
{
}
QString UBExportCFF::exportName()
{
return tr("Export to IWB");
}
QString UBExportCFF::exportExtention()
{
return QString(".iwb");
}
void UBExportCFF::persist(UBDocumentProxy* pDocument)
{
QString src = pDocument->persistencePath();
if (!pDocument)
return;
QString filename = askForFileName(pDocument, tr("Export as IWB File"));
if (filename.length() > 0)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
if (mIsVerbose)
UBApplication::showMessage(tr("Exporting document..."));
UBCFFAdaptor toIWBExporter;
if (toIWBExporter.convertUBZToIWB(src, filename))
{
if (mIsVerbose)
UBApplication::showMessage(tr("Export successful."));
}
else
if (mIsVerbose)
UBApplication::showMessage(tr("Export failed."));
QApplication::restoreOverrideCursor();
}
}

@ -0,0 +1,39 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBExportCFF_H_
#define UBExportCFF_H_
#include <QtCore>
#include "UBExportAdaptor.h"
#include "frameworks/UBFileSystemUtils.h"
class UBDocumentProxy;
class UBExportCFF : public UBExportAdaptor
{
Q_OBJECT;
public:
UBExportCFF(QObject *parent = 0);
virtual ~UBExportCFF();
virtual QString exportName();
virtual QString exportExtention();
virtual void persist(UBDocumentProxy* pDocument);
};
#endif /* UBExportCFF_H_ */

@ -306,9 +306,6 @@ UBSvgSubsetAdaptor::UBSvgSubsetReader::UBSvgSubsetReader(UBDocumentProxy* pProxy
UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{ {
UBGraphicsScene *scene = 0; UBGraphicsScene *scene = 0;
qreal maxDrawingZIndex = 0;
qreal maxObjectZIndex = 0;
UBGraphicsWidgetItem *currentWidget = 0; UBGraphicsWidgetItem *currentWidget = 0;
mFileVersion = 40100; // default to 4.1.0 mFileVersion = 40100; // default to 4.1.0
@ -320,6 +317,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)
@ -479,7 +478,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(polygonItem); scene->addItem(polygonItem);
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
maxDrawingZIndex = qMax(polygonItem->zValue(), maxDrawingZIndex);
polygonItem->show(); polygonItem->show();
} }
@ -499,8 +497,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->addItem(polygonItem); scene->addItem(polygonItem);
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
maxDrawingZIndex = qMax(polygonItem->zValue(), maxDrawingZIndex);
polygonItem->show(); polygonItem->show();
} }
} }
@ -525,10 +521,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(pixmapItem->zValue(), maxObjectZIndex);
scene->addItem(pixmapItem); scene->addItem(pixmapItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(pixmapItem, zFromSvg);
if (isBackground) if (isBackground)
scene->setAsBackgroundObject(pixmapItem); scene->setAsBackgroundObject(pixmapItem);
@ -544,10 +541,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
svgItem->setFlag(QGraphicsItem::ItemIsMovable, true); svgItem->setFlag(QGraphicsItem::ItemIsMovable, true);
svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true); svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(svgItem->zValue(), maxObjectZIndex);
scene->addItem(svgItem); scene->addItem(svgItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(svgItem, zFromSvg);
if (isBackground) if (isBackground)
scene->setAsBackgroundObject(svgItem); scene->setAsBackgroundObject(svgItem);
@ -569,10 +567,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
audioItem->setFlag(QGraphicsItem::ItemIsMovable, true); audioItem->setFlag(QGraphicsItem::ItemIsMovable, true);
audioItem->setFlag(QGraphicsItem::ItemIsSelectable, true); audioItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(audioItem->zValue(), maxObjectZIndex);
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
@ -589,10 +588,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
videoItem->setFlag(QGraphicsItem::ItemIsMovable, true); videoItem->setFlag(QGraphicsItem::ItemIsMovable, true);
videoItem->setFlag(QGraphicsItem::ItemIsSelectable, true); videoItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(videoItem->zValue(), maxObjectZIndex);
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
@ -609,10 +609,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
textItem->setFlag(QGraphicsItem::ItemIsMovable, true); textItem->setFlag(QGraphicsItem::ItemIsMovable, true);
textItem->setFlag(QGraphicsItem::ItemIsSelectable, true); textItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(textItem->zValue(), maxObjectZIndex);
scene->addItem(textItem); scene->addItem(textItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(textItem, zFromSvg);
textItem->show(); textItem->show();
} }
} }
@ -624,17 +625,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 +655,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 +668,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 +681,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 +694,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")
@ -694,10 +717,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
pdfItem->setFlag(QGraphicsItem::ItemIsMovable, true); pdfItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pdfItem->setFlag(QGraphicsItem::ItemIsSelectable, true); pdfItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(pdfItem->zValue(), maxObjectZIndex);
scene->addItem(pdfItem); scene->addItem(pdfItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(pdfItem, zFromSvg);
if (isBackground) if (isBackground)
scene->setAsBackgroundObject(pdfItem); scene->setAsBackgroundObject(pdfItem);
@ -716,10 +740,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
appleWidgetItem->resize(foreignObjectWidth, foreignObjectHeight); appleWidgetItem->resize(foreignObjectWidth, foreignObjectHeight);
maxObjectZIndex = qMax(appleWidgetItem->zValue(), maxObjectZIndex);
scene->addItem(appleWidgetItem); scene->addItem(appleWidgetItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(appleWidgetItem, zFromSvg);
appleWidgetItem->show(); appleWidgetItem->show();
currentWidget = appleWidgetItem; currentWidget = appleWidgetItem;
@ -736,10 +761,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
w3cWidgetItem->resize(foreignObjectWidth, foreignObjectHeight); w3cWidgetItem->resize(foreignObjectWidth, foreignObjectHeight);
maxObjectZIndex = qMax(w3cWidgetItem->zValue(), maxObjectZIndex);
scene->addItem(w3cWidgetItem); scene->addItem(w3cWidgetItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(w3cWidgetItem, zFromSvg);
w3cWidgetItem->show(); w3cWidgetItem->show();
currentWidget = w3cWidgetItem; currentWidget = w3cWidgetItem;
@ -754,8 +780,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
textItem->setFlag(QGraphicsItem::ItemIsMovable, true); textItem->setFlag(QGraphicsItem::ItemIsMovable, true);
textItem->setFlag(QGraphicsItem::ItemIsSelectable, true); textItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
maxObjectZIndex = qMax(textItem->zValue(), maxObjectZIndex);
scene->addItem(textItem); scene->addItem(textItem);
if (zFromSvg != UBZLayerController::errorNum())
UBGraphicsItem::assignZValue(textItem, zFromSvg);
textItem->show(); textItem->show();
} }
} }
@ -804,17 +833,14 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
qWarning() << "error parsing Sankore file " << mXmlReader.errorString(); qWarning() << "error parsing Sankore file " << mXmlReader.errorString();
} }
if (scene) if (scene) {
{
scene->setObjectZIndex(maxObjectZIndex);
scene->setDrawingZIndex(maxDrawingZIndex);
scene->setModified(false); scene->setModified(false);
} }
if (annotationGroup) if (annotationGroup)
{ {
if (annotationGroup->polygons().empty()) if (annotationGroup->polygons().empty())
delete annotationGroup; delete annotationGroup;
} }
return scene; return scene;
@ -1348,12 +1374,10 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
if (!ubZValue.isNull()) if (!ubZValue.isNull())
{ {
// polygonItem->setZValue (ubZValue.toString().toFloat());
UBGraphicsItem::assignZValue(polygonItem, ubZValue.toString().toFloat()); UBGraphicsItem::assignZValue(polygonItem, ubZValue.toString().toFloat());
} }
else else
{ {
// polygonItem->setZValue(mGroupZIndex);
UBGraphicsItem::assignZValue(polygonItem, mGroupZIndex); UBGraphicsItem::assignZValue(polygonItem, mGroupZIndex);
} }
@ -1457,12 +1481,10 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLin
if (!ubZValue.isNull()) if (!ubZValue.isNull())
{ {
// polygonItem->setZValue(ubZValue.toString().toFloat());
UBGraphicsItem::assignZValue(polygonItem, ubZValue.toString().toFloat()); UBGraphicsItem::assignZValue(polygonItem, ubZValue.toString().toFloat());
} }
else else
{ {
// polygonItem->setZValue(mGroupZIndex);
UBGraphicsItem::assignZValue(polygonItem, mGroupZIndex); UBGraphicsItem::assignZValue(polygonItem, mGroupZIndex);
} }
@ -1611,7 +1633,6 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem
{ {
UBGraphicsPolygonItem* polygonItem = new UBGraphicsPolygonItem(QLineF(points.at(i), points.at(i + 1)), lineWidth); UBGraphicsPolygonItem* polygonItem = new UBGraphicsPolygonItem(QLineF(points.at(i), points.at(i + 1)), lineWidth);
polygonItem->setColor(brushColor); polygonItem->setColor(brushColor);
// polygonItem->setZValue(zValue);
UBGraphicsItem::assignZValue(polygonItem, zValue); UBGraphicsItem::assignZValue(polygonItem, zValue);
polygonItem->setColorOnDarkBackground(colorOnDarkBackground); polygonItem->setColorOnDarkBackground(colorOnDarkBackground);
polygonItem->setColorOnLightBackground(colorOnLightBackground); polygonItem->setColorOnLightBackground(colorOnLightBackground);
@ -1956,7 +1977,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g
if (!ubZValue.isNull()) if (!ubZValue.isNull())
{ {
// gItem->setZValue(ubZValue.toString().toFloat());
UBGraphicsItem::assignZValue(gItem, ubZValue.toString().toFloat()); UBGraphicsItem::assignZValue(gItem, ubZValue.toString().toFloat());
} }
@ -2009,6 +2029,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)
{ {
@ -2528,7 +2559,6 @@ UBGraphicsRuler* UBSvgSubsetAdaptor::UBSvgSubsetReader::rulerFromSvg()
graphicsItemFromSvg(ruler); graphicsItemFromSvg(ruler);
// ruler->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler);
UBGraphicsItem::assignZValue(ruler, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler); UBGraphicsItem::assignZValue(ruler, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler);
ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
@ -2587,7 +2617,6 @@ UBGraphicsCompass* UBSvgSubsetAdaptor::UBSvgSubsetReader::compassFromSvg()
graphicsItemFromSvg(compass); graphicsItemFromSvg(compass);
//compass->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass);
UBGraphicsItem::assignZValue(compass, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass); UBGraphicsItem::assignZValue(compass, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass);
compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
@ -2652,7 +2681,6 @@ UBGraphicsProtractor* UBSvgSubsetAdaptor::UBSvgSubsetReader::protractorFromSvg()
{ {
UBGraphicsProtractor* protractor = new UBGraphicsProtractor(); UBGraphicsProtractor* protractor = new UBGraphicsProtractor();
// protractor->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor);
UBGraphicsItem::assignZValue(protractor, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor); UBGraphicsItem::assignZValue(protractor, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor);
protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
@ -2723,7 +2751,6 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
{ {
UBGraphicsTriangle* triangle = new UBGraphicsTriangle(); UBGraphicsTriangle* triangle = new UBGraphicsTriangle();
// triangle->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle);
UBGraphicsItem::assignZValue(triangle, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle); UBGraphicsItem::assignZValue(triangle, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle);
triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
@ -2750,8 +2777,6 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
UBGraphicsCache* UBSvgSubsetAdaptor::UBSvgSubsetReader::cacheFromSvg() UBGraphicsCache* UBSvgSubsetAdaptor::UBSvgSubsetReader::cacheFromSvg()
{ {
UBGraphicsCache* pCache = new UBGraphicsCache(); UBGraphicsCache* pCache = new UBGraphicsCache();
pCache->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCache);
// UBGraphicsItem::assignZValue(pCache, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCache);
pCache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); pCache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
graphicsItemFromSvg(pCache); graphicsItemFromSvg(pCache);

@ -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;

@ -14,6 +14,7 @@ HEADERS += src/adaptors/UBExportAdaptor.h\
src/adaptors/UBExportWeb.h \ src/adaptors/UBExportWeb.h \
src/adaptors/UBWebPublisher.h \ src/adaptors/UBWebPublisher.h \
src/adaptors/UBImportCFF.h \ src/adaptors/UBImportCFF.h \
src/adaptors/UBExportCFF.h \
src/adaptors/UBCFFSubsetAdaptor.h src/adaptors/UBCFFSubsetAdaptor.h
HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \ HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \
@ -36,6 +37,7 @@ SOURCES += src/adaptors/UBExportAdaptor.cpp\
src/adaptors/UBExportWeb.cpp \ src/adaptors/UBExportWeb.cpp \
src/adaptors/UBWebPublisher.cpp \ src/adaptors/UBWebPublisher.cpp \
src/adaptors/UBImportCFF.cpp \ src/adaptors/UBImportCFF.cpp \
src/adaptors/UBExportCFF.cpp \
src/adaptors/UBCFFSubsetAdaptor.cpp \ src/adaptors/UBCFFSubsetAdaptor.cpp \
src/adaptors/publishing/UBDocumentPublisher.cpp src/adaptors/publishing/UBDocumentPublisher.cpp

@ -664,6 +664,7 @@ void UBBoardController::zoom(const qreal ratio, QPointF scenePoint)
UBApplication::applicationController->adjustDisplayView(); UBApplication::applicationController->adjustDisplayView();
emit controlViewportChanged(); emit controlViewportChanged();
mActiveScene->setBackgroundZoomFactor(mControlView->transform().m11());
} }
@ -1163,7 +1164,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
mControlView->setScene(mActiveScene); mControlView->setScene(mActiveScene);
mDisplayView->setScene(mActiveScene); mDisplayView->setScene(mActiveScene);
mActiveScene->setBackgroundZoomFactor(mControlView->transform().m11());
pDocumentProxy->setDefaultDocumentSize(mActiveScene->nominalSize()); pDocumentProxy->setDefaultDocumentSize(mActiveScene->nominalSize());
updatePageSizeState(); updatePageSizeState();
@ -1564,7 +1565,7 @@ void UBBoardController::updateSystemScaleFactor()
mControlView->setTransform(scalingTransform); mControlView->setTransform(scalingTransform);
mControlView->horizontalScrollBar()->setValue(viewState.horizontalPosition); mControlView->horizontalScrollBar()->setValue(viewState.horizontalPosition);
mControlView->verticalScrollBar()->setValue(viewState.verticalPostition); mControlView->verticalScrollBar()->setValue(viewState.verticalPostition);
} mActiveScene->setBackgroundZoomFactor(mControlView->transform().m11());}
void UBBoardController::setWidePageSize(bool checked) void UBBoardController::setWidePageSize(bool checked)
@ -1943,8 +1944,6 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if (gi) if (gi)
{ {
// gi->setZValue(mActiveScene->getNextObjectZIndex());
UBGraphicsItem::assignZValue(gi, mActiveScene->getNextObjectZIndex());
mActiveScene->addItem(gi); mActiveScene->addItem(gi);
gi->setPos(gi->pos() + QPointF(50, 50)); gi->setPos(gi->pos() + QPointF(50, 50));
} }

@ -54,6 +54,7 @@
#include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h" #include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -425,7 +426,8 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
|| movingItem->type() == UBGraphicsCompass::Type || movingItem->type() == UBGraphicsCompass::Type
|| movingItem->type() == UBGraphicsPDFItem::Type || movingItem->type() == UBGraphicsPDFItem::Type
|| movingItem->type() == UBGraphicsPolygonItem::Type || movingItem->type() == UBGraphicsPolygonItem::Type
|| movingItem->type() == UBGraphicsCache::Type) || movingItem->type() == UBGraphicsCache::Type
|| movingItem->type() == UBGraphicsTriangle::Type)
{ {
movingItem = NULL; movingItem = NULL;
QGraphicsView::mousePressEvent (event); QGraphicsView::mousePressEvent (event);

@ -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,38 @@ struct UBItemLayerType
}; };
}; };
struct itemLayerType
{
enum Enum {
NoLayer = 0
, BackgroundItem
, ObjectItem
, DrawingItem
, ToolItem
, CppTool
, Eraiser
, Curtain
, Pointer
, Cache
, SelectedItem
};
};
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

@ -289,7 +289,6 @@ int UBApplication::exec(const QString& pFileToImport)
bool bUseMultiScreen = UBSettings::settings()->appUseMultiscreen->get().toBool(); bool bUseMultiScreen = UBSettings::settings()->appUseMultiscreen->get().toBool();
mainWindow->actionMultiScreen->setChecked(bUseMultiScreen); mainWindow->actionMultiScreen->setChecked(bUseMultiScreen);
applicationController->useMultiScreen(bUseMultiScreen);
connect(mainWindow->actionMultiScreen, SIGNAL(triggered(bool)), applicationController, SLOT(useMultiScreen(bool))); connect(mainWindow->actionMultiScreen, SIGNAL(triggered(bool)), applicationController, SLOT(useMultiScreen(bool)));
connect(mainWindow->actionWidePageSize, SIGNAL(triggered(bool)), boardController, SLOT(setWidePageSize(bool))); connect(mainWindow->actionWidePageSize, SIGNAL(triggered(bool)), boardController, SLOT(setWidePageSize(bool)));
connect(mainWindow->actionRegularPageSize, SIGNAL(triggered(bool)), boardController, SLOT(setRegularPageSize(bool))); connect(mainWindow->actionRegularPageSize, SIGNAL(triggered(bool)), boardController, SLOT(setRegularPageSize(bool)));
@ -299,7 +298,7 @@ int UBApplication::exec(const QString& pFileToImport)
connect(mainWindow->actionCopy, SIGNAL(triggered()), applicationController, SLOT(actionCopy())); connect(mainWindow->actionCopy, SIGNAL(triggered()), applicationController, SLOT(actionCopy()));
connect(mainWindow->actionPaste, SIGNAL(triggered()), applicationController, SLOT(actionPaste())); connect(mainWindow->actionPaste, SIGNAL(triggered()), applicationController, SLOT(actionPaste()));
applicationController->initScreenLayout(); applicationController->initScreenLayout(bUseMultiScreen);
boardController->setupLayout(); boardController->setupLayout();
if (pFileToImport.length() > 0) if (pFileToImport.length() > 0)

@ -135,14 +135,15 @@ void UBApplicationController::initViewState(int horizontalPosition, int vertical
} }
void UBApplicationController::initScreenLayout() void UBApplicationController::initScreenLayout(bool useMultiscreen)
{ {
mDisplayManager->setAsControl(mMainWindow, true); mDisplayManager->setControlWidget(mMainWindow);
mDisplayManager->setAsDisplay(mDisplayView); mDisplayManager->setDisplayWidget(mDisplayView);
mDisplayManager->setAsPreviousDisplays(mPreviousViews); mDisplayManager->setPreviousDisplaysWidgets(mPreviousViews);
mDisplayManager->setAsDesktop(mUninoteController->drawingView()); mDisplayManager->setDesktopWidget(mUninoteController->drawingView());
mDisplayManager->setUseMultiScreen(useMultiscreen);
mDisplayManager->adjustScreens(-1); mDisplayManager->adjustScreens(-1);
} }
@ -343,7 +344,6 @@ void UBApplicationController::showBoard()
mirroringEnabled(false); mirroringEnabled(false);
mMainWindow->switchToBoardWidget(); mMainWindow->switchToBoardWidget();
mDisplayManager->setAsDisplay(mDisplayView);
if (UBApplication::boardController) if (UBApplication::boardController)
UBApplication::boardController->show(); UBApplication::boardController->show();
@ -353,7 +353,7 @@ void UBApplicationController::showBoard()
mUninoteController->hideWindow(); mUninoteController->hideWindow();
mDisplayManager->adjustScreens(0); mMainWindow->show();
emit mainModeChanged(Board); emit mainModeChanged(Board);
@ -637,12 +637,12 @@ void UBApplicationController::mirroringEnabled(bool enabled)
if (enabled) if (enabled)
{ {
mMirror->start(); mMirror->start();
mDisplayManager->setAsDisplay(mMirror); mDisplayManager->setDisplayWidget(mMirror);
} }
else else
{ {
mDisplayManager->setAsDisplay(mDisplayView); mDisplayManager->setDisplayWidget(mDisplayView);
mMirror->stop(); mMirror->stop();
} }
@ -652,7 +652,7 @@ void UBApplicationController::mirroringEnabled(bool enabled)
} }
else else
{ {
mDisplayManager->setAsDisplay(mDisplayView); mDisplayManager->setDisplayWidget(mDisplayView);
} }
} }
@ -727,6 +727,7 @@ void UBApplicationController::importFile(const QString& pFilePath)
void UBApplicationController::useMultiScreen(bool use) void UBApplicationController::useMultiScreen(bool use)
{ {
mDisplayManager->setUseMultiScreen(use); mDisplayManager->setUseMultiScreen(use);
mDisplayManager->adjustScreens(0);
UBSettings::settings()->appUseMultiscreen->set(use); UBSettings::settings()->appUseMultiscreen->set(use);
} }

@ -51,7 +51,7 @@ class UBApplicationController : public QObject
void blackout(); void blackout();
void initScreenLayout(); void initScreenLayout(bool useMultiscreen);
void closing(); void closing();

@ -118,16 +118,11 @@ int UBDisplayManager::numPreviousViews()
} }
void UBDisplayManager::setAsControl(QWidget* pControlWidget, bool init) void UBDisplayManager::setControlWidget(QWidget* pControlWidget)
{ {
if(hasControl() && pControlWidget && (pControlWidget != mControlWidget)) if(hasControl() && pControlWidget && (pControlWidget != mControlWidget))
{ {
mControlWidget = pControlWidget; mControlWidget = pControlWidget;
mControlWidget->hide();
mControlWidget->setGeometry(mDesktop->screenGeometry(mControlScreenIndex));
if (!init)
mControlWidget->showFullScreen();
// !!!! Should be included into Windows after QT recompilation // !!!! Should be included into Windows after QT recompilation
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// mControlWidget->setAttribute(Qt::WA_MacNoShadow); // mControlWidget->setAttribute(Qt::WA_MacNoShadow);
@ -135,14 +130,11 @@ void UBDisplayManager::setAsControl(QWidget* pControlWidget, bool init)
} }
} }
void UBDisplayManager::setAsDesktop(QWidget* pControlWidget ) void UBDisplayManager::setDesktopWidget(QWidget* pControlWidget )
{ {
if(pControlWidget && (pControlWidget != mControlWidget)) if(pControlWidget && (pControlWidget != mControlWidget))
{ {
mDesktopWidget = pControlWidget; mDesktopWidget = pControlWidget;
mDesktopWidget->hide();
mDesktopWidget->setGeometry(mDesktop->screenGeometry(mControlScreenIndex));
// mDisplayWidget->showFullScreen();
// !!!! Should be included into Windows after QT recompilation // !!!! Should be included into Windows after QT recompilation
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// mControlWidget->setAttribute(Qt::WA_MacNoShadow); // mControlWidget->setAttribute(Qt::WA_MacNoShadow);
@ -150,14 +142,11 @@ void UBDisplayManager::setAsDesktop(QWidget* pControlWidget )
} }
} }
void UBDisplayManager::setAsDisplay(QWidget* pDisplayWidget) void UBDisplayManager::setDisplayWidget(QWidget* pDisplayWidget)
{ {
if(pDisplayWidget && (pDisplayWidget != mDisplayWidget)) if(pDisplayWidget && (pDisplayWidget != mDisplayWidget))
{ {
mDisplayWidget = pDisplayWidget; mDisplayWidget = pDisplayWidget;
mDisplayWidget->hide();
mDisplayWidget->setGeometry(mDesktop->screenGeometry(mDisplayScreenIndex));
mDisplayWidget->showFullScreen();
// !!!! Should be included into Windows after QT recompilation // !!!! Should be included into Windows after QT recompilation
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// mDisplayWidget->setAttribute(Qt::WA_MacNoShadow); // mDisplayWidget->setAttribute(Qt::WA_MacNoShadow);
@ -166,7 +155,7 @@ void UBDisplayManager::setAsDisplay(QWidget* pDisplayWidget)
} }
void UBDisplayManager::setAsPreviousDisplays(QList<UBBoardView*> pPreviousViews) void UBDisplayManager::setPreviousDisplaysWidgets(QList<UBBoardView*> pPreviousViews)
{ {
mPreviousDisplayWidgets = pPreviousViews; mPreviousDisplayWidgets = pPreviousViews;
} }
@ -182,7 +171,7 @@ QRect UBDisplayManager::displayGeometry()
return mDesktop->screenGeometry(mDisplayScreenIndex); return mDesktop->screenGeometry(mDisplayScreenIndex);
} }
void UBDisplayManager::swapScreens(bool swap) void UBDisplayManager::reinitScreens(bool swap)
{ {
Q_UNUSED(swap); Q_UNUSED(swap);
adjustScreens(-1); adjustScreens(-1);
@ -310,6 +299,5 @@ void UBDisplayManager::setRoleToScreen(DisplayRole role, int screenIndex)
void UBDisplayManager::setUseMultiScreen(bool pUse) void UBDisplayManager::setUseMultiScreen(bool pUse)
{ {
mUseMultiScreen = pUse; mUseMultiScreen = pUse;
adjustScreens(0);
} }

@ -33,13 +33,13 @@ class UBDisplayManager : public QObject
int numPreviousViews(); int numPreviousViews();
void setAsControl(QWidget* pControlWidget, bool init = false); void setControlWidget(QWidget* pControlWidget);
void setAsDisplay(QWidget* pDisplayWidget); void setDisplayWidget(QWidget* pDisplayWidget);
void setAsDesktop(QWidget* pControlWidget); void setDesktopWidget(QWidget* pControlWidget);
void setAsPreviousDisplays(QList<UBBoardView*> pPreviousViews); void setPreviousDisplaysWidgets(QList<UBBoardView*> pPreviousViews);
bool hasControl() bool hasControl()
{ {
@ -77,7 +77,7 @@ class UBDisplayManager : public QObject
public slots: public slots:
void swapScreens(bool bswap); void reinitScreens(bool bswap);
void adjustScreens(int screen); void adjustScreens(int screen);

@ -21,6 +21,7 @@
#include "adaptors/UBExportFullPDF.h" #include "adaptors/UBExportFullPDF.h"
#include "adaptors/UBExportDocument.h" #include "adaptors/UBExportDocument.h"
#include "adaptors/UBExportWeb.h" #include "adaptors/UBExportWeb.h"
#include "adaptors/UBExportCFF.h"
#include "adaptors/UBWebPublisher.h" #include "adaptors/UBWebPublisher.h"
#include "adaptors/UBImportDocument.h" #include "adaptors/UBImportDocument.h"
#include "adaptors/UBImportPDF.h" #include "adaptors/UBImportPDF.h"
@ -62,6 +63,8 @@ UBDocumentManager::UBDocumentManager(QObject *parent)
QString dummyObjects = tr("objects"); QString dummyObjects = tr("objects");
QString dummyWidgets = tr("widgets"); QString dummyWidgets = tr("widgets");
UBExportCFF* cffExporter = new UBExportCFF(this);
mExportAdaptors.append(cffExporter);
UBExportFullPDF* exportFullPdf = new UBExportFullPDF(this); UBExportFullPDF* exportFullPdf = new UBExportFullPDF(this);
mExportAdaptors.append(exportFullPdf); mExportAdaptors.append(exportFullPdf);
UBExportDocument* exportDocument = new UBExportDocument(this); UBExportDocument* exportDocument = new UBExportDocument(this);

@ -118,7 +118,7 @@ void UBPreferencesController::wire()
connect(mPreferencesUI->useExternalBrowserCheckBox, SIGNAL(clicked(bool)), settings->webUseExternalBrowser, SLOT(setBool(bool))); connect(mPreferencesUI->useExternalBrowserCheckBox, SIGNAL(clicked(bool)), settings->webUseExternalBrowser, SLOT(setBool(bool)));
connect(mPreferencesUI->displayBrowserPageCheckBox, SIGNAL(clicked(bool)), settings->webShowPageImmediatelyOnMirroredScreen, SLOT(setBool(bool))); connect(mPreferencesUI->displayBrowserPageCheckBox, SIGNAL(clicked(bool)), settings->webShowPageImmediatelyOnMirroredScreen, SLOT(setBool(bool)));
connect(mPreferencesUI->swapControlAndDisplayScreensCheckBox, SIGNAL(clicked(bool)), settings->swapControlAndDisplayScreens, SLOT(setBool(bool))); connect(mPreferencesUI->swapControlAndDisplayScreensCheckBox, SIGNAL(clicked(bool)), settings->swapControlAndDisplayScreens, SLOT(setBool(bool)));
connect(mPreferencesUI->swapControlAndDisplayScreensCheckBox, SIGNAL(clicked(bool)), UBApplication::applicationController->displayManager(), SLOT(swapScreens(bool))); connect(mPreferencesUI->swapControlAndDisplayScreensCheckBox, SIGNAL(clicked(bool)), UBApplication::applicationController->displayManager(), SLOT(reinitScreens(bool)));
connect(mPreferencesUI->toolbarAtTopRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool))); connect(mPreferencesUI->toolbarAtTopRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool)));
connect(mPreferencesUI->toolbarAtBottomRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool))); connect(mPreferencesUI->toolbarAtBottomRadioButton, SIGNAL(clicked(bool)), this, SLOT(toolbarPositionChanged(bool)));

@ -88,6 +88,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingScene = new UBGraphicsScene(0); mTransparentDrawingScene = new UBGraphicsScene(0);
mTransparentDrawingView->setScene(mTransparentDrawingScene); mTransparentDrawingView->setScene(mTransparentDrawingScene);
mTransparentDrawingScene->setDrawingMode(true);
// mRightPalette = UBApplication::boardController->paletteManager()->createDesktopRightPalette(mTransparentDrawingView); // mRightPalette = UBApplication::boardController->paletteManager()->createDesktopRightPalette(mTransparentDrawingView);
//mRightPalette = new UBRightPalette(mTransparentDrawingView); //mRightPalette = new UBRightPalette(mTransparentDrawingView);

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

@ -73,29 +73,33 @@ void UBGraphicsItemDelegate::init()
{ {
mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio); mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio);
mFrame->hide(); mFrame->hide();
// mFrame->setZValue(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)
{ {
button->hide(); button->hide();
// button->setZValue(UBGraphicsScene::toolLayerStart + 2);
UBGraphicsItem::assignZValue(button, UBGraphicsScene::toolLayerStart + 2);
button->setFlag(QGraphicsItem::ItemIsSelectable, true); button->setFlag(QGraphicsItem::ItemIsSelectable, true);
} }
} }
@ -160,18 +164,9 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (!mDelegated->isSelected()) if (!mDelegated->isSelected())
{ {
mDelegated->setSelected(true); mDelegated->setSelected(true);
UBGraphicsScene* scene = static_cast<UBGraphicsScene*>(mDelegated->scene());
qDebug() << mDelegated->zValue(); qDebug() << mDelegated->zValue();
qDebug() << scene->currentObjectZIndex();
// To investigate. Z value behavior
// if (mDelegated->zValue() < scene->currentObjectZIndex() && !isLocked())
// mDelegated->setZValue(scene->getNextObjectZIndex());
positionHandles(); positionHandles();
return true; return true;
} }
else else
@ -239,12 +234,13 @@ void UBGraphicsItemDelegate::positionHandles()
mDeleteButton->setTransform(tr); mDeleteButton->setTransform(tr);
qreal topX = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2;
qreal topY = mFrame->rect().top() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2;
// This is where the position of the buttons is calculated. It starts always on the topleft of mFrame! qreal bottomX = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2;
qreal x = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2; qreal bottomY = mFrame->rect().bottom() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2;
qreal y = mFrame->rect().top() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2;
mDeleteButton->setPos(x, y); mDeleteButton->setPos(topX, topY);
if (!mDeleteButton->scene()) if (!mDeleteButton->scene())
{ {
@ -262,13 +258,19 @@ 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())
{ {
@ -278,11 +280,10 @@ void UBGraphicsItemDelegate::positionHandles()
} }
if(!mFrame->isResizing()){ if(!mFrame->isResizing()){
button->show(); button->show();
button->setZValue(delegated()->zValue());
} }
} }
} } else {
else
{
foreach(DelegateButton* button, mButtons) foreach(DelegateButton* button, mButtons)
button->hide(); button->hide();
@ -325,7 +326,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::TopLeftSection)
: 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);
@ -147,6 +153,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);
@ -154,10 +163,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;
@ -176,6 +190,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();
} }
@ -84,8 +85,6 @@ UBItem* UBGraphicsPDFItem::deepCopy() const
UBGraphicsPDFItem *copy = new UBGraphicsPDFItem(mRenderer, mPageNumber, parentItem()); UBGraphicsPDFItem *copy = new UBGraphicsPDFItem(mRenderer, mPageNumber, parentItem());
copy->setPos(this->pos()); copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -135,8 +134,6 @@ UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const
pixmapItem->setPixmap(pixmap); pixmapItem->setPixmap(pixmap);
pixmapItem->setPos(this->pos()); pixmapItem->setPos(this->pos());
// pixmapItem->setZValue(this->zValue());
UBGraphicsItem::assignZValue(pixmapItem, this->zValue());
pixmapItem->setTransform(this->transform()); pixmapItem->setTransform(this->transform());
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -37,6 +37,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);
} }
@ -102,8 +103,6 @@ UBItem* UBGraphicsPixmapItem::deepCopy() const
copy->setPixmap(this->pixmap()); copy->setPixmap(this->pixmap());
copy->setPos(this->pos()); copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, 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()
@ -153,9 +161,6 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
copy->setPen(this->pen()); copy->setPen(this->pen());
copy->mHasAlpha = this->mHasAlpha; copy->mHasAlpha = this->mHasAlpha;
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setColorOnDarkBackground(this->colorOnDarkBackground()); copy->setColorOnDarkBackground(this->colorOnDarkBackground());
copy->setColorOnLightBackground(this->colorOnLightBackground()); copy->setColorOnLightBackground(this->colorOnLightBackground());

@ -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;

@ -61,8 +61,6 @@
#include "core/memcheck.h" #include "core/memcheck.h"
qreal UBGraphicsScene::backgroundLayerStart = -20000000.0;
qreal UBGraphicsScene::objectLayerStart = -10000000.0;
qreal UBGraphicsScene::drawingLayerStart = 0.0; qreal UBGraphicsScene::drawingLayerStart = 0.0;
qreal UBGraphicsScene::toolLayerStart = 10000000.0; qreal UBGraphicsScene::toolLayerStart = 10000000.0;
@ -77,6 +75,47 @@ 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::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)
{
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 over for the scope" << key;
result = top - 1;
}
scopeMap[key].curValue = result;
return result;
}
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
: UBCoreGraphicsScene(parent) : UBCoreGraphicsScene(parent)
, mEraser(0) , mEraser(0)
@ -96,6 +135,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, enableUndoRedoStack(true) , enableUndoRedoStack(true)
, magniferControlViewWidget(0) , magniferControlViewWidget(0)
, magniferDisplayViewWidget(0) , magniferDisplayViewWidget(0)
, mIsDesktopMode(false)
{ {
@ -106,32 +146,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
#endif #endif
setDocument(parent); setDocument(parent);
createEraiser();
mDrawingZIndex = drawingLayerStart; createPointer();
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));
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);
if (UBApplication::applicationController) if (UBApplication::applicationController)
{ {
@ -145,8 +161,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
UBGraphicsScene::~UBGraphicsScene() UBGraphicsScene::~UBGraphicsScene()
{ {
DisposeMagnifierQWidgets();
if (mCurrentStroke) if (mCurrentStroke)
if (mCurrentStroke->polygons().empty()) if (mCurrentStroke->polygons().empty())
delete mCurrentStroke; delete mCurrentStroke;
@ -155,27 +169,18 @@ 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.;
for( int i = 0; i < allItemsList.size(); i++ ) { for( int i = 0; i < allItemsList.size(); i++ ) {
QGraphicsItem *nextItem = allItemsList.at(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->isSelected()) {
if (nextItem == mBackgroundObject) nextItem->setZValue(mZLayerController.generateZLevel(itemLayerType::SelectedItem));
continue; } else {
//Temporary stub end (sankore 360) nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal());
if (nextItem->zValue() > maxZ) }
maxZ = nextItem->zValue();
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);
} }
} }
@ -404,25 +409,11 @@ void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw)
qreal eraserRadius = eraserWidth / 2; qreal eraserRadius = eraserWidth / 2;
// TODO UB 4.x optimize - no need to do that every time we move it // 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)); mEraser->setRect(QRectF(pPoint.x() - eraserRadius, pPoint.y() - eraserRadius, eraserWidth, eraserWidth));
if(isFirstDraw) if(isFirstDraw) {
{ mEraser->show();
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);
mEraser->show();
} }
} }
} }
@ -433,27 +424,12 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw)
qreal pointerRadius = pointerDiameter / 2; qreal pointerRadius = pointerDiameter / 2;
// TODO UB 4.x optimize - no need to do that every time we move it // 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, mPointer->setRect(QRectF(pPoint.x() - pointerRadius,
pPoint.y() - pointerRadius, pPoint.y() - pointerRadius,
pointerDiameter, pointerDiameter,
pointerDiameter)); pointerDiameter));
if(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();
if (zValue > maxZ)
maxZ = zValue;
nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal());
}
mPointer->setZValue(maxZ + 0.0001);
mPointer->show(); mPointer->show();
} }
} }
@ -690,21 +666,6 @@ void UBGraphicsScene::drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle)
setDocumentUpdated(); 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) void UBGraphicsScene::setBackground(bool pIsDark, bool pIsCrossed)
{ {
bool needRepaint = false; bool needRepaint = false;
@ -749,6 +710,15 @@ void UBGraphicsScene::setBackground(bool pIsDark, bool pIsCrossed)
} }
} }
void UBGraphicsScene::setBackgroundZoomFactor(qreal zoom)
{
mZoomFactor = zoom;
}
void UBGraphicsScene::setDrawingMode(bool bModeDesktop)
{
mIsDesktopMode = bModeDesktop;
}
void UBGraphicsScene::recolorAllItems() void UBGraphicsScene::recolorAllItems()
{ {
@ -827,9 +797,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());
} }
@ -870,9 +837,6 @@ UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
UBGraphicsScene* copy = new UBGraphicsScene(this->document()); UBGraphicsScene* copy = new UBGraphicsScene(this->document());
copy->setBackground(this->isDarkBackground(), this->isCrossedBackground()); copy->setBackground(this->isDarkBackground(), this->isCrossedBackground());
copy->mDrawingZIndex = this->mDrawingZIndex;
copy->mObjectZIndex = this->mObjectZIndex;
copy->setSceneRect(this->sceneRect()); copy->setSceneRect(this->sceneRect());
if (this->mNominalSize.isValid()) if (this->mNominalSize.isValid())
@ -1050,8 +1014,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());
UBGraphicsItem::assignZValue(pixmapItem, getNextObjectZIndex());
pixmapItem->setPixmap(pPixmap); pixmapItem->setPixmap(pPixmap);
@ -1103,8 +1065,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());
UBGraphicsItem::assignZValue(videoItem, getNextObjectZIndex());
addItem(videoItem); addItem(videoItem);
@ -1136,8 +1096,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());
UBGraphicsItem::assignZValue(audioItem, getNextObjectZIndex());
addItem(audioItem); addItem(audioItem);
@ -1204,8 +1162,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 +1223,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 +1257,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 +1313,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 +1338,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 +1350,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();
@ -1460,8 +1414,7 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool
item->setAcceptedMouseButtons(Qt::NoButton); item->setAcceptedMouseButtons(Qt::NoButton);
item->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::FixedBackground); item->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::FixedBackground);
// item->setZValue(backgroundLayerStart); UBGraphicsItem::assignZValue(item, mZLayerController.generateZLevel(itemLayerType::BackgroundItem));
UBGraphicsItem::assignZValue(item, backgroundLayerStart);
if (pAdaptTransformation) if (pAdaptTransformation)
{ {
@ -1565,9 +1518,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 +1534,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 +1552,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 +1682,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 +1713,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);
@ -1923,6 +1862,58 @@ void UBGraphicsScene::drawItems (QPainter * painter, int numItems,
} }
} }
void UBGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
{
if (mIsDesktopMode)
{
QGraphicsScene::drawBackground (painter, rect);
return;
}
bool darkBackground = isDarkBackground ();
if (darkBackground)
{
painter->fillRect (rect, QBrush (QColor (Qt::black)));
}
else
{
painter->fillRect (rect, QBrush (QColor (Qt::white)));
}
if (mZoomFactor > 0.5)
{
QColor bgCrossColor;
if (darkBackground)
bgCrossColor = UBSettings::crossDarkBackground;
else
bgCrossColor = UBSettings::crossLightBackground;
if (mZoomFactor < 1.0)
{
int alpha = 255 * mZoomFactor / 2;
bgCrossColor.setAlpha (alpha); // fade the crossing on small zooms
}
painter->setPen (bgCrossColor);
if (isCrossedBackground())
{
qreal firstY = ((int) (rect.y () / UBSettings::crossSize)) * UBSettings::crossSize;
for (qreal yPos = firstY; yPos < rect.y () + rect.height (); yPos += UBSettings::crossSize)
{
painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
}
qreal firstX = ((int) (rect.x () / UBSettings::crossSize)) * UBSettings::crossSize;
for (qreal xPos = firstX; xPos < rect.x () + rect.width (); xPos += UBSettings::crossSize)
{
painter->drawLine (xPos, rect.y (), xPos, rect.y () + rect.height ());
}
}
}
}
void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent) void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent)
{ {
@ -1991,7 +1982,46 @@ void UBGraphicsScene::setDocumentUpdated()
document()->setMetaData(UBSettings::documentUpdatedAt document()->setMetaData(UBSettings::documentUpdatedAt
, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); , 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)
{
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;}
@ -152,23 +181,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
return mCrossedBackground; return mCrossedBackground;
} }
void setDrawingZIndex(qreal pDrawingZIndex)
{
mDrawingZIndex = pDrawingZIndex;
}
void setObjectZIndex(qreal pObjectZIndex)
{
mObjectZIndex = pObjectZIndex;
}
bool hasBackground() bool hasBackground()
{ {
return (mBackgroundObject != 0); return (mBackgroundObject != 0);
} }
qreal getNextObjectZIndex();
void addRuler(QPointF center); void addRuler(QPointF center);
void addProtractor(QPointF center); void addProtractor(QPointF center);
void addCompass(QPointF center); void addCompass(QPointF center);
@ -225,11 +242,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void setNominalSize(int pWidth, int pHeight); void setNominalSize(int pWidth, int pHeight);
qreal currentObjectZIndex()
{
return mObjectZIndex;
}
enum RenderingContext enum RenderingContext
{ {
Screen = 0, NonScreen, PdfExport, Podcast Screen = 0, NonScreen, PdfExport, Podcast
@ -276,7 +288,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void hideEraser(); void hideEraser();
void setBackground(bool pIsDark, bool pIsCrossed); void setBackground(bool pIsDark, bool pIsCrossed);
void setBackgroundZoomFactor(qreal zoom);
void setDrawingMode(bool bModeDesktop);
void deselectAllItems(); void deselectAllItems();
UBGraphicsPixmapItem* addPixmap(const QPixmap& pPixmap, const QPointF& pPos = QPointF(0,0), qreal scaleFactor = 1.0, bool pUseAnimation = false); UBGraphicsPixmapItem* addPixmap(const QPixmap& pPixmap, const QPointF& pPos = QPointF(0,0), qreal scaleFactor = 1.0, bool pUseAnimation = false);
@ -314,18 +327,19 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void recolorAllItems(); void recolorAllItems();
qreal getNextDrawingZIndex(); virtual void drawItems (QPainter * painter, int numItems,
virtual void drawItems (QPainter * painter, int numItems,
QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget = 0); QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget = 0);
QGraphicsItem* rootItem(QGraphicsItem* item) const; QGraphicsItem* rootItem(QGraphicsItem* item) const;
virtual void drawBackground(QPainter *painter, const QRectF &rect);
private: private:
void setDocumentUpdated(); void setDocumentUpdated();
void createEraiser();
void createPointer();
qreal mDrawingZIndex; qreal generateZLevel(QGraphicsItem *item);
qreal mObjectZIndex;
QGraphicsEllipseItem* mEraser; QGraphicsEllipseItem* mEraser;
QGraphicsEllipseItem* mPointer; QGraphicsEllipseItem* mPointer;
@ -337,6 +351,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
bool mDarkBackground; bool mDarkBackground;
bool mCrossedBackground; bool mCrossedBackground;
bool mIsDesktopMode;
qreal mZoomFactor;
bool mIsModified; bool mIsModified;
@ -376,7 +392,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)
{ {
@ -61,6 +60,8 @@ void UBGraphicsSvgItem::init()
setCacheMode(QGraphicsItem::DeviceCoordinateCache); setCacheMode(QGraphicsItem::DeviceCoordinateCache);
setMaximumCacheSize(boundingRect().size().toSize() * UB_MAX_ZOOM); 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
} }
@ -132,8 +133,6 @@ UBItem* UBGraphicsSvgItem::deepCopy() const
UBGraphicsSvgItem* copy = new UBGraphicsSvgItem(this->fileData()); UBGraphicsSvgItem* copy = new UBGraphicsSvgItem(this->fileData());
copy->setPos(this->pos()); copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -187,8 +186,6 @@ UBGraphicsPixmapItem* UBGraphicsSvgItem::toPixmapItem() const
pixmapItem->setPixmap(QPixmap::fromImage(image)); pixmapItem->setPixmap(QPixmap::fromImage(image));
pixmapItem->setPos(this->pos()); pixmapItem->setPos(this->pos());
// pixmapItem->setZValue(this->zValue());
UBGraphicsItem::assignZValue(pixmapItem, this->zValue());
pixmapItem->setTransform(this->transform()); pixmapItem->setTransform(this->transform());
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true);
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true); pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -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);
@ -205,8 +193,6 @@ UBItem* UBGraphicsTextItem::deepCopy() const
copy->setHtml(toHtml()); copy->setHtml(toHtml());
copy->setPos(this->pos()); copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, 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)));
} }
@ -68,8 +70,6 @@ UBItem* UBGraphicsVideoItem::deepCopy() const
UBGraphicsVideoItem *copy = new UBGraphicsVideoItem(videoUrl, parentItem()); UBGraphicsVideoItem *copy = new UBGraphicsVideoItem(videoUrl, parentItem());
copy->setPos(this->pos()); copy->setPos(this->pos());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true); copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true); copy->setFlag(QGraphicsItem::ItemIsSelectable, true);

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

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

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

@ -19,6 +19,7 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "board/UBBoardView.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -27,7 +28,6 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
: QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint)) : QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint))
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
, mShouldResizeWidget(false) , mShouldResizeWidget(false)
, inTimer(false)
, borderPen(Qt::darkGray) , borderPen(Qt::darkGray)
, gView(0) , gView(0)
, mView(0) , mView(0)
@ -70,16 +70,11 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
#endif #endif
} }
connect(&mRefreshTimer, SIGNAL(timeout()), this, SLOT(slot_refresh()));
} }
UBMagnifier::~UBMagnifier() UBMagnifier::~UBMagnifier()
{ {
if (timerUpdate != 0)
{
killTimer(timerUpdate);
timerUpdate = 0;
}
if(sClosePixmap) if(sClosePixmap)
{ {
delete sClosePixmap; delete sClosePixmap;
@ -285,50 +280,55 @@ void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
} }
void UBMagnifier::timerEvent(QTimerEvent *e) void UBMagnifier::slot_refresh()
{ {
if(inTimer) return; if(!(updPointGrab.isNull()))
if (e->timerId() == timerUpdate) grabPoint(updPointGrab);
{
inTimer = true;
if(!(updPointGrab.isNull()))
grabPoint(updPointGrab);
if(isCusrsorAlreadyStored) if(isCusrsorAlreadyStored)
{
QPoint globalCursorPos = QCursor::pos();
QPoint cursorPos = mapFromGlobal(globalCursorPos);
if (cursorPos.x() < size().width() - mResizeItem->width() - 20 ||
cursorPos.x() > size().width() - 20 ||
cursorPos.y() < size().height() - mResizeItem->height() - 20 ||
cursorPos.y() > size().height() - - 20
)
{ {
QPoint globalCursorPos = QCursor::pos(); isCusrsorAlreadyStored = false;
QPoint cursorPos = mapFromGlobal(globalCursorPos); setCursor(mOldCursor);
if (cursorPos.x() < size().width() - mResizeItem->width() - 20 ||
cursorPos.x() > size().width() - 20 ||
cursorPos.y() < size().height() - mResizeItem->height() - 20 ||
cursorPos.y() > size().height() - - 20
)
{
isCusrsorAlreadyStored = false;
setCursor(mOldCursor);
}
} }
inTimer = false;
} }
} }
void UBMagnifier::grabPoint() void UBMagnifier::grabPoint()
{ {
QMatrix transM = UBApplication::boardController->controlView()->matrix();
QPointF itemPos = gView->mapFromGlobal(updPointGrab); QPointF itemPos = gView->mapFromGlobal(updPointGrab);
qreal zWidth = size().width() / params.zoom; qreal zWidth = width() / (params.zoom * transM.m11());
qreal zWidthHalf = zWidth / 2; qreal zWidthHalf = zWidth / 2;
qreal zHeight = size().height() / params.zoom; qreal zHeight = height() / (params.zoom * transM.m22());
qreal zHeightHalf = zHeight / 2; qreal zHeightHalf = zHeight / 2;
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight)); QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y())));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
QRect magnifierRect = rect();
float x = pfScLtF.x() - zWidthHalf;
float y = pfScLtF.y() - zHeightHalf;
QPointF leftTop(x,y);
QPointF rightBottom(x + zWidth, y + zHeight);
QRectF srcRect(leftTop, rightBottom);
QPixmap newPixMap(QSize(width(), height()));
QPainter painter(&newPixMap);
UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect);
painter.end();
pMap.fill(Qt::transparent); pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height())); pMap = newPixMap.scaled(QSize(width(), height()));
@ -339,28 +339,43 @@ void UBMagnifier::grabPoint()
void UBMagnifier::grabPoint(const QPoint &pGrab) void UBMagnifier::grabPoint(const QPoint &pGrab)
{ {
QMatrix transM = UBApplication::boardController->controlView()->matrix();
updPointGrab = pGrab; updPointGrab = pGrab;
QPointF itemPos = gView->mapFromGlobal(pGrab); QPointF itemPos = gView->mapFromGlobal(pGrab);
qreal zWidth = size().width() / params.zoom; qreal zWidth = width() / (params.zoom * transM.m11());
qreal zWidthHalf = zWidth / 2; qreal zWidthHalf = zWidth / 2;
qreal zHeight = size().height() / params.zoom; qreal zHeight = height() / (params.zoom * transM.m22());
qreal zHeightHalf = zHeight / 2; qreal zHeightHalf = zHeight / 2;
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight)); QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y())));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height())); QRect magnifierRect = rect();
float x = pfScLtF.x() - zWidthHalf;
float y = pfScLtF.y() - zHeightHalf;
QPointF leftTop(x,y);
QPointF rightBottom(x + zWidth, y + zHeight);
QRectF srcRect(leftTop, rightBottom);
QPixmap newPixMap(QSize(width(), height()));
QPainter painter(&newPixMap);
UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect);
painter.end();
// pMap.fill(Qt::transparent);
pMap = newPixMap;
pMap.setMask(bmpMask); pMap.setMask(bmpMask);
update(); update();
} }
// from global // from global
void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove) void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove)
{ {
@ -380,9 +395,8 @@ void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needG
void UBMagnifier::setGrabView(QWidget *view) void UBMagnifier::setGrabView(QWidget *view)
{ {
if (timerUpdate != 0)
killTimer(timerUpdate);
gView = view; gView = view;
timerUpdate = startTimer(200); mRefreshTimer.setInterval(40);
mRefreshTimer.start();
} }

@ -54,9 +54,11 @@ signals:
void magnifierZoomOut_Signal(); void magnifierZoomOut_Signal();
void magnifierResized_Signal(qreal newPercentSize); void magnifierResized_Signal(qreal newPercentSize);
public slots:
void slot_refresh();
protected: protected:
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void timerEvent(QTimerEvent *);
virtual void mousePressEvent ( QMouseEvent * event ); virtual void mousePressEvent ( QMouseEvent * event );
virtual void mouseMoveEvent ( QMouseEvent * event ); virtual void mouseMoveEvent ( QMouseEvent * event );
@ -78,10 +80,9 @@ protected:
QCursor mResizeCursor; QCursor mResizeCursor;
private: private:
bool inTimer; QTimer mRefreshTimer;
bool m_isInteractive; bool m_isInteractive;
int timerUpdate;
QPoint updPointGrab; QPoint updPointGrab;
QPoint updPointMove; QPoint updPointMove;

@ -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
@ -49,8 +47,6 @@ UBItem* UBGraphicsCache::deepCopy() const
copy->setPos(this->pos()); copy->setPos(this->pos());
copy->setRect(this->rect()); copy->setRect(this->rect());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?
@ -92,8 +88,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()));
} }
@ -85,8 +87,6 @@ UBItem* UBGraphicsCompass::deepCopy() const
copy->setPos(this->pos()); copy->setPos(this->pos());
copy->setRect(this->rect()); copy->setRect(this->rect());
// copy->setZValue(this->zValue());
UBGraphicsItem::assignZValue(copy, this->zValue());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?

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

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

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

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

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

Loading…
Cancel
Save