Salome HOME
Automatic assigning of default name for the group at the dialog box initialization
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GroupDlg.cxx
index 1b6f8cda7e53d72ea5041f8fed4eb00ecc9deb45..41270689a12924e118b3c720ce20376b02a5e8bd 100644 (file)
@@ -521,6 +521,22 @@ QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation)
   return aName;
 }
 
+void  SMESHGUI_GroupDlg::setDefaultName() const
+{
+  QString aResName;
+  _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+  int i=1;
+  QString aPrefix ="Group_";
+  _PTR(SObject) anObj;
+  do
+  {
+    aResName = aPrefix + QString::number( i++ );
+    anObj = aStudy->FindObject( aResName.toLatin1().data() );
+  }
+  while ( anObj );
+  myName->setText(aResName); 
+}
+
 //=================================================================================
 // function : Init()
 // purpose  :
@@ -543,6 +559,8 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
   SetAppropriateActor();
 
   setDefaultGroupColor();
+  setDefaultName();
+
 
   SALOME_ListIO aList;
   mySelectionMgr->selectedObjects( aList );
@@ -805,7 +823,7 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
       if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : EdgeSelection);
       break;
     case grpBallSelection:
-      //if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : BallSelection);
+      if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : BallSelection);
       break;
     case grpFaceSelection:
       if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : FaceSelection);
@@ -1112,7 +1130,7 @@ bool SMESHGUI_GroupDlg::onApply()
       SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" );
 
       /* init for the next operation */
-      myName->setText( "" );
+      setDefaultName();
       myElements->clear();
       myGroup         = SMESH::SMESH_Group::_nil();
       myGroupOnGeom   = SMESH::SMESH_GroupOnGeom::_nil();
@@ -1126,17 +1144,21 @@ bool SMESHGUI_GroupDlg::onApply()
       if ( aMeshGroupSO )
         if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) {
           anActor->setName(myName->text().toLatin1().data());
+         QColor c;
+         int delta;
           switch ( myTypeId ) {
           case grpNodeSelection:   anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
           case grpBallSelection:   anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
           case grpEdgeSelection:   anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
-          case grpFaceSelection:   
           case grpVolumeSelection: 
+              SMESH::GetColor("SMESH", "volume_color", c , delta, "255,0,170|-100");
+              anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;          
+             break;
+          case grpFaceSelection:   
           default:
-              QColor c;
-              int delta;
               SMESH::GetColor("SMESH", "fill_color", c , delta, "0,170,255|-100");
               anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break;          
+             break;
           }
         }
     }
@@ -1759,7 +1781,7 @@ void SMESHGUI_GroupDlg::onAdd()
     break;
   case grpBallSelection:
     aType = SMESH::BALL;
-    //mySelector->SetSelectionMode(BallSelection);
+    mySelector->SetSelectionMode(BallSelection);
     break;
   case grpEdgeSelection:
     aType = SMESH::EDGE;