@@ -60,7 +60,6 @@ eVisEventIdTool::eVisEventIdTool( QgsMapCanvas* theCanvas )
6060*/
6161void eVisEventIdTool::canvasReleaseEvent ( QMouseEvent* theMouseEvent )
6262{
63-
6463 if ( 0 == mCanvas || 0 == theMouseEvent ) { return ; }
6564
6665 // Check to see if there is a layer selected
@@ -90,26 +89,35 @@ void eVisEventIdTool::select( QgsPoint thePoint )
9089{
9190
9291 if ( 0 == mCanvas ) { return ; }
93-
92+
9493 QgsVectorLayer* myLayer = ( QgsVectorLayer* )mCanvas ->currentLayer ( );
95-
94+
9695 // create the search rectangle. this was modeled after the QgsMapIdentifyTool in core QGIS application
9796 double searchWidth = mCanvas ->extent ( ).width ( ) * (( double )QGis::DEFAULT_IDENTIFY_RADIUS / 100.0 );
98-
97+
9998 QgsRectangle myRectangle;
10099 myRectangle.setXMinimum ( thePoint.x ( ) - searchWidth );
101100 myRectangle.setXMaximum ( thePoint.x ( ) + searchWidth );
102101 myRectangle.setYMinimum ( thePoint.y ( ) - searchWidth );
103102 myRectangle.setYMaximum ( thePoint.y ( ) + searchWidth );
104-
103+
105104 // Transform rectange to map coordinates
106105 myRectangle = toLayerCoordinates ( myLayer, myRectangle );
107106
108107 // Rather than add to the current selection, clear all selected features
109108 myLayer->removeSelection ( false );
110109 // select features
111- myLayer->select ( myRectangle, false );
110+ myLayer->select ( QgsAttributeList (), myRectangle, true , true );
111+
112+ QgsFeature f;
113+ QgsFeatureIds newSelectedFeatures;
114+ while ( myLayer->nextFeature ( f ) )
115+ {
116+ newSelectedFeatures.insert ( f.id () );
117+ }
112118
119+ myLayer->setSelectedFeatures ( newSelectedFeatures );
120+
113121 // Launch a new event browser to view selected features
114122 mBrowser = new eVisGenericEventBrowserGui ( mCanvas , mCanvas , NULL );
115123 mBrowser ->setAttribute ( Qt::WA_DeleteOnClose );
0 commit comments