From: ptv Date: Mon, 15 Jun 2009 12:35:04 +0000 (+0000) Subject: IMP 0019925 (Improve Precompute modes detection) X-Git-Tag: V5_1_2rc2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a351e17e758d8d45573fb395c392d27bbc1e8f1a;p=modules%2Fsmesh.git IMP 0019925 (Improve Precompute modes detection) --- diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index dcbe51e7f..6f2bc5d95 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -3051,7 +3051,7 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->insert( separator(), -1, 0 ); createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE - createPopupItem( 711, OB, mesh, "&& isComputable" ); // PRECOMPUTE + createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE createPopupItem( 214, OB, mesh_group ); // UPDATE createPopupItem( 900, OB, mesh_group ); // ADV_INFO createPopupItem( 902, OB, mesh ); // STD_INFO diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx index 8e9400a4c..47f6db187 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx @@ -1617,7 +1617,7 @@ void SMESHGUI_PrecomputeOp::stopOperation() //================================================================================ /*! - * \brief perform it's intention action: reinitialise dialog + * \brief reinitialize dialog after operaiton become active again */ //================================================================================ @@ -1628,16 +1628,48 @@ void SMESHGUI_PrecomputeOp::resumeOperation() SMESHGUI_BaseComputeOp::resumeOperation(); } +//================================================================================ +/*! + * \brief perform it's intention action: reinitialise dialog + */ +//================================================================================ + void SMESHGUI_PrecomputeOp::initDialog() { QList modes; + QMap 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 ); + } + + myDlg->setPreviewModes( modes ); +} + +//================================================================================ +/*! + * \brief detect asigned mesh algorithms + */ +//================================================================================ + +void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject) theMesh, + QMap& theModeMap) +{ _PTR(SObject) aHypRoot; _PTR(GenericAttribute) anAttr; int aPart = SMESH::Tag_RefOnAppliedAlgorithms; - - _PTR(SObject) pMesh = studyDS()->FindObjectID( myIObject->getEntry() ); - if ( pMesh && pMesh->FindSubObject( aPart, aHypRoot ) ) + if ( theMesh && theMesh->FindSubObject( aPart, aHypRoot ) ) { _PTR(ChildIterator) anIter = SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot ); @@ -1655,28 +1687,22 @@ void SMESHGUI_PrecomputeOp::initDialog() CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject(); if ( CORBA::is_nil( aVar ) ) continue; - - SMESH::SMESH_Algo_var algo = SMESH::SMESH_3D_Algo::_narrow( aVar ); - if ( !algo->_is_nil() ) - { - modeMap[ SMESH::DIM_1D ] = 0; - modeMap[ SMESH::DIM_2D ] = 0; - } - else + + for( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ ) { - algo = SMESH::SMESH_2D_Algo::_narrow( aVar ); + 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() ) - modeMap[ SMESH::DIM_1D ] = 0; + theModeMap[ dim ] = 0; } } } } - if ( modeMap.contains( SMESH::DIM_1D ) ) - modes.append( SMESH::DIM_1D ); - if ( modeMap.contains( SMESH::DIM_2D ) ) - modes.append( SMESH::DIM_2D ); - - myDlg->setPreviewModes( modes ); } //================================================================================ diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.h b/src/SMESHGUI/SMESHGUI_ComputeDlg.h index 9a84f8a1c..baef23649 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.h +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.h @@ -136,6 +136,12 @@ public: virtual LightApp_Dialog* dlg() const; + /** + * \brief returns map of assigned algorithms modes + */ + static void getAssignedAlgos(_PTR(SObject) theMesh, + QMap& theModeMap); + protected: virtual void startOperation(); virtual void stopOperation(); diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index e49ee940b..d3b80a7c4 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -29,6 +29,7 @@ #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_GEOMGenUtils.h" +#include "SMESHGUI_ComputeDlg.h" #include #include @@ -113,6 +114,7 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const else if ( p=="controlMode" ) val = QVariant( controlMode( ind ) ); else if ( p=="displayMode" ) val = QVariant( displayMode( ind ) ); else if ( p=="isComputable" ) val = QVariant( isComputable( ind ) ); + else if ( p=="isPreComputable" ) val = QVariant( isPreComputable( ind ) ); else if ( p=="hasReference" ) val = QVariant( hasReference( ind ) ); else if ( p=="isImported" ) val = QVariant( isImported( ind ) ); else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) ); @@ -384,6 +386,23 @@ QVariant SMESHGUI_Selection::isComputable( int ind ) const return QVariant( false ); } +//======================================================================= +//function : isPreComputable +//purpose : +//======================================================================= + +QVariant SMESHGUI_Selection::isPreComputable( int ind ) const +{ + if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) + { + QMap modeMap; + _PTR(SObject) pMesh = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() ); + SMESHGUI_PrecomputeOp::getAssignedAlgos( pMesh, modeMap ); + return QVariant( modeMap.size() > 1 ); + } + return QVariant( false ); +} + //======================================================================= //function : hasReference //purpose : diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h index e1b1cc2df..ce64db54a 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.h +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -54,6 +54,7 @@ public: virtual bool isAutoColor( int ) const; virtual int numberOfNodes( int ) const; virtual QVariant isComputable( int ) const; + virtual QVariant isPreComputable( int ) const; virtual QVariant hasReference( int ) const; virtual QVariant isVisible( int ) const;