Skip to content

Commit e3bb161

Browse files
author
mhugent
committedMar 13, 2008
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@8214 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2ea7615 commit e3bb161

File tree

3 files changed

+158
-77
lines changed

3 files changed

+158
-77
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
163163
myGreen = settings.value("/qgis/digitizing/line_color_green", 0).toInt();
164164
myBlue = settings.value("/qgis/digitizing/line_color_blue", 0).toInt();
165165
mLineColourToolButton->setColor(QColor(myRed, myGreen, myBlue));
166+
167+
//default snap mode
168+
mDefaultSnapModeComboBox->insertItem(0, tr("to vertex"));
169+
mDefaultSnapModeComboBox->insertItem(1, tr("to segment"));
170+
mDefaultSnapModeComboBox->insertItem(2, tr("to vertex and segment"));
171+
QString defaultSnapString = settings.value("/qgis/digitizing/default_snap_mode", "to vertex").toString();
172+
mDefaultSnapModeComboBox->setCurrentIndex(mDefaultSnapModeComboBox->findText(tr(defaultSnapString)));
166173
mDefaultSnappingToleranceSpinBox->setValue(settings.value("/qgis/digitizing/default_snapping_tolerance", 0).toDouble());
167174
mSearchRadiusVertexEditSpinBox->setValue(settings.value("/qgis/digitizing/search_radius_vertex_edit", 10).toDouble());
168175
}
@@ -287,6 +294,22 @@ void QgsOptions::saveOptions()
287294
settings.setValue("/qgis/digitizing/line_color_red", digitizingColor.red());
288295
settings.setValue("/qgis/digitizing/line_color_green", digitizingColor.green());
289296
settings.setValue("/qgis/digitizing/line_color_blue", digitizingColor.blue());
297+
298+
//default snap mode
299+
QString defaultSnapModeString;
300+
if(mDefaultSnapModeComboBox->currentText() == tr("to vertex"))
301+
{
302+
defaultSnapModeString = "to vertex";
303+
}
304+
else if(mDefaultSnapModeComboBox->currentText() == tr("to segment"))
305+
{
306+
defaultSnapModeString = "to segment";
307+
}
308+
else if(mDefaultSnapModeComboBox->currentText() == tr("to vertex and segment"))
309+
{
310+
defaultSnapModeString = "to vertex and segment";
311+
}
312+
settings.setValue("/qgis/digitizing/default_snap_mode", defaultSnapModeString);
290313
settings.setValue("/qgis/digitizing/default_snapping_tolerance", mDefaultSnappingToleranceSpinBox->value());
291314
settings.setValue("/qgis/digitizing/search_radius_vertex_edit", mSearchRadiusVertexEditSpinBox->value());
292315
//

‎src/gui/qgsmapcanvassnapper.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,24 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers(const QPoint& p, QList<QgsSnappi
227227
}
228228

229229
vectorLayerList.push_back(currentVectorLayer);
230-
snapTo.push_back(QgsSnapper::SNAP_TO_VERTEX);
231230
QSettings settings;
231+
232+
//default snap mode
233+
QString defaultSnapString = settings.value("/qgis/digitizing/default_snap_mode", "to vertex").toString();
234+
if(defaultSnapString == "to segment")
235+
{
236+
snapTo.push_back(QgsSnapper::SNAP_TO_SEGMENT);
237+
}
238+
else if(defaultSnapString == "to vertex and segment")
239+
{
240+
snapTo.push_back(QgsSnapper::SNAP_TO_VERTEX_AND_SEGMENT);
241+
}
242+
else
243+
{
244+
snapTo.push_back(QgsSnapper::SNAP_TO_VERTEX);
245+
}
246+
247+
//default snapping tolerance
232248
toleranceDoubleList.push_back(settings.value("/qgis/digitizing/default_snapping_tolerance", 0).toDouble());
233249
}
234250

‎src/ui/qgsoptionsbase.ui

Lines changed: 118 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@
2828
<property name="spacing" >
2929
<number>6</number>
3030
</property>
31-
<item row="1" column="0" >
32-
<widget class="QDialogButtonBox" name="buttonBox" >
33-
<property name="orientation" >
34-
<enum>Qt::Horizontal</enum>
35-
</property>
36-
<property name="standardButtons" >
37-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
38-
</property>
39-
</widget>
40-
</item>
4131
<item row="0" column="0" >
4232
<widget class="QTabWidget" name="tabWidget" >
4333
<property name="currentIndex" >
@@ -675,10 +665,23 @@
675665
<property name="spacing" >
676666
<number>6</number>
677667
</property>
678-
<item row="0" column="0" >
679-
<widget class="QGroupBox" name="mRubberBandGroupBox" >
668+
<item row="2" column="0" >
669+
<spacer>
670+
<property name="orientation" >
671+
<enum>Qt::Vertical</enum>
672+
</property>
673+
<property name="sizeHint" >
674+
<size>
675+
<width>20</width>
676+
<height>171</height>
677+
</size>
678+
</property>
679+
</spacer>
680+
</item>
681+
<item row="1" column="0" >
682+
<widget class="QGroupBox" name="mSnappingGroupBox" >
680683
<property name="title" >
681-
<string>Rubberband</string>
684+
<string>Snapping</string>
682685
</property>
683686
<layout class="QGridLayout" >
684687
<property name="margin" >
@@ -696,22 +699,9 @@
696699
<number>6</number>
697700
</property>
698701
<item>
699-
<widget class="QLabel" name="mLineWidthTextLabel" >
702+
<widget class="QLabel" name="mDefaultSnapModeLabel" >
700703
<property name="text" >
701-
<string>Line Width:</string>
702-
</property>
703-
<property name="buddy" >
704-
<cstring>mLineWidthSpinBox</cstring>
705-
</property>
706-
</widget>
707-
</item>
708-
<item>
709-
<widget class="QSpinBox" name="mLineWidthSpinBox" >
710-
<property name="toolTip" >
711-
<string>Line width in pixels</string>
712-
</property>
713-
<property name="minimum" >
714-
<number>1</number>
704+
<string>Default Snap Mode:</string>
715705
</property>
716706
</widget>
717707
</item>
@@ -722,53 +712,64 @@
722712
</property>
723713
<property name="sizeHint" >
724714
<size>
725-
<width>271</width>
715+
<width>311</width>
726716
<height>20</height>
727717
</size>
728718
</property>
729719
</spacer>
730720
</item>
731721
<item>
732-
<widget class="QLabel" name="mLineColourTextLabel" >
733-
<property name="text" >
734-
<string>Line Colour:</string>
722+
<widget class="QComboBox" name="mDefaultSnapModeComboBox" >
723+
<property name="sizePolicy" >
724+
<sizepolicy>
725+
<hsizetype>7</hsizetype>
726+
<vsizetype>0</vsizetype>
727+
<horstretch>0</horstretch>
728+
<verstretch>0</verstretch>
729+
</sizepolicy>
735730
</property>
736-
<property name="buddy" >
737-
<cstring>mLineColourToolButton</cstring>
731+
</widget>
732+
</item>
733+
</layout>
734+
</item>
735+
<item row="2" column="0" >
736+
<layout class="QHBoxLayout" >
737+
<property name="margin" >
738+
<number>0</number>
739+
</property>
740+
<property name="spacing" >
741+
<number>6</number>
742+
</property>
743+
<item>
744+
<widget class="QLabel" name="mVertexSearchRadiusVertexEditLabel" >
745+
<property name="text" >
746+
<string>Search radius for vertex edits (in layer units):</string>
738747
</property>
739748
</widget>
740749
</item>
741750
<item>
742-
<widget class="QgsColorButton" name="mLineColourToolButton" >
743-
<property name="minimumSize" >
751+
<spacer>
752+
<property name="orientation" >
753+
<enum>Qt::Horizontal</enum>
754+
</property>
755+
<property name="sizeHint" >
744756
<size>
745-
<width>100</width>
746-
<height>0</height>
757+
<width>61</width>
758+
<height>20</height>
747759
</size>
748760
</property>
749-
<property name="text" >
750-
<string/>
761+
</spacer>
762+
</item>
763+
<item>
764+
<widget class="QDoubleSpinBox" name="mSearchRadiusVertexEditSpinBox" >
765+
<property name="maximum" >
766+
<double>9999.989999999999782</double>
751767
</property>
752768
</widget>
753769
</item>
754770
</layout>
755771
</item>
756-
</layout>
757-
</widget>
758-
</item>
759-
<item row="1" column="0" >
760-
<widget class="QGroupBox" name="mSnappingGroupBox" >
761-
<property name="title" >
762-
<string>Snapping</string>
763-
</property>
764-
<layout class="QGridLayout" >
765-
<property name="margin" >
766-
<number>9</number>
767-
</property>
768-
<property name="spacing" >
769-
<number>6</number>
770-
</property>
771-
<item row="0" column="0" >
772+
<item row="1" column="0" >
772773
<layout class="QHBoxLayout" >
773774
<property name="margin" >
774775
<number>0</number>
@@ -805,7 +806,22 @@
805806
</item>
806807
</layout>
807808
</item>
808-
<item row="1" column="0" >
809+
</layout>
810+
</widget>
811+
</item>
812+
<item row="0" column="0" >
813+
<widget class="QGroupBox" name="mRubberBandGroupBox" >
814+
<property name="title" >
815+
<string>Rubberband</string>
816+
</property>
817+
<layout class="QGridLayout" >
818+
<property name="margin" >
819+
<number>9</number>
820+
</property>
821+
<property name="spacing" >
822+
<number>6</number>
823+
</property>
824+
<item row="0" column="0" >
809825
<layout class="QHBoxLayout" >
810826
<property name="margin" >
811827
<number>0</number>
@@ -814,9 +830,22 @@
814830
<number>6</number>
815831
</property>
816832
<item>
817-
<widget class="QLabel" name="mVertexSearchRadiusVertexEditLabel" >
833+
<widget class="QLabel" name="mLineWidthTextLabel" >
818834
<property name="text" >
819-
<string>Search radius for vertex edits (in layer units):</string>
835+
<string>Line Width:</string>
836+
</property>
837+
<property name="buddy" >
838+
<cstring>mLineWidthSpinBox</cstring>
839+
</property>
840+
</widget>
841+
</item>
842+
<item>
843+
<widget class="QSpinBox" name="mLineWidthSpinBox" >
844+
<property name="toolTip" >
845+
<string>Line width in pixels</string>
846+
</property>
847+
<property name="minimum" >
848+
<number>1</number>
820849
</property>
821850
</widget>
822851
</item>
@@ -827,16 +856,32 @@
827856
</property>
828857
<property name="sizeHint" >
829858
<size>
830-
<width>61</width>
859+
<width>271</width>
831860
<height>20</height>
832861
</size>
833862
</property>
834863
</spacer>
835864
</item>
836865
<item>
837-
<widget class="QDoubleSpinBox" name="mSearchRadiusVertexEditSpinBox" >
838-
<property name="maximum" >
839-
<double>9999.989999999999782</double>
866+
<widget class="QLabel" name="mLineColourTextLabel" >
867+
<property name="text" >
868+
<string>Line Colour:</string>
869+
</property>
870+
<property name="buddy" >
871+
<cstring>mLineColourToolButton</cstring>
872+
</property>
873+
</widget>
874+
</item>
875+
<item>
876+
<widget class="QgsColorButton" name="mLineColourToolButton" >
877+
<property name="minimumSize" >
878+
<size>
879+
<width>100</width>
880+
<height>0</height>
881+
</size>
882+
</property>
883+
<property name="text" >
884+
<string/>
840885
</property>
841886
</widget>
842887
</item>
@@ -845,19 +890,6 @@
845890
</layout>
846891
</widget>
847892
</item>
848-
<item row="2" column="0" >
849-
<spacer>
850-
<property name="orientation" >
851-
<enum>Qt::Vertical</enum>
852-
</property>
853-
<property name="sizeHint" >
854-
<size>
855-
<width>20</width>
856-
<height>171</height>
857-
</size>
858-
</property>
859-
</spacer>
860-
</item>
861893
</layout>
862894
</widget>
863895
<widget class="QWidget" name="tabProjection" >
@@ -1023,6 +1055,16 @@
10231055
</widget>
10241056
</widget>
10251057
</item>
1058+
<item row="1" column="0" >
1059+
<widget class="QDialogButtonBox" name="buttonBox" >
1060+
<property name="orientation" >
1061+
<enum>Qt::Horizontal</enum>
1062+
</property>
1063+
<property name="standardButtons" >
1064+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
1065+
</property>
1066+
</widget>
1067+
</item>
10261068
</layout>
10271069
</widget>
10281070
<layoutdefault spacing="6" margin="11" />

0 commit comments

Comments
 (0)
Please sign in to comment.