33 #include <type_traits>    39 #include "qgis_core.h"    48 int QgisEvent = QEvent::User + 1;
   106       ARGB32_Premultiplied = 13 
   170 #define cast_to_fptr(f) f   192       , mPreviousState( object->blockSignals( true ) )
   197       mObject->blockSignals( mPreviousState );
   205     Object *mObject = 
nullptr;
   230 CORE_EXPORT uint 
qHash( 
const QVariant &variant );
   240     return QString::number( a, 
'f', precision ).remove( QRegExp( 
"\\.?0+$" ) );
   242     return QString::number( a, 
'f', precision );
   251 inline bool qgsDoubleNear( 
double a, 
double b, 
double epsilon = 4 * std::numeric_limits<double>::epsilon() )
   253   const double diff = a - b;
   254   return diff > -epsilon && diff <= epsilon;
   263 inline bool qgsFloatNear( 
float a, 
float b, 
float epsilon = 4 * FLT_EPSILON )
   265   const float diff = a - b;
   266   return diff > -epsilon && diff <= epsilon;
   278   double ar = std::frexp( a, &aexp );
   279   double br = std::frexp( b, &bexp );
   281   return aexp == bexp &&
   282          std::round( ar * std::pow( 10.0, significantDigits ) ) == std::round( br * std::pow( 10.0, significantDigits ) );
   290 inline double qgsRound( 
double number, 
double places )
   292   int scaleFactor = std::pow( 10, places );
   293   return static_cast<double>( 
static_cast<qlonglong
>( number * scaleFactor + 0.5 ) ) / scaleFactor;
   322   template <
typename T> 
struct QgsAddConst { 
typedef const T Type; };
   324   template <
typename T>
   325   constexpr 
typename QgsAddConst<T>::Type &as_const( T &t ) noexcept { 
return t; }
   327   template <
typename T>
   328   void as_const( 
const T && ) = 
delete;
   332   template<
class T> 
struct _Unique_if
   334     typedef std::unique_ptr<T> _Single_object;
   337   template<
class T> 
struct _Unique_if<T[]>
   339     typedef std::unique_ptr<T[]> _Unknown_bound;
   342   template<
class T, 
size_t N> 
struct _Unique_if<T[N]>
   344     typedef void _Known_bound;
   347   template<
class T, 
class... Args>
   348   typename _Unique_if<T>::_Single_object
   349   make_unique( Args &&... args )
   351     return std::unique_ptr<T>( 
new T( std::forward<Args>( args )... ) );
   355   typename _Unique_if<T>::_Unknown_bound
   356   make_unique( 
size_t n )
   358     typedef typename std::remove_extent<T>::type U;
   359     return std::unique_ptr<T>( 
new U[n]() );
   362   template<
class T, 
class... Args>
   363   typename _Unique_if<T>::_Known_bound
   364   make_unique( Args &&... ) = 
delete;
   378   template<
typename... Args> 
struct overload
   380     template<
typename C, 
typename R>
   381     static constexpr 
auto of( R( C::*pmf )( Args... ) ) -> decltype( pmf )
   428 CORE_EXPORT QString 
qgsVsiPrefix( 
const QString &path );
   456 extern CORE_EXPORT 
const QString 
GEOWKT;
   460 extern CORE_EXPORT 
const QString 
GEOPROJ4;
   476 extern CORE_EXPORT 
const QString 
GEO_NONE;
   493 const int PREVIEW_JOB_DELAY_MS = 250;
   496 const int MAXIMUM_LAYER_PREVIEW_TIME_MS = 250;
   513 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)   515 #define Q_NOWARN_DEPRECATED_PUSH \   516   _Pragma("GCC diagnostic push") \   517   _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"");   518 #define Q_NOWARN_DEPRECATED_POP \   519   _Pragma("GCC diagnostic pop");   520 #define Q_NOWARN_UNREACHABLE_PUSH   521 #define Q_NOWARN_UNREACHABLE_POP   523 #elif defined(_MSC_VER)   525 #define Q_NOWARN_DEPRECATED_PUSH \   526   __pragma(warning(push)) \   527   __pragma(warning(disable:4996))   528 #define Q_NOWARN_DEPRECATED_POP \   529   __pragma(warning(pop))   530 #define Q_NOWARN_UNREACHABLE_PUSH \   531   __pragma(warning(push)) \   532   __pragma(warning(disable:4702))   533 #define Q_NOWARN_UNREACHABLE_POP \   534   __pragma(warning(pop))   538 #define Q_NOWARN_DEPRECATED_PUSH   539 #define Q_NOWARN_DEPRECATED_POP   540 #define Q_NOWARN_UNREACHABLE_PUSH   541 #define Q_NOWARN_UNREACHABLE_POP   548 #  define QGISEXTERN extern "C" __declspec( dllexport )   551 #    pragma warning(disable:4190)   554 #  if defined(__GNUC__) || defined(__clang__)   555 #    define QGISEXTERN extern "C" __attribute__ ((visibility ("default")))   557 #    define QGISEXTERN extern "C"   563 #if __cplusplus >= 201500   564 #define FALLTHROUGH [[fallthrough]];   565 #elif defined(__clang__)   566 #define FALLTHROUGH //[[clang::fallthrough]]   567 #elif defined(__GNUC__) && __GNUC__ >= 7   568 #define FALLTHROUGH [[gnu::fallthrough]];   574 #if __cplusplus >= 201703L   575 #define NODISCARD [[nodiscard]]   576 #elif defined(__clang__)   577 #define NODISCARD [[nodiscard]]   578 #elif defined(_MSC_VER)   579 #define NODISCARD // no support   580 #elif defined(__has_cpp_attribute)   581 #if __has_cpp_attribute(nodiscard)   582 #define NODISCARD [[nodiscard]]   583 #elif __has_cpp_attribute(gnu::warn_unused_result)   584 #define NODISCARD [[gnu::warn_unused_result]]   586 #define NODISCARD Q_REQUIRED_RESULT   589 #define NODISCARD Q_REQUIRED_RESULT   592 #if __cplusplus >= 201703L   593 #define MAYBE_UNUSED [[maybe_unused]]   594 #elif defined(__clang__)   595 #define MAYBE_UNUSED [[maybe_unused]]   596 #elif defined(_MSC_VER)   597 #define MAYBE_UNUSED // no support   598 #elif defined(__has_cpp_attribute)   599 #if __has_cpp_attribute(gnu::unused)   600 #define MAYBE_UNUSED [[gnu::unused]] CORE_EXPORT QString qgsVsiPrefix(const QString &path)
 
static const QString QGIS_VERSION
Version string. 
 
static const char * QGIS_DEV_VERSION
The development version. 
 
static const double UI_SCALE_FACTOR
UI scaling factor. 
 
bool qgsFloatNear(float a, float b, float epsilon=4 *FLT_EPSILON)
Compare two floats (but allow some difference) 
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference) 
 
DataType
Raster data types. 
 
UnitType
Type of unit of tolerance value from settings. 
 
static const QColor DEFAULT_HIGHLIGHT_COLOR
Default highlight color. 
 
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 alloc...
 
MessageLevel
Level for messages This will be used both for message log and message bar in application. 
 
static const int QGIS_VERSION_INT
Version number used for comparing versions using the "Check QGIS Version" function. 
 
QMap< QString, QString > QgsStringMap
 
double qgsRound(double number, double places)
Returns a double number, rounded (as close as possible) to the specified number of places...
 
The Qgis class provides global constants for use throughout the application. 
 
CORE_EXPORT bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second. 
 
static const double DEFAULT_Z_COORDINATE
Default Z coordinate value for 2.5d geometry This value have to be assigned to the Z coordinate for t...
 
QgsSignalBlocker(Object *object)
Constructor for QgsSignalBlocker. 
 
static const double DEFAULT_SNAP_TOLERANCE
Default snapping distance tolerance. 
 
CORE_EXPORT const QString GEO_NONE
Constant that holds the string representation for "No ellips/No CRS". 
 
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments. 
 
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double. 
 
const long GEOCRS_ID
Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id. 
 
static const double DEFAULT_SEARCH_RADIUS_MM
Identify search radius in mm. 
 
CORE_EXPORT double qgsPermissiveToDouble(QString string, bool &ok)
Converts a string to a double in a permissive way, e.g., allowing for incorrect numbers of digits bet...
 
CORE_EXPORT const QString GEOPROJ4
PROJ4 string that represents a geographic coord sys. 
 
RAII signal blocking class. 
 
static const QgsTolerance::UnitType DEFAULT_SNAP_UNITS
Default snapping distance units. 
 
void CORE_EXPORT qgsFree(void *ptr)
Frees the memory space pointed to by ptr. 
 
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
 
const double DEFAULT_POINT_SIZE
Magic number that determines the default point size for point symbols. 
 
static const float DEFAULT_MAPTOPIXEL_THRESHOLD
Default threshold between map coordinates and device coordinates for map2pixel simplification. 
 
const int USER_CRS_START_ID
Magick number that determines whether a projection crsid is a system (srs.db) or user (~/...
 
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object. 
 
const long GEOSRID
Magic number for a geographic coord sys in POSTGIS SRID. 
 
static const QString QGIS_RELEASE_NAME
Release name. 
 
bool qgsDoubleNearSig(double a, double b, int significantDigits=10)
Compare two doubles using specified number of significant digits. 
 
const double DEFAULT_LINE_WIDTH
 
CORE_EXPORT const QString PROJECT_SCALES
 
CORE_EXPORT uint qHash(const QVariant &variant)
Hash for QVariant. 
 
static const double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM
Default highlight line/stroke minimum width in mm. 
 
static const double DEFAULT_HIGHLIGHT_BUFFER_MM
Default highlight buffer in mm. 
 
CORE_EXPORT int qgsPermissiveToInt(QString string, bool &ok)
Converts a string to an integer in a permissive way, e.g., allowing for incorrect numbers of digits b...
 
CORE_EXPORT bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second. 
 
void CORE_EXPORT * qgsMalloc(size_t size)
Allocates size bytes and returns a pointer to the allocated memory. 
 
Object * operator->()
Returns pointer to blocked QObject. 
 
const long GEO_EPSG_CRS_ID
Magic number for a geographic coord sys in EpsgCrsId ID format. 
 
static const double SCALE_PRECISION
Fudge factor used to compare two scales. 
 
CORE_EXPORT const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority. 
 
CORE_EXPORT const QString GEOWKT
Wkt string that represents a geographic coord sys.