#include <StdMeshersGUI_FixedPointsParamWdg.h>

Data Structures | |
| class | LineDelegate |
Public Member Functions | |
| StdMeshersGUI_FixedPointsParamWdg (QWidget *parent=0) | |
| Constructor. | |
| ~StdMeshersGUI_FixedPointsParamWdg () | |
| Destructor. | |
| bool | eventFilter (QObject *, QEvent *) |
| Event filter. | |
| SMESH::double_array_var | GetListOfPoints () |
| void | SetListOfPoints (SMESH::double_array_var) |
| SMESH::long_array_var | GetListOfSegments () |
| void | SetListOfSegments (SMESH::long_array_var) |
| QString | GetValue () const |
Private Slots | |
| void | onAdd () |
| void | onRemove () |
| void | onCheckBoxChanged () |
| void | updateState () |
Private Member Functions | |
| void | clear () |
| Clear widget. | |
| void | addPoint (double) |
| void | removePoints () |
| double | point (int) const |
| void | setNbSegments (int, int) |
| int | nbSegments (int) const |
Static Private Member Functions | |
| static QTreeWidgetItem * | newTreeItem (double v1, double v2) |
| static QListWidgetItem * | newListItem (double v1) |
| static QString | treeItemText (double v1, double v2) |
Private Attributes | |
| QListWidget * | myListWidget |
| QTreeWidget * | myTreeWidget |
| SMESHGUI_SpinBox * | mySpinBox |
| QPushButton * | myAddButton |
| QPushButton * | myRemoveButton |
| QCheckBox * | mySameValues |
| QString | myParamValue |
Definition at line 44 of file StdMeshersGUI_FixedPointsParamWdg.h.
| StdMeshersGUI_FixedPointsParamWdg::StdMeshersGUI_FixedPointsParamWdg | ( | QWidget * | parent = 0 | ) |
Constructor.
Definition at line 108 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References clear(), MARGIN, myAddButton, myListWidget, myRemoveButton, mySameValues, mySpinBox, myTreeWidget, onAdd(), onCheckBoxChanged(), onRemove(), SMESHGUI_SpinBox.RangeStepAndValidator(), SPACING, and updateState().
: QWidget( parent ) { QGridLayout* edgesLayout = new QGridLayout( this ); edgesLayout->setMargin( MARGIN ); edgesLayout->setSpacing( SPACING ); myListWidget = new QListWidget( this ); myTreeWidget = new QTreeWidget( this ); mySpinBox = new SMESHGUI_SpinBox( 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); myListWidget->setSelectionMode( QListWidget::ExtendedSelection ); myTreeWidget->setColumnCount(2); myTreeWidget->setHeaderLabels( QStringList() << tr( "SMESH_RANGE" ) << tr( "SMESH_NB_SEGMENTS" ) ); myTreeWidget->setColumnWidth( 1, 40 ); myTreeWidget->setColumnWidth( 2, 30 ); myTreeWidget->setItemDelegate( new LineDelegate( myTreeWidget ) ); edgesLayout->addWidget(myListWidget, 0, 0, 4, 1); edgesLayout->addWidget(mySpinBox, 0, 1); edgesLayout->addWidget(myAddButton, 1, 1); edgesLayout->addWidget(myRemoveButton, 2, 1); edgesLayout->addWidget(myTreeWidget, 0, 2, 4, 1); edgesLayout->addWidget(mySameValues, 4, 0, 1, 3); edgesLayout->setRowStretch( 3, 5 ); edgesLayout->setColumnStretch(0, 1); edgesLayout->setColumnStretch(1, 0); edgesLayout->setColumnStretch(2, 2); myListWidget->setMinimumWidth( 80 ); myTreeWidget->setMinimumWidth( 200 ); mySpinBox->setAcceptNames( false ); // No Notebook variables allowed mySpinBox->RangeStepAndValidator( 0., 1., .1, "parametric_precision" ); 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(); }
| StdMeshersGUI_FixedPointsParamWdg::~StdMeshersGUI_FixedPointsParamWdg | ( | ) |
| void StdMeshersGUI_FixedPointsParamWdg::addPoint | ( | double | v | ) | [private] |
Definition at line 256 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References EQUAL_DBL, GT_DBL, LT_DBL, myListWidget, myTreeWidget, newListItem(), newTreeItem(), onCheckBoxChanged(), point(), treeItemText(), and updateState().
Referenced by onAdd(), and SetListOfPoints().
{
if ( GT_DBL(v, 0.0) && LT_DBL(v, 1.0)) {
bool toInsert = true;
int idx = myTreeWidget->topLevelItemCount()-1;
for ( int i = 0 ; i < myListWidget->count(); i++ ) {
double lv = point( i );
if ( EQUAL_DBL(lv, v) ) { toInsert = false; break; }
else if ( GT_DBL(lv, v) ) {
idx = i; break;
}
}
if ( toInsert ) {
double v1 = idx == 0 ? 0 : point( idx-1 );
double v2 = idx == myTreeWidget->topLevelItemCount()-1 ? 1 : point( idx );
myTreeWidget->insertTopLevelItem( idx, newTreeItem( v1, v ) );
myTreeWidget->topLevelItem( idx+1 )->setText( 0, treeItemText( v, v2 ) );
myListWidget->insertItem( idx, newListItem( v ) );
onCheckBoxChanged();
}
}
updateState();
}
| void StdMeshersGUI_FixedPointsParamWdg::clear | ( | ) | [private] |
Clear widget.
Definition at line 188 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References myListWidget, mySpinBox, myTreeWidget, newTreeItem(), onCheckBoxChanged(), and updateState().
Referenced by SetListOfPoints(), and StdMeshersGUI_FixedPointsParamWdg().
{
myTreeWidget->clear();
myListWidget->clear();
myTreeWidget->addTopLevelItem( newTreeItem( 0, 1 ) );
mySpinBox->setValue( 0. );
onCheckBoxChanged();
updateState();
}
Event filter.
Definition at line 173 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References myListWidget, and removePoints().
{
if ( o == myListWidget && e->type() == QEvent::KeyPress ) {
QKeyEvent* ke = (QKeyEvent*)e;
if ( ke->key() == Qt::Key_Delete )
removePoints();
}
return QWidget::eventFilter( o, e );
}
| SMESH::double_array_var StdMeshersGUI_FixedPointsParamWdg::GetListOfPoints | ( | ) |
Definition at line 345 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References myListWidget, point(), and ex21_lamp.size.
Referenced by StdMeshersGUI_StdHypothesisCreator.storeParams().
{
SMESH::double_array_var anArray = new SMESH::double_array;
int size = myListWidget->count();
anArray->length( size );
for (int i = 0; i < size; i++) {
anArray[i] = point(i);
}
return anArray;
}
| SMESH::long_array_var StdMeshersGUI_FixedPointsParamWdg::GetListOfSegments | ( | ) |
Definition at line 372 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References mySameValues, myTreeWidget, nbSegments(), and ex21_lamp.size.
Referenced by StdMeshersGUI_StdHypothesisCreator.storeParams().
{
SMESH::long_array_var anArray = new SMESH::long_array;
int size = mySameValues->isChecked() ? 1 : myTreeWidget->topLevelItemCount();
anArray->length( size );
for (int i = 0; i < size; i++) {
anArray[i] = nbSegments( i );
}
return anArray;
}
| QString StdMeshersGUI_FixedPointsParamWdg.GetValue | ( | ) | const |
Definition at line 62 of file StdMeshersGUI_FixedPointsParamWdg.h.
Referenced by StdMeshersGUI_StdHypothesisCreator.getParamFromCustomWidget().
{ return myParamValue; }
Definition at line 312 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References myTreeWidget.
Referenced by GetListOfSegments(), and onCheckBoxChanged().
{
return idx >= 0 && idx < myTreeWidget->topLevelItemCount() ? myTreeWidget->topLevelItem( idx )->data( 1, Qt::UserRole ).toInt() : 1;
}
| QListWidgetItem * StdMeshersGUI_FixedPointsParamWdg::newListItem | ( | double | v1 | ) | [static, private] |
Definition at line 235 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
Referenced by addPoint().
{
QListWidgetItem* anItem = new QListWidgetItem( QString::number( v ) );
anItem->setData( Qt::UserRole, v );
return anItem;
}
| QTreeWidgetItem * StdMeshersGUI_FixedPointsParamWdg::newTreeItem | ( | double | v1, |
| double | v2 | ||
| ) | [static, private] |
Definition at line 221 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References treeItemText().
Referenced by addPoint(), and clear().
{
QTreeWidgetItem* anItem = new QTreeWidgetItem();
anItem->setText( 0, treeItemText( v1, v2 ) );
anItem->setText( 1, QString::number( 1 ) );
anItem->setData( 1, Qt::UserRole, 1 );
return anItem;
}
| void StdMeshersGUI_FixedPointsParamWdg::onAdd | ( | ) | [private, slot] |
Definition at line 202 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References addPoint(), and mySpinBox.
Referenced by StdMeshersGUI_FixedPointsParamWdg().
| void StdMeshersGUI_FixedPointsParamWdg::onCheckBoxChanged | ( | ) | [private, slot] |
Definition at line 321 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References mySameValues, myTreeWidget, nbSegments(), and setNbSegments().
Referenced by addPoint(), clear(), removePoints(), and StdMeshersGUI_FixedPointsParamWdg().
{
for ( int i = 0; i < myTreeWidget->topLevelItemCount(); i++ ) {
QTreeWidgetItem* anItem = myTreeWidget->topLevelItem(i);
setNbSegments( i, nbSegments( i ) );
anItem->setFlags( mySameValues->isChecked() && i > 0 ? anItem->flags() & ~Qt::ItemIsEditable : anItem->flags() | Qt::ItemIsEditable );
}
}
| void StdMeshersGUI_FixedPointsParamWdg::onRemove | ( | ) | [private, slot] |
Definition at line 211 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References removePoints().
Referenced by StdMeshersGUI_FixedPointsParamWdg().
{
removePoints();
}
| double StdMeshersGUI_FixedPointsParamWdg::point | ( | int | idx | ) | const [private] |
Definition at line 299 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References myListWidget.
Referenced by addPoint(), GetListOfPoints(), and removePoints().
{
return idx >= 0 && idx < myListWidget->count() ? myListWidget->item( idx )->data( Qt::UserRole ).toDouble() : 0.;
}
| void StdMeshersGUI_FixedPointsParamWdg::removePoints | ( | ) | [private] |
Definition at line 284 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References myListWidget, myTreeWidget, onCheckBoxChanged(), point(), treeItemText(), and updateState().
Referenced by eventFilter(), and onRemove().
{
QList<QListWidgetItem*> selItems = myListWidget->selectedItems();
QListWidgetItem* item;
foreach ( item, selItems ) {
int idx = myListWidget->row( item );
delete myTreeWidget->topLevelItem( idx );
delete item;
myTreeWidget->topLevelItem( idx )->setText( 0, treeItemText( idx == 0 ? 0 : point( idx-1 ),
idx > myListWidget->count()-1 ? 1 : point( idx ) ) );
}
onCheckBoxChanged();
updateState();
}
| void StdMeshersGUI_FixedPointsParamWdg::SetListOfPoints | ( | SMESH::double_array_var | thePoints | ) |
Definition at line 360 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References addPoint(), and clear().
Referenced by StdMeshersGUI_StdHypothesisCreator.stdParams().
| void StdMeshersGUI_FixedPointsParamWdg::SetListOfSegments | ( | SMESH::long_array_var | theSegments | ) |
Definition at line 387 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References myListWidget, mySameValues, and setNbSegments().
Referenced by StdMeshersGUI_StdHypothesisCreator.stdParams().
{
if ( myListWidget->count() > 0 && theSegments->length() == 1)
mySameValues->setChecked(true);
for ( int i = 0; i < theSegments->length(); i++ ) {
setNbSegments( i, theSegments[i] );
}
}
Definition at line 304 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References mySameValues, myTreeWidget, and SAME_TEXT.
Referenced by onCheckBoxChanged(), and SetListOfSegments().
{
if ( idx >= 0 && idx < myTreeWidget->topLevelItemCount() ) {
myTreeWidget->topLevelItem( idx )->setData( 1, Qt::UserRole, val );
myTreeWidget->topLevelItem( idx )->setText( 1, idx > 0 && mySameValues->isChecked() ? QString( SAME_TEXT ) : QString::number( val ) );
}
}
| QString StdMeshersGUI_FixedPointsParamWdg::treeItemText | ( | double | v1, |
| double | v2 | ||
| ) | [static, private] |
Definition at line 247 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
Referenced by addPoint(), newTreeItem(), and removePoints().
{
return QString( "%1 - %2" ).arg( v1 ).arg( v2 );
}
| void StdMeshersGUI_FixedPointsParamWdg::updateState | ( | ) | [private, slot] |
Definition at line 334 of file StdMeshersGUI_FixedPointsParamWdg.cxx.
References GT_DBL, LT_DBL, myAddButton, myListWidget, myRemoveButton, and mySpinBox.
Referenced by addPoint(), clear(), removePoints(), and StdMeshersGUI_FixedPointsParamWdg().
{
double v = mySpinBox->value();
myAddButton->setEnabled( GT_DBL(v, 0.0) && LT_DBL(v, 1.0) );
myRemoveButton->setEnabled( myListWidget->selectedItems().count() > 0 );
}
QPushButton* StdMeshersGUI_FixedPointsParamWdg.myAddButton [private] |
Definition at line 86 of file StdMeshersGUI_FixedPointsParamWdg.h.
Referenced by StdMeshersGUI_FixedPointsParamWdg(), and updateState().
QListWidget* StdMeshersGUI_FixedPointsParamWdg.myListWidget [private] |
Definition at line 83 of file StdMeshersGUI_FixedPointsParamWdg.h.
Referenced by addPoint(), clear(), eventFilter(), GetListOfPoints(), point(), removePoints(), SetListOfSegments(), StdMeshersGUI_FixedPointsParamWdg(), and updateState().
QString StdMeshersGUI_FixedPointsParamWdg.myParamValue [private] |
Definition at line 89 of file StdMeshersGUI_FixedPointsParamWdg.h.
QPushButton* StdMeshersGUI_FixedPointsParamWdg.myRemoveButton [private] |
Definition at line 87 of file StdMeshersGUI_FixedPointsParamWdg.h.
Referenced by StdMeshersGUI_FixedPointsParamWdg(), and updateState().
QCheckBox* StdMeshersGUI_FixedPointsParamWdg.mySameValues [private] |
Definition at line 88 of file StdMeshersGUI_FixedPointsParamWdg.h.
Referenced by GetListOfSegments(), onCheckBoxChanged(), SetListOfSegments(), setNbSegments(), and StdMeshersGUI_FixedPointsParamWdg().
Definition at line 85 of file StdMeshersGUI_FixedPointsParamWdg.h.
Referenced by clear(), onAdd(), StdMeshersGUI_FixedPointsParamWdg(), and updateState().
QTreeWidget* StdMeshersGUI_FixedPointsParamWdg.myTreeWidget [private] |
Definition at line 84 of file StdMeshersGUI_FixedPointsParamWdg.h.
Referenced by addPoint(), clear(), GetListOfSegments(), nbSegments(), onCheckBoxChanged(), removePoints(), setNbSegments(), and StdMeshersGUI_FixedPointsParamWdg().