[Qgis-developer] General questions & multiple map canvases

Martin Dobias wonder.sk at gmail.com
Mon May 8 09:17:44 EDT 2006


Hi,

yesterday I had a discussion with Tim on this topic, so here is a summary:

Let's remove QgsMapLayerRegistry: we should eliminate use of global
map layer registry in favour of collections of map layers shared
between legends and map canvases. The basic idea:

class QgsMapLayerSetItem
{
public:
  // accessors / mutators

private:
  QgsMapLayer* mLayer;
  bool mVisible;
  bool mShowInOverview;
};


class QgsMapLayerSet : public QList<QgsMapLayerSetItem>
{
public:
  addLayer(QgsMapLayer* layer);
  removeLayer(QgsMapLayer* layer);
  // some more
};

Such layer set will be owned by map canvas and legend will access it
and do changes in it.

Two possibilities how to deal with using the same layer in more canvases:
- enable sharing of layers between layer sets with reference counting
- disable sharing of layers, allow cloning of layers
Currently I'm in favour of cloning instead of sharing them, because
IMO it's more straightforward to use, moreover the shared layers would
need to have same properties in the map canvases (renderer, symbology,
transparency...)

Another thing we talked about is interaction between legend and map
canvas. The original idea was to use something like
QgsLegend::setMapCanvas(QgsMapCanvas* canvas) call which would load
and show layers of map canvas. With this we could stay with only one
instance of QgsLegend for all map canvases. But now I've realized that
it won't be that easy because legend has its own properties like layer
groups, states of nodes (collapsed / expanded) etc. which would be
lost. Therefore I would say that be still need to use one legend
widget for every map canvas - if we won't find out a suitable
mechanism to save legend's state...


Martin



More information about the Qgis-developer mailing list