//
#include "StdMeshersGUI_FixedPointsParamWdg.h"
+#include <QtxIntSpinBox.h>
+#include <QtxDoubleSpinBox.h>
+
// Qt includes
#include <QPushButton>
#include <QIntValidator>
#include <QTreeWidgetItem>
#include <QCheckBox>
#include <QLineEdit>
-#include <QDoubleSpinBox>
#include <QItemDelegate>
#include <QKeyEvent>
#define MARGIN 0
#define SAME_TEXT "-/-"
+#define TOLERANCE 1e-7
+#define EQUAL_DBL(a,b) (fabs(a-b)<TOLERANCE)
+
/*
- * function : Tree Widget Item Delegate
+ * class : Tree Widget Item Delegate
* purpose : Custom item delegate
*/
{
QWidget* w = 0;
if ( (index.column() == 1 ) ) {
- QSpinBox* sb = new QSpinBox( parent );
+ QtxIntSpinBox* sb = new QtxIntSpinBox( parent );
sb->setFrame( false );
sb->setRange( 1, 999);
w = sb;
QAbstractItemModel* model,
const QModelIndex& index ) const
{
- model->setData( index, qobject_cast<QSpinBox*>( editor )->value(), Qt::EditRole );
- model->setData( index, qobject_cast<QSpinBox*>( editor )->value(), Qt::UserRole );
+ model->setData( index, qobject_cast<QtxIntSpinBox*>( editor )->value(), Qt::EditRole );
+ model->setData( index, qobject_cast<QtxIntSpinBox*>( editor )->value(), Qt::UserRole );
}
//================================================================================
myListWidget = new QListWidget( this );
myTreeWidget = new QTreeWidget( this );
- mySpinBox = new QDoubleSpinBox( this );
+ mySpinBox = new QtxDoubleSpinBox( this );
myAddButton = new QPushButton( tr( "SMESH_BUT_ADD" ), this );
myRemoveButton = new QPushButton( tr( "SMESH_BUT_REMOVE" ), this );
mySameValues = new QCheckBox( tr("SMESH_SAME_NB_SEGMENTS"), this);
mySpinBox->setRange( 0, 1 );
mySpinBox->setSingleStep( 0.1 );
-
- connect( myAddButton, SIGNAL(clicked()), SLOT(onAdd()));
- connect( myRemoveButton, SIGNAL(clicked()), SLOT(onRemove()));
- connect( mySameValues, SIGNAL(stateChanged(int)), SLOT(onCheckBoxChanged()));
+ mySpinBox->setDecimals( 4 );
+ mySpinBox->setPrecision( 4 );
+ myListWidget->setMinimumWidth( 70 );
+
+ connect( myAddButton, SIGNAL( clicked() ), SLOT( onAdd() ) );
+ connect( myRemoveButton, SIGNAL( clicked() ), SLOT( onRemove() ) );
+ connect( mySameValues, SIGNAL( stateChanged( int ) ), SLOT( onCheckBoxChanged() ) );
+ connect( mySpinBox, SIGNAL( valueChanged( double ) ), SLOT( updateState() ) );
+ connect( myListWidget, SIGNAL( itemSelectionChanged() ), SLOT( updateState() ) );
myListWidget->installEventFilter( this );
clear();
myTreeWidget->addTopLevelItem( newTreeItem( 0, 1 ) );
mySpinBox->setValue( 0. );
onCheckBoxChanged();
+ updateState();
}
//=================================================================================
int idx = myTreeWidget->topLevelItemCount()-1;
for ( int i = 0 ; i < myListWidget->count(); i++ ) {
double lv = point( i );
- if ( lv == v ) { toInsert = false; break; }
+ if ( EQUAL_DBL(lv,v) ) { toInsert = false; break; }
else if ( lv > v ) {
idx = i; break;
}
onCheckBoxChanged();
}
}
+ updateState();
}
//=================================================================================
idx > myListWidget->count()-1 ? 1 : point( idx ) ) );
}
onCheckBoxChanged();
+ updateState();
}
double StdMeshersGUI_FixedPointsParamWdg::point( int idx ) const
}
}
+//=================================================================================
+// function : updateState()
+// purpose : Update widgets state
+//=================================================================================
+void StdMeshersGUI_FixedPointsParamWdg::updateState()
+{
+ myAddButton->setEnabled( mySpinBox->value() > 0 && mySpinBox->value() < 1 );
+ myRemoveButton->setEnabled( myListWidget->selectedItems().count() > 0 );
+}
+
//=================================================================================
// function : GetListOfPoints
// purpose : Called to get the list of Edges IDs
anArray->length( size );
for (int i = 0; i < size; i++) {
anArray[i] = point(i);
- // printf ("Point %f \n", anArray[i]);
}
return anArray;
}
clear();
for ( int i = 0; i < thePoints->length(); i++ ) {
addPoint( thePoints[ i ] );
- // printf ("Add Point %f \n", thePoints[ i ]);
}
}
anArray->length( size );
for (int i = 0; i < size; i++) {
anArray[i] = nbSegments( i );
- // printf ("Segments %d \n", anArray[i] );
}
return anArray;
}
mySameValues->setChecked(true);
for ( int i = 0; i < theSegments->length(); i++ ) {
setNbSegments( i, theSegments[i] );
- // printf ("\nadd Segment = %d\n", theSegments[i]);
}
}