DATAKIT API  V2025.4
How to use Attributes

Generalities about entity attributes

You can retrieve attributes for a wide variety of Datakit classes, any class inheriting from Dtk_Entity or Dtk_DocElement being eligible.
Common entities on which attributes can be found are :

Sample code

Dtk_NodePtr layerInfoSetNode;
Dtk_LayerInfosSetPtr layerSet = layerInfoSetNode->GetDtk_LayerInfosSetPtr();
Dtk_NodePtr inNode;
/* Get Dtk_InfoPtr class */
Dtk_InfoPtr infos = inNode->GetInfos();
/* Retrieve inNode blanked status : -1 = undefined, 0 = Visible, 1=Invisible, 2=Construction Geometry */
int NodeBlankedStatus = infos->GetBlankedStatus();
/* Retrieve inNode activation status : 1 = Activated (Shown), 0 = Disable (Not Shown)*/
int ActivationStatus = infos->GetActivationFlag();
/* Retrieve inNode name */
Dtk_string name = infos->GetName();
/* Retrieve inNode color RGB */
Dtk_RGB color = infos->GetColor();
/* Retrieve inNode layer */
int layer = infos->GetLayer();
/* Retrieve inNode layer name */
Dtk_string layerName;
layerSet->GetLayerNameById( layer, layerName );
/* Retrieve inNode list of layer it appears in */
/* Retrieve inNode render information (Lights, texture data) */


Focus on layers

Calling Dtk_Info::GetLayer() provides a layer identifier, of which the entity belong.
For format allowing an entity to be listed in multiples layers, Dtk_Info::GetlayerList() allow to retrieve the list of layers the entity belong to.
If the said entity appears in only one layer, this call is equivalent to Dtk_Info::GetLayer().

In case the format allows more information relative to layers, such as name assignment or layer filtering, Dtk_LayerInfosSet allows to retrieve those information.
They live in the context of a Dtk_Component.
See Dtk_LayerFilterInfos and Dtk_LayerInfosSet interface and detailed description for more information.

Dtk_LayerInfosSet sample code

/* Set creation */
Dtk_LayerInfosSetPtr in = Dtk_LayerInfosSet::Create( 3 );//Creates a layer set with 3 layers in it.
in->SetLayerID( 0, 42 );
in->SetLayerName( 0, "42" );
in->SetLayerID( 1, 50 );
in->SetLayerName( 1, "Layer fifty" );
in->SetLayerID( 2, 1025 );
in->SetDefaultLayer( 2 );
auto const& createdFilter = in->CreateLayerFilterInfos( L"simple filter", L"A simple filter", DTK_FALSE, DTK_TRUE );//Creates a filter that is the default, where none of the set's layers are selected.
createdFilter->SelectLayer( 1 );
createdFilter->SelectLayer( 2 );
/* Browse through layers */
for( Dtk_Size_t i = 0; i < in->GetNumLayers(); ++i )
{
Dtk_string layerName; Dtk_ID layerID;
in->GetLayerName( i, layerName );
in->GetLayerID( i, layerID );
}
/* Find a specific layer */
Dtk_string layerNameWithID50;
auto status = in->GetLayerNameById( 50, layerNameWithID50 );//Get name of layer with ID 50
if( status != dtkNoError )
std::cout << "Layer 50 not found" << std::endl;
else
std::cout << layerNameWithID50 << std::endl;//prints "Layer fifty"
/* Find default layer */
Dtk_Size_t defaultIndex = 0;
Dtk_ID defaultLayerID;
status = in->GetDefaultLayer( defaultIndex );
if( status == dtkNoError )
{
in->GetLayerID( defaultIndex, defaultLayerID );
std::cout << defaultLayerID << std::endl;//prints 1025
}
/* Browse through layer filters */
for( Dtk_Size_t i = 0; i < in->GetNumLayerFilters(); ++i )
{
auto const& filter = in->GetLayerFilterByPos( i );
Dtk_tab<Dtk_Size_t> outIndexes;
filter->GetSelectedLayers( outIndexes );
for( Dtk_Size_t j = 0; j < outIndexes.size(); ++j )
{
Dtk_string selectedLayerName; Dtk_ID selectedLayerID;
in->GetLayerName( outIndexes[ j ], selectedLayerName );
in->GetLayerID( outIndexes[ j ], selectedLayerID );
}
}
/* Find default layer filter */
Dtk_Size_t defaultFilterIndex = 0;
Dtk_string defaultFilterLayerName, defaultFilterLayerDescription;
status = in->GetDefaultLayerFilter( defaultFilterIndex );
if( status == dtkNoError )
{
auto const& defaultFilter = in->GetLayerFilterByPos( defaultFilterIndex );
defaultFilter->GetName( defaultFilterLayerName );
defaultFilter->GetDescription( defaultFilterLayerDescription );
std::cout << defaultFilterLayerName << " : " << defaultFilterLayerDescription << std::endl;//prints "simple filter : A simple filter"
}
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:691
Dtk_Info::GetName
Dtk_string GetName() const
Retrieves the entity name.
Dtk_Info::GetBlankedStatus
int GetBlankedStatus() const
Retrieves the entity Blanked Status.
DTK_TRUE
#define DTK_TRUE
Definition: define.h:729
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:714
Dtk_Info::GetColor
Dtk_RGB GetColor() const
Retrieves the entity color as Dtk_RGBA values.
Dtk_Info::GetActivationFlag
int GetActivationFlag() const
DTK_FALSE
#define DTK_FALSE
Definition: define.h:730
Dtk_Node::GetDtk_LayerInfosSetPtr
Dtk_LayerInfosSetPtr GetDtk_LayerInfosSetPtr()
Retrieves the Dtk_Node as a Dtk_LayerInfosSetPtr - if exists -.
Dtk_DocElement::GetInfos
Dtk_InfoPtr GetInfos() const
Retrieves the Dtk_DocElement Dtk_InfoPtr - read only -.
Dtk_Info::GetLayer
int GetLayer() const
Retrieves the entity layer.
Dtk_Info::GetRenderInfos
Dtk_RenderInfosPtr GetRenderInfos() const
Retrieves the entity RenderInfos of the entity.
Dtk_SmartPtr< Dtk_Node >
Dtk_DumpXml_Dtk_RenderInfos
Dtk_ErrorStatus Dtk_DumpXml_Dtk_RenderInfos(FILE *F, const Dtk_RenderInfosPtr &inRender)
Definition: util_xml_dtk.cpp:3571
Dtk_tab< Dtk_Int32 >
Dtk_tab::size
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:504
Dtk_Info::GetlayerList
Dtk_tab< Dtk_Int32 > GetlayerList() const
Retrieves the layers in which the entity is assigned.
Dtk_LayerInfosSet::Create
static Dtk_LayerInfosSetPtr Create(const Dtk_Size_t inNumLayers)
Calls a constructor to allocate a new object.
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:144
Dtk_RGB
Definition: dtk_rgb.hpp:7