3.6 KiB
Creating Objects and adding to context
In uLib the context is meant to hold a set of objects and their hierarchy. In addition ObjectFactory is used to create objects from a predefined registry.
Object context can be thought as a collection of uLib::Object instances. And there exists nested collection of objects if a context is added to another context. A nested context is a Group of elements that appears like a single object in the parent context and a hierarchy of objects inside the tree structure.
SmartPointer access
SmartPointer is a class that is used to hold a reference to another object. It is a template class that can be used to hold a reference to any object that is derived from uLib::Object. It is a smart pointer because it will automatically delete the object when it is no longer needed. It is also a smart pointer because it will automatically update the object when it is no longer needed.
The ObjectContext is responsible to keep track of all the objects that are added to it and to provide a way to access them, but also it holds the SmartPointer instances that point to the objects that are added to it. In this way Objects added to a Context are disposed only when the context is destroyed. For this reason the access to a object context for a Object via Get/Set is done using the SmartPointer instances.
Geant Physical Volumes
The Geant library add a further layer of complexity. The physical volumes are created from a what is called LogicalVolume (which holds information about the shape, material and daughter volumes) and represent the actual instances of the volumes in the detector. So in this sense they represent what could be the Prop3D in the uLib Vtk library. The PhysicalVolume is created from the LogicalVolume and is the one that is actually placed in the scene, with its own relative TRS: position and rotation (rotation here is a rotation matrix comprising the scaling).
so Adding a Solid or a Logical volume on the scene is not enough. We need to create a PhysicalVolume from the LogicalVolume and add it to the scene to see its instance and apply the TRS to the PhysicalVolume and so to eventually to the representation.
Gcompose interaction with objects that have Prop3d and object without 3D actor
In VTK and Qt the objects are organized in a tree structure. When We will add a new object to the scene it will be added to the tree structure and it will be displayed once wrapped in a vtk representation (like vtkContainerBox for instance).
For objects without 3D representation, they are added to the tree structure but they are not displayed in the scene. But when Object have a internal member that is a reference to another object, this will be represented in the tree structure as a child of the object that contains a reference to it. It is also important to note that the reference can be either the object itself or a smart pointer to the object. So the representation of the child in the tree structure is a placeholder for the object that is referenced and it can be added to many parents, creating multiple instances of the same reference in the tree structure.
When a object contains a reference to another object, the reference can be set from properties by selecting form the possible instances in the context that are compatible (can be casted) to the type of the reference. In this way the reference appears also as a child in the tree. On the other hand the same add operation can be performed by dragging the object from the tree structure and dropping it on the property of the object that contains the reference. In this case the reference will be set to the parent selecting the compatible menber automatically.