Skip to content

Commit d8e8ee4

Browse files
author
jef
committed
workaround for #1759
git-svn-id: http://svn.osgeo.org/qgis/trunk@12833 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent bad5345 commit d8e8ee4

File tree

1 file changed

+81
-64
lines changed

1 file changed

+81
-64
lines changed

src/core/qgsvectorlayer.cpp

+81-64
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,6 @@ unsigned char *QgsVectorLayer::drawLineString( unsigned char *feature, QgsRender
439439
pa[i].setY( y[i] );
440440
}
441441

442-
#ifdef QGISDEBUGVERBOSE
443-
// this is only used for verbose debug output
444-
for ( int i = 0; i < pa.size(); ++i )
445-
{
446-
QgsDebugMsgLevel( "pa" + QString::number( pa.point( i ).x() ), 2 );
447-
QgsDebugMsgLevel( "pa" + QString::number( pa.point( i ).y() ), 2 );
448-
}
449-
#endif
450-
451442
// The default pen gives bevelled joins between segements of the
452443
// polyline, which is good enough for the moment.
453444
//preserve a copy of the pen before we start fiddling with it
@@ -581,52 +572,6 @@ unsigned char *QgsVectorLayer::drawPolygon( unsigned char *feature, QgsRenderCon
581572
// Only try to draw polygons if there is something to draw
582573
if ( total_points > 0 )
583574
{
584-
// Store size here and use it in the loop to avoid penalty of
585-
// multiple calls to size()
586-
int numRings = rings.size();
587-
for ( register int i = 0; i < numRings; ++i )
588-
{
589-
// Store the pointer in a variable with a short name so as to make
590-
// the following code easier to type and read.
591-
ringTypePtr r = rings[i];
592-
// only do this once to avoid penalty of additional calls
593-
unsigned ringSize = r->first.size();
594-
595-
// Transfer points to the array of QPointF
596-
QPolygonF pa( ringSize );
597-
for ( register unsigned int j = 0; j != ringSize; ++j )
598-
{
599-
pa[j].setX( r->first[j] );
600-
pa[j].setY( r->second[j] );
601-
}
602-
603-
path.addPolygon( pa );
604-
605-
// Tidy up the pointed to pairs of vectors as we finish with them
606-
delete rings[i];
607-
}
608-
609-
#if 0
610-
// A bit of code to aid in working out what values of
611-
// QgsClipper::minX, etc cause the X11 zoom bug.
612-
int largestX = -std::numeric_limits<int>::max();
613-
int smallestX = std::numeric_limits<int>::max();
614-
int largestY = -std::numeric_limits<int>::max();
615-
int smallestY = std::numeric_limits<int>::max();
616-
617-
for ( int i = 0; i < pa.size(); ++i )
618-
{
619-
largestX = std::max( largestX, pa.point( i ).x() );
620-
smallestX = std::min( smallestX, pa.point( i ).x() );
621-
largestY = std::max( largestY, pa.point( i ).y() );
622-
smallestY = std::min( smallestY, pa.point( i ).y() );
623-
}
624-
QgsDebugMsg( QString( "Largest X coordinate was %1" ).arg( largestX ) );
625-
QgsDebugMsg( QString( "Smallest X coordinate was %1" ).arg( smallestX ) );
626-
QgsDebugMsg( QString( "Largest Y coordinate was %1" ).arg( largestY ) );
627-
QgsDebugMsg( QString( "Smallest Y coordinate was %1" ).arg( smallestY ) );
628-
#endif
629-
630575
//preserve a copy of the brush and pen before we start fiddling with it
631576
QBrush brush = p->brush(); //to be kept as original
632577
QPen pen = p->pen(); // to be kept original
@@ -658,19 +603,91 @@ unsigned char *QgsVectorLayer::drawPolygon( unsigned char *feature, QgsRenderCon
658603
p->setBrush( myTransparentBrush );
659604
p->setPen( myTransparentPen );
660605

661-
//
662-
// draw the polygon
663-
//
664-
p->drawPath( path );
606+
if ( numRings == 1 )
607+
{
608+
ringTypePtr r = rings[0];
609+
unsigned ringSize = r->first.size();
610+
611+
QPolygonF pa( ringSize );
612+
for ( register unsigned int j = 0; j != ringSize; ++j )
613+
{
614+
pa[j].setX( r->first[j] );
615+
pa[j].setY( r->second[j] );
616+
}
617+
p->drawPolygon( pa );
665618

619+
// draw vertex markers if in editing mode, but only to the main canvas
620+
if ( mEditable && renderContext.drawEditingInformation() )
621+
{
622+
for ( register unsigned int j = 0; j != ringSize; ++j )
623+
{
624+
drawVertexMarker( r->first[j], r->second[j], *p, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
625+
}
626+
}
666627

667-
// draw vertex markers if in editing mode, but only to the main canvas
668-
if ( mEditable && renderContext.drawEditingInformation() )
628+
delete rings[0];
629+
}
630+
else
669631
{
670-
for ( int i = 0; i < path.elementCount(); ++i )
632+
// Store size here and use it in the loop to avoid penalty of
633+
// multiple calls to size()
634+
int numRings = rings.size();
635+
for ( register int i = 0; i < numRings; ++i )
636+
{
637+
// Store the pointer in a variable with a short name so as to make
638+
// the following code easier to type and read.
639+
ringTypePtr r = rings[i];
640+
// only do this once to avoid penalty of additional calls
641+
unsigned ringSize = r->first.size();
642+
643+
// Transfer points to the array of QPointF
644+
QPolygonF pa( ringSize );
645+
for ( register unsigned int j = 0; j != ringSize; ++j )
646+
{
647+
pa[j].setX( r->first[j] );
648+
pa[j].setY( r->second[j] );
649+
}
650+
651+
path.addPolygon( pa );
652+
653+
// Tidy up the pointed to pairs of vectors as we finish with them
654+
delete rings[i];
655+
}
656+
657+
#if 0
658+
// A bit of code to aid in working out what values of
659+
// QgsClipper::minX, etc cause the X11 zoom bug.
660+
int largestX = -std::numeric_limits<int>::max();
661+
int smallestX = std::numeric_limits<int>::max();
662+
int largestY = -std::numeric_limits<int>::max();
663+
int smallestY = std::numeric_limits<int>::max();
664+
665+
for ( int i = 0; i < pa.size(); ++i )
671666
{
672-
const QPainterPath::Element & e = path.elementAt( i );
673-
drawVertexMarker( e.x, e.y, *p, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
667+
largestX = std::max( largestX, pa.point( i ).x() );
668+
smallestX = std::min( smallestX, pa.point( i ).x() );
669+
largestY = std::max( largestY, pa.point( i ).y() );
670+
smallestY = std::min( smallestY, pa.point( i ).y() );
671+
}
672+
QgsDebugMsg( QString( "Largest X coordinate was %1" ).arg( largestX ) );
673+
QgsDebugMsg( QString( "Smallest X coordinate was %1" ).arg( smallestX ) );
674+
QgsDebugMsg( QString( "Largest Y coordinate was %1" ).arg( largestY ) );
675+
QgsDebugMsg( QString( "Smallest Y coordinate was %1" ).arg( smallestY ) );
676+
#endif
677+
678+
//
679+
// draw the polygon
680+
//
681+
p->drawPath( path );
682+
683+
// draw vertex markers if in editing mode, but only to the main canvas
684+
if ( mEditable && renderContext.drawEditingInformation() )
685+
{
686+
for ( int i = 0; i < path.elementCount(); ++i )
687+
{
688+
const QPainterPath::Element & e = path.elementAt( i );
689+
drawVertexMarker( e.x, e.y, *p, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
690+
}
674691
}
675692
}
676693

0 commit comments

Comments
 (0)