diff --git a/src/domain/UBGraphicsPolygonItem.cpp b/src/domain/UBGraphicsPolygonItem.cpp index 7608e20e..9569dcd9 100644 --- a/src/domain/UBGraphicsPolygonItem.cpp +++ b/src/domain/UBGraphicsPolygonItem.cpp @@ -176,7 +176,6 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { - if(mHasAlpha && scene() && scene()->isLightBackground()) { painter->setCompositionMode(QPainter::CompositionMode_Darken); @@ -190,11 +189,3 @@ UBGraphicsScene* UBGraphicsPolygonItem::scene() { return qobject_cast(QGraphicsPolygonItem::scene()); } - - - - - - - - diff --git a/src/domain/UBGraphicsPolygonItem.h b/src/domain/UBGraphicsPolygonItem.h index 22dfe712..25895096 100644 --- a/src/domain/UBGraphicsPolygonItem.h +++ b/src/domain/UBGraphicsPolygonItem.h @@ -116,7 +116,6 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem protected: void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); - private: void clearStroke(); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 27ebfb59..012363d2 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -364,7 +364,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre mRemovedItems.clear(); if (UBDrawingController::drawingController()->mActiveRuler) - { + { UBDrawingController::drawingController()->mActiveRuler->StartLine(scenePos, width); } else @@ -432,40 +432,37 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres width /= UBApplication::boardController->systemScaleFactor(); width /= UBApplication::boardController->currentZoom(); - if (dc->mActiveRuler) - { - dc->mActiveRuler->DrawLine(position, width); - } - else - { - if (currentTool == UBStylusTool::Line) - { - if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){ - UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon); - mAddedItems.remove(mpLastPolygon); - mCurrentStroke->remove(mpLastPolygon); - removeItem(mpLastPolygon); - mPreviousPolygonItems.removeAll(mpLastPolygon); - } + if (currentTool == UBStylusTool::Line || dc->mActiveRuler) + { + if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){ + UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon); + mAddedItems.remove(mpLastPolygon); + mCurrentStroke->remove(mpLastPolygon); + removeItem(mpLastPolygon); + mPreviousPolygonItems.removeAll(mpLastPolygon); + } - // ------------------------------------------------------------------------ - // Here we wanna make sure that the Line will 'grip' at i*45, i*90 degrees - // ------------------------------------------------------------------------ - - QLineF radius(mPreviousPoint, position); - qreal angle = radius.angle(); - angle = qRound(angle / 45) * 45; - qreal radiusLength = radius.length(); - QPointF newPosition( - mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180), - mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180)); - QLineF chord(position, newPosition); - if (chord.length() < qMin((int)16, (int)(radiusLength / 20))) - position = newPosition; - } + // ------------------------------------------------------------------------ + // Here we wanna make sure that the Line will 'grip' at i*45, i*90 degrees + // ------------------------------------------------------------------------ + + QLineF radius(mPreviousPoint, position); + qreal angle = radius.angle(); + angle = qRound(angle / 45) * 45; + qreal radiusLength = radius.length(); + QPointF newPosition( + mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180), + mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180)); + QLineF chord(position, newPosition); + if (chord.length() < qMin((int)16, (int)(radiusLength / 20))) + position = newPosition; + } + if(dc->mActiveRuler){ + dc->mActiveRuler->DrawLine(position, width); + }else{ drawLineTo(position, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line); - } + } } else if (currentTool == UBStylusTool::Eraser) { @@ -675,14 +672,14 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, mpLastPolygon = polygonItem; mAddedItems.insert(polygonItem); + // Here we add the item to the scene + addItem(polygonItem); + if (mCurrentStroke) { polygonItem->setStroke(mCurrentStroke); } - // Here we add the item to the scene - addItem(polygonItem); - mPreviousPolygonItems.append(polygonItem); if (!bLineStyle) diff --git a/src/tools/UBGraphicsRuler.cpp b/src/tools/UBGraphicsRuler.cpp index 728b5bad..27bcc713 100644 --- a/src/tools/UBGraphicsRuler.cpp +++ b/src/tools/UBGraphicsRuler.cpp @@ -103,6 +103,7 @@ void UBGraphicsRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *s painter->setPen(drawColor()); + painter->setRenderHint(QPainter::Antialiasing, true); painter->drawRoundedRect(rect(), sRoundingRadius, sRoundingRadius); fillBackground(painter); paintGraduations(painter); @@ -452,8 +453,8 @@ void UBGraphicsRuler::StartLine(const QPointF& scenePos, qreal width) itemPos.setY(y); itemPos = mapToScene(itemPos); - scene()->moveTo(itemPos); - scene()->drawLineTo(itemPos, width, true); + scene()->moveTo(itemPos); + scene()->drawLineTo(itemPos, width, true); } void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width) @@ -478,9 +479,11 @@ void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width) itemPos = mapToScene(itemPos); // We have to use "pointed" line for marker tool - scene()->drawLineTo(itemPos, width, - UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker); + scene()->drawLineTo(itemPos, width, UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker); } void UBGraphicsRuler::EndLine() -{} +{ + // We never come to this place + scene()->inputDeviceRelease(); +}