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 
22 #include <QMetaEnum>
23 #include <cfloat>
24 #include <memory>
25 #include <cmath>
26 
27 #include "qgstolerance.h"
28 #include "qgis_core.h"
29 #include "qgis_sip.h"
30 
31 #ifdef SIP_RUN
32 % ModuleHeaderCode
33 #include <qgis.h>
34 % End
35 
36 % ModuleCode
37 int QgisEvent = QEvent::User + 1;
38 % End
39 #endif
40 
41 /**
42  * \ingroup core
43  * \brief Types of layers that can be added to a map
44  * \since QGIS 3.8
45  */
46 enum class QgsMapLayerType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsMapLayer, LayerType ) : int
47   {
48   VectorLayer,
49   RasterLayer,
50   PluginLayer,
51   MeshLayer,      //!< Added in 3.2
52   VectorTileLayer, //!< Added in 3.14
53   AnnotationLayer, //!< Contains freeform, georeferenced annotations. Added in QGIS 3.16
54   PointCloudLayer, //!< Added in 3.18
55 };
56 
57 
58 /**
59  * \ingroup core
60  * \brief The Qgis class provides global constants for use throughout the application.
61  */
62 class CORE_EXPORT Qgis
63 {
64     Q_GADGET
65   public:
66 
67     /**
68      * Version string.
69      *
70      * \since QGIS 3.12
71      */
72     static QString version();
73 
74     /**
75      * Version number used for comparing versions using the "Check QGIS Version" function
76      *
77      * \since QGIS 3.12
78      */
79     static int versionInt();
80 
81     /**
82      * Release name
83      *
84      * \since QGIS 3.12
85      */
86     static QString releaseName();
87 
88     //! The development version
89     static const char *QGIS_DEV_VERSION;
90 
91     /**
92      * The development version
93      *
94      * \since QGIS 3.12
95      */
96     static QString devVersion();
97 
98     // Enumerations
99     //
100 
101     /**
102      * \brief Level for messages
103      * This will be used both for message log and message bar in application.
104      */
105     enum MessageLevel
106     {
107       Info = 0, //!< Information message
108       Warning = 1, //!< Warning message
109       Critical = 2, //!< Critical/error message
110       Success = 3, //!< Used for reporting a successful operation
111       NoLevel = 4, //!< No level
112     };
Q_ENUM(MessageLevel)113     Q_ENUM( MessageLevel )
114 
115     /**
116      * Raster data types.
117      * This is modified and extended copy of GDALDataType.
118      */
119     enum class DataType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( Qgis, DataType ) : int
120       {
121       UnknownDataType = 0, //!< Unknown or unspecified type
122       Byte = 1, //!< Eight bit unsigned integer (quint8)
123       UInt16 = 2, //!< Sixteen bit unsigned integer (quint16)
124       Int16 = 3, //!< Sixteen bit signed integer (qint16)
125       UInt32 = 4, //!< Thirty two bit unsigned integer (quint32)
126       Int32 = 5, //!< Thirty two bit signed integer (qint32)
127       Float32 = 6, //!< Thirty two bit floating point (float)
128       Float64 = 7, //!< Sixty four bit floating point (double)
129       CInt16 = 8, //!< Complex Int16
130       CInt32 = 9, //!< Complex Int32
131       CFloat32 = 10, //!< Complex Float32
132       CFloat64 = 11, //!< Complex Float64
133       ARGB32 = 12, //!< Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32
134       ARGB32_Premultiplied = 13 //!< Color, alpha, red, green, blue, 4 bytes  the same as QImage::Format_ARGB32_Premultiplied
135     };
Q_ENUM(DataType)136     Q_ENUM( DataType )
137 
138     /**
139      * Authorisation to run Python Macros
140      * \since QGIS 3.10
141      */
142     enum class PythonMacroMode SIP_MONKEYPATCH_SCOPEENUM_UNNEST( Qgis, PythonMacroMode ) : int
143       {
144       Never = 0, //!< Macros are never run
145       Ask = 1, //!< User is prompt before running
146       SessionOnly = 2, //!< Only during this session
147       Always = 3, //!< Macros are always run
148       NotForThisSession, //!< Macros will not be run for this session
149     };
Q_ENUM(PythonMacroMode)150     Q_ENUM( PythonMacroMode )
151 
152     /**
153      * \ingroup core
154      * \brief Enumeration of feature count states
155      * \since QGIS 3.20
156      */
157     enum class FeatureCountState SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsVectorDataProvider, FeatureCountState ) : int
158       {
159       Uncounted = -2, //!< Feature count not yet computed
160       UnknownCount = -1, //!< Provider returned an unknown feature count
161     };
Q_ENUM(FeatureCountState)162     Q_ENUM( FeatureCountState )
163 
164     /**
165      * \brief Symbol types
166      * \since QGIS 3.20
167      */
168     enum class SymbolType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsSymbol, SymbolType ) : int
169       {
170       Marker, //!< Marker symbol
171       Line, //!< Line symbol
172       Fill, //!< Fill symbol
173       Hybrid //!< Hybrid symbol
174     };
Q_ENUM(SymbolType)175     Q_ENUM( SymbolType )
176 
177     /**
178      * \brief Scale methods
179      *
180      * \since QGIS 3.20
181      */
182     enum class ScaleMethod SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsSymbol, ScaleMethod ) : int
183       {
184       ScaleArea,     //!< Calculate scale by the area
185       ScaleDiameter  //!< Calculate scale by the diameter
186     };
Q_ENUM(ScaleMethod)187     Q_ENUM( ScaleMethod )
188 
189     /**
190      * \brief Flags controlling behavior of symbols during rendering
191      *
192      * \since QGIS 3.20
193      */
194     enum class SymbolRenderHint SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsSymbol, RenderHint ) : int
195       {
196       DynamicRotation = 2, //!< Rotation of symbol may be changed during rendering and symbol should not be cached
197     };
198     Q_ENUM( SymbolRenderHint )
199     //! Symbol render hints
200     Q_DECLARE_FLAGS( SymbolRenderHints, SymbolRenderHint ) SIP_MONKEYPATCH_FLAGS_UNNEST( QgsSymbol, RenderHints )
201 
202 
203     /**
204      * \brief Flags controlling behavior of symbols
205      *
206      * \since QGIS 3.20
207      */
208     enum class SymbolFlag : int
209     {
210       RendererShouldUseSymbolLevels = 1 << 0, //!< If present, indicates that a QgsFeatureRenderer using the symbol should use symbol levels for best results
211     };
212     Q_ENUM( SymbolFlag )
213     //! Symbol flags
Q_DECLARE_FLAGS(SymbolFlags,SymbolFlag)214     Q_DECLARE_FLAGS( SymbolFlags, SymbolFlag )
215 
216     /**
217      * Flags for controlling how symbol preview images are generated.
218      *
219      * \since QGIS 3.20
220      */
221     enum class SymbolPreviewFlag SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsSymbol, PreviewFlag ) : int
222       {
223       FlagIncludeCrosshairsForMarkerSymbols = 1 << 0, //!< Include a crosshairs reference image in the background of marker symbol previews
224     };
225     Q_ENUM( SymbolPreviewFlag )
226     //! Symbol preview flags
227     Q_DECLARE_FLAGS( SymbolPreviewFlags, SymbolPreviewFlag ) SIP_MONKEYPATCH_FLAGS_UNNEST( QgsSymbol, SymbolPreviewFlags )
228 
229     /**
230      * \brief Flags controlling behavior of symbol layers
231      *
232      * \since QGIS 3.22
233      */
234     enum class SymbolLayerFlag : int
235     {
236       DisableFeatureClipping = 1 << 0, //!< If present, indicates that features should never be clipped to the map extent during rendering
237     };
238     Q_ENUM( SymbolLayerFlag )
239     //! Symbol layer flags
Q_DECLARE_FLAGS(SymbolLayerFlags,SymbolLayerFlag)240     Q_DECLARE_FLAGS( SymbolLayerFlags, SymbolLayerFlag )
241 
242     /**
243      * Browser item types.
244      *
245      * \since QGIS 3.20
246      */
247     enum class BrowserItemType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsDataItem, Type ) : int
248       {
249       Collection, //!< A collection of items
250       Directory, //!< Represents a file directory
251       Layer, //!< Represents a map layer
252       Error, //!< Contains an error message
253       Favorites, //!< Represents a favorite item
254       Project, //!< Represents a QGIS project
255       Custom, //!< Custom item type
256       Fields, //!< Collection of fields
257       Field, //!< Vector layer field
258     };
Q_ENUM(BrowserItemType)259     Q_ENUM( BrowserItemType )
260 
261     /**
262      * Browser item states.
263      *
264      * \since QGIS 3.20
265      */
266     enum class BrowserItemState SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsDataItem, State ) : int
267       {
268       NotPopulated, //!< Children not yet created
269       Populating, //!< Creating children in separate thread (populating or refreshing)
270       Populated, //!< Children created
271     };
Q_ENUM(BrowserItemState)272     Q_ENUM( BrowserItemState )
273 
274     /**
275      * Browser item capabilities.
276      *
277      * \since QGIS 3.20
278      */
279     enum class BrowserItemCapability SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsDataItem, Capability ) : int
280       {
281       NoCapabilities = 0, //!< Item has no capabilities
282       SetCrs = 1 << 0, //!< Can set CRS on layer or group of layers. \deprecated since QGIS 3.6 -- no longer used by QGIS and will be removed in QGIS 4.0
283       Fertile = 1 << 1, //!< Can create children. Even items without this capability may have children, but cannot create them, it means that children are created by item ancestors.
284       Fast = 1 << 2, //!< CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms,wfs,wcs,postgres...) are considered fast because they are reading data only from QgsSettings
285       Collapse = 1 << 3, //!< The collapse/expand status for this items children should be ignored in order to avoid undesired network connections (wms etc.)
286       Rename = 1 << 4, //!< Item can be renamed
287       Delete = 1 << 5, //!< Item can be deleted
288       ItemRepresentsFile = 1 << 6, //!< Item's path() directly represents a file on disk (since QGIS 3.22)
289     };
290     Q_ENUM( BrowserItemCapability )
291     //! Browser item capabilities
Q_DECLARE_FLAGS(BrowserItemCapabilities,BrowserItemCapability)292     Q_DECLARE_FLAGS( BrowserItemCapabilities, BrowserItemCapability ) SIP_MONKEYPATCH_FLAGS_UNNEST( QgsDataItem, Capabilities )
293 
294     /**
295      * Browser item layer types
296      *
297      * \since QGIS 3.20
298      */
299     enum class BrowserLayerType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsLayerItem, LayerType ) : int
300       {
301       NoType, //!< No type
302       Vector, //!< Generic vector layer
303       Raster, //!< Raster layer
304       Point, //!< Vector point layer
305       Line, //!< Vector line layer
306       Polygon, //!< Vector polygon layer
307       TableLayer, //!< Vector non-spatial layer
308       Database, //!< Database layer
309       Table, //!< Database table
310       Plugin, //!< Plugin based layer
311       Mesh, //!< Mesh layer
312       VectorTile, //!< Vector tile layer
313       PointCloud //!< Point cloud layer
314     };
315     Q_ENUM( BrowserLayerType )
316 
317     /**
318      * Browser directory item monitoring switches.
319      *
320      * \since QGIS 3.20
321      */
322     enum class BrowserDirectoryMonitoring : int
323     {
324       Default, //!< Use default logic to determine whether directory should be monitored
325       NeverMonitor, //!< Never monitor the directory, regardless of the default logic
326       AlwaysMonitor, //!< Always monitor the directory, regardless of the default logic
327     };
328     Q_ENUM( BrowserDirectoryMonitoring )
329 
330     /**
331      * Different methods of HTTP requests
332      * \since 3.22
333      */
334     enum class HttpMethod : int
335     {
336       Get = 0, //!< GET method
337       Post = 1 //!< POST method
338     };
Q_ENUM(HttpMethod)339     Q_ENUM( HttpMethod )
340 
341     /**
342      * Vector layer export result codes.
343      *
344      * \since QGIS 3.20
345      */
346     enum class VectorExportResult SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsVectorLayerExporter, ExportError ) : int
347       {
348       Success SIP_MONKEYPATCH_COMPAT_NAME( NoError ) = 0, //!< No errors were encountered
349       ErrorCreatingDataSource SIP_MONKEYPATCH_COMPAT_NAME( ErrCreateDataSource ), //!< Could not create the destination data source
350       ErrorCreatingLayer SIP_MONKEYPATCH_COMPAT_NAME( ErrCreateLayer ), //!< Could not create destination layer
351       ErrorAttributeTypeUnsupported SIP_MONKEYPATCH_COMPAT_NAME( ErrAttributeTypeUnsupported ), //!< Source layer has an attribute type which could not be handled by destination
352       ErrorAttributeCreationFailed SIP_MONKEYPATCH_COMPAT_NAME( ErrAttributeCreationFailed ), //!< Destination provider was unable to create an attribute
353       ErrorProjectingFeatures SIP_MONKEYPATCH_COMPAT_NAME( ErrProjection ), //!< An error occurred while reprojecting features to destination CRS
354       ErrorFeatureWriteFailed SIP_MONKEYPATCH_COMPAT_NAME( ErrFeatureWriteFailed ), //!< An error occurred while writing a feature to the destination
355       ErrorInvalidLayer SIP_MONKEYPATCH_COMPAT_NAME( ErrInvalidLayer ), //!< Could not access newly created destination layer
356       ErrorInvalidProvider SIP_MONKEYPATCH_COMPAT_NAME( ErrInvalidProvider ), //!< Could not find a matching provider key
357       ErrorProviderUnsupportedFeature SIP_MONKEYPATCH_COMPAT_NAME( ErrProviderUnsupportedFeature ), //!< Provider does not support creation of empty layers
358       ErrorConnectionFailed SIP_MONKEYPATCH_COMPAT_NAME( ErrConnectionFailed ), //!< Could not connect to destination
359       UserCanceled SIP_MONKEYPATCH_COMPAT_NAME( ErrUserCanceled ), //!< User canceled the export
360     };
361     Q_ENUM( VectorExportResult )
362 
363     /**
364      * SqlLayerDefinitionCapability enum lists the arguments supported by the provider when creating SQL query layers.
365      * \since QGIS 3.22
366      */
367     enum class SqlLayerDefinitionCapability : int
368     {
369       SubsetStringFilter = 1 << 1,  //!< SQL layer definition supports subset string filter
370       GeometryColumn = 1 << 2,      //!< SQL layer definition supports geometry column
371       PrimaryKeys = 1 << 3,         //!< SQL layer definition supports primary keys
372       UnstableFeatureIds = 1 << 4   //!< SQL layer definition supports disabling select at id
373     };
374     Q_ENUM( SqlLayerDefinitionCapability )
375     //! SQL layer definition capabilities
376     Q_DECLARE_FLAGS( SqlLayerDefinitionCapabilities, SqlLayerDefinitionCapability )
377 
378     /**
379      * SqlKeywordCategory enum represents the categories of the SQL keywords used by the SQL query editor.
380      * \note The category has currently no usage, but it was planned for future uses.
381      * \since QGIS 3.22
382      */
383     enum class SqlKeywordCategory : int
384     {
385       Keyword,      //!< SQL keyword
386       Constant,     //!< SQL constant
387       Function,     //!< SQL generic function
388       Geospatial,   //!< SQL spatial function
389       Operator,     //!< SQL operator
390       Math,         //!< SQL math function
391       Aggregate,    //!< SQL aggregate function
392       String,       //!< SQL string function
393       Identifier    //!< SQL identifier
394     };
395     Q_ENUM( SqlKeywordCategory )
396 
397     /**
398      * Drive types
399      * \since QGIS 3.20
400      */
401     enum class DriveType : int
402     {
403       Unknown, //!< Unknown type
404       Invalid, //!< Invalid path
405       Removable, //!< Removable drive
406       Fixed, //!< Fixed drive
407       Remote, //!< Remote drive
408       CdRom, //!< CD-ROM
409       RamDisk, //!< RAM disk
410     };
Q_ENUM(DriveType)411     Q_ENUM( DriveType )
412 
413     /**
414      * Enum to determine when an operation would begin
415      * \since QGIS 3.22
416      */
417     enum class ActionStart SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsNetworkContentFetcherRegistry, FetchingMode ) : int
418       {
419       Deferred SIP_MONKEYPATCH_COMPAT_NAME( DownloadLater ), //!< Do not start immediately the action
420       Immediate SIP_MONKEYPATCH_COMPAT_NAME( DownloadImmediately ), //!< Action will start immediately
421     };
422     Q_ENUM( ActionStart )
423 
424     /**
425      * Unplaced label visibility.
426      *
427      * \since QGIS 3.20
428      */
429     enum class UnplacedLabelVisibility : int
430     {
431       FollowEngineSetting, //!< Respect the label engine setting
432       NeverShow, //!< Never show unplaced labels, regardless of the engine setting
433     };
434     Q_ENUM( UnplacedLabelVisibility )
435 
436     /**
437      * Flags which control how data providers will scan for sublayers in a dataset.
438      *
439      * \since QGIS 3.22
440      */
441     enum class SublayerQueryFlag : int
442     {
443       FastScan = 1 << 0, //!< Indicates that the provider must scan for sublayers using the fastest possible approach -- e.g. by first checking that a uri has an extension which is known to be readable by the provider
444       ResolveGeometryType = 1 << 1, //!< Attempt to resolve the geometry type for vector sublayers
445       CountFeatures = 1 << 2, //!< Count features in vector sublayers
446       IncludeSystemTables = 1 << 3, //!< Include system or internal tables (these are not included by default)
447     };
448     //! Sublayer query flags
449     Q_DECLARE_FLAGS( SublayerQueryFlags, SublayerQueryFlag )
450     Q_ENUM( SublayerQueryFlag )
451 
452     /**
453      * Flags which reflect the properties of sublayers in a dataset.
454      *
455      * \since QGIS 3.22
456      */
457     enum class SublayerFlag : int
458     {
459       SystemTable = 1 << 0, //!< Sublayer is a system or internal table, which should be hidden by default
460     };
461     //! Sublayer flags
Q_DECLARE_FLAGS(SublayerFlags,SublayerFlag)462     Q_DECLARE_FLAGS( SublayerFlags, SublayerFlag )
463     Q_ENUM( SublayerFlag )
464 
465     /**
466      * Raster pipe interface roles.
467      *
468      * \since QGIS 3.22
469      */
470     enum class RasterPipeInterfaceRole SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsRasterPipe, Role ) : int
471       {
472       Unknown SIP_MONKEYPATCH_COMPAT_NAME( UnknownRole ) = 0, //!< Unknown role
473       Provider SIP_MONKEYPATCH_COMPAT_NAME( ProviderRole ) = 1, //!< Data provider role
474       Renderer SIP_MONKEYPATCH_COMPAT_NAME( RendererRole ) = 2, //!< Raster renderer role
475       Brightness SIP_MONKEYPATCH_COMPAT_NAME( BrightnessRole ) = 3, //!< Brightness filter role
476       Resampler SIP_MONKEYPATCH_COMPAT_NAME( ResamplerRole ) = 4, //!< Resampler role
477       Projector SIP_MONKEYPATCH_COMPAT_NAME( ProjectorRole ) = 5, //!< Projector role
478       Nuller SIP_MONKEYPATCH_COMPAT_NAME( NullerRole ) = 6, //!< Raster nuller role
479       HueSaturation SIP_MONKEYPATCH_COMPAT_NAME( HueSaturationRole ) = 7, //!< Hue/saturation filter role (also applies grayscale/color inversion)
480     };
Q_ENUM(RasterPipeInterfaceRole)481     Q_ENUM( RasterPipeInterfaceRole )
482 
483     /**
484      * Stage at which raster resampling occurs.
485      * \since QGIS 3.22
486      */
487     enum class RasterResamplingStage SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsRasterPipe, ResamplingStage ) : int
488       {
489       //! Resampling occurs in ResamplingFilter
490       ResampleFilter,
491       //! Resampling occurs in Provider
492       Provider
493     };
494     Q_ENUM( RasterResamplingStage )
495 
496     /**
497      * Type of error that can occur during mesh frame editing.
498      *
499      * \since QGIS 3.22
500      */
501     enum class MeshEditingErrorType : int
502     {
503       NoError, //!< No type
504       InvalidFace, //!< An error occurs due to an invalid face (for example, vertex indexes are unordered)
505       TooManyVerticesInFace, //!< A face has more vertices than the maximum number supported per face
506       FlatFace, //!< A flat face is present
507       UniqueSharedVertex, //!< A least two faces share only one vertices
508       InvalidVertex, //!< An error occurs due to an invalid vertex (for example, vertex index is out of range the available vertex)
509       ManifoldFace, //!< ManifoldFace
510     };
511     Q_ENUM( MeshEditingErrorType )
512 
513     /**
514      * File path types.
515      *
516      * \since QGIS 3.22
517      */
518     enum class FilePathType : int
519     {
520       Absolute, //!< Absolute path
521       Relative, //!< Relative path
522     };
523     Q_ENUM( FilePathType )
524 
525     /**
526      * Specifies how to handle layer sources with multiple sublayers.
527      *
528      * \since QGIS 3.22
529      */
530     enum class SublayerPromptMode : int
531     {
532       AlwaysAsk, //!< Always ask users to select from available sublayers, if sublayers are present
533       AskExcludingRasterBands, //!< Ask users to select from available sublayers, unless only raster bands are present
534       NeverAskSkip, //!< Never ask users to select sublayers, instead don't load anything
535       NeverAskLoadAll, //!< Never ask users to select sublayers, instead automatically load all available sublayers
536     };
Q_ENUM(SublayerPromptMode)537     Q_ENUM( SublayerPromptMode )
538 
539     /**
540      * Specifies how a selection should be applied.
541      *
542      * \since QGIS 3.22
543      */
544     enum class SelectBehavior SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsVectorLayer, SelectBehavior ) : int
545       {
546       SetSelection, //!< Set selection, removing any existing selection
547       AddToSelection, //!< Add selection to current selection
548       IntersectSelection, //!< Modify current selection to include only select features which match
549       RemoveFromSelection, //!< Remove from current selection
550     };
Q_ENUM(SelectBehavior)551     Q_ENUM( SelectBehavior )
552 
553     /**
554      * Specifies the result of a vector layer edit operation
555      *
556      * \since QGIS 3.22
557      */
558     enum class VectorEditResult SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsVectorLayer, EditResult ) : int
559       {
560       Success = 0, //!< Edit operation was successful
561       EmptyGeometry = 1, //!< Edit operation resulted in an empty geometry
562       EditFailed = 2, //!< Edit operation failed
563       FetchFeatureFailed = 3, //!< Unable to fetch requested feature
564       InvalidLayer = 4, //!< Edit failed due to invalid layer
565     };
Q_ENUM(VectorEditResult)566     Q_ENUM( VectorEditResult )
567 
568     /**
569      * Editing vertex markers, used for showing vertices during a edit operation.
570      *
571      * \since QGIS 3.22
572      */
573     enum class VertexMarkerType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsSymbolLayerUtils, VertexMarkerType ) : int
574       {
575       SemiTransparentCircle, //!< Semi-transparent circle marker
576       Cross, //!< Cross marker
577       NoMarker, //!< No marker
578     };
579     Q_ENUM( VertexMarkerType )
580 
581     /**
582      * Status for fetched or stored content
583      * \since QGIS 3.22
584      */
585     enum class ContentStatus : int
586     {
587       NotStarted, //!< Content fetching/storing has not started yet
588       Running, //!< Content fetching/storing is in progress
589       Finished, //!< Content fetching/storing is finished and successful
590       Failed, //!< Content fetching/storing has failed
591       Canceled, //!< Content fetching/storing has been canceled
592     };
593     Q_ENUM( ContentStatus )
594 
595     /**
596      * Babel GPS format capabilities.
597      *
598      * \since QGIS 3.22
599      */
600     enum class BabelFormatCapability : int
601     {
602       Import = 1 << 0, //!< Format supports importing
603       Export = 1 << 1, //!< Format supports exporting
604       Waypoints = 1 << 2, //!< Format supports waypoints
605       Routes = 1 << 3, //!< Format supports routes
606       Tracks = 1 << 4, //!< Format supports tracks
607     };
608     //! Babel GPS format capabilities
609     Q_DECLARE_FLAGS( BabelFormatCapabilities, BabelFormatCapability )
610     Q_ENUM( BabelFormatCapability )
611 
612     /**
613      * Babel command flags, which control how commands and arguments
614      * are generated for executing GPSBabel processes.
615      *
616      * \since QGIS 3.22
617      */
618     enum class BabelCommandFlag : int
619     {
620       QuoteFilePaths = 1 << 0, //!< File paths should be enclosed in quotations and escaped
621     };
622     //! Babel command flags
623     Q_DECLARE_FLAGS( BabelCommandFlags, BabelCommandFlag )
624     Q_ENUM( BabelCommandFlag )
625 
626     /**
627      * GPS feature types.
628      *
629      * \since QGIS 3.22
630      */
631     enum class GpsFeatureType : int
632     {
633       Waypoint, //!< Waypoint
634       Route, //!< Route
635       Track, //!< Track
636     };
Q_ENUM(GpsFeatureType)637     Q_ENUM( GpsFeatureType )
638 
639     /**
640      * Success or failure of a geometry operation.
641      *
642      * This enum gives details about cause of failure.
643      *
644      * \since QGIS 3.22
645      */
646     enum class GeometryOperationResult SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsGeometry, OperationResult ) : int
647       {
648       Success = 0, //!< Operation succeeded
649       NothingHappened = 1000, //!< Nothing happened, without any error
650       InvalidBaseGeometry, //!< The base geometry on which the operation is done is invalid or empty
651       InvalidInputGeometryType, //!< The input geometry (ring, part, split line, etc.) has not the correct geometry type
652       SelectionIsEmpty, //!< No features were selected
653       SelectionIsGreaterThanOne, //!< More than one features were selected
654       GeometryEngineError, //!< Geometry engine misses a method implemented or an error occurred in the geometry engine
655       LayerNotEditable, //!< Cannot edit layer
656       /* Add part issues */
657       AddPartSelectedGeometryNotFound, //!< The selected geometry cannot be found
658       AddPartNotMultiGeometry, //!< The source geometry is not multi
659       /* Add ring issues*/
660       AddRingNotClosed, //!< The input ring is not closed
661       AddRingNotValid, //!< The input ring is not valid
662       AddRingCrossesExistingRings, //!< The input ring crosses existing rings (it is not disjoint)
663       AddRingNotInExistingFeature, //!< The input ring doesn't have any existing ring to fit into
664       /* Split features */
665       SplitCannotSplitPoint, //!< Cannot split points
666     };
Q_ENUM(GeometryOperationResult)667     Q_ENUM( GeometryOperationResult )
668 
669     /**
670      * Geometry validity check flags.
671      *
672      * \since QGIS 3.22
673      */
674     enum class GeometryValidityFlag SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsGeometry, ValidityFlag ) : int
675       {
676       AllowSelfTouchingHoles SIP_MONKEYPATCH_COMPAT_NAME( FlagAllowSelfTouchingHoles ) = 1 << 0, //!< Indicates that self-touching holes are permitted. OGC validity states that self-touching holes are NOT permitted, whilst other vendor validity checks (e.g. ESRI) permit self-touching holes.
677     };
678     //! Geometry validity flags
Q_DECLARE_FLAGS(GeometryValidityFlags,GeometryValidityFlag)679     Q_DECLARE_FLAGS( GeometryValidityFlags, GeometryValidityFlag ) SIP_MONKEYPATCH_FLAGS_UNNEST( QgsGeometry, ValidityFlags )
680     Q_ENUM( GeometryValidityFlag )
681 
682     /**
683      * Available engines for validating geometries.
684      * \since QGIS 3.22
685      */
686     enum class GeometryValidationEngine SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsGeometry, ValidationMethod ) : int
687       {
688       QgisInternal SIP_MONKEYPATCH_COMPAT_NAME( ValidatorQgisInternal ), //!< Use internal QgsGeometryValidator method
689       Geos SIP_MONKEYPATCH_COMPAT_NAME( ValidatorGeos ), //!< Use GEOS validation methods
690     };
Q_ENUM(GeometryValidationEngine)691     Q_ENUM( GeometryValidationEngine )
692 
693     /**
694      * Side of line to buffer.
695      *
696      * \since QGIS 3.22
697      */
698     enum class BufferSide SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsGeometry, BufferSide ) : int
699       {
700       Left SIP_MONKEYPATCH_COMPAT_NAME( SideLeft ) = 0, //!< Buffer to left of line
701       Right SIP_MONKEYPATCH_COMPAT_NAME( SideRight ), //!< Buffer to right of line
702     };
Q_ENUM(BufferSide)703     Q_ENUM( BufferSide )
704 
705     /**
706      * End cap styles for buffers.
707      *
708      * \since QGIS 3.22
709      */
710     enum class EndCapStyle SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsGeometry, EndCapStyle ) : int
711       {
712       Round SIP_MONKEYPATCH_COMPAT_NAME( CapRound ) = 1, //!< Round cap
713       Flat SIP_MONKEYPATCH_COMPAT_NAME( CapFlat ), //!< Flat cap (in line with start/end of line)
714       Square SIP_MONKEYPATCH_COMPAT_NAME( CapSquare ), //!< Square cap (extends past start/end of line by buffer distance)
715     };
Q_ENUM(EndCapStyle)716     Q_ENUM( EndCapStyle )
717 
718     /**
719      * Join styles for buffers.
720      *
721      * \since QGIS 3.22
722      */
723     enum class JoinStyle SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsGeometry, JoinStyle ) : int
724       {
725       Round SIP_MONKEYPATCH_COMPAT_NAME( JoinStyleRound ) = 1, //!< Use rounded joins
726       Miter SIP_MONKEYPATCH_COMPAT_NAME( JoinStyleMiter ), //!< Use mitered joins
727       Bevel SIP_MONKEYPATCH_COMPAT_NAME( JoinStyleBevel ), //!< Use beveled joins
728     };
729     Q_ENUM( JoinStyle )
730 
731     /**
732      * Feature request spatial filter types.
733      *
734      * \since QGIS 3.22
735      */
736     enum class SpatialFilterType : int
737     {
738       NoFilter, //!< No spatial filtering of features
739       BoundingBox, //!< Filter using a bounding box
740       DistanceWithin, //!< Filter by distance to reference geometry
741     };
742     Q_ENUM( SpatialFilterType )
743 
744     /**
745      * File operation flags.
746      *
747      * \since QGIS 3.22
748      */
749     enum class FileOperationFlag : int
750     {
751       IncludeMetadataFile = 1 << 0, //!< Indicates that any associated .qmd metadata file should be included with the operation
752       IncludeStyleFile = 1 << 1, //!< Indicates that any associated .qml styling file should be included with the operation
753     };
754     //! File operation flags
755     Q_DECLARE_FLAGS( FileOperationFlags, FileOperationFlag )
756     Q_ENUM( FileOperationFlag )
757 
758     /**
759      * Generic map layer properties.
760      *
761      * \since QGIS 3.22
762      */
763     enum class MapLayerProperty : int
764     {
765       UsersCannotToggleEditing = 1 << 0, //!< Indicates that users are not allowed to toggle editing for this layer. Note that this does not imply that the layer is non-editable (see isEditable(), supportsEditing() ), rather that the editable status of the layer cannot be changed by users manually. Since QGIS 3.22.
766     };
767     //! Map layer properties
768     Q_DECLARE_FLAGS( MapLayerProperties, MapLayerProperty )
769     Q_ENUM( MapLayerProperty )
770 
771     /**
772      * Flags for annotation items.
773      *
774      * \since QGIS 3.22
775      */
776     enum class AnnotationItemFlag : int
777     {
778       ScaleDependentBoundingBox = 1 << 0, //!< Item's bounding box will vary depending on map scale
779     };
780     //! Annotation item flags
781     Q_DECLARE_FLAGS( AnnotationItemFlags, AnnotationItemFlag )
782     Q_ENUM( AnnotationItemFlag )
783 
784     /**
785      * Flags for controlling how an annotation item behaves in the GUI.
786      *
787      * \since QGIS 3.22
788      */
789     enum class AnnotationItemGuiFlag : int
790     {
791       FlagNoCreationTools = 1 << 0,  //!< Do not show item creation tools for the item type
792     };
793     //! Annotation item GUI flags
794     Q_DECLARE_FLAGS( AnnotationItemGuiFlags, AnnotationItemGuiFlag )
795     Q_ENUM( AnnotationItemGuiFlag )
796 
797     /**
798      * Annotation item node types.
799      *
800      * \since QGIS 3.22
801      */
802     enum class AnnotationItemNodeType : int
803     {
804       VertexHandle, //!< Node is a handle for manipulating vertices
805     };
806     Q_ENUM( AnnotationItemNodeType )
807 
808     /**
809      * Results from an edit operation on an annotation item.
810      *
811      * \since QGIS 3.22
812      */
813     enum class AnnotationItemEditOperationResult : int
814     {
815       Success, //!< Item was modified successfully
816       Invalid, //!< Operation has invalid parameters for the item, no change occurred
817       ItemCleared, //!< The operation results in the item being cleared, and the item should be removed from the layer as a result
818     };
Q_ENUM(AnnotationItemEditOperationResult)819     Q_ENUM( AnnotationItemEditOperationResult )
820 
821     /**
822      * Vector layer temporal feature modes
823      *
824      * \since QGIS 3.22
825      */
826     enum class VectorTemporalMode SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsVectorLayerTemporalProperties, TemporalMode ) : int
827       {
828       FixedTemporalRange SIP_MONKEYPATCH_COMPAT_NAME( ModeFixedTemporalRange ) = 0, //!< Mode when temporal properties have fixed start and end datetimes.
829       FeatureDateTimeInstantFromField SIP_MONKEYPATCH_COMPAT_NAME( ModeFeatureDateTimeInstantFromField ), //!< Mode when features have a datetime instant taken from a single field
830       FeatureDateTimeStartAndEndFromFields SIP_MONKEYPATCH_COMPAT_NAME( ModeFeatureDateTimeStartAndEndFromFields ), //!< Mode when features have separate fields for start and end times
831       FeatureDateTimeStartAndDurationFromFields SIP_MONKEYPATCH_COMPAT_NAME( ModeFeatureDateTimeStartAndDurationFromFields ), //!< Mode when features have a field for start time and a field for event duration
832       FeatureDateTimeStartAndEndFromExpressions SIP_MONKEYPATCH_COMPAT_NAME( ModeFeatureDateTimeStartAndEndFromExpressions ), //!< Mode when features use expressions for start and end times
833       RedrawLayerOnly SIP_MONKEYPATCH_COMPAT_NAME( ModeRedrawLayerOnly ), //!< Redraw the layer when temporal range changes, but don't apply any filtering. Useful when symbology or rule based renderer expressions depend on the time range.
834     };
835     Q_ENUM( VectorTemporalMode )
836 
837     /**
838      * Mode for the handling of the limits of the filtering timeframe for vector features
839      *
840      * \since QGIS 3.22
841      */
842     enum class VectorTemporalLimitMode : int
843     {
844       IncludeBeginExcludeEnd = 0, //!< Default mode: include the Begin limit, but exclude the End limit
845       IncludeBeginIncludeEnd, //!< Mode to include both limits of the filtering timeframe
846     };
Q_ENUM(VectorTemporalLimitMode)847     Q_ENUM( VectorTemporalLimitMode )
848 
849     /**
850      * Vector data provider temporal handling modes.
851      *
852      * \since QGIS 3.22
853      */
854     enum class VectorDataProviderTemporalMode SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsVectorDataProviderTemporalCapabilities, TemporalMode ) : int
855       {
856       HasFixedTemporalRange SIP_MONKEYPATCH_COMPAT_NAME( ProviderHasFixedTemporalRange ) = 0, //!< Entire dataset from provider has a fixed start and end datetime.
857       StoresFeatureDateTimeInstantInField SIP_MONKEYPATCH_COMPAT_NAME( ProviderStoresFeatureDateTimeInstantInField ), //!< Dataset has feature datetime instants stored in a single field
858       StoresFeatureDateTimeStartAndEndInSeparateFields SIP_MONKEYPATCH_COMPAT_NAME( ProviderStoresFeatureDateTimeStartAndEndInSeparateFields ), //!< Dataset stores feature start and end datetimes in separate fields
859     };
Q_ENUM(VectorDataProviderTemporalMode)860     Q_ENUM( VectorDataProviderTemporalMode )
861 
862     /**
863      * Raster layer temporal modes
864      *
865      * \since QGIS 3.22
866      */
867     enum class RasterTemporalMode SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsRasterLayerTemporalProperties, TemporalMode ) : int
868       {
869       FixedTemporalRange SIP_MONKEYPATCH_COMPAT_NAME( ModeFixedTemporalRange ) = 0, //!< Mode when temporal properties have fixed start and end datetimes.
870       TemporalRangeFromDataProvider SIP_MONKEYPATCH_COMPAT_NAME( ModeTemporalRangeFromDataProvider ) = 1, //!< Mode when raster layer delegates temporal range handling to the dataprovider.
871       RedrawLayerOnly SIP_MONKEYPATCH_COMPAT_NAME( ModeRedrawLayerOnly ) = 2, //!< Redraw the layer when temporal range changes, but don't apply any filtering. Useful when raster symbology expressions depend on the time range. (since QGIS 3.22)
872     };
Q_ENUM(RasterTemporalMode)873     Q_ENUM( RasterTemporalMode )
874 
875     /**
876      * Method to use when resolving a temporal range to a data provider layer or band.
877      *
878      * \since QGIS 3.22
879      */
880     enum class TemporalIntervalMatchMethod SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsRasterDataProviderTemporalCapabilities, IntervalHandlingMethod ) : int
881       {
882       MatchUsingWholeRange, //!< Use an exact match to the whole temporal range
883       MatchExactUsingStartOfRange, //!< Match the start of the temporal range to a corresponding layer or band, and only use exact matching results
884       MatchExactUsingEndOfRange, //!< Match the end of the temporal range to a corresponding layer or band, and only use exact matching results
885       FindClosestMatchToStartOfRange, //!< Match the start of the temporal range to the least previous closest datetime.
886       FindClosestMatchToEndOfRange //!< Match the end of the temporal range to the least previous closest datetime.
887     };
Q_ENUM(TemporalIntervalMatchMethod)888     Q_ENUM( TemporalIntervalMatchMethod )
889 
890     /**
891      * Indicates the direction (forward or inverse) of a transform.
892      *
893      * \since QGIS 3.22
894      */
895     enum class TransformDirection SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsCoordinateTransform, TransformDirection ) : int
896       {
897       Forward SIP_MONKEYPATCH_COMPAT_NAME( ForwardTransform ), //!< Forward transform (from source to destination)
898       Reverse SIP_MONKEYPATCH_COMPAT_NAME( ReverseTransform ) //!< Reverse/inverse transform (from destination to source)
899     };
Q_ENUM(TransformDirection)900     Q_ENUM( TransformDirection )
901 
902     /**
903      * Flags which adjust the way maps are rendered.
904      *
905      * \since QGIS 3.22
906      */
907     enum class MapSettingsFlag SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsMapSettings, Flag ) : int
908       {
909       Antialiasing             = 0x01,  //!< Enable anti-aliasing for map rendering
910       DrawEditingInfo          = 0x02,  //!< Enable drawing of vertex markers for layers in editing mode
911       ForceVectorOutput        = 0x04,  //!< Vector graphics should not be cached and drawn as raster images
912       UseAdvancedEffects       = 0x08,  //!< Enable layer opacity and blending effects
913       DrawLabeling             = 0x10,  //!< Enable drawing of labels on top of the map
914       UseRenderingOptimization = 0x20,  //!< Enable vector simplification and other rendering optimizations
915       DrawSelection            = 0x40,  //!< Whether vector selections should be shown in the rendered map
916       DrawSymbolBounds         = 0x80,  //!< Draw bounds of symbols (for debugging/testing)
917       RenderMapTile            = 0x100, //!< Draw map such that there are no problems between adjacent tiles
918       RenderPartialOutput      = 0x200, //!< Whether to make extra effort to update map image with partially rendered layers (better for interactive map canvas). Added in QGIS 3.0
919       RenderPreviewJob         = 0x400, //!< Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering
920       RenderBlocking           = 0x800, //!< Render and load remote sources in the same thread to ensure rendering remote sources (svg and images). WARNING: this flag must NEVER be used from GUI based applications (like the main QGIS application) or crashes will result. Only for use in external scripts or QGIS server.
921       LosslessImageRendering   = 0x1000, //!< Render images losslessly whenever possible, instead of the default lossy jpeg rendering used for some destination devices (e.g. PDF). This flag only works with builds based on Qt 5.13 or later.
922       Render3DMap              = 0x2000, //!< Render is for a 3D map
923     };
924     //! Map settings flags
Q_DECLARE_FLAGS(MapSettingsFlags,MapSettingsFlag)925     Q_DECLARE_FLAGS( MapSettingsFlags, MapSettingsFlag ) SIP_MONKEYPATCH_FLAGS_UNNEST( QgsMapSettings, Flags )
926     Q_ENUM( MapSettingsFlag )
927 
928     /**
929      * Flags which affect rendering operations.
930      *
931      * \since QGIS 3.22
932      */
933     enum class RenderContextFlag SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsRenderContext, Flag ) : int
934       {
935       DrawEditingInfo          = 0x01,  //!< Enable drawing of vertex markers for layers in editing mode
936       ForceVectorOutput        = 0x02,  //!< Vector graphics should not be cached and drawn as raster images
937       UseAdvancedEffects       = 0x04,  //!< Enable layer opacity and blending effects
938       UseRenderingOptimization = 0x08,  //!< Enable vector simplification and other rendering optimizations
939       DrawSelection            = 0x10,  //!< Whether vector selections should be shown in the rendered map
940       DrawSymbolBounds         = 0x20,  //!< Draw bounds of symbols (for debugging/testing)
941       RenderMapTile            = 0x40,  //!< Draw map such that there are no problems between adjacent tiles
942       Antialiasing             = 0x80,  //!< Use antialiasing while drawing
943       RenderPartialOutput      = 0x100, //!< Whether to make extra effort to update map image with partially rendered layers (better for interactive map canvas). Added in QGIS 3.0
944       RenderPreviewJob         = 0x200, //!< Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering
945       RenderBlocking           = 0x400, //!< Render and load remote sources in the same thread to ensure rendering remote sources (svg and images). WARNING: this flag must NEVER be used from GUI based applications (like the main QGIS application) or crashes will result. Only for use in external scripts or QGIS server.
946       RenderSymbolPreview      = 0x800, //!< The render is for a symbol preview only and map based properties may not be available, so care should be taken to handle map unit based sizes in an appropriate way.
947       LosslessImageRendering   = 0x1000, //!< Render images losslessly whenever possible, instead of the default lossy jpeg rendering used for some destination devices (e.g. PDF). This flag only works with builds based on Qt 5.13 or later.
948       ApplyScalingWorkaroundForTextRendering = 0x2000, //!< Whether a scaling workaround designed to stablise the rendering of small font sizes (or for painters scaled out by a large amount) when rendering text. Generally this is recommended, but it may incur some performance cost.
949       Render3DMap              = 0x4000, //!< Render is for a 3D map
950       ApplyClipAfterReprojection = 0x8000, //!< Feature geometry clipping to mapExtent() must be performed after the geometries are transformed using coordinateTransform(). Usually feature geometry clipping occurs using the extent() in the layer's CRS prior to geometry transformation, but in some cases when extent() could not be accurately calculated it is necessary to clip geometries to mapExtent() AFTER transforming them using coordinateTransform().
951       RenderingSubSymbol       = 0x10000, //!< Set whenever a sub-symbol of a parent symbol is currently being rendered. Can be used during symbol and symbol layer rendering to determine whether the symbol being rendered is a subsymbol. (Since QGIS 3.24)
952     };
953     //! Render context flags
Q_DECLARE_FLAGS(RenderContextFlags,RenderContextFlag)954     Q_DECLARE_FLAGS( RenderContextFlags, RenderContextFlag ) SIP_MONKEYPATCH_FLAGS_UNNEST( QgsRenderContext, Flags )
955     Q_ENUM( RenderContextFlag )
956 
957     // refs for below dox: https://github.com/qgis/QGIS/pull/1286#issuecomment-39806854
958     // https://github.com/qgis/QGIS/pull/8573#issuecomment-445585826
959 
960     /**
961      * Options for rendering text.
962      * \since QGIS 3.22
963      */
964     enum class TextRenderFormat SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsRenderContext, TextRenderFormat ) : int
965       {
966       AlwaysOutlines SIP_MONKEYPATCH_COMPAT_NAME( TextFormatAlwaysOutlines ), //!< Always render text using path objects (AKA outlines/curves). This setting guarantees the best quality rendering, even when using a raster paint surface (where sub-pixel path based text rendering is superior to sub-pixel text-based rendering). The downside is that text is converted to paths only, so users cannot open created vector outputs for post-processing in other applications and retain text editability.  This setting also guarantees complete compatibility with the full range of formatting options available through QgsTextRenderer and QgsTextFormat, some of which may not be possible to reproduce when using a vector-based paint surface and TextFormatAlwaysText mode. A final benefit to this setting is that vector exports created using text as outlines do not require all users to have the original fonts installed in order to display the text in its original style.
967       AlwaysText SIP_MONKEYPATCH_COMPAT_NAME( TextFormatAlwaysText ), //!< Always render text as text objects. While this mode preserves text objects as text for post-processing in external vector editing applications, it can result in rendering artifacts or poor quality rendering, depending on the text format settings. Even with raster based paint devices, TextFormatAlwaysText can result in inferior rendering quality to TextFormatAlwaysOutlines. When rendering using TextFormatAlwaysText to a vector based device (e.g. PDF or SVG), care must be taken to ensure that the required fonts are available to users when opening the created files, or default fallback fonts will be used to display the output instead. (Although PDF exports MAY automatically embed some fonts when possible, depending on the user's platform).
968     };
969     Q_ENUM( TextRenderFormat )
970 
971     /**
972      * Rendering subcomponent properties.
973      *
974      * \since QGIS 3.22
975      */
976     enum class RenderSubcomponentProperty : int
977     {
978       Generic, //!< Generic subcomponent property
979       ShadowOffset, //!< Shadow offset
980       BlurSize, //!< Blur size
981       GlowSpread, //!< Glow spread size
982     };
Q_ENUM(RenderSubcomponentProperty)983     Q_ENUM( RenderSubcomponentProperty )
984 
985     /**
986      * Types of vertex.
987      * \since QGIS 3.22
988      */
989     enum class VertexType SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsVertexId, VertexType ) : int
990       {
991       Segment SIP_MONKEYPATCH_COMPAT_NAME( SegmentVertex ) = 1, //!< The actual start or end point of a segment
992       Curve SIP_MONKEYPATCH_COMPAT_NAME( CurveVertex ) = 2, //!< An intermediate point on a segment defining the curvature of the segment
993     };
994     Q_ENUM( VertexType )
995 
996     /**
997      * Identify search radius in mm
998      * \since QGIS 2.3
999      */
1000     static const double DEFAULT_SEARCH_RADIUS_MM;
1001 
1002     //! Default threshold between map coordinates and device coordinates for map2pixel simplification
1003     static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
1004 
1005     /**
1006      * Default highlight color.  The transparency is expected to only be applied to polygon
1007      * fill. Lines and outlines are rendered opaque.
1008      *
1009      *  \since QGIS 2.3
1010      */
1011     static const QColor DEFAULT_HIGHLIGHT_COLOR;
1012 
1013     /**
1014      * Default highlight buffer in mm.
1015      *  \since QGIS 2.3
1016      */
1017     static const double DEFAULT_HIGHLIGHT_BUFFER_MM;
1018 
1019     /**
1020      * Default highlight line/stroke minimum width in mm.
1021      * \since QGIS 2.3
1022      */
1023     static const double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM;
1024 
1025     /**
1026      * Fudge factor used to compare two scales. The code is often going from scale to scale
1027      *  denominator. So it looses precision and, when a limit is inclusive, can lead to errors.
1028      *  To avoid that, use this factor instead of using <= or >=.
1029      * \since QGIS 2.15
1030      */
1031     static const double SCALE_PRECISION;
1032 
1033     /**
1034      * Default Z coordinate value.
1035      * This value have to be assigned to the Z coordinate for the vertex.
1036      * \since QGIS 3.0
1037      */
1038     static const double DEFAULT_Z_COORDINATE;
1039 
1040     /**
1041      * Default M coordinate value.
1042      * This value have to be assigned to the M coordinate for the vertex.
1043      * \since QGIS 3.20
1044      */
1045     static const double DEFAULT_M_COORDINATE;
1046 
1047     /**
1048      * UI scaling factor. This should be applied to all widget sizes obtained from font metrics,
1049      * to account for differences in the default font sizes across different platforms.
1050      *  \since QGIS 3.0
1051      */
1052     static const double UI_SCALE_FACTOR;
1053 
1054     /**
1055      * Default snapping distance tolerance.
1056      *  \since QGIS 3.0
1057      */
1058     static const double DEFAULT_SNAP_TOLERANCE;
1059 
1060     /**
1061      * Default snapping distance units.
1062      *  \since QGIS 3.0
1063      */
1064     static const QgsTolerance::UnitType DEFAULT_SNAP_UNITS;
1065 
1066     /**
1067      * A string with default project scales.
1068      *
1069      * \since QGIS 3.12
1070      */
1071     static QString defaultProjectScales();
1072 
1073     /**
1074      * GEOS version number linked
1075      *
1076      * \since QGIS 3.20
1077      */
1078     static int geosVersionInt();
1079 
1080     /**
1081      * GEOS Major version number linked
1082      *
1083      * \since QGIS 3.20
1084      */
1085     static int geosVersionMajor();
1086 
1087     /**
1088      * GEOS Minor version number linked
1089      *
1090      * \since QGIS 3.20
1091      */
1092     static int geosVersionMinor();
1093 
1094     /**
1095      * GEOS Patch version number linked
1096      *
1097      * \since QGIS 3.20
1098      */
1099     static int geosVersionPatch();
1100 
1101     /**
1102      * GEOS string version linked
1103      *
1104      * \since QGIS 3.20
1105      */
1106     static QString geosVersion();
1107 };
1108 
1109 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolRenderHints )
Q_DECLARE_OPERATORS_FOR_FLAGS(Qgis::SymbolFlags)1110 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolFlags )
1111 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolPreviewFlags )
1112 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolLayerFlags )
1113 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::BrowserItemCapabilities )
1114 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SublayerQueryFlags )
1115 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SublayerFlags )
1116 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SqlLayerDefinitionCapabilities )
1117 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::BabelFormatCapabilities )
1118 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::BabelCommandFlags )
1119 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::GeometryValidityFlags )
1120 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::FileOperationFlags )
1121 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::AnnotationItemFlags )
1122 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::AnnotationItemGuiFlags )
1123 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::MapSettingsFlags )
1124 Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::RenderContextFlags )
1125 
1126 
1127 // hack to workaround warnings when casting void pointers
1128 // retrieved from QLibrary::resolve to function pointers.
1129 // It's assumed that this works on all systems supporting
1130 // QLibrary
1131 #define cast_to_fptr(f) f
1132 
1133 
1134 /**
1135  * \ingroup core
1136  * \brief RAII signal blocking class. Used for temporarily blocking signals from a QObject
1137  * for the lifetime of QgsSignalBlocker object.
1138  * \see whileBlocking()
1139  * \note not available in Python bindings
1140  * \since QGIS 2.16
1141  */
1142 // based on Boojum's code from http://stackoverflow.com/questions/3556687/prevent-firing-signals-in-qt
1143 template<class Object> class QgsSignalBlocker SIP_SKIP SIP_SKIP // clazy:exclude=rule-of-three
1144 {
1145   public:
1146 
1147     /**
1148      * Constructor for QgsSignalBlocker
1149      * \param object QObject to block signals from
1150      */
1151     explicit QgsSignalBlocker( Object * object )
1152       : mObject( object )
1153       , mPreviousState( object->blockSignals( true ) )
1154     {}
1155 
1156     ~QgsSignalBlocker()
1157     {
1158       mObject->blockSignals( mPreviousState );
1159     }
1160 
1161     //! Returns pointer to blocked QObject
1162     Object *operator->() { return mObject; }
1163 
1164   private:
1165 
1166     Object *mObject = nullptr;
1167     bool mPreviousState;
1168 
1169 };
1170 
1171 /**
1172  * Temporarily blocks signals from a QObject while calling a single method from the object.
1173  *
1174  * Usage:
1175  *   whileBlocking( checkBox )->setChecked( true );
1176  *   whileBlocking( spinBox )->setValue( 50 );
1177  *
1178  * No signals will be emitted when calling these methods.
1179  *
1180  * \see QgsSignalBlocker
1181  * \note not available in Python bindings
1182  * \since QGIS 2.16
1183  */
1184 // based on Boojum's code from http://stackoverflow.com/questions/3556687/prevent-firing-signals-in-qt
whileBlocking(Object * object)1185 template<class Object> inline QgsSignalBlocker<Object> whileBlocking( Object *object ) SIP_SKIP SIP_SKIP
1186 {
1187   return QgsSignalBlocker<Object>( object );
1188 }
1189 
1190 //! Hash for QVariant
1191 CORE_EXPORT uint qHash( const QVariant &variant );
1192 
1193 /**
1194  * Returns a string representation of a double
1195  * \param a double value
1196  * \param precision number of decimal places to retain
1197  */
1198 inline QString qgsDoubleToString( double a, int precision = 17 )
1199 {
1200   QString str = QString::number( a, 'f', precision );
1201   if ( precision )
1202   {
1203     if ( str.contains( QLatin1Char( '.' ) ) )
1204     {
1205       // remove ending 0s
1206       int idx = str.length() - 1;
1207       while ( str.at( idx ) == '0' && idx > 1 )
1208       {
1209         idx--;
1210       }
1211       if ( idx < str.length() - 1 )
1212         str.truncate( str.at( idx ) == '.' ? idx : idx + 1 );
1213     }
1214   }
1215   // avoid printing -0
1216   // see https://bugreports.qt.io/browse/QTBUG-71439
1217   if ( str == QLatin1String( "-0" ) )
1218   {
1219     return QLatin1String( "0" );
1220   }
1221   return str;
1222 }
1223 
1224 /**
1225  * Compare two doubles, treating nan values as equal
1226  * \param a first double
1227  * \param b second double
1228  * \since QGIS 3.20
1229  */
qgsNanCompatibleEquals(double a,double b)1230 inline bool qgsNanCompatibleEquals( double a, double b )
1231 {
1232   const bool aIsNan = std::isnan( a );
1233   const bool bIsNan = std::isnan( b );
1234   if ( aIsNan || bIsNan )
1235     return aIsNan && bIsNan;
1236 
1237   return a == b;
1238 }
1239 
1240 /**
1241  * Compare two doubles (but allow some difference)
1242  * \param a first double
1243  * \param b second double
1244  * \param epsilon maximum difference allowable between doubles
1245  */
1246 inline bool qgsDoubleNear( double a, double b, double epsilon = 4 * std::numeric_limits<double>::epsilon() )
1247 {
1248   const bool aIsNan = std::isnan( a );
1249   const bool bIsNan = std::isnan( b );
1250   if ( aIsNan || bIsNan )
1251     return aIsNan && bIsNan;
1252 
1253   const double diff = a - b;
1254   return diff > -epsilon && diff <= epsilon;
1255 }
1256 
1257 /**
1258  * Compare two floats (but allow some difference)
1259  * \param a first float
1260  * \param b second float
1261  * \param epsilon maximum difference allowable between floats
1262  */
1263 inline bool qgsFloatNear( float a, float b, float epsilon = 4 * FLT_EPSILON )
1264 {
1265   const bool aIsNan = std::isnan( a );
1266   const bool bIsNan = std::isnan( b );
1267   if ( aIsNan || bIsNan )
1268     return aIsNan && bIsNan;
1269 
1270   const float diff = a - b;
1271   return diff > -epsilon && diff <= epsilon;
1272 }
1273 
1274 //! Compare two doubles using specified number of significant digits
1275 inline bool qgsDoubleNearSig( double a, double b, int significantDigits = 10 )
1276 {
1277   const bool aIsNan = std::isnan( a );
1278   const bool bIsNan = std::isnan( b );
1279   if ( aIsNan || bIsNan )
1280     return aIsNan && bIsNan;
1281 
1282   // The most simple would be to print numbers as %.xe and compare as strings
1283   // but that is probably too costly
1284   // Then the fastest would be to set some bits directly, but little/big endian
1285   // has to be considered (maybe TODO)
1286   // Is there a better way?
1287   int aexp, bexp;
1288   const double ar = std::frexp( a, &aexp );
1289   const double br = std::frexp( b, &bexp );
1290 
1291   return aexp == bexp &&
1292          std::round( ar * std::pow( 10.0, significantDigits ) ) == std::round( br * std::pow( 10.0, significantDigits ) );
1293 }
1294 
1295 /**
1296  * Returns a double \a number, rounded (as close as possible) to the specified number of \a places.
1297  *
1298  * \since QGIS 3.0
1299  */
qgsRound(double number,int places)1300 inline double qgsRound( double number, int places )
1301 {
1302   const double m = ( number < 0.0 ) ? -1.0 : 1.0;
1303   const double scaleFactor = std::pow( 10.0, places );
1304   return ( std::round( number * m * scaleFactor ) / scaleFactor ) * m;
1305 }
1306 
1307 
1308 #ifndef SIP_RUN
1309 
1310 ///@cond PRIVATE
1311 
1312 /**
1313  * Contains "polyfills" for backporting c++ features from standards > c++11 and Qt global methods
1314  * added later than our minimum version.
1315  *
1316  * To be removed when minimum c++ or Qt build requirement includes the std implementation
1317  * for these features.
1318  *
1319  * \note not available in Python bindings.
1320  */
1321 namespace qgis
1322 {
1323 
1324   /**
1325    * Use qgis::down_cast<Derived*>(pointer_to_base) as equivalent of
1326    * static_cast<Derived*>(pointer_to_base) with safe checking in debug
1327    * mode.
1328    *
1329    * Only works if no virtual inheritance is involved.
1330    *
1331    * Ported from GDAL's cpl::down_cast method.
1332    *
1333    * \param f pointer to a base class
1334    * \return pointer to a derived class
1335    */
down_cast(From * f)1336   template<typename To, typename From> inline To down_cast( From *f )
1337   {
1338     static_assert(
1339       ( std::is_base_of<From,
1340         typename std::remove_pointer<To>::type>::value ),
1341       "target type not derived from source type" );
1342     Q_ASSERT( f == nullptr || dynamic_cast<To>( f ) != nullptr );
1343     return static_cast<To>( f );
1344   }
1345 
1346   template<class T>
listToSet(const QList<T> & list)1347   QSet<T> listToSet( const QList<T> &list )
1348   {
1349 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
1350     return list.toSet();
1351 #else
1352     return QSet<T>( list.begin(), list.end() );
1353 #endif
1354   }
1355 
1356   template<class T>
setToList(const QSet<T> & set)1357   QList<T> setToList( const QSet<T> &set )
1358   {
1359 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
1360     return set.toList();
1361 #else
1362     return QList<T>( set.begin(), set.end() );
1363 #endif
1364   }
1365 }
1366 
1367 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
1368 namespace std
1369 {
1370   template<> struct hash<QString>
1371   {
1372     std::size_t operator()( const QString &s ) const noexcept
1373     {
1374       return ( size_t ) qHash( s );
1375     }
1376   };
1377 }
1378 #endif
1379 
1380 ///@endcond
1381 #endif
1382 
1383 /**
1384  * Returns a map of all enum entries.
1385  * The map has the enum values (int) as keys and the enum keys (QString) as values.
1386  * The enum must have been declared using Q_ENUM or Q_FLAG.
1387  */
1388 template<class T> const QMap<T, QString> qgsEnumMap() SIP_SKIP
1389 {
1390   const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
1391   Q_ASSERT( metaEnum.isValid() );
1392   QMap<T, QString> enumMap;
1393   for ( int idx = 0; idx < metaEnum.keyCount(); ++idx )
1394   {
1395     const char *enumKey = metaEnum.key( idx );
1396     enumMap.insert( static_cast<T>( metaEnum.keyToValue( enumKey ) ), QString( enumKey ) );
1397   }
1398   return enumMap;
1399 }
1400 
1401 /**
1402  * Returns the value for the given key of an enum.
1403  * \since QGIS 3.6
1404  */
1405 template<class T> QString qgsEnumValueToKey( const T &value ) SIP_SKIP
1406 {
1407   const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
1408   Q_ASSERT( metaEnum.isValid() );
1409   return QString::fromUtf8( metaEnum.valueToKey( static_cast<int>( value ) ) );
1410 }
1411 
1412 /**
1413  * Returns the value corresponding to the given \a key of an enum.
1414  * If the key is invalid, it will return the \a defaultValue.
1415  * If \a tryValueAsKey is TRUE, it will try to convert the string key to an enum value
1416  * \since QGIS 3.6
1417  */
1418 template<class T> T qgsEnumKeyToValue( const QString &key, const T &defaultValue, bool tryValueAsKey = true ) SIP_SKIP
1419 {
1420   const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
1421   Q_ASSERT( metaEnum.isValid() );
1422   bool ok = false;
1423   T v = static_cast<T>( metaEnum.keyToValue( key.toUtf8().data(), &ok ) );
1424   if ( ok )
1425   {
1426     return v;
1427   }
1428   else
1429   {
1430     // if conversion has failed, try with conversion from int value
1431     if ( tryValueAsKey )
1432     {
1433       bool canConvert = false;
1434       const int intValue = key.toInt( &canConvert );
1435       if ( canConvert && metaEnum.valueToKey( intValue ) )
1436       {
1437         return static_cast<T>( intValue );
1438       }
1439     }
1440   }
1441   return defaultValue;
1442 }
1443 
1444 /**
1445  * Returns the value for the given keys of a flag.
1446  * \since QGIS 3.16
1447  */
1448 template<class T> QString qgsFlagValueToKeys( const T &value ) SIP_SKIP
1449 {
1450   const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
1451   Q_ASSERT( metaEnum.isValid() );
1452   return QString::fromUtf8( metaEnum.valueToKeys( static_cast<int>( value ) ) );
1453 }
1454 
1455 /**
1456  * Returns the value corresponding to the given \a keys of a flag.
1457  * If the keys are invalid, it will return the \a defaultValue.
1458  * \since QGIS 3.16
1459  */
1460 template<class T> T qgsFlagKeysToValue( const QString &keys, const T &defaultValue ) SIP_SKIP
1461 {
1462   const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
1463   Q_ASSERT( metaEnum.isValid() );
1464   bool ok = false;
1465   T v = static_cast<T>( metaEnum.keysToValue( keys.toUtf8().constData(), &ok ) );
1466   if ( ok )
1467     return v;
1468   else
1469     return defaultValue;
1470 }
1471 
1472 
1473 /**
1474  * Converts a string to a double in a permissive way, e.g., allowing for incorrect
1475  * numbers of digits between thousand separators
1476  * \param string string to convert
1477  * \param ok will be set to TRUE if conversion was successful
1478  * \returns string converted to double if possible
1479  * \see permissiveToInt
1480  * \since QGIS 2.9
1481  */
1482 CORE_EXPORT double qgsPermissiveToDouble( QString string, bool &ok );
1483 
1484 /**
1485  * Converts a string to an integer in a permissive way, e.g., allowing for incorrect
1486  * numbers of digits between thousand separators
1487  * \param string string to convert
1488  * \param ok will be set to TRUE if conversion was successful
1489  * \returns string converted to int if possible
1490  * \see permissiveToDouble
1491  * \since QGIS 2.9
1492  */
1493 CORE_EXPORT int qgsPermissiveToInt( QString string, bool &ok );
1494 
1495 /**
1496  * Converts a string to an qlonglong in a permissive way, e.g., allowing for incorrect
1497  * numbers of digits between thousand separators
1498  * \param string string to convert
1499  * \param ok will be set to TRUE if conversion was successful
1500  * \returns string converted to int if possible
1501  * \see permissiveToInt
1502  * \since QGIS 3.4
1503  */
1504 CORE_EXPORT qlonglong qgsPermissiveToLongLong( QString string, bool &ok );
1505 
1506 /**
1507  * Compares two QVariant values and returns whether the first is less than the second.
1508  * Useful for sorting lists of variants, correctly handling sorting of the various
1509  * QVariant data types (such as strings, numeric values, dates and times)
1510  *
1511  * Invalid < NULL < Values
1512  *
1513  * \see qgsVariantGreaterThan()
1514  */
1515 CORE_EXPORT bool qgsVariantLessThan( const QVariant &lhs, const QVariant &rhs );
1516 
1517 /**
1518  * Compares two QVariant values and returns whether they are equal, two NULL values are
1519  * always treated as equal and 0 is not treated as equal with NULL
1520  *
1521  * \param lhs first value
1522  * \param rhs second value
1523  * \return TRUE if values are equal
1524  */
1525 CORE_EXPORT bool qgsVariantEqual( const QVariant &lhs, const QVariant &rhs );
1526 
1527 /**
1528  * Compares two QVariant values and returns whether the first is greater than the second.
1529  * Useful for sorting lists of variants, correctly handling sorting of the various
1530  * QVariant data types (such as strings, numeric values, dates and times)
1531  * \see qgsVariantLessThan()
1532  */
1533 CORE_EXPORT bool qgsVariantGreaterThan( const QVariant &lhs, const QVariant &rhs );
1534 
1535 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
1536 
1537 /**
1538  * Compares two QVariant values and returns whether the first is greater than the second.
1539  * Useful for sorting lists of variants, correctly handling sorting of the various
1540  * QVariant data types (such as strings, numeric values, dates and times)
1541  * \see qgsVariantLessThan()
1542  */
1543 inline bool operator> ( const QVariant &v1, const QVariant &v2 )
1544 {
1545   return qgsVariantGreaterThan( v1, v2 );
1546 }
1547 
1548 /**
1549  * Compares two QVariant values and returns whether the first is less than the second.
1550  * Useful for sorting lists of variants, correctly handling sorting of the various
1551  * QVariant data types (such as strings, numeric values, dates and times)
1552  *
1553  * Invalid < NULL < Values
1554  *
1555  * \see qgsVariantGreaterThan()
1556  */
1557 inline bool operator< ( const QVariant &v1, const QVariant &v2 )
1558 {
1559   return qgsVariantLessThan( v1, v2 );
1560 }
1561 #endif
1562 
1563 
1564 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1565 
1566 /**
1567  * Compares two QVariantList values and returns whether the first is less than the second.
1568  */
1569 template<> CORE_EXPORT bool qMapLessThanKey<QVariantList>( const QVariantList &key1, const QVariantList &key2 ) SIP_SKIP;
1570 #endif
1571 
1572 CORE_EXPORT QString qgsVsiPrefix( const QString &path );
1573 
1574 /**
1575  * Allocates size bytes and returns a pointer to the allocated  memory.
1576  * Works like C malloc() but prints debug message by QgsLogger if allocation fails.
1577  * \param size size in bytes
1578  */
1579 void CORE_EXPORT *qgsMalloc( size_t size ) SIP_SKIP;
1580 
1581 /**
1582  * Allocates  memory for an array of nmemb elements of size bytes each and returns
1583  * a pointer to the allocated memory. Works like C calloc() but prints debug message
1584  * by QgsLogger if allocation fails.
1585  * \param nmemb number of elements
1586  * \param size size of element in bytes
1587  */
1588 void CORE_EXPORT *qgsCalloc( size_t nmemb, size_t size ) SIP_SKIP;
1589 
1590 /**
1591  * Frees the memory space  pointed  to  by  ptr. Works like C free().
1592  * \param ptr pointer to memory space
1593  */
1594 void CORE_EXPORT qgsFree( void *ptr ) SIP_SKIP;
1595 
1596 #ifndef SIP_RUN
1597 
1598 #ifdef _MSC_VER
1599 #define CONSTLATIN1STRING inline const QLatin1String
1600 #else
1601 #define CONSTLATIN1STRING constexpr QLatin1String
1602 #endif
1603 
1604 ///@cond PRIVATE
1605 class ScopedIntIncrementor
1606 {
1607   public:
1608 
1609     ScopedIntIncrementor( int *variable )
1610       : mVariable( variable )
1611     {
1612       ( *mVariable )++;
1613     }
1614 
1615     ScopedIntIncrementor( const ScopedIntIncrementor &other ) = delete;
1616     ScopedIntIncrementor &operator=( const ScopedIntIncrementor &other ) = delete;
1617 
1618     void release()
1619     {
1620       if ( mVariable )
1621         ( *mVariable )--;
1622 
1623       mVariable = nullptr;
1624     }
1625 
1626     ~ScopedIntIncrementor()
1627     {
1628       release();
1629     }
1630 
1631   private:
1632     int *mVariable = nullptr;
1633 };
1634 ///@endcond
1635 
1636 /**
1637 * Wkt string that represents a geographic coord sys
1638 * \since QGIS GEOWkt
1639 */
1640 CONSTLATIN1STRING geoWkt()
1641 {
1642   return QLatin1String(
1643            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]] )"""
1644          );
1645 }
1646 
1647 //! PROJ4 string that represents a geographic coord sys
1648 CONSTLATIN1STRING geoProj4()
1649 {
1650   return QLatin1String( "+proj=longlat +datum=WGS84 +no_defs" );
1651 }
1652 
1653 //! Geographic coord sys from EPSG authority
1654 CONSTLATIN1STRING geoEpsgCrsAuthId()
1655 {
1656   return QLatin1String( "EPSG:4326" );
1657 }
1658 
1659 //! Constant that holds the string representation for "No ellips/No CRS"
1660 CONSTLATIN1STRING geoNone()
1661 {
1662   return QLatin1String( "NONE" );
1663 }
1664 
1665 ///@cond PRIVATE
1666 
1667 //! Delay between the scheduling of 2 preview jobs
1668 const int PREVIEW_JOB_DELAY_MS = 250;
1669 
1670 //! Maximum rendering time for a layer of a preview job
1671 const int MAXIMUM_LAYER_PREVIEW_TIME_MS = 250;
1672 
1673 ///@endcond
1674 
1675 #endif
1676 
1677 //! Magic number for a geographic coord sys in POSTGIS SRID
1678 const long GEOSRID = 4326;
1679 
1680 //! Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id
1681 const long GEOCRS_ID = 3452;
1682 
1683 //! Magic number for a geographic coord sys in EpsgCrsId ID format
1684 const long GEO_EPSG_CRS_ID = 4326;
1685 
1686 /**
1687  * Magick number that determines whether a projection crsid is a system (srs.db)
1688  * or user (~/.qgis.qgis.db) defined projection.
1689 */
1690 const int USER_CRS_START_ID = 100000;
1691 
1692 //
1693 // Constants for point symbols
1694 //
1695 
1696 //! Magic number that determines the default point size for point symbols
1697 const double DEFAULT_POINT_SIZE = 2.0;
1698 const double DEFAULT_LINE_WIDTH = 0.26;
1699 
1700 //! Default snapping tolerance for segments
1701 const double DEFAULT_SEGMENT_EPSILON = 1e-8;
1702 
1703 typedef QMap<QString, QString> QgsStringMap SIP_SKIP;
1704 
1705 /**
1706  * Qgssize is used instead of size_t, because size_t is stdlib type, unknown
1707  *  by SIP, and it would be hard to define size_t correctly in SIP.
1708  *  Currently used "unsigned long long" was introduced in C++11 (2011)
1709  *  but it was supported already before C++11 on common platforms.
1710  *  "unsigned long long int" gives syntax error in SIP.
1711  *  KEEP IN SYNC WITH qgssize defined in SIP!
1712 */
1713 typedef unsigned long long qgssize;
1714 
1715 #ifndef SIP_RUN
1716 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
1717 
1718 #define Q_NOWARN_DEPRECATED_PUSH \
1719   _Pragma("GCC diagnostic push") \
1720   _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"");
1721 #define Q_NOWARN_DEPRECATED_POP \
1722   _Pragma("GCC diagnostic pop");
1723 #define Q_NOWARN_UNREACHABLE_PUSH
1724 #define Q_NOWARN_UNREACHABLE_POP
1725 
1726 #elif defined(_MSC_VER)
1727 
1728 #define Q_NOWARN_DEPRECATED_PUSH \
1729   __pragma(warning(push)) \
1730   __pragma(warning(disable:4996))
1731 #define Q_NOWARN_DEPRECATED_POP \
1732   __pragma(warning(pop))
1733 #define Q_NOWARN_UNREACHABLE_PUSH \
1734   __pragma(warning(push)) \
1735   __pragma(warning(disable:4702))
1736 #define Q_NOWARN_UNREACHABLE_POP \
1737   __pragma(warning(pop))
1738 
1739 #else
1740 
1741 #define Q_NOWARN_DEPRECATED_PUSH
1742 #define Q_NOWARN_DEPRECATED_POP
1743 #define Q_NOWARN_UNREACHABLE_PUSH
1744 #define Q_NOWARN_UNREACHABLE_POP
1745 
1746 #endif
1747 #endif
1748 
1749 #ifndef QGISEXTERN
1750 #ifdef Q_OS_WIN
1751 #  define QGISEXTERN extern "C" __declspec( dllexport )
1752 #else
1753 #  if defined(__GNUC__) || defined(__clang__)
1754 #    define QGISEXTERN extern "C" __attribute__ ((visibility ("default")))
1755 #  else
1756 #    define QGISEXTERN extern "C"
1757 #  endif
1758 #endif
1759 #endif
1760 #endif
1761 
1762 #if __cplusplus >= 201500
1763 #define FALLTHROUGH [[fallthrough]];
1764 #elif defined(__clang__)
1765 #define FALLTHROUGH [[clang::fallthrough]];
1766 #elif defined(__GNUC__) && __GNUC__ >= 7
1767 #define FALLTHROUGH [[gnu::fallthrough]];
1768 #else
1769 #define FALLTHROUGH
1770 #endif
1771 
1772 // see https://infektor.net/posts/2017-01-19-using-cpp17-attributes-today.html#using-the-nodiscard-attribute
1773 #if __cplusplus >= 201703L
1774 #define NODISCARD [[nodiscard]]
1775 #elif defined(__clang__)
1776 #define NODISCARD [[nodiscard]]
1777 #elif defined(_MSC_VER)
1778 #define NODISCARD // no support
1779 #elif defined(__has_cpp_attribute)
1780 #if __has_cpp_attribute(nodiscard)
1781 #define NODISCARD [[nodiscard]]
1782 #elif __has_cpp_attribute(gnu::warn_unused_result)
1783 #define NODISCARD [[gnu::warn_unused_result]]
1784 #else
1785 #define NODISCARD Q_REQUIRED_RESULT
1786 #endif
1787 #else
1788 #define NODISCARD Q_REQUIRED_RESULT
1789 #endif
1790 
1791 #if __cplusplus >= 201703L
1792 #define MAYBE_UNUSED [[maybe_unused]]
1793 #elif defined(__clang__)
1794 #define MAYBE_UNUSED [[maybe_unused]]
1795 #elif defined(_MSC_VER)
1796 #define MAYBE_UNUSED // no support
1797 #elif defined(__has_cpp_attribute)
1798 #if __has_cpp_attribute(gnu::unused)
1799 #define MAYBE_UNUSED [[gnu::unused]]
1800 #else
1801 #define MAYBE_UNUSED
1802 #endif
1803 #else
1804 #define MAYBE_UNUSED
1805 #endif
1806 
1807 #ifndef FINAL
1808 #define FINAL final
1809 #endif
1810 
1811 #ifndef SIP_RUN
1812 #ifdef _MSC_VER
1813 #define BUILTIN_UNREACHABLE \
1814   __assume(false);
1815 #elif defined(__GNUC__) && !defined(__clang__)
1816 // Workaround a GCC bug where a -Wreturn-type warning is emitted in constructs
1817 // like:
1818 // switch( mVariableThatCanOnlyBeXorY )
1819 // {
1820 //    case X:
1821 //        return "foo";
1822 //    case Y:
1823 //        return "foo";
1824 // }
1825 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87951
1826 #define BUILTIN_UNREACHABLE \
1827   __builtin_unreachable();
1828 #else
1829 #define BUILTIN_UNREACHABLE
1830 #endif
1831 #endif // SIP_RUN
1832 
1833 #ifdef SIP_RUN
1834 
1835 /**
1836  * Wkt string that represents a geographic coord sys
1837  * \since QGIS GEOWkt
1838  */
1839 QString CORE_EXPORT geoWkt();
1840 
1841 //! PROJ4 string that represents a geographic coord sys
1842 QString CORE_EXPORT geoProj4();
1843 
1844 //! Geographic coord sys from EPSG authority
1845 QString CORE_EXPORT geoEpsgCrsAuthId();
1846 
1847 //! Constant that holds the string representation for "No ellips/No CRS"
1848 QString CORE_EXPORT geoNone();
1849 
1850 #endif
1851