Library containing scene items, allowing scene item instances to be stored with identifiers, and be instanced elsewhere in a scene.
More...
#include <Rendering/SceneComponents/sceneitemlibrary.h>
The main purpose of this class is to provide a single place from which clients can retrieve a SceneItem with a given id. A SceneItemLibrary can hold other SceneItemLibrary instances, searching recursively (depth first) for a requested scene item id.
◆ SceneItemLibrary() [1/2]
Creates an empty library.
◆ SceneItemLibrary() [2/2]
- Parameters
-
lib | The library to make a copy of. |
When lib is copied, the items it contains are not copied. Instead, the new SceneItemLibrary instance will hold references to the same things as lib. Therefore, the client needs to ensure that these contents remain valid for as long as the copy is in use. In particular, if lib is rebuilt as a result of a workspace operation's inputs being updated, the original copy of it should also be updated to prevent that copy from trying to use objects which might no longer exist.
◆ ~SceneItemLibrary()
The destructor destroys the library, but not the things it contains.
◆ add() [1/2]
bool add |
( |
const QString & |
id, |
|
|
SceneItem & |
sceneItem |
|
) |
| |
- Parameters
-
id | The id to assign to this sceneItem in the library. |
sceneItem | The sceneItem to add to the library. |
If a sceneItem with the same id as sceneItem is already present in the library, this function will not add sceneItem. Instead, the old sceneItem is retained and the function returns false. Note that this test is only performed for sceneItems held directly by this library, not for any of the sub-libraries it also might hold. This allows a library to provide sceneItems which override those specified in any sub-libraries.
- Returns
- True if sceneItem could be added.
◆ add() [2/2]
- Parameters
-
library | The sub-library to add to this library. |
- Returns
- True if library could be added or false if it is already a direct sub-library of this one.
◆ clearSceneItems()
Clears all sceneItems from the library. Note that the sceneItems are not deleted. This function merely clears the list of sceneItems the library keeps internally.
◆ clearSubLibraries()
void clearSubLibraries |
( |
| ) |
|
Clears all sub-libraries from this library. Note that the sub-libraries are not deleted. This function merely clears the list of sub-libraries this library keeps internally.
◆ getSceneItem()
SceneItem * getSceneItem |
( |
const QString & |
id | ) |
|
- Parameters
-
id | The id of the sceneItem to retrieve. |
- Returns
- The sceneItem corresponding to the specified id, or a null pointer if no such sceneItem could be found. Searches sub-libraries in a depth-first manner. The first sceneItem matching id is always returned whether or not the sceneItem is able to be used successfully.
◆ operator=()
◆ remove() [1/3]
bool remove |
( |
const QString & |
id | ) |
|
- Parameters
-
id | The id of the sceneItem to remove from the library. |
- Returns
- True if a sceneItem exists in the library with the specified id and it could be removed.
◆ remove() [2/3]
- Parameters
-
sceneItem | The sceneItem to remove from the library. |
Note that this function is slower than the remove(const String&) version due to how the data is stored internally. Access is optimized for lookups based on the id string, so searching for a particular sceneItem object is O(n) where n is the number of sceneItem this library holds directly (but is not affected by any sub-libraries).
- Returns
- True if sceneItem exists in the library and could be removed.
◆ remove() [3/3]
- Parameters
-
library | The sub-library to remove from this library. |
- Returns
- True if library is a sub-library directly held by this library and it could be removed. It will not be removed if it is not an immediate sub-library but is held more deeply in the sub-library hierachy.