[Qgis-developer] Plugin specific maplayers

Marco Hugentobler marco at hugis.net
Tue Oct 6 06:53:30 EDT 2009


Hi Mathias

There is a limited possibility to read from / write to project file from 
plugins with QgsProject::instance()->writeEntry / readEntry. 

However, in your case of custom maplayers, I think it is better to create a 
specific subclass of QgsMapLayer (as in your second idea).

Regards,
Marco

Am Dienstag, 6. Oktober 2009 11.05:13 schrieb Mathias Walker:
> Hello
>
> At the moment our mapfile plugin only works when adding a mapfile layer
> using the plugin dialog. This is done by creating a temporary image and
> adding it as a raster layer. This image is then rerendered on every change
> of the map canvas extents.
> But this layer will not be restored when saving it in a project, as the
> temporary image no longer exists. Also the plugin can not detect which
> layer belonged to it or what parameters to use.
>
> To solve these issues it would be nice to have a new plugin specific
> maplayer type.
>
> Desired features:
> - attach layer to corresponding plugin when loading a project
>   - get plugin specific parameters to recreate the layer
>   - handle layers with missing plugins
> - save plugin specific parameters when saving a project
> - detach from plugin when removing the layer
> - create and add layer using the plugin
> - get layer draw events for custom rendering based on current extents and
> image size
> - customizable layer properties dialog
>
> Several of these features can be solved with workarounds using the QGIS
> API. But especially the problem of restoring a layer when loading a project
> is still unsolved.
>
> What would be the best approach to integrate plugin specific maplayers into
> QGIS?
>
> Some ideas:
> - add a new class QgsPluginRasterDataProvider : QgsRasterDataProvider,
> though the QgsRasterDataProvider interface is rather WMS specific
> - or add a new class QgsPluginLayer : QgsMapLayer and
> LayerType::PluginLayer which would cause a lot of adjustments all over the
> place
>
> Best regards
> Mathias Walker


-- 
Dr. Marco Hugentobler
HUGIS - GIS programming and consulting
Honrainweg 5
CH-8038 Zürich
marco at hugis.net
http://homepage.hispeed.ch/hugis/


More information about the Qgis-developer mailing list