Layer tree model

Boudewijn Rempt boud at valdyas.org
Fri Mar 23 11:00:50 CET 2007


As you know bob, I've been working on getting the mask/selection proposal 
done. Because the masks etc. need to appear in the layerbox I've been forced 
to investigate the way we track our layer hierarchy right now. 

We do that actually three times:

* Inside the layers themselves (they have index, pointers to siblings, lists 
of child layers, divided over KisLayer and KisGroupLayer)
* Inside KisShapeController (which maps from layer to layershape, for the use 
of tools and flake integration) (not vice-versa, because a shape has a layer, 
but a layer hasn't got a shape)
* Inside a QAbstractItemModel implementation. I've started ripping that out of 
KisLayer/KisGrouplayer, because there should be only one model for all items, 
not a model per item. (KisLayerModel)

But: Qt's model-view model really wants to be kept in charge of the datamodel, 
with beforeInsertRow and afterInsertRow pointers. Ben already had some 
remarks about our internal layer hierarchy adminstration, too. 

So -- what should we do?

The requirements:

* layers need to be able to access their parents
* layers need to be able to access their siblings
* groups need to know their children
* all types of layers need to have an optional selection and optional masks
* the selections and masks only need to know about their parent, not their 
siblings.
* we need a QAbstractItemModel implementation that contains layers, masks and 
selections for the layerbox to work

Anything I've forgotten?

There is no great need for optimization here, since we won't have tens of 
thousands of layers.

There are a couple of possible designs:

* Keep the hierarchy administration inside KisGroupLayer and KisLayer. Access 
only through KisImage. Keep the external KisLayerModel updated from KisLayer.

* Make KisLayerModel leading. Give KisImage and all layers a pointer to the 
KisLayerModel instance and make them use the model to find their peers. All 
layer inserts and removals go through KisModel, with perhaps a facade on 
KisImage.

* Make KisImage a QAbstractItemModel. Make KisImage do all administration. A 
group layer becomes little more than a KisLayer that has no paint device of 
its own, just a projection.

Any other options?

-- 
Boudewijn Rempt 
http://www.valdyas.org/fading/index.cgi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20070323/c0a1bb1d/attachment.pgp 


More information about the kimageshop mailing list