Changeset View
Changeset View
Standalone View
Standalone View
src/lib/marble/ClipPainter.cpp
Context not available. | |||||
22 | 22 | | |||
---|---|---|---|---|---|
23 | class ClipPainterPrivate | 23 | class ClipPainterPrivate | ||
24 | { | 24 | { | ||
25 | public: | 25 | public: | ||
26 | explicit ClipPainterPrivate( ClipPainter * parent ); | 26 | explicit ClipPainterPrivate( ClipPainter * parent ); | ||
27 | 27 | | |||
28 | ClipPainter * q; | 28 | ClipPainter * q; | ||
Context not available. | |||||
43 | // int m_debugNodeCount; | 43 | // int m_debugNodeCount; | ||
44 | 44 | | |||
45 | QPointF m_currentPoint; | 45 | QPointF m_currentPoint; | ||
46 | QPointF m_previousPoint; | 46 | QPointF m_previousPoint; | ||
47 | | ||||
48 | // | ||||
49 | QPointF m_currentCrossing; | ||||
50 | QPointF m_previousCrossing; | ||||
51 | | ||||
52 | int m_currentCrossingSector; | ||||
53 | int m_previousCrossingSector; | ||||
54 | | ||||
55 | qreal m_currentCrossingAngle; | ||||
56 | qreal m_previousCrossingAngle; | ||||
57 | | ||||
58 | bool m_hasCrossingPoint; | ||||
47 | 59 | | |||
48 | inline int sector( const QPointF & point ) const; | 60 | inline int sector( const QPointF & point ) const; | ||
61 | inline int borderSector( const QPointF & point ) const; | ||||
62 | inline bool isClockwise(const QPointF& pointA, const QPointF& pointB) const; | ||||
63 | inline qreal calculateAngle(const QPointF& point) const ; | ||||
49 | 64 | | |||
50 | inline QPointF clipTop( qreal m, const QPointF & point ) const; | 65 | inline QPointF clipTop( qreal m, const QPointF & point ) const; | ||
51 | inline QPointF clipLeft( qreal m, const QPointF & point ) const; | 66 | inline QPointF clipLeft( qreal m, const QPointF & point ) const; | ||
Context not available. | |||||
54 | 69 | | |||
55 | inline void initClipRect(); | 70 | inline void initClipRect(); | ||
56 | 71 | | |||
57 | inline void clipPolyObject ( const QPolygonF & sourcePolygon, | 72 | inline void clipPolyObject ( const QPolygonF & sourcePolygon, | ||
58 | QVector<QPolygonF> & clippedPolyObjects, | 73 | QVector<QPolygonF> & clippedPolyObjects, | ||
59 | bool isClosed ); | 74 | bool isClosed ); | ||
60 | 75 | | |||
76 | inline void clipPolygon( QPolygonF & clippedPolyObject, | ||||
77 | QVector<QPolygonF> & clippedPolyObjects, | ||||
78 | bool isClosed ); | ||||
79 | | ||||
61 | inline void clipMultiple( QPolygonF & clippedPolyObject, | 80 | inline void clipMultiple( QPolygonF & clippedPolyObject, | ||
62 | QVector<QPolygonF> & clippedPolyObjects, | 81 | QVector<QPolygonF> & clippedPolyObjects, | ||
63 | bool isClosed ); | 82 | bool isClosed ); | ||
64 | inline void clipOnce( QPolygonF & clippedPolyObject, | 83 | inline void clipOnce( QPolygonF & clippedPolyObject, | ||
65 | QVector<QPolygonF> & clippedPolyObjects, | 84 | QVector<QPolygonF> & clippedPolyObjects, | ||
66 | bool isClosed ); | 85 | bool isClosed ); | ||
67 | inline void clipOnceCorner( QPolygonF & clippedPolyObject, | 86 | inline void clipOnceCorner( QPolygonF & clippedPolyObject, | ||
68 | QVector<QPolygonF> & clippedPolyObjects, | 87 | QVector<QPolygonF> & clippedPolyObjects, | ||
69 | const QPointF& corner, | 88 | const QPointF& corner, | ||
Context not available. | |||||
74 | const QPointF& point, | 93 | const QPointF& point, | ||
75 | bool isClosed ) const; | 94 | bool isClosed ) const; | ||
76 | 95 | | |||
96 | inline void closePolygon( QPolygonF & clippedPolyObject, | ||||
97 | QVector<QPolygonF> & clippedPolyObjects, | ||||
98 | bool isClosed ); | ||||
77 | 99 | | |||
78 | void labelPosition( const QPolygonF & polygon, QVector<QPointF>& labelNodes, | 100 | | ||
79 | LabelPositionFlags labelPositionFlags); | 101 | void labelPosition( const QPolygonF & polygon, QVector<QPointF>& labelNodes, | ||
102 | LabelPositionFlags labelPositionFlags); | ||||
80 | 103 | | |||
81 | bool pointAllowsLabel( const QPointF& point ); | 104 | bool pointAllowsLabel( const QPointF& point ); | ||
82 | QPointF interpolateLabelPoint( const QPointF& previousPoint, | 105 | QPointF interpolateLabelPoint( const QPointF& previousPoint, | ||
83 | const QPointF& currentPoint, | 106 | const QPointF& currentPoint, | ||
84 | LabelPositionFlags labelPositionFlags ); | 107 | LabelPositionFlags labelPositionFlags ); | ||
85 | 108 | | |||
Context not available. | |||||
135 | void ClipPainter::drawPolygon ( const QPolygonF & polygon, | 158 | void ClipPainter::drawPolygon ( const QPolygonF & polygon, | ||
136 | Qt::FillRule fillRule ) | 159 | Qt::FillRule fillRule ) | ||
137 | { | 160 | { | ||
138 | if ( d->m_doClip ) { | 161 | if ( d->m_doClip ) { | ||
139 | d->initClipRect(); | 162 | d->initClipRect(); | ||
140 | QVector<QPolygonF> clippedPolyObjects; | 163 | QVector<QPolygonF> clippedPolyObjects; | ||
141 | 164 | | |||
142 | d->clipPolyObject( polygon, clippedPolyObjects, true ); | 165 | d->clipPolyObject( polygon, clippedPolyObjects, true ); | ||
143 | 166 | | |||
144 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | 167 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | ||
145 | if ( clippedPolyObject.size() > 2 ) { | 168 | if ( clippedPolyObject.size() > 2 ) { | ||
146 | // mDebug() << "Size: " << clippedPolyObject.size(); | 169 | // mDebug() << "Size: " << clippedPolyObject.size(); | ||
147 | if (d->m_debugPolygonsLevel) { | 170 | if (d->m_debugPolygonsLevel) { | ||
Context not available. | |||||
193 | 216 | | |||
194 | d->clipPolyObject( polygon, clippedPolyObjects, false ); | 217 | d->clipPolyObject( polygon, clippedPolyObjects, false ); | ||
195 | 218 | | |||
196 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | 219 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | ||
197 | if ( clippedPolyObject.size() > 1 ) { | 220 | if ( clippedPolyObject.size() > 1 ) { | ||
198 | if (d->m_debugPolygonsLevel) { | 221 | if (d->m_debugPolygonsLevel) { | ||
199 | QPen pen = QPainter::pen(); | 222 | QPen pen = QPainter::pen(); | ||
Context not available. | |||||
245 | 268 | | |||
246 | d->clipPolyObject( polygon, clippedPolyObjects, false ); | 269 | d->clipPolyObject( polygon, clippedPolyObjects, false ); | ||
247 | 270 | | |||
248 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | 271 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | ||
249 | if (d->m_debugPolygonsLevel) { | 272 | if (d->m_debugPolygonsLevel) { | ||
250 | QPen pen = QPainter::pen(); | 273 | QPen pen = QPainter::pen(); | ||
251 | QPen originalPen = pen; | 274 | QPen originalPen = pen; | ||
Context not available. | |||||
316 | if ( currentAllowsLabel ) { | 339 | if ( currentAllowsLabel ) { | ||
317 | // As polygon.size() > 0 it's ensured that it-1 exists. | 340 | // As polygon.size() > 0 it's ensured that it-1 exists. | ||
318 | QPointF node = interpolateLabelPoint( polygon.at( it -1 ), polygon.at( it ), | 341 | QPointF node = interpolateLabelPoint( polygon.at( it -1 ), polygon.at( it ), | ||
319 | labelPositionFlags ); | 342 | labelPositionFlags ); | ||
320 | if ( node != QPointF( -1.0, -1.0 ) ) { | 343 | if ( node != QPointF( -1.0, -1.0 ) ) { | ||
321 | labelNodes << node; | 344 | labelNodes << node; | ||
322 | } | 345 | } | ||
Context not available. | |||||
336 | 359 | | |||
337 | if ( currentAllowsLabel ) { | 360 | if ( currentAllowsLabel ) { | ||
338 | QPointF node = interpolateLabelPoint( polygon.at( it + 1 ), polygon.at( it ), | 361 | QPointF node = interpolateLabelPoint( polygon.at( it + 1 ), polygon.at( it ), | ||
339 | labelPositionFlags ); | 362 | labelPositionFlags ); | ||
340 | if ( node != QPointF( -1.0, -1.0 ) ) { | 363 | if ( node != QPointF( -1.0, -1.0 ) ) { | ||
341 | labelNodes << node; | 364 | labelNodes << node; | ||
342 | } | 365 | } | ||
Context not available. | |||||
349 | bool ClipPainterPrivate::pointAllowsLabel( const QPointF& point ) | 372 | bool ClipPainterPrivate::pointAllowsLabel( const QPointF& point ) | ||
350 | { | 373 | { | ||
351 | 374 | | |||
352 | if ( point.x() > m_labelAreaMargin && point.x() < q->viewport().width() - m_labelAreaMargin | 375 | if ( point.x() > m_labelAreaMargin && point.x() < q->viewport().width() - m_labelAreaMargin | ||
353 | && point.y() > m_labelAreaMargin && point.y() < q->viewport().height() - m_labelAreaMargin ) { | 376 | && point.y() > m_labelAreaMargin && point.y() < q->viewport().height() - m_labelAreaMargin ) { | ||
354 | return true; | 377 | return true; | ||
355 | } | 378 | } | ||
Context not available. | |||||
365 | if ( labelPositionFlags.testFlag( IgnoreXMargin ) ) { | 388 | if ( labelPositionFlags.testFlag( IgnoreXMargin ) ) { | ||
366 | return QPointF( -1.0, -1.0 ); | 389 | return QPointF( -1.0, -1.0 ); | ||
367 | } | 390 | } | ||
368 | return QPointF( m_labelAreaMargin, | 391 | return QPointF( m_labelAreaMargin, | ||
369 | previousPoint.y() + ( m_labelAreaMargin - previousPoint.x() ) * m ); | 392 | previousPoint.y() + ( m_labelAreaMargin - previousPoint.x() ) * m ); | ||
370 | } | 393 | } | ||
371 | else if ( previousPoint.x() >= q->viewport().width() - m_labelAreaMargin ) { | 394 | else if ( previousPoint.x() >= q->viewport().width() - m_labelAreaMargin ) { | ||
Context not available. | |||||
373 | return QPointF( -1.0, -1.0 ); | 396 | return QPointF( -1.0, -1.0 ); | ||
374 | } | 397 | } | ||
375 | return QPointF( q->viewport().width() - m_labelAreaMargin, | 398 | return QPointF( q->viewport().width() - m_labelAreaMargin, | ||
376 | previousPoint.y() - | 399 | previousPoint.y() - | ||
377 | ( previousPoint.x() - q->viewport().width() + m_labelAreaMargin ) * m ); | 400 | ( previousPoint.x() - q->viewport().width() + m_labelAreaMargin ) * m ); | ||
378 | } | 401 | } | ||
379 | 402 | | |||
380 | if ( previousPoint.y() <= m_labelAreaMargin ) { | 403 | if ( previousPoint.y() <= m_labelAreaMargin ) { | ||
381 | if ( labelPositionFlags.testFlag( IgnoreYMargin ) ) { | 404 | if ( labelPositionFlags.testFlag( IgnoreYMargin ) ) { | ||
382 | return QPointF( -1.0, -1.0 ); | 405 | return QPointF( -1.0, -1.0 ); | ||
383 | } | 406 | } | ||
384 | return QPointF( previousPoint.x() + ( m_labelAreaMargin - previousPoint.y() ) / m, | 407 | return QPointF( previousPoint.x() + ( m_labelAreaMargin - previousPoint.y() ) / m, | ||
385 | m_labelAreaMargin ); | 408 | m_labelAreaMargin ); | ||
386 | } | 409 | } | ||
387 | else if ( previousPoint.y() >= q->viewport().height() - m_labelAreaMargin ) { | 410 | else if ( previousPoint.y() >= q->viewport().height() - m_labelAreaMargin ) { | ||
388 | if ( labelPositionFlags.testFlag( IgnoreYMargin ) ) { | 411 | if ( labelPositionFlags.testFlag( IgnoreYMargin ) ) { | ||
389 | return QPointF( -1.0, -1.0 ); | 412 | return QPointF( -1.0, -1.0 ); | ||
390 | } | 413 | } | ||
391 | return QPointF( previousPoint.x() - | 414 | return QPointF( previousPoint.x() - | ||
392 | ( previousPoint.y() - q->viewport().height() + m_labelAreaMargin ) / m, | 415 | ( previousPoint.y() - q->viewport().height() + m_labelAreaMargin ) / m, | ||
393 | q->viewport().height() - m_labelAreaMargin ); | 416 | q->viewport().height() - m_labelAreaMargin ); | ||
394 | } | 417 | } | ||
395 | 418 | | |||
396 | // mDebug() << Q_FUNC_INFO << "Previous and current node position are allowed!"; | 419 | // mDebug() << Q_FUNC_INFO << "Previous and current node position are allowed!"; | ||
397 | 420 | | |||
398 | return QPointF( -1.0, -1.0 ); | 421 | return QPointF( -1.0, -1.0 ); | ||
399 | } | 422 | } | ||
Context not available. | |||||
407 | m_currentSector(4), | 430 | m_currentSector(4), | ||
408 | m_previousSector(4), | 431 | m_previousSector(4), | ||
409 | m_currentPoint(QPointF()), | 432 | m_currentPoint(QPointF()), | ||
410 | m_previousPoint(QPointF()), | 433 | m_previousPoint(QPointF()), | ||
411 | m_labelAreaMargin(10.0), | 434 | m_labelAreaMargin(10.0), | ||
412 | m_debugPolygonsLevel(0) | 435 | m_debugPolygonsLevel(0) | ||
413 | { | 436 | { | ||
Context not available. | |||||
416 | 439 | | |||
417 | void ClipPainterPrivate::initClipRect () | 440 | void ClipPainterPrivate::initClipRect () | ||
418 | { | 441 | { | ||
419 | qreal penHalfWidth = q->pen().widthF() / 2.0 + 1.0; | 442 | // qreal penHalfWidth = q->pen().widthF() / 2.0 + 1.0; | ||
420 | 443 | | |||
421 | m_left = -penHalfWidth; | 444 | m_left = 20; | ||
422 | m_right = (qreal)(q->device()->width()) + penHalfWidth; | 445 | m_right = (qreal)(q->device()->width()) - 20; | ||
423 | m_top = -penHalfWidth; | 446 | m_top = 20; | ||
424 | m_bottom = (qreal)(q->device()->height()) + penHalfWidth; | 447 | m_bottom = (qreal)(q->device()->height()) - 20; | ||
425 | } | 448 | } | ||
426 | 449 | | |||
427 | qreal ClipPainterPrivate::_m( const QPointF & start, const QPointF & end ) | 450 | qreal ClipPainterPrivate::_m( const QPointF & start, const QPointF & end ) | ||
Context not available. | |||||
429 | qreal divisor = end.x() - start.x(); | 452 | qreal divisor = end.x() - start.x(); | ||
430 | if ( std::fabs( divisor ) < 0.000001 ) { | 453 | if ( std::fabs( divisor ) < 0.000001 ) { | ||
431 | // this is in screencoordinates so the difference | 454 | // this is in screencoordinates so the difference | ||
432 | // between 0, 0.000001 and -0.000001 isn't visible at all | 455 | // between 0, 0.000001 and -0.000001 isn't visible at all | ||
433 | divisor = 0.000001; | 456 | divisor = 0.000001; | ||
434 | } | 457 | } | ||
435 | 458 | | |||
436 | return ( end.y() - start.y() ) | 459 | return ( end.y() - start.y() ) | ||
437 | / divisor; | 460 | / divisor; | ||
438 | } | 461 | } | ||
439 | 462 | | |||
440 | 463 | | |||
Context not available. | |||||
487 | // By adding xSector and ySector we get a | 510 | // By adding xSector and ySector we get a | ||
488 | // sector number of the values shown in the ASCII-art graph above. | 511 | // sector number of the values shown in the ASCII-art graph above. | ||
489 | return ySector + xSector; | 512 | return ySector + xSector; | ||
513 | } | ||||
490 | 514 | | |||
515 | // Determines that the point on which border or corner is exactly on, 4 otherwise. | ||||
516 | int ClipPainterPrivate::borderSector( const QPointF & point ) const | ||||
517 | { | ||||
518 | int xSector = 1; | ||||
519 | if ( point.x() == m_left ) | ||||
520 | xSector = 0; | ||||
521 | else if ( point.x() == m_right ) | ||||
522 | xSector = 2; | ||||
523 | | ||||
524 | int ySector = 3; | ||||
525 | if ( point.y() == m_top ) | ||||
526 | ySector = 0; | ||||
527 | else if ( point.y() == m_bottom ) | ||||
528 | ySector = 6; | ||||
529 | | ||||
530 | return ySector + xSector; | ||||
531 | } | ||||
532 | | ||||
533 | qreal ClipPainterPrivate::calculateAngle(const QPointF& point) const | ||||
534 | { | ||||
535 | QPointF middlePoint((m_left + m_right)/2.0, -(m_top + m_bottom)/2.0); | ||||
536 | | ||||
537 | qreal angle = atan2(-point.y() - middlePoint.y(), point.x() - middlePoint.x()) * RAD2DEG; | ||||
538 | | ||||
539 | //if(angle < 0) angle += 360.0; | ||||
540 | | ||||
541 | return angle; | ||||
542 | } | ||||
543 | | ||||
544 | bool ClipPainterPrivate::isClockwise(const QPointF& pointA, const QPointF& pointB) const | ||||
545 | { | ||||
546 | QPointF middlePoint((m_left + m_right)/2.0, -(m_top + m_bottom)/2.0); | ||||
547 | | ||||
548 | QPointF vecA(QPointF(pointA.x(), -pointA.y()) - middlePoint); | ||||
549 | QPointF vecB(QPointF(pointB.x(), -pointB.y()) - middlePoint); | ||||
550 | | ||||
551 | qreal angle = atan2(vecA.x()*vecB.y() - vecB.x()*vecA.y(), vecA.x()*vecB.x() + vecA.y()*vecB.y()) * RAD2DEG; | ||||
552 | mDebug() << "isClockwise angle:" << angle; | ||||
553 | return angle < 0; | ||||
491 | } | 554 | } | ||
492 | 555 | | |||
493 | void ClipPainterPrivate::clipPolyObject ( const QPolygonF & polygon, | 556 | void ClipPainterPrivate::clipPolyObject ( const QPolygonF & polygon, | ||
Context not available. | |||||
496 | { | 559 | { | ||
497 | // mDebug() << "ClipPainter enabled." ; | 560 | // mDebug() << "ClipPainter enabled." ; | ||
498 | 561 | | |||
499 | // Only create a new polyObject as soon as we know for sure that | 562 | // Only create a new polyObject as soon as we know for sure that | ||
500 | // the current point is on the screen. | 563 | // the current point is on the screen. | ||
501 | QPolygonF clippedPolyObject = QPolygonF(); | 564 | QPolygonF clippedPolyObject = QPolygonF(); | ||
502 | 565 | | |||
503 | const QVector<QPointF>::const_iterator itStartPoint = polygon.constBegin(); | 566 | const QVector<QPointF>::const_iterator itStartPoint = polygon.constBegin(); | ||
Context not available. | |||||
510 | 573 | | |||
511 | bool processingLastNode = false; | 574 | bool processingLastNode = false; | ||
512 | 575 | | |||
576 | m_previousCrossing = QPointF(0,0); | ||||
577 | m_previousCrossingSector = -1; | ||||
578 | m_currentCrossingSector = -1; | ||||
579 | m_previousCrossingAngle = 0; | ||||
580 | m_currentCrossingAngle = 0; | ||||
581 | m_hasCrossingPoint = false; | ||||
582 | | ||||
583 | mDebug() << "\n"; | ||||
584 | mDebug() << "New polygon"; | ||||
513 | while ( itPoint != itEndPoint ) { | 585 | while ( itPoint != itEndPoint ) { | ||
514 | m_currentPoint = (*itPoint); | 586 | m_currentPoint = (*itPoint); | ||
515 | // mDebug() << "m_currentPoint.x()" << m_currentPoint.x() << "m_currentPOint.y()" << m_currentPoint.y(); | 587 | // mDebug() << "m_currentPoint.x()" << m_currentPoint.x() << "m_currentPOint.y()" << m_currentPoint.y(); | ||
Context not available. | |||||
537 | // screen but not both. Hence we only need to clip once and require | 609 | // screen but not both. Hence we only need to clip once and require | ||
538 | // only one interpolation for both cases. | 610 | // only one interpolation for both cases. | ||
539 | 611 | | |||
540 | clipOnce( clippedPolyObject, clippedPolyObjects, isClosed ); | 612 | m_hasCrossingPoint = true; | ||
541 | } | 613 | | ||
542 | else { | 614 | if(!isClosed) { | ||
615 | clipOnce( clippedPolyObject, clippedPolyObjects, isClosed ); | ||||
616 | } else { | ||||
617 | clipPolygon( clippedPolyObject, clippedPolyObjects, isClosed ); | ||||
618 | } | ||||
619 | | ||||
620 | } else if (!isClosed/* || m_hasCrossingPoint */) { | ||||
543 | // This case mostly deals with lines that reach from one | 621 | // This case mostly deals with lines that reach from one | ||
544 | // sector that is located off screen to another one that | 622 | // sector that is located off screen to another one that | ||
545 | // is located off screen. In this situation the line | 623 | // is located off screen. In this situation the line | ||
546 | // can get clipped once, twice, or not at all. | 624 | // can get clipped once, twice, or not at all. | ||
547 | clipMultiple( clippedPolyObject, clippedPolyObjects, isClosed ); | 625 | clipMultiple( clippedPolyObject, clippedPolyObjects, isClosed ); | ||
548 | } | 626 | } | ||
Context not available. | |||||
569 | } | 647 | } | ||
570 | ++itPoint; | 648 | ++itPoint; | ||
571 | 649 | | |||
572 | if ( itPoint == itEndPoint && isClosed ) { | 650 | if ( itPoint == itEndPoint && isClosed ) { | ||
651 | | ||||
652 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
653 | | ||||
573 | itPoint = itStartPoint; | 654 | itPoint = itStartPoint; | ||
574 | processingLastNode = true; | 655 | processingLastNode = true; | ||
575 | } | 656 | } | ||
Context not available. | |||||
581 | } | 662 | } | ||
582 | } | 663 | } | ||
583 | 664 | | |||
665 | void ClipPainterPrivate::clipPolygon( QPolygonF & clippedPolyObject, | ||||
666 | QVector<QPolygonF> & clippedPolyObjects, | ||||
667 | bool isClosed ) | ||||
668 | { | ||||
669 | clipOnce(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
670 | | ||||
671 | if (isClosed && clippedPolyObject.size() > 1) { | ||||
672 | if (m_currentSector != 4 && m_previousSector == 4) { | ||||
673 | // Disappearing | ||||
674 | | ||||
675 | if(m_currentCrossingSector != -1) { | ||||
676 | m_previousCrossing = m_currentCrossing; | ||||
677 | m_currentCrossing = clippedPolyObject.last(); | ||||
678 | | ||||
679 | m_previousCrossingSector = m_currentCrossingSector; | ||||
680 | m_currentCrossingSector = borderSector(m_currentCrossing); | ||||
681 | | ||||
682 | m_previousCrossingAngle = m_currentCrossingAngle; | ||||
683 | m_currentCrossingAngle = calculateAngle(m_currentCrossing); | ||||
684 | | ||||
685 | switch (m_currentCrossingSector) { | ||||
686 | case 1: | ||||
687 | switch(m_previousCrossingSector) { | ||||
688 | case 1: | ||||
689 | break; | ||||
690 | case 5: | ||||
691 | if(borderSector(clippedPolyObject.at(clippedPolyObject.size() - 2)) != 4) { | ||||
692 | clippedPolyObject << QPointF(m_right, m_top); | ||||
693 | } | ||||
694 | break; | ||||
695 | case 7: | ||||
696 | break; | ||||
697 | case 3: | ||||
698 | break; | ||||
699 | default: | ||||
700 | break; | ||||
701 | } | ||||
702 | break; | ||||
703 | case 5: | ||||
704 | switch(m_previousCrossingSector) { | ||||
705 | case 1: | ||||
706 | break; | ||||
707 | case 5: | ||||
708 | break; | ||||
709 | case 7: | ||||
710 | break; | ||||
711 | case 3: | ||||
712 | break; | ||||
713 | default: | ||||
714 | break; | ||||
715 | } | ||||
716 | | ||||
717 | break; | ||||
718 | case 7: | ||||
719 | switch(m_previousCrossingSector) { | ||||
720 | case 1: | ||||
721 | break; | ||||
722 | case 5: | ||||
723 | if(borderSector(clippedPolyObject.at(clippedPolyObject.size() - 2)) != 4) { | ||||
724 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
725 | } | ||||
726 | break; | ||||
727 | case 7: | ||||
728 | break; | ||||
729 | case 3: | ||||
730 | break; | ||||
731 | default: | ||||
732 | break; | ||||
733 | } | ||||
734 | | ||||
735 | break; | ||||
736 | case 3: | ||||
737 | switch(m_previousCrossingSector) { | ||||
738 | case 1: | ||||
739 | if(borderSector(clippedPolyObject.at(clippedPolyObject.size() - 2)) != 4) { | ||||
740 | clippedPolyObject << QPointF(m_left, m_top); | ||||
741 | } | ||||
742 | break; | ||||
743 | case 5: | ||||
744 | break; | ||||
745 | case 7: | ||||
746 | break; | ||||
747 | case 3: | ||||
748 | break; | ||||
749 | default: | ||||
750 | break; | ||||
751 | } | ||||
752 | | ||||
753 | break; | ||||
754 | default: | ||||
755 | break; | ||||
756 | } | ||||
757 | } else { | ||||
758 | m_currentCrossing = clippedPolyObject.last(); | ||||
759 | m_currentCrossingSector = borderSector(m_currentCrossing); | ||||
760 | m_currentCrossingAngle = calculateAngle(m_currentCrossing); | ||||
761 | if(m_currentCrossingSector == borderSector(clippedPolyObject.first())) { | ||||
762 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
763 | } | ||||
764 | } | ||||
765 | | ||||
766 | mDebug() << "Disappearing"; | ||||
767 | mDebug() << "m_currentCrossingSector:" << m_currentCrossingSector; | ||||
768 | mDebug() << "m_previousCrossingSector:" << m_previousCrossingSector; | ||||
769 | mDebug() << "m_currentCrossingAngle:" << m_currentCrossingAngle; | ||||
770 | mDebug() << "m_previousCrossingAngle:" << m_previousCrossingAngle; | ||||
771 | mDebug() << "Angle delta:" << m_currentCrossingAngle - m_previousCrossingAngle; | ||||
772 | } else if (m_currentSector == 4 && m_previousSector != 4) { | ||||
773 | // Appearing | ||||
774 | | ||||
775 | if(m_currentCrossingSector != -1) { | ||||
776 | m_previousCrossing = m_currentCrossing; | ||||
777 | m_currentCrossing = clippedPolyObject.last(); | ||||
778 | | ||||
779 | m_previousCrossingSector = m_currentCrossingSector; | ||||
780 | m_currentCrossingSector = borderSector(m_currentCrossing); | ||||
781 | | ||||
782 | m_previousCrossingAngle = m_currentCrossingAngle; | ||||
783 | m_currentCrossingAngle = calculateAngle(m_currentCrossing); | ||||
784 | | ||||
785 | switch (m_currentCrossingSector) { | ||||
786 | case 1: | ||||
787 | switch(m_previousCrossingSector) { | ||||
788 | case 1: | ||||
789 | if(!isClockwise(m_previousCrossing, m_currentCrossing)) { | ||||
790 | clippedPolyObject.removeLast(); | ||||
791 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
792 | clippedPolyObjects << clippedPolyObject; | ||||
793 | clippedPolyObject = QPolygonF(); | ||||
794 | clippedPolyObject << m_currentCrossing; | ||||
795 | } | ||||
796 | break; | ||||
797 | case 5: | ||||
798 | clippedPolyObject.removeLast(); | ||||
799 | clippedPolyObjects << clippedPolyObject; | ||||
800 | clippedPolyObject = QPolygonF(); | ||||
801 | clippedPolyObject << m_currentCrossing; | ||||
802 | break; | ||||
803 | case 7: | ||||
804 | break; | ||||
805 | case 3: | ||||
806 | clippedPolyObject.removeLast(); | ||||
807 | clippedPolyObject << QPointF(m_left, m_top); | ||||
808 | clippedPolyObject << m_currentCrossing; | ||||
809 | break; | ||||
810 | default: | ||||
811 | clippedPolyObject.removeLast(); | ||||
812 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
813 | clippedPolyObjects << clippedPolyObject; | ||||
814 | clippedPolyObject = QPolygonF(); | ||||
815 | clippedPolyObject << m_currentCrossing; | ||||
816 | break; | ||||
817 | } | ||||
818 | break; | ||||
819 | case 5: | ||||
820 | switch(m_previousCrossingSector) { | ||||
821 | case 1: | ||||
822 | break; | ||||
823 | case 5: | ||||
824 | if(!isClockwise(m_previousCrossing, m_currentCrossing)) { | ||||
825 | clippedPolyObject.removeLast(); | ||||
826 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
827 | clippedPolyObjects << clippedPolyObject; | ||||
828 | clippedPolyObject = QPolygonF(); | ||||
829 | clippedPolyObject << m_currentCrossing; | ||||
830 | } | ||||
831 | break; | ||||
832 | case 7: | ||||
833 | clippedPolyObject.removeLast(); | ||||
834 | clippedPolyObjects << clippedPolyObject; | ||||
835 | clippedPolyObject = QPolygonF(); | ||||
836 | clippedPolyObject << m_currentCrossing; | ||||
837 | break; | ||||
838 | case 3: | ||||
839 | break; | ||||
840 | default: | ||||
841 | clippedPolyObject.removeLast(); | ||||
842 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
843 | clippedPolyObjects << clippedPolyObject; | ||||
844 | clippedPolyObject = QPolygonF(); | ||||
845 | clippedPolyObject << m_currentCrossing; | ||||
846 | break; | ||||
847 | } | ||||
848 | | ||||
849 | break; | ||||
850 | case 7: | ||||
851 | switch(m_previousCrossingSector) { | ||||
852 | case 1: | ||||
853 | break; | ||||
854 | case 5: | ||||
855 | clippedPolyObject.removeLast(); | ||||
856 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
857 | clippedPolyObject << m_currentCrossing; | ||||
858 | break; | ||||
859 | case 7: | ||||
860 | if(!isClockwise(m_previousCrossing, m_currentCrossing)) { | ||||
861 | clippedPolyObject.removeLast(); | ||||
862 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
863 | clippedPolyObjects << clippedPolyObject; | ||||
864 | clippedPolyObject = QPolygonF(); | ||||
865 | clippedPolyObject << m_currentCrossing; | ||||
866 | } | ||||
867 | break; | ||||
868 | case 3: | ||||
869 | clippedPolyObject.removeLast(); | ||||
870 | clippedPolyObjects << clippedPolyObject; | ||||
871 | clippedPolyObject = QPolygonF(); | ||||
872 | clippedPolyObject << m_currentCrossing; | ||||
873 | break; | ||||
874 | default: | ||||
875 | clippedPolyObject.removeLast(); | ||||
876 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
877 | clippedPolyObjects << clippedPolyObject; | ||||
878 | clippedPolyObject = QPolygonF(); | ||||
879 | clippedPolyObject << m_currentCrossing; | ||||
880 | break; | ||||
881 | } | ||||
882 | | ||||
883 | break; | ||||
884 | case 3: | ||||
885 | switch(m_previousCrossingSector) { | ||||
886 | case 1: | ||||
887 | clippedPolyObject.removeLast(); | ||||
888 | clippedPolyObjects << clippedPolyObject; | ||||
889 | clippedPolyObject = QPolygonF(); | ||||
890 | clippedPolyObject << m_currentCrossing; | ||||
891 | break; | ||||
892 | case 5: | ||||
893 | clippedPolyObject.removeLast(); | ||||
894 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
895 | clippedPolyObject << QPointF(m_left, m_bottom); | ||||
896 | clippedPolyObject << m_currentCrossing; | ||||
897 | break; | ||||
898 | case 7: | ||||
899 | clippedPolyObject.removeLast(); | ||||
900 | clippedPolyObject << QPointF(m_left, m_bottom); | ||||
901 | clippedPolyObject << m_currentCrossing; | ||||
902 | break; | ||||
903 | case 3: | ||||
904 | if(!isClockwise(m_previousCrossing, m_currentCrossing)) { | ||||
905 | clippedPolyObject.removeLast(); | ||||
906 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
907 | clippedPolyObjects << clippedPolyObject; | ||||
908 | clippedPolyObject = QPolygonF(); | ||||
909 | clippedPolyObject << m_currentCrossing; | ||||
910 | } | ||||
911 | break; | ||||
912 | default: | ||||
913 | clippedPolyObject.removeLast(); | ||||
914 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
915 | clippedPolyObjects << clippedPolyObject; | ||||
916 | clippedPolyObject = QPolygonF(); | ||||
917 | clippedPolyObject << m_currentCrossing; | ||||
918 | break; | ||||
919 | } | ||||
920 | | ||||
921 | break; | ||||
922 | default: | ||||
923 | break; | ||||
924 | } | ||||
925 | | ||||
926 | } else { | ||||
927 | m_currentCrossing = clippedPolyObject.last(); | ||||
928 | m_currentCrossingSector = borderSector(m_currentCrossing); | ||||
929 | m_currentCrossingAngle = calculateAngle(m_currentCrossing); | ||||
930 | } | ||||
931 | | ||||
932 | mDebug() << "Appearing"; | ||||
933 | mDebug() << "m_currentCrossingSector:" << m_currentCrossingSector; | ||||
934 | mDebug() << "m_previousCrossingSector:" << m_previousCrossingSector; | ||||
935 | mDebug() << "m_currentCrossingAngle:" << m_currentCrossingAngle; | ||||
936 | mDebug() << "m_previousCrossingAngle:" << m_previousCrossingAngle; | ||||
937 | mDebug() << "Angle delta:" << m_currentCrossingAngle - m_previousCrossingAngle; | ||||
938 | } | ||||
939 | } | ||||
940 | } | ||||
941 | | ||||
942 | void ClipPainterPrivate::closePolygon( QPolygonF & clippedPolyObject, | ||||
943 | QVector<QPolygonF> & clippedPolyObjects, | ||||
944 | bool isClosed ) | ||||
945 | { | ||||
946 | Q_UNUSED(isClosed) | ||||
947 | Q_UNUSED(clippedPolyObjects) | ||||
948 | | ||||
949 | if(!clippedPolyObject.isEmpty()) { | ||||
950 | | ||||
951 | int firstPointSector = borderSector(clippedPolyObject.first()); | ||||
952 | | ||||
953 | switch (m_currentCrossingSector) { | ||||
954 | case 1: | ||||
955 | switch(firstPointSector) { | ||||
956 | case 1: | ||||
957 | break; | ||||
958 | case 5: | ||||
959 | clippedPolyObject << QPointF(m_right, m_top); | ||||
960 | break; | ||||
961 | case 7: | ||||
962 | clippedPolyObject << QPointF(m_right, m_top); | ||||
963 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
964 | break; | ||||
965 | case 3: | ||||
966 | break; | ||||
967 | case -1: | ||||
968 | break; | ||||
969 | default: | ||||
970 | break; | ||||
971 | } | ||||
972 | break; | ||||
973 | case 5: | ||||
974 | switch(firstPointSector) { | ||||
975 | case 1: | ||||
976 | break; | ||||
977 | case 5: | ||||
978 | break; | ||||
979 | case 7: | ||||
980 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
981 | break; | ||||
982 | case 3: | ||||
983 | break; | ||||
984 | case -1: | ||||
985 | break; | ||||
986 | default: | ||||
987 | break; | ||||
988 | } | ||||
989 | | ||||
990 | break; | ||||
991 | case 7: | ||||
992 | switch(firstPointSector) { | ||||
993 | case 1: | ||||
994 | clippedPolyObject << QPointF(m_left, m_bottom); | ||||
995 | clippedPolyObject << QPointF(m_left, m_top); | ||||
996 | break; | ||||
997 | case 5: | ||||
998 | if(m_previousSector == -1) { | ||||
999 | clippedPolyObject << QPointF(m_left, m_bottom); | ||||
1000 | clippedPolyObject << QPointF(m_left, m_top); | ||||
1001 | clippedPolyObject << QPointF(m_right, m_top); | ||||
1002 | } | ||||
1003 | break; | ||||
1004 | case 7: | ||||
1005 | if(!isClockwise(m_currentCrossing, clippedPolyObject.first())) { | ||||
1006 | clippedPolyObject.removeLast(); | ||||
1007 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
1008 | clippedPolyObjects << clippedPolyObject; | ||||
1009 | clippedPolyObject = QPolygonF(); | ||||
1010 | clippedPolyObject << m_currentCrossing; | ||||
1011 | } | ||||
1012 | break; | ||||
1013 | case 3: | ||||
1014 | clippedPolyObject << QPointF(m_left, m_bottom); | ||||
1015 | break; | ||||
1016 | case -1: | ||||
1017 | break; | ||||
1018 | default: | ||||
1019 | break; | ||||
1020 | } | ||||
1021 | | ||||
1022 | break; | ||||
1023 | case 3: | ||||
1024 | switch(firstPointSector) { | ||||
1025 | case 1: | ||||
1026 | clippedPolyObject << QPointF(m_left, m_top); | ||||
1027 | break; | ||||
1028 | case 5: | ||||
1029 | clippedPolyObject << QPointF(m_left, m_top); | ||||
1030 | clippedPolyObject << QPointF(m_right, m_top); | ||||
1031 | break; | ||||
1032 | case 7: | ||||
1033 | if(m_previousSector == -1) { | ||||
1034 | clippedPolyObject << QPointF(m_left, m_top); | ||||
1035 | clippedPolyObject << QPointF(m_right, m_top); | ||||
1036 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
1037 | } | ||||
1038 | break; | ||||
1039 | case 3: | ||||
1040 | break; | ||||
1041 | default: | ||||
1042 | break; | ||||
1043 | } | ||||
1044 | | ||||
1045 | break; | ||||
1046 | default: | ||||
1047 | break; | ||||
1048 | } | ||||
1049 | } | ||||
1050 | } | ||||
1051 | | ||||
1052 | | ||||
584 | 1053 | | |||
585 | void ClipPainterPrivate::clipMultiple( QPolygonF & clippedPolyObject, | 1054 | void ClipPainterPrivate::clipMultiple( QPolygonF & clippedPolyObject, | ||
586 | QVector<QPolygonF> & clippedPolyObjects, | 1055 | QVector<QPolygonF> & clippedPolyObjects, | ||
Context not available. | |||||
589 | Q_UNUSED( clippedPolyObjects ) | 1058 | Q_UNUSED( clippedPolyObjects ) | ||
590 | Q_UNUSED( isClosed ) | 1059 | Q_UNUSED( isClosed ) | ||
591 | 1060 | | |||
592 | // Take care of adding nodes in the image corners if the iterator | 1061 | // Take care of adding nodes in the image corners if the iterator | ||
593 | // traverses off screen sections. | 1062 | // traverses off screen sections. | ||
594 | 1063 | | |||
595 | qreal m = _m( m_previousPoint, m_currentPoint ); | 1064 | qreal m = _m( m_previousPoint, m_currentPoint ); | ||
Context not available. | |||||
608 | } | 1077 | } | ||
609 | if ( pointTop.x() >= m_left && pointTop.x() < m_right ) | 1078 | if ( pointTop.x() >= m_left && pointTop.x() < m_right ) | ||
610 | clippedPolyObject << pointTop; | 1079 | clippedPolyObject << pointTop; | ||
611 | if ( pointLeft.y() > m_top ) | 1080 | if ( pointLeft.y() > m_top ) | ||
612 | clippedPolyObject << pointLeft; | 1081 | clippedPolyObject << pointLeft; | ||
613 | } | 1082 | } | ||
614 | else if ( m_previousSector == 7 ) { | 1083 | else if ( m_previousSector == 7 ) { | ||
Context not available. | |||||
621 | } else { | 1090 | } else { | ||
622 | clippedPolyObject << QPointF( m_left, m_bottom ); | 1091 | clippedPolyObject << QPointF( m_left, m_bottom ); | ||
623 | } | 1092 | } | ||
624 | if ( pointLeft.y() >= m_top && pointLeft.y() < m_bottom ) | 1093 | if ( pointLeft.y() >= m_top && pointLeft.y() < m_bottom ) | ||
625 | clippedPolyObject << pointLeft; | 1094 | clippedPolyObject << pointLeft; | ||
626 | if ( pointTop.x() > m_left ) | 1095 | if ( pointTop.x() > m_left ) | ||
627 | clippedPolyObject << pointTop; | 1096 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
634 | 1103 | | |||
635 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | 1104 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | ||
636 | clippedPolyObject << pointBottom; | 1105 | clippedPolyObject << pointBottom; | ||
637 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | 1106 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | ||
638 | clippedPolyObject << pointRight; | 1107 | clippedPolyObject << pointRight; | ||
639 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | 1108 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | ||
640 | clippedPolyObject << pointTop; | 1109 | clippedPolyObject << pointTop; | ||
641 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | 1110 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | ||
642 | clippedPolyObject << pointLeft; | 1111 | clippedPolyObject << pointLeft; | ||
643 | 1112 | | |||
644 | if ( pointBottom.x() <= m_left && pointLeft.y() >= m_bottom ) | 1113 | if ( pointBottom.x() <= m_left && pointLeft.y() >= m_bottom ) | ||
645 | clippedPolyObject << QPointF( m_left, m_bottom ); | 1114 | clippedPolyObject << QPointF( m_left, m_bottom ); | ||
646 | if ( pointTop.x() >= m_right && pointRight.y() <= m_top ) | 1115 | if ( pointTop.x() >= m_right && pointRight.y() <= m_top ) | ||
Context not available. | |||||
682 | 1151 | | |||
683 | if ( pointBottom.x() > m_left ) | 1152 | if ( pointBottom.x() > m_left ) | ||
684 | clippedPolyObject << pointBottom; | 1153 | clippedPolyObject << pointBottom; | ||
685 | if ( pointLeft.y() > m_top && pointLeft.y() <= m_bottom ) | 1154 | if ( pointLeft.y() > m_top && pointLeft.y() <= m_bottom ) | ||
686 | clippedPolyObject << pointLeft; | 1155 | clippedPolyObject << pointLeft; | ||
687 | if ( pointTop.x() > m_left ) { | 1156 | if ( pointTop.x() > m_left ) { | ||
688 | clippedPolyObject << pointTop; | 1157 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
701 | 1170 | | |||
702 | if ( pointBottom.x() < m_right ) | 1171 | if ( pointBottom.x() < m_right ) | ||
703 | clippedPolyObject << pointBottom; | 1172 | clippedPolyObject << pointBottom; | ||
704 | if ( pointRight.y() > m_top && pointRight.y() <= m_bottom ) | 1173 | if ( pointRight.y() > m_top && pointRight.y() <= m_bottom ) | ||
705 | clippedPolyObject << pointRight; | 1174 | clippedPolyObject << pointRight; | ||
706 | if ( pointTop.x() < m_right ) { | 1175 | if ( pointTop.x() < m_right ) { | ||
707 | clippedPolyObject << pointTop; | 1176 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
724 | } | 1193 | } | ||
725 | if ( pointTop.x() > m_left && pointTop.x() <= m_right ) | 1194 | if ( pointTop.x() > m_left && pointTop.x() <= m_right ) | ||
726 | clippedPolyObject << pointTop; | 1195 | clippedPolyObject << pointTop; | ||
727 | if ( pointRight.y() > m_top ) | 1196 | if ( pointRight.y() > m_top ) | ||
728 | clippedPolyObject << pointRight; | 1197 | clippedPolyObject << pointRight; | ||
729 | } | 1198 | } | ||
730 | else if ( m_previousSector == 7 ) { | 1199 | else if ( m_previousSector == 7 ) { | ||
Context not available. | |||||
737 | } else { | 1206 | } else { | ||
738 | clippedPolyObject << QPointF( m_right, m_bottom ); | 1207 | clippedPolyObject << QPointF( m_right, m_bottom ); | ||
739 | } | 1208 | } | ||
740 | if ( pointRight.y() >= m_top && pointRight.y() < m_bottom ) | 1209 | if ( pointRight.y() >= m_top && pointRight.y() < m_bottom ) | ||
741 | clippedPolyObject << pointRight; | 1210 | clippedPolyObject << pointRight; | ||
742 | if ( pointTop.x() < m_right ) | 1211 | if ( pointTop.x() < m_right ) | ||
743 | clippedPolyObject << pointTop; | 1212 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
750 | 1219 | | |||
751 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | 1220 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | ||
752 | clippedPolyObject << pointBottom; | 1221 | clippedPolyObject << pointBottom; | ||
753 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | 1222 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | ||
754 | clippedPolyObject << pointLeft; | 1223 | clippedPolyObject << pointLeft; | ||
755 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | 1224 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | ||
756 | clippedPolyObject << pointTop; | 1225 | clippedPolyObject << pointTop; | ||
757 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | 1226 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | ||
758 | clippedPolyObject << pointRight; | 1227 | clippedPolyObject << pointRight; | ||
759 | 1228 | | |||
760 | if ( pointBottom.x() >= m_right && pointRight.y() >= m_bottom ) | 1229 | if ( pointBottom.x() >= m_right && pointRight.y() >= m_bottom ) | ||
761 | clippedPolyObject << QPointF( m_right, m_bottom ); | 1230 | clippedPolyObject << QPointF( m_right, m_bottom ); | ||
762 | if ( pointTop.x() <= m_left && pointLeft.y() <= m_top ) | 1231 | if ( pointTop.x() <= m_left && pointLeft.y() <= m_top ) | ||
Context not available. | |||||
796 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | 1265 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | ||
797 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | 1266 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | ||
798 | 1267 | | |||
799 | if ( pointRight.y() < m_bottom ) | 1268 | if ( pointRight.y() < m_bottom ) | ||
800 | clippedPolyObject << pointRight; | 1269 | clippedPolyObject << pointRight; | ||
801 | if ( pointBottom.x() > m_left && pointBottom.x() <= m_right ) | 1270 | if ( pointBottom.x() > m_left && pointBottom.x() <= m_right ) | ||
802 | clippedPolyObject << pointBottom; | 1271 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
815 | QPointF pointTop = clipTop( m, m_previousPoint ); | 1284 | QPointF pointTop = clipTop( m, m_previousPoint ); | ||
816 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | 1285 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | ||
817 | 1286 | | |||
818 | if ( pointRight.y() > m_top ) | 1287 | if ( pointRight.y() > m_top ) | ||
819 | clippedPolyObject << pointRight; | 1288 | clippedPolyObject << pointRight; | ||
820 | if ( pointTop.x() > m_left && pointTop.x() <= m_right ) | 1289 | if ( pointTop.x() > m_left && pointTop.x() <= m_right ) | ||
821 | clippedPolyObject << pointTop; | 1290 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
857 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | 1326 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | ||
858 | QPointF pointRight = clipRight( m, m_currentPoint ); | 1327 | QPointF pointRight = clipRight( m, m_currentPoint ); | ||
859 | 1328 | | |||
860 | if ( pointLeft.y() < m_bottom ) | 1329 | if ( pointLeft.y() < m_bottom ) | ||
861 | clippedPolyObject << pointLeft; | 1330 | clippedPolyObject << pointLeft; | ||
862 | if ( pointBottom.x() >= m_left && pointBottom.x() < m_right ) | 1331 | if ( pointBottom.x() >= m_left && pointBottom.x() < m_right ) | ||
863 | clippedPolyObject << pointBottom; | 1332 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
876 | QPointF pointTop = clipTop( m, m_previousPoint ); | 1345 | QPointF pointTop = clipTop( m, m_previousPoint ); | ||
877 | QPointF pointRight = clipRight( m, m_currentPoint ); | 1346 | QPointF pointRight = clipRight( m, m_currentPoint ); | ||
878 | 1347 | | |||
879 | if ( pointLeft.y() > m_top ) | 1348 | if ( pointLeft.y() > m_top ) | ||
880 | clippedPolyObject << pointLeft; | 1349 | clippedPolyObject << pointLeft; | ||
881 | if ( pointTop.x() >= m_left && pointTop.x() < m_right ) | 1350 | if ( pointTop.x() >= m_left && pointTop.x() < m_right ) | ||
882 | clippedPolyObject << pointTop; | 1351 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
901 | } | 1370 | } | ||
902 | if ( pointBottom.x() >= m_left && pointBottom.x() < m_right ) | 1371 | if ( pointBottom.x() >= m_left && pointBottom.x() < m_right ) | ||
903 | clippedPolyObject << pointBottom; | 1372 | clippedPolyObject << pointBottom; | ||
904 | if ( pointLeft.y() < m_bottom ) | 1373 | if ( pointLeft.y() < m_bottom ) | ||
905 | clippedPolyObject << pointLeft; | 1374 | clippedPolyObject << pointLeft; | ||
906 | } | 1375 | } | ||
907 | else if ( m_previousSector == 1 ) { | 1376 | else if ( m_previousSector == 1 ) { | ||
Context not available. | |||||
914 | } else { | 1383 | } else { | ||
915 | clippedPolyObject << QPointF( m_left, m_top ); | 1384 | clippedPolyObject << QPointF( m_left, m_top ); | ||
916 | } | 1385 | } | ||
917 | if ( pointLeft.y() > m_top && pointLeft.y() <= m_bottom ) | 1386 | if ( pointLeft.y() > m_top && pointLeft.y() <= m_bottom ) | ||
918 | clippedPolyObject << pointLeft; | 1387 | clippedPolyObject << pointLeft; | ||
919 | if ( pointBottom.x() > m_left ) | 1388 | if ( pointBottom.x() > m_left ) | ||
920 | clippedPolyObject << pointBottom; | 1389 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
925 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | 1394 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | ||
926 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | 1395 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | ||
927 | 1396 | | |||
928 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | 1397 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | ||
929 | clippedPolyObject << pointTop; | 1398 | clippedPolyObject << pointTop; | ||
930 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | 1399 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | ||
931 | clippedPolyObject << pointRight; | 1400 | clippedPolyObject << pointRight; | ||
932 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | 1401 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | ||
933 | clippedPolyObject << pointBottom; | 1402 | clippedPolyObject << pointBottom; | ||
934 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | 1403 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | ||
935 | clippedPolyObject << pointLeft; | 1404 | clippedPolyObject << pointLeft; | ||
936 | 1405 | | |||
937 | if ( pointBottom.x() >= m_right && pointRight.y() >= m_bottom ) | 1406 | if ( pointBottom.x() >= m_right && pointRight.y() >= m_bottom ) | ||
938 | clippedPolyObject << QPointF( m_right, m_bottom ); | 1407 | clippedPolyObject << QPointF( m_right, m_bottom ); | ||
939 | if ( pointTop.x() <= m_left && pointLeft.y() <= m_top ) | 1408 | if ( pointTop.x() <= m_left && pointLeft.y() <= m_top ) | ||
Context not available. | |||||
975 | 1444 | | |||
976 | if ( pointTop.x() > m_left ) | 1445 | if ( pointTop.x() > m_left ) | ||
977 | clippedPolyObject << pointTop; | 1446 | clippedPolyObject << pointTop; | ||
978 | if ( pointLeft.y() >= m_top && pointLeft.y() < m_bottom ) | 1447 | if ( pointLeft.y() >= m_top && pointLeft.y() < m_bottom ) | ||
979 | clippedPolyObject << pointLeft; | 1448 | clippedPolyObject << pointLeft; | ||
980 | if ( pointBottom.x() > m_left ) { | 1449 | if ( pointBottom.x() > m_left ) { | ||
981 | clippedPolyObject << pointBottom; | 1450 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
994 | 1463 | | |||
995 | if ( pointTop.x() < m_right ) | 1464 | if ( pointTop.x() < m_right ) | ||
996 | clippedPolyObject << pointTop; | 1465 | clippedPolyObject << pointTop; | ||
997 | if ( pointRight.y() >= m_top && pointRight.y() < m_bottom ) | 1466 | if ( pointRight.y() >= m_top && pointRight.y() < m_bottom ) | ||
998 | clippedPolyObject << pointRight; | 1467 | clippedPolyObject << pointRight; | ||
999 | if ( pointBottom.x() < m_right ) { | 1468 | if ( pointBottom.x() < m_right ) { | ||
1000 | clippedPolyObject << pointBottom; | 1469 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
1017 | } | 1486 | } | ||
1018 | if ( pointBottom.x() > m_left && pointBottom.x() <= m_right ) | 1487 | if ( pointBottom.x() > m_left && pointBottom.x() <= m_right ) | ||
1019 | clippedPolyObject << pointBottom; | 1488 | clippedPolyObject << pointBottom; | ||
1020 | if ( pointRight.y() < m_bottom ) | 1489 | if ( pointRight.y() < m_bottom ) | ||
1021 | clippedPolyObject << pointRight; | 1490 | clippedPolyObject << pointRight; | ||
1022 | } | 1491 | } | ||
1023 | else if ( m_previousSector == 1 ) { | 1492 | else if ( m_previousSector == 1 ) { | ||
Context not available. | |||||
1030 | } else { | 1499 | } else { | ||
1031 | clippedPolyObject << QPointF( m_right, m_top ); | 1500 | clippedPolyObject << QPointF( m_right, m_top ); | ||
1032 | } | 1501 | } | ||
1033 | if ( pointRight.y() > m_top && pointRight.y() <= m_bottom ) | 1502 | if ( pointRight.y() > m_top && pointRight.y() <= m_bottom ) | ||
1034 | clippedPolyObject << pointRight; | 1503 | clippedPolyObject << pointRight; | ||
1035 | if ( pointBottom.x() < m_right ) | 1504 | if ( pointBottom.x() < m_right ) | ||
1036 | clippedPolyObject << pointBottom; | 1505 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
1041 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | 1510 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | ||
1042 | QPointF pointRight = clipRight( m, m_previousPoint ); | 1511 | QPointF pointRight = clipRight( m, m_previousPoint ); | ||
1043 | 1512 | | |||
1044 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | 1513 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | ||
1045 | clippedPolyObject << pointTop; | 1514 | clippedPolyObject << pointTop; | ||
1046 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | 1515 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | ||
1047 | clippedPolyObject << pointLeft; | 1516 | clippedPolyObject << pointLeft; | ||
1048 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | 1517 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | ||
1049 | clippedPolyObject << pointBottom; | 1518 | clippedPolyObject << pointBottom; | ||
1050 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | 1519 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | ||
1051 | clippedPolyObject << pointRight; | 1520 | clippedPolyObject << pointRight; | ||
1052 | 1521 | | |||
1053 | if ( pointBottom.x() <= m_left && pointLeft.y() >= m_bottom ) | 1522 | if ( pointBottom.x() <= m_left && pointLeft.y() >= m_bottom ) | ||
1054 | clippedPolyObject << QPointF( m_left, m_bottom ); | 1523 | clippedPolyObject << QPointF( m_left, m_bottom ); | ||
1055 | if ( pointTop.x() >= m_right && pointRight.y() <= m_top ) | 1524 | if ( pointTop.x() >= m_right && pointRight.y() <= m_top ) | ||
Context not available. | |||||
1060 | break; | 1529 | break; | ||
1061 | 1530 | | |||
1062 | default: | 1531 | default: | ||
1063 | break; | 1532 | break; | ||
1064 | } | 1533 | } | ||
1065 | } | 1534 | } | ||
1066 | 1535 | | |||
1067 | void ClipPainterPrivate::clipOnceCorner( QPolygonF & clippedPolyObject, | 1536 | void ClipPainterPrivate::clipOnceCorner( QPolygonF & clippedPolyObject, | ||
1068 | QVector<QPolygonF> & clippedPolyObjects, | 1537 | QVector<QPolygonF> & clippedPolyObjects, | ||
1069 | const QPointF& corner, | 1538 | const QPointF& corner, | ||
1070 | const QPointF& point, | 1539 | const QPointF& point, | ||
1071 | bool isClosed ) const | 1540 | bool isClosed ) const | ||
1072 | { | 1541 | { | ||
1073 | Q_UNUSED( clippedPolyObjects ) | 1542 | Q_UNUSED( clippedPolyObjects ) | ||
Context not available. | |||||
1100 | // Disappearing | 1569 | // Disappearing | ||
1101 | clippedPolyObject << point; | 1570 | clippedPolyObject << point; | ||
1102 | if ( !isClosed ) { | 1571 | if ( !isClosed ) { | ||
1103 | clippedPolyObjects << clippedPolyObject; | 1572 | clippedPolyObjects << clippedPolyObject; | ||
1573 | clippedPolyObject = QPolygonF(); | ||||
1104 | } | 1574 | } | ||
1105 | } | 1575 | } | ||
1106 | } | 1576 | } | ||
Context not available. | |||||
1115 | // Calculating the slope. | 1585 | // Calculating the slope. | ||
1116 | qreal m = _m( m_previousPoint, m_currentPoint ); | 1586 | qreal m = _m( m_previousPoint, m_currentPoint ); | ||
1117 | 1587 | | |||
1118 | // Calculate in which sector the end of the line is located that is off screen | 1588 | // Calculate in which sector the end of the line is located that is off screen | ||
1119 | int offscreenpos = ( m_currentSector == 4 ) ? m_previousSector : m_currentSector; | 1589 | int offscreenpos = ( m_currentSector == 4 ) ? m_previousSector : m_currentSector; | ||
1120 | 1590 | | |||
1121 | // "Rise over run" for all possible situations . | 1591 | // "Rise over run" for all possible situations . | ||
Context not available. | |||||
1165 | clipOnceCorner( clippedPolyObject, clippedPolyObjects, QPointF( m_right, m_bottom ), point, isClosed ); | 1635 | clipOnceCorner( clippedPolyObject, clippedPolyObjects, QPointF( m_right, m_bottom ), point, isClosed ); | ||
1166 | break; | 1636 | break; | ||
1167 | default: | 1637 | default: | ||
1168 | break; | 1638 | break; | ||
1169 | } | 1639 | } | ||
1170 | 1640 | | |||
1171 | } | 1641 | } | ||
Context not available. |