Class: QgsCategorized3DRenderer

Categorized 3D renderer.

Similar to Categorized 2D renderer and Categorized labeling, it allows specification of rules for 3D symbols.

Warning

This is not considered stable API, and may change in future QGIS releases. It is exposed to the Python bindings as a tech preview only.

Added in version 4.2.

Class Hierarchy

Inheritance diagram of qgis._3d.QgsCategorized3DRenderer

Base classes

QgsAbstractVectorLayer3DRenderer

Base class for 3D renderers that are based on vector layers.

QgsAbstract3DRenderer

Base class for all renderers that participate in 3D views.

Constructor

__init__

Methods

addCategory

Adds a new category to the renderer.

categories

Returns a list of all categories recognized by the renderer.

classAttribute

Returns the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories.

deleteAllCategories

Deletes all existing categories from the renderer.

deleteCategory

Deletes the category with the specified index from the renderer.

moveCategory

Moves an existing category at index position from to index position to.

readXmlBaseProperties

setClassAttribute

Sets the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories.

setSourceColorRamp

Sets the source color ramp.

setSourceSymbol

Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbol before applying the categories' color.

sortByValue

Sorts the existing categories by their value.

sourceColorRamp

Returns the source color ramp, from which each categories' color is derived.

sourceSymbol

Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol before applying the categories' color.

updateCategoryRenderState

Changes the render state for the category with the specified index.

updateCategorySymbol

Changes the symbol for the category with the specified index.

updateCategoryValue

Changes the value for the category with the specified index.

updateColorRamp

Update the color ramp used and all symbols colors.

updateSymbols

Update all the symbols but leave categories and colors.

writeXmlBaseProperties

Static Methods

createCategories

Create categories for a list of values.

class qgis._3d.QgsCategorized3DRenderer[source]

Bases: QgsAbstractVectorLayer3DRenderer

__init__(attributeName: str | None = '', categories: Iterable[Qgs3DRendererCategory] = [])

Construct renderer with the given categories

Parameters:
addCategory(self, category: Qgs3DRendererCategory)[source]

Adds a new category to the renderer.

See also

categories()

Parameters:

category (Qgs3DRendererCategory)

categories(self) list[Qgs3DRendererCategory]

Returns a list of all categories recognized by the renderer.

Return type:

list[Qgs3DRendererCategory]

classAttribute(self) str[source]

Returns the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories.

Return type:

str

static createCategories(values: Iterable[Any], symbol: QgsAbstract3DSymbol | None, layer: QgsVectorLayer | None = None, attributeName: str | None = '') list[Qgs3DRendererCategory][source]

Create categories for a list of values. The returned symbols in the category list will be a modification of symbol.

If layer and fieldName are specified it will try to find nicer values to represent the description for the categories based on the respective field configuration.

Parameters:
Return type:

list[Qgs3DRendererCategory]

deleteAllCategories(self)[source]

Deletes all existing categories from the renderer.

See also

deleteCategory()

deleteCategory(self, catIndex: int) bool[source]

Deletes the category with the specified index from the renderer.

Parameters:

catIndex (int)

Return type:

bool

moveCategory(self, from_: int, to: int) bool[source]

Moves an existing category at index position from to index position to.

Parameters:
  • from (int)

  • to (int)

Return type:

bool

readXmlBaseProperties()
setClassAttribute(self, attributeName: str | None)[source]

Sets the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories.

See also

classAttribute()

Parameters:

attributeName (Optional[str])

setSourceColorRamp(self, ramp: QgsColorRamp | None)[source]

Sets the source color ramp.

Parameters:

ramp (Optional[QgsColorRamp]) – color ramp. Ownership is transferred to the renderer

setSourceSymbol(self, symbol: QgsAbstract3DSymbol | None)[source]

Sets the source symbol for the renderer, which is the base symbol used for the each categories’ symbol before applying the categories’ color.

Parameters:

symbol (Optional[QgsAbstract3DSymbol]) – source symbol, ownership is transferred to the renderer

See also

sourceSymbol()

sortByValue(self, order: Qt.SortOrder = Qt.AscendingOrder)[source]

Sorts the existing categories by their value.

Parameters:

order (Qt.SortOrder = Qt.AscendingOrder)

sourceColorRamp(self) QgsColorRamp | None[source]

Returns the source color ramp, from which each categories’ color is derived.

See also

sourceSymbol()

Return type:

Optional[QgsColorRamp]

sourceSymbol(self) QgsAbstract3DSymbol | None[source]

Returns the renderer’s source symbol, which is the base symbol used for the each categories’ symbol before applying the categories’ color.

Return type:

Optional[QgsAbstract3DSymbol]

updateCategoryRenderState(self, catIndex: int, render: bool) bool[source]

Changes the render state for the category with the specified index.

The render state indicates whether or not the category will be rendered, and is reflected in whether the category is checked with the project’s layer tree.

Parameters:
  • catIndex (int)

  • render (bool)

Return type:

bool

updateCategorySymbol(self, catIndex: int, symbol: QgsAbstract3DSymbol | None) bool[source]

Changes the symbol for the category with the specified index.

Ownership of symbol is transferred to the renderer.

Parameters:
Return type:

bool

updateCategoryValue(self, catIndex: int, value: Any) bool[source]

Changes the value for the category with the specified index.

If value is a list, then the category will match any of the values from this list.

Parameters:
  • catIndex (int)

  • value (Any)

Return type:

bool

updateColorRamp(self, ramp: QgsColorRamp | None)[source]

Update the color ramp used and all symbols colors.

Parameters:

ramp (Optional[QgsColorRamp]) – color ramp. Ownership is transferred to the renderer

updateSymbols(self, symbol: QgsAbstract3DSymbol | None)[source]

Update all the symbols but leave categories and colors. This method also sets the source symbol for the renderer.

Parameters:

symbol (Optional[QgsAbstract3DSymbol]) – source symbol to use for categories. Ownership is not transferred.

writeXmlBaseProperties()