7

I have some layers :

layer 1
layer 2
layer 3

and I have create styles for any labels layer using base rule styles and labels and I have create a template .qpt and I use atlas correct.

In my template I have dynamic labels with my values from attributes like name id and more.

Here my template :

my template

On my style I have define specific $mapid for any style and layer.

Now I want to create a plugin where add automate layers styles and create composed Atlas generation.

First have a plugin window where the user can chooses layers from ToC.

Here the window :

plugin windows

Second I create the PyQGIS code where add style on chooses labels:

def run(self):
    layers = self.iface.legendInterface().layers()
    layer_list = []
    for layer in layers:
         layer_list.append(layer.name())
    self.dlg.comboBox_1_layer1.addItems(layer_list)
    self.dlg.comboBox_2_layer2.addItems(layer_list)
    self.dlg.comboBox_3_layer3.addItems(layer_list)
    self.dlg.show()
    result = self.dlg.exec_()
    if result:
        selectedLayerIndex1 = self.dlg.comboBox_1_layer1.currentIndex()
        selectedLayerIndex2 = self.dlg.comboBox_2_layer2.currentIndex()
        selectedLayerIndex3 = self.dlg.comboBox_3_layer3.currentIndex()
        selectedLayer1 = layers[selectedLayerIndex1]
        selectedLayer2 = layers[selectedLayerIndex2]
        selectedLayer3 = layers[selectedLayerIndex3]
        selectedLayer4 = layers[selectedLayerIndex4]
        selectedLayer5 = layers[selectedLayerIndex5]
        selectedLayer6 = layers[selectedLayerIndex6]
        a='/layer1.qml'
        b='/layer2.qml'
        c='/layer3.qml'
        test1=uri+a
        test2=uri+b
        test3=uri+c
        selectedLayer1.loadNamedStyle(test1)
        selectedLayer2.loadNamedStyle(test2)
        selectedLayer3.loadNamedStyle(test3)
        pass

This code work fine I have specific style for any chooses layer.

But I don't know how to start/add composed with my layers where I chooses and how to define my atlas with my template.

Any idea how to do that?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.