LAYER_TREE_VIEW.md
Some complex drawings may include lots of layers. Also, one layer may be used for single part/view, and separate layers may be used for dimensions, alternative position of part or for some additional meta information (notes, sketches and so on).
If some parts belong to some units, it is convenient to name layers for such parts in uniform way, or, what is even better, organize hierarchy of layers.
Unfortunately, DXF format does not support hierarchy of layer as well as LibreCAD (so far).
Even with plain list of layers it is possible to use logical grouping or layers - by relying on some common logical prefix in their names. However, while artificial naming of layers simplifies layers related operations a bit, it is still limited.
In order to provide more convenient way of working with layers, support of hierarchical layers was added and implemented in Layer Tree widget. The widget is similar to standard Layer List widget, yet brings a bit more functions.
Layers hierarchy is built purely based on naming convention, which assumes that some uniform substring is used as separator of layer's levels).
In addition to support of hierarchical view of layers, the widget adds some additional features that are listed below.
Here is a brief list of features, implemented in widget
Several predefined layer types are supported:
This is pure UI implementation that does not affect internal structures of layers or underlying storage format. Original plain layers list is not affected and two widgets may be used in parallel.
The current implementation tried to affect existing codebase as minimal as it is possible and minimize refactoring of the existing codebase in order to avoid introducing regression issues.
No additional libraries or dependencies were added, it's just plain C++/QT code with comments.
While such approach allows to have quite isolated and self-contained implementation, it is not clear how does it fit in general architecture of the existing code.
Possible candidates for further refactorings (if it will be reasonable) - classes for actions, code for working with entities, original layers list (RS_LayersList).
All strings used are localizable, yet it is necessary to create actual language-specific values for them.