Skip to content

Commit

Permalink
fix eVis Event Browser and ID tool
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15740 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
alexbruy committed Apr 17, 2011
1 parent 3c0f834 commit fbd10b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp
Expand Up @@ -258,8 +258,7 @@ bool eVisGenericEventBrowserGui::initBrowser( )
*/
if ( 0 == mVectorLayer->selectedFeatureCount( ) ) //if nothing is selected select everything
{
QgsRectangle myRect;
mVectorLayer->select( myRect, true );
mVectorLayer->invertSelection();
mFeatureIds = mVectorLayer->selectedFeaturesIds( ).toList( );
}
else //use selected features
Expand Down
20 changes: 14 additions & 6 deletions src/plugins/evis/idtool/eviseventidtool.cpp
Expand Up @@ -60,7 +60,6 @@ eVisEventIdTool::eVisEventIdTool( QgsMapCanvas* theCanvas )
*/
void eVisEventIdTool::canvasReleaseEvent( QMouseEvent* theMouseEvent )
{

if ( 0 == mCanvas || 0 == theMouseEvent ) { return; }

//Check to see if there is a layer selected
Expand Down Expand Up @@ -90,26 +89,35 @@ void eVisEventIdTool::select( QgsPoint thePoint )
{

if ( 0 == mCanvas ) { return; }

QgsVectorLayer* myLayer = ( QgsVectorLayer* )mCanvas->currentLayer( );

// create the search rectangle. this was modeled after the QgsMapIdentifyTool in core QGIS application
double searchWidth = mCanvas->extent( ).width( ) * (( double )QGis::DEFAULT_IDENTIFY_RADIUS / 100.0 );

QgsRectangle myRectangle;
myRectangle.setXMinimum( thePoint.x( ) - searchWidth );
myRectangle.setXMaximum( thePoint.x( ) + searchWidth );
myRectangle.setYMinimum( thePoint.y( ) - searchWidth );
myRectangle.setYMaximum( thePoint.y( ) + searchWidth );

//Transform rectange to map coordinates
myRectangle = toLayerCoordinates( myLayer, myRectangle );

//Rather than add to the current selection, clear all selected features
myLayer->removeSelection( false );
//select features
myLayer->select( myRectangle, false );
myLayer->select( QgsAttributeList(), myRectangle, true, true );

QgsFeature f;
QgsFeatureIds newSelectedFeatures;
while ( myLayer->nextFeature( f ) )
{
newSelectedFeatures.insert( f.id() );
}

myLayer->setSelectedFeatures( newSelectedFeatures );

//Launch a new event browser to view selected features
mBrowser = new eVisGenericEventBrowserGui( mCanvas, mCanvas, NULL );
mBrowser->setAttribute( Qt::WA_DeleteOnClose );
Expand Down

0 comments on commit fbd10b5

Please sign in to comment.