Skip to content

Commit 80a5f66

Browse files
author
mhugent
committed
Added option to have the old vertex markers back
git-svn-id: http://svn.osgeo.org/qgis/trunk@8392 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 38fc0b9 commit 80a5f66

File tree

4 files changed

+139
-17
lines changed

4 files changed

+139
-17
lines changed

src/app/qgsoptions.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,20 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
172172
mDefaultSnapModeComboBox->setCurrentIndex(mDefaultSnapModeComboBox->findText(tr(defaultSnapString)));
173173
mDefaultSnappingToleranceSpinBox->setValue(settings.value("/qgis/digitizing/default_snapping_tolerance", 0).toDouble());
174174
mSearchRadiusVertexEditSpinBox->setValue(settings.value("/qgis/digitizing/search_radius_vertex_edit", 10).toDouble());
175+
176+
//vertex marker
177+
mMarkerStyleComboBox->addItem(tr("Semi transparent circle"));
178+
mMarkerStyleComboBox->addItem(tr("Cross"));
179+
180+
QString markerStyle = settings.value("/qgis/digitizing/marker_style", "SemiTransparentCircle").toString();
181+
if(markerStyle == "SemiTransparentCircle")
182+
{
183+
mMarkerStyleComboBox->setCurrentIndex(mMarkerStyleComboBox->findText(tr("Semi transparent circle")));
184+
}
185+
else if(markerStyle == "Cross")
186+
{
187+
mMarkerStyleComboBox->setCurrentIndex(mMarkerStyleComboBox->findText(tr("Cross")));
188+
}
175189
}
176190

177191
//! Destructor
@@ -312,6 +326,17 @@ void QgsOptions::saveOptions()
312326
settings.setValue("/qgis/digitizing/default_snap_mode", defaultSnapModeString);
313327
settings.setValue("/qgis/digitizing/default_snapping_tolerance", mDefaultSnappingToleranceSpinBox->value());
314328
settings.setValue("/qgis/digitizing/search_radius_vertex_edit", mSearchRadiusVertexEditSpinBox->value());
329+
330+
QString markerComboText = mMarkerStyleComboBox->currentText();
331+
if(markerComboText == tr("Semi transparent circle"))
332+
{
333+
settings.setValue("/qgis/digitizing/marker_style", "SemiTransparentCircle");
334+
}
335+
else if(markerComboText == tr("Cross"))
336+
{
337+
settings.setValue("/qgis/digitizing/marker_style", "Cross");
338+
}
339+
315340
//
316341
// Locale settings
317342
//

src/core/qgsvectorlayer.cpp

+42-12
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <QPainter>
3939
#include <QPainterPath>
4040
#include <QPolygonF>
41-
#include <QSettings> //for update threshold
41+
#include <QSettings>
4242
#include <QString>
4343

4444
#include "qgsvectorlayer.h"
@@ -443,12 +443,14 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
443443
(drawingToEditingCanvas)
444444
)
445445
{
446-
std::vector<double>::const_iterator xIt;
447-
std::vector<double>::const_iterator yIt;
448-
for(xIt = x.begin(), yIt = y.begin(); xIt != x.end(); ++xIt, ++yIt)
449-
{
450-
drawVertexMarker((int)(*xIt), (int)(*yIt), *p);
451-
}
446+
QgsVectorLayer::VertexMarkerType markerType = currentVertexMarkerType();
447+
448+
std::vector<double>::const_iterator xIt;
449+
std::vector<double>::const_iterator yIt;
450+
for(xIt = x.begin(), yIt = y.begin(); xIt != x.end(); ++xIt, ++yIt)
451+
{
452+
drawVertexMarker((int)(*xIt), (int)(*yIt), *p, markerType);
453+
}
452454
}
453455

454456
//restore the pen
@@ -690,10 +692,13 @@ std::cerr << i << ": " << ring->first[i]
690692
(drawingToEditingCanvas)
691693
)
692694
{
695+
696+
QgsVectorLayer::VertexMarkerType markerType = currentVertexMarkerType();
697+
693698
for(int i = 0; i < path.elementCount(); ++i)
694699
{
695700
const QPainterPath::Element & e = path.elementAt(i);
696-
drawVertexMarker((int)e.x, (int)e.y, *p);
701+
drawVertexMarker((int)e.x, (int)e.y, *p, markerType);
697702
}
698703
}
699704

@@ -887,11 +892,22 @@ void QgsVectorLayer::deleteCachedGeometries()
887892
mCachedGeometries.clear();
888893
}
889894

890-
void QgsVectorLayer::drawVertexMarker(int x, int y, QPainter& p)
895+
void QgsVectorLayer::drawVertexMarker(int x, int y, QPainter& p, QgsVectorLayer::VertexMarkerType type)
891896
{
892-
p.setPen(QColor(50, 100, 120, 200));
893-
p.setBrush(QColor(200, 200, 210, 120));
894-
p.drawEllipse(QRectF(x - 7, y - 7, 14, 14));
897+
if(type == QgsVectorLayer::SemiTransparentCircle)
898+
{
899+
p.setPen(QColor(50, 100, 120, 200));
900+
p.setBrush(QColor(200, 200, 210, 120));
901+
p.drawEllipse(QRectF(x - 7, y - 7, 14, 14));
902+
}
903+
else
904+
{
905+
int size = 15;
906+
int m = (size-1)/2;
907+
p.setPen(QColor(255, 0, 0));
908+
p.drawLine(x-m, y+m, x+m, y-m);
909+
p.drawLine(x-m, y-m, x+m, y+m);
910+
}
895911
}
896912

897913
void QgsVectorLayer::select(int number, bool emitSignal)
@@ -2934,6 +2950,20 @@ int QgsVectorLayer::boundingBoxFromPointList(const QList<QgsPoint>& list, double
29342950
return 0;
29352951
}
29362952

2953+
QgsVectorLayer::VertexMarkerType QgsVectorLayer::currentVertexMarkerType()
2954+
{
2955+
QSettings settings;
2956+
QString markerTypeString = settings.value("/qgis/digitizing/marker_style", "SemiTransparentCircle").toString();
2957+
if(markerTypeString == "Cross")
2958+
{
2959+
return QgsVectorLayer::Cross;
2960+
}
2961+
else
2962+
{
2963+
return QgsVectorLayer::SemiTransparentCircle;
2964+
}
2965+
}
2966+
29372967
void QgsVectorLayer::drawFeature(QPainter* p,
29382968
QgsFeature& fet,
29392969
QgsMapToPixel * theMapToPixelTransform,

src/core/qgsvectorlayer.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ public slots:
422422

423423
private: // Private methods
424424

425+
enum VertexMarkerType
426+
{
427+
SemiTransparentCircle,
428+
Cross
429+
};
430+
425431
/** vector layers are not copyable */
426432
QgsVectorLayer( QgsVectorLayer const & rhs );
427433

@@ -475,8 +481,9 @@ public slots:
475481

476482
/**Deletes the geometries in mCachedGeometries*/
477483
void deleteCachedGeometries();
484+
478485
/** Draws a vertex symbol at (screen) coordinates x, y. (Useful to assist vertex editing.) */
479-
void drawVertexMarker(int x, int y, QPainter& p);
486+
void drawVertexMarker(int x, int y, QPainter& p, QgsVectorLayer::VertexMarkerType type);
480487

481488
/**Snaps to a geometry and adds the result to the multimap if it is within the snapping result
482489
@param startPoint start point of the snap
@@ -492,6 +499,9 @@ public slots:
492499
@return 0 in case of success*/
493500
int boundingBoxFromPointList(const QList<QgsPoint>& list, double& xmin, double& ymin, double& xmax, double& ymax) const;
494501

502+
/**Reads vertex marker type from settings*/
503+
QgsVectorLayer::VertexMarkerType currentVertexMarkerType();
504+
495505

496506
private: // Private attributes
497507

src/ui/qgsoptionsbase.ui

+61-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<rect>
66
<x>0</x>
77
<y>0</y>
8-
<width>868</width>
9-
<height>506</height>
8+
<width>871</width>
9+
<height>512</height>
1010
</rect>
1111
</property>
1212
<property name="windowTitle" >
@@ -670,19 +670,76 @@
670670
<property name="spacing" >
671671
<number>6</number>
672672
</property>
673-
<item row="2" column="0" >
673+
<item row="3" column="0" >
674674
<spacer>
675675
<property name="orientation" >
676676
<enum>Qt::Vertical</enum>
677677
</property>
678678
<property name="sizeHint" >
679679
<size>
680680
<width>20</width>
681-
<height>171</height>
681+
<height>40</height>
682682
</size>
683683
</property>
684684
</spacer>
685685
</item>
686+
<item row="2" column="0" >
687+
<widget class="QGroupBox" name="mVertexMarkerGroupBox" >
688+
<property name="title" >
689+
<string>Vertex markers</string>
690+
</property>
691+
<layout class="QGridLayout" >
692+
<property name="margin" >
693+
<number>9</number>
694+
</property>
695+
<property name="spacing" >
696+
<number>6</number>
697+
</property>
698+
<item row="0" column="0" >
699+
<layout class="QHBoxLayout" >
700+
<property name="margin" >
701+
<number>0</number>
702+
</property>
703+
<property name="spacing" >
704+
<number>6</number>
705+
</property>
706+
<item>
707+
<widget class="QLabel" name="mMarkerStyleLabel" >
708+
<property name="text" >
709+
<string>Marker style:</string>
710+
</property>
711+
</widget>
712+
</item>
713+
<item>
714+
<spacer>
715+
<property name="orientation" >
716+
<enum>Qt::Horizontal</enum>
717+
</property>
718+
<property name="sizeHint" >
719+
<size>
720+
<width>281</width>
721+
<height>20</height>
722+
</size>
723+
</property>
724+
</spacer>
725+
</item>
726+
<item>
727+
<widget class="QComboBox" name="mMarkerStyleComboBox" >
728+
<property name="sizePolicy" >
729+
<sizepolicy>
730+
<hsizetype>7</hsizetype>
731+
<vsizetype>0</vsizetype>
732+
<horstretch>0</horstretch>
733+
<verstretch>0</verstretch>
734+
</sizepolicy>
735+
</property>
736+
</widget>
737+
</item>
738+
</layout>
739+
</item>
740+
</layout>
741+
</widget>
742+
</item>
686743
<item row="1" column="0" >
687744
<widget class="QGroupBox" name="mSnappingGroupBox" >
688745
<property name="title" >

0 commit comments

Comments
 (0)