+
+//=================================================================================
+// function : SetAppropriateActor()
+// purpose : Find more appropriate of visible actors, set it to myActor, allow picking
+// NPAL19389: create a group with a selection in another group.
+// if mesh actor is not visible - find any first visible group or submesh
+//=================================================================================
+bool SMESHGUI_GroupDlg::SetAppropriateActor()
+{
+ bool isActor = false;
+
+ if (myMesh->_is_nil()) return false;
+
+ SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
+
+ // try mesh actor
+ myActor = SMESH::FindActorByObject(myMesh);
+ if (myActor && myActor->hasIO())
+ {
+ isActor = true;
+ if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
+ isActor = false;
+ }
+
+ // try current group actor
+ if (!isActor) {
+ if (!myGroup->_is_nil()) {
+ myActor = SMESH::FindActorByObject(myGroup);
+ if (myActor && myActor->hasIO())
+ {
+ isActor = true;
+ if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
+ isActor = false;
+ }
+ }
+ }
+
+ // try current group on geometry actor
+ if (!isActor) {
+ if (!myGroupOnGeom->_is_nil()) {
+ myActor = SMESH::FindActorByObject(myGroupOnGeom);
+ if (myActor && myActor->hasIO())
+ {
+ isActor = true;
+ if (aViewWindow && !aViewWindow->isVisible(myActor->getIO()))
+ isActor = false;
+ }
+ }
+ }
+
+ // try any visible actor of group or submesh of current mesh
+ if (!isActor && aViewWindow) {
+ // mesh entry
+ _PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
+ if (aSObject) {
+ CORBA::String_var meshEntry = aSObject->GetID().c_str();
+ int len = strlen(meshEntry);
+
+ // iterate on all actors in current view window, search for
+ // any visible actor, that belongs to group or submesh of current mesh
+ vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors();
+ aCollection->InitTraversal();
+ for (vtkActor *anAct = aCollection->GetNextActor();
+ anAct && !isActor;
+ anAct = aCollection->GetNextActor())
+ {
+ SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct);
+ if (anActor && anActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+ if (aViewWindow->isVisible(anIO)) {
+ if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0) {
+ myActor = anActor;
+ isActor = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (isActor)
+ SMESH::SetPickable(myActor);
+
+ return isActor;
+}
+
+//=======================================================================
+//function : setShowEntityMode
+//purpose : make shown only entity corresponding to my type
+//=======================================================================
+void SMESHGUI_GroupDlg::setShowEntityMode()
+{
+ if ( !myMesh->_is_nil() ) {
+ if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
+ if (!myStoredShownEntity)
+ myStoredShownEntity = actor->GetEntityMode();
+ switch ( myTypeId ) {
+ case 0: restoreShowEntityMode(); break;
+ case 1: actor->SetEntityMode( SMESH_Actor::eEdges ); break;
+ case 2: actor->SetEntityMode( SMESH_Actor::eFaces ); break;
+ case 3: actor->SetEntityMode( SMESH_Actor::eVolumes ); break;
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : restoreShowEntityMode
+//purpose : restore ShowEntity mode of myActor
+//=======================================================================
+void SMESHGUI_GroupDlg::restoreShowEntityMode()
+{
+ if ( myStoredShownEntity && !myMesh->_is_nil() ) {
+ if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
+ actor->SetEntityMode(myStoredShownEntity);
+ }
+ }
+ myStoredShownEntity = 0;
+}