QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgis.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgis.h - QGIS namespace
3  -------------------
4  begin : Sat Jun 30 2002
5  copyright : (C) 2002 by Gary E.Sherman
6  email : sherman at mrcc.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGIS_H
19 #define QGIS_H
20 
21 #include <QMetaEnum>
22 #include <cfloat>
23 #include <memory>
24 #include <cmath>
25 
26 #include "qgstolerance.h"
27 #include "qgis_core.h"
28 #include "qgis_sip.h"
29 
30 #ifdef SIP_RUN
31 % ModuleHeaderCode
32 #include <qgis.h>
33 % End
34 
35 % ModuleCode
36 int QgisEvent = QEvent::User + 1;
37 % End
38 #endif
39 
46  {
50  MeshLayer,
54 };
55 
56 
61 class CORE_EXPORT Qgis
62 {
63  Q_GADGET
64  public:
65 
71  static QString version();
72 
78  static int versionInt();
79 
85  static QString releaseName();
86 
88  static const char *QGIS_DEV_VERSION;
89 
95  static QString devVersion();
96 
97  // Enumerations
98  //
99 
105  {
106  Info = 0,
107  Warning = 1,
108  Critical = 2,
109  Success = 3,
110  NoLevel = 4,
111  };
112  Q_ENUM( MessageLevel )
113 
114 
119  {
120  UnknownDataType = 0,
121  Byte = 1,
122  UInt16 = 2,
123  Int16 = 3,
124  UInt32 = 4,
125  Int32 = 5,
126  Float32 = 6,
127  Float64 = 7,
128  CInt16 = 8,
129  CInt32 = 9,
130  CFloat32 = 10,
131  CFloat64 = 11,
132  ARGB32 = 12,
133  ARGB32_Premultiplied = 13
134  };
135  Q_ENUM( DataType )
136 
137 
142  {
143  Never = 0,
144  Ask = 1,
145  SessionOnly = 2,
146  Always = 3,
147  NotForThisSession,
148  };
149  Q_ENUM( PythonMacroMode )
150 
151 
157  {
158  Uncounted = -2,
159  UnknownCount = -1,
160  };
161  Q_ENUM( FeatureCountState )
162 
163 
168  {
169  Marker,
170  Line,
171  Fill,
172  Hybrid
173  };
174  Q_ENUM( SymbolType )
175 
176 
182  {
183  ScaleArea,
184  ScaleDiameter
185  };
186  Q_ENUM( ScaleMethod )
187 
188 
194  {
195  DynamicRotation = 2,
196  };
197  Q_ENUM( SymbolRenderHint )
198  Q_DECLARE_FLAGS( SymbolRenderHints, SymbolRenderHint )
199 
200 
205  enum class SymbolFlag : int
206  {
207  RendererShouldUseSymbolLevels = 1 << 0,
208  };
209  Q_ENUM( SymbolFlag )
210  Q_DECLARE_FLAGS( SymbolFlags, SymbolFlag )
211 
212 
218  {
219  FlagIncludeCrosshairsForMarkerSymbols = 1 << 0,
220  };
221  Q_ENUM( SymbolPreviewFlag )
222  Q_DECLARE_FLAGS( SymbolPreviewFlags, SymbolPreviewFlag )
223 
224 
230  {
231  Collection,
232  Directory,
233  Layer,
234  Error,
235  Favorites,
236  Project,
237  Custom,
238  Fields,
239  Field,
240  };
241  Q_ENUM( BrowserItemType )
242 
243 
249  {
250  NotPopulated,
251  Populating,
252  Populated,
253  };
254  Q_ENUM( BrowserItemState )
255 
256 
262  {
263  NoCapabilities = 0,
264  SetCrs = 1 << 0,
265  Fertile = 1 << 1,
266  Fast = 1 << 2,
267  Collapse = 1 << 3,
268  Rename = 1 << 4,
269  Delete = 1 << 5,
270  };
271  Q_ENUM( BrowserItemCapability )
272  Q_DECLARE_FLAGS( BrowserItemCapabilities, BrowserItemCapability )
273 
274 
280  {
281  NoType,
282  Vector,
283  Raster,
284  Point,
285  Line,
286  Polygon,
287  TableLayer,
288  Database,
289  Table,
290  Plugin,
291  Mesh,
292  VectorTile,
293  PointCloud
294  };
295  Q_ENUM( BrowserLayerType )
296 
297 
302  enum class BrowserDirectoryMonitoring : int
303  {
304  Default,
305  NeverMonitor,
306  AlwaysMonitor,
307  };
308  Q_ENUM( BrowserDirectoryMonitoring )
309 
310 
316  {
317  Success SIP_MONKEYPATCH_COMPAT_NAME( NoError ) = 0,
318  ErrorCreatingDataSource SIP_MONKEYPATCH_COMPAT_NAME( ErrCreateDataSource ),
319  ErrorCreatingLayer SIP_MONKEYPATCH_COMPAT_NAME( ErrCreateLayer ),
320  ErrorAttributeTypeUnsupported SIP_MONKEYPATCH_COMPAT_NAME( ErrAttributeTypeUnsupported ),
321  ErrorAttributeCreationFailed SIP_MONKEYPATCH_COMPAT_NAME( ErrAttributeCreationFailed ),
322  ErrorProjectingFeatures SIP_MONKEYPATCH_COMPAT_NAME( ErrProjection ),
323  ErrorFeatureWriteFailed SIP_MONKEYPATCH_COMPAT_NAME( ErrFeatureWriteFailed ),
324  ErrorInvalidLayer SIP_MONKEYPATCH_COMPAT_NAME( ErrInvalidLayer ),
325  ErrorInvalidProvider SIP_MONKEYPATCH_COMPAT_NAME( ErrInvalidProvider ),
326  ErrorProviderUnsupportedFeature SIP_MONKEYPATCH_COMPAT_NAME( ErrProviderUnsupportedFeature ),
327  ErrorConnectionFailed SIP_MONKEYPATCH_COMPAT_NAME( ErrConnectionFailed ),
328  UserCanceled SIP_MONKEYPATCH_COMPAT_NAME( ErrUserCanceled ),
329  };
330  Q_ENUM( VectorExportResult )
331 
332 
336  enum class DriveType : int
337  {
338  Unknown,
339  Invalid,
340  Removable,
341  Fixed,
342  Remote,
343  CdRom,
344  RamDisk,
345  };
346  Q_ENUM( DriveType )
347 
348 
353  enum class UnplacedLabelVisibility : int
354  {
355  FollowEngineSetting,
356  NeverShow,
357  };
358  Q_ENUM( UnplacedLabelVisibility )
359 
360 
364  static const double DEFAULT_SEARCH_RADIUS_MM;
365 
367  static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
368 
375  static const QColor DEFAULT_HIGHLIGHT_COLOR;
376 
381  static const double DEFAULT_HIGHLIGHT_BUFFER_MM;
382 
387  static const double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM;
388 
395  static const double SCALE_PRECISION;
396 
402  static const double DEFAULT_Z_COORDINATE;
403 
409  static const double DEFAULT_M_COORDINATE;
410 
416  static const double UI_SCALE_FACTOR;
417 
422  static const double DEFAULT_SNAP_TOLERANCE;
423 
428  static const QgsTolerance::UnitType DEFAULT_SNAP_UNITS;
429 
435  static QString defaultProjectScales();
436 
442  static int geosVersionInt();
443 
449  static int geosVersionMajor();
450 
456  static int geosVersionMinor();
457 
463  static int geosVersionPatch();
464 
470  static QString geosVersion();
471 };
472 
473 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolRenderHints )
474 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolFlags )
475 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolPreviewFlags )
476 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::BrowserItemCapabilities )
477 
478 
479 // hack to workaround warnings when casting void pointers
480 // retrieved from QLibrary::resolve to function pointers.
481 // It's assumed that this works on all systems supporting
482 // QLibrary
483 #define cast_to_fptr(f) f
484 
485 
494 // based on Boojum's code from http://stackoverflow.com/questions/3556687/prevent-firing-signals-in-qt
495 template<class Object> class QgsSignalBlocker SIP_SKIP SIP_SKIP // clazy:exclude=rule-of-three
496 {
497  public:
498 
503  explicit QgsSignalBlocker( Object * object )
504  : mObject( object )
505  , mPreviousState( object->blockSignals( true ) )
506  {}
507 
509  {
510  mObject->blockSignals( mPreviousState );
511  }
512 
514  Object *operator->() { return mObject; }
515 
516  private:
517 
518  Object *mObject = nullptr;
519  bool mPreviousState;
520 
521 };
522 
536 // based on Boojum's code from http://stackoverflow.com/questions/3556687/prevent-firing-signals-in-qt
537 template<class Object> inline QgsSignalBlocker<Object> whileBlocking( Object *object ) SIP_SKIP SIP_SKIP
538 {
539  return QgsSignalBlocker<Object>( object );
540 }
541 
543 CORE_EXPORT uint qHash( const QVariant &variant );
544 
550 inline QString qgsDoubleToString( double a, int precision = 17 )
551 {
552  QString str = QString::number( a, 'f', precision );
553  if ( precision )
554  {
555  if ( str.contains( QLatin1Char( '.' ) ) )
556  {
557  // remove ending 0s
558  int idx = str.length() - 1;
559  while ( str.at( idx ) == '0' && idx > 1 )
560  {
561  idx--;
562  }
563  if ( idx < str.length() - 1 )
564  str.truncate( str.at( idx ) == '.' ? idx : idx + 1 );
565  }
566  }
567  // avoid printing -0
568  // see https://bugreports.qt.io/browse/QTBUG-71439
569  if ( str == QLatin1String( "-0" ) )
570  {
571  return QLatin1String( "0" );
572  }
573  return str;
574 }
575 
582 inline bool qgsNanCompatibleEquals( double a, double b )
583 {
584  const bool aIsNan = std::isnan( a );
585  const bool bIsNan = std::isnan( b );
586  if ( aIsNan || bIsNan )
587  return aIsNan && bIsNan;
588 
589  return a == b;
590 }
591 
598 inline bool qgsDoubleNear( double a, double b, double epsilon = 4 * std::numeric_limits<double>::epsilon() )
599 {
600  const bool aIsNan = std::isnan( a );
601  const bool bIsNan = std::isnan( b );
602  if ( aIsNan || bIsNan )
603  return aIsNan && bIsNan;
604 
605  const double diff = a - b;
606  return diff > -epsilon && diff <= epsilon;
607 }
608 
615 inline bool qgsFloatNear( float a, float b, float epsilon = 4 * FLT_EPSILON )
616 {
617  const bool aIsNan = std::isnan( a );
618  const bool bIsNan = std::isnan( b );
619  if ( aIsNan || bIsNan )
620  return aIsNan && bIsNan;
621 
622  const float diff = a - b;
623  return diff > -epsilon && diff <= epsilon;
624 }
625 
627 inline bool qgsDoubleNearSig( double a, double b, int significantDigits = 10 )
628 {
629  const bool aIsNan = std::isnan( a );
630  const bool bIsNan = std::isnan( b );
631  if ( aIsNan || bIsNan )
632  return aIsNan && bIsNan;
633 
634  // The most simple would be to print numbers as %.xe and compare as strings
635  // but that is probably too costly
636  // Then the fastest would be to set some bits directly, but little/big endian
637  // has to be considered (maybe TODO)
638  // Is there a better way?
639  int aexp, bexp;
640  double ar = std::frexp( a, &aexp );
641  double br = std::frexp( b, &bexp );
642 
643  return aexp == bexp &&
644  std::round( ar * std::pow( 10.0, significantDigits ) ) == std::round( br * std::pow( 10.0, significantDigits ) );
645 }
646 
652 inline double qgsRound( double number, int places )
653 {
654  double m = ( number < 0.0 ) ? -1.0 : 1.0;
655  double scaleFactor = std::pow( 10.0, places );
656  return ( std::round( number * m * scaleFactor ) / scaleFactor ) * m;
657 }
658 
659 
660 #ifndef SIP_RUN
661 
663 
673 namespace qgis
674 {
675 
688  template<typename To, typename From> inline To down_cast( From *f )
689  {
690  static_assert(
691  ( std::is_base_of<From,
692  typename std::remove_pointer<To>::type>::value ),
693  "target type not derived from source type" );
694  Q_ASSERT( f == nullptr || dynamic_cast<To>( f ) != nullptr );
695  return static_cast<To>( f );
696  }
697 
698  template<class T>
699  QSet<T> listToSet( const QList<T> &list )
700  {
701 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
702  return list.toSet();
703 #else
704  return QSet<T>( list.begin(), list.end() );
705 #endif
706  }
707 
708  template<class T>
709  QList<T> setToList( const QSet<T> &set )
710  {
711 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
712  return set.toList();
713 #else
714  return QList<T>( set.begin(), set.end() );
715 #endif
716  }
717 }
719 #endif
720 
726 template<class T> const QMap<T, QString> qgsEnumMap() SIP_SKIP
727 {
728  QMetaEnum metaEnum = QMetaEnum::fromType<T>();
729  Q_ASSERT( metaEnum.isValid() );
730  QMap<T, QString> enumMap;
731  for ( int idx = 0; idx < metaEnum.keyCount(); ++idx )
732  {
733  const char *enumKey = metaEnum.key( idx );
734  enumMap.insert( static_cast<T>( metaEnum.keyToValue( enumKey ) ), QString( enumKey ) );
735  }
736  return enumMap;
737 }
738 
743 template<class T> QString qgsEnumValueToKey( const T &value ) SIP_SKIP
744 {
745  QMetaEnum metaEnum = QMetaEnum::fromType<T>();
746  Q_ASSERT( metaEnum.isValid() );
747  return QString::fromUtf8( metaEnum.valueToKey( static_cast<int>( value ) ) );
748 }
749 
756 template<class T> T qgsEnumKeyToValue( const QString &key, const T &defaultValue, bool tryValueAsKey = true ) SIP_SKIP
757 {
758  QMetaEnum metaEnum = QMetaEnum::fromType<T>();
759  Q_ASSERT( metaEnum.isValid() );
760  bool ok = false;
761  T v = static_cast<T>( metaEnum.keyToValue( key.toUtf8().data(), &ok ) );
762  if ( ok )
763  {
764  return v;
765  }
766  else
767  {
768  // if conversion has failed, try with conversion from int value
769  if ( tryValueAsKey )
770  {
771  bool canConvert = false;
772  int intValue = key.toInt( &canConvert );
773  if ( canConvert && metaEnum.valueToKey( intValue ) )
774  {
775  return static_cast<T>( intValue );
776  }
777  }
778  }
779  return defaultValue;
780 }
781 
786 template<class T> QString qgsFlagValueToKeys( const T &value ) SIP_SKIP
787 {
788  QMetaEnum metaEnum = QMetaEnum::fromType<T>();
789  Q_ASSERT( metaEnum.isValid() );
790  return QString::fromUtf8( metaEnum.valueToKeys( static_cast<int>( value ) ) );
791 }
792 
798 template<class T> T qgsFlagKeysToValue( const QString &keys, const T &defaultValue ) SIP_SKIP
799 {
800  QMetaEnum metaEnum = QMetaEnum::fromType<T>();
801  Q_ASSERT( metaEnum.isValid() );
802  bool ok = false;
803  T v = static_cast<T>( metaEnum.keysToValue( keys.toUtf8().constData(), &ok ) );
804  if ( ok )
805  return v;
806  else
807  return defaultValue;
808 }
809 
810 
820 CORE_EXPORT double qgsPermissiveToDouble( QString string, bool &ok );
821 
831 CORE_EXPORT int qgsPermissiveToInt( QString string, bool &ok );
832 
842 CORE_EXPORT qlonglong qgsPermissiveToLongLong( QString string, bool &ok );
843 
853 CORE_EXPORT bool qgsVariantLessThan( const QVariant &lhs, const QVariant &rhs );
854 
863 CORE_EXPORT bool qgsVariantEqual( const QVariant &lhs, const QVariant &rhs );
864 
871 CORE_EXPORT bool qgsVariantGreaterThan( const QVariant &lhs, const QVariant &rhs );
872 
873 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
874 
881 inline bool operator> ( const QVariant &v1, const QVariant &v2 )
882 {
883  return qgsVariantGreaterThan( v1, v2 );
884 }
885 
895 inline bool operator< ( const QVariant &v1, const QVariant &v2 )
896 {
897  return qgsVariantLessThan( v1, v2 );
898 }
899 #endif
900 
901 
902 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
903 
907 template<> CORE_EXPORT bool qMapLessThanKey<QVariantList>( const QVariantList &key1, const QVariantList &key2 ) SIP_SKIP;
908 #endif
909 
910 CORE_EXPORT QString qgsVsiPrefix( const QString &path );
911 
917 void CORE_EXPORT *qgsMalloc( size_t size ) SIP_SKIP;
918 
926 void CORE_EXPORT *qgsCalloc( size_t nmemb, size_t size ) SIP_SKIP;
927 
932 void CORE_EXPORT qgsFree( void *ptr ) SIP_SKIP;
933 
934 #ifndef SIP_RUN
935 
936 #ifdef _MSC_VER
937 #define CONSTLATIN1STRING inline const QLatin1String
938 #else
939 #define CONSTLATIN1STRING constexpr QLatin1String
940 #endif
941 
943 class ScopedIntIncrementor
944 {
945  public:
946 
947  ScopedIntIncrementor( int *variable )
948  : mVariable( variable )
949  {
950  ( *mVariable )++;
951  }
952 
953  ScopedIntIncrementor( const ScopedIntIncrementor &other ) = delete;
954  ScopedIntIncrementor &operator=( const ScopedIntIncrementor &other ) = delete;
955 
956  void release()
957  {
958  if ( mVariable )
959  ( *mVariable )--;
960 
961  mVariable = nullptr;
962  }
963 
964  ~ScopedIntIncrementor()
965  {
966  release();
967  }
968 
969  private:
970  int *mVariable = nullptr;
971 };
973 
979 {
980  return QLatin1String(
981  R"""(GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]] )"""
982  );
983 }
984 
987 {
988  return QLatin1String( "+proj=longlat +datum=WGS84 +no_defs" );
989 }
990 
993 {
994  return QLatin1String( "EPSG:4326" );
995 }
996 
999 {
1000  return QLatin1String( "NONE" );
1001 }
1002 
1004 
1006 const int PREVIEW_JOB_DELAY_MS = 250;
1007 
1009 const int MAXIMUM_LAYER_PREVIEW_TIME_MS = 250;
1010 
1012 
1013 #endif
1014 
1016 const long GEOSRID = 4326;
1017 
1019 const long GEOCRS_ID = 3452;
1020 
1022 const long GEO_EPSG_CRS_ID = 4326;
1023 
1028 const int USER_CRS_START_ID = 100000;
1029 
1030 //
1031 // Constants for point symbols
1032 //
1033 
1035 const double DEFAULT_POINT_SIZE = 2.0;
1036 const double DEFAULT_LINE_WIDTH = 0.26;
1037 
1039 const double DEFAULT_SEGMENT_EPSILON = 1e-8;
1040 
1041 typedef QMap<QString, QString> QgsStringMap SIP_SKIP;
1042 
1051 typedef unsigned long long qgssize;
1052 
1053 #ifndef SIP_RUN
1054 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
1055 
1056 #define Q_NOWARN_DEPRECATED_PUSH \
1057  _Pragma("GCC diagnostic push") \
1058  _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"");
1059 #define Q_NOWARN_DEPRECATED_POP \
1060  _Pragma("GCC diagnostic pop");
1061 #define Q_NOWARN_UNREACHABLE_PUSH
1062 #define Q_NOWARN_UNREACHABLE_POP
1063 
1064 #elif defined(_MSC_VER)
1065 
1066 #define Q_NOWARN_DEPRECATED_PUSH \
1067  __pragma(warning(push)) \
1068  __pragma(warning(disable:4996))
1069 #define Q_NOWARN_DEPRECATED_POP \
1070  __pragma(warning(pop))
1071 #define Q_NOWARN_UNREACHABLE_PUSH \
1072  __pragma(warning(push)) \
1073  __pragma(warning(disable:4702))
1074 #define Q_NOWARN_UNREACHABLE_POP \
1075  __pragma(warning(pop))
1076 
1077 #else
1078 
1079 #define Q_NOWARN_DEPRECATED_PUSH
1080 #define Q_NOWARN_DEPRECATED_POP
1081 #define Q_NOWARN_UNREACHABLE_PUSH
1082 #define Q_NOWARN_UNREACHABLE_POP
1083 
1084 #endif
1085 #endif
1086 
1087 #ifndef QGISEXTERN
1088 #ifdef Q_OS_WIN
1089 # define QGISEXTERN extern "C" __declspec( dllexport )
1090 # ifdef _MSC_VER
1091 // do not warn about C bindings returning QString
1092 # pragma warning(disable:4190)
1093 # endif
1094 #else
1095 # if defined(__GNUC__) || defined(__clang__)
1096 # define QGISEXTERN extern "C" __attribute__ ((visibility ("default")))
1097 # else
1098 # define QGISEXTERN extern "C"
1099 # endif
1100 #endif
1101 #endif
1102 #endif
1103 
1104 #if __cplusplus >= 201500
1105 #define FALLTHROUGH [[fallthrough]];
1106 #elif defined(__clang__)
1107 #define FALLTHROUGH [[clang::fallthrough]];
1108 #elif defined(__GNUC__) && __GNUC__ >= 7
1109 #define FALLTHROUGH [[gnu::fallthrough]];
1110 #else
1111 #define FALLTHROUGH
1112 #endif
1113 
1114 // see https://infektor.net/posts/2017-01-19-using-cpp17-attributes-today.html#using-the-nodiscard-attribute
1115 #if __cplusplus >= 201703L
1116 #define NODISCARD [[nodiscard]]
1117 #elif defined(__clang__)
1118 #define NODISCARD [[nodiscard]]
1119 #elif defined(_MSC_VER)
1120 #define NODISCARD // no support
1121 #elif defined(__has_cpp_attribute)
1122 #if __has_cpp_attribute(nodiscard)
1123 #define NODISCARD [[nodiscard]]
1124 #elif __has_cpp_attribute(gnu::warn_unused_result)
1125 #define NODISCARD [[gnu::warn_unused_result]]
1126 #else
1127 #define NODISCARD Q_REQUIRED_RESULT
1128 #endif
1129 #else
1130 #define NODISCARD Q_REQUIRED_RESULT
1131 #endif
1132 
1133 #if __cplusplus >= 201703L
1134 #define MAYBE_UNUSED [[maybe_unused]]
1135 #elif defined(__clang__)
1136 #define MAYBE_UNUSED [[maybe_unused]]
1137 #elif defined(_MSC_VER)
1138 #define MAYBE_UNUSED // no support
1139 #elif defined(__has_cpp_attribute)
1140 #if __has_cpp_attribute(gnu::unused)
1141 #define MAYBE_UNUSED [[gnu::unused]]
1142 #else
1143 #define MAYBE_UNUSED
1144 #endif
1145 #else
1146 #define MAYBE_UNUSED
1147 #endif
1148 
1149 #ifndef FINAL
1150 #define FINAL final
1151 #endif
1152 
1153 #ifndef SIP_RUN
1154 #if defined(__GNUC__) && !defined(__clang__)
1155 // Workaround a GCC bug where a -Wreturn-type warning is emitted in constructs
1156 // like:
1157 // switch( mVariableThatCanOnlyBeXorY )
1158 // {
1159 // case X:
1160 // return "foo";
1161 // case Y:
1162 // return "foo";
1163 // }
1164 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87951
1165 #define DEFAULT_BUILTIN_UNREACHABLE \
1166  default: \
1167  __builtin_unreachable();
1168 #else
1169 #define DEFAULT_BUILTIN_UNREACHABLE
1170 #endif
1171 #endif // SIP_RUN
1172 
1173 #ifdef SIP_RUN
1174 
1179 QString CORE_EXPORT geoWkt();
1180 
1182 QString CORE_EXPORT geoProj4();
1183 
1185 QString CORE_EXPORT geoEpsgCrsAuthId();
1186 
1188 QString CORE_EXPORT geoNone();
1189 
1190 #endif
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:62
static const char * QGIS_DEV_VERSION
The development version.
Definition: qgis.h:88
DriveType
Drive types.
Definition: qgis.h:337
BrowserItemState
Browser item states.
Definition: qgis.h:249
SymbolRenderHint
Flags controlling behavior of symbols during rendering.
Definition: qgis.h:194
BrowserItemCapability
Browser item capabilities.
Definition: qgis.h:262
BrowserDirectoryMonitoring
Browser directory item monitoring switches.
Definition: qgis.h:303
VectorExportResult
Vector layer export result codes.
Definition: qgis.h:316
ScaleMethod
Scale methods.
Definition: qgis.h:182
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:105
PythonMacroMode
Authorisation to run Python Macros.
Definition: qgis.h:142
UnplacedLabelVisibility
Unplaced label visibility.
Definition: qgis.h:354
BrowserItemType
Browser item types.
Definition: qgis.h:230
BrowserLayerType
Browser item layer types.
Definition: qgis.h:280
DataType
Raster data types.
Definition: qgis.h:119
SymbolPreviewFlag
Flags for controlling how symbol preview images are generated.
Definition: qgis.h:218
SymbolType
Symbol types.
Definition: qgis.h:168
SymbolFlag
Flags controlling behavior of symbols.
Definition: qgis.h:206
Base class for all items in the model.
Definition: qgsdataitem.h:46
Item that represents a layer that can be opened with one of the providers.
Definition: qgslayeritem.h:30
Base class for all map layer types.
Definition: qgsmaplayer.h:70
RAII signal blocking class.
Definition: qgis.h:496
~QgsSignalBlocker()
Definition: qgis.h:508
QgsSignalBlocker(Object *object)
Constructor for QgsSignalBlocker.
Definition: qgis.h:503
Object * operator->()
Returns pointer to blocked QObject.
Definition: qgis.h:514
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
This is the class is providing tolerance value in map unit values.
Definition: qgstolerance.h:33
This is the base class for vector data providers.
A convenience class for exporting vector layers to a destination data provider.
FeatureCountState
Enumeration of feature count states.
Definition: qgis.h:157
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgis.h:46
@ PointCloudLayer
Added in 3.18.
@ MeshLayer
Added in 3.2.
@ VectorTileLayer
Added in 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
int significantDigits(const Qgis::DataType rasterDataType)
Returns the maximum number of significant digits a for the given rasterDataType.
#define str(x)
Definition: qgis.cpp:37
CONSTLATIN1STRING geoNone()
Constant that holds the string representation for "No ellips/No CRS".
Definition: qgis.h:998
const double DEFAULT_LINE_WIDTH
Definition: qgis.h:1036
CORE_EXPORT uint qHash(const QVariant &variant)
Hash for QVariant.
Definition: qgis.cpp:225
bool operator>(const QVariant &v1, const QVariant &v2)
Compares two QVariant values and returns whether the first is greater than the second.
Definition: qgis.h:881
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...
Definition: qgis.cpp:107
CORE_EXPORT QString qgsVsiPrefix(const QString &path)
Definition: qgis.cpp:200
CORE_EXPORT bool qgsVariantEqual(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether they are equal, two NULL values are always treated a...
Definition: qgis.cpp:274
void CORE_EXPORT * qgsMalloc(size_t size)
Allocates size bytes and returns a pointer to the allocated memory.
Definition: qgis.cpp:92
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition: qgis.h:550
QString qgsEnumValueToKey(const T &value)
Returns the value for the given key of an enum.
Definition: qgis.h:743
const QMap< T, QString > qgsEnumMap()
Returns a map of all enum entries.
Definition: qgis.h:726
const long GEO_EPSG_CRS_ID
Magic number for a geographic coord sys in EpsgCrsId ID format.
Definition: qgis.h:1022
CORE_EXPORT bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
Definition: qgis.cpp:195
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...
Definition: qgis.h:1051
bool qgsFloatNear(float a, float b, float epsilon=4 *FLT_EPSILON)
Compare two floats (but allow some difference)
Definition: qgis.h:615
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...
Definition: qgis.cpp:71
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
Definition: qgis.h:652
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:598
CONSTLATIN1STRING geoProj4()
PROJ4 string that represents a geographic coord sys.
Definition: qgis.h:986
T qgsFlagKeysToValue(const QString &keys, const T &defaultValue)
Returns the value corresponding to the given keys of a flag.
Definition: qgis.h:798
bool qgsNanCompatibleEquals(double a, double b)
Compare two doubles, treating nan values as equal.
Definition: qgis.h:582
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
Definition: qgis.h:1039
QMap< QString, QString > QgsStringMap
Definition: qgis.h:1041
#define CONSTLATIN1STRING
Definition: qgis.h:939
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:537
CONSTLATIN1STRING geoWkt()
Wkt string that represents a geographic coord sys.
Definition: qgis.h:978
bool qgsDoubleNearSig(double a, double b, int significantDigits=10)
Compare two doubles using specified number of significant digits.
Definition: qgis.h:627
const int USER_CRS_START_ID
Magick number that determines whether a projection crsid is a system (srs.db) or user (~/....
Definition: qgis.h:1028
QString qgsFlagValueToKeys(const T &value)
Returns the value for the given keys of a flag.
Definition: qgis.h:786
void CORE_EXPORT qgsFree(void *ptr)
Frees the memory space pointed to by ptr.
Definition: qgis.cpp:122
CORE_EXPORT qlonglong qgsPermissiveToLongLong(QString string, bool &ok)
Converts a string to an qlonglong in a permissive way, e.g., allowing for incorrect numbers of digits...
Definition: qgis.cpp:85
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...
Definition: qgis.cpp:78
CORE_EXPORT bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
Definition: qgis.cpp:127
const long GEOSRID
Magic number for a geographic coord sys in POSTGIS SRID.
Definition: qgis.h:1016
bool operator<(const QVariant &v1, const QVariant &v2)
Compares two QVariant values and returns whether the first is less than the second.
Definition: qgis.h:895
CONSTLATIN1STRING geoEpsgCrsAuthId()
Geographic coord sys from EPSG authority.
Definition: qgis.h:992
const long GEOCRS_ID
Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id.
Definition: qgis.h:1019
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true)
Returns the value corresponding to the given key of an enum.
Definition: qgis.h:756
const double DEFAULT_POINT_SIZE
Magic number that determines the default point size for point symbols.
Definition: qgis.h:1035
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition: qgis_sip.h:257
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition: qgis_sip.h:258
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
int precision