[Qgis-developer] patch to draw selected features on top

Marco Hugentobler marco.hugentobler at karto.baug.ethz.ch
Sat Feb 16 02:54:15 EST 2008


Hi Stefanie,

Thanks for sending this patch. I think it is good to know about modifications 
people make to the code, even if not all of them can go to svn. 

In this particular case, my suggestion is to not apply it to svn. As you 
mention, selected features are drawn twice. Ok, it would be possible to skip 
them in the first drawing loop. But even then getFeatureAtId is not very fast 
for data providers that don't provide fast random access (e.g. gpx, delimited 
text, wfs).

Regards,
Marco

Am Donnerstag 14 Februar 2008 14:39:42 schrieb Stefanie Tellex:
> Hi,
>
> I wanted to draw selected features on top so you can clearly see them
> when they're selected, rather than being obscured by other features that
> happen to come out first in the database.
>
> The patch works by adding an extra draw for selected features, after the
> normal draw.  I did it that way because the normal draw was doing
> various event handling stuff that I didn't want to break, and I'm
> ignorant of the performance ramifications so I didn't want to try
> something more elegant like making a list of all the feature ids and
> then loading each one instead of doing a cursor and a group select as it
> does now.
>
> I'm not sure you'll be interested in this patch at all, but I find it
> very useful.
>
>
> Tim, I've always been attaching my patches as a file rather than
> inlining them.  I use thunderbird... maybe it's messing up somehow?
> This time I both attached it as a file and inlined it at the end of this
> email.  I'm also mailing you directly, in addition to mailing the list,
> to see if any of that helps.
>
> Stefanie
>
>
> Index: src/core/qgsvectorlayer.cpp
> ===================================================================
> --- src/core/qgsvectorlayer.cpp	(revision 8155)
> +++ src/core/qgsvectorlayer.cpp	(working copy)
> @@ -859,7 +859,15 @@
>             drawFeature(p,*it,theMapToPixelTransform,ct, &marker,scale,
> drawingToEditingCanvas);
>           }
>         }
> +      for(QgsFeatureIds::iterator iter = mSelectedFeatureIds.begin();
> iter != mSelectedFeatureIds.end(); ++iter)
> +	{
> +	  mDataProvider->getFeatureAtId(*iter, fet);
> +	  mRenderer->renderFeature(p,fet, &marker, &markerScaleFactor, TRUE,
> widthScale );
> +	  double scale = symbolScale / markerScaleFactor;
> +	  drawFeature(p,fet,theMapToPixelTransform,ct, &marker, scale,
> drawingToEditingCanvas);
>
> +	}
> +
>       }
>       catch (QgsCsException &cse)
>       {



-- 
Dr. Marco Hugentobler
Institute of Cartography
ETH Zurich
Technical Advisor QGIS Project Steering Committee


More information about the Qgis-developer mailing list