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