Subgroup: Map
Class: QgsMapThemeCollection¶
-
class
qgis.core.
QgsMapThemeCollection
(project: QgsProject = None)¶ Bases:
PyQt5.QtCore.QObject
Create map theme collection that handles themes of the given project.
Container class that allows storage of map themes consisting of visiblemap layers and layer styles.
New in version 2.12: Methods
applyTheme
Apply theme given by its name and modify layer tree, current style of layers and checked legend items of passed layer tree model. childEvent
clear
Remove all map themes from the collection. connectNotify
createThemeFromCurrentState
Static method to create theme from the current state of layer visibilities in layer tree, current style of layers and check state of legend items (from a layer tree model). customEvent
disconnectNotify
hasMapTheme
Returns whether a map theme with a matching name exists. insert
Inserts a new map theme to the collection. isSignalConnected
mapThemeState
Returns the recorded state of a map theme. mapThemeStyleOverrides
Get layer style overrides (for QgsMapSettings
) of the visible layers for given map theme.mapThemeVisibleLayerIds
Returns the list of layer IDs that are visible for the specified map theme. mapThemeVisibleLayers
Returns the list of layers that are visible for the specified map theme. mapThemes
Returns a list of existing map theme names. masterLayerOrder
Returns the master layer order (this will always match the project’s QgsProject. masterVisibleLayers
Returns the master list of visible layers. project
The QgsProject on which this map theme collection works. readXml
Reads the map theme collection state from XML receivers
removeMapTheme
Remove an existing map theme from collection. sender
senderSignalIndex
setProject
copydoc project() timerEvent
update
Updates a map theme within the collection. writeXml
Writes the map theme collection state to XML. Signals
mapThemeChanged
Emitted when a map theme changes definition. mapThemesChanged
Emitted when map themes within the collection are changed. projectChanged
Emitted when the project changes Attributes
-
class
MapThemeLayerRecord
(l: QgsMapLayer = None)¶ Bases:
sip.wrapper
Initialize layer record with a map layer - it will be stored as a weak pointer
QgsMapThemeCollection.MapThemeLayerRecord(QgsMapThemeCollection.MapThemeLayerRecord)
Individual record of a visible layer in a map theme record.
New in version 3.0.
-
checkedLegendItems
¶
-
currentStyle
¶
-
layer
(self) → QgsMapLayer¶ Returns map layer or null if the layer does not exist anymore
-
setLayer
(self, layer: QgsMapLayer)¶ Set the map layer for this record
-
usingCurrentStyle
¶
-
usingLegendItems
¶
-
-
class
MapThemeRecord
¶ Bases:
sip.wrapper
Individual map theme record of visible layers and styles.
New in version 3.0.
-
addLayerRecord
(self, record: QgsMapThemeCollection.MapThemeLayerRecord)¶ Add a new record for a layer.
-
layerRecords
(self) → object¶ Returns a list of records for all visible layer belonging to the theme.
-
removeLayerRecord
(self, layer: QgsMapLayer)¶ Removes a record for
layer
if present.
-
setLayerRecords
(self, records: Iterable[QgsMapThemeCollection.MapThemeLayerRecord])¶ Sets layer records for the theme.
-
-
applyTheme
(self, name: str, root: QgsLayerTreeGroup, model: QgsLayerTreeModel)¶ Apply theme given by its name and modify layer tree, current style of layers and checked legend items of passed layer tree model.
New in version 3.0.
-
childEvent
()¶
-
clear
(self)¶ Remove all map themes from the collection.
-
connectNotify
()¶
-
createThemeFromCurrentState
(root: QgsLayerTreeGroup, model: QgsLayerTreeModel) → QgsMapThemeCollection.MapThemeRecord¶ Static method to create theme from the current state of layer visibilities in layer tree, current style of layers and check state of legend items (from a layer tree model).
New in version 3.0.
-
customEvent
()¶
-
disconnectNotify
()¶
-
hasMapTheme
(self, name: str) → bool¶ Returns whether a map theme with a matching name exists.
New in version 3.0.
-
insert
(self, name: str, state: QgsMapThemeCollection.MapThemeRecord)¶ Inserts a new map theme to the collection.
See also
-
isSignalConnected
()¶
-
mapThemeChanged
¶ Emitted when a map theme changes definition.
New in version 3.0: [signal]
-
mapThemeState
(self, name: str) → QgsMapThemeCollection.MapThemeRecord¶ Returns the recorded state of a map theme.
New in version 3.0.
-
mapThemeStyleOverrides
(self, name: str) → Dict[str, str]¶ Get layer style overrides (for
QgsMapSettings
) of the visible layers for given map theme.New in version 3.0.
-
mapThemeVisibleLayerIds
(self, name: str) → List[str]¶ Returns the list of layer IDs that are visible for the specified map theme.
Note
The order of the returned list is not guaranteed to reflect the order of layers in the canvas.
New in version 3.0.
-
mapThemeVisibleLayers
(self, name: str) → List[QgsMapLayer]¶ Returns the list of layers that are visible for the specified map theme.
Note
The order of the returned list is not guaranteed to reflect the order of layers in the canvas.
New in version 3.0.
-
mapThemes
(self) → List[str]¶ Returns a list of existing map theme names.
New in version 3.0.
-
mapThemesChanged
¶ Emitted when map themes within the collection are changed.
New in version 3.0: [signal]
-
masterLayerOrder
(self) → List[QgsMapLayer]¶ Returns the master layer order (this will always match the project’s QgsProject.layerOrder() ). All map themes will maintain the same layer order as the master layer order.
New in version 3.0.
See also
-
masterVisibleLayers
(self) → List[QgsMapLayer]¶ Returns the master list of visible layers. The order of returned layers will always match those of masterLayerOrder(), but the returned layers are filtered to only include those visible in the project’s layer tree.
New in version 3.0.
See also
-
project
(self) → QgsProject¶ The QgsProject on which this map theme collection works.
New in version 3.0.
-
projectChanged
¶ Emitted when the project changes
copydoc project()
New in version 3.0: [signal]
-
readXml
(self, doc: QDomDocument)¶ Reads the map theme collection state from XML
Parameters: doc – DOM document See also
-
receivers
()¶
-
removeMapTheme
(self, name: str)¶ Remove an existing map theme from collection.
New in version 3.0.
-
sender
()¶
-
senderSignalIndex
()¶
-
setProject
(self, project: QgsProject)¶ copydoc project()
New in version 3.0.
-
timerEvent
()¶
-
update
(self, name: str, state: QgsMapThemeCollection.MapThemeRecord)¶ Updates a map theme within the collection.
Parameters: - name – name of map theme to update
- state – map theme record to replace existing map theme
See also
-
class