Graphics Reference
In-Depth Information
bolLayerV2Registry object's addSymbolLayerType() method. Here
is an example implementation of the metadata for our CrossSymbolLayer
class, along with the code to register it within QGIS:
class
CrossSymbolLayerMetadata(QgsSymbolLayerV2AbstractMetadata):
def __init__(self):
QgsSymbolLayerV2AbstractMetadata.__init__(self,
"Cross", "Cross marker", QgsSymbolV2.Marker)
def createSymbolLayer(self, properties):
if "length" in properties:
length = int(properties['length'])
else:
length = 10
if "width" in properties:
width = int(properties['width'])
else:
width = 2
return CrossSymbolLayer(length, width)
def createSymbolLayerWidget(self, layer):
return CrossSymbolLayerWidget()
registry = QgsSymbolLayerV2Registry.instance()
registry.addSymbolLayerType(CrossSymbolLayerMetadata())
Note that the parameters for the QgsSymbolLayerV2Ab-
stractMetadata.__init__() method are as follows:
name : The unique name for the symbol layer, which must match the name re-
turned by the symbol layer's layerType() method.
visibleName : A display name for this symbol layer, as shown to the user with-
in the Layer Properties window.
type : The type of symbol that this symbol layer will be used for.
The createSymbolLayer() method is used to restore the symbol layer based on the
properties stored in the QGIS project file when the project was saved. The createSym-
Search WWH ::




Custom Search