Salome HOME
NPAL16812: Elements Info dialog is added. The size of dialog is modified.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.cxx
index 3a9d29b3df7a4351539c684bbef58c7829732d5b..a7e98a05e79c0f1ab4d70f1ddc0f187a8c220b3e 100644 (file)
@@ -35,6 +35,7 @@
 #include "SMESHGUI_HypothesesUtils.h"
 
 #include "SMDS_SetIterator.hxx"
+#include <SMDS_Mesh.hxx>
 
 #include "GEOMBase.h"
 #include "GEOM_Actor.h"
@@ -67,6 +68,8 @@
 #include <BRepBndLib.hxx>
 #include <BRepMesh_IncrementalMesh.hxx>
 
+#include <Standard_ErrorHandler.hxx>
+
 // QT Includes
 #include <qframe.h>
 #include <qlayout.h>
@@ -328,7 +331,7 @@ namespace SMESH {
       CASE2TEXT( COMPERR_BAD_INPUT_MESH);
       CASE2TEXT( COMPERR_STD_EXCEPTION );
       CASE2TEXT( COMPERR_OCC_EXCEPTION );
-      CASE2TEXT( COMPERR_SLM_EXCEPTION );
+    case SMESH::COMPERR_SLM_EXCEPTION: break; // avoid double "Salome exception"
       CASE2TEXT( COMPERR_EXCEPTION     );
       CASE2TEXT( COMPERR_MEMORY_PB     );
       CASE2TEXT( COMPERR_BAD_SHAPE     );
@@ -424,7 +427,7 @@ namespace SMESH {
   }
   // -----------------------------------------------------------------------
   /*!
-   * \brief Return text describing a subshape
+   * \brief Return a list of selected rows
    */
   bool getSelectedRows(QTable* table, list< int > & rows)
   {
@@ -437,6 +440,9 @@ namespace SMESH {
       for ( int row = selected.topRow(); row <= selected.bottomRow(); ++row )
         rows.push_back( row );
     }
+    if (rows.empty() && table->currentRow() > -1 )
+      rows.push_back( table->currentRow() );
+
     return !rows.empty();
   }
 
@@ -759,6 +765,7 @@ SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
   connect(myDlg->myShowBtn,    SIGNAL (clicked()), SLOT(onPreviewShape()));
   connect(myDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
   connect(table(),SIGNAL(selectionChanged()), SLOT(currentCellChanged()));
+  connect(table(),SIGNAL(currentChanged(int,int)), SLOT(currentCellChanged()));
 }
 
 //=======================================================================
@@ -778,7 +785,6 @@ void SMESHGUI_ComputeOp::startOperation()
   // COMPUTE MESH
 
   bool computeFailed = true, memoryLack = false;
-  int nbNodes = 0, nbEdges = 0, nbFaces = 0, nbVolums = 0;
 
   LightApp_SelectionMgr *Sel = selectionMgr();
   SALOME_ListIO selected; Sel->selectedObjects( selected );
@@ -814,6 +820,9 @@ void SMESHGUI_ComputeOp::startOperation()
       }
       SUIT_OverrideCursor aWaitCursor;
       try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+          OCC_CATCH_SIGNALS;
+#endif
         if (gen->Compute(aMesh, myMainShape))
           computeFailed = false;
       }
@@ -822,6 +831,9 @@ void SMESHGUI_ComputeOp::startOperation()
         //SalomeApp_Tools::QtCatchCorbaException(S_ex);
       }
       try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+          OCC_CATCH_SIGNALS;
+#endif
         anErrors = gen->GetComputeErrors( aMesh, myMainShape );
         //           if ( anErrors->length() == 0 ) {
         //             SUIT_MessageBox::warn1(desktop(),
@@ -832,44 +844,41 @@ void SMESHGUI_ComputeOp::startOperation()
         //             return;
         //           }
         // check if there are memory problems
-        for ( int i = 0; i < anErrors->length() && !memoryLack; ++i )
+        for ( int i = 0; (i < anErrors->length()) && !memoryLack; ++i )
           memoryLack = ( anErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
       }
       catch(const SALOME::SALOME_Exception & S_ex){
         memoryLack = true;
       }
 
-      if ( !memoryLack )
+      // NPAL16631: if ( !memoryLack )
       {
         SMESH::ModifiedMesh(aMeshSObj, !computeFailed, aMesh->NbNodes() == 0);
         update( UF_ObjBrowser | UF_Model );
 
         // SHOW MESH
-        try {
-          if ( getSMESHGUI()->automaticUpdate() ) {
-            SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(getSMESHGUI(), true);
-            if (aVTKView) {
-              int anId = study()->id();
-              TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
-              if (aVisualObj) {
-                aVisualObj->Update();
-                SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
-                if (!anActor) {
-                  anActor = SMESH::CreateActor(studyDS(), IObject->getEntry());
-                  if (anActor) {
-                    SMESH::DisplayActor(aVTKView, anActor); //apo
-                    SMESH::FitAll();
-                  }
-                }
-                SMESH::RepaintCurrentView();
-                Sel->setSelectedObjects( selected );
-              }
+        // NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
+        if ( !memoryLack && getSMESHGUI()->automaticUpdate() )
+        {
+          try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+            OCC_CATCH_SIGNALS;
+#endif
+            SMESH::Update(IObject, true);
+          }
+          catch (...) {
+#ifdef _DEBUG_
+            cout << "Exception thrown during mesh visualization" << endl;
+#endif
+            if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning?
+              SMESH::OnVisuException();
+            }
+            else {
+              memoryLack = true;
             }
           }
         }
-        catch (...) {
-          memoryLack = true;
-        }
+        Sel->setSelectedObjects( selected );
       }
     }
   }
@@ -897,6 +906,7 @@ void SMESHGUI_ComputeOp::startOperation()
   }
   else if ( noError )
   {
+    SUIT_OverrideCursor aWaitCursor;
     myDlg->myFullInfo->SetInfoByMesh( aMesh );
     myDlg->myFullInfo->show();
     myDlg->myBriefInfo->hide();