Skip to content
Permalink
Browse files

[FEATURE] Added option to show only markers of selected features in e…

…diting mode.

git-svn-id: http://svn.osgeo.org/qgis/trunk@10882 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Jun 5, 2009
1 parent 7e47f8e commit bc83dafe2dc251da05df2b89902155a7e3b9aa61
Showing with 76 additions and 118 deletions.
  1. +3 −0 src/app/qgsoptions.cpp
  2. +22 −10 src/core/qgsvectorlayer.cpp
  3. +6 −0 src/core/qgsvectorlayer.h
  4. +45 −108 src/ui/qgsoptionsbase.ui
@@ -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" ) );
@@ -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" ) )
@@ -101,6 +101,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
mRenderer( 0 ),
mLabel( 0 ),
mLabelOn( false ),
mVertexMarkerOnlyForSelection(false),
mFetching( false )
{
mActions = new QgsAttributeAction;
@@ -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 );
}
}

@@ -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 );
}
}

@@ -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();
@@ -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
@@ -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;

0 comments on commit bc83daf

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