Salome HOME
PAL10406. Enable myNodes when a pattern is loaded. UpdatePreview() when elements...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshPatternDlg.cxx
index ecd3c522ac29a48bcae2caa1265538f86eee1a42..a3a862b00609ce6a7074cfde7e6087f2f619ca39 100755 (executable)
@@ -47,7 +47,7 @@
 #include "SUIT_Desktop.h"
 #include "SUIT_FileDlg.h"
 
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_SelectionMgr.h"
 #include "SalomeApp_Tools.h"
 #include "SalomeApp_Study.h"
 
@@ -110,9 +110,7 @@ SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI*   theModule,
                 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
        myBusy(false),
        mySMESHGUI( theModule ),
-       mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
-       myViewWindow( SMESH::GetViewWindow( theModule ) ),
-       mySelector( myViewWindow->GetSelector() )
+       mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
 {
   setCaption(tr("CAPTION"));
 
@@ -127,6 +125,9 @@ SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI*   theModule,
   aDlgLay->setStretchFactor(aMainFrame, 1);
 
   myCreationDlg = 0;
+
+  mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
+
   Init();
 }
 
@@ -414,7 +415,6 @@ bool SMESHGUI_MeshPatternDlg::onApply()
     bool toCreatePolyedrs = myCreatePolyedrsChk->isChecked();
     if ( myPattern->MakeMesh( myMesh, toCreatePolygons, toCreatePolyedrs ) ) {
       mySelectionMgr->clearSelected();
-      SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
       bool autoUpdate = SMESHGUI::automaticUpdate();
       if (!isRefine() && autoUpdate) {
        _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
@@ -428,7 +428,7 @@ bool SMESHGUI_MeshPatternDlg::onApply()
        }
       }
       SMESH::UpdateView();
-      
+
       mySMESHGUI->updateObjBrowser(true);
       return true;
     } else {
@@ -462,7 +462,8 @@ void SMESHGUI_MeshPatternDlg::onClose()
 {
   mySelectionMgr->clearFilters();
   SMESH::SetPickable();
-  myViewWindow->SetSelectionMode(ActorSelection);
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+    aViewWindow->SetSelectionMode(ActorSelection);
   disconnect(mySelectionMgr, 0, this, 0);
   disconnect(mySMESHGUI, 0, this, 0);
   mySMESHGUI->ResetState();
@@ -738,7 +739,10 @@ void SMESHGUI_MeshPatternDlg::onOkCreationDlg()
 {
   myPattern = SMESH::SMESH_Pattern::_duplicate(myCreationDlg->GetPattern());
   myName->setText(myCreationDlg->GetPatternName());
+
+  updateWgState();
   displayPreview();
+
   setEnabled(true);
   myIsCreateDlgOpen = false;
 }
@@ -932,7 +936,7 @@ void SMESHGUI_MeshPatternDlg::updateWgState()
     }
 
     QValueList<int> ids;
-    if (!CORBA::is_nil(myPattern) && getIds(ids)) {
+    if (!CORBA::is_nil(myPattern)/* && getIds(ids)*/) {
       SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
       if (keyPoints->length()) {
        myNode1->setEnabled(true);
@@ -963,14 +967,21 @@ void SMESHGUI_MeshPatternDlg::activateSelection()
       SMESH::SetPickable(anActor);
 
     if (myType == Type_2d)
-      myViewWindow->SetSelectionMode(FaceSelection);
+      {
+       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+         aViewWindow->SetSelectionMode(FaceSelection);
+      }
     else
-      myViewWindow->SetSelectionMode(CellSelection);
+      {
+       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+         aViewWindow->SetSelectionMode(CellSelection);
+      }
   }
   else {
     SMESH::SetPickable();
     //mySelectionMgr->setSelectionModes(ActorSelection);
-    myViewWindow->SetSelectionMode(ActorSelection);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(ActorSelection);
   }
 
   if (mySelInput == Object && !myMeshShape->_is_nil()) {
@@ -1256,19 +1267,22 @@ void SMESHGUI_MeshPatternDlg::onTextChanged (const QString& theNewText)
 
   if (aMesh) {
     QStringList aListId = QStringList::split(" ", theNewText, false);
-    
+
     TColStd_MapOfInteger newIndices;
-    
+
     for (int i = 0; i < aListId.count(); i++) {
       const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
       if (e && e->GetType() == (myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume))
        newIndices.Add(e->GetID());
     }
     mySelector->AddOrRemoveIndex( anActor->getIO(), newIndices, false);
-    myViewWindow->highlight( anActor->getIO(), true, true );
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->highlight( anActor->getIO(), true, true );
   }
 
   myBusy = false;
+
+  displayPreview();
 }
 
 //=======================================================================