Salome HOME
Join BR-D5-38-2003
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GroupDlg.cxx
index 5ec1935cdeebf2f032b04c0842aa089ae04b2db1..b9396313bb87e81b284c3e58874978770855a78d 100644 (file)
@@ -89,9 +89,9 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
                 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
      mySMESHGUI( theModule ),
      mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
-     myViewWindow( SMESH::GetViewWindow( theModule ) ),
-     mySelector( myViewWindow->GetSelector() ),
-     myIsBusy( false )
+     mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
+     myIsBusy( false ),
+     myActor( 0 )
 {
   if (!name) setName("SMESHGUI_GroupDlg");
   initDialog(true);
@@ -104,6 +104,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
     myGeomGroupLine->setEnabled(false);
   }
 
+
   /* Move widget on the botton right corner of main widget */
   int x, y ;
   mySMESHGUI->DefineDlgPosition(this, x, y);
@@ -120,19 +121,22 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
                 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
      mySMESHGUI( theModule ),
      mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
-     myViewWindow( SMESH::GetViewWindow( theModule ) ),
-     mySelector( myViewWindow->GetSelector() ),
+     mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
      myIsBusy( false )
 {
   if (!name) setName("SMESHGUI_GroupDlg");
+
   initDialog(false);
   if (!theGroup->_is_nil())
     init(theGroup);
   else {
     mySelectSubMesh->setEnabled(false);
     mySelectGroup->setEnabled(false);
-  }
 
+    myCurrentLineEdit = myMeshGroupLine;
+    setSelectionMode(5);
+  }
+  
   /* Move widget on the botton right corner of main widget */
   int x, y ;
   mySMESHGUI->DefineDlgPosition(this, x, y);
@@ -149,7 +153,7 @@ void SMESHGUI_GroupDlg::initDialog(bool create)
   myCreate = create;
   myCurrentLineEdit = 0;
 
-  QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
+  QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
 
   if (create)
     setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
@@ -532,7 +536,7 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
     return;
 
   if (mySelectionMode != theMode) {
-    mySelectionMgr->clearSelected();
+    // [PAL10408] mySelectionMgr->clearSelected();
     mySelectionMgr->clearFilters();
     SMESH::SetPointRepresentation(false);
     if (theMode < 4) {
@@ -542,25 +546,30 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
           myActor->SetPointRepresentation(true);
         else
           SMESH::SetPointRepresentation(true);
-       myViewWindow->SetSelectionMode(NodeSelection);
+       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+         aViewWindow->SetSelectionMode(NodeSelection);
        break;
       case 1:
-       myViewWindow->SetSelectionMode(EdgeSelection);
+       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+         aViewWindow->SetSelectionMode(EdgeSelection);
        break;
       case 2:
-       myViewWindow->SetSelectionMode(FaceSelection);
+       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+         aViewWindow->SetSelectionMode(FaceSelection);
        break;
       default:
-        myViewWindow->SetSelectionMode(VolumeSelection);
+       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+         aViewWindow->SetSelectionMode(VolumeSelection);
       }
     } else {
-      myViewWindow->SetSelectionMode(ActorSelection);
       if (theMode == 4)
        mySelectionMgr->installFilter(mySubMeshFilter);
       else if (theMode == 5)
        mySelectionMgr->installFilter(myGroupFilter);
       else if (theMode == 6)
        mySelectionMgr->installFilter(myMeshFilter);
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+       aViewWindow->SetSelectionMode(ActorSelection);
     }
     mySelectionMode = theMode;
   }
@@ -706,7 +715,6 @@ void SMESHGUI_GroupDlg::onListSelectionChanged()
     SALOME_ListIO aList;
     aList.Append(myActor->getIO());
     mySelectionMgr->setSelectedObjects(aList,false);
-    myViewWindow->highlight( myActor->getIO(), true, true );
   }
   myIsBusy = false;
 }
@@ -744,7 +752,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
 
       myElements->clear();
 
-      if (aNbSel == 0 ) {
+      if (aNbSel != 1 ) {
         myGroup = SMESH::SMESH_Group::_nil();
         myMesh = SMESH::SMESH_Mesh::_nil();
         myIsBusy = false;
@@ -805,7 +813,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
       return;
 
     } else if (myCurrentLineEdit == myGeomGroupLine) {
-      if (aNbSel == 0) {
+      if (aNbSel != 1) {
         myGeomGroup = GEOM::GEOM_Object::_nil();
         myIsBusy = false;
         return;
@@ -833,7 +841,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
         aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup);
       _PTR(SObject) aGroupMainShapeSO =
         //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
-        aStudy->FindObjectIOR(aGroupMainShape->GetStudyEntry());
+        aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
 
       // The mesh SObject
       _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
@@ -885,7 +893,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
     updateButtons();
 
   } else {
-    if (aNbSel == 1) {
+    if (aNbSel == 1 && myActor ) {
       QString aListStr = "";
       int aNbItems = 0;
       if (myTypeId == 0) {
@@ -1085,12 +1093,27 @@ void SMESHGUI_GroupDlg::onAdd()
 
   SMESH::ElementType aType = SMESH::ALL;
   switch(myTypeId) {
-  case 0: aType = SMESH::NODE; break;
-  case 1: aType = SMESH::EDGE; break;
-  case 2: aType = SMESH::FACE; break;
-  case 3: aType = SMESH::VOLUME; break;
+  case 0: 
+    aType = SMESH::NODE; 
+    mySelector->SetSelectionMode(NodeSelection);
+    break;
+  case 1: 
+    aType = SMESH::EDGE; 
+    mySelector->SetSelectionMode(EdgeSelection);
+    break;
+  case 2: 
+    aType = SMESH::FACE; 
+    mySelector->SetSelectionMode(FaceSelection);
+    break;
+  case 3: 
+    aType = SMESH::VOLUME; 
+    mySelector->SetSelectionMode(VolumeSelection);
+    break;
+  default:
+    mySelector->SetSelectionMode(ActorSelection);
   }
 
+
   if (myCurrentLineEdit == 0) {
     //if (aNbSel != 1) { myIsBusy = false; return; }
     QString aListStr = "";
@@ -1198,7 +1221,7 @@ void SMESHGUI_GroupDlg::onAdd()
     if (aGroupType == aType) {
       _PTR(SObject) aGroupSO =
         //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
-        aStudy->FindObjectIOR(myGeomGroup->GetStudyEntry());
+        aStudy->FindObjectID(myGeomGroup->GetStudyEntry());
       // Construct filter
       SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
       SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
@@ -1391,7 +1414,8 @@ void SMESHGUI_GroupDlg::onClose()
   }
 
   mySelectionMgr->clearSelected();
-  myViewWindow->SetSelectionMode(ActorSelection);
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    aViewWindow->SetSelectionMode(ActorSelection);
   mySelectionMgr->clearFilters();
   mySMESHGUI->ResetState();