Skip to content
Permalink
Browse files
Added option to have the old vertex markers back
git-svn-id: http://svn.osgeo.org/qgis/trunk@8392 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 1, 2008
1 parent 38fc0b9 commit 80a5f660900087a86f4ffdba7afa05911b2811fb
Showing with 139 additions and 17 deletions.
  1. +25 −0 src/app/qgsoptions.cpp
  2. +42 −12 src/core/qgsvectorlayer.cpp
  3. +11 −1 src/core/qgsvectorlayer.h
  4. +61 −4 src/ui/qgsoptionsbase.ui
@@ -172,6 +172,20 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
mDefaultSnapModeComboBox->setCurrentIndex(mDefaultSnapModeComboBox->findText(tr(defaultSnapString)));
mDefaultSnappingToleranceSpinBox->setValue(settings.value("/qgis/digitizing/default_snapping_tolerance", 0).toDouble());
mSearchRadiusVertexEditSpinBox->setValue(settings.value("/qgis/digitizing/search_radius_vertex_edit", 10).toDouble());

//vertex marker
mMarkerStyleComboBox->addItem(tr("Semi transparent circle"));
mMarkerStyleComboBox->addItem(tr("Cross"));

QString markerStyle = settings.value("/qgis/digitizing/marker_style", "SemiTransparentCircle").toString();
if(markerStyle == "SemiTransparentCircle")
{
mMarkerStyleComboBox->setCurrentIndex(mMarkerStyleComboBox->findText(tr("Semi transparent circle")));
}
else if(markerStyle == "Cross")
{
mMarkerStyleComboBox->setCurrentIndex(mMarkerStyleComboBox->findText(tr("Cross")));
}
}

//! Destructor
@@ -312,6 +326,17 @@ void QgsOptions::saveOptions()
settings.setValue("/qgis/digitizing/default_snap_mode", defaultSnapModeString);
settings.setValue("/qgis/digitizing/default_snapping_tolerance", mDefaultSnappingToleranceSpinBox->value());
settings.setValue("/qgis/digitizing/search_radius_vertex_edit", mSearchRadiusVertexEditSpinBox->value());

QString markerComboText = mMarkerStyleComboBox->currentText();
if(markerComboText == tr("Semi transparent circle"))
{
settings.setValue("/qgis/digitizing/marker_style", "SemiTransparentCircle");
}
else if(markerComboText == tr("Cross"))
{
settings.setValue("/qgis/digitizing/marker_style", "Cross");
}

//
// Locale settings
//
@@ -38,7 +38,7 @@
#include <QPainter>
#include <QPainterPath>
#include <QPolygonF>
#include <QSettings> //for update threshold
#include <QSettings>
#include <QString>

#include "qgsvectorlayer.h"
@@ -443,12 +443,14 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
(drawingToEditingCanvas)
)
{
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);
}
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);
}
}

//restore the pen
@@ -690,10 +692,13 @@ std::cerr << i << ": " << ring->first[i]
(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);
drawVertexMarker((int)e.x, (int)e.y, *p, markerType);
}
}

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

void QgsVectorLayer::drawVertexMarker(int x, int y, QPainter& p)
void QgsVectorLayer::drawVertexMarker(int x, int y, QPainter& p, QgsVectorLayer::VertexMarkerType type)
{
p.setPen(QColor(50, 100, 120, 200));
p.setBrush(QColor(200, 200, 210, 120));
p.drawEllipse(QRectF(x - 7, y - 7, 14, 14));
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));
}
else
{
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);
}
}

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

QgsVectorLayer::VertexMarkerType QgsVectorLayer::currentVertexMarkerType()
{
QSettings settings;
QString markerTypeString = settings.value("/qgis/digitizing/marker_style", "SemiTransparentCircle").toString();
if(markerTypeString == "Cross")
{
return QgsVectorLayer::Cross;
}
else
{
return QgsVectorLayer::SemiTransparentCircle;
}
}

void QgsVectorLayer::drawFeature(QPainter* p,
QgsFeature& fet,
QgsMapToPixel * theMapToPixelTransform,
@@ -422,6 +422,12 @@ public slots:

private: // Private methods

enum VertexMarkerType
{
SemiTransparentCircle,
Cross
};

/** vector layers are not copyable */
QgsVectorLayer( QgsVectorLayer const & rhs );

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

/**Deletes the geometries in mCachedGeometries*/
void deleteCachedGeometries();

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

/**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
@@ -492,6 +499,9 @@ public slots:
@return 0 in case of success*/
int boundingBoxFromPointList(const QList<QgsPoint>& list, double& xmin, double& ymin, double& xmax, double& ymax) const;

/**Reads vertex marker type from settings*/
QgsVectorLayer::VertexMarkerType currentVertexMarkerType();


private: // Private attributes

@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>868</width>
<height>506</height>
<width>871</width>
<height>512</height>
</rect>
</property>
<property name="windowTitle" >
@@ -670,19 +670,76 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="2" column="0" >
<item row="3" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>171</height>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" >
<widget class="QGroupBox" name="mVertexMarkerGroupBox" >
<property name="title" >
<string>Vertex markers</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="mMarkerStyleLabel" >
<property name="text" >
<string>Marker style:</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>281</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="mMarkerStyleComboBox" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" >
<widget class="QGroupBox" name="mSnappingGroupBox" >
<property name="title" >

0 comments on commit 80a5f66

Please sign in to comment.