|
78 | 78 | #include "qgsattributetabledisplay.h"
|
79 | 79 | #include "qgsdistancearea.h"
|
80 | 80 | #include "qgsvectordataprovider.h"
|
| 81 | +#ifdef Q_WS_X11 |
| 82 | +#include "qgsclipper.h" |
| 83 | +#endif |
81 | 84 | #include "qgssvgcache.h"
|
82 | 85 | #include "qgsspatialrefsys.h"
|
83 | 86 | #include "qgis.h" //for globals
|
@@ -460,6 +463,22 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
|
460 | 463 |
|
461 | 464 | transformPoints(x, y, z, mtp, projectionsEnabledFlag);
|
462 | 465 |
|
| 466 | +#if defined(Q_WS_X11) |
| 467 | + // Work around a +/- 32768 limitation on coordinates in X11 |
| 468 | + |
| 469 | + // Look through the x and y coordinates and see if there are any |
| 470 | + // that need trimming. If one is found, there's no need to look at |
| 471 | + // the rest of them so end the loop at that point. |
| 472 | + for (register unsigned int i = 0; i < nPoints; ++i) |
| 473 | + if (std::abs(x[i]) > QgsClipper::maxX || |
| 474 | + std::abs(y[i]) > QgsClipper::maxY) |
| 475 | + { |
| 476 | + QgsClipper::trimFeature(x, y, true); // true = polyline |
| 477 | + nPoints = x.size(); // trimming may change nPoints. |
| 478 | + break; |
| 479 | + } |
| 480 | +#endif |
| 481 | + |
463 | 482 | // set up QPolygonF class with transformed points
|
464 | 483 | QPolygonF pa(nPoints);
|
465 | 484 | for (register unsigned int i = 0; i < nPoints; ++i)
|
@@ -564,6 +583,33 @@ std::cerr << jdx << ": "
|
564 | 583 |
|
565 | 584 | transformPoints(ring->first, ring->second, zVector, mtp, projectionsEnabledFlag);
|
566 | 585 |
|
| 586 | +#if defined(Q_WS_X11) |
| 587 | + // Work around a +/- 32768 limitation on coordinates in X11 |
| 588 | + |
| 589 | + // Look through the x and y coordinates and see if there are any |
| 590 | + // that need trimming. If one is found, there's no need to look at |
| 591 | + // the rest of them so end the loop at that point. |
| 592 | + for (register unsigned int i = 0; i < nPoints; ++i) |
| 593 | + { |
| 594 | + if (std::abs(ring->first[i]) > QgsClipper::maxX || |
| 595 | + std::abs(ring->second[i]) > QgsClipper::maxY) |
| 596 | + { |
| 597 | + QgsClipper::trimFeature(ring->first, ring->second, false); |
| 598 | + /* |
| 599 | +#ifdef QGISDEBUG |
| 600 | +std::cerr << "Trimmed points (" << ring->first.size() << ")\n"; |
| 601 | +for (int i = 0; i < ring->first.size(); ++i) |
| 602 | +std::cerr << i << ": " << ring->first[i] |
| 603 | +<< ", " << ring->second[i] << '\n'; |
| 604 | +#endif |
| 605 | +*/ |
| 606 | + break; |
| 607 | + } |
| 608 | + //std::cout << "POLYGONTRANSFORM: " << ring->first[i] << ", " << ring->second[i] << std::endl; |
| 609 | + } |
| 610 | + |
| 611 | +#endif |
| 612 | + |
567 | 613 | // Don't bother keeping the ring if it has been trimmed out of
|
568 | 614 | // existence.
|
569 | 615 | if (ring->first.size() == 0)
|
@@ -650,6 +696,27 @@ std::cerr << jdx << ": "
|
650 | 696 | << ", " << outerRingPt.y() << '\n';
|
651 | 697 | #endif
|
652 | 698 |
|
| 699 | + /* |
| 700 | + // A bit of code to aid in working out what values of |
| 701 | + // QgsClipper::minX, etc cause the X11 zoom bug. |
| 702 | + int largestX = -std::numeric_limits<int>::max(); |
| 703 | + int smallestX = std::numeric_limits<int>::max(); |
| 704 | + int largestY = -std::numeric_limits<int>::max(); |
| 705 | + int smallestY = std::numeric_limits<int>::max(); |
| 706 | +
|
| 707 | + for (int i = 0; i < pa.size(); ++i) |
| 708 | + { |
| 709 | + largestX = std::max(largestX, pa.point(i).x()); |
| 710 | + smallestX = std::min(smallestX, pa.point(i).x()); |
| 711 | + largestY = std::max(largestY, pa.point(i).y()); |
| 712 | + smallestY = std::min(smallestY, pa.point(i).y()); |
| 713 | + } |
| 714 | + std::cerr << "Largest X coordinate was " << largestX << '\n'; |
| 715 | + std::cerr << "Smallest X coordinate was " << smallestX << '\n'; |
| 716 | + std::cerr << "Largest Y coordinate was " << largestY << '\n'; |
| 717 | + std::cerr << "Smallest Y coordinate was " << smallestY << '\n'; |
| 718 | + */ |
| 719 | + |
653 | 720 | //preserve a copy of the brush and pen before we start fiddling with it
|
654 | 721 | QBrush brush = p->brush(); //to be kept as original
|
655 | 722 | QPen pen = p->pen(); // to be kept original
|
@@ -3127,6 +3194,13 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
|
3127 | 3194 | transformPoint(x, y, theMapToPixelTransform, projectionsEnabledFlag);
|
3128 | 3195 | QPointF pt(x - (marker->width()/2), y - (marker->height()/2));
|
3129 | 3196 |
|
| 3197 | +#if defined(Q_WS_X11) |
| 3198 | + // Work around a +/- 32768 limitation on coordinates in X11 |
| 3199 | + if (std::abs(x) > QgsClipper::maxX || |
| 3200 | + std::abs(y) > QgsClipper::maxY) |
| 3201 | + needToTrim = true; |
| 3202 | + else |
| 3203 | +#endif |
3130 | 3204 | p->drawPixmap(pt, *marker);
|
3131 | 3205 | }
|
3132 | 3206 | p->restore();
|
|
0 commit comments