Skip to content

Commit bc83daf

Browse files
author
mhugent
committed
[FEATURE] Added option to show only markers of selected features in editing mode.
git-svn-id: http://svn.osgeo.org/qgis/trunk@10882 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7e47f8e commit bc83daf

File tree

4 files changed

+76
-118
lines changed

4 files changed

+76
-118
lines changed

src/app/qgsoptions.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
218218
mSearchRadiusVertexEditComboBox->setCurrentIndex( settings.value( "/qgis/digitizing/search_radius_vertex_edit_unit", 0 ).toInt() );
219219

220220
//vertex marker
221+
mMarkersOnlyForSelectedCheckBox->setChecked(settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool());
222+
221223
mMarkerStyleComboBox->addItem( tr( "Semi transparent circle" ) );
222224
mMarkerStyleComboBox->addItem( tr( "Cross" ) );
223225
mMarkerStyleComboBox->addItem( tr( "None" ) );
@@ -436,6 +438,7 @@ void QgsOptions::saveOptions()
436438
settings.setValue( "/qgis/digitizing/search_radius_vertex_edit_unit",
437439
( mSearchRadiusVertexEditComboBox->currentIndex() == 0 ? QgsTolerance::MapUnits : QgsTolerance::Pixels ) );
438440

441+
settings.setValue( "/qgis/digitizing/marker_only_for_selected", mMarkersOnlyForSelectedCheckBox->isChecked() );
439442

440443
QString markerComboText = mMarkerStyleComboBox->currentText();
441444
if ( markerComboText == tr( "Semi transparent circle" ) )

src/core/qgsvectorlayer.cpp

+22-10
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
101101
mRenderer( 0 ),
102102
mLabel( 0 ),
103103
mLabelOn( false ),
104+
mVertexMarkerOnlyForSelection(false),
104105
mFetching( false )
105106
{
106107
mActions = new QgsAttributeAction;
@@ -439,13 +440,12 @@ unsigned char* QgsVectorLayer::drawLineString(
439440
// draw vertex markers if in editing mode, but only to the main canvas
440441
if ( mEditable && drawingToEditingCanvas )
441442
{
442-
QgsVectorLayer::VertexMarkerType markerType = currentVertexMarkerType();
443443

444444
std::vector<double>::const_iterator xIt;
445445
std::vector<double>::const_iterator yIt;
446446
for ( xIt = x.begin(), yIt = y.begin(); xIt != x.end(); ++xIt, ++yIt )
447447
{
448-
drawVertexMarker(( int )( *xIt ), ( int )( *yIt ), *p, markerType );
448+
drawVertexMarker(( int )( *xIt ), ( int )( *yIt ), *p, mCurrentVertexMarkerType );
449449
}
450450
}
451451

@@ -662,12 +662,10 @@ unsigned char *QgsVectorLayer::drawPolygon(
662662
// draw vertex markers if in editing mode, but only to the main canvas
663663
if ( mEditable && drawingToEditingCanvas )
664664
{
665-
QgsVectorLayer::VertexMarkerType markerType = currentVertexMarkerType();
666-
667665
for ( int i = 0; i < path.elementCount(); ++i )
668666
{
669667
const QPainterPath::Element & e = path.elementAt( i );
670-
drawVertexMarker(( int )e.x, ( int )e.y, *p, markerType );
668+
drawVertexMarker(( int )e.x, ( int )e.y, *p, mCurrentVertexMarkerType );
671669
}
672670
}
673671

@@ -702,13 +700,16 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
702700
QPen pen;
703701
/*Pointer to a marker image*/
704702
QImage marker;
703+
//vertex marker type for selection
704+
QgsVectorLayer::VertexMarkerType vertexMarker;
705705

706706
if ( mEditable )
707707
{
708708
// Destroy all cached geometries and clear the references to them
709709
deleteCachedGeometries();
710-
711710
mCachedGeometriesRect = rendererContext.extent();
711+
vertexMarker = currentVertexMarkerType();
712+
mVertexMarkerOnlyForSelection = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();
712713
}
713714

714715
updateFeatureCount();
@@ -744,16 +745,27 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
744745
Q_UNUSED( totalFeatures );
745746
#endif //Q_WS_MAC
746747

748+
// check if feature is selected
749+
// only show selections of the current layer
750+
// TODO: create a mechanism to let layer know whether it's current layer or not [MD]
751+
bool sel = mSelectedFeatureIds.contains( fet.id() );
752+
747753
if ( mEditable )
748754
{
749755
// Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
750756
mCachedGeometries[fet.id()] = *fet.geometry();
757+
758+
if(mVertexMarkerOnlyForSelection && !sel)
759+
{
760+
mCurrentVertexMarkerType = QgsVectorLayer::NoMarker;
761+
}
762+
else
763+
{
764+
mCurrentVertexMarkerType = vertexMarker;
765+
}
751766
}
752767

753-
// check if feature is selected
754-
// only show selections of the current layer
755-
// TODO: create a mechanism to let layer know whether it's current layer or not [MD]
756-
bool sel = mSelectedFeatureIds.contains( fet.id() );
768+
757769

758770
//QgsDebugMsg(QString("markerScale before renderFeature(): %1").arg(markerScaleFactor));
759771
// markerScalerFactore reflects the wanted scaling of the marker

src/core/qgsvectorlayer.h

+6
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
654654
/** Display labels */
655655
bool mLabelOn;
656656

657+
/**The current type of editing marker*/
658+
QgsVectorLayer::VertexMarkerType mCurrentVertexMarkerType;
659+
660+
/**Flag if the vertex markers should be drawn only for selection (true) or for all features (false)*/
661+
bool mVertexMarkerOnlyForSelection;
662+
657663
/**List of overlays. Vector overlays will be rendered on top of all maplayers*/
658664
QList<QgsVectorOverlay*> mOverlays;
659665

0 commit comments

Comments
 (0)