From: imn Date: Thu, 26 Dec 2013 16:40:53 +0000 (+0000) Subject: Integrated in BR_imps_2013: 0022365: EDF SMESH: Create Mesh dialog box improvement... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=55e82c8f228da91bab210dd5b9d3cd07d4ed915c;p=modules%2Fsmesh.git Integrated in BR_imps_2013: 0022365: EDF SMESH: Create Mesh dialog box improvement: hide algorithms depending on a mesh type --- diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 2d45966ed..58003954a 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -296,24 +296,45 @@ namespace SMESH } - QStringList GetHypothesesSets(int maxDim) + QStringList GetHypothesesSets(int maxDim, const QString& MeshType) { QStringList aSetNameList; // Init list of available hypotheses, if needed InitAvailableHypotheses(); - QList::iterator hypoSet; - for ( hypoSet = myListOfHypothesesSets.begin(); + for ( hypoSet = myListOfHypothesesSets.begin(); hypoSet != myListOfHypothesesSets.end(); ++hypoSet ) { HypothesesSet* aSet = *hypoSet; - if ( aSet && - ( aSet->count( true ) || aSet->count( false )) && - aSet->maxDim() <= maxDim) + bool isAvailable = false; + if ( !MeshType.isEmpty() ) + { + if ( aSet->maxDim() != maxDim) + continue; + aSet->init( true ); + while ( aSet->next(), aSet->more() ) + { + if ( HypothesisData* hypData = SMESH::GetHypothesisData( aSet->current() ) ) + { + QStringList::const_iterator inElemType = hypData->OutputTypes.begin(); + for ( ; inElemType != hypData->OutputTypes.end(); inElemType++ ) + { + if ( *inElemType == MeshType ){ + isAvailable = true; + break; + } + } + } + if ( isAvailable ) break; + } + } + else if ( aSet && ( aSet->count( true ) || aSet->count( false )) && + aSet->maxDim() <= maxDim) { - aSetNameList.append( mangledHypoSetName( aSet )); + isAvailable = true; } + if ( isAvailable ) aSetNameList.append( mangledHypoSetName( aSet )); } aSetNameList.removeDuplicates(); aSetNameList.sort(); diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.h b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h index a2c12f595..333418b31 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.h +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h @@ -71,7 +71,7 @@ namespace SMESH const bool = false, const bool = true); SMESHGUI_EXPORT - QStringList GetHypothesesSets( int maxDim ); + QStringList GetHypothesesSets( int, const QString& ); SMESHGUI_EXPORT HypothesesSet* GetHypothesesSet( const QString& ); diff --git a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx index 4b030bbc0..94d9ce681 100644 --- a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx @@ -364,6 +364,9 @@ SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh // geometry createObject( tr( "GEOMETRY" ), mainFrame(), Geom ); myGeomPopup = 0; + // mesh type + QLabel* anMeshTypeLbl = new QLabel( tr( "MESH_TYPE" ), this ); + myMeshType = new QComboBox( this ); // Create tab widget @@ -398,10 +401,16 @@ SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh aLay->addWidget( objectWg( Geom, Label ), 2, 0 ); aLay->addWidget( objectWg( Geom, Btn ), 2, 1 ); aLay->addWidget( objectWg( Geom, Control ), 2, 2 ); - aLay->addWidget( myTabWg, 4, 0, 1, 3 ); - aLay->addWidget( myHypoSetButton, 5, 0, 1, 3 ); + aLay->addWidget( anMeshTypeLbl, 3, 0 ); + aLay->addWidget( myMeshType, 3, 2 ); + aLay->addWidget( myTabWg, 5, 0, 1, 3 ); + aLay->addWidget( myHypoSetButton, 6, 0, 1, 3 ); aLay->setRowMinimumHeight( 3, 20 ); + myMeshType->clear(); + + // Connect signals and slots + connect( myMeshType, SIGNAL( activated( int ) ), SLOT( onChangedMeshType( int ) ) ); // Disable controls if necessary setObjectShown( Mesh, false ); if ( theToCreate ) @@ -615,3 +624,36 @@ int SMESHGUI_MeshDlg::getActiveObject() return i; return -1; } +//================================================================================ +/*! + * \brief Sets available types of mesh + * \param theTypeMesh - list of available types of mesh + */ +//================================================================================ +void SMESHGUI_MeshDlg::setAvailableMeshType( const QStringList& theTypeMesh ) +{ + myMeshType->clear(); + myMeshType->addItems(theTypeMesh); +} +//================================================================================ +/*! + * \brief Emits selectMeshType( const int, const int ) signal + * + * SLOT is called when a combo box "mesh type" is selected. + */ +//================================================================================ +void SMESHGUI_MeshDlg::onChangedMeshType( const int isIndex ) +{ + emit selectMeshType( Dim3D - myTabWg->currentIndex(), isIndex ); +} +//================================================================================ +/*! + * \brief Get current index types of mesh + */ +//================================================================================ +int SMESHGUI_MeshDlg::currentMeshType( ) +{ + return myMeshType->currentIndex( ); +} + + diff --git a/src/SMESHGUI/SMESHGUI_MeshDlg.h b/src/SMESHGUI/SMESHGUI_MeshDlg.h index 6ba8e6cb9..08f11ff6f 100644 --- a/src/SMESHGUI/SMESHGUI_MeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_MeshDlg.h @@ -74,21 +74,26 @@ public: void enableTab(const int); bool isTabEnabled(const int) const; int getActiveObject(); + void setAvailableMeshType(const QStringList& ); + int currentMeshType(); signals: void hypoSet( const QString& ); void geomSelectionByMesh( bool ); + void selectMeshType( const int, const int ); private slots: void onHypoSetPopup( QAction* ); void onGeomPopup( QAction* ); void onGeomSelectionButton( bool ); + void onChangedMeshType( const int ); private: QMap myTabs; QTabWidget* myTabWg; QToolButton* myHypoSetButton; QMenu* myGeomPopup; + QComboBox* myMeshType; }; /*! diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 62a5c4b74..eb0a30ed7 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -95,6 +95,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh ) if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists GeometryGUI::InitGeomGen(); myIsOnGeometry = true; + myMaxShapeDim = -1; } //================================================================================ @@ -211,14 +212,13 @@ void SMESHGUI_MeshOp::startOperation() } connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& ))); connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool ))); - + connect( myDlg, SIGNAL( selectMeshType( const int, const int ) ), SLOT( onAlgoSetByMeshType( const int, const int))); if ( myToCreate ) if ( myIsMesh ) myHelpFileName = "constructing_meshes_page.html"; else myHelpFileName = "constructing_submeshes_page.html"; else myHelpFileName = "editing_meshes_page.html"; } SMESHGUI_SelectionOp::startOperation(); - // iterate through dimensions and get available algoritms, set them to the dialog _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" ); for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ ) @@ -245,6 +245,11 @@ void SMESHGUI_MeshOp::startOperation() myDlg->activateObject( SMESHGUI_MeshDlg::Obj ); myDlg->setCurrentTab( SMESH::DIM_3D ); + + QStringList TypeMeshList; + createMeshTypeList( TypeMeshList ); + setAvailableMeshType( TypeMeshList ); + myDlg->show(); myDlg->setGeomPopupEnabled(false); selectionDone(); @@ -582,7 +587,8 @@ void SMESHGUI_MeshOp::selectionDone() onAlgoSelected(-1, i); } myDlg->setMaxHypoDim( shapeDim ); - myDlg->setHypoSets( SMESH::GetHypothesesSets( shapeDim )); + myMaxShapeDim = shapeDim; + myDlg->setHypoSets( SMESH::GetHypothesesSets( shapeDim, "" )); if (!myToCreate) // edition: read hypotheses { @@ -669,12 +675,16 @@ void SMESHGUI_MeshOp::selectionDone() for (int i = SMESH::DIM_0D;i < SMESH::DIM_3D; ++i) { myDlg->disableTab(i); } + myMaxShapeDim = -1; //Hide labels and fields (Mesh ang Geometry) myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, false ); myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, false ); myDlg->adjustSize(); readMesh(); } + QStringList TypeMeshList; + createMeshTypeList( TypeMeshList ); + setAvailableMeshType( TypeMeshList ); } catch ( const SALOME::SALOME_Exception& S_ex ) { @@ -1380,7 +1390,19 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex, availableHyps( aDim, Algo, anAvailable, myAvailableHypData[ aDim ][ Algo ]); myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable ); } - + // check that tab enable, if algorithm building needed algo is one less than dimension + if ( algoData && myIsOnGeometry && !algoData->InputTypes.isEmpty() && + ( aDim > SMESH::DIM_0D ) && !isAccessibleDim( aDim - 1 ) ){ + myDlg->enableTab( aDim - 1 ); + } + if ( (myDlg->currentMeshType() != MT_ANY) && + (( !algoData && ( aDim > SMESH::DIM_0D ) && isAccessibleDim( aDim - 1 )) || + ( algoData && myIsOnGeometry && algoData->InputTypes.isEmpty() && + ( aDim > SMESH::DIM_0D ) && isAccessibleDim( aDim - 1 ) ) ) ){ + for (int i = aDim - 1; i >= SMESH::DIM_0D; i--){ + if ( isAccessibleDim( i ) ) myDlg->disableTab( i ); + } + } // check that algorithms of other dimentions are compatible with // the selected one @@ -2343,3 +2365,193 @@ void SMESHGUI_MeshOp::selectObject( _PTR(SObject) theSObj ) const sm->setSelectedObjects( anIOList, false ); } } +//================================================================================ +/*! + * \brief Create available list types of mesh + * \param theTypeMesh - Output list of available types of mesh + */ +//================================================================================ +void SMESHGUI_MeshOp::createMeshTypeList( QStringList& theTypeMesh) +{ + theTypeMesh.clear(); + theTypeMesh.append( tr( "MT_ANY" ) ); + if ( myIsOnGeometry && ( myMaxShapeDim >= 2 || myMaxShapeDim == -1 ) ) + { + theTypeMesh.append( tr( "MT_TRIANGULAR" ) ); + theTypeMesh.append( tr( "MT_QUADRILATERAL" ) ); + } + if ( myIsOnGeometry && ( myMaxShapeDim == 3 || myMaxShapeDim == -1 ) ) + { + theTypeMesh.append( tr( "MT_TETRAHEDRAL" ) ); + theTypeMesh.append( tr( "MT_HEXAHEDRAL" ) ); + } + +} +//================================================================================ +/*! + * \brief Set available types of mesh + * \param theTypeMesh - List of available types of mesh + */ +//================================================================================ +void SMESHGUI_MeshOp::setAvailableMeshType( const QStringList& theTypeMesh ) +{ + myDlg->setAvailableMeshType( theTypeMesh ); +} + +//================================================================================ +/*! + * \brief SLOT. Is called when the user select type of mesh + * \param theTabIndex - Index of current active tab + * \param theIndex - Index of current type of mesh + */ +//================================================================================ +void SMESHGUI_MeshOp::onAlgoSetByMeshType( const int theTabIndex, const int theIndex) +{ + int aDim; + if ( !myIsOnGeometry ) return; + THypDataList anAvailableAlgsData; + QStringList anAvailableAlgs; + QString anCompareType = "ANY"; + bool isAvailableChoiceAlgo = false; + int anCurrentAvailableAlgo = 0; + bool isNone = true; + switch ( theIndex ) { + case MT_ANY: + { + for ( int dim = SMESH::DIM_2D; dim <= SMESH::DIM_3D; dim++ ) + { + isNone = currentHyp( dim, Algo ) < 0; + isAvailableChoiceAlgo = false; + // retrieves a list of available algorithms from resources + availableHyps( dim, Algo, anAvailableAlgs, anAvailableAlgsData ); + //return current algo in current tab + if ( !isNone && !myAvailableHypData[dim][Algo].empty() ){ + for (int i = 0 ; i < anAvailableAlgsData.count(); i++) + { + HypothesisData* algoAny = anAvailableAlgsData.at(i); + HypothesisData* algoCur = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) ); + QString tem = algoAny->Label; + if ( algoAny->Label == algoCur->Label ){ + isAvailableChoiceAlgo = true; + anCurrentAvailableAlgo = i; + break; + } + } + } + else if ( !isNone ){ + isAvailableChoiceAlgo = true; + anCurrentAvailableAlgo = currentHyp( dim, Algo ); + } + //set new algorithm list and select the current algorithm + myAvailableHypData[dim][Algo] = anAvailableAlgsData; + myDlg->tab( dim )->setAvailableHyps( Algo, anAvailableAlgs ); + if ( isAvailableChoiceAlgo ) + setCurrentHyp( dim, Algo, anCurrentAvailableAlgo ); + } + int aMaxShapeDim = ( myMaxShapeDim == -1 ) ? SMESH::DIM_3D : myMaxShapeDim; + for ( int i = SMESH::DIM_0D; i <= aMaxShapeDim; i++ ) { + myDlg->enableTab( i ); + } + myDlg->setCurrentTab( theTabIndex ); + myDlg->setHypoSets( SMESH::GetHypothesesSets( aMaxShapeDim, "" ) ); + } + break; + case MT_TRIANGULAR:{ + aDim = SMESH::DIM_2D; + anCompareType = "TRIA"; + } + break; + case MT_QUADRILATERAL:{ + aDim = SMESH::DIM_2D; + anCompareType = "QUAD"; + } + break; + case MT_TETRAHEDRAL:{ + aDim = SMESH::DIM_3D; + anCompareType = "TETRA"; + } + break; + case MT_HEXAHEDRAL:{ + aDim = SMESH::DIM_3D; + anCompareType = "HEXA"; + } + break; + default:; + } + if ( anCompareType != "ANY" ) + { + QString anCurrentAlgo; + bool isReqDisBound = true; + isNone = currentHyp( aDim, Algo ) < 0; + // retrieves a list of available algorithms from resources + availableHyps( aDim, Algo, anAvailableAlgs, anAvailableAlgsData ); + // finding algorithm which is selected + if ( !isNone && !myAvailableHypData[aDim][Algo].empty() && + myAvailableHypData[aDim][Algo].count() != anAvailableAlgsData.count() ){ + anCurrentAlgo = myAvailableHypData[aDim][Algo].at( currentHyp( aDim, Algo ) )->Label; + isReqDisBound = myAvailableHypData[aDim][Algo].at( currentHyp( aDim, Algo ) )->InputTypes.isEmpty(); + } + else if ( !isNone ){ + anCurrentAlgo = anAvailableAlgsData.at( currentHyp( aDim, Algo ) )->Label; + isReqDisBound = anAvailableAlgsData.at( currentHyp( aDim, Algo ) )->InputTypes.isEmpty(); + } + anAvailableAlgs.clear(); + myAvailableHypData[aDim][Algo].clear(); + // finding and adding algorithm depending on the type mesh + for ( int i = 0 ; i < anAvailableAlgsData.count(); i++ ) + { + HypothesisData* algoIn = anAvailableAlgsData.at( i ); + bool isAvailableAlgo = ( algoIn->OutputTypes.count() == 0 ); + QStringList::const_iterator inElemType = algoIn->OutputTypes.begin(); + for ( ; inElemType != algoIn->OutputTypes.end(); inElemType++ ) + { + if ( *inElemType == anCompareType ){ + isAvailableAlgo = true; + break; + } + } + if ( isAvailableAlgo || algoIn->OutputTypes.count()==0 ){ + anAvailableAlgs.append( algoIn->Label ); + myAvailableHypData[aDim][Algo].append( algoIn ); + } + //algorithm will be active, if the chosen algorithm available in the current mesh type + if ( !isNone && isAvailableAlgo && algoIn->Label == anCurrentAlgo ){ + isAvailableChoiceAlgo = true; + anCurrentAvailableAlgo = anAvailableAlgs.count() - 1 ; + } + } + //set new algorithm list and select the current algorithm + myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailableAlgs ); + if ( isAvailableChoiceAlgo ) + setCurrentHyp( aDim, Algo, anCurrentAvailableAlgo ); + int aMaxShapeDim = ( myMaxShapeDim == -1 ) ? SMESH::DIM_3D : myMaxShapeDim; + if ( isNone || isReqDisBound || !isAvailableChoiceAlgo ) { + for ( int i = SMESH::DIM_0D; i <= aMaxShapeDim; i++ ) { + if ( aDim != i ) { + myDlg->disableTab( i ); + setCurrentHyp(i, Algo, -1); + } + } + } + else if ( !isNone ){ + if ( aDim == SMESH::DIM_2D){ + myDlg->disableTab( SMESH::DIM_3D ); + setCurrentHyp( SMESH::DIM_3D, Algo, -1); + } + for ( int i = aMaxShapeDim; i > SMESH::DIM_0D; i-- ) + { + isReqDisBound = ( currentHyp( i, Algo ) < 0 ) ? true : myAvailableHypData[i][Algo].at( currentHyp( i, Algo ) )->InputTypes.isEmpty(); + if ( aMaxShapeDim != i && isReqDisBound) { + for (int j = i - 1; j >= SMESH::DIM_0D; j--){ + myDlg->disableTab( j ); + setCurrentHyp( j , Algo, -1 ); + } + break; + } + } + } + myDlg->setHypoSets( SMESH::GetHypothesesSets( aDim, anCompareType ) ); + myDlg->enableTab( aDim ); + myDlg->setCurrentTab( aDim ); + } +} diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.h b/src/SMESHGUI/SMESHGUI_MeshOp.h index 91c39ed72..5f5688267 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.h +++ b/src/SMESHGUI/SMESHGUI_MeshOp.h @@ -48,6 +48,7 @@ class SMESHGUI_EXPORT SMESHGUI_MeshOp : public SMESHGUI_SelectionOp public: enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes }; + enum MeshType{ MT_ANY = 0, MT_TRIANGULAR, MT_QUADRILATERAL, MT_TETRAHEDRAL, MT_HEXAHEDRAL }; typedef std::pair THypItem; typedef QList< THypItem > THypList; @@ -83,6 +84,7 @@ protected slots: void processSet(); void onHypoCreated( int ); void onHypoEdited( int ); + void onAlgoSetByMeshType( const int, const int ); private: typedef QList THypDataList; // typedef: list of hypothesis data @@ -125,7 +127,8 @@ private: char* isSubmeshIgnored() const; _PTR(SObject) getSubmeshByGeom() const; void selectObject( _PTR(SObject) ) const; - + void createMeshTypeList( QStringList& ); + void setAvailableMeshType( const QStringList& ); private: SMESHGUI_MeshDlg* myDlg; SMESHGUI_ShapeByMeshOp* myShapeByMeshOp; @@ -136,13 +139,12 @@ private: TDim2Type2HypList myExistingHyps; //!< all hypothesis of SMESH module TDim2Type2HypList myObjHyps; //!< hypothesis assigned to the current // edited mesh/sub-mesh - // hypdata corresponding to hypotheses present in myDlg THypDataList myAvailableHypData[4][NbHypTypes]; bool myIgnoreAlgoSelection; HypothesesSet* myHypoSet; - int myDim, myType; + int myDim, myType, myMaxShapeDim; QString myObjectToSelect; }; diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 174bcf165..df41ace14 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -5977,6 +5977,10 @@ Please specify them and try again MESH Mesh + + MESH_TYPE + Mesh type + NAME Name @@ -6032,6 +6036,26 @@ Please specify it and try again MESH_IS_NULL Mesh is null + + MT_ANY + Any + + + MT_HEXAHEDRAL + Hexahedral + + + MT_TETRAHEDRAL + Tetrahedral + + + MT_TRIANGULAR + Triangular + + + MT_QUADRILATERAL + Quadrilaterial + NAME_OF_MESH_IS_EMPTY Name of mesh is empty diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 749b17e7e..b8ddd3e1b 100755 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -5971,6 +5971,10 @@ Indiquez-les et essayez de nouveau MESH Maillage + + MESH_TYPE + Mesh type + NAME Nom @@ -6026,6 +6030,26 @@ Spécifiez-le et essayez de nouveau MESH_IS_NULL Le maillage est nul + + MT_ANY + Any + + + MT_HEXAHEDRAL + Hexahedral + + + MT_TETRAHEDRAL + Tetrahedral + + + MT_TRIANGULAR + Triangular + + + MT_QUADRILATERAL + Quadrilaterial + NAME_OF_MESH_IS_EMPTY Le nom du maillage est vide