Salome HOME
bos #20256: [CEA 18523] Porting SMESH to int 64 bits
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_CreatePolyhedralVolumeDlg.cxx
index 8b52bb3f98ee64a6cd81fd94b2f4848232963247..ef6949db3e559a8d6e35eff7a977fb340819a8e7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -49,6 +49,8 @@
 #include <SalomeApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 
+#include "utilities.h"
+
 #include <SVTK_ViewWindow.h>
 
 // OCCT includes
@@ -300,7 +302,7 @@ SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI
  
   mySMESHGUI->SetActiveDialogBox( (QDialog*)this );
 
-  myHelpFileName = "adding_nodes_and_elements_page.html#adding_polyhedrons_anchor";
+  myHelpFileName = "adding_nodes_and_elements.html#adding-polyhedrons-anchor";
   
   Init();
 }
@@ -351,8 +353,9 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::Init()
   connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
   connect( Preview, SIGNAL(toggled(bool)), this, SLOT(ClickOnPreview(bool)));
   /* to close dialog if study change */
-  connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( reject() ) );
-  
+  connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ),      this, SLOT( reject() ) );
+  connect( mySMESHGUI, SIGNAL ( SignalActivatedViewManager() ), this, SLOT( onOpenView() ) );
+  connect( mySMESHGUI, SIGNAL ( SignalCloseView() ),            this, SLOT( onCloseView() ) );
   ConstructorsClicked(0);
   SelectionIntoArgument();
 }
@@ -445,7 +448,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
   if( !isValid() )
     return;
 
-  if ( myNbOkElements>0 && !mySMESHGUI->isActiveStudyLocked())
+  if ( myNbOkElements>0 && !SMESHGUI::isStudyLocked())
     {
       if(checkEditLine(false) == -1) {return;}
       busy = true;
@@ -477,7 +480,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
 
       if (GetConstructorId() == 0)
         {
-          SMESH::long_array_var anIdsOfNodes = new SMESH::long_array;
+          SMESH::smIdType_array_var anIdsOfNodes = new SMESH::smIdType_array;
           SMESH::long_array_var aQuantities  = new SMESH::long_array;
 
           aQuantities->length( myFacesByNodes->count() );
@@ -515,7 +518,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
         }
       else if (GetConstructorId() == 1)
         {
-          SMESH::long_array_var anIdsOfFaces = new SMESH::long_array;
+          SMESH::smIdType_array_var anIdsOfFaces = new SMESH::smIdType_array;
           
           QStringList aListId = myEditCurrentArgument->text().split( " ", QString::SkipEmptyParts );
           anIdsOfFaces->length(aListId.count());
@@ -559,7 +562,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
         }
         
         if ( !aGroupUsed->_is_nil() ) {
-          SMESH::long_array_var anIdList = new SMESH::long_array;
+          SMESH::smIdType_array_var anIdList = new SMESH::smIdType_array;
           anIdList->length( 1 );
           anIdList[0] = anElemId;
           aGroupUsed->Add( anIdList.inout() );
@@ -611,6 +614,36 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::reject()
   QDialog::reject();
 }
 
+//=================================================================================
+// function : onOpenView()
+// purpose  :
+//=================================================================================
+void SMESHGUI_CreatePolyhedralVolumeDlg::onOpenView()
+{
+  if ( mySelector && mySimulation ) {
+    mySimulation->SetVisibility(false);
+    SMESH::SetPointRepresentation(false);
+  }
+  else {
+    mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
+    mySimulation = new SMESH::TPolySimulation(
+      dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );
+    ActivateThisDialog();
+  }
+}
+
+//=================================================================================
+// function : onCloseView()
+// purpose  :
+//=================================================================================
+void SMESHGUI_CreatePolyhedralVolumeDlg::onCloseView()
+{
+  DeactivateActiveDialog();
+  mySelector = 0;
+  delete mySimulation;
+  mySimulation = 0;
+}
+
 //=================================================================================
 // function : ClickOnHelp()
 // purpose  :
@@ -655,7 +688,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText)
   if (GetConstructorId() == 0)
     {
       if ( aMesh ) {
-        TColStd_MapOfInteger newIndices;
+        SVTK_TVtkIDsMap newIndices;
       
         QStringList aListId = theNewText.split( " ", QString::SkipEmptyParts );
         for ( int i = 0; i < aListId.count(); i++ ) {
@@ -684,10 +717,10 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText)
         buttonOk->setEnabled( false );
         buttonApply->setEnabled( false );
       
-        // check entered ids of faces and hilight them
+        // check entered ids of faces and highlight them
         QStringList aListId;
         if ( aMesh ) {
-          TColStd_MapOfInteger newIndices;
+          SVTK_TVtkIDsMap newIndices;
       
           aListId = theNewText.split( " ", QString::SkipEmptyParts );
 
@@ -1025,16 +1058,21 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ActivateThisDialog()
   SelectionIntoArgument();
 }
 
-
 //=================================================================================
 // function : enterEvent()
 // purpose  :
 //=================================================================================
-void SMESHGUI_CreatePolyhedralVolumeDlg::enterEvent(QEvent* e)
+void SMESHGUI_CreatePolyhedralVolumeDlg::enterEvent (QEvent*)
 {
-  if ( ConstructorsBox->isEnabled() )
-    return;  
-  ActivateThisDialog();
+  if ( !ConstructorsBox->isEnabled() ) {
+    SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+    if ( aViewWindow && !mySelector && !mySimulation) {
+      mySelector = aViewWindow->GetSelector();
+      mySimulation = new SMESH::TPolySimulation(
+        dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );
+    }
+    ActivateThisDialog();
+  }
 }
 
 //=================================================================================
@@ -1109,7 +1147,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onListSelectionChanged()
 
   SALOME_ListIO aList;
   mySelectionMgr->setSelectedObjects( aList );
-  TColStd_MapOfInteger aIndexes;
+  SVTK_TVtkIDsMap aIndexes;
 
   QList<QListWidgetItem*> selItems = myFacesByNodes->selectedItems();
   QListWidgetItem* anItem;