For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Labels ?

Anonymous's picture
Forums: 

Hi !

How do I delete a TDF_Label from a TDocStd_Document ?

I have looked both into the docs and the header files, but I have not found any way to delete them.

Mikael

Mikhail KAZAKOV's picture

Hi, Mikael! Labels in the Application Framework are the persistant keys for the attributes manipulation. Label is like the address in the memory. You may attach some attributes (TDF_Attribute classes tree) to the label and remove attributes from the label. Each of the attribute has specific GUID, which is unique for the certain type of TDF_Attribute descendant. There is one important rule. On a label it may be only one attribute with one ID attached. It means, that You can attach as much as You want attributes to the label, but each of attribute has to have different GUID. That allows You the exact identification of each of attribute inside Your model. It's impossible to delete the Label from the data model. Label is the persistant storage of the attributes only. You can create as much labels as You need, but You can't delete any.

Best wishes.

Mikhail.

Mikael Aronsson's picture

Hi !

I thought the idea here was to use the document to create the hierarchy for a model, and then this would be saved to disk and then later loaded back in.

My idea was to display the label hierarchy of a document in a tree view widget to allow the user to have a good overview of the models hierarchy.

But I must have missunderstodd something here, I mean I must be able to delete labels or else it's pretty useless.

What should I use to create this hierarchy instead, do I have to do that on my own maybe and skip the OCAF classes ?

What I need is a nice tree hierarchy of the parts of a model that can be saved to disk, loaded back in, modified, displayed in a viewer and also I would like to display the hierarchy in a tree widget.

Mikael

Mikhail KAZAKOV's picture

Hello! Ok. It's a good idea to display the hierarchy of labels, but in fact labels are not data. They are only the handlers of data. Real data is in attributes, attached to labels. In fact what can be usefull to display is:

rootlabel

|

AttributeOnRootLabel_1

AttributeOnRootLabel_2

|

|

ChildLabel1

|

AttributeOnChildLabel1_1

|

ChildLabel2

and so on...

In fact such of information is usefull. You are right, that labels themselves without any information on them are... a little bit useless.

Labels are very low level. In fact You have the attribute TDataStd_TreeNode. Using this attribute You can generate the tree inside the model with the structure You want. each of node have to be placed on some label and after You connect nodes between each other. And how to provide the label structure of model... it's only Your private question. It depends in fact of the model.

Regards.

Mikhail.

Mikael Aronsson's picture

Hi !

If I use the TDataStd_TreeNode to create the hierarchy of a model, I still need to have the labels in the same hierarchy, for example if I add a TDataStd_CoordSys attribute and let that transform the children to, this will then transform the child labels, not the child tree nodes, correct ?

Is there a way to solve this ?

...
> Labels are very low level. In fact You have
> the attribute TDataStd_TreeNode. Using this
> attribute You can generate the tree inside
> the model with the structure You want. each
> of node have to be placed on some label and
> after You connect nodes between each other.
> And how to provide the label structure of
> model... it's only Your private question. It
> depends in fact of the model.

Vlad Romashko's picture

Hello Mikael!

You are right. TDataStd_TreeNode is an attribute only and it has to be set at a label. Labels during the creation of a model hierarchy are only the containers for the model's nodes. So, to create a node You have to set a TDataStd_TreeNode attribute attached to a label. In this case it doesn't matter what the label is. You may set it anywhere (attached to any label). What is important in this case - a TreeNode set at a label. Then You must connect just created node with other nodes of Your model. For this there are such methods as Append(), Prepend(), InsertBefore() and InsertAfter(). Using these methods You connect a node with others or You can redesign the tree of nodes using these methods. The manipulations of nodes don't concern a label hierarchy. You may forget about labels during working with TreeNodes.

The answer to You question. If You transform a node to a new place (for example: using TDataStd_TreeNode::Append() method) its label remain at the previous position. It's impossible to change the label's hierarchy.

The TreeNode attribute is very important one in OCAF. It may be used with the Function Services of OCAF. Changing a tree of Your model You may change the regeneration sequence of functions (function drivers).

Good luck,

Vlad

Vlad Romashko's picture

Bonjour Mikael!

It's not necessary to make Your own classes instead of OCAF classes. Please, look at the class TreeNode from TDataStd package. You may see that this class provides creation of an editable tree.

Good luck, Vlad