Salome HOME
PAL10332 - references are interpreted as original objects in filters, dialogs, etc.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ExtrusionAlongPathDlg.cxx
index 46222594ed97e7242cc0c7d3c3bd6ad8bdbb440a..3e84be424a3d3c3957d164cdae29aa3ea8ff6ab5 100644 (file)
@@ -97,15 +97,14 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod
      : QDialog( SMESH::GetDesktop( theModule ), "SMESHGUI_ExtrusionAlongPathDlg", modal,
                 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
      mySMESHGUI( theModule ),
-     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
-     myViewWindow( SMESH::GetViewWindow( theModule ) ),
-     mySelector( myViewWindow->GetSelector() )
+     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
 {
-  QPixmap edgeImage   (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
-  QPixmap faceImage   (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
-  QPixmap selectImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
-  QPixmap addImage    (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_APPEND")));
-  QPixmap removeImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_REMOVE")));
+  SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
+  QPixmap edgeImage   ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
+  QPixmap faceImage   ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
+  QPixmap selectImage ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
+  QPixmap addImage    ( mgr->loadPixmap("SMESH", tr("ICON_APPEND")));
+  QPixmap removeImage ( mgr->loadPixmap("SMESH", tr("ICON_REMOVE")));
 
   myType = -1;
 
@@ -316,6 +315,8 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod
   ZSpin->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
   AngleSpin->RangeStepAndValidator(-999999.999, +999999.999, 5.0, 3);
 
+  mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
+
   mySMESHGUI->SetActiveDialogBox(this);
 
   // Costruction of the logical filter for the elements: mesh/sub-mesh/group
@@ -447,13 +448,20 @@ void SMESHGUI_ExtrusionAlongPathDlg::ConstructorsClicked (int type)
 
     SMESH::SetPointRepresentation(false);
     if (MeshCheck->isChecked()) {
-      myViewWindow->SetSelectionMode(ActorSelection);
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+       aViewWindow->SetSelectionMode(ActorSelection);
       mySelectionMgr->installFilter(myElementsFilter);
     } else {
       if (type == 0)
-        myViewWindow->SetSelectionMode(EdgeSelection);
+       {
+         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+           aViewWindow->SetSelectionMode(EdgeSelection);
+       }
       if (type == 1)
-        myViewWindow->SetSelectionMode(FaceSelection);
+       {
+         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+           aViewWindow->SetSelectionMode(FaceSelection);
+       }
     }
   }
   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
@@ -659,7 +667,8 @@ void SMESHGUI_ExtrusionAlongPathDlg::reject()
   mySelectionMgr->clearSelected();
   SMESH::SetPickable(); // ???
   SMESH::SetPointRepresentation(false);
-  myViewWindow->SetSelectionMode(ActorSelection);
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    aViewWindow->SetSelectionMode(ActorSelection);
   mySMESHGUI->ResetState();
   QDialog::reject();
 }
@@ -697,9 +706,7 @@ void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText)
       QStringList aListId = QStringList::split(" ", theNewText, false);
       bool bOk;
       const Handle(SALOME_InteractiveObject)& anIO = myMeshActor->getIO();
-      TColStd_IndexedMapOfInteger selectedIndices;
       TColStd_MapOfInteger newIndices;
-      mySelector->GetIndex(anIO, selectedIndices);
       for (int i = 0; i < aListId.count(); i++) {
        long ind = aListId[ i ].toLong(&bOk);
        if (bOk) {
@@ -708,18 +715,14 @@ void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText)
            // check also type of element
            bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge ||
                             Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
-           if (typeMatch) {
-             if (selectedIndices.Add(e->GetID())) {
-                newIndices.Add(e->GetID());
-              }
-           }
+           if (typeMatch)
+             newIndices.Add(e->GetID());
          }
        }
       }
-      if (newIndices.Extent() > 0) {
-        mySelector->AddOrRemoveIndex(anIO, newIndices, true);
-       myViewWindow->highlight( anIO, true, true );
-      }
+      mySelector->AddOrRemoveIndex(anIO, newIndices, false);
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+       aViewWindow->highlight( anIO, true, true );
     }
   } else if (send == StartPointLineEdit &&
              myEditCurrentArgument == StartPointLineEdit) {
@@ -741,14 +744,11 @@ void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText)
          const SMDS_MeshNode* n = aMesh->FindNode(ind);
          if (n) {
            //if (!mySelectionMgr->IsIndexSelected(aPathActor->getIO(), n->GetID())) {
-            TColStd_IndexedMapOfInteger selectedIndices;
             TColStd_MapOfInteger newIndices;
-            mySelector->GetIndex(aPathActor->getIO(), selectedIndices);
-            if (selectedIndices.Add(n->GetID())) {
-              newIndices.Add(n->GetID());
-             mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, true );
-             myViewWindow->highlight( aPathActor->getIO(), true, true );
-           }
+           newIndices.Add(n->GetID());
+           mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, false );
+           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+             aViewWindow->highlight( aPathActor->getIO(), true, true );
          }
        }
       }
@@ -950,24 +950,33 @@ void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button
     myEditCurrentArgument = ElementsLineEdit;
     SMESH::SetPointRepresentation(false);
     if (MeshCheck->isChecked()) {
-      myViewWindow->SetSelectionMode(ActorSelection);
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+       aViewWindow->SetSelectionMode(ActorSelection);
       mySelectionMgr->installFilter(myElementsFilter);
     } else {
       if (Elements1dRB->isChecked())
-       myViewWindow->SetSelectionMode(EdgeSelection);
+       {
+         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+           aViewWindow->SetSelectionMode(EdgeSelection);
+       }
       else if (Elements2dRB->isChecked())
-       myViewWindow->SetSelectionMode(FaceSelection);
+       {
+         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+           aViewWindow->SetSelectionMode(FaceSelection);
+       }
     }
   } else if (button == SelectPathMeshButton) {
     myEditCurrentArgument = PathMeshLineEdit;
     SMESH::SetPointRepresentation(false);
-    myViewWindow->SetSelectionMode(ActorSelection);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(ActorSelection);
     mySelectionMgr->installFilter(myPathMeshFilter);
   }
   else if (button == SelectPathShapeButton) {
     myEditCurrentArgument = PathShapeLineEdit;
     SMESH::SetPointRepresentation(false);
-    myViewWindow->SetSelectionMode(ActorSelection);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(ActorSelection);
 
     if (!myPathMesh->_is_nil()) {
       GEOM::GEOM_Object_var aMainShape = myPathMesh->GetShapeToMesh();
@@ -985,7 +994,8 @@ void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button
       SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPathMesh);
       if (aPathActor) {
        SMESH::SetPointRepresentation(true);
-       myViewWindow->SetSelectionMode(NodeSelection);
+       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+         aViewWindow->SetSelectionMode(NodeSelection);
        SMESH::SetPickable(aPathActor);
       }
     }
@@ -993,7 +1003,8 @@ void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button
   else if (button == SelectBasePointButton) {
     myEditCurrentArgument = XSpin;
     SMESH::SetPointRepresentation(true);
-    myViewWindow->SetSelectionMode(NodeSelection);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(NodeSelection);
 
     SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH);
     SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter(GROUP);