[Qgis-developer] should legends be shown for invisible layers ?
strk at keybit.net
Mon Dec 15 05:24:27 PST 2014
On Mon, Dec 15, 2014 at 06:56:39PM +0700, Martin Dobias wrote:
> On Mon, Dec 15, 2014 at 6:32 PM, Sandro Santilli <strk at keybit.net> wrote:
> > On Mon, Dec 15, 2014 at 03:21:15PM +0700, Martin Dobias wrote:
> > > There is a softer way to ask to call legend node's data() again - the
> > > legend node can emit dataChanged() signal. This is used e.g. for symbols
> > > defined in map units - when the scale changes they will tell the model to
> > > update (QgsSymbolV2LegendNode::invalidateMapBasedData()).
> > Ah, interesting. But I see invalidateMapBasedData is invoked on all legend
> > nodes by QgsLayerTreeModel::setLegendMapViewData but not by
> > QgsLayerTreeModel::setLegendFilterByMap. Should the latter also invoke
> > the invalidation method ?
> That sounds reasonably. The invalidateMapBasedData() could have optional
> pointer to QgsMapSettings, so the WMS legend node would have a way to find
> out about the details of the map view (bbox, dpi, etc).
Great, I'll look into that !
> I'm not sure I like the fact that QgsMapSettings would be passed when
> legend nodes are created. I guess with invalidateMapBasedData() having
> QgsMapSettings pointer that would not be necessary.
If we want ::data() to lazily load the legend, there will be a need to
store the "last used map settings" anyway. Unless we leave all the caching
to the single layer (rather than to each of the layertree nodes).
> > Would it be inappropriate to store a pointer to the QgsLayerTreeModel
> > into a QgsLayerTreeModelLegendNode ? Or is there already such link ?
> Yes there is QgsLayerTreeModelLegendNode::model()
A-ha, thanks ! This should simplify the current PR.
> > Good idea, but also the "filtering" would need to be posibly done by
> > nodes themself. I mean there would be a "removing nodes" kind of filtering
> > and a "modify node contents" kind of filtering. Maybe there could be a
> > QgsLayerTreeModelLegendNode::filterByMap() method that would return
> > a value indicating if the node should be kept or removed, and would have
> > a chance to update its contents. What would you think about that ?
> That would be nice to have it directly inside legend nodes, but you would
> still need something that would run QgsMapHitTest and then pass it to
> individual nodes. So I am not sure if that would actually help.
More information about the Qgis-developer