Hi,

I am making a plugin drawing focal mechanisms (a symbol indicating how move a fault when an earthquake occurs) and there is one last problem before the release that i can't solve.

Anyway, the plugin draws the SVG symbol using the attributes and save them in a folder, each SVG symbol have the name of the feature Id. Then, symbology is applied to the layer using :

symbol_layer = QgsSvgMarkerSymbolLayerV2().create({'name_expression':'concat(\''+dirNameSymbol+'/\',\"'+self.ui.idField.currentText()+'\",\'.svg\')'})
layer.rendererV2().symbols()[0].changeSymbolLayer(0, symbol_layer)
iface.mapCanvas().refreshMap()

It works but only the first time. If i run the plugin a second time (i.e. to changed the color of the symbols), the new SVG symbol are well drawn in the folder, but don't displayed in the map canvas (the first are still displayed).

I understand it is probably because of cache memory (because if i close and re-open qgis or generate the new symbols in a different folder it works) but i'm not able to find the right way to refresh the view.

I have tried the following functions but no one make the job :

QgsMapRendererCache().clearCacheImage(layer.id())

or

if hasattr(layer, "setCacheImage"): layer.setCacheImage(None)
            layer.triggerRepaint()

or

layer.dataProvider().reloadData()
layer.triggerRepaint()

Thank you for your help.


--
Billant Jérémy - PhD student
CEREGE - UMR 7330
Europôle méditerranéen de l'Arbois
Avenue Louis Philibert
BP 80 13545 Aix-en-Provence Cedex 04
04 42 97 16 79

_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to