X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshersGUI%2FStdMeshersGUI_NbSegmentsCreator.cxx;h=0d095e26bb96313ad2fddfc5a4d3d6e9c320a5a6;hb=f757d34e5ab5e6471f7d49c835b6d7b0d58009c8;hp=9e8e0bda842b80b5672c123d7dacee87a15723ca;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070;p=modules%2Fsmesh.git diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx index 9e8e0bda8..0d095e26b 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx @@ -1,31 +1,36 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// 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. +// 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, 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 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : StdMeshersGUI_NbSegmentsCreator.cxx // Author : Open CASCADE S.A.S. // SMESH includes // #include "StdMeshersGUI_NbSegmentsCreator.h" +#ifndef DISABLE_PLOT2DVIEWER + #include "StdMeshersGUI_DistrPreview.h" +#endif #include "StdMeshersGUI_DistrTable.h" -#include "StdMeshersGUI_DistrPreview.h" +#include "StdMeshersGUI_PropagationHelperWdg.h" +#include "StdMeshersGUI_SubShapeSelectorWdg.h" #include #include @@ -61,7 +66,9 @@ StdMeshersGUI_NbSegmentsCreator::StdMeshersGUI_NbSegmentsCreator() myDistr( 0 ), myScale( 0 ), myTable( 0 ), +#ifndef DISABLE_PLOT2DVIEWER myPreview( 0 ), +#endif myExpr( 0 ), myConvBox( 0 ), myConv( 0 ), @@ -87,26 +94,27 @@ bool StdMeshersGUI_NbSegmentsCreator::checkParams( QString& msg ) const readParamsFromHypo( data_old ); readParamsFromWidgets( data_new ); bool res = storeParamsToHypo( data_new ); - storeParamsToHypo( data_old ); res = myNbSeg->isValid( msg, true ) && res; res = myScale->isValid( msg, true ) && res; + if ( !res ) + storeParamsToHypo( data_old ); return res; } QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() { QFrame* fr = new QFrame(); + fr->setMinimumWidth(460); QVBoxLayout* lay = new QVBoxLayout( fr ); lay->setMargin( 0 ); - lay->setSpacing( 0 ); + lay->setSpacing( SPACING ); QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr ); lay->addWidget( GroupC1 ); StdMeshers::StdMeshers_NumberOfSegments_var h = StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() ); - myPreview = new StdMeshersGUI_DistrPreview( GroupC1, h.in() ); myGroupLayout = new QGridLayout( GroupC1 ); myGroupLayout->setSpacing( SPACING ); @@ -125,6 +133,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() row++; } + // 1) number of segments myGroupLayout->addWidget( new QLabel( tr( "SMESH_NB_SEGMENTS_PARAM" ), GroupC1 ), row, 0 ); myNbSeg = new SalomeApp_IntSpinBox( GroupC1 ); @@ -133,6 +142,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() myGroupLayout->addWidget( myNbSeg, row, 1 ); row++; + // 2) type of distribution myGroupLayout->addWidget( new QLabel( tr( "SMESH_DISTR_TYPE" ), GroupC1 ), row, 0 ); myDistr = new QtxComboBox( GroupC1 ); @@ -145,32 +155,45 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() myGroupLayout->addWidget( myDistr, row, 1 ); row++; + // 3) scale myGroupLayout->addWidget( myLScale = new QLabel( tr( "SMESH_NB_SEGMENTS_SCALE_PARAM" ), GroupC1 ), row, 0 ); myScale = new SMESHGUI_SpinBox( GroupC1 ); - myScale->RangeStepAndValidator( 1E-5, 1E+5, 0.1, 6 ); + myScale->RangeStepAndValidator( 1E-5, 1E+5, 0.1, "parametric_precision" ); myGroupLayout->addWidget( myScale, row, 1 ); row++; - myInfo = new QLabel( tr( "SMESH_FUNC_DOMAIN" ), GroupC1 ); - myGroupLayout->addWidget( myInfo, row, 0, 1, 2 ); - row++; - // 4) table - myGroupLayout->addWidget( myLTable = new QLabel( tr( "SMESH_TAB_FUNC" ), GroupC1 ), row, 0 ); - myTable = new StdMeshersGUI_DistrTableFrame( GroupC1 ); - myGroupLayout->addWidget( myTable, row, 1 ); + // 4) Distribution definition + QGridLayout* myDistLayout = new QGridLayout(GroupC1); + myGroupLayout->addLayout( myDistLayout, row, 0, 1, 2 ); myGroupLayout->setRowStretch( row, 1 ); - myTableRow = row; - row++; + row ++; - // 5) expression - myGroupLayout->addWidget( myLExpr = new QLabel( tr( "SMESH_EXPR_FUNC" ), GroupC1 ), row, 0 ); + // a) expression + QHBoxLayout* myExprLayout = new QHBoxLayout(GroupC1); + myExprLayout->addWidget( myLExpr = new QLabel( "f(t)=", GroupC1 ), 0); myExpr = new QLineEdit( GroupC1 ); - myGroupLayout->addWidget( myExpr, row, 1 ); - row++; + myExprLayout->addWidget( myExpr,1); + myDistLayout->addLayout(myExprLayout,1 ,0); + myDistLayout->setRowStretch(2, 1); - // 6) conversion (radiogroup) + // b) warning + myInfo = new QLabel( tr( "SMESH_FUNC_DOMAIN" ), GroupC1 ); + myDistLayout->addWidget( myInfo, 0, 0, 1, 2); + + // c) table + myTable = new StdMeshersGUI_DistrTableFrame( GroupC1 ); + myTable->setMinimumHeight(220); + myDistLayout->addWidget( myTable, 1, 0, 2, 1 ); + +#ifndef DISABLE_PLOT2DVIEWER + // d) preview + myPreview = new StdMeshersGUI_DistrPreview( GroupC1, h.in() ); + myDistLayout->addWidget( myPreview, 1, 1, 2, 1 ); +#endif + + // 5) conversion (radiogroup) myConvBox = new QGroupBox( tr( "SMESH_CONV_MODE" ), GroupC1 ); myConv = new QButtonGroup( GroupC1 ); @@ -189,17 +212,39 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() myGroupLayout->addWidget( myConvBox, row, 0, 1, 2 ); row++; - // 7) distribution preview - myGroupLayout->addWidget( myPreview, row, 0, 1, 2 ); - myGroupLayout->setRowStretch( row, 1 ); - myPreviewRow = row; - row++; + + // 6) reverse edge parameters + myReversedEdgesBox = new QGroupBox(tr( "SMESH_REVERSED_EDGES" ), fr); + QHBoxLayout* edgeLay = new QHBoxLayout( myReversedEdgesBox ); + + myDirectionWidget = new StdMeshersGUI_SubShapeSelectorWdg( myReversedEdgesBox ); + QString aGeomEntry = getShapeEntry(); + QString aMainEntry = getMainShapeEntry(); + if ( aGeomEntry == "" ) + aGeomEntry = h->GetObjectEntry(); + myDirectionWidget->SetGeomShapeEntry( aGeomEntry, aMainEntry ); + myDirectionWidget->SetListOfIDs( h->GetReversedEdges() ); + edgeLay->addWidget( myDirectionWidget ); + + lay->addWidget( myReversedEdgesBox ); + lay->setStretchFactor( GroupC1, 1); + lay->setStretchFactor( myReversedEdgesBox, 1); + + myReversedEdgesHelper = 0; + if ( !aGeomEntry.isEmpty() || !aMainEntry.isEmpty() ) + { + myReversedEdgesHelper = new StdMeshersGUI_PropagationHelperWdg( myDirectionWidget, fr, false ); + lay->addWidget( myReversedEdgesHelper ); + lay->setStretchFactor( myReversedEdgesHelper, 1 ); + } connect( myNbSeg, SIGNAL( valueChanged( const QString& ) ), this, SLOT( onValueChanged() ) ); connect( myDistr, SIGNAL( activated( int ) ), this, SLOT( onValueChanged() ) ); connect( myTable, SIGNAL( valueChanged( int, int ) ), this, SLOT( onValueChanged() ) ); connect( myExpr, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) ); - connect( myConv, SIGNAL( cuttonClicked( int ) ), this, SLOT( onValueChanged() ) ); + connect( myConv, SIGNAL( buttonClicked( int ) ), this, SLOT( onValueChanged() ) ); + + onValueChanged(); return fr; } @@ -250,13 +295,13 @@ QString StdMeshersGUI_NbSegmentsCreator::storeParams() const case Regular : valStr += tr("SMESH_DISTR_REGULAR"); break; - case Scale : - valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale );\ + case Scale : + valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale ); break; case TabFunc : { //valStr += tr("SMESH_TAB_FUNC"); bool param = true; - for( int i=0; i < data.myTable.length(); i++, param = !param ) { + for( CORBA::ULong i = 0; i < data.myTable.length(); i++, param = !param ) { if ( param ) valStr += "["; valStr += QString::number( data.myTable[ i ]); @@ -271,10 +316,12 @@ QString StdMeshersGUI_NbSegmentsCreator::storeParams() const break; } if ( hasConv ) + { if ( data.myConv ) valStr += "; " + tr("SMESH_CUT_NEG_MODE"); else valStr += "; " + tr("SMESH_EXP_MODE"); + } return valStr; } @@ -287,17 +334,17 @@ bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisDa h_data.myName = hypName(); h_data.myNbSeg = (int) h->GetNumberOfSegments(); - - SMESH::ListOfParameters_var aParameters = h->GetLastParameters(); - h_data.myNbSegVarName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString(""); + CORBA::String_var aVaribaleName = h->GetVarParameter( "SetNumberOfSegments" ); + h_data.myNbSegVarName = aVaribaleName.in(); int distr = (int) h->GetDistrType(); h_data.myDistrType = distr; h_data.myScale = distr==1 ? h->GetScaleFactor() : 1.0; - if(distr==1){ - h_data.myScaleVarName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString(""); + if(distr==1) { + aVaribaleName = h->GetVarParameter( "SetScaleFactor" ); + h_data.myScaleVarName = aVaribaleName.in(); } else h_data.myScaleVarName = QString(""); @@ -334,20 +381,24 @@ bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothe if( isCreation() ) SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().data() ); - QStringList aVariablesList; - aVariablesList.append(h_data.myNbSegVarName); - + h->SetVarParameter( h_data.myNbSegVarName.toLatin1().constData(), "SetNumberOfSegments" ); h->SetNumberOfSegments( h_data.myNbSeg ); - int distr = h_data.myDistrType; - h->SetDistrType( distr ); + int distr = h_data.myDistrType; + if ( distr == 0 ) + h->SetDistrType( distr ); // this is actually needed at non-uniform -> uniform switch if( distr==1 ) { + h->SetVarParameter( h_data.myScaleVarName.toLatin1().constData(), "SetScaleFactor" ); h->SetScaleFactor( h_data.myScale ); - aVariablesList.append(h_data.myScaleVarName); } if( distr==2 || distr==3 ) h->SetConversionMode( h_data.myConv ); + if( distr==1 || distr==2 || distr==3 ) { + h->SetReversedEdges( myDirectionWidget->GetListOfIDs() ); + h->SetObjectEntry( myDirectionWidget->GetMainShapeEntry() ); + } + if( distr==2 ) h->SetTableFunction( h_data.myTable ); @@ -356,8 +407,6 @@ bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothe //setting of function must follow after setConversionMode, because otherwise //the function will be checked with old conversion mode, so that it may occurs //unexpected errors for user - - h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } catch(const SALOME::SALOME_Exception& ex) { @@ -398,26 +447,27 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged() myTable->setData( arr ); //update data in table } - myScale->setShown( distr==1 ); - myLScale->setShown( distr==1 ); + myScale->setVisible( distr==1 ); + myLScale->setVisible( distr==1 ); + myReversedEdgesBox->setVisible( distr!=0 ); + if ( myReversedEdgesHelper ) { + myReversedEdgesHelper->Clear(); + myReversedEdgesHelper->setVisible( distr!=0 ); + } + myDirectionWidget->ShowPreview( distr!=0 ); bool isFunc = distr==2 || distr==3; - myPreview->setShown( isFunc ); - myGroupLayout->setRowStretch( myPreviewRow, isFunc ? 1 : 0 ); - - myConvBox->setShown( isFunc ); - - if( distr==2 ) - myTable->show(); - else - myTable->hide(); - myLTable->setShown( distr==2 ); - myGroupLayout->setRowStretch( myTableRow, distr==2 ? 1 : 0 ); - - myExpr->setShown( distr==3 ); - myLExpr->setShown( distr==3 ); - myInfo->setShown( isFunc ); +#ifndef DISABLE_PLOT2DVIEWER + myPreview->setVisible( isFunc ); +#endif + myConvBox->setVisible( isFunc ); + + myTable->setVisible( distr==2 ); + myExpr->setVisible( distr==3 ); + myLExpr->setVisible( distr==3 ); + myInfo->setVisible( distr==3); +#ifndef DISABLE_PLOT2DVIEWER //change of preview int nbSeg = myNbSeg->value(); if( distr==2 ) //preview for table-described function @@ -431,11 +481,15 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged() if( isFunc ) myPreview->setConversion( StdMeshersGUI_DistrPreview::Conversion( myConv->checkedId() ) ); +#endif if ( (QtxComboBox*)sender() == myDistr && dlg() ) { QApplication::instance()->processEvents(); + myGroupLayout->invalidate(); + dlg()->layout()->invalidate(); dlg()->updateGeometry(); - dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() ); + dlg()->setMinimumSize( dlg()->minimumSizeHint() ); dlg()->resize( dlg()->minimumSize() ); + QApplication::instance()->processEvents(); } }