QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Classes | Macros | Typedefs | Functions | Variables
qgis.h File Reference
#include <QEvent>
#include <QString>
#include <QRegExp>
#include <QMetaType>
#include <QVariant>
#include <QDateTime>
#include <QDate>
#include <QTime>
#include <QHash>
#include <stdlib.h>
#include <cfloat>
#include <cmath>
#include <qnumeric.h>
#include <qgswkbtypes.h>
Include dependency graph for qgis.h:

Go to the source code of this file.

Classes

class  QGis
 The QGis class provides global constants for use throughout the application. More...
 
class  QgsSignalBlocker< Object >
 RAII signal blocking class. More...
 

Macros

#define FALLTHROUGH
 
#define Q_NOWARN_DEPRECATED_POP
 
#define Q_NOWARN_DEPRECATED_PUSH
 
#define QGISEXTERN   extern "C"
 

Typedefs

typedef unsigned long long qgssize
 Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be hard to define size_t correctly in SIP. More...
 
typedef QMap< QString, QStringQgsStringMap
 

Functions

void CORE_EXPORT * qgsCalloc (size_t nmemb, size_t size)
 Allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the allocated memory. More...
 
bool qgsDoubleNear (double a, double b, double epsilon=4 *DBL_EPSILON)
 Compare two doubles (but allow some difference) More...
 
bool qgsDoubleNearSig (double a, double b, int significantDigits=10)
 Compare two doubles using specified number of significant digits. More...
 
QString qgsDoubleToString (double a, int precision=17)
 Returns a string representation of a double. More...
 
bool qgsFloatNear (float a, float b, float epsilon=4 *FLT_EPSILON)
 Compare two floats (but allow some difference) More...
 
void CORE_EXPORT qgsFree (void *ptr)
 Frees the memory space pointed to by ptr. More...
 
void CORE_EXPORT * qgsMalloc (size_t size)
 Allocates size bytes and returns a pointer to the allocated memory. More...
 
double qgsRound (double x)
 A round function which returns a double to guard against overflows. More...
 
CORE_EXPORT bool qgsVariantGreaterThan (const QVariant &lhs, const QVariant &rhs)
 Compares two QVariant values and returns whether the first is greater than the second. More...
 
CORE_EXPORT bool qgsVariantLessThan (const QVariant &lhs, const QVariant &rhs)
 Compares two QVariant values and returns whether the first is less than the second. More...
 
CORE_EXPORT QString qgsVsiPrefix (const QString &path)
 
uint qHash (const QDateTime &key)
 Hash implementation for QDateTime. More...
 
uint qHash (const QDate &key)
 Hash implementation for QDate. More...
 
uint qHash (const QTime &key)
 Hash implementation for QTime. More...
 
template<class Object >
QgsSignalBlocker< Object > whileBlocking (Object *object)
 Temporarily blocks signals from a QObject while calling a single method from the object. More...
 

Variables

void(*)() cast_to_fptr (void *p)
 
const double DEFAULT_LINE_WIDTH = 0.26
 
const double DEFAULT_POINT_SIZE = 2.0
 Magic number that determines the default point size for point symbols. More...
 
const double DEFAULT_SEGMENT_EPSILON = 1e-8
 Default snapping tolerance for segments. More...
 
const int ELLPS_PREFIX_LEN = 7
 The length of the string "+ellps=". More...
 
CORE_EXPORT const QString GEO_EPSG_CRS_AUTHID
 Geographic coord sys from EPSG authority. More...
 
const long GEO_EPSG_CRS_ID = 4326
 Magic number for a geographic coord sys in EpsgCrsId ID format. More...
 
CORE_EXPORT const QString GEO_NONE
 Constant that holds the string representation for "No ellips/No CRS". More...
 
const long GEOCRS_ID = 3452
 Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id. More...
 
CORE_EXPORT const QString GEOPROJ4
 PROJ4 string that represents a geographic coord sys. More...
 
const long GEOSRID = 4326
 Magic number for a geographic coord sys in POSTGIS SRID. More...
 
CORE_EXPORT const QString GEOWKT
 Wkt string that represents a geographic coord sys. More...
 
const int LAT_PREFIX_LEN = 7
 The length of the string "+lat_1=". More...
 
const double MINIMUM_POINT_SIZE = 0.1
 Magic number that determines the minimum allowable point size for point symbols. More...
 
const int PROJ_PREFIX_LEN = 6
 The length of the string "+proj=". More...
 
CORE_EXPORT const QString PROJECT_SCALES
 
const int USER_CRS_START_ID = 100000
 Magick number that determines whether a projection crsid is a system (srs.db) or user (~/.qgis.qgis.db) defined projection. More...
 

Macro Definition Documentation

◆ FALLTHROUGH

#define FALLTHROUGH

Definition at line 539 of file qgis.h.

◆ Q_NOWARN_DEPRECATED_POP

#define Q_NOWARN_DEPRECATED_POP

Definition at line 516 of file qgis.h.

◆ Q_NOWARN_DEPRECATED_PUSH

#define Q_NOWARN_DEPRECATED_PUSH

Definition at line 515 of file qgis.h.

◆ QGISEXTERN

#define QGISEXTERN   extern "C"

Definition at line 530 of file qgis.h.

Typedef Documentation

◆ qgssize

typedef unsigned long long qgssize

Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be hard to define size_t correctly in SIP.

Currently used "unsigned long long" was introduced in C++11 (2011) but it was supported already before C++11 on common platforms. "unsigned long long int" gives syntax error in SIP. KEEP IN SYNC WITH qgssize defined in SIP!

Definition at line 500 of file qgis.h.

◆ QgsStringMap

Definition at line 492 of file qgis.h.

Function Documentation

◆ qgsCalloc()

void CORE_EXPORT* qgsCalloc ( size_t  nmemb,
size_t  size 
)

Allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the allocated memory.

Works like C calloc() but prints debug message by QgsLogger if allocation fails.

Parameters
nmembnumber of elements
sizesize of element in bytes

Definition at line 249 of file qgis.cpp.

◆ qgsDoubleNear()

bool qgsDoubleNear ( double  a,
double  b,
double  epsilon = 4 * DBL_EPSILON 
)
inline

Compare two doubles (but allow some difference)

Parameters
afirst double
bsecond double
epsilonmaximum difference allowable between doubles

Definition at line 353 of file qgis.h.

◆ qgsDoubleNearSig()

bool qgsDoubleNearSig ( double  a,
double  b,
int  significantDigits = 10 
)
inline

Compare two doubles using specified number of significant digits.

Definition at line 370 of file qgis.h.

◆ qgsDoubleToString()

QString qgsDoubleToString ( double  a,
int  precision = 17 
)
inline

Returns a string representation of a double.

Parameters
adouble value
precisionnumber of decimal places to retain

Definition at line 341 of file qgis.h.

◆ qgsFloatNear()

bool qgsFloatNear ( float  a,
float  b,
float  epsilon = 4 * FLT_EPSILON 
)
inline

Compare two floats (but allow some difference)

Parameters
afirst float
bsecond float
epsilonmaximum difference allowable between floats

Definition at line 363 of file qgis.h.

◆ qgsFree()

void CORE_EXPORT qgsFree ( void *  ptr)

Frees the memory space pointed to by ptr.

Works like C free().

Parameters
ptrpointer to memory space

Definition at line 264 of file qgis.cpp.

◆ qgsMalloc()

void CORE_EXPORT* qgsMalloc ( size_t  size)

Allocates size bytes and returns a pointer to the allocated memory.

Works like C malloc() but prints debug message by QgsLogger if allocation fails.

Parameters
sizesize in bytes

Definition at line 234 of file qgis.cpp.

◆ qgsRound()

double qgsRound ( double  x)
inline

A round function which returns a double to guard against overflows.

Definition at line 386 of file qgis.h.

◆ qgsVariantGreaterThan()

CORE_EXPORT bool qgsVariantGreaterThan ( const QVariant lhs,
const QVariant rhs 
)

Compares two QVariant values and returns whether the first is greater than the second.

Useful for sorting lists of variants, correctly handling sorting of the various QVariant data types (such as strings, numeric values, dates and times)

See also
qgsVariantLessThan()

Definition at line 337 of file qgis.cpp.

◆ qgsVariantLessThan()

CORE_EXPORT bool qgsVariantLessThan ( const QVariant lhs,
const QVariant rhs 
)

Compares two QVariant values and returns whether the first is less than the second.

Useful for sorting lists of variants, correctly handling sorting of the various QVariant data types (such as strings, numeric values, dates and times)

See also
qgsVariantGreaterThan()

Definition at line 269 of file qgis.cpp.

◆ qgsVsiPrefix()

CORE_EXPORT QString qgsVsiPrefix ( const QString path)

Definition at line 342 of file qgis.cpp.

◆ qHash() [1/3]

uint qHash ( const QDateTime key)
inline

Hash implementation for QDateTime.

Note
not available in Python bindings

Definition at line 397 of file qgis.h.

◆ qHash() [2/3]

uint qHash ( const QDate key)
inline

Hash implementation for QDate.

Note
not available in Python bindings

Definition at line 404 of file qgis.h.

◆ qHash() [3/3]

uint qHash ( const QTime key)
inline

Hash implementation for QTime.

Note
not available in Python bindings

Definition at line 411 of file qgis.h.

◆ whileBlocking()

template<class Object >
QgsSignalBlocker<Object> whileBlocking ( Object *  object)
inline

Temporarily blocks signals from a QObject while calling a single method from the object.

Usage: whileBlocking( checkBox )->setChecked( true ); whileBlocking( spinBox )->setValue( 50 );

No signals will be emitted when calling these methods.

Note
added in QGIS 2.16
See also
QgsSignalBlocker
Note
not available in Python bindings

Definition at line 333 of file qgis.h.

Variable Documentation

◆ cast_to_fptr

void( *)() cast_to_fptr(void *p)
inline

Definition at line 272 of file qgis.h.

◆ DEFAULT_LINE_WIDTH

const double DEFAULT_LINE_WIDTH = 0.26

Definition at line 487 of file qgis.h.

◆ DEFAULT_POINT_SIZE

const double DEFAULT_POINT_SIZE = 2.0

Magic number that determines the default point size for point symbols.

Definition at line 486 of file qgis.h.

◆ DEFAULT_SEGMENT_EPSILON

const double DEFAULT_SEGMENT_EPSILON = 1e-8

Default snapping tolerance for segments.

Definition at line 490 of file qgis.h.

◆ ELLPS_PREFIX_LEN

const int ELLPS_PREFIX_LEN = 7

The length of the string "+ellps=".

Definition at line 469 of file qgis.h.

◆ GEO_EPSG_CRS_AUTHID

CORE_EXPORT const QString GEO_EPSG_CRS_AUTHID

Geographic coord sys from EPSG authority.

Definition at line 74 of file qgis.cpp.

◆ GEO_EPSG_CRS_ID

const long GEO_EPSG_CRS_ID = 4326

Magic number for a geographic coord sys in EpsgCrsId ID format.

Definition at line 463 of file qgis.h.

◆ GEO_NONE

CORE_EXPORT const QString GEO_NONE

Constant that holds the string representation for "No ellips/No CRS".

Definition at line 76 of file qgis.cpp.

◆ GEOCRS_ID

const long GEOCRS_ID = 3452

Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id.

Definition at line 461 of file qgis.h.

◆ GEOPROJ4

CORE_EXPORT const QString GEOPROJ4

PROJ4 string that represents a geographic coord sys.

Definition at line 54 of file qgis.cpp.

◆ GEOSRID

const long GEOSRID = 4326

Magic number for a geographic coord sys in POSTGIS SRID.

Definition at line 459 of file qgis.h.

◆ GEOWKT

CORE_EXPORT const QString GEOWKT

Wkt string that represents a geographic coord sys.

Note
added to replace GEOWkt

Definition at line 57 of file qgis.cpp.

◆ LAT_PREFIX_LEN

const int LAT_PREFIX_LEN = 7

The length of the string "+lat_1=".

Definition at line 471 of file qgis.h.

◆ MINIMUM_POINT_SIZE

const double MINIMUM_POINT_SIZE = 0.1

Magic number that determines the minimum allowable point size for point symbols.

Definition at line 484 of file qgis.h.

◆ PROJ_PREFIX_LEN

const int PROJ_PREFIX_LEN = 6

The length of the string "+proj=".

Definition at line 467 of file qgis.h.

◆ PROJECT_SCALES

CORE_EXPORT const QString PROJECT_SCALES

Definition at line 70 of file qgis.cpp.

◆ USER_CRS_START_ID

const int USER_CRS_START_ID = 100000

Magick number that determines whether a projection crsid is a system (srs.db) or user (~/.qgis.qgis.db) defined projection.

Definition at line 474 of file qgis.h.