|
|
|
@ -254,7 +254,7 @@ void UBZLayerController::setLayerType(QGraphicsItem *pItem, itemLayerType::Enum |
|
|
|
|
pItem->setData(UBGraphicsItemData::itemLayerType, QVariant(pNewType)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) |
|
|
|
|
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoStack) |
|
|
|
|
: UBCoreGraphicsScene(parent) |
|
|
|
|
, mEraser(0) |
|
|
|
|
, mPointer(0) |
|
|
|
@ -271,7 +271,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) |
|
|
|
|
, mCurrentStroke(0) |
|
|
|
|
, mShouldUseOMP(true) |
|
|
|
|
, mItemCount(0) |
|
|
|
|
, enableUndoRedoStack(true) |
|
|
|
|
, mUndoRedoStackEnabled(enableUndoRedoStack) |
|
|
|
|
, magniferControlViewWidget(0) |
|
|
|
|
, magniferDisplayViewWidget(0) |
|
|
|
|
, mZLayerController(new UBZLayerController(this)) |
|
|
|
@ -558,7 +558,7 @@ bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
|
if (dc->isDrawingTool() || mDrawWithCompass) |
|
|
|
|
{ |
|
|
|
|
if(mArcPolygonItem){ |
|
|
|
|
if(eDrawingMode_Vector == dc->drawingMode()){ |
|
|
|
|
|
|
|
|
|
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup(); |
|
|
|
|
|
|
|
|
|
// Add the arc
|
|
|
|
@ -580,10 +580,9 @@ bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
|
mAddedItems << pStrokes; |
|
|
|
|
addItem(pStrokes); |
|
|
|
|
mDrawWithCompass = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else if (mCurrentStroke) |
|
|
|
|
{ |
|
|
|
|
if(eDrawingMode_Vector == UBDrawingController::drawingController()->drawingMode()){ |
|
|
|
|
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup(); |
|
|
|
|
|
|
|
|
|
// Remove the strokes that were just drawn here and replace them by a stroke item
|
|
|
|
@ -600,7 +599,6 @@ bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
|
mAddedItems.clear(); |
|
|
|
|
mAddedItems << pStrokes; |
|
|
|
|
addItem(pStrokes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mCurrentStroke->polygons().empty()){ |
|
|
|
|
delete mCurrentStroke; |
|
|
|
@ -612,7 +610,7 @@ bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
|
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack
|
|
|
|
|
|
|
|
|
|
if(UBApplication::undoStack) |
|
|
|
@ -751,10 +749,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, |
|
|
|
|
if (!mCurrentStroke) |
|
|
|
|
mCurrentStroke = new UBGraphicsStroke(); |
|
|
|
|
|
|
|
|
|
if (mCurrentStroke) |
|
|
|
|
{ |
|
|
|
|
polygonItem->setStroke(mCurrentStroke); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mPreviousPolygonItems.append(polygonItem); |
|
|
|
|
|
|
|
|
@ -1002,7 +997,7 @@ void UBGraphicsScene::leaveEvent(QEvent * event) |
|
|
|
|
|
|
|
|
|
UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const |
|
|
|
|
{ |
|
|
|
|
UBGraphicsScene* copy = new UBGraphicsScene(this->document()); |
|
|
|
|
UBGraphicsScene* copy = new UBGraphicsScene(this->document(), this->mUndoRedoStackEnabled); |
|
|
|
|
|
|
|
|
|
copy->setBackground(this->isDarkBackground(), this->isCrossedBackground()); |
|
|
|
|
copy->setSceneRect(this->sceneRect()); |
|
|
|
@ -1138,7 +1133,7 @@ void UBGraphicsScene::clearContent(clearCase pCase) |
|
|
|
|
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
|
|
|
|
|
update(sceneRect()); |
|
|
|
|
|
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet<QGraphicsItem*>(), groupsMap); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
@ -1165,7 +1160,7 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi |
|
|
|
|
|
|
|
|
|
addItem(pixmapItem); |
|
|
|
|
|
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, replaceFor, pixmapItem); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
@ -1192,7 +1187,7 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi |
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) |
|
|
|
|
{ |
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsTextItemUndoCommand* uc = new UBGraphicsTextItemUndoCommand(textItem); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
@ -1213,7 +1208,7 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s |
|
|
|
|
|
|
|
|
|
mediaItem->show(); |
|
|
|
|
|
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, mediaItem); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
@ -1296,7 +1291,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co |
|
|
|
|
// graphicsWidget->widgetWebView()->loadMainHtml();
|
|
|
|
|
|
|
|
|
|
graphicsWidget->setSelected(true); |
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
@ -1362,7 +1357,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem * |
|
|
|
|
groupItem->setVisible(true); |
|
|
|
|
groupItem->setFocus(); |
|
|
|
|
|
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsItemGroupUndoCommand* uc = new UBGraphicsItemGroupUndoCommand(this, groupItem); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
@ -1391,7 +1386,7 @@ void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem) |
|
|
|
|
groupItem->setUuid(QUuid::createUuid()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, groupItem); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
@ -1421,7 +1416,7 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint |
|
|
|
|
|
|
|
|
|
addItem(svgItem); |
|
|
|
|
|
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, svgItem); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
@ -1511,7 +1506,7 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con |
|
|
|
|
|
|
|
|
|
textItem->show(); |
|
|
|
|
|
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
@ -1535,7 +1530,7 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q |
|
|
|
|
addItem(textItem); |
|
|
|
|
textItem->show(); |
|
|
|
|
|
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
|
|
|
|
|
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); |
|
|
|
|
UBApplication::undoStack->push(uc); |
|
|
|
|
} |
|
|
|
|