Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
f82a0a32
Commit
f82a0a32
authored
Apr 11, 2016
by
Craig Watson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed calculation of minimum distance for stroke polygons' drawing
parent
999fcec9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
18 deletions
+13
-18
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+2
-3
UBGraphicsStroke.cpp
src/domain/UBGraphicsStroke.cpp
+9
-12
UBGraphicsStroke.h
src/domain/UBGraphicsStroke.h
+2
-3
No files found.
src/domain/UBGraphicsScene.cpp
View file @
f82a0a32
...
...
@@ -558,10 +558,9 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
}
QList
<
QPointF
>
newPoints
=
mCurrentStroke
->
addPoint
(
scenePos
,
interpolator
);
if
(
newPoints
.
length
()
>
1
)
if
(
newPoints
.
length
()
>
1
)
{
drawCurve
(
newPoints
,
mPreviousWidth
,
width
);
else
drawLineTo
(
scenePos
,
width
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Line
);
}
}
}
else
if
(
currentTool
==
UBStylusTool
::
Eraser
)
...
...
src/domain/UBGraphicsStroke.cpp
View file @
f82a0a32
...
...
@@ -29,12 +29,14 @@
#include "UBGraphicsPolygonItem.h"
#include "board/UBBoardController.h"
#include "core/UBApplication.h"
#include "core/memcheck.h"
UBGraphicsStroke
::
UBGraphicsStroke
()
{
// NOOP
mAntiScaleRatio
=
1.
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
}
...
...
@@ -71,7 +73,6 @@ QList<QPointF> UBGraphicsStroke::addPoint(const QPointF& point, UBInterpolator::
int
n
=
mDrawnPoints
.
size
();
if
(
interpolationMethod
==
UBInterpolator
::
NoInterpolation
||
n
==
0
)
{
mLastReceivedPoint
=
point
;
mDrawnPoints
<<
point
;
mAllPoints
<<
point
;
return
QList
<
QPointF
>
()
<<
point
;
...
...
@@ -80,28 +81,24 @@ QList<QPointF> UBGraphicsStroke::addPoint(const QPointF& point, UBInterpolator::
else
if
(
interpolationMethod
==
UBInterpolator
::
Bezier
)
{
// This is a bit special, as the curve we are interpolating is not between two drawn points;
// it is between the midway points of the second-to-last and last point, and last and current point.
qreal
MIN_DISTANCE
=
3
;
// TODO: make this dependant on zoom
qreal
distance
=
QLineF
(
mLastReceivedPoint
,
point
).
length
();
//qDebug() << "distance: " << distance;
// Don't draw segments smaller than a certain length. This can help with performance
// (less polygons in a stroke) but mostly with keeping the curve smooth.
qreal
MIN_DISTANCE
=
3
*
mAntiScaleRatio
;
qreal
distance
=
QLineF
(
mDrawnPoints
.
last
(),
point
).
length
();
// We don't draw anything below the minimum distance. For performance reasons but also to make the curve
// look smoother (e.g shaking slightly won't affect the curve).
if
(
distance
<
MIN_DISTANCE
)
{
// but we still keep track of that point to calculate the distance correctly next time around
mLastReceivedPoint
=
point
;
return
QList
<
QPointF
>
();
}
// The first segment is just a straight line to the first midway point
if
(
n
==
1
)
{
// We start with a straight line to the first midway point
QPointF
lastPoint
=
mDrawnPoints
[
0
];
mDrawnPoints
<<
point
;
return
QList
<
QPointF
>
()
<<
((
lastPoint
+
point
)
/
2.0
);
return
QList
<
QPointF
>
()
<<
lastPoint
<<
((
lastPoint
+
point
)
/
2.0
);
}
QPointF
p0
=
mDrawnPoints
[
mDrawnPoints
.
size
()
-
2
];
QPointF
p1
=
mDrawnPoints
[
mDrawnPoints
.
size
()
-
1
];
QPointF
p2
=
point
;
...
...
src/domain/UBGraphicsStroke.h
View file @
f82a0a32
...
...
@@ -68,14 +68,13 @@ class UBGraphicsStroke
QList
<
UBGraphicsPolygonItem
*>
mPolygons
;
/// Points that were drawn (actually received through input device)
/// Points that were drawn
by the user
(actually received through input device)
QList
<
QPointF
>
mDrawnPoints
;
/// All the points (including interpolated) that are used to draw the stroke
QList
<
QPointF
>
mAllPoints
;
QPointF
mLastReceivedPoint
;
qreal
mAntiScaleRatio
;
};
#endif
/* UBGRAPHICSSTROKE_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment