mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-12 00:06:43 -04:00
Apply non-string parts of patch #2938
git-svn-id: http://svn.osgeo.org/qgis/trunk@14497 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
ca8eebe6a5
commit
485ae1921f
@ -29,7 +29,7 @@
|
||||
|
||||
|
||||
QgsMapToolSelect::QgsMapToolSelect( QgsMapCanvas* canvas )
|
||||
: QgsMapTool( canvas )
|
||||
: QgsMapTool( canvas )
|
||||
{
|
||||
mCursor = Qt::ArrowCursor;
|
||||
}
|
||||
@ -37,7 +37,7 @@ QgsMapToolSelect::QgsMapToolSelect( QgsMapCanvas* canvas )
|
||||
void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e )
|
||||
{
|
||||
QgsVectorLayer* vlayer = QgsMapToolSelectUtils::getCurrentVectorLayer( mCanvas );
|
||||
if ( vlayer == NULL )
|
||||
if( vlayer == NULL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -46,9 +46,8 @@ void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e )
|
||||
QgsMapToolSelectUtils::expandSelectRectangle( selectRect, vlayer, e->pos() );
|
||||
QgsMapToolSelectUtils::setRubberBand( mCanvas, selectRect, &rubberBand );
|
||||
QgsGeometry* selectGeom = rubberBand.asGeometry();
|
||||
bool addSelection = e->modifiers() & Qt::ControlModifier ? true : false;
|
||||
bool substractSelection = e->modifiers() & Qt::ShiftModifier ? true : false;
|
||||
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, false, addSelection, substractSelection, true );
|
||||
bool doDifference = e->modifiers() & Qt::ControlModifier ? true : false;
|
||||
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, false, doDifference, true );
|
||||
delete selectGeom;
|
||||
rubberBand.reset( true );
|
||||
}
|
||||
|
@ -81,8 +81,7 @@ void QgsMapToolSelectUtils::expandSelectRectangle( QRect& selectRect,
|
||||
void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
|
||||
QgsGeometry* selectGeometry,
|
||||
bool doContains,
|
||||
bool addSelection,
|
||||
bool substractSelection,
|
||||
bool doDifference,
|
||||
bool singleSelect )
|
||||
{
|
||||
if( selectGeometry->type() != QGis::Polygon )
|
||||
@ -124,8 +123,7 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
|
||||
QgsDebugMsg( "Selection layer: " + vlayer->name() );
|
||||
QgsDebugMsg( "Selection polygon: " + selectGeomTrans.exportToWkt() );
|
||||
QgsDebugMsg( "doContains: " + QString( doContains ? "T" : "F" ) );
|
||||
QgsDebugMsg( "addSelection: " + QString( addSelection ? "T" : "F" ) );
|
||||
QgsDebugMsg( "substractSelection: " + QString( substractSelection ? "T" : "F" ) );
|
||||
QgsDebugMsg( "doDifference: " + QString( doDifference ? "T" : "F" ) );
|
||||
|
||||
vlayer->select( QgsAttributeList(), selectGeomTrans.boundingBox(), true, true );
|
||||
|
||||
@ -161,20 +159,10 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
|
||||
newSelectedFeatures.insert( closestFeatureId );
|
||||
}
|
||||
|
||||
QgsDebugMsg( "Number of selected features: " + QString::number( newSelectedFeatures.size() ) );
|
||||
QgsDebugMsg( "Number of new selected features: " + QString::number( newSelectedFeatures.size() ) );
|
||||
|
||||
QgsFeatureIds layerSelectedFeatures;
|
||||
if( addSelection )
|
||||
{
|
||||
layerSelectedFeatures = vlayer->selectedFeaturesIds();
|
||||
QgsFeatureIds::const_iterator i = newSelectedFeatures.constEnd();
|
||||
while( i != newSelectedFeatures.constBegin() )
|
||||
{
|
||||
--i;
|
||||
layerSelectedFeatures.insert( *i );
|
||||
}
|
||||
}
|
||||
else if( substractSelection )
|
||||
if( doDifference )
|
||||
{
|
||||
layerSelectedFeatures = vlayer->selectedFeaturesIds();
|
||||
QgsFeatureIds::const_iterator i = newSelectedFeatures.constEnd();
|
||||
@ -185,6 +173,10 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
|
||||
{
|
||||
layerSelectedFeatures.remove( *i );
|
||||
}
|
||||
else
|
||||
{
|
||||
layerSelectedFeatures.insert( *i );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -198,8 +190,7 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
|
||||
|
||||
void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas, QgsGeometry* selectGeometry, QMouseEvent * e )
|
||||
{
|
||||
bool doContains = e->modifiers() & Qt::AltModifier ? true : false;
|
||||
bool addSelection = e->modifiers() & Qt::ControlModifier ? true : false;
|
||||
bool substractSelection = e->modifiers() & Qt::ShiftModifier ? true : false;
|
||||
setSelectFeatures( canvas, selectGeometry, doContains, addSelection, substractSelection );
|
||||
bool doContains = e->modifiers() & Qt::ShiftModifier ? true : false;
|
||||
bool doDifference = e->modifiers() & Qt::ControlModifier ? true : false;
|
||||
setSelectFeatures( canvas, selectGeometry, doContains, doDifference );
|
||||
}
|
||||
|
@ -40,17 +40,14 @@ namespace QgsMapToolSelectUtils
|
||||
must be in terms of the canvas coordinate system.
|
||||
@param doContains Features will only be selected if contained within the
|
||||
selection rubber band.
|
||||
@param addSelection New selected features will be added to the layer's
|
||||
currently selected features.
|
||||
@param substractSelection New selected features will be subtracted from
|
||||
the layer's currently selected features.
|
||||
@param doDifference Take the symmetric difference of the the current selected
|
||||
features and the new features found within the provided selectGeometry.
|
||||
@param singleSelect Only selects the closest feature to the selectGeometry.
|
||||
*/
|
||||
void setSelectFeatures( QgsMapCanvas* canvas,
|
||||
QgsGeometry* selectGeometry,
|
||||
bool doContains = true,
|
||||
bool addSelection = false,
|
||||
bool substractSelection = false,
|
||||
bool doDifference = false,
|
||||
bool singleSelect = false );
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user