Skip to content

Commit 214914c

Browse files
author
g_j_m
committed
Reverted commit 5064, as QgsClipper _is_ still required (if one
zooms in enough, qgis will crash while drawing with r5064, but won't crash under r5063). git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5065 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f95c460 commit 214914c

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/gui/qgsvectorlayer.cpp

+74
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
#include "qgsattributetabledisplay.h"
7979
#include "qgsdistancearea.h"
8080
#include "qgsvectordataprovider.h"
81+
#ifdef Q_WS_X11
82+
#include "qgsclipper.h"
83+
#endif
8184
#include "qgssvgcache.h"
8285
#include "qgsspatialrefsys.h"
8386
#include "qgis.h" //for globals
@@ -460,6 +463,22 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
460463

461464
transformPoints(x, y, z, mtp, projectionsEnabledFlag);
462465

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+
463482
// set up QPolygonF class with transformed points
464483
QPolygonF pa(nPoints);
465484
for (register unsigned int i = 0; i < nPoints; ++i)
@@ -564,6 +583,33 @@ std::cerr << jdx << ": "
564583

565584
transformPoints(ring->first, ring->second, zVector, mtp, projectionsEnabledFlag);
566585

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+
567613
// Don't bother keeping the ring if it has been trimmed out of
568614
// existence.
569615
if (ring->first.size() == 0)
@@ -650,6 +696,27 @@ std::cerr << jdx << ": "
650696
<< ", " << outerRingPt.y() << '\n';
651697
#endif
652698

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+
653720
//preserve a copy of the brush and pen before we start fiddling with it
654721
QBrush brush = p->brush(); //to be kept as original
655722
QPen pen = p->pen(); // to be kept original
@@ -3127,6 +3194,13 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
31273194
transformPoint(x, y, theMapToPixelTransform, projectionsEnabledFlag);
31283195
QPointF pt(x - (marker->width()/2), y - (marker->height()/2));
31293196

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
31303204
p->drawPixmap(pt, *marker);
31313205
}
31323206
p->restore();

0 commit comments

Comments
 (0)