Version: 6.3.1
Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Private Types | Private Slots | Private Attributes

SMESHGUI_PrecomputeOp Class Reference

Operation to preview and compute a mesh and show computation errors. More...

#include <SMESHGUI_ComputeDlg.h>

Inheritance diagram for SMESHGUI_PrecomputeOp:
Inheritance graph
[legend]

Public Member Functions

 SMESHGUI_PrecomputeOp ()
 Constructor.
virtual ~SMESHGUI_PrecomputeOp ()
 Destructor.
virtual LightApp_Dialogdlg () const
 Gets current dialog of this operation.
SMESH::SMESH_Mesh_ptr getMesh ()

Static Public Member Functions

static void getAssignedAlgos (_PTR(SObject) theMesh, QMap< int, int > &theModeMap)
 returns map of assigned algorithms modes

Protected Slots

virtual void onCancel ()
 perform it's intention action: compute mesh
virtual bool onApply ()
 returns from compute mesh result dialog
void onPreviewShape ()
 update preview
void onPublishShape ()
 publish selected subshape
void onShowBadMesh ()
 show mesh elements preventing computation of a submesh of current row
void currentCellChanged ()
 SLOT called when a selected cell in table() changed.
virtual void onOk ()
void onHelp ()

Protected Member Functions

virtual void startOperation ()
 perform it's intention action: prepare data
virtual void stopOperation ()
 Stops operation.
virtual void resumeOperation ()
 reinitialize dialog after operaiton become active again
virtual void initDialog ()
 perform it's intention action: reinitialise dialog
SMESHGUI_ComputeDlgcomputeDlg () const
 Gets dialog of compute operation.
void computeMesh ()
 computeMesh()
void showComputeResult (const bool, const bool, SMESH::compute_error_array_var &, const bool, const QString &)
SMESHGUI_ComputeDlgevaluateDlg () const
 Gets dialog of evaluate operation.
void evaluateMesh ()
 evaluateMesh()
void showEvaluateResult (const SMESH::long_array &theRes, const bool, const bool, SMESH::compute_error_array_var &, const bool, const QString &)
virtual bool isValid (SUIT_Operation *theOp) const
 check the same operations on the same mesh
 Handle (SALOME_InteractiveObject) myIObject
virtual bool isReadyToStart () const
virtual void setIsApplyAndClose (const bool theFlag)
virtual bool isApplyAndClose () const
virtual void setDialogActive (const bool)
 Set according dialog active or inactive.
SMESHGUIgetSMESHGUI () const
bool isStudyLocked (const bool=true) const
 Verifies whether study of operation is locked.
 _PTR (Study) studyDS() const

Protected Attributes

SMESH::SMESH_Mesh_var myMesh
GEOM::GEOM_Object_var myMainShape
SMESH::TShapeDisplayermyTShapeDisplayer
SMESHGUI_MeshEditPreviewmyBadMeshDisplayer
QString myHelpFileName
bool myIsApplyAndClose

Private Types

typedef QList< intTListOfInt
 fields for mesh order
typedef QList< TListOfIntTListOfListOfInt

Private Slots

void onPreview ()
 perform it's intention action: preview mesh
void onCompute ()
 perform it's intention action: compute mesh

Private Attributes

QMap< int, intmyMapShapeId
 private fields
QPointer< LightApp_DialogmyActiveDlg
QPointer< SMESHGUI_PrecomputeDlgmyDlg
SMESHGUI_MeshEditPreviewmyPreviewDisplayer
TListOfListOfInt myPrevOrder
SMESHGUI_MeshOrderMgrmyOrderMgr

Detailed Description

Operation to preview and compute a mesh and show computation errors.

Definition at line 142 of file SMESHGUI_ComputeDlg.h.


Member Typedef Documentation

typedef QList<int> SMESHGUI_PrecomputeOp.TListOfInt [private]

fields for mesh order

Definition at line 179 of file SMESHGUI_ComputeDlg.h.

Definition at line 180 of file SMESHGUI_ComputeDlg.h.


Constructor & Destructor Documentation

SMESHGUI_PrecomputeOp::SMESHGUI_PrecomputeOp ( )

Constructor.

Definition at line 1335 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_Operation.myHelpFileName.

 : SMESHGUI_BaseComputeOp(),
 myDlg( 0 ),
 myOrderMgr( 0 ),
 myActiveDlg( 0 ),
 myPreviewDisplayer( 0 )
{
  myHelpFileName = "constructing_meshes_page.html#preview_mesh_anchor";
}
SMESHGUI_PrecomputeOp::~SMESHGUI_PrecomputeOp ( ) [virtual]

Destructor.

Definition at line 1351 of file SMESHGUI_ComputeDlg.cxx.

References myActiveDlg, myDlg, myOrderMgr, and myPreviewDisplayer.


Member Function Documentation

SMESHGUI_Operation._PTR ( Study  ) const [protected, inherited]
SMESHGUI_ComputeDlg * SMESHGUI_BaseComputeOp::computeDlg ( ) const [protected, inherited]

Gets dialog of compute operation.

Return values:
SMESHGUI_ComputeDlg*- pointer to dialog of this operation

Definition at line 1223 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_BaseComputeOp.currentCellChanged(), SMESHGUI_BaseComputeOp.myCompDlg, SMESHGUI_BaseComputeOp.onPreviewShape(), SMESHGUI_BaseComputeOp.onPublishShape(), SMESHGUI_BaseComputeOp.onShowBadMesh(), and SMESHGUI_BaseComputeOp.table().

Referenced by SMESHGUI_ComputeOp.dlg(), onCancel(), onCompute(), onPreview(), SMESHGUI_BaseComputeOp.showComputeResult(), startOperation(), and SMESHGUI_BaseComputeOp.startOperation().

{
  if ( !myCompDlg )
  {
    SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
    me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), false );
    // connect signals and slots
    connect(myCompDlg->myShowBtn,    SIGNAL (clicked()), SLOT(onPreviewShape()));
    connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
    connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));

    QTableWidget* aTable = me->table();
    connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
    connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));
  }
  return myCompDlg;
}
void SMESHGUI_BaseComputeOp::computeMesh ( ) [protected, inherited]

computeMesh()

Definition at line 762 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_Operation._PTR(), SMDS_Mesh.CheckMemory(), SMESH.COMPERR_MEMORY_PB, SMESH.GetMessageOnAlgoStateErrors(), SMESH.GetResourceMgr(), SMESHGUI.GetSMESHGen(), SMESHGUI.GetSMESHGUI(), SMESHGUI_Operation.getSMESHGUI(), MESSAGE, SMESH.ModifiedMesh(), SMESHGUI_BaseComputeOp.myCompDlg, SMESHGUI_BaseComputeOp.myMainShape, SMESHGUI_BaseComputeOp.myMesh, SMESH.OnVisuException(), SMESH.MemoryReserve.release(), SMESH_AdvancedEditor.res, SMESHGUI_ComputeDlg_QThreadQDialog.result(), SMESHGUI_BaseComputeOp.showComputeResult(), and SMESH.Update().

Referenced by onCompute(), and SMESHGUI_ComputeOp.startOperation().

{
  // COMPUTE MESH

  SMESH::MemoryReserve aMemoryReserve;

  SMESH::compute_error_array_var aCompErrors;
  QString                        aHypErrors;

  bool computeFailed = true, memoryLack = false;

  _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
  if ( !aMeshSObj ) // IPAL 21340
    return;
  bool hasShape = myMesh->HasShapeToMesh();
  bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
  if ( shapeOK )
  {
    myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
    SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
    SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
    if ( errors->length() > 0 ) {
      aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
    }
    if ( myMesh->HasModificationsToDiscard() && // issue 0020693
         SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
                                    tr( "FULL_RECOMPUTE_QUESTION" ),
                                    tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 1, 0 ) == 0 )
      myMesh->Clear();
    SUIT_OverrideCursor aWaitCursor;
    try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
      OCC_CATCH_SIGNALS;
#endif
      //SMESH::UpdateNulData(myIObject, true);
      bool res;
#ifdef WITH_SMESH_CANCEL_COMPUTE
      SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape);
      qthreaddialog.exec();
      res = qthreaddialog.result();
#else
      res = gen->Compute(myMesh, myMainShape);
#endif
      if (res)
        computeFailed = false;
    }
    catch(const SALOME::SALOME_Exception & S_ex){
      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 ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
        memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
    }
    catch(const SALOME::SALOME_Exception & S_ex){
      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);
      update( UF_ObjBrowser | UF_Model );

      // SHOW MESH
      // NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
      SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
      long newSize = myMesh->NbElements();
      bool limitExceeded;
      if ( !memoryLack )
      {
        if ( getSMESHGUI()->automaticUpdate( newSize, &limitExceeded ) )
        {
          try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
            OCC_CATCH_SIGNALS;
#endif
            SMESH::Update(myIObject, true);
          }
          catch (...) {
#ifdef _DEBUG_
            MESSAGE ( "Exception thrown during mesh visualization" );
#endif
            if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning?
              SMESH::OnVisuException();
            }
            else {
              memoryLack = true;
            }
          }
        }
        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 ) );
        }
      }
      LightApp_SelectionMgr *Sel = selectionMgr();
      if ( Sel )
      {
        SALOME_ListIO selected;
        selected.Append( myIObject );
        Sel->setSelectedObjects( selected );
      }
    }
  }

  if ( memoryLack )
    aMemoryReserve.release();

  myCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));

  // SHOW ERRORS
  
  bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
  bool noHypoError = ( aHypErrors.isEmpty() );

  SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
  int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );

  bool isShowResultDlg = true;
  switch( aNotifyMode ) {
  case 0: // show the mesh computation result dialog NEVER
    isShowResultDlg = false;
    commit();
    break;
  case 1: // show the mesh computation result dialog if there are some errors
    if ( memoryLack || !noCompError || !noHypoError )
      isShowResultDlg = true;
    else
    {
      isShowResultDlg = false;
      commit();
    }
    break;
  default: // show the result dialog after each mesh computation
    isShowResultDlg = true;
  }

  // SHOW RESULTS
  if ( isShowResultDlg )
    showComputeResult( memoryLack, noCompError,aCompErrors, noHypoError, aHypErrors );
}
void SMESHGUI_BaseComputeOp::currentCellChanged ( ) [protected, slot, inherited]

SLOT called when a selected cell in table() changed.

Definition at line 1138 of file SMESHGUI_ComputeDlg.cxx.

References COL_BAD_MESH, COL_PUBLISHED, COL_SHAPE, COL_SHAPEID, SMESH.getSelectedRows(), SMESH.TShapeDisplayer.HasReadyActorsFor(), SMESHGUI_BaseComputeOp.myBadMeshDisplayer, SMESHGUI_BaseComputeOp.myCompDlg, SMESHGUI_BaseComputeOp.myMainShape, SMESHGUI_BaseComputeOp.myTShapeDisplayer, SMESHGUI_MeshEditPreview.SetVisibility(), SMESH.TShapeDisplayer.SetVisibility(), SMESH.TShapeDisplayer.Show(), and SMESHGUI_BaseComputeOp.table().

Referenced by SMESHGUI_BaseComputeOp.computeDlg(), SMESHGUI_BaseComputeOp.evaluateDlg(), SMESHGUI_BaseComputeOp.onPreviewShape(), SMESHGUI_BaseComputeOp.onPublishShape(), SMESHGUI_BaseComputeOp.showComputeResult(), and SMESHGUI_BaseComputeOp.showEvaluateResult().

{
  myTShapeDisplayer->SetVisibility( false );
  if ( myBadMeshDisplayer )
    myBadMeshDisplayer->SetVisibility( false );

  bool publishEnable = 0, showEnable = 0, showOnly = 1, hasBadMesh = 0;
  QList<int> rows;
  int nbSelected = SMESH::getSelectedRows( table(), rows );
  int row;
  foreach ( row, rows )
  {
    bool hasData     = ( !table()->item( row, COL_SHAPE )->text().isEmpty() );
    bool isPublished = ( !table()->item( row, COL_PUBLISHED )->text().isEmpty() );
    if ( hasData && !isPublished )
      publishEnable = true;

    int curSub = table()->item( row, COL_SHAPEID )->text().toInt();
    bool prsReady = myTShapeDisplayer->HasReadyActorsFor( curSub, myMainShape );
    if ( prsReady ) {
      myTShapeDisplayer->Show( curSub, myMainShape, showOnly );
      showOnly = false;
    }
    else {
      showEnable = true;
    }

    if ( !table()->item(row, COL_BAD_MESH)->text().isEmpty() )
      hasBadMesh = true;
  }
  myCompDlg->myPublishBtn->setEnabled( publishEnable );
  myCompDlg->myShowBtn   ->setEnabled( showEnable );
  myCompDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 ));
}
LightApp_Dialog * SMESHGUI_PrecomputeOp::dlg ( ) const [virtual]

Gets current dialog of this operation.

Return values:
LightApp_Dialog*- pointer to dialog of this operation

Definition at line 1370 of file SMESHGUI_ComputeDlg.cxx.

References myActiveDlg.

{
  return myActiveDlg;
}
SMESHGUI_ComputeDlg * SMESHGUI_BaseComputeOp::evaluateDlg ( ) const [protected, inherited]

Gets dialog of evaluate operation.

Return values:
SMESHGUI_ComputeDlg*- pointer to dialog of this operation

Definition at line 2086 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_BaseComputeOp.currentCellChanged(), SMESHGUI_BaseComputeOp.myCompDlg, SMESHGUI_BaseComputeOp.onPreviewShape(), SMESHGUI_BaseComputeOp.onPublishShape(), SMESHGUI_BaseComputeOp.onShowBadMesh(), and SMESHGUI_BaseComputeOp.table().

Referenced by SMESHGUI_EvaluateOp.dlg(), SMESHGUI_BaseComputeOp.showEvaluateResult(), and SMESHGUI_EvaluateOp.startOperation().

{
  if ( !myCompDlg )
  {
    SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
    me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), true );
    // connect signals and slots
    connect(myCompDlg->myShowBtn,    SIGNAL (clicked()), SLOT(onPreviewShape()));
    connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
    connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
    QTableWidget* aTable = me->table();
    connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
    connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));
  }
  return myCompDlg;
}
void SMESHGUI_BaseComputeOp::evaluateMesh ( ) [protected, inherited]

evaluateMesh()

Definition at line 1882 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_Operation._PTR(), SMESH.GetMessageOnAlgoStateErrors(), SMESHGUI.GetSMESHGen(), SMESHGUI_Operation.getSMESHGUI(), SMESHGUI_BaseComputeOp.myCompDlg, SMESHGUI_BaseComputeOp.myMainShape, SMESHGUI_BaseComputeOp.myMesh, SMESH.MemoryReserve.release(), and SMESHGUI_BaseComputeOp.showEvaluateResult().

Referenced by SMESHGUI_EvaluateOp.startOperation().

{
  // EVALUATE MESH

  SMESH::MemoryReserve aMemoryReserve;

  SMESH::compute_error_array_var aCompErrors;
  QString                        aHypErrors;

  bool evaluateFailed = true, memoryLack = false;
  SMESH::long_array_var aRes;

  _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
  if ( !aMeshSObj ) //  IPAL21340
    return;

  bool hasShape = myMesh->HasShapeToMesh();
  bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
  if ( shapeOK )
  {
    myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
    SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
    SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
    if ( errors->length() > 0 ) {
      aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
    }
    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){
      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 );
    }
    catch(const SALOME::SALOME_Exception & S_ex){
      memoryLack = true;
    }
  }

  if ( memoryLack )
    aMemoryReserve.release();

  evaluateFailed =  ( aCompErrors->length() > 0 );
  myCompDlg->setWindowTitle(tr( evaluateFailed ? "SMESH_WRN_EVALUATE_FAILED" : "SMESH_EVALUATE_SUCCEED"));

  // SHOW ERRORS
  
  bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
  bool noHypoError = ( aHypErrors.isEmpty() );

  //SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
  //int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );

  bool isShowResultDlg = true;
  //if( noHypoError )
  //switch( aNotifyMode ) {
  //case 0: // show the mesh computation result dialog NEVER
  //isShowResultDlg = false;
  //commit();
  //break;
  //case 1: // show the mesh computation result dialog if there are some errors
  //if ( memoryLack || !noHypoError )
  //  isShowResultDlg = true;
  //else
  //{
  //  isShowResultDlg = false;
  //  commit();
  //}
  //break;
  //default: // show the result dialog after each mesh computation
  //isShowResultDlg = true;
  //}

  // SHOW RESULTS
  if ( isShowResultDlg )
    showEvaluateResult( aRes, memoryLack, noCompError, aCompErrors,
                        noHypoError, aHypErrors);
}
void SMESHGUI_PrecomputeOp::getAssignedAlgos ( _PTR(SObject)  theMesh,
QMap< int, int > &  theModeMap 
) [static]

returns map of assigned algorithms modes

detect asigned mesh algorithms

Definition at line 1514 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_Operation._PTR(), ex01_cube2build.algo, SMESH.DIM_1D, SMESH.DIM_2D, SMESH.DIM_3D, and batchmode_smesh.Tag_RefOnAppliedAlgorithms.

Referenced by initDialog(), and SMESHGUI_Selection.isPreComputable().

{
  _PTR(SObject)          aHypRoot;
  _PTR(GenericAttribute) anAttr;
  int aPart = SMESH::Tag_RefOnAppliedAlgorithms;
  if ( theMesh && theMesh->FindSubObject( aPart, aHypRoot ) )
  {
    _PTR(ChildIterator) anIter =
      SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
    for ( ; anIter->More(); anIter->Next() )
    {
      _PTR(SObject) anObj = anIter->Value();
      _PTR(SObject) aRefObj;
      if ( anObj->ReferencedObject( aRefObj ) )
        anObj = aRefObj;
      else
        continue;
      
      if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
      {
        CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
        if ( CORBA::is_nil( aVar ) )
          continue;
        
        for( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
        {
          SMESH::SMESH_Algo_var algo;
          switch(dim) {
          case SMESH::DIM_1D: algo = SMESH::SMESH_1D_Algo::_narrow( aVar ); break;
          case SMESH::DIM_2D: algo = SMESH::SMESH_2D_Algo::_narrow( aVar ); break;
          case SMESH::DIM_3D: algo = SMESH::SMESH_3D_Algo::_narrow( aVar ); break;
          default: break;
          }
          if ( !algo->_is_nil() )
            theModeMap[ dim ] = 0;
        }
      }
    }
  }
}
SMESH::SMESH_Mesh_ptr SMESHGUI_BaseComputeOp::getMesh ( ) [inherited]

Definition at line 624 of file SMESHGUI_ComputeDlg.cxx.

References SMESH.GetMeshByIO(), SMESHGUI_BaseComputeOp.Handle(), and SMESHGUI_BaseComputeOp.myMesh.

Referenced by SMESHGUI_BaseComputeOp.isValid().

{
  LightApp_SelectionMgr* Sel = selectionMgr();
  SALOME_ListIO selected; Sel->selectedObjects( selected );
  Handle(SALOME_InteractiveObject) anIO = selected.First();
  SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
  return myMesh->_is_nil() ? aMesh._retn() : SMESH::SMESH_Mesh::_duplicate( myMesh );
}
SMESHGUI * SMESHGUI_Operation::getSMESHGUI ( ) const [protected, inherited]
SMESHGUI_BaseComputeOp.Handle ( SALOME_InteractiveObject  ) [protected, inherited]
void SMESHGUI_PrecomputeOp::initDialog ( ) [protected, virtual]

perform it's intention action: reinitialise dialog

Reimplemented from SMESHGUI_Operation.

Definition at line 1476 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_Operation._PTR(), SMESH.DIM_1D, SMESH.DIM_2D, SMESH.DIM_3D, getAssignedAlgos(), SMESHGUI_MeshOrderMgr.GetMeshOrder(), myDlg, SMESHGUI_BaseComputeOp.myMesh, myOrderMgr, myPrevOrder, and SMESHGUI_MeshOrderMgr.SetMesh().

Referenced by resumeOperation().

{
  QList<int> modes;

  QMap<int, int> modeMap;
  _PTR(SObject)  pMesh = studyDS()->FindObjectID( myIObject->getEntry() );
  getAssignedAlgos( pMesh, modeMap );
  if ( modeMap.contains( SMESH::DIM_3D ) )
  {
    if ( modeMap.contains( SMESH::DIM_2D ) )
      modes.append( SMESH::DIM_2D );
    if ( modeMap.contains( SMESH::DIM_1D ) )
      modes.append( SMESH::DIM_1D );
  }
  else if ( modeMap.contains( SMESH::DIM_2D ) )
  {
    if ( modeMap.contains( SMESH::DIM_1D ) )
      modes.append( SMESH::DIM_1D );
  }

  myOrderMgr = new SMESHGUI_MeshOrderMgr( myDlg->getMeshOrderBox() );
  myOrderMgr->SetMesh( myMesh );
  bool isOrder = myOrderMgr->GetMeshOrder(myPrevOrder);
  myDlg->getMeshOrderBox()->setShown(isOrder);
  if ( !isOrder ) {
    delete myOrderMgr;
    myOrderMgr = 0;
  }

  myDlg->setPreviewModes( modes );
}
bool SMESHGUI_Operation::isApplyAndClose ( ) const [protected, virtual, inherited]
bool SMESHGUI_Operation::isReadyToStart ( ) const [protected, virtual, inherited]

Definition at line 115 of file SMESHGUI_Operation.cxx.

References SMESHGUI_Operation.getSMESHGUI(), and SMESHGUI_Operation.isStudyLocked().

{
  if ( !LightApp_Operation::isReadyToStart() )
    return false;
  else if ( getSMESHGUI() == 0 )
  {
    SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
                              tr( "NO_MODULE" ) );
    return false;
  }
  else if ( isStudyLocked() )
    return false;

  return true;
}
bool SMESHGUI_Operation::isStudyLocked ( const bool  theMess = true) const [protected, inherited]

Verifies whether study of operation is locked.

Parameters:
theMess- specifies whether message box must be shown if study is locked
Returns:
State of study.

Verifies whether study of operation is locked. If second parameter is TRUE and study is locked when corresponding message box appears

Definition at line 247 of file SMESHGUI_Operation.cxx.

References SMESHGUI.desktop().

Referenced by SMESHGUI_Operation.isReadyToStart(), SMESHGUI_MeshOp.onApply(), SMESHGUI_MakeNodeAtPointOp.onApply(), SMESHGUI_Make2DFrom3DOp.onApply(), and SMESHGUI_GroupOnShapeOp.onApply().

{
  if ( studyDS() )
  {
    if ( studyDS()->GetProperties()->IsLocked() )
    {
      if ( theMess )
        SUIT_MessageBox::warning( SMESHGUI::desktop(), tr( "WRN_WARNING" ),
                                  tr( "WRN_STUDY_LOCKED" ) );
      return true;
    }
  }

  return false;
}
bool SMESHGUI_BaseComputeOp::isValid ( SUIT_Operation *  theOp) const [protected, virtual, inherited]

check the same operations on the same mesh

Reimplemented from SMESHGUI_Operation.

Definition at line 1306 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_BaseComputeOp.getMesh(), SMESHGUI_BaseComputeOp.myMesh, and PAL_MESH_041_mesh.ret.

{
  SMESHGUI_BaseComputeOp* baseOp = dynamic_cast<SMESHGUI_BaseComputeOp*>( theOp );
  bool ret = true;
  if ( !myMesh->_is_nil() && baseOp ) {
    SMESH::SMESH_Mesh_var aMesh = baseOp->getMesh();
    if ( !aMesh->_is_nil() && aMesh->GetId() == myMesh->GetId() ) ret = false;
  }
  return ret;
}
bool SMESHGUI_BaseComputeOp::onApply ( ) [protected, virtual, slot, inherited]

returns from compute mesh result dialog

Reimplemented from SMESHGUI_Operation.

Definition at line 1247 of file SMESHGUI_ComputeDlg.cxx.

Referenced by startOperation().

{
  return true;
}
void SMESHGUI_PrecomputeOp::onCancel ( ) [protected, virtual, slot]

perform it's intention action: compute mesh

Reimplemented from SMESHGUI_Operation.

Definition at line 1578 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_BaseComputeOp.computeDlg(), SMESHGUI_MeshOrderMgr.IsOrderChanged(), myActiveDlg, myDlg, myMapShapeId, SMESHGUI_BaseComputeOp.myMesh, myOrderMgr, myPrevOrder, and SMESHGUI_MeshOrderMgr.SetMeshOrder().

Referenced by startOperation().

{
  QObject* curDlg = sender();
  if ( curDlg == computeDlg() && myActiveDlg == myDlg )
  {
    // return from error messages
    myDlg->show();
    return;
  }

  bool isRestoreOrder = false;
  if ( myActiveDlg == myDlg  && !myMesh->_is_nil() && myMapShapeId.count() )
  {
    // ask to remove already computed mesh elements
    if ( SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
                                    tr( "CLEAR_SUBMESH_QUESTION" ),
                                    tr( "SMESH_BUT_DELETE" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0 )
    {
      // remove all submeshes for collected shapes
      QMap<int,int>::const_iterator it = myMapShapeId.constBegin();
      for ( ; it != myMapShapeId.constEnd(); ++it )
        myMesh->ClearSubMesh( *it );
      isRestoreOrder = true;
    }
  }

  // return previous mesh order
  if (myOrderMgr && myOrderMgr->IsOrderChanged()) {
    if (!isRestoreOrder)
      isRestoreOrder = 
        (SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
                                    tr( "SMESH_REJECT_MESH_ORDER" ),
                                    tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0);
    if (isRestoreOrder)
      myOrderMgr->SetMeshOrder(myPrevOrder);
  }

  delete myOrderMgr;
  myOrderMgr = 0;

  myMapShapeId.clear();
  SMESHGUI_BaseComputeOp::onCancel();
}
void SMESHGUI_PrecomputeOp::onCompute ( ) [private, slot]
void SMESHGUI_Operation::onHelp ( ) [protected, slot, inherited]

Definition at line 191 of file SMESHGUI_Operation.cxx.

References SMESHGUI_Operation.getSMESHGUI(), and SMESHGUI_Operation.myHelpFileName.

Referenced by SMESHGUI_Operation.startOperation(), and startOperation().

{
  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
  if (app)
    app->onHelpContextModule(getSMESHGUI() ? app->moduleName(getSMESHGUI()->moduleName()) : QString(""), myHelpFileName);
  else {
    QString platform;
#ifdef WIN32
    platform = "winapplication";
#else
    platform = "application";
#endif
    SUIT_MessageBox::warning( desktop(), tr("WRN_WARNING"),
                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
                                                                  platform)).
                              arg(myHelpFileName) );
  }
}
void SMESHGUI_Operation::onOk ( ) [protected, virtual, slot, inherited]

Definition at line 159 of file SMESHGUI_Operation.cxx.

References SMESHGUI_Operation.onApply(), and SMESHGUI_Operation.setIsApplyAndClose().

Referenced by SMESHGUI_Operation.startOperation(), and startOperation().

{
  setIsApplyAndClose( true );
  if( onApply() )
    commit();
  setIsApplyAndClose( false );
  //else
  //  abort();
}
void SMESHGUI_PrecomputeOp::onPreview ( ) [private, slot]

perform it's intention action: preview mesh

Definition at line 1628 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_Operation._PTR(), SMESH.COMPERR_MEMORY_PB, SMESHGUI_BaseComputeOp.computeDlg(), SMESH.GetMessageOnAlgoStateErrors(), SMESH.GetResourceMgr(), SMESHGUI.GetSMESHGen(), SMESHGUI_Operation.getSMESHGUI(), SMESH.GetViewWindow(), SMESHGUI_MeshOrderMgr.IsOrderChanged(), myDlg, SMESHGUI_BaseComputeOp.myMainShape, myMapShapeId, SMESHGUI_BaseComputeOp.myMesh, SMESHGUI_ComputeDlg.myMeshName, myOrderMgr, myPreviewDisplayer, SMESH.MeshPreviewStruct.nodesXYZ, SMESH.MemoryReserve.release(), SMESHGUI_MeshEditPreview.SetData(), SMESHGUI_MeshOrderMgr.SetMeshOrder(), SMESHGUI_MeshEditPreview.SetVisibility(), and SMESHGUI_BaseComputeOp.showComputeResult().

Referenced by startOperation().

{
  if ( !myDlg || myMesh->_is_nil() || myMainShape->_is_nil() )
    return;

  _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
  if ( !aMeshSObj )
    return;

  // set modified submesh priority if any
  if (myOrderMgr && myOrderMgr->IsOrderChanged())
    myOrderMgr->SetMeshOrder();

  // Compute preview of mesh, 
  // i.e. compute mesh till indicated dimension
  int dim = myDlg->getPreviewMode();
  
  SMESH::MemoryReserve aMemoryReserve;
  
  SMESH::compute_error_array_var aCompErrors;
  QString                        aHypErrors;

  bool computeFailed = true, memoryLack = false;

  SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
    aCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );

  SMESHGUI* gui = getSMESHGUI();
  SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
  SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
  if ( errors->length() > 0 ) {
    aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
  }

  SUIT_OverrideCursor aWaitCursor;

  SVTK_ViewWindow*    view = SMESH::GetViewWindow( gui );
  if ( myPreviewDisplayer ) delete myPreviewDisplayer;
  myPreviewDisplayer = new SMESHGUI_MeshEditPreview( view );
  
  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);

    SMESH::MeshPreviewStruct* previewRes = previewData._retn();
    if ( previewRes && previewRes->nodesXYZ.length() > 0 )
    {
      computeFailed = false;
      myPreviewDisplayer->SetData( previewRes );
      // append shape indeces with computed mesh entities
      for ( int i = 0, n = aShapesId->length(); i < n; i++ )
        myMapShapeId[ aShapesId[ i ] ] = 0;
    }
    else
      myPreviewDisplayer->SetVisibility(false);
  }
  catch(const SALOME::SALOME_Exception & S_ex){
    memoryLack = true;
    myPreviewDisplayer->SetVisibility(false);
  }

  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 ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
      memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
  }
  catch(const SALOME::SALOME_Exception & S_ex){
    memoryLack = true;
  }

  if ( memoryLack )
    aMemoryReserve.release();

  bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
  bool noHypoError = ( aHypErrors.isEmpty() );

  SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( gui );
  int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );

  bool isShowError = true;
  switch( aNotifyMode ) {
  case 0: // show the mesh computation result dialog NEVER
    isShowError = false;
    break;
  case 1: // show the mesh computation result dialog if there are some errors
  default: // show the result dialog after each mesh computation
    if ( !computeFailed && !memoryLack && noCompError && noHypoError )
      isShowError = false;
    break;
  }

  aWaitCursor.suspend();
  // SHOW ERRORS
  if ( isShowError )
  {
    myDlg->hide();
    aCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
    showComputeResult( memoryLack, noCompError, aCompErrors, noHypoError, aHypErrors );
  }
}
void SMESHGUI_BaseComputeOp::onPreviewShape ( ) [protected, slot, inherited]

update preview

Definition at line 1179 of file SMESHGUI_ComputeDlg.cxx.

References COL_SHAPEID, SMESHGUI_BaseComputeOp.currentCellChanged(), SMESH.getSelectedRows(), SMESHGUI_BaseComputeOp.myMainShape, SMESHGUI_BaseComputeOp.myTShapeDisplayer, SMESH.TShapeDisplayer.Show(), and SMESHGUI_BaseComputeOp.table().

Referenced by SMESHGUI_BaseComputeOp.computeDlg(), and SMESHGUI_BaseComputeOp.evaluateDlg().

{
  if ( myTShapeDisplayer )
  {
    SUIT_OverrideCursor aWaitCursor;
    QList<int> rows;
    SMESH::getSelectedRows( table(), rows );

    bool showOnly = true;
    int row;
    foreach ( row, rows )
    {
      int curSub = table()->item( row, COL_SHAPEID )->text().toInt();
      if ( curSub > 0 ) {
        myTShapeDisplayer->Show( curSub, myMainShape, showOnly );
        showOnly = false;
      }
    }
    currentCellChanged(); // to update buttons
  }
}
void SMESHGUI_BaseComputeOp::onPublishShape ( ) [protected, slot, inherited]

publish selected subshape

Definition at line 1056 of file SMESHGUI_ComputeDlg.cxx.

References COL_PUBLISHED, COL_SHAPE, COL_SHAPEID, SMESHGUI_BaseComputeOp.currentCellChanged(), SMESH.GetGEOMGen(), SMESH.getSelectedRows(), SMESHGUI.GetSMESHGen(), SMESHGUI_Operation.getSMESHGUI(), SMESH.getSubShape(), SMESHGUI_BaseComputeOp.myMainShape, ex21_lamp.name, SMESH_fixation.shape, SMESH.shapeTypeName(), and SMESHGUI_BaseComputeOp.table().

Referenced by SMESHGUI_BaseComputeOp.computeDlg(), and SMESHGUI_BaseComputeOp.evaluateDlg().

{
  GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
  SALOMEDS::Study_var study = SMESHGUI::GetSMESHGen()->GetCurrentStudy();

  QList<int> rows;
  SMESH::getSelectedRows( table(), rows );
  int row;
  foreach ( row, rows )
  {
    int curSub = table()->item(row, COL_SHAPEID)->text().toInt();
    GEOM::GEOM_Object_var shape = SMESH::getSubShape( curSub, myMainShape );
    if ( !shape->_is_nil() && ! SMESH::getSubShapeSO( curSub, myMainShape ))
    {
      if ( !SMESH::getSubShapeSO( 1, myMainShape )) // the main shape not published
      {
        QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( myMainShape, "MAIN_SHAPE" ));
        SALOMEDS::SObject_var so =
          geomGen->AddInStudy( study, myMainShape, name.toLatin1().data(), GEOM::GEOM_Object::_nil());
        // look for myMainShape in the table
        for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
          if ( table()->item( r, COL_SHAPEID )->text() == "1" ) {
            if ( so->_is_nil() ) {
              table()->item( r, COL_SHAPE )->setText( so->GetName() );
              table()->item( r, COL_PUBLISHED )->setText( so->GetID() );
            }
            break;
          }
        }
        if ( curSub == 1 ) continue;
      }
      QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( shape, "ERROR_SHAPE" ));
      SALOMEDS::SObject_var so = geomGen->AddInStudy( study, shape, name.toLatin1().data(), myMainShape);
      if ( !so->_is_nil() ) {
        table()->item( row, COL_SHAPE )->setText( so->GetName() );
        table()->item( row, COL_PUBLISHED )->setText( so->GetID() );
      }
    }
  }
  getSMESHGUI()->getApp()->updateObjectBrowser();
  currentCellChanged(); // to update buttons
}
void SMESHGUI_BaseComputeOp::onShowBadMesh ( ) [protected, slot, inherited]

show mesh elements preventing computation of a submesh of current row

Definition at line 1105 of file SMESHGUI_ComputeDlg.cxx.

References COL_BAD_MESH, COL_SHAPEID, SMESHGUI_MeshEditPreview.GetActor(), SMESH.GetFloat(), SMESH.getSelectedRows(), SMESHGUI.GetSMESHGen(), SMESHGUI_Operation.getSMESHGUI(), SMESH.GetViewWindow(), SMESHGUI_BaseComputeOp.myBadMeshDisplayer, SMESHGUI_BaseComputeOp.myMesh, SMESHGUI_BaseComputeOp.myTShapeDisplayer, SMESHGUI_MeshEditPreview.SetData(), SMESH.TShapeDisplayer.SetVisibility(), and SMESHGUI_BaseComputeOp.table().

Referenced by SMESHGUI_BaseComputeOp.computeDlg(), and SMESHGUI_BaseComputeOp.evaluateDlg().

{
  myTShapeDisplayer->SetVisibility( false );
  QList<int> rows;
  if ( SMESH::getSelectedRows( table(), rows ) == 1 ) {
    bool hasBadMesh = ( !table()->item(rows.front(), COL_BAD_MESH)->text().isEmpty() );
    if ( hasBadMesh ) {
      int curSub = table()->item(rows.front(), COL_SHAPEID)->text().toInt();
      SMESHGUI* gui = getSMESHGUI();
      SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
      SVTK_ViewWindow*    view = SMESH::GetViewWindow( gui );
      if ( myBadMeshDisplayer ) delete myBadMeshDisplayer;
      myBadMeshDisplayer = new SMESHGUI_MeshEditPreview( view );
      SMESH::MeshPreviewStruct_var aMeshData = gen->GetBadInputElements(myMesh,curSub);
      vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
      vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
      // delete property !!!!!!!!!!
      vtkProperty* prop = vtkProperty::New();
      prop->SetLineWidth( aLineWidth * 3 );
      prop->SetPointSize( aPointSize * 3 );
      prop->SetColor( 250, 0, 250 );
      myBadMeshDisplayer->GetActor()->SetProperty( prop );
      myBadMeshDisplayer->SetData( aMeshData._retn() );
    }
  }
}
void SMESHGUI_PrecomputeOp::resumeOperation ( ) [protected, virtual]

reinitialize dialog after operaiton become active again

Definition at line 1463 of file SMESHGUI_ComputeDlg.cxx.

References initDialog(), myActiveDlg, and myDlg.

void SMESHGUI_Operation::setDialogActive ( const bool  active) [protected, virtual, inherited]

Set according dialog active or inactive.

Definition at line 135 of file SMESHGUI_Operation.cxx.

References ex13_hole1partial.d, and SMESHGUI_Dialog.setContentActive().

{
  LightApp_Operation::setDialogActive( active );

  SMESHGUI_Dialog* d = dynamic_cast<SMESHGUI_Dialog*>( dlg() );
  if( d )
    d->setContentActive( active );

}
void SMESHGUI_Operation::setIsApplyAndClose ( const bool  theFlag) [protected, virtual, inherited]

Definition at line 224 of file SMESHGUI_Operation.cxx.

References SMESHGUI_Operation.myIsApplyAndClose.

Referenced by SMESHGUI_Operation.onOk().

{
  myIsApplyAndClose = theFlag;
}
void SMESHGUI_BaseComputeOp::showComputeResult ( const bool  theMemoryLack,
const bool  theNoCompError,
SMESH::compute_error_array_var &  theCompErrors,
const bool  theNoHypoError,
const QString &  theHypErrors 
) [protected, inherited]

Definition at line 915 of file SMESHGUI_ComputeDlg.cxx.

References SMESH.ComputeError.algoName, SMESH.ComputeError.code, COL_ALGO, COL_BAD_MESH, COL_ERROR, COL_PUBLISHED, COL_SHAPE, COL_SHAPEID, SMESH.ComputeError.comment, SMESHGUI_BaseComputeOp.computeDlg(), SMESHGUI_BaseComputeOp.currentCellChanged(), SMESH.errorText(), SMESH.ComputeError.hasBadMesh, SMESHGUI_ComputeDlg.myBadMeshBtn, SMESHGUI_ComputeDlg.myBriefInfo, SMESHGUI_ComputeDlg.myCompErrorGroup, SMESHGUI_ComputeDlg.myFullInfo, SMESHGUI_ComputeDlg.myHypErrorGroup, SMESHGUI_ComputeDlg.myHypErrorLabel, SMESHGUI_BaseComputeOp.myMainShape, SMESHGUI_ComputeDlg.myMemoryLackGroup, SMESHGUI_BaseComputeOp.myMesh, SMESHGUI_ComputeDlg.myPublishBtn, SMESHGUI_ComputeDlg.myShowBtn, SMESHGUI_ComputeDlg.myTable, SMESHGUI_MeshInfosBox.SetMeshInfo(), SMESH.shapeText(), SMESHGUI_Dialog.show(), and SMESH.ComputeError.subShapeID.

Referenced by SMESHGUI_BaseComputeOp.computeMesh(), and onPreview().

{
  bool hasShape = myMesh->HasShapeToMesh();
  SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
  aCompDlg->myMemoryLackGroup->hide();

  if ( theMemoryLack )
  {
    aCompDlg->myMemoryLackGroup->show();
    aCompDlg->myFullInfo->hide();
    aCompDlg->myBriefInfo->hide();
    aCompDlg->myHypErrorGroup->hide();
    aCompDlg->myCompErrorGroup->hide();
  }
  else if ( theNoCompError && theNoHypoError )
  {
    SMESH::long_array_var aRes = myMesh->GetMeshInfo();
    aCompDlg->myFullInfo->SetMeshInfo( aRes );
    aCompDlg->myFullInfo->show();
    aCompDlg->myBriefInfo->hide();
    aCompDlg->myHypErrorGroup->hide();
    aCompDlg->myCompErrorGroup->hide();
  }
  else
  {
    QTableWidget* tbl = aCompDlg->myTable;
    SMESH::long_array_var aRes = myMesh->GetMeshInfo();
    aCompDlg->myBriefInfo->SetMeshInfo( aRes );
    aCompDlg->myBriefInfo->show();
    aCompDlg->myFullInfo->hide();

    if ( theNoHypoError ) {
      aCompDlg->myHypErrorGroup->hide();
    }
    else {
      aCompDlg->myHypErrorGroup->show();
      aCompDlg->myHypErrorLabel->setText( theHypErrors );
    }

    if ( theNoCompError ) {
      aCompDlg->myCompErrorGroup->hide();
    }
    else {
      aCompDlg->myCompErrorGroup->show();

      if ( !hasShape ) {
        aCompDlg->myPublishBtn->hide();
        aCompDlg->myShowBtn->hide();
      }
      else {
        aCompDlg->myPublishBtn->show();
        aCompDlg->myShowBtn->show();
      }

      // fill table of errors
      tbl->setRowCount( theCompErrors->length() );
      if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
      else             tbl->showColumn( COL_SHAPE );
      tbl->setColumnWidth( COL_ERROR, 200 );

      bool hasBadMesh = false;
      for ( int row = 0; row < theCompErrors->length(); ++row )
      {
        SMESH::ComputeError & err = theCompErrors[ row ];

        QString text = err.algoName.in();
        if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_ALGO )->setText( text );

        text = SMESH::errorText( err.code, err.comment.in() );
        if ( !tbl->item( row, COL_ERROR ) ) tbl->setItem( row, COL_ERROR, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_ERROR )->setText( text );

        text = QString("%1").arg( err.subShapeID );
        if ( !tbl->item( row, COL_SHAPEID ) ) tbl->setItem( row, COL_SHAPEID, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_SHAPEID )->setText( text );

        text = hasShape ? SMESH::shapeText( err.subShapeID, myMainShape ) : QString("");
        if ( !tbl->item( row, COL_SHAPE ) ) tbl->setItem( row, COL_SHAPE, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_SHAPE )->setText( text );

        text = ( !hasShape || SMESH::getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
        if ( !tbl->item( row, COL_PUBLISHED ) ) tbl->setItem( row, COL_PUBLISHED, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_PUBLISHED )->setText( text ); // if text=="", "PUBLISH" button enabled

        text = err.hasBadMesh ? "hasBadMesh" : "";
        if ( !tbl->item( row, COL_BAD_MESH ) ) tbl->setItem( row, COL_BAD_MESH, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_BAD_MESH )->setText( text );
        if ( err.hasBadMesh ) hasBadMesh = true;

        //tbl->item( row, COL_ERROR )->setWordWrap( true ); // VSR: TODO ???
        tbl->resizeRowToContents( row );
      }
      tbl->resizeColumnToContents( COL_ALGO );
      tbl->resizeColumnToContents( COL_SHAPE );

      if ( hasBadMesh )
        aCompDlg->myBadMeshBtn->show();
      else
        aCompDlg->myBadMeshBtn->hide();

      tbl->setCurrentCell(0,0);
      currentCellChanged(); // to update buttons
    }
  }
  // show dialog and wait, becase Compute can be invoked from Preview operation
  //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
  aCompDlg->show();
}
void SMESHGUI_BaseComputeOp::showEvaluateResult ( const SMESH::long_array theRes,
const bool  theMemoryLack,
const bool  theNoCompError,
SMESH::compute_error_array_var &  theCompErrors,
const bool  theNoHypoError,
const QString &  theHypErrors 
) [protected, inherited]

Definition at line 1971 of file SMESHGUI_ComputeDlg.cxx.

References SMESH.ComputeError.algoName, SMESH.ComputeError.code, COL_ALGO, COL_BAD_MESH, COL_ERROR, COL_PUBLISHED, COL_SHAPE, COL_SHAPEID, SMESH.ComputeError.comment, SMESHGUI_BaseComputeOp.currentCellChanged(), SMESH.errorText(), SMESHGUI_BaseComputeOp.evaluateDlg(), SMESH.ComputeError.hasBadMesh, SMESHGUI_ComputeDlg.myBadMeshBtn, SMESHGUI_ComputeDlg.myBriefInfo, SMESHGUI_ComputeDlg.myCompErrorGroup, SMESHGUI_ComputeDlg.myFullInfo, SMESHGUI_ComputeDlg.myHypErrorGroup, SMESHGUI_ComputeDlg.myHypErrorLabel, SMESHGUI_BaseComputeOp.myMainShape, SMESHGUI_ComputeDlg.myMemoryLackGroup, SMESHGUI_BaseComputeOp.myMesh, SMESHGUI_ComputeDlg.myPublishBtn, SMESHGUI_ComputeDlg.myShowBtn, SMESHGUI_ComputeDlg.myTable, SMESHGUI_MeshInfosBox.SetMeshInfo(), SMESH.shapeText(), SMESHGUI_Dialog.show(), and SMESH.ComputeError.subShapeID.

Referenced by SMESHGUI_BaseComputeOp.evaluateMesh().

{
  bool hasShape = myMesh->HasShapeToMesh();
  SMESHGUI_ComputeDlg* aCompDlg = evaluateDlg();
  aCompDlg->myMemoryLackGroup->hide();

  if ( theMemoryLack )
  {
    aCompDlg->myMemoryLackGroup->show();
    aCompDlg->myFullInfo->hide();
    aCompDlg->myBriefInfo->hide();
    aCompDlg->myHypErrorGroup->hide();
    aCompDlg->myCompErrorGroup->hide();
  }
  else if ( theNoCompError && theNoHypoError )
  {
    aCompDlg->myFullInfo->SetMeshInfo( theRes );
    aCompDlg->myFullInfo->show();
    aCompDlg->myBriefInfo->hide();
    aCompDlg->myHypErrorGroup->hide();
    aCompDlg->myCompErrorGroup->hide();
  }
  else
  {
    QTableWidget* tbl = aCompDlg->myTable;
    aCompDlg->myBriefInfo->SetMeshInfo( theRes );
    aCompDlg->myBriefInfo->show();
    aCompDlg->myFullInfo->hide();

    if ( theNoHypoError ) {
      aCompDlg->myHypErrorGroup->hide();
    }
    else {
      aCompDlg->myHypErrorGroup->show();
      aCompDlg->myHypErrorLabel->setText( theHypErrors );
    }

    if ( theNoCompError ) {
      aCompDlg->myCompErrorGroup->hide();
    }
    else {
      aCompDlg->myCompErrorGroup->show();

      aCompDlg->myPublishBtn->hide();
      aCompDlg->myShowBtn->hide();

      // fill table of errors
      tbl->setRowCount( theCompErrors->length() );
      if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
      else             tbl->showColumn( COL_SHAPE );
      tbl->setColumnWidth( COL_ERROR, 200 );

      bool hasBadMesh = false;
      for ( int row = 0; row < theCompErrors->length(); ++row )
      {
        SMESH::ComputeError & err = theCompErrors[ row ];

        QString text = err.algoName.in();
        if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_ALGO )->setText( text );

        text = SMESH::errorText( err.code, err.comment.in() );
        if ( !tbl->item( row, COL_ERROR ) ) tbl->setItem( row, COL_ERROR, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_ERROR )->setText( text );

        text = QString("%1").arg( err.subShapeID );
        if ( !tbl->item( row, COL_SHAPEID ) ) tbl->setItem( row, COL_SHAPEID, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_SHAPEID )->setText( text );

        text = hasShape ? SMESH::shapeText( err.subShapeID, myMainShape ) : QString("");
        if ( !tbl->item( row, COL_SHAPE ) ) tbl->setItem( row, COL_SHAPE, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_SHAPE )->setText( text );

        text = ( !hasShape || SMESH::getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
        if ( !tbl->item( row, COL_PUBLISHED ) ) tbl->setItem( row, COL_PUBLISHED, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_PUBLISHED )->setText( text ); // if text=="", "PUBLISH" button enabled

        text = err.hasBadMesh ? "hasBadMesh" : "";
        if ( !tbl->item( row, COL_BAD_MESH ) ) tbl->setItem( row, COL_BAD_MESH, new QTableWidgetItem( text ) );
        else tbl->item( row, COL_BAD_MESH )->setText( text );
        if ( err.hasBadMesh ) hasBadMesh = true;

        //tbl->item( row, COL_ERROR )->setWordWrap( true ); // VSR: TODO ???
        tbl->resizeRowToContents( row );
      }
      tbl->resizeColumnToContents( COL_ALGO );
      tbl->resizeColumnToContents( COL_SHAPE );

      if ( hasBadMesh )
        aCompDlg->myBadMeshBtn->show();
      else
        aCompDlg->myBadMeshBtn->hide();

      tbl->setCurrentCell(0,0);
      currentCellChanged(); // to update buttons
    }
  }
  // show dialog and wait, becase Compute can be invoked from Preview operation
  //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
  aCompDlg->show();
}
void SMESHGUI_PrecomputeOp::startOperation ( ) [protected, virtual]

perform it's intention action: prepare data

Reimplemented from SMESHGUI_BaseComputeOp.

Definition at line 1381 of file SMESHGUI_ComputeDlg.cxx.

References SMESHGUI_BaseComputeOp.computeDlg(), myActiveDlg, myDlg, SMESHGUI_BaseComputeOp.myMesh, SMESHGUI_BaseComputeOp.onApply(), onCancel(), onCompute(), SMESHGUI_Operation.onHelp(), SMESHGUI_Operation.onOk(), and onPreview().

{
  if ( !myDlg )
  {
    myDlg = new SMESHGUI_PrecomputeDlg( desktop() );
    
    // connect signals
    connect( myDlg, SIGNAL( preview() ), this, SLOT( onPreview() ) );
    connect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onCompute() ) );
    connect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onCompute() ) );
  }
  myActiveDlg = myDlg;

  // connect signal to compute dialog. which will be shown after Compute mesh operation
  SMESHGUI_ComputeDlg* cmpDlg = computeDlg();
  if ( cmpDlg )
  {
    // disconnect signals
    disconnect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
    disconnect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
    disconnect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
    disconnect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
    disconnect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );

    // connect signals
    if( cmpDlg->testButtonFlags( QtxDialog::OK ) )
      connect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
    if( cmpDlg->testButtonFlags( QtxDialog::Apply ) )
      connect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
    if( cmpDlg->testButtonFlags( QtxDialog::Help ) )
      connect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
    if( cmpDlg->testButtonFlags( QtxDialog::Cancel ) )
      connect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
    if( cmpDlg->testButtonFlags( QtxDialog::Close ) )
      connect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
  }

  SMESHGUI_BaseComputeOp::startOperation();
  if (myMesh->_is_nil())
    return;

  if (myDlg->getPreviewMode() == -1)
  {
    // nothing to preview
    SUIT_MessageBox::warning(desktop(),
                             tr("SMESH_WRN_WARNING"),
                             tr("SMESH_WRN_NOTHING_PREVIEW"));
    onCancel();
    return;
  }

  // disconnect slot from preview dialog to have Apply from results of compute operation only 
  disconnect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
  disconnect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );

  myDlg->show();
}
void SMESHGUI_PrecomputeOp::stopOperation ( ) [protected, virtual]

Field Documentation

QString SMESHGUI_Operation.myHelpFileName [protected, inherited]
GEOM::GEOM_Object_var SMESHGUI_BaseComputeOp.myMainShape [protected, inherited]

private fields

Definition at line 174 of file SMESHGUI_ComputeDlg.h.

Referenced by onCancel(), onCompute(), onPreview(), and stopOperation().

SMESH::SMESH_Mesh_var SMESHGUI_BaseComputeOp.myMesh [protected, inherited]

Definition at line 177 of file SMESHGUI_ComputeDlg.h.

Referenced by onPreview(), stopOperation(), and ~SMESHGUI_PrecomputeOp().

Definition at line 181 of file SMESHGUI_ComputeDlg.h.

Referenced by initDialog(), and onCancel().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS