Changeset View
Changeset View
Standalone View
Standalone View
core/annotations.cpp
Show First 20 Lines • Show All 1623 Lines • ▼ Show 20 Line(s) | 1623 | { | |||
---|---|---|---|---|---|
1624 | QLinkedList<NormalizedPoint> transformedLinePoints = m_transformedLinePoints; | 1624 | QLinkedList<NormalizedPoint> transformedLinePoints = m_transformedLinePoints; | ||
1625 | 1625 | | |||
1626 | if ( m_lineClosed ) // Close the path | 1626 | if ( m_lineClosed ) // Close the path | ||
1627 | transformedLinePoints.append( transformedLinePoints.first() ); | 1627 | transformedLinePoints.append( transformedLinePoints.first() ); | ||
1628 | 1628 | | |||
1629 | if ( m_lineInnerColor.isValid() ) | 1629 | if ( m_lineInnerColor.isValid() ) | ||
1630 | { | 1630 | { | ||
1631 | QPolygonF polygon; | 1631 | QPolygonF polygon; | ||
1632 | foreach ( const NormalizedPoint &p, transformedLinePoints ) | 1632 | for ( const NormalizedPoint &p : qAsConst(transformedLinePoints) ) | ||
1633 | polygon.append( QPointF( p.x, p.y ) ); | 1633 | polygon.append( QPointF( p.x, p.y ) ); | ||
1634 | 1634 | | |||
1635 | if ( polygon.containsPoint( QPointF( x, y ), Qt::WindingFill ) ) | 1635 | if ( polygon.containsPoint( QPointF( x, y ), Qt::WindingFill ) ) | ||
1636 | return 0; | 1636 | return 0; | ||
1637 | } | 1637 | } | ||
1638 | 1638 | | |||
1639 | return strokeDistance( ::distanceSqr( x, y, xScale, yScale, transformedLinePoints ), | 1639 | return strokeDistance( ::distanceSqr( x, y, xScale, yScale, transformedLinePoints ), | ||
1640 | m_style.width() * xScale / ( m_page->m_width * 2 ) ); | 1640 | m_style.width() * xScale / ( m_page->m_width * 2 ) ); | ||
▲ Show 20 Lines • Show All 445 Lines • ▼ Show 20 Line(s) | |||||
2086 | { | 2086 | { | ||
2087 | return new HighlightAnnotationPrivate(); | 2087 | return new HighlightAnnotationPrivate(); | ||
2088 | } | 2088 | } | ||
2089 | 2089 | | |||
2090 | double HighlightAnnotationPrivate::distanceSqr( double x, double y, double xScale, double yScale ) const | 2090 | double HighlightAnnotationPrivate::distanceSqr( double x, double y, double xScale, double yScale ) const | ||
2091 | { | 2091 | { | ||
2092 | NormalizedPoint point( x, y ); | 2092 | NormalizedPoint point( x, y ); | ||
2093 | double outsideDistance = DBL_MAX; | 2093 | double outsideDistance = DBL_MAX; | ||
2094 | foreach ( const HighlightAnnotation::Quad& quad, m_highlightQuads ) | 2094 | for ( const HighlightAnnotation::Quad &quad : m_highlightQuads ) | ||
aacid: i'm going to commit a patch that makes distanceSqr be const so you won't need this anymore. | |||||
2095 | { | 2095 | { | ||
2096 | QLinkedList<NormalizedPoint> pathPoints; | 2096 | QLinkedList<NormalizedPoint> pathPoints; | ||
2097 | 2097 | | |||
2098 | //first, we check if the point is within the area described by the 4 quads | 2098 | //first, we check if the point is within the area described by the 4 quads | ||
2099 | //this is the case, if the point is always on one side of each segments delimiting the polygon: | 2099 | //this is the case, if the point is always on one side of each segments delimiting the polygon: | ||
2100 | pathPoints << quad.transformedPoint( 0 ); | 2100 | pathPoints << quad.transformedPoint( 0 ); | ||
2101 | int directionVote = 0; | 2101 | int directionVote = 0; | ||
2102 | for ( int i = 1; i < 5; ++i ) | 2102 | for ( int i = 1; i < 5; ++i ) | ||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Line(s) | 2296 | { | |||
2301 | pointElement.setAttribute( QStringLiteral("y"), QString::number( point.y ) ); | 2301 | pointElement.setAttribute( QStringLiteral("y"), QString::number( point.y ) ); | ||
2302 | } | 2302 | } | ||
2303 | } | 2303 | } | ||
2304 | } | 2304 | } | ||
2305 | 2305 | | |||
2306 | double InkAnnotationPrivate::distanceSqr( double x, double y, double xScale, double yScale ) const | 2306 | double InkAnnotationPrivate::distanceSqr( double x, double y, double xScale, double yScale ) const | ||
2307 | { | 2307 | { | ||
2308 | double distance = DBL_MAX; | 2308 | double distance = DBL_MAX; | ||
2309 | foreach ( const QLinkedList<NormalizedPoint>& path, m_transformedInkPaths ) | 2309 | for ( const QLinkedList<NormalizedPoint> &path : m_transformedInkPaths ) | ||
aacid: same | |||||
2310 | { | 2310 | { | ||
2311 | const double thisDistance = ::distanceSqr( x, y, xScale, yScale, path ); | 2311 | const double thisDistance = ::distanceSqr( x, y, xScale, yScale, path ); | ||
2312 | if ( thisDistance < distance ) | 2312 | if ( thisDistance < distance ) | ||
2313 | distance = thisDistance; | 2313 | distance = thisDistance; | ||
2314 | } | 2314 | } | ||
2315 | return strokeDistance( distance, m_style.width() * xScale / ( m_page->m_width * 2 ) ); | 2315 | return strokeDistance( distance, m_style.width() * xScale / ( m_page->m_width * 2 ) ); | ||
2316 | } | 2316 | } | ||
2317 | 2317 | | |||
▲ Show 20 Lines • Show All 801 Lines • Show Last 20 Lines |
i'm going to commit a patch that makes distanceSqr be const so you won't need this anymore.