Skip to content

Commit

Permalink
clear code
Browse files Browse the repository at this point in the history
clear code after code review by Vekhir
  • Loading branch information
ThomasLucky13 committed Jun 10, 2024
1 parent 5ad0a9c commit d5c22fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
23 changes: 8 additions & 15 deletions src/domain/UBGraphicsScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,10 +716,10 @@ bool UBGraphicsScene::inputDeviceRelease(int tool)
addPolygonItemToCurrentStroke(poly);
}

if(multiDrawLines.isEmpty()) // is it not polygons drawing by multiDraw
// replace the stroke by a simplified version of it
if ((currentTool == UBStylusTool::Pen && UBSettings::settings()->boardSimplifyPenStrokes->get().toBool())
|| (currentTool == UBStylusTool::Marker && UBSettings::settings()->boardSimplifyMarkerStrokes->get().toBool()))
if(multiDrawLines.isEmpty() && // is it not polygons drawing by multiDraw
((currentTool == UBStylusTool::Pen && UBSettings::settings()->boardSimplifyPenStrokes->get().toBool())
|| (currentTool == UBStylusTool::Marker && UBSettings::settings()->boardSimplifyMarkerStrokes->get().toBool())))
{
simplifyCurrentStroke();
}
Expand Down Expand Up @@ -3150,22 +3150,16 @@ void UBGraphicsScene::initStroke()
void UBGraphicsScene::MultiTouchDrawing(QTouchEvent* event, UBStylusTool::Enum currentTool)
{
QList <QTouchEvent::TouchPoint> touchPoints = event->touchPoints();
QPointF lastPoint, endPoint;
foreach (QTouchEvent::TouchPoint point, touchPoints)
{
lastPoint_m = point.lastPos();
endPoint_m = point.pos();

int distance = sqrt(pow((lastPoint_m.x() - endPoint_m.x()),2) + pow((lastPoint_m.y() - endPoint_m.y()),2)) + 1;
distance = sqrt(distance);
if (distance > 6)
distance = 6;
else if(distance < 4)
distance = 4;
lastPoint = point.lastPos();
endPoint = point.pos();

UBBoardView* boardView = controlView();
QLineF line;
line.setP1(boardView->mapToScene(UBGeometryUtils::pointConstrainedInRect(lastPoint_m.toPoint(), boardView->rect())));
line.setP2(boardView->mapToScene(UBGeometryUtils::pointConstrainedInRect(endPoint_m.toPoint(), boardView->rect())));
line.setP1(boardView->mapToScene(UBGeometryUtils::pointConstrainedInRect(lastPoint.toPoint(), boardView->rect())));
line.setP2(boardView->mapToScene(UBGeometryUtils::pointConstrainedInRect(endPoint.toPoint(), boardView->rect())));
if (!multiDrawLines.contains(line)) // to eliminate duplicates
{
multiDrawLines.append(line);
Expand All @@ -3182,7 +3176,6 @@ void UBGraphicsScene::MultiTouchDrawing(QTouchEvent* event, UBStylusTool::Enum c
addPolygonItemToCurrentStroke(polygonItem);
}

lastPoint_m = endPoint_m;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/domain/UBGraphicsScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ public slots:

UBGraphicsCache* mGraphicsCache;

QPointF lastPoint_m, endPoint_m;
QList<QLineF> multiDrawLines;
};

Expand Down

0 comments on commit d5c22fa

Please sign in to comment.