X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshersGUI%2FStdMeshersGUI_CartesianParamCreator.cxx;h=2aa6c49f1a7e5c13b82c7d5e8373c0676619721f;hp=88ad6ddc365c25c9465b4933239af2a301aef088;hb=HEAD;hpb=b0a908c0d20341651771d0249fb10882f54b2aad diff --git a/src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.cxx index 88ad6ddc3..675f377cc 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_CartesianParamCreator.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -58,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -177,7 +177,7 @@ namespace StdMeshersGUI myStepSpin->SetStep( 1. ); myStepSpin->SetValue( myStep = 1. ); - // 3) Coodrinates/Spacing group + // 3) Coordinates/Spacing group QFrame* csFrame = new QFrame( this ); QVBoxLayout* scLay = new QVBoxLayout( csFrame ); scLay->setMargin( 0 ); @@ -204,8 +204,8 @@ namespace StdMeshersGUI axisTabLayout->setSpacing( SPACING ); axisTabLayout->addWidget( modeBox , 0, 0, 1, 3 ); - axisTabLayout->addWidget( myInsertBtn , 1, 0, 1, 2 ); - axisTabLayout->addWidget( myDeleteBtn , 2, 0, 1, 2 ); + axisTabLayout->addWidget( myInsertBtn, 1, 0, 1, 2 ); + axisTabLayout->addWidget( myDeleteBtn, 2, 0, 1, 2 ); axisTabLayout->addWidget( myStepLabel, 3, 0 ); axisTabLayout->addWidget( myStepSpin , 3, 1 ); axisTabLayout->addWidget( csFrame , 1, 2, 4, 1 ); @@ -319,10 +319,10 @@ namespace StdMeshersGUI void GridAxisTab::onMode(int isSpacing) { - mySpacingTreeWdg->setShown( isSpacing ); - myCoordList->setShown( !isSpacing ); - myStepSpin->setShown( !isSpacing ); - myStepLabel->setShown( !isSpacing ); + mySpacingTreeWdg->setVisible( isSpacing ); + myCoordList->setVisible( !isSpacing ); + myStepSpin->setVisible( !isSpacing ); + myStepLabel->setVisible( !isSpacing ); if ( isSpacing ) { if ( mySpacingTreeWdg->topLevelItemCount() == 0 ) @@ -430,7 +430,7 @@ namespace StdMeshersGUI //================================================================================ /*! - * \brief Checks grid definintion mode + * \brief Checks grid definition mode */ //================================================================================ @@ -457,7 +457,7 @@ namespace StdMeshersGUI //================================================================================ /*! - * \brief Returms spacing to set to a hypothesis + * \brief Returns spacing to set to a hypothesis */ //================================================================================ @@ -534,7 +534,7 @@ namespace StdMeshersGUI //================================================================================ QWidget* LineDelegate::createEditor( QWidget* parent, - const QStyleOptionViewItem& opt, + const QStyleOptionViewItem& /*opt*/, const QModelIndex& index) const { QWidget* w = 0; @@ -677,6 +677,22 @@ namespace dirs[( iOk+2 ) % 3] = dirs[ iOk ] ^ dirs[ ( iOk+1 ) % 3 ]; dirs[( iOk+1 ) % 3] = dirs[ ( iOk+2 ) % 3 ] ^ dirs[ iOk ]; } + + //================================================================================ + /*! + * \brief Returns a minimal width of a SpinBox depending on a precision type + */ + //================================================================================ + + int getMinWidth( const char* precisionType ) + { + int nb = SMESHGUI::resourceMgr()->integerValue( "SMESH", precisionType, -3 ); + QString s; + s.fill('0', qAbs(nb)+7 ); + QLineEdit le; + QFontMetrics metrics( le.font() ); + return metrics.width( s ); + } } //================================================================================ @@ -805,6 +821,26 @@ QFrame* StdMeshersGUI_CartesianParamCreator::buildFrame() myAddEdges = new QCheckBox( tr("ADD_EDGES"), GroupC1 ); argGroupLayout->addWidget( myAddEdges, row, 0, 1, 2 ); row++; + myCreateFaces = new QCheckBox( tr("CREATE_FACES"), GroupC1 ); + argGroupLayout->addWidget( myCreateFaces, row, 0, 1, 2 ); + row++; + myConsiderInternalFaces = new QCheckBox( tr("CONSIDER_INTERNAL_FACES"), GroupC1 ); + argGroupLayout->addWidget( myConsiderInternalFaces, row, 0, 1, 2 ); + row++; + myUseThresholdForInternalFaces = new QCheckBox( tr("USE_THRESHOLD_FOR_INTERNAL_FACES"), GroupC1 ); + argGroupLayout->addWidget( myUseThresholdForInternalFaces, row, 0, 1, 2 ); + row++; + mySetQuanta = new QCheckBox( tr("SET_QUANTA"), GroupC1 ); + argGroupLayout->addWidget( mySetQuanta, row, 0, 1, 2 ); + row++; + + argGroupLayout->addWidget( new QLabel( tr("QUANTA_VALUE"), GroupC1 ), row, 0 ); + myQuanta = new SMESHGUI_SpinBox( GroupC1 ); + myQuanta->setAcceptNames( false ); + myQuanta->RangeStepAndValidator( 1e-6, 1, 0.05, "length_precision" ); + myQuanta->setEnabled(false); + argGroupLayout->addWidget( myQuanta, row, 1 ); + row++; // 3) Grid definition QTabWidget* tabWdg = new QTabWidget( fr ); @@ -858,7 +894,9 @@ QFrame* StdMeshersGUI_CartesianParamCreator::buildFrame() axisLbl[2] = new QLabel( tr( "AXIS_Z"), axesDirGrp ); QLabel* dLbl[3]; myAxisBtnGrp = new QButtonGroup( axesDirGrp ); - SMESHGUI_SpinBox** spins[3] = { &myXDirSpin[0], &myYDirSpin[0], &myZDirSpin[0] }; + // get spin width + const char * const precisionType = "len_tol_precision"; + int minWidth = getMinWidth( precisionType ); for ( int i = 0; i < 3; ++i ) { QPushButton* axisBtn = new QPushButton( QIcon(aPix), "", axesDirGrp ); @@ -867,9 +905,12 @@ QFrame* StdMeshersGUI_CartesianParamCreator::buildFrame() myXDirSpin[i] = new SMESHGUI_SpinBox( axesDirGrp ); myYDirSpin[i] = new SMESHGUI_SpinBox( axesDirGrp ); myZDirSpin[i] = new SMESHGUI_SpinBox( axesDirGrp ); - myXDirSpin[i]->RangeStepAndValidator( -1, 1, 0.1, "len_tol_precision" ); - myYDirSpin[i]->RangeStepAndValidator( -1, 1, 0.1, "len_tol_precision" ); - myZDirSpin[i]->RangeStepAndValidator( -1, 1, 0.1, "len_tol_precision" ); + myXDirSpin[i]->RangeStepAndValidator( -1, 1, 0.1, precisionType ); + myYDirSpin[i]->RangeStepAndValidator( -1, 1, 0.1, precisionType ); + myZDirSpin[i]->RangeStepAndValidator( -1, 1, 0.1, precisionType ); + myXDirSpin[i]->setMinimumWidth( minWidth ); + myYDirSpin[i]->setMinimumWidth( minWidth ); + myZDirSpin[i]->setMinimumWidth( minWidth ); dLbl[0] = new QLabel( tr("SMESH_DX"), axesDirGrp ); dLbl[1] = new QLabel( tr("SMESH_DY"), axesDirGrp ); dLbl[2] = new QLabel( tr("SMESH_DZ"), axesDirGrp ); @@ -903,6 +944,9 @@ QFrame* StdMeshersGUI_CartesianParamCreator::buildFrame() connect( myOrthogonalChk, SIGNAL( toggled(bool)), SLOT( onOrthogonalAxes(bool))); connect( optimBtn, SIGNAL( clicked(bool)), SLOT( onOptimalAxes(bool))); connect( resetBtn, SIGNAL( clicked(bool)), SLOT( onResetAxes(bool))); + connect( myConsiderInternalFaces, SIGNAL( toggled(bool)), + myUseThresholdForInternalFaces, SLOT( setEnabled(bool))); + connect( mySetQuanta, SIGNAL( clicked(bool)), SLOT( onSetQuanta(bool)) ); for ( int i = 0; i < 3; ++i ) { connect( myXDirSpin[i], SIGNAL(valueChanged (const QString&)), @@ -923,9 +967,7 @@ QFrame* StdMeshersGUI_CartesianParamCreator::buildFrame() if ( !shapeEntry.isEmpty() ) { // find origin - Handle(SALOME_InteractiveObject) io = - new SALOME_InteractiveObject( shapeEntry.toStdString().c_str(), "GEOM" ); - GEOM::GEOM_Object_var geomObj = SMESH::IObjectToInterface( io ); + GEOM::GEOM_Object_var geomObj = SMESH::EntryToInterface( shapeEntry ); if ( GEOMBase::GetShape( geomObj, shape ) && !shape.IsNull()) { Bnd_Box box; @@ -959,7 +1001,7 @@ QFrame* StdMeshersGUI_CartesianParamCreator::buildFrame() //================================================================================ /*! - * \brief Tranfer parameters from hypothesis to widgets + * \brief Transfer parameters from hypothesis to widgets */ //================================================================================ @@ -978,6 +1020,13 @@ void StdMeshersGUI_CartesianParamCreator::retrieveParams() const myThreshold->setText( varName ); myAddEdges->setChecked( h->GetToAddEdges() ); + myCreateFaces->setChecked( h->GetToCreateFaces() ); + myConsiderInternalFaces->setChecked( h->GetToConsiderInternalFaces() ); + myUseThresholdForInternalFaces->setChecked( h->GetToUseThresholdForInternalFaces() ); + mySetQuanta->setChecked( h->GetToUseQuanta() ); + myQuanta->setValue( h->GetQuanta() ); + if (h->GetToUseQuanta()) + myQuanta->setEnabled(true); // grid definition for ( int ax = 0; ax < 3; ++ax ) @@ -1047,7 +1096,7 @@ void StdMeshersGUI_CartesianParamCreator::retrieveParams() const //================================================================================ /*! - * \brief Tranfer parameters from widgets to hypothesis + * \brief Transfer parameters from widgets to hypothesis */ //================================================================================ @@ -1059,12 +1108,17 @@ QString StdMeshersGUI_CartesianParamCreator::storeParams() const try { if( isCreation() ) - SMESH::SetName( SMESH::FindSObject( h ), myName->text().toLatin1().constData() ); + SMESH::SetName( SMESH::FindSObject( h ), myName->text().toUtf8().constData() ); // threshold h->SetVarParameter( myThreshold->text().toLatin1().constData(), "SetSizeThreshold" ); h->SetSizeThreshold( myThreshold->text().toDouble() ); h->SetToAddEdges( myAddEdges->isChecked() ); + h->SetToCreateFaces( myCreateFaces->isChecked() ); + h->SetToConsiderInternalFaces( myConsiderInternalFaces->isChecked() ); + h->SetToUseThresholdForInternalFaces( myUseThresholdForInternalFaces->isChecked() ); + h->SetToUseQuanta( mySetQuanta->isChecked() ); + h->SetQuanta( myQuanta->text().toDouble() ); // grid for ( int ax = 0; ax < 3; ++ax ) @@ -1088,7 +1142,7 @@ QString StdMeshersGUI_CartesianParamCreator::storeParams() const params << myPointSpin[0]->text(); params << myPointSpin[1]->text(); params << myPointSpin[2]->text(); - h->SetVarParameter( params.join(":").toLatin1().constData(), "SetFixedPoint" ); + h->SetVarParameter( params.join(":").toUtf8().constData(), "SetFixedPoint" ); params.clear(); SMESH::PointStruct ps; @@ -1105,7 +1159,7 @@ QString StdMeshersGUI_CartesianParamCreator::storeParams() const params << spins[ax][1]->text(); params << spins[ax][2]->text(); } - h->SetVarParameter( params.join(":").toLatin1().constData(), "SetAxesDirs" ); + h->SetVarParameter( params.join(":").toUtf8().constData(), "SetAxesDirs" ); SMESH::DirStruct axDir[3]; for ( int ax = 0; ax < 3; ++ax ) @@ -1132,7 +1186,7 @@ QString StdMeshersGUI_CartesianParamCreator::storeParams() const QString StdMeshersGUI_CartesianParamCreator::helpPage() const { - return "cartesian_algo_page.html#cartesian_hyp_anchor"; + return "cartesian_algo.html#cartesian-hyp-anchor"; } //================================================================================ @@ -1356,9 +1410,7 @@ void StdMeshersGUI_CartesianParamCreator::onOptimalAxes(bool) if ( shapeEntry.isEmpty() ) return; - Handle(SALOME_InteractiveObject) io = - new SALOME_InteractiveObject( shapeEntry.toStdString().c_str(), "GEOM" ); - GEOM::GEOM_Object_var geomObj = SMESH::IObjectToInterface( io ); + GEOM::GEOM_Object_var geomObj = SMESH::EntryToInterface( shapeEntry ); if ( geomObj->_is_nil() ) return; @@ -1407,7 +1459,7 @@ void StdMeshersGUI_CartesianParamCreator::onResetAxes(bool) //================================================================================ /*! - * \brief SLOT called when the grid definintion mode changes + * \brief SLOT called when the grid definition mode changes */ //================================================================================ @@ -1419,3 +1471,19 @@ void StdMeshersGUI_CartesianParamCreator::onGridModeChanged(int) myFixedPointGrp->setEnabled( haveSpacing ); } + +//================================================================================ +/*! + * \brief Enable and disable quanta value combo box + */ +//================================================================================ + +void StdMeshersGUI_CartesianParamCreator::onSetQuanta(bool) +{ + StdMeshers::StdMeshers_CartesianParameters3D_var h = + StdMeshers::StdMeshers_CartesianParameters3D::_narrow( hypothesis() ); + if ( h->_is_nil() ) + return; + + myQuanta->setEnabled( mySetQuanta->isChecked() ); +}