wx_BGI_Graphics
Classic BGI-compatible graphics API with modern OpenGL extension API
Loading...
Searching...
No Matches
bgi::DdsScene Class Reference

In-memory DDS scene graph. More...

#include <bgi_dds.h>

Public Member Functions

std::shared_ptr< DdsObject > append (std::shared_ptr< DdsObject > obj)
 Assigns an auto-generated ID to obj and appends it to the scene.
std::shared_ptr< DdsObject > appendWithId (std::shared_ptr< DdsObject > obj)
 Appends an object that already has its id field set (used during deserialization to restore the original ID strings).
void clearAll ()
 Clears ALL objects (cameras, UCS, drawing objects).
void clearDrawingObjects ()
 Clears all drawing-primitive objects (type not Camera, Ucs, WorldExtentsObj).
bool clearLayer (const std::string &name)
void compact ()
 Physically removes soft-deleted entries from order and index.
int count () const
 Returns the number of non-deleted objects in the scene.
int countDrawing () const
 Returns the number of non-deleted drawing-primitive objects only.
bool createLayer (const std::string &name)
 DdsScene ()
 DdsScene (const DdsScene &)=delete
bool deleteLayer (const std::string &name)
std::shared_ptr< DdsObject > findById (const std::string &id) const
 Returns the object with the given id, or nullptr if not found / deleted.
std::shared_ptr< DdsObject > findByLabel (const std::string &label) const
 Returns the first non-deleted object whose label equals label, or nullptr if none found.
std::string findIdByLabel (const std::string &label) const
 Returns the ID of the first non-deleted object with the given label, or "".
template<typename Fn>
void forEach (Fn &&fn) const
 Calls fn(DdsObject&) for every non-deleted object in insertion order.
template<typename Fn>
void forEachDrawing (Fn &&fn) const
 Calls fn(DdsObject&) for non-deleted drawing-primitive objects only.
template<typename Fn>
void forEachRenderRoot (Fn &&fn) const
 Calls fn(DdsObject&) for top-level render roots only.
std::string idAt (int index) const
 Returns the insertion-order ID at position index (0-based).
bool layerExists (const std::string &name) const
std::vector< std::string > layerNames () const
bool layerVisible (const std::string &name) const
DdsScene & operator= (const DdsScene &)=delete
bool remove (const std::string &id)
 Soft-deletes the object with the given id.
void resetLayers ()
bool setLayerVisible (const std::string &name, bool visible)
bool setObjectLayer (const std::string &id, const std::string &layerName)
 ~DdsScene ()=default

Data Fields

std::unordered_map< std::string, std::shared_ptr< DdsObject > > index
std::unordered_map< std::string, DdsLayer > layers
uint64_t nextId {1}
std::vector< std::string > order
uint64_t revision {1}

Detailed Description

In-memory DDS scene graph.

Maintains two parallel collections for O(1) direct access and O(n) sequential traversal:

  • order – vector of object IDs in insertion order.
  • index – unordered_map from ID → shared_ptr<DdsObject>.

Deletion is soft: objects are marked deleted so stable IDs are preserved. Call compact() to physically remove soft-deleted entries.

Thread safety: the caller (camera_api, ucs_api, dds_api, …) is responsible for holding gMutex before calling any DdsScene method.

Constructor & Destructor Documentation

◆ DdsScene() [1/2]

bgi::DdsScene::DdsScene ( )

◆ ~DdsScene()

bgi::DdsScene::~DdsScene ( )
default

◆ DdsScene() [2/2]

bgi::DdsScene::DdsScene ( const DdsScene & )
delete

Member Function Documentation

◆ append()

std::shared_ptr< DdsObject > bgi::DdsScene::append ( std::shared_ptr< DdsObject > obj)

Assigns an auto-generated ID to obj and appends it to the scene.

◆ appendWithId()

std::shared_ptr< DdsObject > bgi::DdsScene::appendWithId ( std::shared_ptr< DdsObject > obj)

Appends an object that already has its id field set (used during deserialization to restore the original ID strings).

Updates nextId if the id's numeric value exceeds the current counter.

◆ clearAll()

void bgi::DdsScene::clearAll ( )

Clears ALL objects (cameras, UCS, drawing objects).

◆ clearDrawingObjects()

void bgi::DdsScene::clearDrawingObjects ( )

Clears all drawing-primitive objects (type not Camera, Ucs, WorldExtentsObj).

Camera and UCS objects remain in the scene.

◆ clearLayer()

bool bgi::DdsScene::clearLayer ( const std::string & name)

◆ compact()

void bgi::DdsScene::compact ( )

Physically removes soft-deleted entries from order and index.

◆ count()

int bgi::DdsScene::count ( ) const

Returns the number of non-deleted objects in the scene.

◆ countDrawing()

int bgi::DdsScene::countDrawing ( ) const

Returns the number of non-deleted drawing-primitive objects only.

◆ createLayer()

bool bgi::DdsScene::createLayer ( const std::string & name)

◆ deleteLayer()

bool bgi::DdsScene::deleteLayer ( const std::string & name)

◆ findById()

std::shared_ptr< DdsObject > bgi::DdsScene::findById ( const std::string & id) const

Returns the object with the given id, or nullptr if not found / deleted.

◆ findByLabel()

std::shared_ptr< DdsObject > bgi::DdsScene::findByLabel ( const std::string & label) const

Returns the first non-deleted object whose label equals label, or nullptr if none found.

◆ findIdByLabel()

std::string bgi::DdsScene::findIdByLabel ( const std::string & label) const

Returns the ID of the first non-deleted object with the given label, or "".

◆ forEach()

template<typename Fn>
void bgi::DdsScene::forEach ( Fn && fn) const
inline

Calls fn(DdsObject&) for every non-deleted object in insertion order.

◆ forEachDrawing()

template<typename Fn>
void bgi::DdsScene::forEachDrawing ( Fn && fn) const
inline

Calls fn(DdsObject&) for non-deleted drawing-primitive objects only.

◆ forEachRenderRoot()

template<typename Fn>
void bgi::DdsScene::forEachRenderRoot ( Fn && fn) const
inline

Calls fn(DdsObject&) for top-level render roots only.

Any object referenced as a child/operand of Transform / SetUnion / SetIntersection / SetDifference is skipped here and is expected to render through its owning composite node instead of as an independent root.

◆ idAt()

std::string bgi::DdsScene::idAt ( int index) const

Returns the insertion-order ID at position index (0-based).

Skips soft-deleted entries. Returns "" if out of range.

◆ layerExists()

bool bgi::DdsScene::layerExists ( const std::string & name) const

◆ layerNames()

std::vector< std::string > bgi::DdsScene::layerNames ( ) const

◆ layerVisible()

bool bgi::DdsScene::layerVisible ( const std::string & name) const

◆ operator=()

DdsScene & bgi::DdsScene::operator= ( const DdsScene & )
delete

◆ remove()

bool bgi::DdsScene::remove ( const std::string & id)

Soft-deletes the object with the given id.

Returns true on success.

◆ resetLayers()

void bgi::DdsScene::resetLayers ( )

◆ setLayerVisible()

bool bgi::DdsScene::setLayerVisible ( const std::string & name,
bool visible )

◆ setObjectLayer()

bool bgi::DdsScene::setObjectLayer ( const std::string & id,
const std::string & layerName )

Field Documentation

◆ index

std::unordered_map<std::string, std::shared_ptr<DdsObject> > bgi::DdsScene::index

◆ layers

std::unordered_map<std::string, DdsLayer> bgi::DdsScene::layers

◆ nextId

uint64_t bgi::DdsScene::nextId {1}

◆ order

std::vector<std::string> bgi::DdsScene::order

◆ revision

uint64_t bgi::DdsScene::revision {1}

The documentation for this class was generated from the following file: