Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] Added option to show only markers of selected features in e…
…diting mode.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10882 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jun 5, 2009
1 parent 8ac15ec commit 0b8a4ff
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 118 deletions.
3 changes: 3 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -218,6 +218,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
mSearchRadiusVertexEditComboBox->setCurrentIndex( settings.value( "/qgis/digitizing/search_radius_vertex_edit_unit", 0 ).toInt() );

//vertex marker
mMarkersOnlyForSelectedCheckBox->setChecked(settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool());

mMarkerStyleComboBox->addItem( tr( "Semi transparent circle" ) );
mMarkerStyleComboBox->addItem( tr( "Cross" ) );
mMarkerStyleComboBox->addItem( tr( "None" ) );
Expand Down Expand Up @@ -436,6 +438,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/digitizing/search_radius_vertex_edit_unit",
( mSearchRadiusVertexEditComboBox->currentIndex() == 0 ? QgsTolerance::MapUnits : QgsTolerance::Pixels ) );

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

QString markerComboText = mMarkerStyleComboBox->currentText();
if ( markerComboText == tr( "Semi transparent circle" ) )
Expand Down
32 changes: 22 additions & 10 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -101,6 +101,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
mRenderer( 0 ),
mLabel( 0 ),
mLabelOn( false ),
mVertexMarkerOnlyForSelection(false),
mFetching( false )
{
mActions = new QgsAttributeAction;
Expand Down Expand Up @@ -439,13 +440,12 @@ unsigned char* QgsVectorLayer::drawLineString(
// draw vertex markers if in editing mode, but only to the main canvas
if ( mEditable && drawingToEditingCanvas )
{
QgsVectorLayer::VertexMarkerType markerType = currentVertexMarkerType();

std::vector<double>::const_iterator xIt;
std::vector<double>::const_iterator yIt;
for ( xIt = x.begin(), yIt = y.begin(); xIt != x.end(); ++xIt, ++yIt )
{
drawVertexMarker(( int )( *xIt ), ( int )( *yIt ), *p, markerType );
drawVertexMarker(( int )( *xIt ), ( int )( *yIt ), *p, mCurrentVertexMarkerType );
}
}

Expand Down Expand Up @@ -662,12 +662,10 @@ unsigned char *QgsVectorLayer::drawPolygon(
// draw vertex markers if in editing mode, but only to the main canvas
if ( mEditable && drawingToEditingCanvas )
{
QgsVectorLayer::VertexMarkerType markerType = currentVertexMarkerType();

for ( int i = 0; i < path.elementCount(); ++i )
{
const QPainterPath::Element & e = path.elementAt( i );
drawVertexMarker(( int )e.x, ( int )e.y, *p, markerType );
drawVertexMarker(( int )e.x, ( int )e.y, *p, mCurrentVertexMarkerType );
}
}

Expand Down Expand Up @@ -702,13 +700,16 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
QPen pen;
/*Pointer to a marker image*/
QImage marker;
//vertex marker type for selection
QgsVectorLayer::VertexMarkerType vertexMarker;

if ( mEditable )
{
// Destroy all cached geometries and clear the references to them
deleteCachedGeometries();

mCachedGeometriesRect = rendererContext.extent();
vertexMarker = currentVertexMarkerType();
mVertexMarkerOnlyForSelection = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();
}

updateFeatureCount();
Expand Down Expand Up @@ -744,16 +745,27 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
Q_UNUSED( totalFeatures );
#endif //Q_WS_MAC

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

if ( mEditable )
{
// Cache this for the use of (e.g.) modifying the feature's uncommitted geometry.
mCachedGeometries[fet.id()] = *fet.geometry();

if(mVertexMarkerOnlyForSelection && !sel)
{
mCurrentVertexMarkerType = QgsVectorLayer::NoMarker;
}
else
{
mCurrentVertexMarkerType = vertexMarker;
}
}

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


//QgsDebugMsg(QString("markerScale before renderFeature(): %1").arg(markerScaleFactor));
// markerScalerFactore reflects the wanted scaling of the marker
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsvectorlayer.h
Expand Up @@ -654,6 +654,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Display labels */
bool mLabelOn;

/**The current type of editing marker*/
QgsVectorLayer::VertexMarkerType mCurrentVertexMarkerType;

/**Flag if the vertex markers should be drawn only for selection (true) or for all features (false)*/
bool mVertexMarkerOnlyForSelection;

/**List of overlays. Vector overlays will be rendered on top of all maplayers*/
QList<QgsVectorOverlay*> mOverlays;

Expand Down

0 comments on commit 0b8a4ff

Please sign in to comment.