Skip to content
Permalink
Browse files

fix eVis Event Browser and ID tool

git-svn-id: http://svn.osgeo.org/qgis/trunk@15740 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
alexbruy
alexbruy committed Apr 17, 2011
1 parent 3c0f834 commit fbd10b55e99a69bf75815237f537764749ef7e48
@@ -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
@@ -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
@@ -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 );

0 comments on commit fbd10b5

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