|
|
@ -75,6 +75,8 @@ qreal UBGraphicsScene::toolOffsetEraser = 200; |
|
|
|
qreal UBGraphicsScene::toolOffsetCurtain = 1000; |
|
|
|
qreal UBGraphicsScene::toolOffsetCurtain = 1000; |
|
|
|
qreal UBGraphicsScene::toolOffsetPointer = 1100; |
|
|
|
qreal UBGraphicsScene::toolOffsetPointer = 1100; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qreal UBGraphicsScene::toolOffsetCache = 1000;//Didier please define offset you want
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) |
|
|
|
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) |
|
|
|
: UBCoreGraphicsScene(parent) |
|
|
|
: UBCoreGraphicsScene(parent) |
|
|
|
, mEraser(0) |
|
|
|
, mEraser(0) |
|
|
@ -91,8 +93,10 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) |
|
|
|
, mCurrentStroke(0) |
|
|
|
, mCurrentStroke(0) |
|
|
|
, mShouldUseOMP(true) |
|
|
|
, mShouldUseOMP(true) |
|
|
|
, mItemCount(0) |
|
|
|
, mItemCount(0) |
|
|
|
|
|
|
|
, enableUndoRedoStack(true) |
|
|
|
, magniferControlViewWidget(0) |
|
|
|
, magniferControlViewWidget(0) |
|
|
|
, magniferDisplayViewWidget(0) |
|
|
|
, magniferDisplayViewWidget(0) |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
#ifdef __ppc__ |
|
|
|
#ifdef __ppc__ |
|
|
@ -137,6 +141,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); |
|
|
|
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsScene::~UBGraphicsScene() |
|
|
|
UBGraphicsScene::~UBGraphicsScene() |
|
|
@ -150,32 +156,28 @@ 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'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QGraphicsItem *> allItemsList = items(); |
|
|
|
QList<QGraphicsItem *> allItemsList = items(); |
|
|
|
for( int i = 0; i < allItemsList.size(); i++ ) |
|
|
|
qreal maxZ = 0.; |
|
|
|
{ |
|
|
|
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)
|
|
|
|
//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
|
|
|
|
//z-order behavior should be reimplemented and this stub should be deleted
|
|
|
|
if (nextItem == mBackgroundObject) |
|
|
|
if (nextItem == mBackgroundObject) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
//Temporary stub end (sankore 360)
|
|
|
|
//Temporary stub end (sankore 360)
|
|
|
|
// qreal zValue = nextItem->zValue();
|
|
|
|
if (nextItem->zValue() > maxZ) |
|
|
|
nextItem->setZValue(qreal(1)); |
|
|
|
maxZ = nextItem->zValue(); |
|
|
|
// qDebug() << QString(" %1 ").arg(i) << QString(" %1 ").arg(zValue);
|
|
|
|
nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); |
|
|
|
|
|
|
|
// nextItem->setZValue(qreal(1));
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QList<QGraphicsItem *> selItemsList = selectedItems(); |
|
|
|
QList<QGraphicsItem *> selItemsList = selectedItems(); |
|
|
|
for( int i = 0; i < selItemsList.size(); i++ ) |
|
|
|
for( int i = 0; i < selItemsList.size(); i++ ) { |
|
|
|
{ |
|
|
|
|
|
|
|
QGraphicsItem *nextItem = selItemsList.at(i); |
|
|
|
QGraphicsItem *nextItem = selItemsList.at(i); |
|
|
|
// qreal zValue = nextItem->zValue();
|
|
|
|
nextItem->setZValue(maxZ + 0.0001); |
|
|
|
nextItem->setZValue(2); |
|
|
|
|
|
|
|
// qDebug() << QString(" >>> %1 <<< ").arg(i) << QString(" >>> %1 <<< ").arg(zValue);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -373,10 +375,13 @@ bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
|
|
|
|
|
|
|
|
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0) |
|
|
|
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(UBApplication::undoStack) |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(udcmd); |
|
|
|
UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(UBApplication::undoStack) |
|
|
|
|
|
|
|
UBApplication::undoStack->push(udcmd); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mRemovedItems.clear(); |
|
|
|
mRemovedItems.clear(); |
|
|
|
mAddedItems.clear(); |
|
|
|
mAddedItems.clear(); |
|
|
@ -407,23 +412,23 @@ void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw) |
|
|
|
|
|
|
|
|
|
|
|
if(isFirstDraw) |
|
|
|
if(isFirstDraw) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
qreal maxZ = 0.; |
|
|
|
QList<QGraphicsItem *> allItemsList = items(); |
|
|
|
QList<QGraphicsItem *> allItemsList = items(); |
|
|
|
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); |
|
|
|
qreal zValue = nextItem->zValue(); |
|
|
|
qreal zValue = nextItem->zValue(); |
|
|
|
nextItem->setZValue(qreal(1)); |
|
|
|
if (zValue > maxZ) |
|
|
|
qDebug() << QString(" %1 ").arg(i) << QString(" %1 ").arg(zValue); |
|
|
|
maxZ = zValue; |
|
|
|
|
|
|
|
nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mEraser->setZValue(2); |
|
|
|
mEraser->setZValue(maxZ + 0.0001); |
|
|
|
mEraser->show(); |
|
|
|
mEraser->show(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw) |
|
|
|
void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qreal pointerDiameter = UBSettings::pointerDiameter / UBApplication::boardController->currentZoom(); |
|
|
|
qreal pointerDiameter = UBSettings::pointerDiameter / UBApplication::boardController->currentZoom(); |
|
|
@ -439,19 +444,20 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw) |
|
|
|
|
|
|
|
|
|
|
|
if(isFirstDraw) |
|
|
|
if(isFirstDraw) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
qreal maxZ = 0.; |
|
|
|
QList<QGraphicsItem *> allItemsList = items(); |
|
|
|
QList<QGraphicsItem *> allItemsList = items(); |
|
|
|
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); |
|
|
|
qreal zValue = nextItem->zValue(); |
|
|
|
qreal zValue = nextItem->zValue(); |
|
|
|
nextItem->setZValue(qreal(1)); |
|
|
|
if (zValue > maxZ) |
|
|
|
qDebug() << QString(" %1 ").arg(i) << QString(" %1 ").arg(zValue); |
|
|
|
maxZ = zValue; |
|
|
|
|
|
|
|
nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mPointer->setZValue(2); |
|
|
|
mPointer->setZValue(maxZ + 0.0001); |
|
|
|
mPointer->show(); |
|
|
|
mPointer->show(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -824,8 +830,8 @@ void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem) |
|
|
|
|
|
|
|
|
|
|
|
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); |
|
|
|
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); |
|
|
|
|
|
|
|
|
|
|
|
polygonItem->setZValue(getNextDrawingZIndex()); |
|
|
|
// polygonItem->setZValue(getNextDrawingZIndex());
|
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(polygonItem, getNextDrawingZIndex()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -962,8 +968,11 @@ void UBGraphicsScene::clearItemsAndAnnotations() |
|
|
|
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
|
|
|
|
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
|
|
|
|
update(sceneRect()); |
|
|
|
update(sceneRect()); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -996,8 +1005,12 @@ void UBGraphicsScene::clearItems() |
|
|
|
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
|
|
|
|
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
|
|
|
|
update(sceneRect()); |
|
|
|
update(sceneRect()); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1023,8 +1036,12 @@ void UBGraphicsScene::clearAnnotations() |
|
|
|
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
|
|
|
|
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
|
|
|
|
update(sceneRect()); |
|
|
|
update(sceneRect()); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1035,7 +1052,8 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const Q |
|
|
|
|
|
|
|
|
|
|
|
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true); |
|
|
|
pixmapItem->setFlag(QGraphicsItem::ItemIsMovable, true); |
|
|
|
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
pixmapItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
pixmapItem->setZValue(getNextObjectZIndex()); |
|
|
|
// pixmapItem->setZValue(getNextObjectZIndex());
|
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(pixmapItem, getNextObjectZIndex()); |
|
|
|
|
|
|
|
|
|
|
|
pixmapItem->setPixmap(pPixmap); |
|
|
|
pixmapItem->setPixmap(pPixmap); |
|
|
|
|
|
|
|
|
|
|
@ -1044,8 +1062,10 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const Q |
|
|
|
|
|
|
|
|
|
|
|
addItem(pixmapItem); |
|
|
|
addItem(pixmapItem); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, pixmapItem); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, pixmapItem); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pixmapItem->scale(pScaleFactor, pScaleFactor); |
|
|
|
pixmapItem->scale(pScaleFactor, pScaleFactor); |
|
|
|
|
|
|
|
|
|
|
@ -1070,8 +1090,10 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const Q |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) |
|
|
|
void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsTextItemUndoCommand* uc = new UBGraphicsTextItemUndoCommand(textItem); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
UBGraphicsTextItemUndoCommand* uc = new UBGraphicsTextItemUndoCommand(textItem); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1083,14 +1105,17 @@ UBGraphicsVideoItem* UBGraphicsScene::addVideo(const QUrl& pVideoFileUrl, bool s |
|
|
|
|
|
|
|
|
|
|
|
videoItem->setFlag(QGraphicsItem::ItemIsMovable, true); |
|
|
|
videoItem->setFlag(QGraphicsItem::ItemIsMovable, true); |
|
|
|
videoItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
videoItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
videoItem->setZValue(getNextObjectZIndex()); |
|
|
|
// videoItem->setZValue(getNextObjectZIndex());
|
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(videoItem, getNextObjectZIndex()); |
|
|
|
|
|
|
|
|
|
|
|
addItem(videoItem); |
|
|
|
addItem(videoItem); |
|
|
|
|
|
|
|
|
|
|
|
videoItem->show(); |
|
|
|
videoItem->show(); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, videoItem); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, videoItem); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
videoItem->mediaObject()->play(); |
|
|
|
videoItem->mediaObject()->play(); |
|
|
|
|
|
|
|
|
|
|
@ -1113,14 +1138,17 @@ UBGraphicsAudioItem* UBGraphicsScene::addAudio(const QUrl& pAudioFileUrl, bool s |
|
|
|
|
|
|
|
|
|
|
|
audioItem->setFlag(QGraphicsItem::ItemIsMovable, true); |
|
|
|
audioItem->setFlag(QGraphicsItem::ItemIsMovable, true); |
|
|
|
audioItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
audioItem->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
audioItem->setZValue(getNextObjectZIndex()); |
|
|
|
// audioItem->setZValue(getNextObjectZIndex());
|
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(audioItem, getNextObjectZIndex()); |
|
|
|
|
|
|
|
|
|
|
|
addItem(audioItem); |
|
|
|
addItem(audioItem); |
|
|
|
|
|
|
|
|
|
|
|
audioItem->show(); |
|
|
|
audioItem->show(); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, audioItem); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, audioItem); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
audioItem->mediaObject()->play(); |
|
|
|
audioItem->mediaObject()->play(); |
|
|
|
|
|
|
|
|
|
|
@ -1178,7 +1206,8 @@ 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()); |
|
|
|
// graphicsWidget->setZValue(getNextObjectZIndex());
|
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(graphicsWidget, getNextObjectZIndex()); |
|
|
|
|
|
|
|
|
|
|
|
addItem(graphicsWidget); |
|
|
|
addItem(graphicsWidget); |
|
|
|
|
|
|
|
|
|
|
@ -1194,8 +1223,10 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co |
|
|
|
// graphicsWidget->widgetWebView()->loadMainHtml();
|
|
|
|
// graphicsWidget->widgetWebView()->loadMainHtml();
|
|
|
|
|
|
|
|
|
|
|
|
graphicsWidget->setSelected(true); |
|
|
|
graphicsWidget->setSelected(true); |
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
} |
|
|
|
} |
|
|
@ -1238,7 +1269,8 @@ 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()); |
|
|
|
// 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); |
|
|
@ -1249,8 +1281,10 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint |
|
|
|
|
|
|
|
|
|
|
|
addItem(svgItem); |
|
|
|
addItem(svgItem); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, svgItem); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, svgItem); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
|
|
|
|
|
|
|
@ -1271,7 +1305,8 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); |
|
|
|
UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); |
|
|
|
textItem->setPlainText(pString); |
|
|
|
textItem->setPlainText(pString); |
|
|
|
textItem->setZValue(getNextObjectZIndex()); |
|
|
|
// textItem->setZValue(getNextObjectZIndex());
|
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(textItem, getNextObjectZIndex()); |
|
|
|
|
|
|
|
|
|
|
|
QFont font = textItem->font(); |
|
|
|
QFont font = textItem->font(); |
|
|
|
|
|
|
|
|
|
|
@ -1309,8 +1344,10 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con |
|
|
|
|
|
|
|
|
|
|
|
textItem->show(); |
|
|
|
textItem->show(); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
connect(textItem, SIGNAL(textUndoCommandAdded(UBGraphicsTextItem *)), this, SLOT(textUndoCommandAdded(UBGraphicsTextItem *))); |
|
|
|
connect(textItem, SIGNAL(textUndoCommandAdded(UBGraphicsTextItem *)), this, SLOT(textUndoCommandAdded(UBGraphicsTextItem *))); |
|
|
|
|
|
|
|
|
|
|
@ -1326,18 +1363,20 @@ 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()); |
|
|
|
// textItem->setZValue(getNextObjectZIndex());
|
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(textItem, getNextObjectZIndex()); |
|
|
|
|
|
|
|
|
|
|
|
addItem(textItem); |
|
|
|
addItem(textItem); |
|
|
|
textItem->show(); |
|
|
|
textItem->show(); |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); |
|
|
|
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
connect(textItem, SIGNAL(textUndoCommandAdded(UBGraphicsTextItem *)), |
|
|
|
connect(textItem, SIGNAL(textUndoCommandAdded(UBGraphicsTextItem *)), |
|
|
|
this, SLOT(textUndoCommandAdded(UBGraphicsTextItem *))); |
|
|
|
this, SLOT(textUndoCommandAdded(UBGraphicsTextItem *))); |
|
|
|
|
|
|
|
|
|
|
|
// textItem->setSelected(true);
|
|
|
|
|
|
|
|
textItem->setFocus(); |
|
|
|
textItem->setFocus(); |
|
|
|
|
|
|
|
|
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
@ -1425,7 +1464,8 @@ 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); |
|
|
|
// item->setZValue(backgroundLayerStart);
|
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(item, backgroundLayerStart); |
|
|
|
|
|
|
|
|
|
|
|
if (pAdaptTransformation) |
|
|
|
if (pAdaptTransformation) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1529,7 +1569,9 @@ 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); |
|
|
|
// 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); |
|
|
@ -1546,7 +1588,9 @@ 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); |
|
|
|
// 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); |
|
|
@ -1565,7 +1609,9 @@ 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); |
|
|
|
// 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); |
|
|
@ -1696,7 +1742,9 @@ 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); |
|
|
|
// 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); |
|
|
@ -1727,7 +1775,10 @@ void UBGraphicsScene::addMask() |
|
|
|
view = (QGraphicsView*)UBApplication::boardController->controlView(); |
|
|
|
view = (QGraphicsView*)UBApplication::boardController->controlView(); |
|
|
|
|
|
|
|
|
|
|
|
QPolygonF polygon = view->mapToScene(view->rect()); |
|
|
|
QPolygonF polygon = view->mapToScene(view->rect()); |
|
|
|
curtain->setZValue(toolLayerStart + toolOffsetCurtain); |
|
|
|
|
|
|
|
|
|
|
|
// curtain->setZValue(toolLayerStart + toolOffsetCurtain);
|
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(curtain, toolLayerStart + toolOffsetCurtain); |
|
|
|
|
|
|
|
|
|
|
|
QRectF rect = polygon.boundingRect(); |
|
|
|
QRectF rect = polygon.boundingRect(); |
|
|
|
qreal xScale = view->matrix().m11(); |
|
|
|
qreal xScale = view->matrix().m11(); |
|
|
|
qreal yScale = view->matrix().m22(); |
|
|
|
qreal yScale = view->matrix().m22(); |
|
|
|