@@ -60,7 +60,6 @@ eVisEventIdTool::eVisEventIdTool( QgsMapCanvas* theCanvas )
60
60
*/
61
61
void eVisEventIdTool::canvasReleaseEvent ( QMouseEvent* theMouseEvent )
62
62
{
63
-
64
63
if ( 0 == mCanvas || 0 == theMouseEvent ) { return ; }
65
64
66
65
// Check to see if there is a layer selected
@@ -90,26 +89,35 @@ void eVisEventIdTool::select( QgsPoint thePoint )
90
89
{
91
90
92
91
if ( 0 == mCanvas ) { return ; }
93
-
92
+
94
93
QgsVectorLayer* myLayer = ( QgsVectorLayer* )mCanvas ->currentLayer ( );
95
-
94
+
96
95
// create the search rectangle. this was modeled after the QgsMapIdentifyTool in core QGIS application
97
96
double searchWidth = mCanvas ->extent ( ).width ( ) * (( double )QGis::DEFAULT_IDENTIFY_RADIUS / 100.0 );
98
-
97
+
99
98
QgsRectangle myRectangle;
100
99
myRectangle.setXMinimum ( thePoint.x ( ) - searchWidth );
101
100
myRectangle.setXMaximum ( thePoint.x ( ) + searchWidth );
102
101
myRectangle.setYMinimum ( thePoint.y ( ) - searchWidth );
103
102
myRectangle.setYMaximum ( thePoint.y ( ) + searchWidth );
104
-
103
+
105
104
// Transform rectange to map coordinates
106
105
myRectangle = toLayerCoordinates ( myLayer, myRectangle );
107
106
108
107
// Rather than add to the current selection, clear all selected features
109
108
myLayer->removeSelection ( false );
110
109
// 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
+ }
112
118
119
+ myLayer->setSelectedFeatures ( newSelectedFeatures );
120
+
113
121
// Launch a new event browser to view selected features
114
122
mBrowser = new eVisGenericEventBrowserGui ( mCanvas , mCanvas , NULL );
115
123
mBrowser ->setAttribute ( Qt::WA_DeleteOnClose );
0 commit comments