2016-01-08 21:31:41 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
__init__.py
|
|
|
|
---------------------
|
|
|
|
Date : May 2014
|
|
|
|
Copyright : (C) 2014 by Nathan Woodrow
|
|
|
|
Email : woodrow dot nathan at gmail dot com
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Nathan Woodrow'
|
|
|
|
__date__ = 'May 2014'
|
|
|
|
__copyright__ = '(C) 2014, Nathan Woodrow'
|
|
|
|
|
2018-05-14 19:53:02 -04:00
|
|
|
from qgis.PyQt.QtCore import NULL
|
2014-05-19 21:40:26 +10:00
|
|
|
from qgis._core import *
|
2014-11-29 18:37:23 +10:00
|
|
|
|
2018-05-14 11:30:27 -04:00
|
|
|
from .additions.edit import edit, QgsEditError
|
|
|
|
from .additions.fromfunction import fromFunction
|
2018-05-18 06:47:18 -08:00
|
|
|
from .additions.metaenum import metaEnumFromType, metaEnumFromValue
|
2018-05-14 11:30:27 -04:00
|
|
|
from .additions.processing import processing_output_layer_repr, processing_source_repr
|
2018-05-16 11:29:28 -04:00
|
|
|
from .additions.projectdirtyblocker import ProjectDirtyBlocker
|
2019-06-21 18:27:36 +02:00
|
|
|
from .additions.providermetadata import PyProviderMetadata
|
2018-05-16 11:29:28 -04:00
|
|
|
from .additions.qgsfeature import mapping_feature
|
|
|
|
from .additions.qgsfunction import register_function, qgsfunction
|
|
|
|
from .additions.qgsgeometry import _geometryNonZero, mapping_geometry
|
2018-06-21 06:11:45 -04:00
|
|
|
from .additions.qgssettings import _qgssettings_enum_value, _qgssettings_set_enum_value, _qgssettings_flag_value
|
2021-04-25 22:48:32 +02:00
|
|
|
from .additions.qgssettingsentry import PyQgsSettingsEntryEnumFlag
|
2018-05-16 11:29:28 -04:00
|
|
|
from .additions.qgstaskwrapper import QgsTaskWrapper
|
|
|
|
from .additions.readwritecontextentercategory import ReadWriteContextEnterCategory
|
2020-05-18 14:22:16 +10:00
|
|
|
from .additions.runtimeprofiler import ScopedRuntimeProfileContextManager
|
2019-01-10 14:52:01 +10:00
|
|
|
from .additions.validitycheck import check
|
2021-03-23 14:12:06 +10:00
|
|
|
from .additions.ranges import datetime_range_repr, date_range_repr
|
2018-05-14 11:30:27 -04:00
|
|
|
|
|
|
|
# Injections into classes
|
2018-05-16 11:29:28 -04:00
|
|
|
QgsFeature.__geo_interface__ = property(mapping_feature)
|
|
|
|
QgsGeometry.__bool__ = _geometryNonZero
|
|
|
|
QgsGeometry.__geo_interface__ = property(mapping_geometry)
|
|
|
|
QgsGeometry.__nonzero__ = _geometryNonZero
|
2017-06-11 19:35:43 +10:00
|
|
|
QgsProcessingFeatureSourceDefinition.__repr__ = processing_source_repr
|
|
|
|
QgsProcessingOutputLayerDefinition.__repr__ = processing_output_layer_repr
|
2018-05-16 11:29:28 -04:00
|
|
|
QgsProject.blockDirtying = ProjectDirtyBlocker
|
|
|
|
QgsReadWriteContext.enterCategory = ReadWriteContextEnterCategory
|
2020-05-18 14:22:16 +10:00
|
|
|
QgsRuntimeProfiler.profile = ScopedRuntimeProfileContextManager
|
2018-05-18 09:25:12 -08:00
|
|
|
QgsSettings.enumValue = _qgssettings_enum_value
|
2018-06-21 06:11:45 -04:00
|
|
|
QgsSettings.setEnumValue = _qgssettings_set_enum_value
|
2018-05-18 09:25:12 -08:00
|
|
|
QgsSettings.flagValue = _qgssettings_flag_value
|
2018-05-16 11:29:28 -04:00
|
|
|
QgsTask.fromFunction = fromFunction
|
2021-03-23 14:12:06 +10:00
|
|
|
QgsDateTimeRange.__repr__ = datetime_range_repr
|
|
|
|
QgsDateRange.__repr__ = date_range_repr
|
2019-06-21 18:27:36 +02:00
|
|
|
|
2021-04-07 14:02:08 +02:00
|
|
|
# Classes patched
|
2021-04-25 22:48:32 +02:00
|
|
|
QgsSettingsEntryEnumFlag = PyQgsSettingsEntryEnumFlag
|
2021-04-07 14:02:08 +02:00
|
|
|
|
2019-06-21 18:27:36 +02:00
|
|
|
# Classes patched using a derived class
|
|
|
|
QgsProviderMetadata = PyProviderMetadata
|
2019-11-01 15:39:28 +01:00
|
|
|
|
|
|
|
# monkey patch deprecated enum values to maintain API
|
|
|
|
# TODO - remove for QGIS 4.0
|
2021-10-21 12:13:07 +10:00
|
|
|
QgsMarkerLineSymbolLayer.Interval = Qgis.MarkerLinePlacement.Interval
|
|
|
|
QgsMarkerLineSymbolLayer.Vertex = Qgis.MarkerLinePlacement.Vertex
|
|
|
|
QgsMarkerLineSymbolLayer.LastVertex = Qgis.MarkerLinePlacement.LastVertex
|
|
|
|
QgsMarkerLineSymbolLayer.FirstVertex = Qgis.MarkerLinePlacement.FirstVertex
|
|
|
|
QgsMarkerLineSymbolLayer.CentralPoint = Qgis.MarkerLinePlacement.CentralPoint
|
|
|
|
QgsMarkerLineSymbolLayer.CurvePoint = Qgis.MarkerLinePlacement.CurvePoint
|
2019-11-01 15:39:28 +01:00
|
|
|
|
2021-10-21 12:34:05 +10:00
|
|
|
QgsRasterFillSymbolLayer.FillCoordinateMode = Qgis.SymbolCoordinateReference
|
|
|
|
QgsRasterFillSymbolLayer.Feature = Qgis.SymbolCoordinateReference.Feature
|
|
|
|
QgsRasterFillSymbolLayer.Viewport = Qgis.SymbolCoordinateReference.Viewport
|
|
|
|
|
|
|
|
QgsShapeburstFillSymbolLayer.ShapeburstColorType = Qgis.GradientColorSource
|
|
|
|
QgsShapeburstFillSymbolLayer.SimpleTwoColor = Qgis.GradientColorSource.SimpleTwoColor
|
|
|
|
QgsShapeburstFillSymbolLayer.ColorRamp = Qgis.GradientColorSource.ColorRamp
|
|
|
|
|
2021-07-19 10:25:29 +10:00
|
|
|
QgsVectorLayer.VertexMarkerType = Qgis.VertexMarkerType
|
|
|
|
QgsVectorLayer.SemiTransparentCircle = Qgis.VertexMarkerType.SemiTransparentCircle
|
|
|
|
QgsVectorLayer.SemiTransparentCircle.is_monkey_patched = True
|
|
|
|
QgsVectorLayer.SemiTransparentCircle.__doc__ = "Semi-transparent circle marker"
|
|
|
|
QgsVectorLayer.Cross = Qgis.VertexMarkerType.Cross
|
|
|
|
QgsVectorLayer.Cross.is_monkey_patched = True
|
|
|
|
QgsVectorLayer.Cross.__doc__ = "Cross marker"
|
|
|
|
QgsVectorLayer.NoMarker = Qgis.VertexMarkerType.NoMarker
|
|
|
|
QgsVectorLayer.NoMarker.is_monkey_patched = True
|
|
|
|
QgsVectorLayer.NoMarker.__doc__ = "No marker"
|
|
|
|
|
2021-08-03 16:05:03 +10:00
|
|
|
QgsSymbol.RenderHints = Qgis.SymbolRenderHints
|
|
|
|
QgsSymbol.PreviewFlags = Qgis.SymbolPreviewFlags
|
|
|
|
QgsDataItem.Capabilities = Qgis.BrowserItemCapabilities
|
|
|
|
QgsGeometry.ValidityFlags = Qgis.GeometryValidityFlags
|
|
|
|
|
2019-11-01 15:39:28 +01:00
|
|
|
# Monkey patch static const "QgsDataProvider.SUBLAYER_SEPARATOR" which was removed for QGIS 3.12
|
|
|
|
QgsDataProvider.SUBLAYER_SEPARATOR = QgsDataProvider.sublayerSeparator()
|
|
|
|
|
|
|
|
# Monkey patch Qgis vars
|
|
|
|
Qgis.QGIS_VERSION = Qgis.version()
|
|
|
|
Qgis.QGIS_VERSION_INT = Qgis.versionInt()
|
2019-11-05 10:34:29 +07:00
|
|
|
Qgis.QGIS_RELEASE_NAME = Qgis.releaseName()
|
2019-11-01 15:39:28 +01:00
|
|
|
|
2019-11-02 13:48:41 +01:00
|
|
|
GEOWKT = geoWkt()
|
|
|
|
PROJECT_SCALES = Qgis.defaultProjectScales()
|
|
|
|
GEOPROJ4 = geoProj4()
|
|
|
|
GEO_EPSG_CRS_AUTHID = geoEpsgCrsAuthId()
|
|
|
|
GEO_NONE = geoNone()
|