X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_ComputeDlg.cxx;h=429531fd28919106e398c59cf2775f7339b2e467;hp=d4e2d238b592d7a0e3752359eeabe3a9dfa08e89;hb=8b8b2deedb4a7c0d3683037a91c1a340e426828c;hpb=b117205bfdd48805999ef5e225e1e474da733fc5 diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx index d4e2d238b..429531fd2 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 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. +// 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 @@ -23,22 +23,20 @@ // #include "SMESHGUI_ComputeDlg.h" +#include "SMDS_Mesh.hxx" +#include "SMDS_SetIterator.hxx" #include "SMESHGUI.h" #include "SMESHGUI_GEOMGenUtils.h" -#include "SMESHGUI_MeshUtils.h" -#include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_MeshInfosBox.h" #include "SMESHGUI_HypothesesUtils.h" #include "SMESHGUI_MeshEditPreview.h" -#include "SMESHGUI_MeshOrderOp.h" +#include "SMESHGUI_MeshInfosBox.h" #include "SMESHGUI_MeshOrderDlg.h" - +#include "SMESHGUI_MeshOrderOp.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_VTKUtils.h" #include "SMESH_Actor.h" #include "SMESH_ActorUtils.h" -#include -#include - // SALOME GEOM includes #include #include @@ -47,36 +45,37 @@ // SALOME GUI includes #include #include +#include #include -#include +#include +#include +#include +#include +#include #include +#include #include -#include -#include -#include -#include -#include // SALOME KERNEL includes #include #include #include +#include "utilities.h" #include CORBA_SERVER_HEADER(SMESH_Group) // OCCT includes +#include +#include #include +#include +#include #include #include +#include #include #include -#include -#include -#include -#include -#include - #include // Qt includes @@ -488,7 +487,7 @@ namespace SMESH //======================================================================= SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg( QWidget* parent, bool ForEval ) - : SMESHGUI_Dialog( parent, false, true, Close/* | Help*/ ) + : SMESHGUI_Dialog( parent, false, true, Close | Help ) { QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame()); aDlgLay->setMargin( 0 ); @@ -619,8 +618,8 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent, bool ForEval) // add all widgets to aFrame QVBoxLayout* aLay = new QVBoxLayout(aFrame); - aLay->setMargin( 0 ); - aLay->setSpacing( 0 ); + aLay->setMargin( MARGIN ); + aLay->setSpacing( SPACING ); aLay->addWidget( aPixGrp ); aLay->addWidget( nameBox ); aLay->addWidget( myBriefInfo ); @@ -901,7 +900,9 @@ void SMESHGUI_BaseComputeOp::computeMesh() // NPAL16631: if ( !memoryLack ) { - SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0); + SMESH::ModifiedMesh( aMeshSObj, + !computeFailed && aHypErrors.isEmpty(), + myMesh->NbNodes() == 0); update( UF_ObjBrowser | UF_Model ); // SHOW MESH @@ -911,53 +912,96 @@ void SMESHGUI_BaseComputeOp::computeMesh() long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 ); int entities = SMESH_Actor::eAllEntity; int hidden = 0; + long nbElements = 0; if ( !memoryLack ) { - if ( getSMESHGUI()->automaticUpdate( myMesh, &entities, &limitExceeded, &hidden ) ) - { - try { + // List of objects that will be updated automatically + QList< QPair< SMESH::SMESH_IDSource_var, _PTR(SObject) > > aListToUpdate; + SMESH::SMESH_IDSource_var aMeshObj = SMESH::SObjectToInterface( aMeshSObj ); + // put Mesh into list + aListToUpdate.append( QPair< SMESH::SMESH_IDSource_var, _PTR(SObject) >(aMeshObj, aMeshSObj) ); + SMESH::submesh_array_var aSubMeshes = myMesh->GetSubMeshes(); + // put SubMeshes into list + for ( int i = 0; i < aSubMeshes->length(); i++ ) { + SMESH::SMESH_subMesh_var sm = aSubMeshes[i]; + if ( CORBA::is_nil( sm ) ) continue; + _PTR(SObject) smSObj = SMESH::ObjectToSObject( sm ); + if ( !smSObj ) continue; + SMESH::SMESH_IDSource_var aSubMeshObj = SMESH::SObjectToInterface( smSObj ); + aListToUpdate.append( QPair< SMESH::SMESH_IDSource_var, _PTR(SObject) >(aSubMeshObj, smSObj) ); + } + // put Groups into list + SMESH::ListOfGroups_var aGroups = myMesh->GetGroups(); + for ( size_t i = 0; i < aGroups->length(); ++i ) { + 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 + _PTR(SObject) aGroupSO = SMESH::FindSObject( aGrp ); + if ( !aGroupSO ) continue; + SMESH::SMESH_IDSource_var aGroupObj = SMESH::SObjectToInterface( aGroupSO ); + aListToUpdate.append( QPair< SMESH::SMESH_IDSource_var, _PTR(SObject) >(aGroupObj, aGroupSO) ); + } + + // update mesh, sub-mesh and groups, if it's possible + QList< QPair< SMESH::SMESH_IDSource_var, _PTR(SObject) > >::iterator anIter; + for( anIter = aListToUpdate.begin(); anIter != aListToUpdate.end(); anIter++ ) { + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( (*anIter).second )); + if ( getSMESHGUI()->automaticUpdate( (*anIter).first, &entities, &limitExceeded, &hidden, &nbElements ) ) + { + try { #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; + OCC_CATCH_SIGNALS; #endif - SMESH_Actor *anActor = SMESH::FindActorByObject( myMesh ); - if ( !anActor ) anActor = SMESH::CreateActor( aMeshSObj->GetStudy(), aMeshSObj->GetID().c_str(), true ); - if ( anActor ) // actor is not created for an empty mesh - { - anActor->SetEntityMode( entities ); - SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor ); + bool toDisplay = false; + + if ( !aMesh->_is_nil() ) { // display a mesh only + toDisplay = true; + SMESH_Actor *anActor = SMESH::FindActorByObject( aMesh ); + if ( !anActor ) anActor = SMESH::CreateActor( (*anIter).second->GetStudy(), (*anIter).second->GetID().c_str(), true ); + if ( anActor ) // actor is not created for an empty mesh + { + anActor->SetEntityMode( entities ); + SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor ); + } + } + Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject + ( (*anIter).second->GetID().c_str(), "SMESH", (*anIter).second->GetName().c_str() ); + SMESH::Update(anIO, toDisplay); + + if ( limitExceeded && !aMesh->_is_nil() ) + { + QStringList hiddenMsg; + if ( hidden & SMESH_Actor::e0DElements ) hiddenMsg << tr( "SMESH_ELEMS0D" ); + if ( hidden & SMESH_Actor::eEdges ) hiddenMsg << tr( "SMESH_EDGES" ); + if ( hidden & SMESH_Actor::eFaces ) hiddenMsg << tr( "SMESH_FACES" ); + if ( hidden & SMESH_Actor::eVolumes ) hiddenMsg << tr( "SMESH_VOLUMES" ); + if ( hidden & SMESH_Actor::eBallElem ) hiddenMsg << tr( "SMESH_BALLS" ); + SUIT_MessageBox::warning( desktop(), + tr( "SMESH_WRN_WARNING" ), + tr( "SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED" ).arg( nbElements ).arg( limitSize ).arg( hiddenMsg.join(", ") ) ); + } } - SMESH::Update(myIObject, true); - - if ( limitExceeded ) - { - QStringList hiddenMsg; - if ( hidden & SMESH_Actor::e0DElements ) hiddenMsg << tr( "SMESH_ELEMS0D" ); - if ( hidden & SMESH_Actor::eEdges ) hiddenMsg << tr( "SMESH_EDGES" ); - if ( hidden & SMESH_Actor::eFaces ) hiddenMsg << tr( "SMESH_FACES" ); - if ( hidden & SMESH_Actor::eVolumes ) hiddenMsg << tr( "SMESH_VOLUMES" ); - if ( hidden & SMESH_Actor::eBallElem ) hiddenMsg << tr( "SMESH_BALLS" ); - SUIT_MessageBox::warning( desktop(), - tr( "SMESH_WRN_WARNING" ), - tr( "SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ).arg( hiddenMsg.join(", ") ) ); - } - } - catch (...) { + catch (...) { #ifdef _DEBUG_ - MESSAGE ( "Exception thrown during mesh visualization" ); + MESSAGE ( "Exception thrown during mesh visualization" ); #endif - if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning? - SMESH::OnVisuException(); - } - else { - memoryLack = true; + if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning? + SMESH::OnVisuException(); + } + else { + memoryLack = true; + } } } - } - else if ( limitExceeded ) - { - SUIT_MessageBox::warning( desktop(), - tr( "SMESH_WRN_WARNING" ), - tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ) ); + else if ( limitExceeded && !aMesh->_is_nil() ) + { + SUIT_MessageBox::warning( desktop(), + tr( "SMESH_WRN_WARNING" ), + tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( nbElements ).arg( limitSize ) ); + } } } LightApp_SelectionMgr *Sel = selectionMgr(); @@ -1177,6 +1221,7 @@ void SMESHGUI_BaseComputeOp::onPublishShape() GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); SALOMEDS::Study_var study = SMESHGUI::GetSMESHGen()->GetCurrentStudy(); + QStringList entryList; QList rows; SMESH::getSelectedRows( table(), rows ); int row; @@ -1214,10 +1259,13 @@ void SMESHGUI_BaseComputeOp::onPublishShape() QString shapeText = QString("%1 (%2)").arg( name.in() ).arg( entry.in() ); table()->item( row, COL_SHAPE )->setText( shapeText ); table()->item( row, COL_PUBLISHED )->setText( entry.in() ); + entryList.push_back( entry.in() ); } } } getSMESHGUI()->getApp()->updateObjectBrowser(); + getSMESHGUI()->getApp()->browseObjects( entryList, /*isApplyAndClose=*/true ); + currentCellChanged(); // to update buttons } @@ -1434,6 +1482,7 @@ QTableWidget* SMESHGUI_BaseComputeOp::table() SMESHGUI_ComputeOp::SMESHGUI_ComputeOp() : SMESHGUI_BaseComputeOp() { + myHelpFileName = "constructing_meshes_page.html#compute_anchor"; } @@ -1497,13 +1546,12 @@ LightApp_Dialog* SMESHGUI_ComputeOp::dlg() const //================================================================================ SMESHGUI_PrecomputeOp::SMESHGUI_PrecomputeOp() - : SMESHGUI_BaseComputeOp(), - myDlg( 0 ), - myOrderMgr( 0 ), - myActiveDlg( 0 ), - myPreviewDisplayer( 0 ) + : SMESHGUI_BaseComputeOp(), + myDlg( 0 ), + myOrderMgr( 0 ), + myActiveDlg( 0 ), + myPreviewDisplayer( 0 ) { - myHelpFileName = "constructing_meshes_page.html#preview_mesh_anchor"; } //================================================================================ @@ -1544,6 +1592,8 @@ LightApp_Dialog* SMESHGUI_PrecomputeOp::dlg() const void SMESHGUI_PrecomputeOp::startOperation() { + myHelpFileName = "constructing_meshes_page.html#preview_anchor"; // other anchor onCompute() + if ( !myDlg ) { myDlg = new SMESHGUI_PrecomputeDlg( desktop() ); @@ -1678,13 +1728,14 @@ void SMESHGUI_PrecomputeOp::initDialog() void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject) theMesh, QMap& theModeMap) { - _PTR(SObject) aHypRoot; + if ( !theMesh ) return; + _PTR(SObject) aHypFolder; _PTR(GenericAttribute) anAttr; int aPart = SMESH::Tag_RefOnAppliedAlgorithms; - if ( theMesh && theMesh->FindSubObject( aPart, aHypRoot ) ) + if ( theMesh->FindSubObject( aPart, aHypFolder ) ) { _PTR(ChildIterator) anIter = - SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot ); + SMESH::GetActiveStudyDocument()->NewChildIterator( aHypFolder ); for ( ; anIter->More(); anIter->Next() ) { _PTR(SObject) anObj = anIter->Value(); @@ -1693,16 +1744,16 @@ void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject) theMesh, anObj = aRefObj; else continue; - + if ( anObj->FindAttribute( anAttr, "AttributeName" ) ) { CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject(); if ( CORBA::is_nil( aVar ) ) continue; - + + SMESH::SMESH_Algo_var algo; 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; @@ -1710,7 +1761,56 @@ void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject) theMesh, default: break; } if ( !algo->_is_nil() ) + { theModeMap[ dim ] = 0; + if ( theModeMap.size() == 3 ) + return; + break; + } + } + } + } + } + + // check sub-meshes + for ( aPart = SMESH::Tag_SubMeshOnEdge; aPart < SMESH::Tag_LastSubMesh; ++aPart ) + { + if ( !theMesh->FindSubObject( aPart, aHypFolder )) + continue; + + _PTR(ChildIterator) anIter = + SMESH::GetActiveStudyDocument()->NewChildIterator( aHypFolder ); + for ( anIter->InitEx(true); 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; + + SMESH::SMESH_Algo_var algo; + for( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ ) + { + 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; + if ( theModeMap.size() == 3 ) + return; + break; + } } } } @@ -1730,6 +1830,7 @@ void SMESHGUI_PrecomputeOp::onCompute() myOrderMgr->SetMeshOrder(); myMapShapeId.clear(); myActiveDlg = computeDlg(); + myHelpFileName = "constructing_meshes_page.html#compute_anchor"; computeMesh(); } @@ -1760,7 +1861,7 @@ void SMESHGUI_PrecomputeOp::onCancel() // remove all submeshes for collected shapes QMap::const_iterator it = myMapShapeId.constBegin(); for ( ; it != myMapShapeId.constEnd(); ++it ) - myMesh->ClearSubMesh( *it ); + myMesh->ClearSubMesh( it.key() ); isRestoreOrder = true; } } @@ -1802,19 +1903,19 @@ void SMESHGUI_PrecomputeOp::onPreview() if (myOrderMgr && myOrderMgr->IsOrderChanged()) myOrderMgr->SetMeshOrder(); - // Compute preview of mesh, + // 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() ); + aCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() ); SMESHGUI* gui = getSMESHGUI(); SMESH::SMESH_Gen_var gen = gui->GetSMESHGen(); @@ -1914,6 +2015,7 @@ SMESHGUI_PrecomputeDlg::SMESHGUI_PrecomputeDlg( QWidget* parent ) setButtonText( OK, tr( "COMPUTE" ) ); QFrame* main = mainFrame(); + main->setMinimumWidth( 300 ); QVBoxLayout* layout = new QVBoxLayout( main ); @@ -1997,6 +2099,7 @@ SMESHGUI_MeshOrderBox* SMESHGUI_PrecomputeDlg::getMeshOrderBox() const SMESHGUI_EvaluateOp::SMESHGUI_EvaluateOp() : SMESHGUI_BaseComputeOp() { + myHelpFileName = "constructing_meshes_page.html#evaluate_anchor"; }