Salome HOME
Update the "Colors / Size" dialog.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.cxx
index 5b7fc580f9242e07e49c97fa4bac651719830051..676a3648e64481884e21ce3a542c22c7d2768514 100644 (file)
@@ -1,20 +1,20 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  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.
+// 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.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 // File   : SMESHGUI_ComputeDlg.cxx
@@ -349,6 +349,8 @@ namespace SMESH
       if ( strlen(comment) == 0 )
         text = QObject::tr("COMPERR_ALGO_FAILED");
       break;
+    case SMESH::COMPERR_WARNING:
+      return comment ? QString(comment) : QObject::tr("COMPERR_UNKNOWN");
     default:
       text = QString("#%1").arg( -errCode );
     }
@@ -357,7 +359,7 @@ namespace SMESH
   }
   // -----------------------------------------------------------------------
   /*!
-   * \brief Return SO of a subshape
+   * \brief Return SO of a sub-shape
    */
   _PTR(SObject) getSubShapeSO( int subShapeID, GEOM::GEOM_Object_var aMainShape)
   {
@@ -382,7 +384,7 @@ namespace SMESH
   }
   // -----------------------------------------------------------------------
   /*!
-   * \brief Return subshape by ID
+   * \brief Return sub-shape by ID
    */
   GEOM::GEOM_Object_ptr getSubShape( int subShapeID, GEOM::GEOM_Object_var aMainShape)
   {
@@ -420,7 +422,7 @@ namespace SMESH
   }
   // -----------------------------------------------------------------------
   /*!
-   * \brief Return text describing a subshape
+   * \brief Return text describing a sub-shape
    */
   QString shapeText(int subShapeID, GEOM::GEOM_Object_var aMainShape )
   {
@@ -535,10 +537,11 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent, bool ForEval)
   // Computation errors
 
   myCompErrorGroup = new QGroupBox(tr("ERRORS"), aFrame);
-  myTable      = new QTableWidget( 1, NB_COLUMNS, myCompErrorGroup);
-  myShowBtn    = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup);
-  myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup);
-  myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup);
+  myWarningLabel = new QLabel(QString("<b>%1</b>").arg(tr("COMPUTE_WARNING")), myCompErrorGroup);
+  myTable        = new QTableWidget( 1, NB_COLUMNS, myCompErrorGroup);
+  myShowBtn      = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup);
+  myPublishBtn   = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup);
+  myBadMeshBtn   = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup);
 
   //myTable->setReadOnly( true ); // VSR: check
   myTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
@@ -560,11 +563,12 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent, bool ForEval)
   QGridLayout* grpLayout = new QGridLayout(myCompErrorGroup);
   grpLayout->setSpacing(SPACING);
   grpLayout->setMargin(MARGIN);
-  grpLayout->addWidget( myTable,      0, 0, 4, 1 );
-  grpLayout->addWidget( myShowBtn,    0, 1 );
-  grpLayout->addWidget( myPublishBtn, 1, 1 );
-  grpLayout->addWidget( myBadMeshBtn, 2, 1 );
-  grpLayout->setRowStretch( 3, 1 );
+  grpLayout->addWidget( myWarningLabel, 0, 0 );
+  grpLayout->addWidget( myTable,        1, 0, 4, 1 );
+  grpLayout->addWidget( myShowBtn,      1, 1 );
+  grpLayout->addWidget( myPublishBtn,   2, 1 );
+  grpLayout->addWidget( myBadMeshBtn,   3, 1 );
+  grpLayout->setRowStretch( 4, 1 );
 
   // Hypothesis definition errors
 
@@ -821,6 +825,10 @@ void SMESHGUI_BaseComputeOp::computeMesh()
       memoryLack = true;
     }
 
+    if ( !memoryLack && !SMDS_Mesh::CheckMemory(true) ) { // has memory to show dialog boxes?
+      memoryLack = true;
+    }
+
     // NPAL16631: if ( !memoryLack )
     {
       SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0);
@@ -830,7 +838,6 @@ void SMESHGUI_BaseComputeOp::computeMesh()
       // NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
       SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
       long newSize = myMesh->NbElements();
-      long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 );
       bool limitExceeded;
       if ( !memoryLack )
       {
@@ -856,6 +863,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
         }
         else if ( limitExceeded )
         {
+          long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 );
           SUIT_MessageBox::warning( desktop(),
                                     tr( "SMESH_WRN_WARNING" ),
                                     tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( newSize ).arg( limitSize ) );
@@ -937,26 +945,44 @@ void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
   }
   else
   {
-    QTableWidget* tbl = aCompDlg->myTable;
+    bool onlyWarnings = !theNoCompError; // == valid mesh computed but there are errors reported
+    for ( int i = 0; i < theCompErrors->length() && onlyWarnings; ++i )
+      onlyWarnings = ( theCompErrors[ i ].code == SMESH::COMPERR_WARNING );
+
+    // full or brief mesh info
     SMESH::long_array_var aRes = myMesh->GetMeshInfo();
-    aCompDlg->myBriefInfo->SetMeshInfo( aRes );
-    aCompDlg->myBriefInfo->show();
-    aCompDlg->myFullInfo->hide();
+    if ( onlyWarnings ) {
+      aCompDlg->myFullInfo->SetMeshInfo( aRes );
+      aCompDlg->myFullInfo->show();
+      aCompDlg->myBriefInfo->hide();
+    } else {
+      aCompDlg->myBriefInfo->SetMeshInfo( aRes );
+      aCompDlg->myBriefInfo->show();
+      aCompDlg->myFullInfo->hide();
+    }
 
+    // pbs of hypo dfinitions
     if ( theNoHypoError ) {
       aCompDlg->myHypErrorGroup->hide();
-    }
-    else {
+    } else {
       aCompDlg->myHypErrorGroup->show();
       aCompDlg->myHypErrorLabel->setText( theHypErrors );
     }
 
-    if ( theNoCompError ) {
+    // table of errors
+    if ( theNoCompError )
+    {
       aCompDlg->myCompErrorGroup->hide();
     }
-    else {
+    else
+    {
       aCompDlg->myCompErrorGroup->show();
 
+      if ( onlyWarnings )
+        aCompDlg->myWarningLabel->show();
+      else
+        aCompDlg->myWarningLabel->hide();
+
       if ( !hasShape ) {
         aCompDlg->myPublishBtn->hide();
         aCompDlg->myShowBtn->hide();
@@ -967,6 +993,7 @@ void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
       }
 
       // fill table of errors
+      QTableWidget* tbl = aCompDlg->myTable;
       tbl->setRowCount( theCompErrors->length() );
       if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
       else             tbl->showColumn( COL_SHAPE );
@@ -1045,7 +1072,7 @@ void SMESHGUI_BaseComputeOp::stopOperation()
 
 //================================================================================
 /*!
- * \brief publish selected subshape
+ * \brief publish selected sub-shape
  */
 //================================================================================