Skip to content
Permalink
Browse files
Added support for a default snap mode (can be to vertex, to segment, …
…to vertex and segment)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8214 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Mar 13, 2008
1 parent 1ff7509 commit 51fd3e364a44d5a5f49a591a36f1d5838b089a8f
Showing with 158 additions and 77 deletions.
  1. +23 −0 src/app/qgsoptions.cpp
  2. +17 −1 src/gui/qgsmapcanvassnapper.cpp
  3. +118 −76 src/ui/qgsoptionsbase.ui
@@ -163,6 +163,13 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
myGreen = settings.value("/qgis/digitizing/line_color_green", 0).toInt();
myBlue = settings.value("/qgis/digitizing/line_color_blue", 0).toInt();
mLineColourToolButton->setColor(QColor(myRed, myGreen, myBlue));

//default snap mode
mDefaultSnapModeComboBox->insertItem(0, tr("to vertex"));
mDefaultSnapModeComboBox->insertItem(1, tr("to segment"));
mDefaultSnapModeComboBox->insertItem(2, tr("to vertex and segment"));
QString defaultSnapString = settings.value("/qgis/digitizing/default_snap_mode", "to vertex").toString();
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());
}
@@ -287,6 +294,22 @@ void QgsOptions::saveOptions()
settings.setValue("/qgis/digitizing/line_color_red", digitizingColor.red());
settings.setValue("/qgis/digitizing/line_color_green", digitizingColor.green());
settings.setValue("/qgis/digitizing/line_color_blue", digitizingColor.blue());

//default snap mode
QString defaultSnapModeString;
if(mDefaultSnapModeComboBox->currentText() == tr("to vertex"))
{
defaultSnapModeString = "to vertex";
}
else if(mDefaultSnapModeComboBox->currentText() == tr("to segment"))
{
defaultSnapModeString = "to segment";
}
else if(mDefaultSnapModeComboBox->currentText() == tr("to vertex and segment"))
{
defaultSnapModeString = "to vertex and segment";
}
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());
//
@@ -227,8 +227,24 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers(const QPoint& p, QList<QgsSnappi
}

vectorLayerList.push_back(currentVectorLayer);
snapTo.push_back(QgsSnapper::SNAP_TO_VERTEX);
QSettings settings;

//default snap mode
QString defaultSnapString = settings.value("/qgis/digitizing/default_snap_mode", "to vertex").toString();
if(defaultSnapString == "to segment")
{
snapTo.push_back(QgsSnapper::SNAP_TO_SEGMENT);
}
else if(defaultSnapString == "to vertex and segment")
{
snapTo.push_back(QgsSnapper::SNAP_TO_VERTEX_AND_SEGMENT);
}
else
{
snapTo.push_back(QgsSnapper::SNAP_TO_VERTEX);
}

//default snapping tolerance
toleranceDoubleList.push_back(settings.value("/qgis/digitizing/default_snapping_tolerance", 0).toDouble());
}

@@ -28,16 +28,6 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QTabWidget" name="tabWidget" >
<property name="currentIndex" >
@@ -675,10 +665,23 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QGroupBox" name="mRubberBandGroupBox" >
<item row="2" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>171</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" >
<widget class="QGroupBox" name="mSnappingGroupBox" >
<property name="title" >
<string>Rubberband</string>
<string>Snapping</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
@@ -696,22 +699,9 @@
<number>6</number>
</property>
<item>
<widget class="QLabel" name="mLineWidthTextLabel" >
<widget class="QLabel" name="mDefaultSnapModeLabel" >
<property name="text" >
<string>Line Width:</string>
</property>
<property name="buddy" >
<cstring>mLineWidthSpinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mLineWidthSpinBox" >
<property name="toolTip" >
<string>Line width in pixels</string>
</property>
<property name="minimum" >
<number>1</number>
<string>Default Snap Mode:</string>
</property>
</widget>
</item>
@@ -722,53 +712,64 @@
</property>
<property name="sizeHint" >
<size>
<width>271</width>
<width>311</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="mLineColourTextLabel" >
<property name="text" >
<string>Line Colour:</string>
<widget class="QComboBox" name="mDefaultSnapModeComboBox" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="buddy" >
<cstring>mLineColourToolButton</cstring>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="mVertexSearchRadiusVertexEditLabel" >
<property name="text" >
<string>Search radius for vertex edits (in layer units):</string>
</property>
</widget>
</item>
<item>
<widget class="QgsColorButton" name="mLineColourToolButton" >
<property name="minimumSize" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>100</width>
<height>0</height>
<width>61</width>
<height>20</height>
</size>
</property>
<property name="text" >
<string/>
</spacer>
</item>
<item>
<widget class="QDoubleSpinBox" name="mSearchRadiusVertexEditSpinBox" >
<property name="maximum" >
<double>9999.989999999999782</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" >
<widget class="QGroupBox" name="mSnappingGroupBox" >
<property name="title" >
<string>Snapping</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<item row="1" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
@@ -805,7 +806,22 @@
</item>
</layout>
</item>
<item row="1" column="0" >
</layout>
</widget>
</item>
<item row="0" column="0" >
<widget class="QGroupBox" name="mRubberBandGroupBox" >
<property name="title" >
<string>Rubberband</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>
@@ -814,9 +830,22 @@
<number>6</number>
</property>
<item>
<widget class="QLabel" name="mVertexSearchRadiusVertexEditLabel" >
<widget class="QLabel" name="mLineWidthTextLabel" >
<property name="text" >
<string>Search radius for vertex edits (in layer units):</string>
<string>Line Width:</string>
</property>
<property name="buddy" >
<cstring>mLineWidthSpinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mLineWidthSpinBox" >
<property name="toolTip" >
<string>Line width in pixels</string>
</property>
<property name="minimum" >
<number>1</number>
</property>
</widget>
</item>
@@ -827,16 +856,32 @@
</property>
<property name="sizeHint" >
<size>
<width>61</width>
<width>271</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDoubleSpinBox" name="mSearchRadiusVertexEditSpinBox" >
<property name="maximum" >
<double>9999.989999999999782</double>
<widget class="QLabel" name="mLineColourTextLabel" >
<property name="text" >
<string>Line Colour:</string>
</property>
<property name="buddy" >
<cstring>mLineColourToolButton</cstring>
</property>
</widget>
</item>
<item>
<widget class="QgsColorButton" name="mLineColourToolButton" >
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
@@ -845,19 +890,6 @@
</layout>
</widget>
</item>
<item row="2" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>171</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabProjection" >
@@ -1023,6 +1055,16 @@
</widget>
</widget>
</item>
<item row="1" column="0" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />

0 comments on commit 51fd3e3

Please sign in to comment.