Skip to content
Permalink
Browse files

Highlight selected features

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11936 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Nov 6, 2009
1 parent 2bd06b4 commit 97a84db70f0fd40448a8d7cc9ca11663540c0d02
@@ -52,6 +52,8 @@ class QgsRenderer
virtual QgsRenderer* clone() const=0;
/** Change selection color */
static void setSelectionColor(QColor color);
/** Get selection color */
static QColor selectionColor();
/**Returns true if this renderer returns a pixmap in the render method (e.g. for point data or diagrams)*/
virtual bool containsPixmap() const;
/**Returns true if this renderer uses its own transparency settings, e.g. differentiated by classification.
@@ -76,7 +76,7 @@
#include "qgsrendererv2.h"
#include "qgssymbolv2.h"
#include "qgssymbollayerv2.h"

#include "qgssinglesymbolrendererv2.h"

#ifdef TESTPROVIDERLIB
#include <dlfcn.h>
@@ -668,16 +668,33 @@ void QgsVectorLayer::drawRendererV2( QgsRenderContext& rendererContext, bool lab
{
mRendererV2->startRender(rendererContext, pendingFields());

QgsSingleSymbolRendererV2* selRenderer = NULL;
if (!mSelectedFeatureIds.isEmpty())
{
selRenderer = new QgsSingleSymbolRendererV2( QgsSymbolV2::defaultSymbol(geometryType()) );
selRenderer->symbol()->setColor( QgsRenderer::selectionColor() );
selRenderer->startRender(rendererContext, pendingFields());
}

QgsFeature fet;
while ( nextFeature( fet ) )
{
mRendererV2->renderFeature(fet, rendererContext);
if (mSelectedFeatureIds.contains( fet.id() ))
selRenderer->renderFeature(fet, rendererContext);
else
mRendererV2->renderFeature(fet, rendererContext);

if ( labeling )
mLabelingEngine->registerFeature(this, fet);
}

mRendererV2->stopRender(rendererContext);

if (selRenderer)
{
selRenderer->stopRender(rendererContext);
delete selRenderer;
}
}

void QgsVectorLayer::drawRendererV2Levels( QgsRenderContext& rendererContext, bool labeling )
@@ -687,6 +704,14 @@ void QgsVectorLayer::drawRendererV2Levels( QgsRenderContext& rendererContext, bo
// startRender must be called before symbolForFeature() calls to make sure renderer is ready
mRendererV2->startRender(rendererContext, pendingFields());

QgsSingleSymbolRendererV2* selRenderer = NULL;
if (!mSelectedFeatureIds.isEmpty())
{
selRenderer = new QgsSingleSymbolRendererV2( QgsSymbolV2::defaultSymbol(geometryType()) );
selRenderer->symbol()->setColor( QgsRenderer::selectionColor() );
selRenderer->startRender(rendererContext, pendingFields());
}

// 1. fetch features
QgsFeature fet;
while ( nextFeature(fet) )
@@ -734,11 +759,22 @@ void QgsVectorLayer::drawRendererV2Levels( QgsRenderContext& rendererContext, bo
QList<QgsFeature>& lst = features[item.symbol()];
QList<QgsFeature>::iterator fit;
for ( fit = lst.begin(); fit != lst.end(); ++fit )
mRendererV2->renderFeature(*fit, rendererContext, layer);
{
if (mSelectedFeatureIds.contains( fit->id() ))
selRenderer->renderFeature(*fit, rendererContext);
else
mRendererV2->renderFeature(*fit, rendererContext, layer);
}
}
}

mRendererV2->stopRender(rendererContext);

if (selRenderer)
{
selRenderer->stopRender(rendererContext);
delete selRenderer;
}
}

bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
@@ -39,6 +39,11 @@ void QgsRenderer::setSelectionColor( QColor color )
mSelectionColor = color;
}

QColor QgsRenderer::selectionColor()
{
return mSelectionColor;
}

bool QgsRenderer::containsPixmap() const
{
//default implementation returns true only for points
@@ -101,6 +101,8 @@ class CORE_EXPORT QgsRenderer
virtual QgsRenderer* clone() const = 0;
/** Change selection color */
static void setSelectionColor( QColor color );
/** Get selection color */
static QColor selectionColor();
/**Returns true if this renderer returns a pixmap in the render method (e.g. for point data or diagrams)*/
virtual bool containsPixmap() const;
/**Returns true if this renderer uses its own transparency settings, e.g. differentiated by classification.

0 comments on commit 97a84db

Please sign in to comment.
You can’t perform that action at this time.