Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added possibility to express tolerances for digitising also in pixels…
… in addition to map units. Patch contributed by Richard Kostecky. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10478 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
wonder
committed
Apr 5, 2009
1 parent
d7a5370
commit c87f2c8
Showing
16 changed files
with
287 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.