Skip to content
Permalink
Browse files

[FEATURE] configurable vertex marker size (fixes #1922)

git-svn-id: http://svn.osgeo.org/qgis/trunk@11599 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Sep 8, 2009
1 parent 91dec3d commit 0a083f59b12d0be22cf0e96510288cbad295918c
Showing with 57 additions and 8 deletions.
  1. +2 −0 src/app/qgsoptions.cpp
  2. +14 −6 src/core/qgsvectorlayer.cpp
  3. +7 −1 src/core/qgsvectorlayer.h
  4. +34 −1 src/ui/qgsoptionsbase.ui
@@ -256,6 +256,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
{
mMarkerStyleComboBox->setCurrentIndex( mMarkerStyleComboBox->findText( tr( "None" ) ) );
}
mMarkerSizeSpinBox->setValue( settings.value( "/qgis/digitizing/marker_size", 7 ).toInt()*2+1 );

chkDisableAttributeValuesDlg->setChecked( settings.value( "/qgis/digitizing/disable_enter_attribute_values_dialog", false ).toBool() );

@@ -483,6 +484,7 @@ void QgsOptions::saveOptions()
{
settings.setValue( "/qgis/digitizing/marker_style", "None" );
}
settings.setValue( "/qgis/digitizing/marker_size", (mMarkerSizeSpinBox->value()-1)/2 );

settings.setValue( "/qgis/digitizing/disable_enter_attribute_values_dialog", chkDisableAttributeValuesDlg->isChecked() );

@@ -438,7 +438,7 @@ unsigned char *QgsVectorLayer::drawLineString( unsigned char *feature, QgsRender
std::vector<double>::const_iterator yIt;
for ( xIt = x.begin(), yIt = y.begin(); xIt != x.end(); ++xIt, ++yIt )
{
drawVertexMarker(( int )( *xIt ), ( int )( *yIt ), *p, mCurrentVertexMarkerType );
drawVertexMarker(( int )( *xIt ), ( int )( *yIt ), *p, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
}
}

@@ -631,7 +631,7 @@ unsigned char *QgsVectorLayer::drawPolygon( unsigned char *feature, QgsRenderCon
for ( int i = 0; i < path.elementCount(); ++i )
{
const QPainterPath::Element & e = path.elementAt( i );
drawVertexMarker(( int )e.x, ( int )e.y, *p, mCurrentVertexMarkerType );
drawVertexMarker(( int )e.x, ( int )e.y, *p, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
}
}

@@ -668,13 +668,15 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
QImage marker;
//vertex marker type for selection
QgsVectorLayer::VertexMarkerType vertexMarker = QgsVectorLayer::NoMarker;
int vertexMarkerSize = 7;

if ( mEditable )
{
// Destroy all cached geometries and clear the references to them
deleteCachedGeometries();
mCachedGeometriesRect = rendererContext.extent();
vertexMarker = currentVertexMarkerType();
vertexMarkerSize = currentVertexMarkerSize();
mVertexMarkerOnlyForSelection = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();
}

@@ -717,6 +719,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
bool sel = mSelectedFeatureIds.contains( fet.id() );

mCurrentVertexMarkerType = QgsVectorLayer::NoMarker;
mCurrentVertexMarkerSize = 7;

if ( mEditable )
{
@@ -726,6 +729,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
if ( !mVertexMarkerOnlyForSelection || sel )
{
mCurrentVertexMarkerType = vertexMarker;
mCurrentVertexMarkerSize = vertexMarkerSize;
}
}

@@ -777,18 +781,16 @@ void QgsVectorLayer::deleteCachedGeometries()
mCachedGeometriesRect = QgsRectangle();
}

void QgsVectorLayer::drawVertexMarker( int x, int y, QPainter& p, QgsVectorLayer::VertexMarkerType type )
void QgsVectorLayer::drawVertexMarker( int x, int y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int m )
{
if ( type == QgsVectorLayer::SemiTransparentCircle )
{
p.setPen( QColor( 50, 100, 120, 200 ) );
p.setBrush( QColor( 200, 200, 210, 120 ) );
p.drawEllipse( QRectF( x - 7, y - 7, 14, 14 ) );
p.drawEllipse( x-m, y-m, m*2+1, m*2+1 );
}
else if ( type == QgsVectorLayer::Cross )
{
int size = 15;
int m = ( size - 1 ) / 2;
p.setPen( QColor( 255, 0, 0 ) );
p.drawLine( x - m, y + m, x + m, y - m );
p.drawLine( x - m, y - m, x + m, y + m );
@@ -3464,6 +3466,12 @@ QgsVectorLayer::VertexMarkerType QgsVectorLayer::currentVertexMarkerType()
}
}

int QgsVectorLayer::currentVertexMarkerSize()
{
QSettings settings;
return settings.value( "/qgis/digitizing/marker_size", 7 ).toInt();
}

void QgsVectorLayer::drawFeature( QgsRenderContext &renderContext,
QgsFeature& fet,
QImage * marker )
@@ -578,7 +578,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
void deleteCachedGeometries();

/** Draws a vertex symbol at (screen) coordinates x, y. (Useful to assist vertex editing.) */
void drawVertexMarker( int x, int y, QPainter& p, QgsVectorLayer::VertexMarkerType type );
void drawVertexMarker( int x, int y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );

/**Snaps to a geometry and adds the result to the multimap if it is within the snapping result
@param startPoint start point of the snap
@@ -597,6 +597,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/**Reads vertex marker type from settings*/
QgsVectorLayer::VertexMarkerType currentVertexMarkerType();

/**Reads vertex marker size from settings*/
int currentVertexMarkerSize();

/**Update feature with uncommited attribute updates*/
void updateFeatureAttributes( QgsFeature &f );

@@ -700,6 +703,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/**The current type of editing marker*/
QgsVectorLayer::VertexMarkerType mCurrentVertexMarkerType;

/** The current size of editing marker */
int mCurrentVertexMarkerSize;

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

@@ -38,7 +38,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>4</number>
</property>
<widget class="QWidget" name="tabGeneral">
<attribute name="title">
@@ -859,6 +859,39 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="mMarkerSizeSpinBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="singleStep">
<number>2</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Marker size</string>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>

0 comments on commit 0a083f5

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