AIS_MultipleConnectedInteractive and Selection

I want to display and select a composite object consisting of several subobjects with different Materials.
I am currently using a AIS_MultipleConnectedInteractive to Display my Object. This works fine, but I am unable to select these Object in my Viewer.

A search of the forums lead to this: http://www.opencascade.org/org/forum/thread_13633/

which indicates that selection of MultipleConnectedInteracitve was not implented by the time of that post (June 2008).

Is this still the case, or do is it my own fault?

////Source

//explore a compound Shape
TopExp_Explorer exp(mShp, TopAbs_SOLID);
while(exp.More())
{
//get current subshape
TopoDS_Solid mSolid = TopoDS::Solid(exp.Current());
InteractiveObj = new AIS_Shape(mSolid);
myAISContext->SetDisplayMode(InteractiveObj, 1, false);

//Get material and color from a shape-info struct wich contains one entry fro each subshape
Graphic3d_NameOfMaterial mat = pShp->material.at(i);
Quantity_Color col = pShp->color.at(i);
//set these values
myAISContext->SetColor(InteractiveObj, col, false);
myAISContext->SetMaterial(InteractiveObj, mat , false);
InteractiveObj->SetSelectionMode(0);

//add the new shape to the shapelist
InteractiveObjGroup->Connect(InteractiveObj);
i++;
exp.Next();
}
//when construction is finished, Set selection mode and display Shapegroup
myAISContext->SetSelectionMode(InteractiveObjGroup, 0);
myAISContext->Activate(InteractiveObjGroup, 0);
myAISContext->SetDisplayMode(InteractiveObjGroup, 1, false);
myAISContext->Display(InteractiveObjGroup);
/*End of source*/

The above code Displays my objects with the correct colors and materials, but no Interactive Selection is possible.
I can, however select the composite object manually, using it's handle and the ais_InteractivecontexT::SetSelected()-function.

any insight is appreciated

Tilman Leune's picture

I 've looked through the sources of AIS_MultipleConnectedShape and AIS_MultipleConnectedInteractive, and it seems that selection still is not implemented. I'll have to cook up my own solution.

JuryS's picture

There Is more optimized code for Selection and HighLight GROUP object.
I make this code with OpenCascade classes, like TDF_LabelList, and It's WORK COOL:

void objectView::TryToHighLightGroup()
{

TDF_Label FatherGroup;

if (myContext->HasDetected())
{
CurrentHighLightedLabels.Clear();
Handle_TPrsStd_AISPresentation CurrentPrs = Handle(TPrsStd_AISPresentation)::DownCast(myContext->DetectedInteractive()->GetOwner());
if (CurrentPrs.IsNull()) return; //Ýòîò îáúåêò íå èíòåðàêòèâíûé, âûõîæó

TDF_Label LabObject = CurrentPrs->Label();

if (IsFatherGroup(LabObject)) return; //Ïðåðâàòü îáðàáîòêó, åñëè îáúåêò íå âõîäèò â ãðóïïó

FatherGroup = GetRootGroupLabel(LabObject);
GetAllLabelsFromGroup(FatherGroup);
HighLightFromList();
}
else
ClearHighligtFromList();
}

void objectView::tryToSelectGroup()
{
bool work;
TDF_Label FatherGroup;
Handle_TPrsStd_AISPresentation CurrentPrs;
TDF_Label completeGroup[20];

CurrentHighLightedLabels.Clear();

AIS_SequenceOfInteractive aSequence;
for(myContext->InitCurrent();myContext->MoreCurrent();myContext->NextCurrent())
aSequence.Append(myContext->Current()); //Äîáàâëÿþ â ñïèñîê âñå âûäåëåííûå îáúåêòû
for(int iter=1;iter <=aSequence.Length();iter++)
{
CurrentPrs = Handle(TPrsStd_AISPresentation)::DownCast(aSequence(iter)->GetOwner());
if (CurrentPrs.IsNull()) continue; //Åñëè âûäåëåííûé îáúåêò íå èíòåðàêòèâíûé, ïðîäîëæàþ ÷òåíèå ïî ñïèñêó
TDF_Label LabObject = CurrentPrs->Label();
if (IsFatherGroup(LabObject)) continue; //Åñëè îáúåêò íå âõîäèò â ãðóïïó, ïðîäîëæàþ ÷òåíèå ïî ñïèñêó
FatherGroup = GetRootGroupLabel(LabObject);
work = true; // Ïûòàþñü îáîéòè ïîâòîðíóþ îáðàáîòêó áàçîâîé ãðóïïû.
for (int i=0;i<20;++i)
{
if (completeGroup[i]==FatherGroup)
{ work=false; break; }
}
if (work)
{
GetAllLabelsFromGroup(FatherGroup);
for (int i=0;i<20;++i)
{
if (completeGroup[i].IsNull()) { completeGroup[i]=FatherGroup; break; }
}
}
}
SetSelectedFromList();
}

void objectView::ClearHighligtFromList()
{
TDF_Label Current;
Handle_TPrsStd_AISPresentation CurrentPrs;
for (TDF_ListIteratorOfLabelList it(CurrentHighLightedLabels); it.More(); it.Next())
{
Current = it.Value();
if (!Current.FindAttribute(TPrsStd_AISPresentation::GetID(),CurrentPrs)) continue;
if (!myContext->IsSelected(CurrentPrs->GetAIS())) myContext->Unhilight(CurrentPrs->GetAIS());
}
}

void objectView::HighLightFromList()
{
TDF_Label Current;
Handle_TPrsStd_AISPresentation CurrentPrs;
for (TDF_ListIteratorOfLabelList it(CurrentHighLightedLabels); it.More(); it.Next())
{
Current = it.Value();
if (!Current.FindAttribute(TPrsStd_AISPresentation::GetID(),CurrentPrs)) continue;
if (!myContext->IsSelected(CurrentPrs->GetAIS())) myContext->Hilight(CurrentPrs->GetAIS());
}
}

void objectView::SetSelectedFromList()
{
TDF_Label Current;
Handle_TPrsStd_AISPresentation CurrentPrs;
for (TDF_ListIteratorOfLabelList it(CurrentHighLightedLabels); it.More(); it.Next())
{
Current = it.Value();
if (!Current.FindAttribute(TPrsStd_AISPresentation::GetID(),CurrentPrs)) continue;
if (myContext->IsSelected(CurrentPrs->GetAIS()))
myContext->AddOrRemoveSelected(CurrentPrs->GetAIS());

myContext->AddOrRemoveSelected(CurrentPrs->GetAIS());
}
}

void objectView::GetAllLabelsFromGroup(TDF_Label GroupLabel)
{
TDF_LabelList myLabelsIsGroup;
GetAllLabelsFromCurrentGroup(GroupLabel);

RunIfGroupList:
myLabelsIsGroup.Clear();

for (TDF_ListIteratorOfLabelList it(CurrentHighLightedLabels); it.More(); it.Next())
{
if (thatLabelIsGroup(it.Value()))
{
myLabelsIsGroup.Append(it.Value());
CurrentHighLightedLabels.Remove(it);
}
}

if (!myLabelsIsGroup.IsEmpty())
{
for (TDF_ListIteratorOfLabelList it(myLabelsIsGroup); it.More(); it.Next())
{
GetAllLabelsFromCurrentGroup(it.Value());
}
}
else return;

goto RunIfGroupList;
}

bool objectView::thatLabelIsGroup(TDF_Label GroupLabel)
{
Handle_TDataStd_AsciiString curString;

GroupLabel.FindAttribute(TDataStd_AsciiString::GetID(),curString);
if (curString->Get()=="Group") return true;
else return false;
}

void objectView::GetAllLabelsFromCurrentGroup(TDF_Label GroupLabel)
{
TDF_Label Root = GroupLabel.Father();
QStringList myNames;
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;

TDF_Label level2 = GroupLabel.FindChild(2,Standard_True);
for (int i = 0; i < 10000; ++i)
{
isFound = level2.FindChild(i).FindAttribute(TDataStd_AsciiString::GetID(),curString);
if (isFound)
{
AsciiName = curString->Get();
myNames.append(AsciiName.ToCString());
}
else break;
}
if (!myNames.isEmpty())
{
for (int i = 0; i < myNames.size(); ++i)
{
for (TDF_ChildIterator it(Root); it.More(); it.Next())
{
TDF_Label LabObject = it.Value();

if (myNames.at(i) == GetNameFromLabel(LabObject)) //Íàøåë ìåòêó ïî èìåíè
{
CurrentHighLightedLabels.Append(LabObject);
break;
}
}
}
}
}

TDF_Label objectView::GetRootGroupLabel(TDF_Label Object)
{
TDF_Label myFather;
TDF_Label groupNext[50];
groupNext[0] = Object;

for (int i=0; i<50; ++i )
{
groupNext[i+1] = GetFatherGrLabel(groupNext[i]);

if (IsFatherGroup(groupNext[i+1]))
{
myFather = groupNext[i+1];
break;
}
}
return myFather;
}

bool objectView::IsFatherGroup(TDF_Label Object) //Ôóíêöèÿ âîçâðàùàåò ïîëîæèòåëüíûé îòâåò,
//åñëè ýòî ðîäèòåëüñêàÿ ãðóïïà
{
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;
bool isFound;
TDF_Label level3 = Object.FindChild(3,Standard_True);
isFound = level3.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";
if (AsciiName=="") return true;
else return false;
}

TDF_Label objectView::GetFatherGrLabel(TDF_Label Object) //Ïîëó÷èòü ðîäèòåëüñêóþ ìåòêó ïî ìåòêå îáúåêòà
{
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;
QString Name;
TDF_Label Root = Object.Father();
TDF_Label FatherLabel;
TDF_Label level3 = Object.FindChild(3,Standard_True);
isFound = level3.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";
Name = AsciiName.ToCString();
for (TDF_ChildIterator it(Root); it.More(); it.Next())
{
TDF_Label LabObject = it.Value();
TDF_Label level0 = LabObject.FindChild(0,Standard_True);
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";

if (Name == AsciiName.ToCString()) //Íàøåë ãðóïïó ïî èìåíè, çàäàííîì â îáúåêòå
{
FatherLabel = LabObject;
break;
}
}
return FatherLabel;
}

QString objectView::GetNameFromLabel(TDF_Label Object)
{
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;

TDF_Label level0 = Object.FindChild(0,Standard_True);
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";
return (AsciiName.ToCString());
}

JuryS's picture

Hi. I make this code.
For the first time I make group driver:
//! Ñîçäàþ èíòåðàêòèâíûé îáúåêò ñ àòðèáóòàìè:
// Group Label - ñîçäàííàÿ ìåòêà
// Ïðèñâàèâàþ àòðèáóòû â ñëåäóþùåì ïîðÿäêå:
// 0 -- òèï îáúåêòà (óíèêàëüíûé êîä äëÿ ëþáîãî îáúåêòà)
// 0:0 -- ÎÏÈÑÀÍÈÅ (èìÿ)
// 1 -- ïðîïóñêàþ
// 2 -- èìåíà îáúåêòîâ, âêëþ÷åííûõ â ýòó ãðóïïó

// Íîâàÿ ìåòêà â ñòðóêòóðå
TDF_Label L = TDF_TagSource::NewChild(MainLab);

// Òèï îáúåêòà - êîíòóð
TDataStd_AsciiString::Set(L, "Group");

//Èìÿ, öâåòà
TDF_Label level0 = L.FindChild(0,Standard_True);
TDataStd_AsciiString::Set(level0.FindChild(0), Name.toAscii().data()); //èìÿ

//Èìåíà îáúåêòîâ, äîáàâëÿåìûõ â ãðóïïó
QString tempStr;
TDF_Label level2 = L.FindChild(2,Standard_True);
for (int i = 0; i < ObjectForGroup.size(); ++i)
{
tempStr = ObjectForGroup.at(i);
TDataStd_AsciiString::Set(level2.FindChild(i), tempStr.toAscii().data());
}

//Âñå ïîñòðîåíî ïåðåäàþ ðåçóëüòàò ïî ðàáîòå
result += trUtf8("Ïîñòðîèëè ãðóïïó. Èìÿ: %1. Âñåãî âêëþ÷èëè îáúåêòîâ %2.")
.arg(QString::fromUtf8(Name.toAscii().data()))
.arg(ObjectForGroup.size());
}
if (result=="") result = trUtf8("Ãðóïïó íå ïîñòðîèëè. Íåò ïîäõîäÿùèõ îáúåêòîâ äëÿ âêëþ÷åíèÿ â ãðóïïó ñðåäè: %1").arg(QString::fromUtf8(NamesOfObjects.toAscii().data()));
return result;
}

And after with myContext I'm used next function for HighLight and Selection mechanism:

void objectView::TryToHighLightGroup()
{
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;
QString FatherGroup;
QString NameOfObject;

if (myContext->HasDetected())
{
CurrentHighLightedNames.clear();
Handle_TPrsStd_AISPresentation CurrentPrs = Handle(TPrsStd_AISPresentation)::DownCast(myContext->DetectedInteractive()->GetOwner());
if (CurrentPrs.IsNull()) return; //Ýòîò îáúåêò íå èíòåðàêòèâíûé, âûõîæó

TDF_Label LabObject = CurrentPrs->Label();
TDF_Label DocLabel = LabObject.Father();
TDF_Label level0 = LabObject.FindChild(0,Standard_True); //C÷èòûâàþ èìÿ îáúåêòà
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";
NameOfObject = AsciiName.ToCString();
if (IsFatherGroup(NameOfObject,DocLabel)) return; //Ïðåðâàòü îáðàáîòêó, åñëè îáúåêò íå âõîäèò â ãðóïïó
FatherGroup = GetRootGroupName(NameOfObject,DocLabel);
CurrentHighLightedNames = GetAllNamesFromGroup(FatherGroup,DocLabel);
HighLightObj(CurrentHighLightedNames,DocLabel);
}
else
tryToClearHighligt();
}

void objectView::tryToSelectGroup()
{
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;
QString FatherGroup;
QString NameOfObject;
QStringList CurrentSelectedNames;
Handle(TPrsStd_AISPresentation) CurrentPrs;

AIS_SequenceOfInteractive aSequence;
for(myContext->InitCurrent();myContext->MoreCurrent();myContext->NextCurrent())
aSequence.Append(myContext->Current()); //Äîáàâëÿþ â ñïèñîê âñå âûäåëåííûå îáúåêòû

for(int iter=1;iter <=aSequence.Length();iter++)
{
CurrentPrs = Handle(TPrsStd_AISPresentation)::DownCast(aSequence(iter)->GetOwner());
if (CurrentPrs.IsNull()) continue; //Åñëè âûäåëåííûé îáúåêò íå èíòåðàêòèâíûé, ïðîäîëæàþ ÷òåíèå ïî ñïèñêó
TDF_Label LabObject = CurrentPrs->Label();
TDF_Label DocLabel = LabObject.Father();
TDF_Label level0 = LabObject.FindChild(0,Standard_True); //C÷èòûâàþ èìÿ îáúåêòà
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";
NameOfObject = AsciiName.ToCString();
if (IsFatherGroup(NameOfObject,DocLabel)) continue; //Åñëè îáúåêò íå âõîäèò â ãðóïïó, ïðîäîëæàþ ÷òåíèå ïî ñïèñêó
FatherGroup = GetRootGroupName(NameOfObject,DocLabel);
CurrentSelectedNames = GetAllNamesFromGroup(FatherGroup,DocLabel);

SetSelectedObj(CurrentSelectedNames,DocLabel);
}
}

void objectView::tryToClearHighligt()
{
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;
Handle_TPrsStd_AISPresentation CurrentPrs;
TDF_Label myLabel;
TDF_Label Root;

AIS_ListOfInteractive aList;
myContext->DisplayedObjects(aList);
if (aList.IsEmpty()) return;
AIS_ListIteratorOfListOfInteractive aListIterator;
for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next())
{
CurrentPrs = Handle(TPrsStd_AISPresentation)::DownCast(aListIterator.Value()->GetOwner());
if (!CurrentPrs.IsNull())
{
myLabel = CurrentPrs->Label();
break;
}
}

if (myLabel.IsNull()) return;

Root = myLabel.Father();

for (int i = 0; i < CurrentHighLightedNames.size(); ++i)
{
for (TDF_ChildIterator it(Root); it.More(); it.Next())
{
TDF_Label LabObject = it.Value();
TDF_Label level0 = LabObject.FindChild(0,Standard_True);
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";

if (CurrentHighLightedNames.at(i) == AsciiName.ToCString()) //Íàøåë îáúåêò ïî èìåíè
{
if (!LabObject.FindAttribute(TPrsStd_AISPresentation::GetID(),CurrentPrs)) continue;
if (!myContext->IsSelected(CurrentPrs->GetAIS())) myContext->Unhilight(CurrentPrs->GetAIS());
break;
}
}
}
}

void objectView::HighLightObj(const QStringList Names, TDF_Label Root)
{
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;
Handle_TPrsStd_AISPresentation CurrentPrs;

for (int i = 0; i < Names.size(); ++i)
{
for (TDF_ChildIterator it(Root); it.More(); it.Next())
{
TDF_Label LabObject = it.Value();
TDF_Label level0 = LabObject.FindChild(0,Standard_True);
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";

if (Names.at(i) == AsciiName.ToCString()) //Íàøåë îáúåêò ïî èìåíè
{
if (!LabObject.FindAttribute(TPrsStd_AISPresentation::GetID(),CurrentPrs)) continue;
if (!myContext->IsSelected(CurrentPrs->GetAIS())) myContext->Hilight(CurrentPrs->GetAIS());
break;
}
}
}
}

void objectView::SetSelectedObj(const QStringList Names, TDF_Label Root)
{
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;
Handle_TPrsStd_AISPresentation CurrentPrs;

for (int i = 0; i < Names.size(); ++i)
{
for (TDF_ChildIterator it(Root); it.More(); it.Next())
{
TDF_Label LabObject = it.Value();
TDF_Label level0 = LabObject.FindChild(0,Standard_True);
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";

if (Names.at(i) == AsciiName.ToCString()) //Íàøåë îáúåêò ïî èìåíè
{

if (!LabObject.FindAttribute(TPrsStd_AISPresentation::GetID(),CurrentPrs)) continue;

if (myContext->IsSelected(CurrentPrs->GetAIS())) //Åñëè îáúåêò óæå âûäåëåí, òî ñíèìàþ åãî, ÷òîáû ïîòîì äîáàâèòü
myContext->AddOrRemoveSelected(CurrentPrs->GetAIS());

myContext->AddOrRemoveSelected(CurrentPrs->GetAIS());
break;
}
}
}
}

QStringList objectView::GetAllNamesFromGroup(const QString NameOfGroup, TDF_Label Root)
{
QStringList myNames;
QStringList myNamesIsGroup;

myNames = GetAllNamesFromCurrentGroup(NameOfGroup,Root);
//Ïîëó÷èë ñïèñîê èìåí ãëàâíîé ìåòêè.  íåé ìîãóò òàêæå ñîäåðæàòüñÿ ãðóïïû, âû÷èñëÿþ èõ èìåíà

RunAgain:
for (int i = 0; i < myNames.size(); ++i) //Èç ñïèñêà âñåõ èìåí ãðóïïû èçâëåêàþ èìåíà äðóãèõ ãðóïï
{
if (thatObjectIsGroup(myNames.at(i),Root))
{
myNamesIsGroup.append(myNames.at(i));
myNames.removeAt(i);
}
}

if (!myNamesIsGroup.isEmpty())
{
for (int i = 0; i < myNamesIsGroup.size(); ++i)
{
myNames.append(GetAllNamesFromCurrentGroup(myNamesIsGroup.at(i),Root));
myNamesIsGroup.removeAt(i);
}
}
else return myNames;

goto RunAgain;
}

bool objectView::thatObjectIsGroup(const QString NameOfObject, TDF_Label Root)
{
bool isFound;
bool state = false;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;

for (TDF_ChildIterator it(Root); it.More(); it.Next())
{
TDF_Label LabObject = it.Value();
TDF_Label level0 = LabObject.FindChild(0,Standard_True);
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";

if (NameOfObject == AsciiName.ToCString()) //Íàøåë îáúåêò ïî èìåíè
{

LabObject.FindAttribute(TDataStd_AsciiString::GetID(),curString);
if (curString->Get()=="Group") state = true;
break;
}
}
return state;
}

QStringList objectView::GetAllNamesFromCurrentGroup(const QString NameOfGroupCurrentGroup, TDF_Label Root)
{
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;
TDF_Label myLabel;
QStringList myNames;

for (TDF_ChildIterator it(Root); it.More(); it.Next())
{
TDF_Label LabObject = it.Value();
TDF_Label level0 = LabObject.FindChild(0,Standard_True);
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";

if (NameOfGroupCurrentGroup == AsciiName.ToCString()) //Íàøåë ìåòêó ïî èìåíè
{
myLabel = it.Value();
break;
}
}
TDF_Label level2 = myLabel.FindChild(2,Standard_True);
for (int i = 0; i < 10000; ++i)
{
isFound = level2.FindChild(i).FindAttribute(TDataStd_AsciiString::GetID(),curString);
if (isFound)
{
AsciiName = curString->Get();
myNames.append(AsciiName.ToCString());
}
else break;
}
return myNames;
}

QString objectView::GetRootGroupName(const QString NameOfObject, TDF_Label Root)
{
QString FatherGroup = QString();
QString NameNext[20];
NameNext[0] = NameOfObject;
for (int i=0; iGet() : "";

if (NameOfObject == AsciiName.ToCString()) //Íàøåë îáúåêò ïî èìåíè
{
TDF_Label level3 = LabObject.FindChild(3,Standard_True);
isFound = level3.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
if (!isFound) state = true;
break;
}
}
return state;
}

QString objectView::GetFatherGrName(const QString NameOfObject, TDF_Label Root)
{
bool isFound;
Handle_TDataStd_AsciiString curString;
TCollection_AsciiString AsciiName;

QString FatherGroup = "";
for (TDF_ChildIterator it(Root); it.More(); it.Next())
{
TDF_Label LabObject = it.Value();
TDF_Label level0 = LabObject.FindChild(0,Standard_True);
isFound = level0.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";

if (NameOfObject == AsciiName.ToCString()) //Íàøåë îáúåêò ïî èìåíè
{
TDF_Label level3 = LabObject.FindChild(3,Standard_True);
isFound = level3.FindChild(0).FindAttribute(TDataStd_AsciiString::GetID(),curString);
AsciiName = isFound ? curString->Get() : "";
FatherGroup = AsciiName.ToCString();
break;
}
}
return FatherGroup;
}

Also, sorry for my bad English.

Yury Sinithin, N. Novgorod, Russia.

Massimo Del Fedele's picture

Hi,

I've just implemented selection for AIS_MultipleConnectedInteractive... here the related code (last function in CXX file, and you need to add a couple of includes) :

//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection) &aSel, const Standard_Integer aMode)
{
if (!(HasLocation() || HasConnection()))
return;

aSel->Clear();

for(int iRef = 1; iRef <= myReferences.Length(); iRef++)
{
Handle(AIS_InteractiveObject) myReference = myReferences(iRef);

if (!myReference->HasSelection(aMode))
myReference->UpdateSelection(aMode);

const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode);

Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this);

Handle(Select3D_SensitiveEntity) SE3D, SNew;

if (TheRefSel->IsEmpty())
myReference->UpdateSelection(aMode);

for (TheRefSel->Init();TheRefSel->More();TheRefSel->Next())
{
SE3D = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive());

if (!SE3D.IsNull())
{
// Get the copy of SE3D
SNew = SE3D->GetConnected(myLocation);

if (aMode == 0)
{
SNew->Set(OWN);
// In case if SE3D caches some location-dependent data
// that must be updated after setting OWN
SNew->SetLocation(myLocation);
}

aSel->Add(SNew);
}
}
}
}