+// function : getGroupQColor()
+// purpose :
+//=================================================================================
+QColor SMESHGUI_GroupDlg::getGroupQColor() const
+{
+ return myColorBtn->color();
+}
+
+//=================================================================================
+// function : setDefaultGroupColor()
+// purpose :
+//=================================================================================
+void SMESHGUI_GroupDlg::setDefaultGroupColor()
+{
+ if( myMesh->_is_nil() )
+ return;
+
+ bool isAutoColor = myMesh->GetAutoColor();
+
+ QColor aQColor = myColorBtn->color();
+ if( !isAutoColor )
+ {
+ if ( !aQColor.isValid() ) {
+ int r = 0, g = 0, b = 0;
+ SMESH::GetColor( "SMESH", "default_grp_color", r, g, b, QColor( 255, 170, 0 ) );
+ aQColor.setRgb( r, g, b );
+ }
+ }
+ else
+ {
+#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
+ SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
+#else // old algorithm for auto-colors
+ SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
+
+ QList<SALOMEDS::Color> aReservedColors;
+ for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
+ {
+ SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
+ SALOMEDS::Color aReservedColor = aGroupObject->GetColor();
+ aReservedColors.append( aReservedColor );
+ }
+
+ SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
+#endif // SIMPLE_AUTOCOLOR
+
+ aQColor.setRgb( (int)( aColor.R * 255.0 ),
+ (int)( aColor.G * 255.0 ),
+ (int)( aColor.B * 255.0 ) );
+
+ }
+
+ setGroupQColor( aQColor );
+}
+
+//=================================================================================
+// 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 sub-mesh
+//=================================================================================
+bool SMESHGUI_GroupDlg::SetAppropriateActor()
+{
+ bool isActor = false;
+ myActorsList.clear();
+
+ if (myMesh->_is_nil()) return false;
+
+ SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
+
+ if (myGrpTypeGroup->checkedId() > 0) { // try current group on geometry actor
+ SMESH_Actor* anActor = 0;
+ if (!myGroupOnGeom->_is_nil())
+ anActor = SMESH::FindActorByObject(myGroupOnGeom);
+ if (!myGroupOnFilter->_is_nil())
+ anActor = SMESH::FindActorByObject(myGroupOnFilter);
+ if (anActor && anActor->hasIO())
+ {
+ isActor = true;
+ if (aViewWindow && !aViewWindow->isVisible(anActor->getIO()))
+ isActor = false;
+ else
+ myActorsList.append(anActor);
+ }
+ return anActor;
+ }
+ else {
+ // try mesh actor
+ SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
+ if (anActor && anActor->hasIO()) {
+ isActor = true;
+ if (aViewWindow && !aViewWindow->isVisible(anActor->getIO()))
+ isActor = false;
+ else
+ myActorsList.append(anActor);
+ }
+
+ // try group actor
+ SMESH_Actor* aGroupActor = 0;
+ if (!isActor && !myGroup->_is_nil()) {
+ aGroupActor = SMESH::FindActorByObject(myGroup);
+ if (aGroupActor && aGroupActor->hasIO())
+ myActorsList.append(aGroupActor);
+ }
+
+ // try any visible actor of group or sub-mesh of current mesh
+ if (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
+ VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
+ int nbItems = aCollection->GetNumberOfItems();
+ for (int i=0; i<nbItems && !isActor; i++)
+ {
+ SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(aCollection->GetItemAsObject(i));
+ if (anActor && anActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+ if (aViewWindow->isVisible(anIO)) {
+ if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0 && !myActorsList.contains(anActor) )
+ myActorsList.append(anActor);
+ }
+ }
+ }
+ }
+ }
+
+ // Show a standalone group if nothing else is visible (IPAL52227)
+ if ( myActorsList.count() == 1 &&
+ myActorsList[0] == aGroupActor &&
+ aViewWindow && !aViewWindow->isVisible(aGroupActor->getIO()))
+ SMESH::UpdateView( aViewWindow, SMESH::eDisplay, aGroupActor->getIO()->getEntry() );
+ }
+
+
+ if (myActorsList.count() > 0) {
+ QListIterator<SMESH_Actor*> it( myActorsList );
+ while ( it.hasNext() ) {
+ SMESH_Actor* anActor = it.next();
+ if ( IsActorVisible(anActor) )
+ anActor->SetPickable(true);
+ }
+ }
+
+ return ( isActor || (myActorsList.count() > 0) );
+}
+
+//=======================================================================
+//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 grpNodeSelection: restoreShowEntityMode(); break;
+ case grp0DSelection: actor->SetEntityMode( SMESH_Actor::e0DElements ); break;
+ case grpBallSelection: actor->SetEntityMode( SMESH_Actor::eBallElem ); break;
+ case grpEdgeSelection: actor->SetEntityMode( SMESH_Actor::eEdges ); break;
+ case grpFaceSelection: actor->SetEntityMode( SMESH_Actor::eFaces ); break;
+ case grpVolumeSelection: 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;
+}
+
+//=======================================================================
+//function : IsActorVisible
+//purpose : return visibility of the actor
+//=======================================================================
+bool SMESHGUI_GroupDlg::IsActorVisible( SMESH_Actor* theActor )
+{
+ SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
+ if (theActor && aViewWindow)
+ return aViewWindow->isVisible(theActor->getIO());
+ return false;
+}
+
+//================================================================
+//function : setIsApplyAndClose
+//purpose : Set value of the flag indicating that the dialog is
+// accepted by Apply & Close button
+//================================================================
+void SMESHGUI_GroupDlg::setIsApplyAndClose( const bool theFlag )
+{
+ myIsApplyAndClose = theFlag;
+}
+
+//================================================================
+//function : isApplyAndClose
+//purpose : Get value of the flag indicating that the dialog is
+// accepted by Apply & Close button
+//================================================================
+bool SMESHGUI_GroupDlg::isApplyAndClose() const