-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move unit handling helpers out of QGis and QgsSymbolLayerUtils
into a new QgsUnitTypes helper class. Add unit tests. TODO QGIS 3.0: Move QGis::UnitType and QgsSymbolV2::OutputUnit to QgsUnitTypes
- Loading branch information
1 parent
5a8e4cc
commit ddabad2
Showing
33 changed files
with
795 additions
and
252 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,80 @@ | ||
/** \ingroup core | ||
* \class QgsUnitTypes | ||
* \brief Helper functions for various unit types. | ||
* \note Added in version 2.14 | ||
*/ | ||
|
||
class QgsUnitTypes | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsunittypes.h> | ||
%End | ||
|
||
public: | ||
|
||
/** Types of distance units | ||
*/ | ||
enum DistanceUnitType | ||
{ | ||
Standard, /*!< unit is a standard measurement unit */ | ||
Geographic, /*!< unit is a geographic (eg degree based) unit */ | ||
UnknownType, /*!< unknown unit type */ | ||
}; | ||
|
||
/** Returns the type for a distance unit. | ||
*/ | ||
static DistanceUnitType unitType( QGis::UnitType unit ); | ||
|
||
/** Encodes a distance unit to a string. | ||
* @param unit unit to encode | ||
* @returns encoded string | ||
* @see decodeDistanceUnit() | ||
*/ | ||
static QString encodeUnit( QGis::UnitType unit ); | ||
|
||
/** Decodes a distance unit from a string. | ||
* @param string string to decode | ||
* @param ok optional boolean, will be set to true if string was converted successfully | ||
* @returns decoded units | ||
* @see encodeUnit() | ||
*/ | ||
static QGis::UnitType decodeDistanceUnit( const QString& string, bool *ok = 0 ); | ||
|
||
/** Returns a translated string representing a distance unit. | ||
* @param unit unit to convert to string | ||
* @see fromString() | ||
*/ | ||
static QString toString( QGis::UnitType unit ); | ||
|
||
/** Converts a translated string to a distance unit. | ||
* @param string string representing a distance unit | ||
* @param ok optional boolean, will be set to true if string was converted successfully | ||
* @see toString() | ||
*/ | ||
static QGis::UnitType stringToDistanceUnit( const QString& string, bool *ok = 0 ); | ||
|
||
/** Returns the conversion factor between the specified distance units. | ||
* @param fromUnit distance unit to convert from | ||
* @param toUnit distance unit to convert to | ||
* @returns multiplication factor to convert between units | ||
*/ | ||
static double fromUnitToUnitFactor( QGis::UnitType fromUnit, QGis::UnitType toUnit ); | ||
|
||
|
||
/** Encodes a symbol unit to a string. | ||
* @param unit unit to encode | ||
* @returns encoded string | ||
* @see decodeSymbolUnit() | ||
*/ | ||
static QString encodeUnit( QgsSymbolV2::OutputUnit unit ); | ||
|
||
/** Decodes a symbol unit from a string. | ||
* @param string string to decode | ||
* @param ok optional boolean, will be set to true if string was converted successfully | ||
* @returns decoded units | ||
* @see encodeUnit() | ||
*/ | ||
static QgsSymbolV2::OutputUnit decodeSymbolUnit( const QString& string, bool *ok = 0 ); | ||
|
||
}; | ||
|
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
Oops, something went wrong.