|
|
@ -314,6 +314,7 @@ void UBGraphicsScene::selectionChangedProcessing() |
|
|
|
+ QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); |
|
|
|
+ QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::enableGroupingButton() |
|
|
|
void UBGraphicsScene::enableGroupingButton() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QAction *groupAction = UBApplication::mainWindow->actionGroupItems; |
|
|
|
QAction *groupAction = UBApplication::mainWindow->actionGroupItems; |
|
|
@ -324,6 +325,7 @@ void UBGraphicsScene::enableGroupingButton() |
|
|
|
groupAction->setEnabled(false); |
|
|
|
groupAction->setEnabled(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::processGroupItems() |
|
|
|
void UBGraphicsScene::processGroupItems() |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug() << "processing grouping items"; |
|
|
|
qDebug() << "processing grouping items"; |
|
|
@ -345,9 +347,6 @@ void UBGraphicsScene::processGroupItems() |
|
|
|
qDebug() << groupItem->boundingRect(); |
|
|
|
qDebug() << groupItem->boundingRect(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
@ -434,7 +433,6 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre |
|
|
|
return accepted; |
|
|
|
return accepted; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pressure) |
|
|
|
bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pressure) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool accepted = false; |
|
|
|
bool accepted = false; |
|
|
@ -518,7 +516,6 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres |
|
|
|
return accepted; |
|
|
|
return accepted; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
bool UBGraphicsScene::inputDeviceRelease() |
|
|
|
{ |
|
|
|
{ |
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -617,8 +614,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(); |
|
|
@ -694,7 +689,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) |
|
|
@ -746,11 +740,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); |
|
|
@ -787,7 +778,6 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
QSet<QGraphicsItem*> toBeAddedItems; |
|
|
|
QSet<QGraphicsItem*> toBeAddedItems; |
|
|
|
QSet<QGraphicsItem*> toBeRemovedItems; |
|
|
|
QSet<QGraphicsItem*> toBeRemovedItems; |
|
|
@ -797,23 +787,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 |
|
|
@ -825,43 +811,55 @@ 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(); |
|
|
|
|
|
|
|
QPointF mTrPrevPoint; |
|
|
|
|
|
|
|
QPointF mTrEndPoint; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Handle the scale & rotation transform here
|
|
|
|
|
|
|
|
mTrPrevPoint.setX(mPreviousPoint.x() - polyTransform.dx()); |
|
|
|
|
|
|
|
mTrPrevPoint.setY(mPreviousPoint.y() - polyTransform.dy()); |
|
|
|
|
|
|
|
mTrEndPoint.setX(pEndPoint.x() - polyTransform.dx()); |
|
|
|
|
|
|
|
mTrEndPoint.setY(pEndPoint.y() - polyTransform.dy()); |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -934,30 +932,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; |
|
|
@ -967,7 +949,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; |
|
|
@ -1079,7 +1060,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); |
|
|
@ -1089,7 +1069,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; |
|
|
@ -1121,7 +1100,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); |
|
|
@ -1129,7 +1107,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); |
|
|
@ -1139,14 +1116,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); |
|
|
@ -1221,13 +1196,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(); |
|
|
@ -1259,7 +1232,6 @@ void UBGraphicsScene::clearItemsAndAnnotations() |
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::clearItems() |
|
|
|
void UBGraphicsScene::clearItems() |
|
|
|
{ |
|
|
|
{ |
|
|
|
deselectAllItems(); |
|
|
|
deselectAllItems(); |
|
|
@ -1297,7 +1269,6 @@ void UBGraphicsScene::clearItems() |
|
|
|
setDocumentUpdated(); |
|
|
|
setDocumentUpdated(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::clearAnnotations() |
|
|
|
void UBGraphicsScene::clearAnnotations() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSet<QGraphicsItem*> emptyList; |
|
|
|
QSet<QGraphicsItem*> emptyList; |
|
|
@ -1328,7 +1299,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(); |
|
|
@ -1368,7 +1338,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
|
|
|
@ -1377,7 +1346,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); |
|
|
@ -1440,7 +1408,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); |
|
|
@ -1460,7 +1427,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); |
|
|
@ -1470,7 +1436,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); |
|
|
@ -1511,7 +1476,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()); |
|
|
@ -1564,7 +1528,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() |
|
|
@ -1572,7 +1535,6 @@ UBGraphicsTextItem* UBGraphicsScene::addText(const QString& pString, const QPoin |
|
|
|
, UBSettings::settings()->isItalicFont()); |
|
|
|
, UBSettings::settings()->isItalicFont()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, const QPointF& pTopLeft |
|
|
|
UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, const QPointF& pTopLeft |
|
|
|
, int pointSize, const QString& fontFamily, bool bold, bool italic) |
|
|
|
, int pointSize, const QString& fontFamily, bool bold, bool italic) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1629,6 +1591,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(); |
|
|
@ -1692,7 +1655,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); |
|
|
@ -1706,7 +1668,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 ()) |
|
|
@ -1752,7 +1713,6 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio) |
|
|
|
QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
@ -1792,7 +1752,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) |
|
|
@ -1807,7 +1766,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); |
|
|
@ -1831,7 +1789,6 @@ QGraphicsItem* UBGraphicsScene::scaleToFitDocumentSize(QGraphicsItem* item, bool |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::addRuler(QPointF center) |
|
|
|
void UBGraphicsScene::addRuler(QPointF center) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBGraphicsRuler* ruler = new UBGraphicsRuler(); // mem : owned and destroyed by the scene
|
|
|
|
UBGraphicsRuler* ruler = new UBGraphicsRuler(); // mem : owned and destroyed by the scene
|
|
|
@ -1847,7 +1804,6 @@ void UBGraphicsScene::addRuler(QPointF center) |
|
|
|
setModified(true); |
|
|
|
setModified(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::addProtractor(QPointF center) |
|
|
|
void UBGraphicsScene::addProtractor(QPointF center) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Protractor
|
|
|
|
// Protractor
|
|
|
@ -2039,7 +1995,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); |
|
|
@ -2057,7 +2012,6 @@ void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQua |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QUrl> UBGraphicsScene::relativeDependencies() const |
|
|
|
QList<QUrl> UBGraphicsScene::relativeDependencies() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<QUrl> relativePathes; |
|
|
|
QList<QUrl> relativePathes; |
|
|
@ -2077,7 +2031,6 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const |
|
|
|
return relativePathes; |
|
|
|
return relativePathes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSize UBGraphicsScene::nominalSize() |
|
|
|
QSize UBGraphicsScene::nominalSize() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mDocument && !mNominalSize.isValid()) |
|
|
|
if (mDocument && !mNominalSize.isValid()) |
|
|
@ -2088,7 +2041,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) |
|
|
@ -2102,7 +2054,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)); |
|
|
@ -2112,10 +2063,12 @@ 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()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsScene::groupItems(QList<QGraphicsItem *> &itemList) |
|
|
|
void UBGraphicsScene::groupItems(QList<QGraphicsItem *> &itemList) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (QGraphicsItem *item, itemList) { |
|
|
|
foreach (QGraphicsItem *item, itemList) { |
|
|
@ -2124,7 +2077,6 @@ void UBGraphicsScene::groupItems(QList<QGraphicsItem *> &itemList) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qreal UBGraphicsScene::changeZLevelTo(QGraphicsItem *item, UBZLayerController::moveDestination dest) |
|
|
|
qreal UBGraphicsScene::changeZLevelTo(QGraphicsItem *item, UBZLayerController::moveDestination dest) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return mZLayerController->changeZLevelTo(item, dest); |
|
|
|
return mZLayerController->changeZLevelTo(item, dest); |
|
|
@ -2142,7 +2094,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) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2317,13 +2268,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
|
|
|
@ -2337,6 +2288,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
|
|
|
|