Sat, 12/15/2012 - 07:40
Forums:
Hi!
I am developing a CAD program in which I am using a TDocStd_Document and displaying its contents through a V3d_Viewer.
Now I am searching for a way to get the label of the shape which is currently selected in the viewer. I can get the shape by calling "myViewer->Context->SelectedShape()".
Is there a simple way to retrieve the associated TDF_Label?
I want to use it e.g. to change the color of the shape or to remove the shape from the document.
PS: I'm using the pythonOCC bindings to work with OCC. I only have little experience with C++, but I think I will be able to understand code examples if you post some.
Thanks in advance,
Marko
Sun, 12/16/2012 - 09:16
Hi, try this:
myContext->InitCurrent();
if (myContext->MoreCurrent()) {
Handle(TPrsStd_AISPresentation) ObjectPrs = Handle(TPrsStd_AISPresentation)::DownCast(myContext->Current()->GetOwner());
if (ObjectPrs.IsNull())
return NULL;
TDF_Label Label = ObjectPrs->Label();
Tue, 12/18/2012 - 09:06
Thanks for your answer!
Unfortunately it does not work as expected for me: It always returns label "0:1:1:1" no matter which shape I selected.
I can imagine that this is because I am already making an error when adding a shape to my document (I never truly understood what was going on there, but it mysteriously worked) - Could that be the cause of the problem?
Anyhow now I see that I'll have to use TPrsStd_AISPresentation for this task - This is already very valuable information for me.
Thank you!