[QGIS Commit] r10478 - in trunk/qgis: python/core src/app src/core
src/gui src/ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Apr 5 12:46:13 EDT 2009
Author: wonder
Date: 2009-04-05 12:46:13 -0400 (Sun, 05 Apr 2009)
New Revision: 10478
Added:
trunk/qgis/python/core/qgstolerance.sip
trunk/qgis/src/core/qgstolerance.cpp
trunk/qgis/src/core/qgstolerance.h
Modified:
trunk/qgis/python/core/core.sip
trunk/qgis/python/core/qgssnapper.sip
trunk/qgis/src/app/qgsmaptoolmovefeature.cpp
trunk/qgis/src/app/qgsoptions.cpp
trunk/qgis/src/app/qgsprojectproperties.cpp
trunk/qgis/src/app/qgssnappingdialog.cpp
trunk/qgis/src/app/qgssnappingdialog.h
trunk/qgis/src/core/CMakeLists.txt
trunk/qgis/src/core/qgssnapper.cpp
trunk/qgis/src/core/qgssnapper.h
trunk/qgis/src/gui/qgsmapcanvassnapper.cpp
trunk/qgis/src/ui/qgsoptionsbase.ui
trunk/qgis/src/ui/qgssnappingdialogbase.ui
Log:
Added possibility to express tolerances for digitising also in pixels in addition to map units. Patch contributed by Richard Kostecky.
Modified: trunk/qgis/python/core/core.sip
===================================================================
--- trunk/qgis/python/core/core.sip 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/python/core/core.sip 2009-04-05 16:46:13 UTC (rev 10478)
@@ -64,6 +64,7 @@
%Include qgscoordinatereferencesystem.sip
%Include qgssymbol.sip
%Include qgssymbologyutils.sip
+%Include qgstolerance.sip
%Include qgsuniquevaluerenderer.sip
%Include qgsvectordataprovider.sip
%Include qgsvectorfilewriter.sip
Modified: trunk/qgis/python/core/qgssnapper.sip
===================================================================
--- trunk/qgis/python/core/qgssnapper.sip 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/python/core/qgssnapper.sip 2009-04-05 16:46:13 UTC (rev 10478)
@@ -65,6 +65,8 @@
double mTolerance;
/**What snapping type to use (snap to segment or to vertex)*/
QgsSnapper::SnappingType mSnapTo;
+ /**What unit is used for tolerance*/
+ QgsTolerance::UnitType mUnitType;
};
QgsSnapper(QgsMapRenderer* mapRender);
Added: trunk/qgis/python/core/qgstolerance.sip
===================================================================
--- trunk/qgis/python/core/qgstolerance.sip (rev 0)
+++ trunk/qgis/python/core/qgstolerance.sip 2009-04-05 16:46:13 UTC (rev 10478)
@@ -0,0 +1,42 @@
+
+class QgsTolerance
+{
+%TypeHeaderCode
+#include <qgstolerance.h>
+%End
+
+public:
+ /**Type of unit of tolerance value from settings*/
+ enum UnitType
+ {
+ /**Map unit value*/
+ MapUnits,
+ /**Pixels unit of tolerance*/
+ Pixels
+ };
+
+ /**
+ * Static function to get vertex tolerance value from settings
+ * @param mapUnitsPerPixel number of map units per pixel
+ * @return value of vertex tolerance in map units
+ */
+ static double vertexSearchRadius( double mapUnitsPerPixel );
+
+ /**
+ * Static function to get default tolerance value from settings
+ * @param mapUnitsPerPixel number of map units per pixel
+ * @return value of default tolerance in map units
+ */
+ static double defaultTolerance( double mapUnitsPerPixel );
+
+ /**
+ * Static function to translate tolerance value into current map unit value
+ * @param tolerace tolerance value to be translated
+ * @param mapUnitsPerPixel number of map units per pixel
+ * @param units type of units to be translated
+ * @return value of tolerance in map units
+ */
+ static double toleranceInMapUnits(double tolerance, double mapUnitsPerPixel, UnitType units = MapUnits);
+
+};
+
Modified: trunk/qgis/src/app/qgsmaptoolmovefeature.cpp
===================================================================
--- trunk/qgis/src/app/qgsmaptoolmovefeature.cpp 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/app/qgsmaptoolmovefeature.cpp 2009-04-05 16:46:13 UTC (rev 10478)
@@ -21,6 +21,7 @@
#include "qgsrubberband.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
+#include "qgstolerance.h"
#include <QMessageBox>
#include <QMouseEvent>
#include <QSettings>
@@ -71,7 +72,7 @@
//find first geometry under mouse cursor and store iterator to it
QgsPoint layerCoords = toLayerCoordinates(( QgsMapLayer* )vlayer, e->pos() );
QSettings settings;
- double searchRadius = settings.value( "/qgis/digitizing/search_radius_vertex_edit", 10 ).toDouble();
+ double searchRadius = QgsTolerance::vertexSearchRadius( mCanvas->mapUnitsPerPixel() );
QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius,
layerCoords.x() + searchRadius, layerCoords.y() + searchRadius );
Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/app/qgsoptions.cpp 2009-04-05 16:46:13 UTC (rev 10478)
@@ -22,6 +22,7 @@
#include "qgisapp.h"
#include "qgsgenericprojectionselector.h"
#include "qgscoordinatereferencesystem.h"
+#include "qgstolerance.h"
#include <QFileDialog>
#include <QSettings>
@@ -196,6 +197,25 @@
mDefaultSnapModeComboBox->setCurrentIndex( mDefaultSnapModeComboBox->findData( defaultSnapString ) );
mDefaultSnappingToleranceSpinBox->setValue( settings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble() );
mSearchRadiusVertexEditSpinBox->setValue( settings.value( "/qgis/digitizing/search_radius_vertex_edit", 10 ).toDouble() );
+ int index;
+ if (settings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt() == QgsTolerance::MapUnits)
+ {
+ index = mDefaultSnappingToleranceComboBox->findText( tr( "map units" ) );
+ }
+ else
+ {
+ index = mDefaultSnappingToleranceComboBox->findText( tr( "pixels" ) );
+ }
+ mDefaultSnappingToleranceComboBox->setCurrentIndex( index );
+ if (settings.value( "/qgis/digitizing/search_radius_vertex_edit_unit", 0 ).toInt() == QgsTolerance::MapUnits)
+ {
+ index = mSearchRadiusVertexEditComboBox->findText( tr( "map units" ) );
+ }
+ else
+ {
+ index = mSearchRadiusVertexEditComboBox->findText( tr( "pixels" ) );
+ }
+ mSearchRadiusVertexEditComboBox->setCurrentIndex( settings.value( "/qgis/digitizing/search_radius_vertex_edit_unit", 0 ).toInt() );
//vertex marker
mMarkerStyleComboBox->addItem( tr( "Semi transparent circle" ) );
@@ -374,7 +394,12 @@
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() );
+ settings.setValue( "/qgis/digitizing/default_snapping_tolerance_unit",
+ (mDefaultSnappingToleranceComboBox->currentIndex() == 0 ? QgsTolerance::MapUnits : QgsTolerance::Pixels ) );
+ settings.setValue( "/qgis/digitizing/search_radius_vertex_edit_unit",
+ (mSearchRadiusVertexEditComboBox->currentIndex() == 0 ? QgsTolerance::MapUnits : QgsTolerance::Pixels ) );
+
QString markerComboText = mMarkerStyleComboBox->currentText();
if ( markerComboText == tr( "Semi transparent circle" ) )
{
Modified: trunk/qgis/src/app/qgsprojectproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsprojectproperties.cpp 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/app/qgsprojectproperties.cpp 2009-04-05 16:46:13 UTC (rev 10478)
@@ -122,11 +122,13 @@
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &ok );
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &ok );
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", &ok );
+ QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", &ok );
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &ok );
QStringList::const_iterator idIter = layerIdList.constBegin();
QStringList::const_iterator enabledIter = enabledList.constBegin();
QStringList::const_iterator tolIter = toleranceList.constBegin();
+ QStringList::const_iterator tolUnitIter = toleranceUnitList.constBegin();
QStringList::const_iterator snapToIter = snapToList.constBegin();
QgsMapLayer* currentLayer = 0;
@@ -160,6 +162,7 @@
newEntry.snapTo = 2;
}
newEntry.tolerance = tolIter->toDouble();
+ newEntry.toleranceUnit = tolUnitIter->toInt();
mSnappingLayerSettings.insert( *idIter, newEntry );
}
}
@@ -306,11 +309,13 @@
QStringList snapToList;
QStringList toleranceList;
QStringList enabledList;
+ QStringList toleranceUnitList;
for ( layerEntryIt = mSnappingLayerSettings.constBegin(); layerEntryIt != mSnappingLayerSettings.constEnd(); ++layerEntryIt )
{
layerIdList << layerEntryIt.key();
toleranceList << QString::number( layerEntryIt->tolerance, 'f' );
+ toleranceUnitList << QString::number( (int)layerEntryIt->toleranceUnit );
if ( layerEntryIt->checked )
{
enabledList << "enabled";
@@ -338,6 +343,7 @@
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingList", layerIdList );
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnapToList", snapToList );
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceList", toleranceList );
+ QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceUnitList", toleranceUnitList );
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingEnabledList", enabledList );
}
Modified: trunk/qgis/src/app/qgssnappingdialog.cpp
===================================================================
--- trunk/qgis/src/app/qgssnappingdialog.cpp 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/app/qgssnappingdialog.cpp 2009-04-05 16:46:13 UTC (rev 10478)
@@ -71,6 +71,12 @@
snappingToleranceEdit->setValidator( validator );
mLayerTreeWidget->setItemWidget( newItem, 2, snappingToleranceEdit );
+ //snap to vertex/ snap to segment
+ QComboBox* toleranceUnitsComboBox = new QComboBox( mLayerTreeWidget );
+ toleranceUnitsComboBox->insertItem( 0, tr( "map units" ) );
+ toleranceUnitsComboBox->insertItem( 1, tr( "pixels" ) );
+ mLayerTreeWidget->setItemWidget( newItem, 3, toleranceUnitsComboBox );
+
settingIt = settings.find( currentVectorLayer->getLayerID() );
if ( settingIt != settings.constEnd() )
{
@@ -89,6 +95,15 @@
index = snapToComboBox->findText( tr( "to vertex and segment" ) );
}
snapToComboBox->setCurrentIndex( index );
+ if ( settingIt.value().toleranceUnit == 0 )//map units
+ {
+ index = toleranceUnitsComboBox->findText( tr( "map units" ) );
+ }
+ else
+ {
+ index = toleranceUnitsComboBox->findText( tr( "pixels" ) );
+ }
+ toleranceUnitsComboBox->setCurrentIndex( index );
if ( settingIt.value().checked )
{
newItem->setCheckState( 0, Qt::Checked );
@@ -103,8 +118,9 @@
}
}
mLayerTreeWidget->resizeColumnToContents( 0 );
- mLayerTreeWidget->setColumnWidth( 1, 300 ); //hardcoded for now
+ mLayerTreeWidget->setColumnWidth( 1, 200 ); //hardcoded for now
mLayerTreeWidget->resizeColumnToContents( 2 );
+ mLayerTreeWidget->resizeColumnToContents( 3 );
}
}
@@ -127,7 +143,9 @@
QString layerId;
QString layerName;
QString snapToItemText;
+ QString toleranceItemText;
int snapTo;
+ int toleranceUnit;
double tolerance;
bool checked = false;
@@ -144,6 +162,7 @@
layerId = mLayerIds.at( i );
checked = ( currentItem->checkState( 0 ) == Qt::Checked );
snapToItemText = (( QComboBox* )( mLayerTreeWidget->itemWidget( currentItem, 1 ) ) )->currentText();
+ toleranceItemText = (( QComboBox* )( mLayerTreeWidget->itemWidget( currentItem, 3 ) ) )->currentText();
if ( snapToItemText == tr( "to vertex" ) )
{
snapTo = 0;
@@ -156,10 +175,18 @@
{
snapTo = 2;
}
+ if ( toleranceItemText == tr( "map units" ) )
+ {
+ toleranceUnit = 0;
+ }
+ else //to vertex and segment
+ {
+ toleranceUnit = 1;
+ }
tolerance = (( QLineEdit* )( mLayerTreeWidget->itemWidget( currentItem, 2 ) ) )->text().toDouble();
LayerEntry newEntry;
newEntry.checked = checked; newEntry.snapTo = snapTo; newEntry.layerName = layerName;
- newEntry.tolerance = tolerance;
+ newEntry.tolerance = tolerance; newEntry.toleranceUnit = toleranceUnit;
settings.insert( layerId, newEntry );
}
}
Modified: trunk/qgis/src/app/qgssnappingdialog.h
===================================================================
--- trunk/qgis/src/app/qgssnappingdialog.h 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/app/qgssnappingdialog.h 2009-04-05 16:46:13 UTC (rev 10478)
@@ -28,6 +28,7 @@
int snapTo; //0 = to vertex, 1 = to segment, 2 = to vertex and to segment
QString layerName;
double tolerance;
+ int toleranceUnit;
};
/**A dialog to enter advanced editing properties, e.g. topological editing, snapping settings
Modified: trunk/qgis/src/core/CMakeLists.txt
===================================================================
--- trunk/qgis/src/core/CMakeLists.txt 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/core/CMakeLists.txt 2009-04-05 16:46:13 UTC (rev 10478)
@@ -43,6 +43,7 @@
qgssearchtreenode.cpp
qgssnapper.cpp
qgscoordinatereferencesystem.cpp
+ qgstolerance.cpp
qgsvectordataprovider.cpp
qgsvectorfilewriter.cpp
qgsvectorlayer.cpp
Modified: trunk/qgis/src/core/qgssnapper.cpp
===================================================================
--- trunk/qgis/src/core/qgssnapper.cpp 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/core/qgssnapper.cpp 2009-04-05 16:46:13 UTC (rev 10478)
@@ -56,7 +56,9 @@
{
//transform point from map coordinates to layer coordinates
layerCoordPoint = mMapRenderer->mapToLayerCoordinates( snapLayerIt->mLayer, mapCoordPoint );
- if ( snapLayerIt->mLayer->snapWithContext( layerCoordPoint, snapLayerIt->mTolerance,
+
+ double tolerance = QgsTolerance::toleranceInMapUnits( snapLayerIt->mTolerance, mMapRenderer->mapUnitsPerPixel(), snapLayerIt->mUnitType );
+ if ( snapLayerIt->mLayer->snapWithContext( layerCoordPoint, tolerance,
currentResultList, snapLayerIt->mSnapTo ) != 0 )
{
//error
Modified: trunk/qgis/src/core/qgssnapper.h
===================================================================
--- trunk/qgis/src/core/qgssnapper.h 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/core/qgssnapper.h 2009-04-05 16:46:13 UTC (rev 10478)
@@ -19,6 +19,7 @@
#define QGSSNAPPER_H
#include "qgspoint.h"
+#include "qgstolerance.h"
#include <QList>
#include <QMultiMap>
@@ -86,6 +87,8 @@
double mTolerance;
/**What snapping type to use (snap to segment or to vertex)*/
QgsSnapper::SnappingType mSnapTo;
+ /**What unit is used for tolerance*/
+ QgsTolerance::UnitType mUnitType;
};
QgsSnapper( QgsMapRenderer* mapRender );
Added: trunk/qgis/src/core/qgstolerance.cpp
===================================================================
--- trunk/qgis/src/core/qgstolerance.cpp (rev 0)
+++ trunk/qgis/src/core/qgstolerance.cpp 2009-04-05 16:46:13 UTC (rev 10478)
@@ -0,0 +1,43 @@
+/***************************************************************************
+ qgstolerance.cpp - wrapper for tolerance handling
+ ----------------------
+ begin : March 2009
+ copyright : (C) 2009 by Richard Kostecky
+ email : csf.kostej at gmail dot com
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "qgstolerance.h"
+#include <QSettings>
+
+
+double QgsTolerance::toleranceInMapUnits(double tolerance, double mapUnitsPerPixel, UnitType units)
+{
+ if (units == MapUnits)
+ {
+ return tolerance;
+ }
+ return tolerance * mapUnitsPerPixel;
+}
+
+double QgsTolerance::vertexSearchRadius( double mapUnitsPerPixel )
+{
+ QSettings settings;
+ double tolerance = settings.value( "/qgis/digitizing/search_radius_vertex_edit", 10 ).toDouble();
+ UnitType units = (QgsTolerance::UnitType) settings.value( "/qgis/digitizing/search_radius_vertex_edit_unit", 0 ).toInt();
+ return toleranceInMapUnits(tolerance, mapUnitsPerPixel, units);
+}
+
+double QgsTolerance::defaultTolerance( double mapUnitsPerPixel )
+{
+ QSettings settings;
+ double tolerance = settings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
+ UnitType units = (QgsTolerance::UnitType) settings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt();
+ return toleranceInMapUnits(tolerance, mapUnitsPerPixel, units);
+}
Added: trunk/qgis/src/core/qgstolerance.h
===================================================================
--- trunk/qgis/src/core/qgstolerance.h (rev 0)
+++ trunk/qgis/src/core/qgstolerance.h 2009-04-05 16:46:13 UTC (rev 10478)
@@ -0,0 +1,63 @@
+/***************************************************************************
+ qgstolerance.h - wrapper for tolerance handling
+ ----------------------
+ begin : March 2009
+ copyright : (C) 2009 by Richard Kostecky
+ email : csf.kostej at gmail dot com
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef QGSTOLERANCE_H
+#define QGSTOLERANCE_H
+
+
+/** \ingroup core
+ * This is the class is providing tolerance value in map unit values.
+ *
+ * \note This class has been added in version 1.1.
+ */
+class CORE_EXPORT QgsTolerance
+{
+
+ public:
+ /**Type of unit of tolerance value from settings*/
+ enum UnitType
+ {
+ /**Map unit value*/
+ MapUnits,
+ /**Pixels unit of tolerance*/
+ Pixels
+ };
+
+ /**
+ * Static function to get vertex tolerance value from settings
+ * @param mapUnitsPerPixel number of map units per pixel
+ * @return value of vertex tolerance in map units
+ */
+ static double vertexSearchRadius( double mapUnitsPerPixel );
+
+ /**
+ * Static function to get default tolerance value from settings
+ * @param mapUnitsPerPixel number of map units per pixel
+ * @return value of default tolerance in map units
+ */
+ static double defaultTolerance( double mapUnitsPerPixel );
+
+ /**
+ * Static function to translate tolerance value into current map unit value
+ * @param tolerace tolerance value to be translated
+ * @param mapUnitsPerPixel number of map units per pixel
+ * @param units type of units to be translated
+ * @return value of tolerance in map units
+ */
+ static double toleranceInMapUnits(double tolerance, double mapUnitsPerPixel, UnitType units = MapUnits);
+
+};
+
+#endif
Modified: trunk/qgis/src/gui/qgsmapcanvassnapper.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvassnapper.cpp 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/gui/qgsmapcanvassnapper.cpp 2009-04-05 16:46:13 UTC (rev 10478)
@@ -21,8 +21,10 @@
#include "qgsmaptopixel.h"
#include "qgsproject.h"
#include "qgsvectorlayer.h"
+#include "qgstolerance.h"
#include <QSettings>
+
QgsMapCanvasSnapper::QgsMapCanvasSnapper( QgsMapCanvas* canvas ): mMapCanvas( canvas ), mSnapper( 0 )
{
if ( canvas )
@@ -92,13 +94,14 @@
QgsSnapper::SnapLayer snapLayer;
snapLayer.mLayer = vlayer;
snapLayer.mSnapTo = snap_to;
+ snapLayer.mUnitType = QgsTolerance::MapUnits;
QSettings settings;
if ( snappingTol < 0 )
{
//use search tolerance for vertex editing
- snapLayer.mTolerance = settings.value( "/qgis/digitizing/search_radius_vertex_edit", 50 ).toDouble();
+ snapLayer.mTolerance = QgsTolerance::vertexSearchRadius(mMapCanvas->mapUnitsPerPixel());
}
else
{
@@ -149,9 +152,10 @@
}
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &ok );
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", &ok );
+ QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", &ok );
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &ok );
- if ( !( layerIdList.size() == enabledList.size() && layerIdList.size() == toleranceList.size() && layerIdList.size() == snapToList.size() ) )
+ if ( !( layerIdList.size() == enabledList.size() && layerIdList.size() == toleranceList.size() && layerIdList.size() == toleranceUnitList.size() && layerIdList.size() == snapToList.size() ) )
{
return 1; //lists must have the same size, otherwise something is wrong
}
@@ -168,10 +172,11 @@
QStringList::const_iterator layerIt = layerIdList.constBegin();
QStringList::const_iterator tolIt = toleranceList.constBegin();
+ QStringList::const_iterator tolUnitIt = toleranceUnitList.constBegin();
QStringList::const_iterator snapIt = snapToList.constBegin();
QStringList::const_iterator enabledIt = enabledList.constBegin();
- for ( ; layerIt != layerIdList.constEnd(); ++layerIt, ++tolIt, ++snapIt, ++enabledIt )
+ for ( ; layerIt != layerIdList.constEnd(); ++layerIt, ++tolIt, ++tolUnitIt, ++snapIt, ++enabledIt )
{
if (( *enabledIt ) != "enabled" ) //skip layer if snapping is not enabled
{
@@ -191,6 +196,7 @@
//tolerance
snapLayer.mTolerance = tolIt->toDouble();
+ snapLayer.mUnitType = (QgsTolerance::UnitType) tolUnitIt->toInt();
//segment or vertex
if (( *snapIt ) == "to_vertex" )
@@ -241,8 +247,9 @@
snapLayer.mSnapTo = QgsSnapper::SnapToVertex;
}
- //default snapping tolerance
- snapLayer.mTolerance = settings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
+ //default snapping tolerance (returned in map units)
+ snapLayer.mTolerance = QgsTolerance::defaultTolerance(mMapCanvas->mapUnitsPerPixel());
+ snapLayer.mUnitType = QgsTolerance::MapUnits;
snapLayers.append( snapLayer );
}
Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui 2009-04-05 16:46:13 UTC (rev 10478)
@@ -659,7 +659,7 @@
</property>
</spacer>
</item>
- <item row="0" column="4" >
+ <item row="0" column="4" colspan="2" >
<widget class="QComboBox" name="mDefaultSnapModeComboBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
@@ -729,6 +729,40 @@
</property>
</widget>
</item>
+ <item row="1" column="5" >
+ <widget class="QComboBox" name="mDefaultSnappingToleranceComboBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text" >
+ <string>map units</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>pixels</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="5" >
+ <widget class="QComboBox" name="mSearchRadiusVertexEditComboBox" >
+ <item>
+ <property name="text" >
+ <string>map units</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>pixels</string>
+ </property>
+ </item>
+ </widget>
+ </item>
</layout>
</widget>
</item>
Modified: trunk/qgis/src/ui/qgssnappingdialogbase.ui
===================================================================
--- trunk/qgis/src/ui/qgssnappingdialogbase.ui 2009-04-05 15:50:24 UTC (rev 10477)
+++ trunk/qgis/src/ui/qgssnappingdialogbase.ui 2009-04-05 16:46:13 UTC (rev 10478)
@@ -13,12 +13,24 @@
<string>Snapping options</string>
</property>
<layout class="QGridLayout" >
- <property name="margin" >
+ <property name="leftMargin" >
<number>9</number>
</property>
- <property name="spacing" >
+ <property name="topMargin" >
+ <number>9</number>
+ </property>
+ <property name="rightMargin" >
+ <number>9</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>9</number>
+ </property>
+ <property name="horizontalSpacing" >
<number>6</number>
</property>
+ <property name="verticalSpacing" >
+ <number>6</number>
+ </property>
<item row="0" column="0" >
<widget class="QTreeWidget" name="mLayerTreeWidget" >
<column>
@@ -36,6 +48,11 @@
<string>Tolerance</string>
</property>
</column>
+ <column>
+ <property name="text" >
+ <string>Units</string>
+ </property>
+ </column>
</widget>
</item>
<item row="1" column="0" >
More information about the QGIS-commit
mailing list