In SALOME, the representation of the data tree in the Object browser for the full (CORBA-based) module is done basing on the study contents as it is supplied by SALOME data server (SALOMEDS). In contrast to the light module which data tree is completely defined and can be easily attuned by the module specific implementation, full module must publish its data in the CORBA study by means of the corresponding API of SALOME data server, namely SALOMEDS::StudyBuilder
. As soon as data entities are published in the study, they are shown in the Object browser, in the same order as they appear in the study tree. Re-arrangement of the data entities with such approach is not a trivial task: for example, when copying/moving any data entity at the new position within the tree, it is necessary to copy all its attributes as well and to clear (in case of move operation) the data entity at the original position. Also, it is not possible to make some data items in the tree "invisible" for the user (though it might be useful).
Use case builder provides an alternative and more flexible way for customizing the data tree representation. It implements another approach to the data tree hierarchy, based on the tree node attributes. With use case builder it is possible to arrange and easily re-arrange the data items in the data tree in any appropriate way.
For example, with use case builder it is easy to implement such operations as Drag and Drop and Copy/Cut/Paste. With use case builder approach it is not important how data entities are arranged in the study tree, they even may lie on the same level - use case builder allows providing custom data tree representation, completely indepedent on the study data tree itself. It is even possible to hide some data entities in the tree representation while still keeping them in the study (to store specific module data).
Object browser automatically checks it the module root data object contains a tree node attribute and switches to the browsing of the data tree for such module using the use case builder. Otherwise, it browses data using an ordinary study tree iterator. Thus, it is possible to have in the same study some modules based on use case builder approach and others not using it.
To obtain a reference to the use case builder, the function GetUseCaseBuilder()
of the SALOMEDS::Study
interface can be used:
SALOMEDS::UseCaseBuilder
interface of the SALOMEDS
CORBA module provides several methods that can be used to build a custom data tree. Its API is similar to the API of SALOMEDS::StudyBuilder
interface - it operates with terms "father object" and "child object". In addition, use case builder uses term "current object" that is used as a parent of the children objects added if the parent is not explicitly specified.
Browsing the use case tree can be done by means of the use case iterator, that is provided by the SALOMEDS::UseCaseIterator
interface of the SALOMEDS
CORBA module. Access to the use case iterator can be done via SALOMEDS::UseCaseBuilder
interface:
The API of the SALOMEDS::UseCaseIterator
interface is similar to the SALOMEDS::ChildIterator:
Typical usage of the UseCaseIterator
is as follows:
If you decide to switch your module to the use case builder approach to provide customization for the data tree representation, you must take care of compatibility with existing SALOME studies. Basically it means that you have to add a simple code to Load()
(and LoadASCII()
if necessary) method of your module, which adds tree node attributes to all data entities in the data tree of your module. The simplest way to do this is to iterate through all data items and recursively add them to the use case builder: