Salome HOME
Merge remote branch 'origin/V8_5_asterstudy'
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.cxx
index ad4453c1c749f7a27038896e64e2792daad9714f..e5ad4a878cabdd555a2d278a5b07ff91922dcba7 100644 (file)
@@ -54,6 +54,7 @@
 #include <SUIT_Session.h>
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
+#include <SVTK_Renderer.h>
 #include <SalomeApp_Application.h>
 
 // SALOME KERNEL includes
 
 // VTK includes
 #include <vtkProperty.h>
+#include <vtkRenderer.h>
 
 // STL includes
 #include <vector>
 #include <set>
 
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
 #include <sys/sysinfo.h>
 #endif
 
@@ -377,9 +379,7 @@ namespace SMESH
     _PTR(SObject) so = SMESH::FindSObject(aMainShape);
     if ( subShapeID == 1 || !so )
       return so;
-    _PTR(ChildIterator) it;
-    if (_PTR(Study) study = SMESH::GetActiveStudyDocument())
-      it =  study->NewChildIterator(so);
+    _PTR(ChildIterator) it = SMESH::getStudy()->NewChildIterator(so);
     _PTR(SObject) subSO;
     if ( it ) {
       for ( it->InitEx(true); !subSO && it->More(); it->Next() ) {
@@ -575,7 +575,11 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent, bool ForEval)
   myTable->hideColumn( COL_PUBLISHED );
   myTable->hideColumn( COL_SHAPEID );
   myTable->hideColumn( COL_BAD_MESH );
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
   myTable->horizontalHeader()->setResizeMode( COL_ERROR, QHeaderView::Interactive );
+#else
+  myTable->horizontalHeader()->setSectionResizeMode( COL_ERROR, QHeaderView::Interactive );
+#endif
   myTable->setWordWrap( true );
   myTable->horizontalHeader()->setStretchLastSection( true );
   myTable->setMinimumWidth( 500 );
@@ -653,7 +657,7 @@ SMESHGUI_BaseComputeOp::SMESHGUI_BaseComputeOp()
   myBadMeshDisplayer = 0;
 
   //myHelpFileName = "/files/about_meshes.htm"; // V3
-  myHelpFileName = "about_meshes_page.html"; // V4
+  myHelpFileName = "about_meshes.html"; // V4
 }
 
 SMESH::SMESH_Mesh_ptr SMESHGUI_BaseComputeOp::getMesh()
@@ -679,6 +683,7 @@ void SMESHGUI_BaseComputeOp::startOperation()
 
   myMesh      = SMESH::SMESH_Mesh::_nil();
   myMainShape = GEOM::GEOM_Object::_nil();
+  myCurShape  = GEOM::GEOM_Object::_nil();
 
   // check selection
   LightApp_SelectionMgr *Sel = selectionMgr();
@@ -694,7 +699,23 @@ void SMESHGUI_BaseComputeOp::startOperation()
   }
 
   myIObject = selected.First();
-  myMesh = SMESH::GetMeshByIO(myIObject);
+  CORBA::Object_var anObj = SMESH::IObjectToObject( myIObject );
+
+  myMesh = SMESH::SMESH_Mesh::_narrow(anObj);
+  if ( myMesh->_is_nil() )
+  {
+    SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj);
+    if ( !aSubMesh->_is_nil() )
+    {
+      myMesh      = aSubMesh->GetFather();
+      myCurShape  = aSubMesh->GetSubShape();
+    }
+  }
+  else
+  {
+    myCurShape = myMesh->GetShapeToMesh();
+  }
+
   if (myMesh->_is_nil()) {
     SUIT_MessageBox::warning(desktop(),
                              tr("SMESH_WRN_WARNING"),
@@ -702,6 +723,7 @@ void SMESHGUI_BaseComputeOp::startOperation()
     onCancel();
     return;
   }
+
   myMainShape = myMesh->GetShapeToMesh();
 
   SMESHGUI_Operation::startOperation();
@@ -762,7 +784,7 @@ SMESHGUI_ComputeDlg_QThreadQDialog(QWidget             * parent,
   QLabel * nbElemsName = new QLabel(tr("SMESH_MESHINFO_ELEMENTS"), this );
   nbNodesLabel = new QLabel("0", this );
   nbElemsLabel = new QLabel("0", this );
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
   QLabel * freeRAMName = new QLabel(tr("SMESH_FREERAM"), this );
   freeRAMLabel = new QLabel("", this );
 #endif
@@ -778,7 +800,7 @@ SMESHGUI_ComputeDlg_QThreadQDialog(QWidget             * parent,
   layout->addWidget(nbNodesLabel, row++, 1);
   layout->addWidget(nbElemsName,  row,   0);
   layout->addWidget(nbElemsLabel, row++, 1);
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
   layout->addWidget(freeRAMName,  row,   0);
   layout->addWidget(freeRAMLabel, row++, 1);
 #endif
@@ -818,7 +840,7 @@ void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event)
   {
     nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() ));
     nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() ));
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
     struct sysinfo si;
     const int err = sysinfo( &si );
     if ( err )
@@ -878,10 +900,8 @@ void SMESHGUI_BaseComputeOp::computeMesh()
       myMesh->Clear();
     SUIT_OverrideCursor aWaitCursor;
     try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
       OCC_CATCH_SIGNALS;
-#endif
-      SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape);
+      SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myCurShape);
       qthreaddialog.exec();
       computeFailed = !qthreaddialog.result();
     }
@@ -889,9 +909,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
       memoryLack = true;
     }
     try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
       OCC_CATCH_SIGNALS;
-#endif
       aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
       // check if there are memory problems
       for ( CORBA::ULong i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
@@ -907,9 +925,6 @@ void SMESHGUI_BaseComputeOp::computeMesh()
 
     // NPAL16631: if ( !memoryLack )
     {
-      SMESH::ModifiedMesh( aMeshSObj,
-                           !computeFailed && aHypErrors.isEmpty(),
-                           myMesh->NbNodes() == 0);
       update( UF_ObjBrowser | UF_Model );
 
       // SHOW MESH
@@ -949,10 +964,8 @@ void SMESHGUI_BaseComputeOp::computeMesh()
         {
           SMESH::SMESH_GroupBase_var aGrp = aGroups[i];
           if ( CORBA::is_nil( aGrp ) ) continue;
-          SMESH::SMESH_Group_var         aStdGroup  = SMESH::SMESH_Group::_narrow( aGrp );
-          SMESH::SMESH_GroupOnGeom_var   aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGrp );
-          SMESH::SMESH_GroupOnFilter_var aFltGroup  = SMESH::SMESH_GroupOnFilter::_narrow( aGrp );
-          if ( !aStdGroup->_is_nil() ) continue; // don't update the standalone groups
+          SMESH::SMESH_Group_var  aStdGroup  = SMESH::SMESH_Group::_narrow( aGrp );
+          if ( !aStdGroup->_is_nil() ) continue; // don't update standalone groups
           _PTR(SObject) aGroupSO = SMESH::FindSObject( aGrp );
           if ( !aGroupSO ) continue;
           SMESH::SMESH_IDSource_var aGroupObj =
@@ -979,8 +992,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
               {
                 toDisplay = true;
                 SMESH_Actor *anActor = SMESH::FindActorByObject( aMesh );
-                if ( !anActor ) anActor = SMESH::CreateActor( (*anIter).second->GetStudy(),
-                                                              (*anIter).second->GetID().c_str(),
+                if ( !anActor ) anActor = SMESH::CreateActor( (*anIter).second->GetID().c_str(),
                                                               /*clearLog =*/ true );
                 if ( anActor ) // actor is not created for an empty mesh
                 {
@@ -992,6 +1004,10 @@ void SMESHGUI_BaseComputeOp::computeMesh()
                 ( (*anIter).second->GetID().c_str(), "SMESH", (*anIter).second->GetName().c_str() );
               SMESH::Update(anIO, toDisplay);
 
+              if ( SVTK_ViewWindow* vtkWnd = SMESH::GetVtkViewWindow(SMESH::GetActiveWindow() ))
+                if ( vtkWnd->getRenderer() )
+                  vtkWnd->getRenderer()->ResetCameraClippingRange();
+
               if ( limitExceeded && !aMesh->_is_nil() )
               {
                 QStringList hiddenMsg;
@@ -1209,7 +1225,7 @@ void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
       currentCellChanged(); // to update buttons
     }
   }
-  // show dialog and wait, becase Compute can be invoked from Preview operation
+  // show dialog and wait, because Compute can be invoked from Preview operation
   //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
   aCompDlg->show();
 }
@@ -1243,8 +1259,8 @@ void SMESHGUI_BaseComputeOp::stopOperation()
 
 void SMESHGUI_BaseComputeOp::onPublishShape()
 {
-  GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
-  SALOMEDS::Study_var study = SMESHGUI::GetSMESHGen()->GetCurrentStudy();
+  GEOM::GEOM_Gen_var      geomGen = SMESH::GetGEOMGen();
+  GEOM::GEOM_Object_var meshShape = myMesh->GetShapeToMesh();
 
   QStringList entryList;
   QList<int> rows;
@@ -1259,8 +1275,8 @@ void SMESHGUI_BaseComputeOp::onPublishShape()
       if ( !SMESH::getSubShapeSO( 1, myMainShape )) // the main shape not published
       {
         QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( myMainShape, "MAIN_SHAPE" ));
-        SALOMEDS::SObject_wrap so = geomGen->AddInStudy( study, myMainShape,
-                                                         name.toLatin1().data(),
+        SALOMEDS::SObject_wrap so = geomGen->AddInStudy( myMainShape,
+                                                         name.toUtf8().data(),
                                                          GEOM::GEOM_Object::_nil());
         // look for myMainShape in the table
         for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
@@ -1278,8 +1294,8 @@ void SMESHGUI_BaseComputeOp::onPublishShape()
         if ( curSub == 1 ) continue;
       }
       QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( shape, "ERROR_SHAPE" ));
-      SALOMEDS::SObject_wrap so = geomGen->AddInStudy( study, shape,
-                                                       name.toLatin1().data(), myMainShape);
+      SALOMEDS::SObject_wrap so = geomGen->AddInStudy( shape,
+                                                       name.toUtf8().data(), myMainShape);
       if ( !so->_is_nil() ) {
         CORBA::String_var name  = so->GetName();
         CORBA::String_var entry = so->GetID();
@@ -1350,7 +1366,7 @@ void SMESHGUI_BaseComputeOp::onGroupOfBadMesh()
       else                    grName = "bad mesh of " + grName;
       SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
       SMESH::ListOfGroups_var groups
-        ( gen->MakeGroupsOfBadInputElements(myMesh,curSub,grName.toLatin1().data()) );
+        ( gen->MakeGroupsOfBadInputElements(myMesh,curSub,grName.toUtf8().data()) );
       update( UF_ObjBrowser | UF_Model );
       if( LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( application() ))
       {
@@ -1509,13 +1525,13 @@ QTableWidget* SMESHGUI_BaseComputeOp::table()
 SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
  : SMESHGUI_BaseComputeOp()
 {
-  myHelpFileName = "constructing_meshes_page.html#compute_anchor";
+  myHelpFileName = "constructing_meshes.html#compute-anchor";
 }
 
 
 //================================================================================
 /*!
- * \brief Desctructor
+ * \brief Destructor
 */
 //================================================================================
 
@@ -1619,7 +1635,7 @@ LightApp_Dialog* SMESHGUI_PrecomputeOp::dlg() const
 
 void SMESHGUI_PrecomputeOp::startOperation()
 {
-  myHelpFileName = "constructing_meshes_page.html#preview_anchor"; // other anchor onCompute()
+  myHelpFileName = "constructing_meshes.html#preview-anchor"; // other anchor onCompute()
 
   if ( !myDlg )
   {
@@ -1719,7 +1735,7 @@ void SMESHGUI_PrecomputeOp::initDialog()
   QList<int> modes;
 
   QMap<int, int> modeMap;
-  _PTR(SObject)  pMesh = studyDS()->FindObjectID( myIObject->getEntry() );
+  _PTR(SObject)  pMesh = SMESH::getStudy()->FindObjectID( myIObject->getEntry() );
   getAssignedAlgos( pMesh, modeMap );
   if ( modeMap.contains( SMESH::DIM_3D ) )
   {
@@ -1748,21 +1764,21 @@ void SMESHGUI_PrecomputeOp::initDialog()
 
 //================================================================================
 /*!
- * \brief detect asigned mesh algorithms
+ * \brief detect assigned mesh algorithms
  */
 //================================================================================
 
-void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject) theMesh,
+void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject)  theMesh,
                                              QMap<int,int>& theModeMap)
 {
   if ( !theMesh ) return;
+
   _PTR(SObject)          aHypFolder;
   _PTR(GenericAttribute) anAttr;
   int aPart = SMESH::Tag_RefOnAppliedAlgorithms;
-  if ( theMesh->FindSubObject( aPart, aHypFolder ) )
+  if ( theMesh->FindSubObject( aPart, aHypFolder ))
   {
-    _PTR(ChildIterator) anIter =
-      SMESH::GetActiveStudyDocument()->NewChildIterator( aHypFolder );
+    _PTR(ChildIterator) anIter = SMESH::getStudy()->NewChildIterator( aHypFolder );
     for ( ; anIter->More(); anIter->Next() )
     {
       _PTR(SObject) anObj = anIter->Value();
@@ -1805,8 +1821,7 @@ void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject) theMesh,
     if ( !theMesh->FindSubObject( aPart, aHypFolder ))
       continue;
 
-    _PTR(ChildIterator) anIter =
-      SMESH::GetActiveStudyDocument()->NewChildIterator( aHypFolder );
+    _PTR(ChildIterator) anIter = SMESH::getStudy()->NewChildIterator( aHypFolder );
     for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
     {
       _PTR(SObject) anObj = anIter->Value();
@@ -1857,7 +1872,7 @@ void SMESHGUI_PrecomputeOp::onCompute()
     myOrderMgr->SetMeshOrder();
   myMapShapeId.clear();
   myActiveDlg = computeDlg();
-  myHelpFileName = "constructing_meshes_page.html#compute_anchor";
+  myHelpFileName = "constructing_meshes.html#compute-anchor";
   computeMesh();
 }
 
@@ -1959,9 +1974,7 @@ void SMESHGUI_PrecomputeOp::onPreview()
   
   SMESH::long_array_var aShapesId = new SMESH::long_array();
   try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
     OCC_CATCH_SIGNALS;
-#endif
       
     SMESH::MeshPreviewStruct_var previewData =
       gen->Precompute(myMesh, myMainShape, (SMESH::Dimension)dim, aShapesId);
@@ -1971,7 +1984,7 @@ void SMESHGUI_PrecomputeOp::onPreview()
     {
       computeFailed = false;
       myPreviewDisplayer->SetData( previewRes );
-      // append shape indeces with computed mesh entities
+      // append shape indices with computed mesh entities
       for ( int i = 0, n = aShapesId->length(); i < n; i++ )
         myMapShapeId[ aShapesId[ i ] ] = 0;
     }
@@ -1984,9 +1997,7 @@ void SMESHGUI_PrecomputeOp::onPreview()
   }
 
   try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
     OCC_CATCH_SIGNALS;
-#endif
     aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
     // check if there are memory problems
     for ( CORBA::ULong i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
@@ -2103,7 +2114,7 @@ void SMESHGUI_PrecomputeDlg::setPreviewModes( const QList<int>& theModes )
 
 int SMESHGUI_PrecomputeDlg::getPreviewMode() const
 {
-  return myPreviewMode->currentId();
+  return myPreviewMode->currentId().toInt();
 }
 
 //================================================================================
@@ -2127,13 +2138,13 @@ SMESHGUI_MeshOrderBox* SMESHGUI_PrecomputeDlg::getMeshOrderBox() const
 SMESHGUI_EvaluateOp::SMESHGUI_EvaluateOp()
  : SMESHGUI_BaseComputeOp()
 {
-  myHelpFileName = "constructing_meshes_page.html#evaluate_anchor";
+  myHelpFileName = "constructing_meshes.html#evaluate-anchor";
 }
 
 
 //================================================================================
 /*!
- * \brief Desctructor
+ * \brief Destructor
 */
 //================================================================================
 
@@ -2202,9 +2213,7 @@ void SMESHGUI_BaseComputeOp::evaluateMesh()
     }
     SUIT_OverrideCursor aWaitCursor;
     try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
       OCC_CATCH_SIGNALS;
-#endif
       aRes = gen->Evaluate(myMesh, myMainShape);
     }
     catch(const SALOME::SALOME_Exception & S_ex){
@@ -2212,9 +2221,7 @@ void SMESHGUI_BaseComputeOp::evaluateMesh()
     }
 
     try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
       OCC_CATCH_SIGNALS;
-#endif
       aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
     }
     catch(const SALOME::SALOME_Exception & S_ex){
@@ -2372,7 +2379,7 @@ void SMESHGUI_BaseComputeOp::showEvaluateResult(const SMESH::long_array& theRes,
       currentCellChanged(); // to update buttons
     }
   }
-  // show dialog and wait, becase Compute can be invoked from Preview operation
+  // show dialog and wait, because Compute can be invoked from Preview operation
   //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
   aCompDlg->show();
 }