Yet more fixes for bugs in the X11 zoom clipping code. Hopefully all sorted

now. Still need to optimise the code a bit.


git-svn-id: http://svn.osgeo.org/qgis/trunk@3136 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
g_j_m 2005-04-12 10:23:06 +00:00
parent 72eb589963
commit e75d32ed0d
2 changed files with 23 additions and 17 deletions

View File

@ -69,8 +69,8 @@ bool QgsClipper::trimLine(QgsPoint& from, QgsPoint& to)
QgsPoint trimmedTo = to, trimmedFrom = from; QgsPoint trimmedTo = to, trimmedFrom = from;
// Check for the need to trim first // Check for the need to trim first
if (from.x() < minX || from.x() > maxX || to.x() < minX || to.x() > maxX || if (std::abs(from.x()) > maxX || std::abs(to.x()) > maxX ||
from.y() < minY || from.y() > maxY || to.y() < minY || to.y() > maxY) std::abs(from.y()) > maxY || std::abs(to.y()) > maxY)
{ {
// Check the top boundary // Check the top boundary
double r_n = (from.y() - minY) * (maxX - minX); double r_n = (from.y() - minY) * (maxX - minX);
@ -213,19 +213,25 @@ bool QgsClipper::trimLine(QgsPoint& from, QgsPoint& to)
} }
} }
} }
// If the line hasn't been trimmed yet, it is entirely outside the
// boundary, so tell the calling code. // Done something, so leave.
if (!toDone && !fromDone) if (toDone || fromDone)
{ {
to = trimmedTo; to = trimmedTo;
from = trimmedFrom; from = trimmedFrom;
return true; return true;
} }
// If the line hasn't been trimmed yet, it is entirely outside the
// boundary, so tell the calling code.
if (!toDone && !fromDone)
return false;
// Shouldn't get here
std::cerr << "XXXXXXXXXXXXXXXXXXXXXXXXXXX\n";
} }
to = trimmedTo; // The line is inside the boundary. Needs to be drawn.
from = trimmedFrom;
return true; return true;
} }

View File

@ -2270,16 +2270,16 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
{ {
//reproject the point to the map coordinate system //reproject the point to the map coordinate system
try try
{ {
myProjectedPoint=mCoordinateTransform->transform(pt); myProjectedPoint=mCoordinateTransform->transform(pt);
} }
catch (QgsCsException &e) catch (QgsCsException &e)
{ {
qDebug( "Transform error caught in %s line %d:\n%s", qDebug( "Transform error caught in %s line %d:\n%s",
__FILE__, __LINE__, e.what()); __FILE__, __LINE__, e.what());
} }
// transform from projected coordinate system to pixel position // transform from projected coordinate system to pixel position
// on map canvas // on map canvas
theMapToPixelTransform->transform(&myProjectedPoint); theMapToPixelTransform->transform(&myProjectedPoint);
} }
else else