X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshersGUI%2FStdMeshersGUI_StdHypothesisCreator.cxx;h=891b2c0c86170a4fdc62f383ba55a3eb9d44303d;hp=1e5234d6ba4b8295b5f9056e8940a5232c62b895;hb=1821a9c35f90be93d3d55b1e1db9114902eaf6f8;hpb=9a54694a0ab1e5cbc558a35c4606ceea4f7af2ef diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index 1e5234d6b..891b2c0c8 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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 @@ -39,6 +39,7 @@ #include "StdMeshersGUI_ObjectReferenceParamWdg.h" #include "StdMeshersGUI_QuadrangleParamWdg.h" #include "StdMeshersGUI_SubShapeSelectorWdg.h" +#include "StdMeshersGUI_RadioButtonsGrpWdg.h" #include @@ -58,6 +59,7 @@ #include #include #include +#include const double VALUE_MAX = 1.0e+15, // COORD_MAX VALUE_MAX_2 = VALUE_MAX * VALUE_MAX, @@ -521,6 +523,23 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const h->SetObjectEntry( w->GetMainShapeEntry() ); } } + else if( hypType()=="GeometricProgression" ) + { + StdMeshers::StdMeshers_Geometric1D_var h = + StdMeshers::StdMeshers_Geometric1D::_narrow( hypothesis() ); + + StdMeshersGUI_SubShapeSelectorWdg* w = + widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 ); + + h->SetVarParameter( params[0].text(), "SetStartLength" ); + h->SetStartLength( params[0].myValue.toDouble() ); + h->SetVarParameter( params[1].text(), "SetCommonRatio" ); + h->SetCommonRatio( params[1].myValue.toDouble() ); + if (w) { + h->SetReversedEdges( w->GetListOfIDs() ); + h->SetObjectEntry( w->GetMainShapeEntry() ); + } + } else if( hypType()=="FixedPoints1D" ) { StdMeshers::StdMeshers_FixedPoints1D_var h = @@ -580,6 +599,17 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const h->SetVarParameter( params[0].text(), "SetDeflection" ); h->SetDeflection( params[0].myValue.toDouble() ); } + else if( hypType()=="Adaptive1D" ) + { + StdMeshers::StdMeshers_Adaptive1D_var h = + StdMeshers::StdMeshers_Adaptive1D::_narrow( hypothesis() ); + h->SetVarParameter( params[0].text(), "SetMinSize" ); + h->SetMinSize( params[0].myValue.toDouble() ); + h->SetVarParameter( params[0].text(), "SetMaxSize" ); + h->SetMaxSize( params[1].myValue.toDouble() ); + h->SetVarParameter( params[0].text(), "SetDeflection" ); + h->SetDeflection( params[2].myValue.toDouble() ); + } else if( hypType()=="AutomaticLength" ) { StdMeshers::StdMeshers_AutomaticLength_var h = @@ -691,9 +721,9 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const h->SetStretchFactor ( params[2].myValue.toDouble() ); if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg = - widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 )) + widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 )) { - h->SetIgnoreFaces( idsWg->GetListOfIDs() ); + h->SetFaces( idsWg->GetListOfIDs(), params[3].myValue.toInt() ); } } else if( hypType()=="ViscousLayers2D" ) @@ -708,29 +738,29 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const h->SetVarParameter( params[2].text(), "SetStretchFactor" ); h->SetStretchFactor ( params[2].myValue.toDouble() ); - if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg = - widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 )) + if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg = + widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 )) { - h->SetIgnoreEdges( idsWg->GetListOfIDs() ); - } - } - else if( hypType()=="QuadrangleParams" ) - { - StdMeshers::StdMeshers_QuadrangleParams_var h = - StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() ); - StdMeshersGUI_SubShapeSelectorWdg* w1 = - widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 ); - StdMeshersGUI_QuadrangleParamWdg* w2 = - widget< StdMeshersGUI_QuadrangleParamWdg >( 1 ); - if (w1 && w2) { - if (w1->GetListSize() > 0) { - h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once - const char * entry = w1->GetMainShapeEntry(); - h->SetObjectEntry(entry); - } - h->SetQuadType(StdMeshers::QuadType(w2->GetType())); + h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() ); } } + // else if( hypType()=="QuadrangleParams" ) + // { + // StdMeshers::StdMeshers_QuadrangleParams_var h = + // StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() ); + // StdMeshersGUI_SubShapeSelectorWdg* w1 = + // widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 ); + // StdMeshersGUI_QuadrangleParamWdg* w2 = + // widget< StdMeshersGUI_QuadrangleParamWdg >( 1 ); + // if (w1 && w2) { + // if (w1->GetListSize() > 0) { + // h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once + // const char * entry = w1->GetMainShapeEntry(); + // h->SetObjectEntry(entry); + // } + // h->SetQuadType(StdMeshers::QuadType(w2->GetType())); + // } + // } } return valueStr; } @@ -865,6 +895,41 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const customWidgets()->append ( aDirectionWidget ); } + else if( hypType()=="GeometricProgression" ) + { + StdMeshers::StdMeshers_Geometric1D_var h = + StdMeshers::StdMeshers_Geometric1D::_narrow( hyp ); + + item.myName = tr( "SMESH_START_LENGTH_PARAM" ); + if(!initVariableName( hyp, item, "SetStartLength" )) + item.myValue = h->GetStartLength(); + p.append( item ); + + customWidgets()->append (0); + + item.myName = tr( "SMESH_COMMON_RATIO" ); + if(!initVariableName( hyp, item, "SetCommonRatio" )) + item.myValue = h->GetCommonRatio(); + p.append( item ); + + customWidgets()->append (0); + + item.myName = tr( "SMESH_REVERSED_EDGES" ); + p.append( item ); + + StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget = + new StdMeshersGUI_SubShapeSelectorWdg(); + QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); + QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry(); + if ( aGeomEntry == "" ) + aGeomEntry = h->GetObjectEntry(); + + aDirectionWidget->SetGeomShapeEntry( aGeomEntry ); + aDirectionWidget->SetMainShapeEntry( aMainEntry ); + aDirectionWidget->SetListOfIDs( h->GetReversedEdges() ); + aDirectionWidget->showPreview( true ); + customWidgets()->append ( aDirectionWidget ); + } else if( hypType()=="FixedPoints1D" ) { @@ -958,7 +1023,27 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const { StdMeshers::StdMeshers_Deflection1D_var h = StdMeshers::StdMeshers_Deflection1D::_narrow( hyp ); - + + item.myName = tr( "SMESH_DEFLECTION1D_PARAM" ); + if(!initVariableName( hyp, item, "SetDeflection" )) + item.myValue = h->GetDeflection(); + p.append( item ); + } + else if( hypType()=="Adaptive1D" ) + { + StdMeshers::StdMeshers_Adaptive1D_var h = + StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp ); + + item.myName = tr( "SMESH_MIN_SIZE" ); + if(!initVariableName( hyp, item, "SetMinSize" )) + item.myValue = h->GetMinSize(); + p.append( item ); + + item.myName = tr( "SMESH_MAX_SIZE" ); + if(!initVariableName( hyp, item, "SetMaxSize" )) + item.myValue = h->GetMaxSize(); + p.append( item ); + item.myName = tr( "SMESH_DEFLECTION1D_PARAM" ); if(!initVariableName( hyp, item, "SetDeflection" )) item.myValue = h->GetDeflection(); @@ -994,8 +1079,8 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item ); initVariableName( hyp, item, "SetLayerDistribution" ); - customWidgets()->append - ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg())); + customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg + ( h, h->GetLayerDistribution(), hypName(), dlg() )); } else if( hypType()=="NumberOfLayers2D" ) { @@ -1014,8 +1099,8 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item ); initVariableName( hyp, item, "SetLayerDistribution" ); - customWidgets()->append - ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg())); + customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg + ( h, h->GetLayerDistribution(), hypName(), dlg() )); } else if( hypType()=="ProjectionSource1D" ) { @@ -1157,17 +1242,30 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const customWidgets()->append (0); QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry(); + QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); if ( !aMainEntry.isEmpty() ) { - item.myName = tr( "SMESH_FACES_WO_LAYERS" ); + item.myName = tr( "TO_IGNORE_FACES_OR_NOT" ); + p.append( item ); + + StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg(""); + ignoreWdg->setButtonLabels ( QStringList() + << tr("NOT_TO_IGNORE_FACES") + << tr("TO_IGNORE_FACES") ); + ignoreWdg->setChecked( h->GetIsToIgnoreFaces() ); + connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged())); + customWidgets()->append( ignoreWdg ); + + item.myName = + tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ); p.append( item ); StdMeshersGUI_SubShapeSelectorWdg* idsWg = new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE); - idsWg->SetGeomShapeEntry( aMainEntry ); idsWg->SetMainShapeEntry( aMainEntry ); - idsWg->SetListOfIDs( h->GetIgnoreFaces() ); + idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry ); + idsWg->SetListOfIDs( h->GetFaces() ); idsWg->showPreview( true ); customWidgets()->append ( idsWg ); } @@ -1196,61 +1294,74 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const customWidgets()->append (0); QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry(); + QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); if ( !aMainEntry.isEmpty() ) { - item.myName = tr( "SMESH_EDGES_WO_LAYERS" ); + item.myName = tr("TO_IGNORE_EDGES_OR_NOT"); + p.append( item ); + + StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg(""); + ignoreWdg->setButtonLabels ( QStringList() + << tr("NOT_TO_IGNORE_EDGES") + << tr("TO_IGNORE_EDGES") ); + ignoreWdg->setChecked( h->GetIsToIgnoreEdges() ); + connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged())); + customWidgets()->append( ignoreWdg ); + + item.myName = + tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ); p.append( item ); StdMeshersGUI_SubShapeSelectorWdg* idsWg = new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE); - idsWg->SetGeomShapeEntry( aMainEntry ); idsWg->SetMainShapeEntry( aMainEntry ); - idsWg->SetListOfIDs( h->GetIgnoreEdges() ); + idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry ); + idsWg->SetListOfIDs( h->GetEdges() ); idsWg->showPreview( true ); customWidgets()->append ( idsWg ); } } - else if (hypType() == "QuadrangleParams") - { - StdMeshers::StdMeshers_QuadrangleParams_var h = - StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp); - - item.myName = tr("SMESH_BASE_VERTEX"); - p.append(item); - - StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget = - new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX); - aDirectionWidget->SetMaxSize(1); - QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); - QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry(); - if (anEntry == "") - anEntry = h->GetObjectEntry(); - aDirectionWidget->SetGeomShapeEntry(anEntry); - aDirectionWidget->SetMainShapeEntry(aMainEntry); - if (!isCreation()) { - SMESH::long_array_var aVec = new SMESH::long_array; - int vertID = h->GetTriaVertex(); - if (vertID > 0) { - aVec->length(1); - aVec[0] = vertID; - aDirectionWidget->SetListOfIDs(aVec); - } - } - aDirectionWidget->showPreview(true); - - item.myName = tr("SMESH_QUAD_TYPE"); - p.append(item); - - StdMeshersGUI_QuadrangleParamWdg* aTypeWidget = - new StdMeshersGUI_QuadrangleParamWdg(); - if (!isCreation()) { - aTypeWidget->SetType(int(h->GetQuadType())); - } - - customWidgets()->append(aDirectionWidget); - customWidgets()->append(aTypeWidget); - } + // else if (hypType() == "QuadrangleParams") + // { + // StdMeshers::StdMeshers_QuadrangleParams_var h = + // StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp); + + // item.myName = tr("SMESH_BASE_VERTEX"); + // p.append(item); + + // StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget = + // new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX); + // aDirectionWidget->SetMaxSize(1); + // QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); + // QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry(); + // if (anEntry == "") + // anEntry = h->GetObjectEntry(); + // aDirectionWidget->SetGeomShapeEntry(anEntry); + // aDirectionWidget->SetMainShapeEntry(aMainEntry); + // if (!isCreation()) { + // SMESH::long_array_var aVec = new SMESH::long_array; + // int vertID = h->GetTriaVertex(); + // if (vertID > 0) { + // aVec->length(1); + // aVec[0] = vertID; + // aDirectionWidget->SetListOfIDs(aVec); + // } + // } + // aDirectionWidget->showPreview(true); + + // item.myName = tr("SMESH_QUAD_TYPE"); + // p.append(item); + + // StdMeshersGUI_QuadrangleParamWdg* aTypeWidget = + // new StdMeshersGUI_QuadrangleParamWdg(); + // if (!isCreation()) { + // aTypeWidget->SetType(int(h->GetQuadType())); + // } + + // customWidgets()->append(aDirectionWidget); + // customWidgets()->append(aTypeWidget); + // } else res = false; return res; @@ -1280,6 +1391,13 @@ void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) { sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" ); } + else if( hypType()=="GeometricProgression" ) + { + if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM")) + sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" ); + else if (sb->objectName() == tr("SMESH_COMMON_RATIO")) + sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" ); + } else if( hypType()=="MaxLength" ) { sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" ); @@ -1301,6 +1419,10 @@ void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) { sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" ); } + else if( hypType()=="Adaptive1D" ) + { + sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" ); + } else if( hypType().startsWith( "ViscousLayers" )) { if (sb->objectName() == tr("SMESH_STRETCH_FACTOR")) @@ -1372,7 +1494,9 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" ); types.insert( "StartEndLength", "START_END_LENGTH" ); types.insert( "Deflection1D", "DEFLECTION1D" ); + types.insert( "Adaptive1D", "ADAPTIVE1D" ); types.insert( "Arithmetic1D", "ARITHMETIC_1D" ); + types.insert( "GeometricProgression", "GEOMETRIC_1D" ); types.insert( "FixedPoints1D", "FIXED_POINTS_1D" ); types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" ); types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" ); @@ -1469,13 +1593,11 @@ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & pa param.myValue = w->GetValue(); return true; } - if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" )) - { - //const StdMeshersGUI_QuadrangleParamWdg * w = - // static_cast( widget ); - param.myValue = "QuadType"; - return true; - } + // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" )) + // { + // param.myValue = "QuadType"; + // return true; + // } if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" )) { const StdMeshersGUI_FixedPointsParamWdg * w = @@ -1489,6 +1611,13 @@ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & pa //param.myValue = w->isChecked(); return true; } + if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" )) + { + const StdMeshersGUI_RadioButtonsGrpWdg * w = + static_cast( widget ); + param.myValue = w->checkedId(); + return true; + } return false; } @@ -1539,6 +1668,17 @@ void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget) toCopyGroups->setEnabled( true ); } } + else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup")) + { + if ( QLabel* label = getLabel(4) ) + { + bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( 3 )->checkedId(); + if ( hypType() == "ViscousLayers2D" ) + label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" )); + else + label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" )); + } + } } //================================================================================