rnc: Modified "Number Of Segment" window so that the use of table density is more convenient.

This commit is contained in:
gdd 2011-04-27 12:40:02 +00:00
parent c67b2bfd8f
commit ed17a76996
6 changed files with 71 additions and 61 deletions

View File

@ -78,7 +78,7 @@ StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::
QwtText mt = myMsg->label(); QwtText mt = myMsg->label();
mt.setBackgroundPen( QPen( Qt::red, 1 ) ); mt.setBackgroundPen( QPen( Qt::red, 1 ) );
QFont f = mt.font(); QFont f = mt.font();
f.setPointSize( 14 ); f.setBold( true ); f.setPointSize( 14 ); //f.setBold( true );
mt.setFont( f ); mt.setFont( f );
myMsg->setLabel( mt ); myMsg->setLabel( mt );
myDensity->setPen( QPen( Qt::red, 1 ) ); myDensity->setPen( QPen( Qt::red, 1 ) );
@ -94,6 +94,17 @@ StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::
} }
insertLegend( l, QwtPlot::BottomLegend ); insertLegend( l, QwtPlot::BottomLegend );
enableAxis(QwtPlot::yLeft, false);
enableAxis(QwtPlot::yRight, true);
QFont axisFont;
axisFont.setPointSize( 8 );
setAxisFont(QwtPlot::yRight, axisFont);
setAxisFont(QwtPlot::xBottom, axisFont);
myDensity->setYAxis(QwtPlot::yRight);
myDistr->setYAxis(QwtPlot::yRight);
myMsg->setYAxis(QwtPlot::yRight);
myDensity->setTitle( tr( "SMESH_DENSITY_FUNC" ) ); myDensity->setTitle( tr( "SMESH_DENSITY_FUNC" ) );
myDistr->setTitle( tr( "SMESH_DISTR" ) ); myDistr->setTitle( tr( "SMESH_DISTR" ) );

View File

@ -31,6 +31,7 @@
// Qt incldues // Qt incldues
#include <QItemDelegate> #include <QItemDelegate>
#include <QTableWidget> #include <QTableWidget>
#include <QHeaderView>
#include <QPushButton> #include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
@ -244,6 +245,8 @@ Table( QWidget* parent, int rows )
QStringList labs; QStringList labs;
labs << "t" << "f(t)"; labs << "t" << "f(t)";
setHorizontalHeaderLabels( labs ); setHorizontalHeaderLabels( labs );
this->horizontalHeader()->setStretchLastSection(true);
this->horizontalHeader()->setDefaultSectionSize(60);
while( rows-- ) while( rows-- )
addRow(); addRow();
@ -412,14 +415,14 @@ sizeHint() const
if( cachedSizeHint().isValid() ) if( cachedSizeHint().isValid() )
return cachedSizeHint(); return cachedSizeHint();
QSize sh = QTableWidget::sizeHint(); // QSize sh = QTableWidget::sizeHint();
if( sh.width() < 400 ) // if( sh.width() < 400 )
sh.setWidth( 400 ); // sh.setWidth( 400 );
if( sh.height() < 200 ) // if( sh.height() < 200 )
sh.setHeight( 200 ); // sh.setHeight( 200 );
//
setCachedSizeHint( sh ); // setCachedSizeHint( sh );
return sh; // return sh;
} }
void void
@ -507,7 +510,7 @@ StdMeshersGUI_DistrTableFrame::
StdMeshersGUI_DistrTableFrame( QWidget* parent ) StdMeshersGUI_DistrTableFrame( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
{ {
QVBoxLayout* main = new QVBoxLayout( this ); QGridLayout* main = new QGridLayout( this );
main->setMargin( 0 ); main->setMargin( 0 );
main->setSpacing( 0 ); main->setSpacing( 0 );
@ -515,22 +518,16 @@ StdMeshersGUI_DistrTableFrame( QWidget* parent )
myTable = new Table( this ); myTable = new Table( this );
connect( myTable, SIGNAL( valueChanged( int, int ) ), this, SIGNAL( valueChanged( int, int ) ) ); connect( myTable, SIGNAL( valueChanged( int, int ) ), this, SIGNAL( valueChanged( int, int ) ) );
// --- myButtons[ InsertRowBtn ] = new QPushButton( tr( "SMESH_INSERT_ROW" ), this );
QWidget* aButFrame = new QWidget( this ); myButtons[ RemoveRowBtn ] = new QPushButton( tr( "SMESH_REMOVE_ROW" ), this );
QHBoxLayout* butLay = new QHBoxLayout( aButFrame );
butLay->setContentsMargins( 0, SPACING, 0, SPACING );
butLay->setSpacing( SPACING );
myButtons[ InsertRowBtn ] = new QPushButton( tr( "SMESH_INSERT_ROW" ), aButFrame );
myButtons[ RemoveRowBtn ] = new QPushButton( tr( "SMESH_REMOVE_ROW" ), aButFrame );
butLay->addWidget( myButtons[ InsertRowBtn ] );
butLay->addWidget( myButtons[ RemoveRowBtn ] );
butLay->addStretch();
// --- // ---
main->addWidget( myTable ); main->addWidget( myTable , 0, 0, 1, 3);
main->addWidget( aButFrame ); main->addWidget( myButtons[ InsertRowBtn ] , 1, 0);
main->addWidget( myButtons[ RemoveRowBtn ] , 1, 1);
main->setColumnStretch(2, 1);
main->setSpacing( SPACING );
// --- // ---
connect( myButtons[ InsertRowBtn ], SIGNAL( clicked() ), this, SLOT( onInsert() ) ); connect( myButtons[ InsertRowBtn ], SIGNAL( clicked() ), this, SLOT( onInsert() ) );

View File

@ -98,6 +98,7 @@ bool StdMeshersGUI_NbSegmentsCreator::checkParams( QString& msg ) const
QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
{ {
QFrame* fr = new QFrame(); QFrame* fr = new QFrame();
fr->setMinimumWidth(460);
QVBoxLayout* lay = new QVBoxLayout( fr ); QVBoxLayout* lay = new QVBoxLayout( fr );
lay->setMargin( 0 ); lay->setMargin( 0 );
@ -108,7 +109,6 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
StdMeshers::StdMeshers_NumberOfSegments_var h = StdMeshers::StdMeshers_NumberOfSegments_var h =
StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() ); StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
myPreview = new StdMeshersGUI_DistrPreview( GroupC1, h.in() );
myGroupLayout = new QGridLayout( GroupC1 ); myGroupLayout = new QGridLayout( GroupC1 );
myGroupLayout->setSpacing( SPACING ); myGroupLayout->setSpacing( SPACING );
@ -127,6 +127,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
row++; row++;
} }
// 1) number of segments // 1) number of segments
myGroupLayout->addWidget( new QLabel( tr( "SMESH_NB_SEGMENTS_PARAM" ), GroupC1 ), row, 0 ); myGroupLayout->addWidget( new QLabel( tr( "SMESH_NB_SEGMENTS_PARAM" ), GroupC1 ), row, 0 );
myNbSeg = new SalomeApp_IntSpinBox( GroupC1 ); myNbSeg = new SalomeApp_IntSpinBox( GroupC1 );
@ -135,6 +136,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
myGroupLayout->addWidget( myNbSeg, row, 1 ); myGroupLayout->addWidget( myNbSeg, row, 1 );
row++; row++;
// 2) type of distribution // 2) type of distribution
myGroupLayout->addWidget( new QLabel( tr( "SMESH_DISTR_TYPE" ), GroupC1 ), row, 0 ); myGroupLayout->addWidget( new QLabel( tr( "SMESH_DISTR_TYPE" ), GroupC1 ), row, 0 );
myDistr = new QtxComboBox( GroupC1 ); myDistr = new QtxComboBox( GroupC1 );
@ -147,6 +149,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
myGroupLayout->addWidget( myDistr, row, 1 ); myGroupLayout->addWidget( myDistr, row, 1 );
row++; row++;
// 3) scale // 3) scale
myGroupLayout->addWidget( myLScale = new QLabel( tr( "SMESH_NB_SEGMENTS_SCALE_PARAM" ), GroupC1 ), row, 0 ); myGroupLayout->addWidget( myLScale = new QLabel( tr( "SMESH_NB_SEGMENTS_SCALE_PARAM" ), GroupC1 ), row, 0 );
myScale = new SMESHGUI_SpinBox( GroupC1 ); myScale = new SMESHGUI_SpinBox( GroupC1 );
@ -154,25 +157,35 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
myGroupLayout->addWidget( myScale, row, 1 ); myGroupLayout->addWidget( myScale, row, 1 );
row++; row++;
myInfo = new QLabel( tr( "SMESH_FUNC_DOMAIN" ), GroupC1 );
myGroupLayout->addWidget( myInfo, row, 0, 1, 2 );
row++;
// 4) table // 4) Distribution definition
myGroupLayout->addWidget( myLTable = new QLabel( tr( "SMESH_TAB_FUNC" ), GroupC1 ), row, 0 ); QGridLayout* myDistLayout = new QGridLayout(GroupC1);
myTable = new StdMeshersGUI_DistrTableFrame( GroupC1 ); myGroupLayout->addLayout( myDistLayout, row, 0, 1, 2 );
myGroupLayout->addWidget( myTable, row, 1 );
myGroupLayout->setRowStretch( row, 1 ); myGroupLayout->setRowStretch( row, 1 );
myTableRow = row; row ++;
row++;
// 5) expression // a) expression
myGroupLayout->addWidget( myLExpr = new QLabel( tr( "SMESH_EXPR_FUNC" ), GroupC1 ), row, 0 ); QHBoxLayout* myExprLayout = new QHBoxLayout(GroupC1);
myExprLayout->addWidget( myLExpr = new QLabel( "f(t)=", GroupC1 ), 0);
myExpr = new QLineEdit( GroupC1 ); myExpr = new QLineEdit( GroupC1 );
myGroupLayout->addWidget( myExpr, row, 1 ); myExprLayout->addWidget( myExpr,1);
row++; 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 );
myDistLayout->addWidget( myTable, 1, 0, 2, 1 );
// d) preview
myPreview = new StdMeshersGUI_DistrPreview( GroupC1, h.in() );
myPreview->setMinimumHeight(220);
myDistLayout->addWidget( myPreview, 1, 1, 2, 1 );
// 5) conversion (radiogroup)
myConvBox = new QGroupBox( tr( "SMESH_CONV_MODE" ), GroupC1 ); myConvBox = new QGroupBox( tr( "SMESH_CONV_MODE" ), GroupC1 );
myConv = new QButtonGroup( GroupC1 ); myConv = new QButtonGroup( GroupC1 );
@ -191,17 +204,12 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
myGroupLayout->addWidget( myConvBox, row, 0, 1, 2 ); myGroupLayout->addWidget( myConvBox, row, 0, 1, 2 );
row++; row++;
// 7) distribution preview
myGroupLayout->addWidget( myPreview, row, 0, 1, 2 );
myGroupLayout->setRowStretch( row, 1 );
myPreviewRow = row;
row++;
// 8) reverce edge parameters // 6) reverse edge parameters
myReversedEdgesBox = new QGroupBox(tr( "SMESH_REVERSED_EDGES" ), fr); myReversedEdgesBox = new QGroupBox(tr( "SMESH_REVERSED_EDGES" ), fr);
QHBoxLayout* edgeLay = new QHBoxLayout( myReversedEdgesBox ); QHBoxLayout* edgeLay = new QHBoxLayout( myReversedEdgesBox );
myDirectionWidget = new StdMeshersGUI_SubShapeSelectorWdg(); myDirectionWidget = new StdMeshersGUI_SubShapeSelectorWdg( myReversedEdgesBox );
QString aGeomEntry = getShapeEntry(); QString aGeomEntry = getShapeEntry();
QString aMainEntry = getMainShapeEntry(); QString aMainEntry = getMainShapeEntry();
if ( aGeomEntry == "" ) if ( aGeomEntry == "" )
@ -212,6 +220,8 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
edgeLay->addWidget( myDirectionWidget ); edgeLay->addWidget( myDirectionWidget );
lay->addWidget( myReversedEdgesBox ); lay->addWidget( myReversedEdgesBox );
lay->setStretchFactor( GroupC1, 2);
lay->setStretchFactor( myReversedEdgesBox, 1);
connect( myNbSeg, SIGNAL( valueChanged( const QString& ) ), this, SLOT( onValueChanged() ) ); connect( myNbSeg, SIGNAL( valueChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
connect( myDistr, SIGNAL( activated( int ) ), this, SLOT( onValueChanged() ) ); connect( myDistr, SIGNAL( activated( int ) ), this, SLOT( onValueChanged() ) );
@ -428,20 +438,12 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged()
bool isFunc = distr==2 || distr==3; bool isFunc = distr==2 || distr==3;
myPreview->setShown( isFunc ); myPreview->setShown( isFunc );
myGroupLayout->setRowStretch( myPreviewRow, isFunc ? 1 : 0 );
myConvBox->setShown( isFunc ); myConvBox->setShown( isFunc );
if( distr==2 ) myTable->setShown( distr==2 );
myTable->show();
else
myTable->hide();
myLTable->setShown( distr==2 );
myGroupLayout->setRowStretch( myTableRow, distr==2 ? 1 : 0 );
myExpr->setShown( distr==3 ); myExpr->setShown( distr==3 );
myLExpr->setShown( distr==3 ); myLExpr->setShown( distr==3 );
myInfo->setShown( isFunc ); myInfo->setShown( distr==3);
//change of preview //change of preview
int nbSeg = myNbSeg->value(); int nbSeg = myNbSeg->value();

View File

@ -102,7 +102,7 @@ StdMeshersGUI_SubShapeSelectorWdg
edgesLayout->addWidget(myAddButton, 0, 4); edgesLayout->addWidget(myAddButton, 0, 4);
edgesLayout->addWidget(myRemoveButton, 1, 4); edgesLayout->addWidget(myRemoveButton, 1, 4);
edgesLayout->setRowStretch(2, 5); //edgesLayout->setRowStretch(2, 5);
edgesLayout->setColumnStretch(2, 5); edgesLayout->setColumnStretch(2, 5);
setLayout( edgesLayout ); setLayout( edgesLayout );

View File

@ -77,7 +77,7 @@
</message> </message>
<message> <message>
<source>SMESH_EXPR_FUNC</source> <source>SMESH_EXPR_FUNC</source>
<translation>Density function f(t) = </translation> <translation>Density function</translation>
</message> </message>
<message> <message>
<source>SMESH_EXP_MODE</source> <source>SMESH_EXP_MODE</source>

View File

@ -77,7 +77,7 @@
</message> </message>
<message> <message>
<source>SMESH_EXPR_FUNC</source> <source>SMESH_EXPR_FUNC</source>
<translation>Expression de la densité f(t) = </translation> <translation>Expression de la densité</translation>
</message> </message>
<message> <message>
<source>SMESH_EXP_MODE</source> <source>SMESH_EXP_MODE</source>
@ -89,7 +89,7 @@
</message> </message>
<message> <message>
<source>SMESH_FUNC_DOMAIN</source> <source>SMESH_FUNC_DOMAIN</source>
<translation>Avertissement: il faut définir la fonction sur le segment [0..1]</translation> <translation>Avertissement: La fonction doit ếtre définie sur le segment [0..1]</translation>
</message> </message>
<message> <message>
<source>SMESH_INSERT_ROW</source> <source>SMESH_INSERT_ROW</source>