Skip to content
Permalink
Browse files

give correct layer to QgsHighlight in QgsIdentifyResultsDialog, fixes #…

  • Loading branch information
blazek committed Oct 1, 2013
1 parent 968c321 commit 96bd7e7f2e1b70e2515e628d3c5583d7d73eeb50
Showing with 27 additions and 7 deletions.
  1. +6 −3 src/app/qgsidentifyresultsdialog.cpp
  2. +17 −3 src/gui/qgshighlight.cpp
  3. +4 −1 src/gui/qgshighlight.h
@@ -1143,10 +1143,13 @@ void QgsIdentifyResultsDialog::attributeValueChanged( QgsFeatureId fid, int idx,

void QgsIdentifyResultsDialog::highlightFeature( QTreeWidgetItem *item )
{
QgsVectorLayer *layer = vectorLayer( item );
QgsMapLayer *layer;
QgsVectorLayer *vlayer = vectorLayer( item );
QgsRasterLayer *rlayer = rasterLayer( item );
if ( !layer && !rlayer )
return;

layer = vlayer ? static_cast<QgsMapLayer *>( vlayer ) : static_cast<QgsMapLayer *>( rlayer );

if ( !layer ) return;

QgsIdentifyResultsFeatureItem *featItem = dynamic_cast<QgsIdentifyResultsFeatureItem *>( featureItem( item ) );
if ( !featItem )
@@ -16,6 +16,7 @@
#include "qgshighlight.h"
#include "qgsgeometry.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayer.h"
#include "qgsmaprenderer.h"
#include "qgscoordinatetransform.h"
#include "qgsvectorlayer.h"
@@ -25,14 +26,27 @@
\brief The QgsHighlight class provides a transparent overlay widget
for highlightng features on the map.
*/
QgsHighlight::QgsHighlight( QgsMapCanvas* mapCanvas, QgsGeometry *geom, QgsVectorLayer *layer )
QgsHighlight::QgsHighlight( QgsMapCanvas* mapCanvas, QgsGeometry *geom, QgsMapLayer *layer )
: QgsMapCanvasItem( mapCanvas )
, mLayer( layer )
{
mGeometry = geom ? new QgsGeometry( *geom ) : 0;
if ( mapCanvas->mapRenderer()->hasCrsTransformEnabled() )
init();
}

QgsHighlight::QgsHighlight( QgsMapCanvas* mapCanvas, QgsGeometry *geom, QgsVectorLayer *layer )
: QgsMapCanvasItem( mapCanvas )
, mLayer( static_cast<QgsMapLayer *>( layer ) )
{
mGeometry = geom ? new QgsGeometry( *geom ) : 0;
init();
}

void QgsHighlight::init()
{
if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
QgsCoordinateTransform transform( mLayer->crs(), mapCanvas->mapRenderer()->destinationCrs() );
QgsCoordinateTransform transform( mLayer->crs(), mMapCanvas->mapRenderer()->destinationCrs() );
mGeometry->transform( transform );
}
updateRect();
@@ -23,13 +23,15 @@
#include <QPainter>
#include <QPainterPath>

class QgsMapLayer;
class QgsVectorLayer;

/** A class for highlight features on the map.
*/
class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
{
public:
QgsHighlight( QgsMapCanvas *mapCanvas, QgsGeometry *geom, QgsMapLayer *layer );
QgsHighlight( QgsMapCanvas *mapCanvas, QgsGeometry *geom, QgsVectorLayer *layer );
~QgsHighlight();

@@ -43,6 +45,7 @@ class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
void updateRect();

private:
void init();
void paintPoint( QPainter *p, QgsPoint point );
void paintLine( QPainter *p, QgsPolyline line );
void paintPolygon( QPainter *p, QgsPolygon polygon );
@@ -52,7 +55,7 @@ class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
QBrush mBrush;
QPen mPen;
QgsGeometry *mGeometry;
QgsVectorLayer *mLayer;
QgsMapLayer *mLayer;
};

#endif

0 comments on commit 96bd7e7

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