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; | ||||
47 | 57 | | |||
48 | inline int sector( const QPointF & point ) const; | 58 | inline int sector( const QPointF & point ) const; | ||
59 | inline int borderSector( const QPointF & point ) const; | ||||
60 | inline bool isClockwise(const QPointF& pointA, const QPointF& pointB) const; | ||||
61 | inline qreal calculateAngle(const QPointF& point) const ; | ||||
49 | 62 | | |||
50 | inline QPointF clipTop( qreal m, const QPointF & point ) const; | 63 | inline QPointF clipTop( qreal m, const QPointF & point ) const; | ||
51 | inline QPointF clipLeft( qreal m, const QPointF & point ) const; | 64 | inline QPointF clipLeft( qreal m, const QPointF & point ) const; | ||
Context not available. | |||||
54 | 67 | | |||
55 | inline void initClipRect(); | 68 | inline void initClipRect(); | ||
56 | 69 | | |||
57 | inline void clipPolyObject ( const QPolygonF & sourcePolygon, | 70 | inline void clipPolyObject ( const QPolygonF & sourcePolygon, | ||
58 | QVector<QPolygonF> & clippedPolyObjects, | 71 | QVector<QPolygonF> & clippedPolyObjects, | ||
59 | bool isClosed ); | 72 | bool isClosed ); | ||
60 | 73 | | |||
74 | inline void clipPolygon( QPolygonF & clippedPolyObject, | ||||
75 | QVector<QPolygonF> & clippedPolyObjects, | ||||
76 | bool isClosed ); | ||||
77 | | ||||
61 | inline void clipMultiple( QPolygonF & clippedPolyObject, | 78 | inline void clipMultiple( QPolygonF & clippedPolyObject, | ||
62 | QVector<QPolygonF> & clippedPolyObjects, | 79 | QVector<QPolygonF> & clippedPolyObjects, | ||
63 | bool isClosed ); | 80 | bool isClosed ); | ||
64 | inline void clipOnce( QPolygonF & clippedPolyObject, | 81 | inline void clipOnce( QPolygonF & clippedPolyObject, | ||
65 | QVector<QPolygonF> & clippedPolyObjects, | 82 | QVector<QPolygonF> & clippedPolyObjects, | ||
66 | bool isClosed ); | 83 | bool isClosed ); | ||
67 | inline void clipOnceCorner( QPolygonF & clippedPolyObject, | 84 | inline void clipOnceCorner( QPolygonF & clippedPolyObject, | ||
68 | QVector<QPolygonF> & clippedPolyObjects, | 85 | QVector<QPolygonF> & clippedPolyObjects, | ||
69 | const QPointF& corner, | 86 | const QPointF& corner, | ||
Context not available. | |||||
74 | const QPointF& point, | 91 | const QPointF& point, | ||
75 | bool isClosed ) const; | 92 | bool isClosed ) const; | ||
76 | 93 | | |||
94 | inline void closePolygon( QPolygonF & clippedPolyObject, | ||||
95 | QVector<QPolygonF> & clippedPolyObjects, | ||||
96 | bool isClosed ); | ||||
77 | 97 | | |||
78 | void labelPosition( const QPolygonF & polygon, QVector<QPointF>& labelNodes, | 98 | | ||
79 | LabelPositionFlags labelPositionFlags); | 99 | void labelPosition( const QPolygonF & polygon, QVector<QPointF>& labelNodes, | ||
100 | LabelPositionFlags labelPositionFlags); | ||||
80 | 101 | | |||
81 | bool pointAllowsLabel( const QPointF& point ); | 102 | bool pointAllowsLabel( const QPointF& point ); | ||
82 | QPointF interpolateLabelPoint( const QPointF& previousPoint, | 103 | QPointF interpolateLabelPoint( const QPointF& previousPoint, | ||
83 | const QPointF& currentPoint, | 104 | const QPointF& currentPoint, | ||
84 | LabelPositionFlags labelPositionFlags ); | 105 | LabelPositionFlags labelPositionFlags ); | ||
85 | 106 | | |||
Context not available. | |||||
135 | void ClipPainter::drawPolygon ( const QPolygonF & polygon, | 156 | void ClipPainter::drawPolygon ( const QPolygonF & polygon, | ||
136 | Qt::FillRule fillRule ) | 157 | Qt::FillRule fillRule ) | ||
137 | { | 158 | { | ||
138 | if ( d->m_doClip ) { | 159 | if ( d->m_doClip ) { | ||
139 | d->initClipRect(); | 160 | d->initClipRect(); | ||
140 | QVector<QPolygonF> clippedPolyObjects; | 161 | QVector<QPolygonF> clippedPolyObjects; | ||
141 | 162 | | |||
142 | d->clipPolyObject( polygon, clippedPolyObjects, true ); | 163 | d->clipPolyObject( polygon, clippedPolyObjects, true ); | ||
143 | 164 | | |||
144 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | 165 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | ||
145 | if ( clippedPolyObject.size() > 2 ) { | 166 | if ( clippedPolyObject.size() > 2 ) { | ||
146 | // mDebug() << "Size: " << clippedPolyObject.size(); | 167 | // mDebug() << "Size: " << clippedPolyObject.size(); | ||
147 | if (d->m_debugPolygonsLevel) { | 168 | if (d->m_debugPolygonsLevel) { | ||
Context not available. | |||||
193 | 214 | | |||
194 | d->clipPolyObject( polygon, clippedPolyObjects, false ); | 215 | d->clipPolyObject( polygon, clippedPolyObjects, false ); | ||
195 | 216 | | |||
196 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | 217 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | ||
197 | if ( clippedPolyObject.size() > 1 ) { | 218 | if ( clippedPolyObject.size() > 1 ) { | ||
198 | if (d->m_debugPolygonsLevel) { | 219 | if (d->m_debugPolygonsLevel) { | ||
199 | QPen pen = QPainter::pen(); | 220 | QPen pen = QPainter::pen(); | ||
Context not available. | |||||
245 | 266 | | |||
246 | d->clipPolyObject( polygon, clippedPolyObjects, false ); | 267 | d->clipPolyObject( polygon, clippedPolyObjects, false ); | ||
247 | 268 | | |||
248 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | 269 | foreach( const QPolygonF & clippedPolyObject, clippedPolyObjects ) { | ||
249 | if (d->m_debugPolygonsLevel) { | 270 | if (d->m_debugPolygonsLevel) { | ||
250 | QPen pen = QPainter::pen(); | 271 | QPen pen = QPainter::pen(); | ||
251 | QPen originalPen = pen; | 272 | QPen originalPen = pen; | ||
Context not available. | |||||
316 | if ( currentAllowsLabel ) { | 337 | if ( currentAllowsLabel ) { | ||
317 | // As polygon.size() > 0 it's ensured that it-1 exists. | 338 | // As polygon.size() > 0 it's ensured that it-1 exists. | ||
318 | QPointF node = interpolateLabelPoint( polygon.at( it -1 ), polygon.at( it ), | 339 | QPointF node = interpolateLabelPoint( polygon.at( it -1 ), polygon.at( it ), | ||
319 | labelPositionFlags ); | 340 | labelPositionFlags ); | ||
320 | if ( node != QPointF( -1.0, -1.0 ) ) { | 341 | if ( node != QPointF( -1.0, -1.0 ) ) { | ||
321 | labelNodes << node; | 342 | labelNodes << node; | ||
322 | } | 343 | } | ||
Context not available. | |||||
336 | 357 | | |||
337 | if ( currentAllowsLabel ) { | 358 | if ( currentAllowsLabel ) { | ||
338 | QPointF node = interpolateLabelPoint( polygon.at( it + 1 ), polygon.at( it ), | 359 | QPointF node = interpolateLabelPoint( polygon.at( it + 1 ), polygon.at( it ), | ||
339 | labelPositionFlags ); | 360 | labelPositionFlags ); | ||
340 | if ( node != QPointF( -1.0, -1.0 ) ) { | 361 | if ( node != QPointF( -1.0, -1.0 ) ) { | ||
341 | labelNodes << node; | 362 | labelNodes << node; | ||
342 | } | 363 | } | ||
Context not available. | |||||
349 | bool ClipPainterPrivate::pointAllowsLabel( const QPointF& point ) | 370 | bool ClipPainterPrivate::pointAllowsLabel( const QPointF& point ) | ||
350 | { | 371 | { | ||
351 | 372 | | |||
352 | if ( point.x() > m_labelAreaMargin && point.x() < q->viewport().width() - m_labelAreaMargin | 373 | if ( point.x() > m_labelAreaMargin && point.x() < q->viewport().width() - m_labelAreaMargin | ||
353 | && point.y() > m_labelAreaMargin && point.y() < q->viewport().height() - m_labelAreaMargin ) { | 374 | && point.y() > m_labelAreaMargin && point.y() < q->viewport().height() - m_labelAreaMargin ) { | ||
354 | return true; | 375 | return true; | ||
355 | } | 376 | } | ||
Context not available. | |||||
365 | if ( labelPositionFlags.testFlag( IgnoreXMargin ) ) { | 386 | if ( labelPositionFlags.testFlag( IgnoreXMargin ) ) { | ||
366 | return QPointF( -1.0, -1.0 ); | 387 | return QPointF( -1.0, -1.0 ); | ||
367 | } | 388 | } | ||
368 | return QPointF( m_labelAreaMargin, | 389 | return QPointF( m_labelAreaMargin, | ||
369 | previousPoint.y() + ( m_labelAreaMargin - previousPoint.x() ) * m ); | 390 | previousPoint.y() + ( m_labelAreaMargin - previousPoint.x() ) * m ); | ||
370 | } | 391 | } | ||
371 | else if ( previousPoint.x() >= q->viewport().width() - m_labelAreaMargin ) { | 392 | else if ( previousPoint.x() >= q->viewport().width() - m_labelAreaMargin ) { | ||
Context not available. | |||||
373 | return QPointF( -1.0, -1.0 ); | 394 | return QPointF( -1.0, -1.0 ); | ||
374 | } | 395 | } | ||
375 | return QPointF( q->viewport().width() - m_labelAreaMargin, | 396 | return QPointF( q->viewport().width() - m_labelAreaMargin, | ||
376 | previousPoint.y() - | 397 | previousPoint.y() - | ||
377 | ( previousPoint.x() - q->viewport().width() + m_labelAreaMargin ) * m ); | 398 | ( previousPoint.x() - q->viewport().width() + m_labelAreaMargin ) * m ); | ||
378 | } | 399 | } | ||
379 | 400 | | |||
380 | if ( previousPoint.y() <= m_labelAreaMargin ) { | 401 | if ( previousPoint.y() <= m_labelAreaMargin ) { | ||
381 | if ( labelPositionFlags.testFlag( IgnoreYMargin ) ) { | 402 | if ( labelPositionFlags.testFlag( IgnoreYMargin ) ) { | ||
382 | return QPointF( -1.0, -1.0 ); | 403 | return QPointF( -1.0, -1.0 ); | ||
383 | } | 404 | } | ||
384 | return QPointF( previousPoint.x() + ( m_labelAreaMargin - previousPoint.y() ) / m, | 405 | return QPointF( previousPoint.x() + ( m_labelAreaMargin - previousPoint.y() ) / m, | ||
385 | m_labelAreaMargin ); | 406 | m_labelAreaMargin ); | ||
386 | } | 407 | } | ||
387 | else if ( previousPoint.y() >= q->viewport().height() - m_labelAreaMargin ) { | 408 | else if ( previousPoint.y() >= q->viewport().height() - m_labelAreaMargin ) { | ||
388 | if ( labelPositionFlags.testFlag( IgnoreYMargin ) ) { | 409 | if ( labelPositionFlags.testFlag( IgnoreYMargin ) ) { | ||
389 | return QPointF( -1.0, -1.0 ); | 410 | return QPointF( -1.0, -1.0 ); | ||
390 | } | 411 | } | ||
391 | return QPointF( previousPoint.x() - | 412 | return QPointF( previousPoint.x() - | ||
392 | ( previousPoint.y() - q->viewport().height() + m_labelAreaMargin ) / m, | 413 | ( previousPoint.y() - q->viewport().height() + m_labelAreaMargin ) / m, | ||
393 | q->viewport().height() - m_labelAreaMargin ); | 414 | q->viewport().height() - m_labelAreaMargin ); | ||
394 | } | 415 | } | ||
395 | 416 | | |||
396 | // mDebug() << Q_FUNC_INFO << "Previous and current node position are allowed!"; | 417 | // mDebug() << Q_FUNC_INFO << "Previous and current node position are allowed!"; | ||
397 | 418 | | |||
398 | return QPointF( -1.0, -1.0 ); | 419 | return QPointF( -1.0, -1.0 ); | ||
399 | } | 420 | } | ||
Context not available. | |||||
407 | m_currentSector(4), | 428 | m_currentSector(4), | ||
408 | m_previousSector(4), | 429 | m_previousSector(4), | ||
409 | m_currentPoint(QPointF()), | 430 | m_currentPoint(QPointF()), | ||
410 | m_previousPoint(QPointF()), | 431 | m_previousPoint(QPointF()), | ||
411 | m_labelAreaMargin(10.0), | 432 | m_labelAreaMargin(10.0), | ||
412 | m_debugPolygonsLevel(0) | 433 | m_debugPolygonsLevel(0) | ||
413 | { | 434 | { | ||
Context not available. | |||||
416 | 437 | | |||
417 | void ClipPainterPrivate::initClipRect () | 438 | void ClipPainterPrivate::initClipRect () | ||
418 | { | 439 | { | ||
419 | qreal penHalfWidth = q->pen().widthF() / 2.0 + 1.0; | 440 | // qreal penHalfWidth = q->pen().widthF() / 2.0 + 1.0; | ||
420 | 441 | | |||
421 | m_left = -penHalfWidth; | 442 | m_left = 20; | ||
422 | m_right = (qreal)(q->device()->width()) + penHalfWidth; | 443 | m_right = (qreal)(q->device()->width()) - 20; | ||
423 | m_top = -penHalfWidth; | 444 | m_top = 20; | ||
424 | m_bottom = (qreal)(q->device()->height()) + penHalfWidth; | 445 | m_bottom = (qreal)(q->device()->height()) - 20; | ||
425 | } | 446 | } | ||
426 | 447 | | |||
427 | qreal ClipPainterPrivate::_m( const QPointF & start, const QPointF & end ) | 448 | qreal ClipPainterPrivate::_m( const QPointF & start, const QPointF & end ) | ||
Context not available. | |||||
429 | qreal divisor = end.x() - start.x(); | 450 | qreal divisor = end.x() - start.x(); | ||
430 | if ( std::fabs( divisor ) < 0.000001 ) { | 451 | if ( std::fabs( divisor ) < 0.000001 ) { | ||
431 | // this is in screencoordinates so the difference | 452 | // this is in screencoordinates so the difference | ||
432 | // between 0, 0.000001 and -0.000001 isn't visible at all | 453 | // between 0, 0.000001 and -0.000001 isn't visible at all | ||
433 | divisor = 0.000001; | 454 | divisor = 0.000001; | ||
434 | } | 455 | } | ||
435 | 456 | | |||
436 | return ( end.y() - start.y() ) | 457 | return ( end.y() - start.y() ) | ||
437 | / divisor; | 458 | / divisor; | ||
438 | } | 459 | } | ||
439 | 460 | | |||
440 | 461 | | |||
Context not available. | |||||
487 | // By adding xSector and ySector we get a | 508 | // By adding xSector and ySector we get a | ||
488 | // sector number of the values shown in the ASCII-art graph above. | 509 | // sector number of the values shown in the ASCII-art graph above. | ||
489 | return ySector + xSector; | 510 | return ySector + xSector; | ||
511 | } | ||||
512 | | ||||
513 | // Determines that the point on which border or corner is exactly on, 4 otherwise. | ||||
514 | int ClipPainterPrivate::borderSector( const QPointF & point ) const | ||||
515 | { | ||||
516 | int xSector = 1; | ||||
517 | if ( point.x() == m_left ) | ||||
518 | xSector = 0; | ||||
519 | else if ( point.x() == m_right ) | ||||
520 | xSector = 2; | ||||
521 | | ||||
522 | int ySector = 3; | ||||
523 | if ( point.y() == m_top ) | ||||
524 | ySector = 0; | ||||
525 | else if ( point.y() == m_bottom ) | ||||
526 | ySector = 6; | ||||
527 | | ||||
528 | return ySector + xSector; | ||||
529 | } | ||||
530 | | ||||
531 | qreal ClipPainterPrivate::calculateAngle(const QPointF& point) const | ||||
532 | { | ||||
533 | QPointF middlePoint((m_left + m_right)/2.0, -(m_top + m_bottom)/2.0); | ||||
490 | 534 | | |||
535 | qreal angle = atan2(-point.y() - middlePoint.y(), point.x() - middlePoint.x()) * RAD2DEG; | ||||
536 | | ||||
537 | if(angle < 0) angle += 360.0; | ||||
538 | | ||||
539 | return angle; | ||||
540 | } | ||||
541 | | ||||
542 | bool ClipPainterPrivate::isClockwise(const QPointF& pointA, const QPointF& pointB) const | ||||
543 | { | ||||
544 | QPointF middlePoint((m_left + m_right)/2.0, -(m_top + m_bottom)/2.0); | ||||
545 | | ||||
546 | QPointF vecA(QPointF(pointA.x(), -pointA.y()) - middlePoint); | ||||
547 | QPointF vecB(QPointF(pointB.x(), -pointB.y()) - middlePoint); | ||||
548 | | ||||
549 | qreal angle = atan2(vecA.x()*vecB.y() - vecB.x()*vecA.y(), vecA.x()*vecB.x() + vecA.y()*vecB.y()) * RAD2DEG; | ||||
550 | mDebug() << "isClockwise angle:" << angle; | ||||
551 | return angle < 0; | ||||
491 | } | 552 | } | ||
492 | 553 | | |||
493 | void ClipPainterPrivate::clipPolyObject ( const QPolygonF & polygon, | 554 | void ClipPainterPrivate::clipPolyObject ( const QPolygonF & polygon, | ||
Context not available. | |||||
496 | { | 557 | { | ||
497 | // mDebug() << "ClipPainter enabled." ; | 558 | // mDebug() << "ClipPainter enabled." ; | ||
498 | 559 | | |||
499 | // Only create a new polyObject as soon as we know for sure that | 560 | // Only create a new polyObject as soon as we know for sure that | ||
500 | // the current point is on the screen. | 561 | // the current point is on the screen. | ||
501 | QPolygonF clippedPolyObject = QPolygonF(); | 562 | QPolygonF clippedPolyObject = QPolygonF(); | ||
502 | 563 | | |||
503 | const QVector<QPointF>::const_iterator itStartPoint = polygon.constBegin(); | 564 | const QVector<QPointF>::const_iterator itStartPoint = polygon.constBegin(); | ||
Context not available. | |||||
510 | 571 | | |||
511 | bool processingLastNode = false; | 572 | bool processingLastNode = false; | ||
512 | 573 | | |||
574 | m_previousCrossing = QPointF(0,0); | ||||
575 | m_previousCrossingSector = -1; | ||||
576 | m_currentCrossingSector = -1; | ||||
577 | m_previousCrossingAngle = 0; | ||||
578 | m_currentCrossingAngle = 0; | ||||
579 | | ||||
580 | mDebug() << "\n"; | ||||
581 | mDebug() << "New polygon"; | ||||
513 | while ( itPoint != itEndPoint ) { | 582 | while ( itPoint != itEndPoint ) { | ||
514 | m_currentPoint = (*itPoint); | 583 | m_currentPoint = (*itPoint); | ||
515 | // mDebug() << "m_currentPoint.x()" << m_currentPoint.x() << "m_currentPOint.y()" << m_currentPoint.y(); | 584 | // 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 | 606 | // screen but not both. Hence we only need to clip once and require | ||
538 | // only one interpolation for both cases. | 607 | // only one interpolation for both cases. | ||
539 | 608 | | |||
540 | clipOnce( clippedPolyObject, clippedPolyObjects, isClosed ); | 609 | if(!isClosed) { | ||
541 | } | 610 | clipOnce( clippedPolyObject, clippedPolyObjects, isClosed ); | ||
542 | else { | 611 | } else { | ||
612 | clipPolygon( clippedPolyObject, clippedPolyObjects, isClosed ); | ||||
613 | } | ||||
614 | | ||||
615 | } else if (!isClosed) { | ||||
543 | // This case mostly deals with lines that reach from one | 616 | // This case mostly deals with lines that reach from one | ||
544 | // sector that is located off screen to another one that | 617 | // sector that is located off screen to another one that | ||
545 | // is located off screen. In this situation the line | 618 | // is located off screen. In this situation the line | ||
546 | // can get clipped once, twice, or not at all. | 619 | // can get clipped once, twice, or not at all. | ||
547 | clipMultiple( clippedPolyObject, clippedPolyObjects, isClosed ); | 620 | clipMultiple( clippedPolyObject, clippedPolyObjects, isClosed ); | ||
548 | } | 621 | } | ||
Context not available. | |||||
569 | } | 642 | } | ||
570 | ++itPoint; | 643 | ++itPoint; | ||
571 | 644 | | |||
572 | if ( itPoint == itEndPoint && isClosed ) { | 645 | if ( itPoint == itEndPoint && isClosed ) { | ||
646 | | ||||
647 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
648 | | ||||
573 | itPoint = itStartPoint; | 649 | itPoint = itStartPoint; | ||
574 | processingLastNode = true; | 650 | processingLastNode = true; | ||
575 | } | 651 | } | ||
Context not available. | |||||
581 | } | 657 | } | ||
582 | } | 658 | } | ||
583 | 659 | | |||
660 | void ClipPainterPrivate::clipPolygon( QPolygonF & clippedPolyObject, | ||||
661 | QVector<QPolygonF> & clippedPolyObjects, | ||||
662 | bool isClosed ) | ||||
663 | { | ||||
664 | clipOnce(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
665 | | ||||
666 | if (isClosed && clippedPolyObject.size() > 1) { | ||||
667 | if (m_currentSector != 4 && m_previousSector == 4) { | ||||
668 | // Disappearing | ||||
669 | | ||||
670 | if(m_currentCrossingSector != -1) { | ||||
671 | m_previousCrossing = m_currentCrossing; | ||||
672 | m_currentCrossing = clippedPolyObject.last(); | ||||
673 | | ||||
674 | m_previousCrossingSector = m_currentCrossingSector; | ||||
675 | m_currentCrossingSector = borderSector(m_currentCrossing); | ||||
676 | | ||||
677 | m_previousCrossingAngle = m_currentCrossingAngle; | ||||
678 | m_currentCrossingAngle = calculateAngle(m_currentCrossing); | ||||
679 | | ||||
680 | switch (m_currentCrossingSector) { | ||||
681 | case 1: | ||||
682 | switch(m_previousCrossingSector) { | ||||
683 | case 1: | ||||
684 | break; | ||||
685 | case 5: | ||||
686 | if(borderSector(clippedPolyObject.at(clippedPolyObject.size() - 2)) != 4) { | ||||
687 | clippedPolyObject << QPointF(m_right, m_top); | ||||
688 | } | ||||
689 | break; | ||||
690 | case 7: | ||||
691 | break; | ||||
692 | case 3: | ||||
693 | break; | ||||
694 | default: | ||||
695 | break; | ||||
696 | } | ||||
697 | break; | ||||
698 | case 5: | ||||
699 | switch(m_previousCrossingSector) { | ||||
700 | case 1: | ||||
701 | break; | ||||
702 | case 5: | ||||
703 | break; | ||||
704 | case 7: | ||||
705 | break; | ||||
706 | case 3: | ||||
707 | break; | ||||
708 | default: | ||||
709 | break; | ||||
710 | } | ||||
711 | | ||||
712 | break; | ||||
713 | case 7: | ||||
714 | switch(m_previousCrossingSector) { | ||||
715 | case 1: | ||||
716 | break; | ||||
717 | case 5: | ||||
718 | if(borderSector(clippedPolyObject.at(clippedPolyObject.size() - 2)) != 4) { | ||||
719 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
720 | } | ||||
721 | break; | ||||
722 | case 7: | ||||
723 | break; | ||||
724 | case 3: | ||||
725 | break; | ||||
726 | default: | ||||
727 | break; | ||||
728 | } | ||||
729 | | ||||
730 | break; | ||||
731 | case 3: | ||||
732 | switch(m_previousCrossingSector) { | ||||
733 | case 1: | ||||
734 | if(borderSector(clippedPolyObject.at(clippedPolyObject.size() - 2)) != 4) { | ||||
735 | clippedPolyObject << QPointF(m_left, m_top); | ||||
736 | } | ||||
737 | break; | ||||
738 | case 5: | ||||
739 | break; | ||||
740 | case 7: | ||||
741 | break; | ||||
742 | case 3: | ||||
743 | break; | ||||
744 | default: | ||||
745 | break; | ||||
746 | } | ||||
747 | | ||||
748 | break; | ||||
749 | default: | ||||
750 | break; | ||||
751 | } | ||||
752 | } else { | ||||
753 | m_currentCrossing = clippedPolyObject.last(); | ||||
754 | m_currentCrossingSector = borderSector(m_currentCrossing); | ||||
755 | m_currentCrossingAngle = calculateAngle(m_currentCrossing); | ||||
756 | } | ||||
757 | | ||||
758 | mDebug() << "Disappearing"; | ||||
759 | mDebug() << "m_currentCrossingSector:" << m_currentCrossingSector; | ||||
760 | mDebug() << "m_previousCrossingSector:" << m_previousCrossingSector; | ||||
761 | mDebug() << "m_currentCrossingAngle:" << m_currentCrossingAngle; | ||||
762 | mDebug() << "m_previousCrossingAngle:" << m_previousCrossingAngle; | ||||
763 | mDebug() << "Angle delta:" << m_currentCrossingAngle - m_previousCrossingAngle; | ||||
764 | } else if (m_currentSector == 4 && m_previousSector != 4) { | ||||
765 | // Appearing | ||||
766 | | ||||
767 | if(m_currentCrossingSector != -1) { | ||||
768 | m_previousCrossing = m_currentCrossing; | ||||
769 | m_currentCrossing = clippedPolyObject.last(); | ||||
770 | | ||||
771 | m_previousCrossingSector = m_currentCrossingSector; | ||||
772 | m_currentCrossingSector = borderSector(m_currentCrossing); | ||||
773 | | ||||
774 | m_previousCrossingAngle = m_currentCrossingAngle; | ||||
775 | m_currentCrossingAngle = calculateAngle(m_currentCrossing); | ||||
776 | | ||||
777 | switch (m_currentCrossingSector) { | ||||
778 | case 1: | ||||
779 | switch(m_previousCrossingSector) { | ||||
780 | case 1: | ||||
781 | if(!isClockwise(m_previousCrossing, m_currentCrossing)) { | ||||
782 | clippedPolyObject.removeLast(); | ||||
783 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
784 | clippedPolyObjects << clippedPolyObject; | ||||
785 | clippedPolyObject = QPolygonF(); | ||||
786 | clippedPolyObject << m_currentCrossing; | ||||
787 | } | ||||
788 | break; | ||||
789 | case 5: | ||||
790 | break; | ||||
791 | case 7: | ||||
792 | break; | ||||
793 | case 3: | ||||
794 | clippedPolyObject.removeLast(); | ||||
795 | clippedPolyObject << QPointF(m_left, m_top); | ||||
796 | clippedPolyObject << m_currentCrossing; | ||||
797 | break; | ||||
798 | default: | ||||
799 | break; | ||||
800 | } | ||||
801 | break; | ||||
802 | case 5: | ||||
803 | switch(m_previousCrossingSector) { | ||||
804 | case 1: | ||||
805 | break; | ||||
806 | case 5: | ||||
807 | if(!isClockwise(m_previousCrossing, m_currentCrossing)) { | ||||
808 | clippedPolyObject.removeLast(); | ||||
809 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
810 | clippedPolyObjects << clippedPolyObject; | ||||
811 | clippedPolyObject = QPolygonF(); | ||||
812 | clippedPolyObject << m_currentCrossing; | ||||
813 | } | ||||
814 | break; | ||||
815 | case 7: | ||||
816 | break; | ||||
817 | case 3: | ||||
818 | break; | ||||
819 | default: | ||||
820 | break; | ||||
821 | } | ||||
822 | | ||||
823 | break; | ||||
824 | case 7: | ||||
825 | switch(m_previousCrossingSector) { | ||||
826 | case 1: | ||||
827 | break; | ||||
828 | case 5: | ||||
829 | clippedPolyObject.removeLast(); | ||||
830 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
831 | clippedPolyObject << m_currentCrossing; | ||||
832 | break; | ||||
833 | case 7: | ||||
834 | if(!isClockwise(m_previousCrossing, m_currentCrossing)) { | ||||
835 | clippedPolyObject.removeLast(); | ||||
836 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
837 | clippedPolyObjects << clippedPolyObject; | ||||
838 | clippedPolyObject = QPolygonF(); | ||||
839 | clippedPolyObject << m_currentCrossing; | ||||
840 | } | ||||
841 | break; | ||||
842 | case 3: | ||||
843 | break; | ||||
844 | default: | ||||
845 | break; | ||||
846 | } | ||||
847 | | ||||
848 | break; | ||||
849 | case 3: | ||||
850 | switch(m_previousCrossingSector) { | ||||
851 | case 1: | ||||
852 | break; | ||||
853 | case 5: | ||||
854 | break; | ||||
855 | case 7: | ||||
856 | clippedPolyObject.removeLast(); | ||||
857 | clippedPolyObject << QPointF(m_left, m_bottom); | ||||
858 | clippedPolyObject << m_currentCrossing; | ||||
859 | break; | ||||
860 | case 3: | ||||
861 | if(!isClockwise(m_previousCrossing, m_currentCrossing)) { | ||||
862 | clippedPolyObject.removeLast(); | ||||
863 | closePolygon(clippedPolyObject, clippedPolyObjects, isClosed); | ||||
864 | clippedPolyObjects << clippedPolyObject; | ||||
865 | clippedPolyObject = QPolygonF(); | ||||
866 | clippedPolyObject << m_currentCrossing; | ||||
867 | } | ||||
868 | break; | ||||
869 | default: | ||||
870 | break; | ||||
871 | } | ||||
872 | | ||||
873 | break; | ||||
874 | default: | ||||
875 | break; | ||||
876 | } | ||||
877 | | ||||
878 | } else { | ||||
879 | m_currentCrossing = clippedPolyObject.last(); | ||||
880 | m_currentCrossingSector = borderSector(m_currentCrossing); | ||||
881 | m_currentCrossingAngle = calculateAngle(m_currentCrossing); | ||||
882 | } | ||||
883 | | ||||
884 | mDebug() << "Appearing"; | ||||
885 | mDebug() << "m_currentCrossingSector:" << m_currentCrossingSector; | ||||
886 | mDebug() << "m_previousCrossingSector:" << m_previousCrossingSector; | ||||
887 | mDebug() << "m_currentCrossingAngle:" << m_currentCrossingAngle; | ||||
888 | mDebug() << "m_previousCrossingAngle:" << m_previousCrossingAngle; | ||||
889 | mDebug() << "Angle delta:" << m_currentCrossingAngle - m_previousCrossingAngle; | ||||
890 | } | ||||
891 | } | ||||
892 | } | ||||
893 | | ||||
894 | void ClipPainterPrivate::closePolygon( QPolygonF & clippedPolyObject, | ||||
895 | QVector<QPolygonF> & clippedPolyObjects, | ||||
896 | bool isClosed ) | ||||
897 | { | ||||
898 | Q_UNUSED(isClosed) | ||||
899 | Q_UNUSED(clippedPolyObjects) | ||||
900 | | ||||
901 | if(!clippedPolyObject.isEmpty()) { | ||||
902 | | ||||
903 | int firstPointSector = borderSector(clippedPolyObject.first()); | ||||
904 | | ||||
905 | switch (m_currentCrossingSector) { | ||||
906 | case 1: | ||||
907 | switch(firstPointSector) { | ||||
908 | case 1: | ||||
909 | break; | ||||
910 | case 5: | ||||
911 | clippedPolyObject << QPointF(m_right, m_top); | ||||
912 | break; | ||||
913 | case 7: | ||||
914 | break; | ||||
915 | case 3: | ||||
916 | break; | ||||
917 | case -1: | ||||
918 | break; | ||||
919 | default: | ||||
920 | break; | ||||
921 | } | ||||
922 | break; | ||||
923 | case 5: | ||||
924 | switch(firstPointSector) { | ||||
925 | case 1: | ||||
926 | break; | ||||
927 | case 5: | ||||
928 | break; | ||||
929 | case 7: | ||||
930 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
931 | break; | ||||
932 | case 3: | ||||
933 | break; | ||||
934 | case -1: | ||||
935 | break; | ||||
936 | default: | ||||
937 | break; | ||||
938 | } | ||||
939 | | ||||
940 | break; | ||||
941 | case 7: | ||||
942 | switch(firstPointSector) { | ||||
943 | case 1: | ||||
944 | break; | ||||
945 | case 5: | ||||
946 | break; | ||||
947 | case 7: | ||||
948 | break; | ||||
949 | case 3: | ||||
950 | clippedPolyObject << QPointF(m_left, m_bottom); | ||||
951 | break; | ||||
952 | case -1: | ||||
953 | break; | ||||
954 | default: | ||||
955 | break; | ||||
956 | } | ||||
957 | | ||||
958 | break; | ||||
959 | case 3: | ||||
960 | switch(firstPointSector) { | ||||
961 | case 1: | ||||
962 | clippedPolyObject << QPointF(m_left, m_top); | ||||
963 | break; | ||||
964 | case 5: | ||||
965 | clippedPolyObject << QPointF(m_left, m_top); | ||||
966 | clippedPolyObject << QPointF(m_right, m_top); | ||||
967 | break; | ||||
968 | case 7: | ||||
969 | clippedPolyObject << QPointF(m_left, m_top); | ||||
970 | clippedPolyObject << QPointF(m_right, m_top); | ||||
971 | clippedPolyObject << QPointF(m_right, m_bottom); | ||||
972 | break; | ||||
973 | case 3: | ||||
974 | break; | ||||
975 | default: | ||||
976 | break; | ||||
977 | } | ||||
978 | | ||||
979 | break; | ||||
980 | default: | ||||
981 | break; | ||||
982 | } | ||||
983 | } | ||||
984 | } | ||||
985 | | ||||
986 | | ||||
584 | 987 | | |||
585 | void ClipPainterPrivate::clipMultiple( QPolygonF & clippedPolyObject, | 988 | void ClipPainterPrivate::clipMultiple( QPolygonF & clippedPolyObject, | ||
586 | QVector<QPolygonF> & clippedPolyObjects, | 989 | QVector<QPolygonF> & clippedPolyObjects, | ||
Context not available. | |||||
589 | Q_UNUSED( clippedPolyObjects ) | 992 | Q_UNUSED( clippedPolyObjects ) | ||
590 | Q_UNUSED( isClosed ) | 993 | Q_UNUSED( isClosed ) | ||
591 | 994 | | |||
592 | // Take care of adding nodes in the image corners if the iterator | 995 | // Take care of adding nodes in the image corners if the iterator | ||
593 | // traverses off screen sections. | 996 | // traverses off screen sections. | ||
594 | 997 | | |||
595 | qreal m = _m( m_previousPoint, m_currentPoint ); | 998 | qreal m = _m( m_previousPoint, m_currentPoint ); | ||
Context not available. | |||||
608 | } | 1011 | } | ||
609 | if ( pointTop.x() >= m_left && pointTop.x() < m_right ) | 1012 | if ( pointTop.x() >= m_left && pointTop.x() < m_right ) | ||
610 | clippedPolyObject << pointTop; | 1013 | clippedPolyObject << pointTop; | ||
611 | if ( pointLeft.y() > m_top ) | 1014 | if ( pointLeft.y() > m_top ) | ||
612 | clippedPolyObject << pointLeft; | 1015 | clippedPolyObject << pointLeft; | ||
613 | } | 1016 | } | ||
614 | else if ( m_previousSector == 7 ) { | 1017 | else if ( m_previousSector == 7 ) { | ||
Context not available. | |||||
621 | } else { | 1024 | } else { | ||
622 | clippedPolyObject << QPointF( m_left, m_bottom ); | 1025 | clippedPolyObject << QPointF( m_left, m_bottom ); | ||
623 | } | 1026 | } | ||
624 | if ( pointLeft.y() >= m_top && pointLeft.y() < m_bottom ) | 1027 | if ( pointLeft.y() >= m_top && pointLeft.y() < m_bottom ) | ||
625 | clippedPolyObject << pointLeft; | 1028 | clippedPolyObject << pointLeft; | ||
626 | if ( pointTop.x() > m_left ) | 1029 | if ( pointTop.x() > m_left ) | ||
627 | clippedPolyObject << pointTop; | 1030 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
634 | 1037 | | |||
635 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | 1038 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | ||
636 | clippedPolyObject << pointBottom; | 1039 | clippedPolyObject << pointBottom; | ||
637 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | 1040 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | ||
638 | clippedPolyObject << pointRight; | 1041 | clippedPolyObject << pointRight; | ||
639 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | 1042 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | ||
640 | clippedPolyObject << pointTop; | 1043 | clippedPolyObject << pointTop; | ||
641 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | 1044 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | ||
642 | clippedPolyObject << pointLeft; | 1045 | clippedPolyObject << pointLeft; | ||
643 | 1046 | | |||
644 | if ( pointBottom.x() <= m_left && pointLeft.y() >= m_bottom ) | 1047 | if ( pointBottom.x() <= m_left && pointLeft.y() >= m_bottom ) | ||
645 | clippedPolyObject << QPointF( m_left, m_bottom ); | 1048 | clippedPolyObject << QPointF( m_left, m_bottom ); | ||
646 | if ( pointTop.x() >= m_right && pointRight.y() <= m_top ) | 1049 | if ( pointTop.x() >= m_right && pointRight.y() <= m_top ) | ||
Context not available. | |||||
682 | 1085 | | |||
683 | if ( pointBottom.x() > m_left ) | 1086 | if ( pointBottom.x() > m_left ) | ||
684 | clippedPolyObject << pointBottom; | 1087 | clippedPolyObject << pointBottom; | ||
685 | if ( pointLeft.y() > m_top && pointLeft.y() <= m_bottom ) | 1088 | if ( pointLeft.y() > m_top && pointLeft.y() <= m_bottom ) | ||
686 | clippedPolyObject << pointLeft; | 1089 | clippedPolyObject << pointLeft; | ||
687 | if ( pointTop.x() > m_left ) { | 1090 | if ( pointTop.x() > m_left ) { | ||
688 | clippedPolyObject << pointTop; | 1091 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
701 | 1104 | | |||
702 | if ( pointBottom.x() < m_right ) | 1105 | if ( pointBottom.x() < m_right ) | ||
703 | clippedPolyObject << pointBottom; | 1106 | clippedPolyObject << pointBottom; | ||
704 | if ( pointRight.y() > m_top && pointRight.y() <= m_bottom ) | 1107 | if ( pointRight.y() > m_top && pointRight.y() <= m_bottom ) | ||
705 | clippedPolyObject << pointRight; | 1108 | clippedPolyObject << pointRight; | ||
706 | if ( pointTop.x() < m_right ) { | 1109 | if ( pointTop.x() < m_right ) { | ||
707 | clippedPolyObject << pointTop; | 1110 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
724 | } | 1127 | } | ||
725 | if ( pointTop.x() > m_left && pointTop.x() <= m_right ) | 1128 | if ( pointTop.x() > m_left && pointTop.x() <= m_right ) | ||
726 | clippedPolyObject << pointTop; | 1129 | clippedPolyObject << pointTop; | ||
727 | if ( pointRight.y() > m_top ) | 1130 | if ( pointRight.y() > m_top ) | ||
728 | clippedPolyObject << pointRight; | 1131 | clippedPolyObject << pointRight; | ||
729 | } | 1132 | } | ||
730 | else if ( m_previousSector == 7 ) { | 1133 | else if ( m_previousSector == 7 ) { | ||
Context not available. | |||||
737 | } else { | 1140 | } else { | ||
738 | clippedPolyObject << QPointF( m_right, m_bottom ); | 1141 | clippedPolyObject << QPointF( m_right, m_bottom ); | ||
739 | } | 1142 | } | ||
740 | if ( pointRight.y() >= m_top && pointRight.y() < m_bottom ) | 1143 | if ( pointRight.y() >= m_top && pointRight.y() < m_bottom ) | ||
741 | clippedPolyObject << pointRight; | 1144 | clippedPolyObject << pointRight; | ||
742 | if ( pointTop.x() < m_right ) | 1145 | if ( pointTop.x() < m_right ) | ||
743 | clippedPolyObject << pointTop; | 1146 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
750 | 1153 | | |||
751 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | 1154 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | ||
752 | clippedPolyObject << pointBottom; | 1155 | clippedPolyObject << pointBottom; | ||
753 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | 1156 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | ||
754 | clippedPolyObject << pointLeft; | 1157 | clippedPolyObject << pointLeft; | ||
755 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | 1158 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | ||
756 | clippedPolyObject << pointTop; | 1159 | clippedPolyObject << pointTop; | ||
757 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | 1160 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | ||
758 | clippedPolyObject << pointRight; | 1161 | clippedPolyObject << pointRight; | ||
759 | 1162 | | |||
760 | if ( pointBottom.x() >= m_right && pointRight.y() >= m_bottom ) | 1163 | if ( pointBottom.x() >= m_right && pointRight.y() >= m_bottom ) | ||
761 | clippedPolyObject << QPointF( m_right, m_bottom ); | 1164 | clippedPolyObject << QPointF( m_right, m_bottom ); | ||
762 | if ( pointTop.x() <= m_left && pointLeft.y() <= m_top ) | 1165 | if ( pointTop.x() <= m_left && pointLeft.y() <= m_top ) | ||
Context not available. | |||||
796 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | 1199 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | ||
797 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | 1200 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | ||
798 | 1201 | | |||
799 | if ( pointRight.y() < m_bottom ) | 1202 | if ( pointRight.y() < m_bottom ) | ||
800 | clippedPolyObject << pointRight; | 1203 | clippedPolyObject << pointRight; | ||
801 | if ( pointBottom.x() > m_left && pointBottom.x() <= m_right ) | 1204 | if ( pointBottom.x() > m_left && pointBottom.x() <= m_right ) | ||
802 | clippedPolyObject << pointBottom; | 1205 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
815 | QPointF pointTop = clipTop( m, m_previousPoint ); | 1218 | QPointF pointTop = clipTop( m, m_previousPoint ); | ||
816 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | 1219 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | ||
817 | 1220 | | |||
818 | if ( pointRight.y() > m_top ) | 1221 | if ( pointRight.y() > m_top ) | ||
819 | clippedPolyObject << pointRight; | 1222 | clippedPolyObject << pointRight; | ||
820 | if ( pointTop.x() > m_left && pointTop.x() <= m_right ) | 1223 | if ( pointTop.x() > m_left && pointTop.x() <= m_right ) | ||
821 | clippedPolyObject << pointTop; | 1224 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
857 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | 1260 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | ||
858 | QPointF pointRight = clipRight( m, m_currentPoint ); | 1261 | QPointF pointRight = clipRight( m, m_currentPoint ); | ||
859 | 1262 | | |||
860 | if ( pointLeft.y() < m_bottom ) | 1263 | if ( pointLeft.y() < m_bottom ) | ||
861 | clippedPolyObject << pointLeft; | 1264 | clippedPolyObject << pointLeft; | ||
862 | if ( pointBottom.x() >= m_left && pointBottom.x() < m_right ) | 1265 | if ( pointBottom.x() >= m_left && pointBottom.x() < m_right ) | ||
863 | clippedPolyObject << pointBottom; | 1266 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
876 | QPointF pointTop = clipTop( m, m_previousPoint ); | 1279 | QPointF pointTop = clipTop( m, m_previousPoint ); | ||
877 | QPointF pointRight = clipRight( m, m_currentPoint ); | 1280 | QPointF pointRight = clipRight( m, m_currentPoint ); | ||
878 | 1281 | | |||
879 | if ( pointLeft.y() > m_top ) | 1282 | if ( pointLeft.y() > m_top ) | ||
880 | clippedPolyObject << pointLeft; | 1283 | clippedPolyObject << pointLeft; | ||
881 | if ( pointTop.x() >= m_left && pointTop.x() < m_right ) | 1284 | if ( pointTop.x() >= m_left && pointTop.x() < m_right ) | ||
882 | clippedPolyObject << pointTop; | 1285 | clippedPolyObject << pointTop; | ||
Context not available. | |||||
901 | } | 1304 | } | ||
902 | if ( pointBottom.x() >= m_left && pointBottom.x() < m_right ) | 1305 | if ( pointBottom.x() >= m_left && pointBottom.x() < m_right ) | ||
903 | clippedPolyObject << pointBottom; | 1306 | clippedPolyObject << pointBottom; | ||
904 | if ( pointLeft.y() < m_bottom ) | 1307 | if ( pointLeft.y() < m_bottom ) | ||
905 | clippedPolyObject << pointLeft; | 1308 | clippedPolyObject << pointLeft; | ||
906 | } | 1309 | } | ||
907 | else if ( m_previousSector == 1 ) { | 1310 | else if ( m_previousSector == 1 ) { | ||
Context not available. | |||||
914 | } else { | 1317 | } else { | ||
915 | clippedPolyObject << QPointF( m_left, m_top ); | 1318 | clippedPolyObject << QPointF( m_left, m_top ); | ||
916 | } | 1319 | } | ||
917 | if ( pointLeft.y() > m_top && pointLeft.y() <= m_bottom ) | 1320 | if ( pointLeft.y() > m_top && pointLeft.y() <= m_bottom ) | ||
918 | clippedPolyObject << pointLeft; | 1321 | clippedPolyObject << pointLeft; | ||
919 | if ( pointBottom.x() > m_left ) | 1322 | if ( pointBottom.x() > m_left ) | ||
920 | clippedPolyObject << pointBottom; | 1323 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
925 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | 1328 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | ||
926 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | 1329 | QPointF pointLeft = clipLeft( m, m_currentPoint ); | ||
927 | 1330 | | |||
928 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | 1331 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | ||
929 | clippedPolyObject << pointTop; | 1332 | clippedPolyObject << pointTop; | ||
930 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | 1333 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | ||
931 | clippedPolyObject << pointRight; | 1334 | clippedPolyObject << pointRight; | ||
932 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | 1335 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | ||
933 | clippedPolyObject << pointBottom; | 1336 | clippedPolyObject << pointBottom; | ||
934 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | 1337 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | ||
935 | clippedPolyObject << pointLeft; | 1338 | clippedPolyObject << pointLeft; | ||
936 | 1339 | | |||
937 | if ( pointBottom.x() >= m_right && pointRight.y() >= m_bottom ) | 1340 | if ( pointBottom.x() >= m_right && pointRight.y() >= m_bottom ) | ||
938 | clippedPolyObject << QPointF( m_right, m_bottom ); | 1341 | clippedPolyObject << QPointF( m_right, m_bottom ); | ||
939 | if ( pointTop.x() <= m_left && pointLeft.y() <= m_top ) | 1342 | if ( pointTop.x() <= m_left && pointLeft.y() <= m_top ) | ||
Context not available. | |||||
975 | 1378 | | |||
976 | if ( pointTop.x() > m_left ) | 1379 | if ( pointTop.x() > m_left ) | ||
977 | clippedPolyObject << pointTop; | 1380 | clippedPolyObject << pointTop; | ||
978 | if ( pointLeft.y() >= m_top && pointLeft.y() < m_bottom ) | 1381 | if ( pointLeft.y() >= m_top && pointLeft.y() < m_bottom ) | ||
979 | clippedPolyObject << pointLeft; | 1382 | clippedPolyObject << pointLeft; | ||
980 | if ( pointBottom.x() > m_left ) { | 1383 | if ( pointBottom.x() > m_left ) { | ||
981 | clippedPolyObject << pointBottom; | 1384 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
994 | 1397 | | |||
995 | if ( pointTop.x() < m_right ) | 1398 | if ( pointTop.x() < m_right ) | ||
996 | clippedPolyObject << pointTop; | 1399 | clippedPolyObject << pointTop; | ||
997 | if ( pointRight.y() >= m_top && pointRight.y() < m_bottom ) | 1400 | if ( pointRight.y() >= m_top && pointRight.y() < m_bottom ) | ||
998 | clippedPolyObject << pointRight; | 1401 | clippedPolyObject << pointRight; | ||
999 | if ( pointBottom.x() < m_right ) { | 1402 | if ( pointBottom.x() < m_right ) { | ||
1000 | clippedPolyObject << pointBottom; | 1403 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
1017 | } | 1420 | } | ||
1018 | if ( pointBottom.x() > m_left && pointBottom.x() <= m_right ) | 1421 | if ( pointBottom.x() > m_left && pointBottom.x() <= m_right ) | ||
1019 | clippedPolyObject << pointBottom; | 1422 | clippedPolyObject << pointBottom; | ||
1020 | if ( pointRight.y() < m_bottom ) | 1423 | if ( pointRight.y() < m_bottom ) | ||
1021 | clippedPolyObject << pointRight; | 1424 | clippedPolyObject << pointRight; | ||
1022 | } | 1425 | } | ||
1023 | else if ( m_previousSector == 1 ) { | 1426 | else if ( m_previousSector == 1 ) { | ||
Context not available. | |||||
1030 | } else { | 1433 | } else { | ||
1031 | clippedPolyObject << QPointF( m_right, m_top ); | 1434 | clippedPolyObject << QPointF( m_right, m_top ); | ||
1032 | } | 1435 | } | ||
1033 | if ( pointRight.y() > m_top && pointRight.y() <= m_bottom ) | 1436 | if ( pointRight.y() > m_top && pointRight.y() <= m_bottom ) | ||
1034 | clippedPolyObject << pointRight; | 1437 | clippedPolyObject << pointRight; | ||
1035 | if ( pointBottom.x() < m_right ) | 1438 | if ( pointBottom.x() < m_right ) | ||
1036 | clippedPolyObject << pointBottom; | 1439 | clippedPolyObject << pointBottom; | ||
Context not available. | |||||
1041 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | 1444 | QPointF pointBottom = clipBottom( m, m_previousPoint ); | ||
1042 | QPointF pointRight = clipRight( m, m_previousPoint ); | 1445 | QPointF pointRight = clipRight( m, m_previousPoint ); | ||
1043 | 1446 | | |||
1044 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | 1447 | if ( pointTop.x() > m_left && pointTop.x() < m_right ) | ||
1045 | clippedPolyObject << pointTop; | 1448 | clippedPolyObject << pointTop; | ||
1046 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | 1449 | if ( pointLeft.y() > m_top && pointLeft.y() < m_bottom ) | ||
1047 | clippedPolyObject << pointLeft; | 1450 | clippedPolyObject << pointLeft; | ||
1048 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | 1451 | if ( pointBottom.x() > m_left && pointBottom.x() < m_right ) | ||
1049 | clippedPolyObject << pointBottom; | 1452 | clippedPolyObject << pointBottom; | ||
1050 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | 1453 | if ( pointRight.y() > m_top && pointRight.y() < m_bottom ) | ||
1051 | clippedPolyObject << pointRight; | 1454 | clippedPolyObject << pointRight; | ||
1052 | 1455 | | |||
1053 | if ( pointBottom.x() <= m_left && pointLeft.y() >= m_bottom ) | 1456 | if ( pointBottom.x() <= m_left && pointLeft.y() >= m_bottom ) | ||
1054 | clippedPolyObject << QPointF( m_left, m_bottom ); | 1457 | clippedPolyObject << QPointF( m_left, m_bottom ); | ||
1055 | if ( pointTop.x() >= m_right && pointRight.y() <= m_top ) | 1458 | if ( pointTop.x() >= m_right && pointRight.y() <= m_top ) | ||
Context not available. | |||||
1060 | break; | 1463 | break; | ||
1061 | 1464 | | |||
1062 | default: | 1465 | default: | ||
1063 | break; | 1466 | break; | ||
1064 | } | 1467 | } | ||
1065 | } | 1468 | } | ||
1066 | 1469 | | |||
1067 | void ClipPainterPrivate::clipOnceCorner( QPolygonF & clippedPolyObject, | 1470 | void ClipPainterPrivate::clipOnceCorner( QPolygonF & clippedPolyObject, | ||
1068 | QVector<QPolygonF> & clippedPolyObjects, | 1471 | QVector<QPolygonF> & clippedPolyObjects, | ||
1069 | const QPointF& corner, | 1472 | const QPointF& corner, | ||
1070 | const QPointF& point, | 1473 | const QPointF& point, | ||
1071 | bool isClosed ) const | 1474 | bool isClosed ) const | ||
1072 | { | 1475 | { | ||
1073 | Q_UNUSED( clippedPolyObjects ) | 1476 | Q_UNUSED( clippedPolyObjects ) | ||
Context not available. | |||||
1100 | // Disappearing | 1503 | // Disappearing | ||
1101 | clippedPolyObject << point; | 1504 | clippedPolyObject << point; | ||
1102 | if ( !isClosed ) { | 1505 | if ( !isClosed ) { | ||
1103 | clippedPolyObjects << clippedPolyObject; | 1506 | clippedPolyObjects << clippedPolyObject; | ||
1507 | clippedPolyObject = QPolygonF(); | ||||
1104 | } | 1508 | } | ||
1105 | } | 1509 | } | ||
1106 | } | 1510 | } | ||
Context not available. | |||||
1115 | // Calculating the slope. | 1519 | // Calculating the slope. | ||
1116 | qreal m = _m( m_previousPoint, m_currentPoint ); | 1520 | qreal m = _m( m_previousPoint, m_currentPoint ); | ||
1117 | 1521 | | |||
1118 | // Calculate in which sector the end of the line is located that is off screen | 1522 | // 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; | 1523 | int offscreenpos = ( m_currentSector == 4 ) ? m_previousSector : m_currentSector; | ||
1120 | 1524 | | |||
1121 | // "Rise over run" for all possible situations . | 1525 | // "Rise over run" for all possible situations . | ||
Context not available. | |||||
1165 | clipOnceCorner( clippedPolyObject, clippedPolyObjects, QPointF( m_right, m_bottom ), point, isClosed ); | 1569 | clipOnceCorner( clippedPolyObject, clippedPolyObjects, QPointF( m_right, m_bottom ), point, isClosed ); | ||
1166 | break; | 1570 | break; | ||
1167 | default: | 1571 | default: | ||
1168 | break; | 1572 | break; | ||
1169 | } | 1573 | } | ||
1170 | 1574 | | |||
1171 | } | 1575 | } | ||
Context not available. |