|
|
@ -313,6 +313,7 @@ void UBGraphicsScene::selectionChangedProcessing() |
|
|
|
+ QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); |
|
|
|
+ QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::updateGroupButtonState() |
|
|
|
void UBGraphicsScene::updateGroupButtonState() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QAction *groupAction = UBApplication::mainWindow->actionGroupItems; |
|
|
|
QAction *groupAction = UBApplication::mainWindow->actionGroupItems; |
|
|
@ -337,9 +338,6 @@ void UBGraphicsScene::updateGroupButtonState() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// MARK: -
|
|
|
|
|
|
|
|
// MARK: Mouse/Tablet events handling
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pressure) |
|
|
|
bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pressure) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//mMesure1Ms = 0;
|
|
|
|
//mMesure1Ms = 0;
|
|
|
@ -509,7 +507,6 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres |
|
|
|
return accepted; |
|
|
|
return accepted; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
{ |
|
|
|
{ |
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -608,8 +605,6 @@ bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
return accepted; |
|
|
|
return accepted; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// MARK: -
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw) |
|
|
|
void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qreal eraserWidth = UBSettings::settings()->currentEraserWidth(); |
|
|
|
qreal eraserWidth = UBSettings::settings()->currentEraserWidth(); |
|
|
@ -685,7 +680,6 @@ void UBGraphicsScene::moveTo(const QPointF &pPoint) |
|
|
|
mDrawWithCompass = false; |
|
|
|
mDrawWithCompass = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, bool bLineStyle) |
|
|
|
void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, bool bLineStyle) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mPreviousWidth == -1.0) |
|
|
|
if (mPreviousWidth == -1.0) |
|
|
@ -737,11 +731,8 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) |
|
|
|
void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// QList<QGraphicsItem*> itemList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QLineF line(mPreviousPoint, pEndPoint); |
|
|
|
const QLineF line(mPreviousPoint, pEndPoint); |
|
|
|
|
|
|
|
|
|
|
|
const QPolygonF eraserPolygon = UBGeometryUtils::lineToPolygon(line, pWidth); |
|
|
|
const QPolygonF eraserPolygon = UBGeometryUtils::lineToPolygon(line, pWidth); |
|
|
@ -778,7 +769,6 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
QSet<QGraphicsItem*> toBeAddedItems; |
|
|
|
QSet<QGraphicsItem*> toBeAddedItems; |
|
|
|
QSet<QGraphicsItem*> toBeRemovedItems; |
|
|
|
QSet<QGraphicsItem*> toBeRemovedItems; |
|
|
@ -788,23 +778,19 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) |
|
|
|
|
|
|
|
|
|
|
|
if (mShouldUseOMP) |
|
|
|
if (mShouldUseOMP) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// #pragma omp parallel for
|
|
|
|
#pragma omp parallel for |
|
|
|
for (int i = 0; i < collidItemsSize; i++) |
|
|
|
for (int i = 0; i < collidItemsSize; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsPolygonItem *collidingPolygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(collidItems.at(i)); |
|
|
|
UBGraphicsPolygonItem *collidingPolygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(collidItems.at(i)); |
|
|
|
|
|
|
|
|
|
|
|
if (NULL != collidingPolygonItem) |
|
|
|
if (NULL != collidingPolygonItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
collidingPolygonItem->setColor(QColor(Qt::green)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsStrokesGroup* pGroup = collidingPolygonItem->strokesGroup(); |
|
|
|
UBGraphicsStrokesGroup* pGroup = collidingPolygonItem->strokesGroup(); |
|
|
|
|
|
|
|
|
|
|
|
if(eraserInnerRect.contains(collidingPolygonItem->boundingRect())) |
|
|
|
if(eraserInnerRect.contains(collidingPolygonItem->boundingRect())) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// #pragma omp critical
|
|
|
|
#pragma omp critical |
|
|
|
qDebug() << "case 1"; |
|
|
|
|
|
|
|
// Put the entire polygon into the remove list
|
|
|
|
// Put the entire polygon into the remove list
|
|
|
|
collidingPolygonItem->setColor(QColor(Qt::blue)); |
|
|
|
|
|
|
|
toBeRemovedItems << collidingPolygonItem; |
|
|
|
toBeRemovedItems << collidingPolygonItem; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -816,43 +802,50 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) |
|
|
|
collidingPath.addPolygon(collidingPolygon); |
|
|
|
collidingPath.addPolygon(collidingPolygon); |
|
|
|
|
|
|
|
|
|
|
|
// Then we substract the eraser path to the polygon and we simplify it
|
|
|
|
// Then we substract the eraser path to the polygon and we simplify it
|
|
|
|
QPainterPath croppedPath = collidingPath.subtracted(eraserPath); |
|
|
|
/**/ |
|
|
|
|
|
|
|
QTransform polyTransform = collidingPolygonItem->sceneTransform().inverted(); |
|
|
|
|
|
|
|
QPointF mTrPrevPoint = polyTransform.map(mPreviousPoint); |
|
|
|
|
|
|
|
QPointF mTrEndPoint = polyTransform.map(pEndPoint); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QLineF trLine(mTrPrevPoint, mTrEndPoint); |
|
|
|
|
|
|
|
const QPolygonF trEraserPolygon = UBGeometryUtils::lineToPolygon(trLine, pWidth); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPainterPath trEraser; |
|
|
|
|
|
|
|
trEraser.addPolygon(trEraserPolygon); |
|
|
|
|
|
|
|
QPainterPath croppedPath = collidingPath.subtracted(trEraser); |
|
|
|
|
|
|
|
/**/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Original
|
|
|
|
|
|
|
|
//QPainterPath croppedPath = collidingPath.subtracted(eraserPath);
|
|
|
|
QPainterPath croppedPathSimplified = croppedPath.simplified(); |
|
|
|
QPainterPath croppedPathSimplified = croppedPath.simplified(); |
|
|
|
|
|
|
|
|
|
|
|
/*if (croppedPath == collidingPath)
|
|
|
|
/*if (croppedPath == collidingPath)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// NOOP
|
|
|
|
// NOOP
|
|
|
|
qDebug() << "case 2"; |
|
|
|
|
|
|
|
toBeRemovedItems << collidingPolygonItem; |
|
|
|
toBeRemovedItems << collidingPolygonItem; |
|
|
|
} |
|
|
|
} |
|
|
|
else */if (croppedPathSimplified.isEmpty()) |
|
|
|
else */if (croppedPathSimplified.isEmpty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// #pragma omp critical
|
|
|
|
#pragma omp critical |
|
|
|
qDebug() << "case 3"; |
|
|
|
|
|
|
|
// Put the entire polygon into the remove list if the eraser removes all its visible content
|
|
|
|
// Put the entire polygon into the remove list if the eraser removes all its visible content
|
|
|
|
collidingPolygonItem->setColor(QColor(Qt::blue)); |
|
|
|
|
|
|
|
toBeRemovedItems << collidingPolygonItem; |
|
|
|
toBeRemovedItems << collidingPolygonItem; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
//qDebug() << "case 4";
|
|
|
|
|
|
|
|
// Then we convert the remaining path to a list of polygons that will be converted in
|
|
|
|
// Then we convert the remaining path to a list of polygons that will be converted in
|
|
|
|
// UBGraphicsPolygonItems and added to the scene
|
|
|
|
// UBGraphicsPolygonItems and added to the scene
|
|
|
|
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons()) |
|
|
|
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol); |
|
|
|
UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol); |
|
|
|
croppedPolygonItem->setColor(QColor(Qt::black)); |
|
|
|
#pragma omp critical |
|
|
|
// #pragma omp critical
|
|
|
|
|
|
|
|
if(NULL != pGroup){ |
|
|
|
if(NULL != pGroup){ |
|
|
|
croppedPolygonItem->setStrokesGroup(pGroup); |
|
|
|
croppedPolygonItem->setStrokesGroup(pGroup); |
|
|
|
// croppedPolygonItem->setTransform(pGroup->sceneTransform().inverted());
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// Add this new polygon to the 'added' list
|
|
|
|
// Add this new polygon to the 'added' list
|
|
|
|
toBeAddedItems << croppedPolygonItem; |
|
|
|
toBeAddedItems << croppedPolygonItem; |
|
|
|
} |
|
|
|
} |
|
|
|
// #pragma omp critical
|
|
|
|
#pragma omp critical |
|
|
|
// Remove the original polygonitem because it has been replaced by many smaller polygons
|
|
|
|
// Remove the original polygonitem because it has been replaced by many smaller polygons
|
|
|
|
collidingPolygonItem->setColor(QColor(Qt::blue)); |
|
|
|
|
|
|
|
toBeRemovedItems << collidingPolygonItem; |
|
|
|
toBeRemovedItems << collidingPolygonItem; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -925,30 +918,14 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) |
|
|
|
mRemovedItems += toBeRemovedItems; |
|
|
|
mRemovedItems += toBeRemovedItems; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// bool hack = false;
|
|
|
|
|
|
|
|
// UBGraphicsStrokesGroup* pG = new UBGraphicsStrokesGroup();
|
|
|
|
|
|
|
|
if(eDrawingMode_Vector == DRAWING_MODE){ |
|
|
|
if(eDrawingMode_Vector == DRAWING_MODE){ |
|
|
|
foreach(QGraphicsItem* item, toBeAddedItems){ |
|
|
|
foreach(QGraphicsItem* item, toBeAddedItems){ |
|
|
|
UBGraphicsPolygonItem* poly = dynamic_cast<UBGraphicsPolygonItem*>(item); |
|
|
|
UBGraphicsPolygonItem* poly = dynamic_cast<UBGraphicsPolygonItem*>(item); |
|
|
|
if(NULL != poly && NULL != poly->strokesGroup()){ |
|
|
|
if(NULL != poly && NULL != poly->strokesGroup()){ |
|
|
|
// if(!hack){
|
|
|
|
poly->setTransform(poly->strokesGroup()->transform()); |
|
|
|
// itemList = poly->strokesGroup()->childItems();
|
|
|
|
poly->strokesGroup()->addToGroup(poly); |
|
|
|
// removeItem(poly->strokesGroup());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// foreach(QGraphicsItem* it, itemList){
|
|
|
|
|
|
|
|
// pG->addToGroup(it);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// hack = true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
qreal dx = -poly->strokesGroup()->sceneTransform().inverted().dx(); |
|
|
|
|
|
|
|
qreal dy = -poly->strokesGroup()->sceneTransform().inverted().dy(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//poly->setTransform(QTransform().translate(20, 0));
|
|
|
|
|
|
|
|
poly->setTransform(QTransform().translate(dx, dy)); |
|
|
|
|
|
|
|
poly->strokesGroup()/*pG*/->addToGroup(poly); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//addItem(pG);
|
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
addItems(toBeAddedItems); |
|
|
|
addItems(toBeAddedItems); |
|
|
|
mAddedItems += toBeAddedItems; |
|
|
|
mAddedItems += toBeAddedItems; |
|
|
@ -958,7 +935,6 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) |
|
|
|
mPreviousPoint = pEndPoint; |
|
|
|
mPreviousPoint = pEndPoint; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle) |
|
|
|
void UBGraphicsScene::drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mDrawWithCompass = true; |
|
|
|
mDrawWithCompass = true; |
|
|
@ -1070,7 +1046,6 @@ void UBGraphicsScene::recolorAllItems() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsPolygonItem* UBGraphicsScene::lineToPolygonItem(const QLineF &pLine, const qreal &pWidth) |
|
|
|
UBGraphicsPolygonItem* UBGraphicsScene::lineToPolygonItem(const QLineF &pLine, const qreal &pWidth) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsPolygonItem *polygonItem = new UBGraphicsPolygonItem(pLine, pWidth); |
|
|
|
UBGraphicsPolygonItem *polygonItem = new UBGraphicsPolygonItem(pLine, pWidth); |
|
|
@ -1080,7 +1055,6 @@ UBGraphicsPolygonItem* UBGraphicsScene::lineToPolygonItem(const QLineF &pLine, c |
|
|
|
return polygonItem; |
|
|
|
return polygonItem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem) |
|
|
|
void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QColor colorOnDarkBG; |
|
|
|
QColor colorOnDarkBG; |
|
|
@ -1112,7 +1086,6 @@ void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem) |
|
|
|
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); |
|
|
|
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRadius, qreal pSpanAngle, qreal pWidth) |
|
|
|
UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRadius, qreal pSpanAngle, qreal pWidth) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QPolygonF polygon = UBGeometryUtils::arcToPolygon(pStartRadius, pSpanAngle, pWidth); |
|
|
|
QPolygonF polygon = UBGeometryUtils::arcToPolygon(pStartRadius, pSpanAngle, pWidth); |
|
|
@ -1120,7 +1093,6 @@ UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRad |
|
|
|
return polygonToPolygonItem(polygon); |
|
|
|
return polygonToPolygonItem(polygon); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsPolygonItem* UBGraphicsScene::polygonToPolygonItem(const QPolygonF pPolygon) |
|
|
|
UBGraphicsPolygonItem* UBGraphicsScene::polygonToPolygonItem(const QPolygonF pPolygon) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsPolygonItem *polygonItem = new UBGraphicsPolygonItem(pPolygon); |
|
|
|
UBGraphicsPolygonItem *polygonItem = new UBGraphicsPolygonItem(pPolygon); |
|
|
@ -1130,14 +1102,12 @@ UBGraphicsPolygonItem* UBGraphicsScene::polygonToPolygonItem(const QPolygonF pPo |
|
|
|
return polygonItem; |
|
|
|
return polygonItem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::hideEraser() |
|
|
|
void UBGraphicsScene::hideEraser() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mEraser) |
|
|
|
if (mEraser) |
|
|
|
mEraser->hide(); |
|
|
|
mEraser->hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::leaveEvent(QEvent * event) |
|
|
|
void UBGraphicsScene::leaveEvent(QEvent * event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_UNUSED(event); |
|
|
|
Q_UNUSED(event); |
|
|
@ -1212,13 +1182,11 @@ UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const |
|
|
|
return copy; |
|
|
|
return copy; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBItem* UBGraphicsScene::deepCopy() const |
|
|
|
UBItem* UBGraphicsScene::deepCopy() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return sceneDeepCopy(); |
|
|
|
return sceneDeepCopy(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::clearItemsAndAnnotations() |
|
|
|
void UBGraphicsScene::clearItemsAndAnnotations() |
|
|
|
{ |
|
|
|
{ |
|
|
|
deselectAllItems(); |
|
|
|
deselectAllItems(); |
|
|
@ -1250,7 +1218,6 @@ void UBGraphicsScene::clearItemsAndAnnotations() |
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::clearItems() |
|
|
|
void UBGraphicsScene::clearItems() |
|
|
|
{ |
|
|
|
{ |
|
|
|
deselectAllItems(); |
|
|
|
deselectAllItems(); |
|
|
@ -1288,7 +1255,6 @@ void UBGraphicsScene::clearItems() |
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::clearAnnotations() |
|
|
|
void UBGraphicsScene::clearAnnotations() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSet<QGraphicsItem*> emptyList; |
|
|
|
QSet<QGraphicsItem*> emptyList; |
|
|
@ -1319,7 +1285,6 @@ void UBGraphicsScene::clearAnnotations() |
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const QPointF& pPos, qreal pScaleFactor, bool pUseAnimation) |
|
|
|
UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const QPointF& pPos, qreal pScaleFactor, bool pUseAnimation) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsPixmapItem* pixmapItem = new UBGraphicsPixmapItem(); |
|
|
|
UBGraphicsPixmapItem* pixmapItem = new UBGraphicsPixmapItem(); |
|
|
@ -1359,7 +1324,6 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const Q |
|
|
|
return pixmapItem; |
|
|
|
return pixmapItem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) |
|
|
|
void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
|
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
|
|
|
@ -1368,7 +1332,6 @@ void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsVideoItem* UBGraphicsScene::addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos) |
|
|
|
UBGraphicsVideoItem* UBGraphicsScene::addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsVideoItem* videoItem = new UBGraphicsVideoItem(pVideoFileUrl); |
|
|
|
UBGraphicsVideoItem* videoItem = new UBGraphicsVideoItem(pVideoFileUrl); |
|
|
@ -1431,7 +1394,6 @@ UBGraphicsAudioItem* UBGraphicsScene::addAudio(const QUrl& pAudioFileUrl, bool s |
|
|
|
return audioItem; |
|
|
|
return audioItem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsWidgetItem* UBGraphicsScene::addWidget(const QUrl& pWidgetUrl, const QPointF& pPos) |
|
|
|
UBGraphicsWidgetItem* UBGraphicsScene::addWidget(const QUrl& pWidgetUrl, const QPointF& pPos) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int widgetType = UBAbstractWidget::widgetType(pWidgetUrl); |
|
|
|
int widgetType = UBAbstractWidget::widgetType(pWidgetUrl); |
|
|
@ -1451,7 +1413,6 @@ UBGraphicsWidgetItem* UBGraphicsScene::addWidget(const QUrl& pWidgetUrl, const Q |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsAppleWidgetItem* UBGraphicsScene::addAppleWidget(const QUrl& pWidgetUrl, const QPointF& pPos) |
|
|
|
UBGraphicsAppleWidgetItem* UBGraphicsScene::addAppleWidget(const QUrl& pWidgetUrl, const QPointF& pPos) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsAppleWidgetItem *appleWidget = new UBGraphicsAppleWidgetItem(pWidgetUrl); |
|
|
|
UBGraphicsAppleWidgetItem *appleWidget = new UBGraphicsAppleWidgetItem(pWidgetUrl); |
|
|
@ -1461,7 +1422,6 @@ UBGraphicsAppleWidgetItem* UBGraphicsScene::addAppleWidget(const QUrl& pWidgetUr |
|
|
|
return appleWidget; |
|
|
|
return appleWidget; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos, int widgetType) |
|
|
|
UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos, int widgetType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsW3CWidgetItem *w3CWidget = new UBGraphicsW3CWidgetItem(pWidgetUrl, 0, widgetType); |
|
|
|
UBGraphicsW3CWidgetItem *w3CWidget = new UBGraphicsW3CWidgetItem(pWidgetUrl, 0, widgetType); |
|
|
@ -1502,7 +1462,6 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsW3CWidgetItem* UBGraphicsScene::addOEmbed(const QUrl& pContentUrl, const QPointF& pPos) |
|
|
|
UBGraphicsW3CWidgetItem* UBGraphicsScene::addOEmbed(const QUrl& pContentUrl, const QPointF& pPos) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QStringList widgetPaths = UBPersistenceManager::persistenceManager()->allWidgets(UBSettings::settings()->applicationApplicationsLibraryDirectory()); |
|
|
|
QStringList widgetPaths = UBPersistenceManager::persistenceManager()->allWidgets(UBSettings::settings()->applicationApplicationsLibraryDirectory()); |
|
|
@ -1588,7 +1547,6 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint |
|
|
|
return svgItem; |
|
|
|
return svgItem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTextItem* UBGraphicsScene::addText(const QString& pString, const QPointF& pTopLeft) |
|
|
|
UBGraphicsTextItem* UBGraphicsScene::addText(const QString& pString, const QPointF& pTopLeft) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return addTextWithFont(pString, pTopLeft, UBSettings::settings()->fontPixelSize() |
|
|
|
return addTextWithFont(pString, pTopLeft, UBSettings::settings()->fontPixelSize() |
|
|
@ -1680,6 +1638,7 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con |
|
|
|
|
|
|
|
|
|
|
|
return textItem; |
|
|
|
return textItem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const QPointF& pTopLeft) |
|
|
|
UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const QPointF& pTopLeft) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); |
|
|
|
UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); |
|
|
@ -1743,7 +1702,6 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item) |
|
|
|
mFastAccessItems.removeAll(item); |
|
|
|
mFastAccessItems.removeAll(item); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items) |
|
|
|
void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setModified(true); |
|
|
|
setModified(true); |
|
|
@ -1757,7 +1715,6 @@ void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items) |
|
|
|
mFastAccessItems.removeAll(item); |
|
|
|
mFastAccessItems.removeAll(item); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::deselectAllItems() |
|
|
|
void UBGraphicsScene::deselectAllItems() |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach(QGraphicsItem *gi, selectedItems ()) |
|
|
|
foreach(QGraphicsItem *gi, selectedItems ()) |
|
|
@ -1803,7 +1760,6 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio) |
|
|
|
QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
@ -1843,7 +1799,6 @@ QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio) |
|
|
|
return normalizedRect; |
|
|
|
return normalizedRect; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::setDocument(UBDocumentProxy* pDocument) |
|
|
|
void UBGraphicsScene::setDocument(UBDocumentProxy* pDocument) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (pDocument != mDocument) |
|
|
|
if (pDocument != mDocument) |
|
|
@ -1858,7 +1813,6 @@ void UBGraphicsScene::setDocument(UBDocumentProxy* pDocument) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QGraphicsItem* UBGraphicsScene::scaleToFitDocumentSize(QGraphicsItem* item, bool center, int margin, bool expand) |
|
|
|
QGraphicsItem* UBGraphicsScene::scaleToFitDocumentSize(QGraphicsItem* item, bool center, int margin, bool expand) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int maxWidth = mNominalSize.width() - (margin * 2); |
|
|
|
int maxWidth = mNominalSize.width() - (margin * 2); |
|
|
@ -1897,7 +1851,6 @@ void UBGraphicsScene::addRuler(QPointF center) |
|
|
|
setModified(true); |
|
|
|
setModified(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::addProtractor(QPointF center) |
|
|
|
void UBGraphicsScene::addProtractor(QPointF center) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Protractor
|
|
|
|
// Protractor
|
|
|
@ -2089,7 +2042,6 @@ void UBGraphicsScene::addMask(const QPointF ¢er) |
|
|
|
setModified(true); |
|
|
|
setModified(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQuality) |
|
|
|
void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQuality) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QListIterator<QGraphicsItem*> itItems(mFastAccessItems); |
|
|
|
QListIterator<QGraphicsItem*> itItems(mFastAccessItems); |
|
|
@ -2107,7 +2059,6 @@ void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQua |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QUrl> UBGraphicsScene::relativeDependencies() const |
|
|
|
QList<QUrl> UBGraphicsScene::relativeDependencies() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<QUrl> relativePathes; |
|
|
|
QList<QUrl> relativePathes; |
|
|
@ -2127,7 +2078,6 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const |
|
|
|
return relativePathes; |
|
|
|
return relativePathes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSize UBGraphicsScene::nominalSize() |
|
|
|
QSize UBGraphicsScene::nominalSize() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mDocument && !mNominalSize.isValid()) |
|
|
|
if (mDocument && !mNominalSize.isValid()) |
|
|
@ -2138,7 +2088,6 @@ QSize UBGraphicsScene::nominalSize() |
|
|
|
return mNominalSize; |
|
|
|
return mNominalSize; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::setNominalSize(const QSize& pSize) |
|
|
|
void UBGraphicsScene::setNominalSize(const QSize& pSize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (nominalSize() != pSize) |
|
|
|
if (nominalSize() != pSize) |
|
|
@ -2152,7 +2101,6 @@ void UBGraphicsScene::setNominalSize(const QSize& pSize) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::setNominalSize(int pWidth, int pHeight) |
|
|
|
void UBGraphicsScene::setNominalSize(int pWidth, int pHeight) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setNominalSize(QSize(pWidth, pHeight)); |
|
|
|
setNominalSize(QSize(pWidth, pHeight)); |
|
|
@ -2162,6 +2110,7 @@ void UBGraphicsScene::setSelectedZLevel(QGraphicsItem * item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
item->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem)); |
|
|
|
item->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::setOwnZlevel(QGraphicsItem *item) |
|
|
|
void UBGraphicsScene::setOwnZlevel(QGraphicsItem *item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
item->setZValue(item->data(UBGraphicsItemData::ItemOwnZValue).toReal()); |
|
|
|
item->setZValue(item->data(UBGraphicsItemData::ItemOwnZValue).toReal()); |
|
|
@ -2184,7 +2133,6 @@ QGraphicsItem* UBGraphicsScene::rootItem(QGraphicsItem* item) const |
|
|
|
return root; |
|
|
|
return root; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::drawItems (QPainter * painter, int numItems, |
|
|
|
void UBGraphicsScene::drawItems (QPainter * painter, int numItems, |
|
|
|
QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget) |
|
|
|
QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2359,13 +2307,13 @@ void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent) |
|
|
|
QGraphicsScene::keyReleaseEvent(keyEvent); |
|
|
|
QGraphicsScene::keyReleaseEvent(keyEvent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::setDocumentUpdated() |
|
|
|
void UBGraphicsScene::setDocumentUpdated() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (document()) |
|
|
|
if (document()) |
|
|
|
document()->setMetaData(UBSettings::documentUpdatedAt |
|
|
|
document()->setMetaData(UBSettings::documentUpdatedAt |
|
|
|
, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); |
|
|
|
, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::createEraiser() |
|
|
|
void UBGraphicsScene::createEraiser() |
|
|
|
{ |
|
|
|
{ |
|
|
|
mEraser = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene
|
|
|
|
mEraser = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene
|
|
|
@ -2379,6 +2327,7 @@ void UBGraphicsScene::createEraiser() |
|
|
|
addItem(mEraser); |
|
|
|
addItem(mEraser); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::createPointer() |
|
|
|
void UBGraphicsScene::createPointer() |
|
|
|
{ |
|
|
|
{ |
|
|
|
mPointer = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene
|
|
|
|
mPointer = new QGraphicsEllipseItem(); // mem : owned and destroyed by the scene
|
|
|
|