1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_FilterDlg.cxx
25 // Author : Sergey LITONIN, Open CASCADE S.A.S.
29 #include "SMESHGUI_FilterDlg.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_Filter.h"
35 #include "SMESHGUI_FilterUtils.h"
36 #include "SMESHGUI_FilterLibraryDlg.h"
37 #include "SMESHGUI_SpinBox.h"
39 #include "SMESH_Actor.h"
40 #include "SMESH_NumberFilter.hxx"
41 #include "SMESH_TypeFilter.hxx"
42 #include "SMESH_LogicalFilter.hxx"
44 // SALOME GEOM includes
46 #include <GEOM_FaceFilter.h>
47 #include <GEOM_TypeFilter.h>
49 // SALOME GUI includes
50 #include <SUIT_Desktop.h>
51 #include <SUIT_ResourceMgr.h>
52 #include <SUIT_Session.h>
53 #include <SUIT_MessageBox.h>
54 #include <SUIT_OverrideCursor.h>
55 #include <QtxColorButton.h>
57 #include <LightApp_Application.h>
58 #include <LightApp_SelectionMgr.h>
59 #include <SalomeApp_Application.h>
60 #include <SalomeApp_DoubleSpinBox.h>
61 #include <SalomeApp_IntSpinBox.h>
62 #include <SalomeApp_Study.h>
63 #include <SalomeApp_Tools.h>
65 #include <SALOME_ListIO.hxx>
67 #include <SVTK_ViewWindow.h>
69 // SALOME KERNEL includes
70 #include <SALOMEDSClient_Study.hxx>
71 #include <Basics_Utils.hxx>
74 #include <StdSelect_TypeOfFace.hxx>
75 #include <BRep_Tool.hxx>
77 #include <TopoDS_Shape.hxx>
78 #include <Geom_Plane.hxx>
79 #include <Geom_CylindricalSurface.hxx>
80 #include <Precision.hxx>
81 #include <TColStd_MapOfInteger.hxx>
82 #include <TColStd_IndexedMapOfInteger.hxx>
83 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
88 #include <QPushButton>
90 #include <QTableWidget>
91 #include <QStringList>
92 #include <QHBoxLayout>
93 #include <QVBoxLayout>
94 #include <QGridLayout>
95 #include <QStackedWidget>
96 #include <QApplication>
98 #include <QFontMetrics>
100 #include <QButtonGroup>
101 #include <QRadioButton>
103 #include <QListWidget>
105 #include <QItemDelegate>
106 #include <QDoubleValidator>
108 #include <QHeaderView>
111 #include <SALOMEconfig.h>
112 #include CORBA_SERVER_HEADER(SMESH_Group)
117 //---------------------------------------
119 //---------------------------------------
120 static int maxLength (const QMap<int, QString> theMap, const QFontMetrics& theMetrics)
123 QMap<int, QString>::const_iterator anIter;
124 for (anIter = theMap.begin(); anIter != theMap.end(); ++anIter)
125 aRes = qMax(aRes, theMetrics.width(anIter.value()));
129 //---------------------------------------
131 //---------------------------------------
132 static int getFilterId (SMESH::ElementType theType)
136 case SMESH::NODE : return SMESH::NodeFilter;
137 case SMESH::EDGE : return SMESH::EdgeFilter;
138 case SMESH::FACE : return SMESH::FaceFilter;
139 case SMESH::VOLUME : return SMESH::VolumeFilter;
140 case SMESH::ALL : return SMESH::AllElementsFilter;
141 default : return SMESH::UnknownFilter;
146 Class : SMESHGUI_FilterTable::AdditionalWidget
147 Description : Class for storing additional parameters of criterion
150 class SMESHGUI_FilterTable::AdditionalWidget : public QWidget
156 AdditionalWidget(QWidget* theParent);
157 virtual ~AdditionalWidget();
159 virtual QList<int> GetParameters() const;
160 virtual bool IsValid(const bool = true) const;
161 virtual double GetDouble(const int) const;
162 virtual int GetInteger(const int) const;
163 virtual QString GetString(const int) const;
164 virtual void SetDouble(const int, const double);
165 virtual void SetInteger(const int, const int);
166 virtual void SetString(const int, const QString&);
167 void SetEditable(const int, const bool);
168 void SetEditable(const bool);
169 void SetPrecision(const int, const char* = 0);
172 QMap< int, QWidget* > myWidgets;
175 SMESHGUI_FilterTable::AdditionalWidget::AdditionalWidget (QWidget* theParent)
178 QLabel* aLabel = new QLabel(tr("SMESH_TOLERANCE"), this);
180 SMESHGUI_SpinBox* sb = new SMESHGUI_SpinBox(this);
181 sb->setAcceptNames( false ); // No Notebook variables allowed
182 sb->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
183 sb->RangeStepAndValidator( 0., 1.e20, 0.1, "len_tol_precision" );
184 myWidgets[ Tolerance ] = sb;
186 QHBoxLayout* aLay = new QHBoxLayout(this);
187 aLay->setSpacing(SPACING);
190 aLay->addWidget(aLabel);
191 aLay->addWidget(myWidgets[ Tolerance ]);
194 SetDouble( Tolerance, Precision::Confusion() );
197 SMESHGUI_FilterTable::AdditionalWidget::~AdditionalWidget()
201 QList<int> SMESHGUI_FilterTable::AdditionalWidget::GetParameters() const
204 theList.append(Tolerance);
208 bool SMESHGUI_FilterTable::AdditionalWidget::IsValid (const bool theMsg) const
213 QList<int> aParams = GetParameters();
214 QList<int>::const_iterator anIter;
215 for (anIter = aParams.begin(); anIter != aParams.end(); ++anIter) {
216 if ( !myWidgets.contains( *anIter ) ) continue;
218 if ( qobject_cast<QLineEdit*>( myWidgets[ *anIter ] ) ) {
219 valid = qobject_cast<QLineEdit*>( myWidgets[ *anIter ] )->hasAcceptableInput();
221 else if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ *anIter ] ) ) {
223 valid = qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ *anIter ] )->isValid( foo, false );
225 if (!valid && theMsg) {
226 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
227 tr("SMESHGUI_INVALID_PARAMETERS"));
235 double SMESHGUI_FilterTable::AdditionalWidget::GetDouble (const int theId) const
238 if ( myWidgets.contains( theId ) ) {
239 if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
240 retval = qobject_cast<QLineEdit*>( myWidgets[ theId ] )->text().toDouble();
241 if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
242 retval = qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->GetValue();
247 int SMESHGUI_FilterTable::AdditionalWidget::GetInteger (const int theId) const
250 if ( myWidgets.contains( theId ) ) {
251 if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
252 retval = qobject_cast<QLineEdit*>( myWidgets[ theId ] )->text().toInt();
253 if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
254 retval = (int)( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->GetValue() );
259 QString SMESHGUI_FilterTable::AdditionalWidget::GetString (const int theId) const
262 if ( myWidgets.contains( theId ) ) {
263 if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
264 retval = qobject_cast<QLineEdit*>( myWidgets[ theId ] )->text();
265 if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
266 retval = QString::number( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->GetValue() );
271 void SMESHGUI_FilterTable::AdditionalWidget::SetDouble (const int theId, const double theVal)
273 if ( myWidgets.contains( theId ) ) {
274 if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
275 qobject_cast<QLineEdit*>( myWidgets[ theId ] )->setText( QString::number( theVal ) );
276 if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
277 qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->SetValue( theVal );
281 void SMESHGUI_FilterTable::AdditionalWidget::SetInteger (const int theId, const int theVal)
283 if ( myWidgets.contains( theId ) ) {
284 if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
285 qobject_cast<QLineEdit*>( myWidgets[ theId ] )->setText( QString::number( theVal ) );
286 if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
287 qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->SetValue( (double)theVal );
291 void SMESHGUI_FilterTable::AdditionalWidget::SetString (const int theId, const QString& theVal)
293 if ( myWidgets.contains( theId ) ) {
294 if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
295 qobject_cast<QLineEdit*>( myWidgets[ theId ] )->setText( theVal );
296 if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
297 qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->SetValue( theVal.toDouble() );
301 void SMESHGUI_FilterTable::AdditionalWidget::SetEditable (const int theId, const bool isEditable)
303 if ( myWidgets.contains( theId ) ) {
304 if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
305 qobject_cast<QLineEdit*>( myWidgets[ theId ] )->setReadOnly( !isEditable );
306 if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
307 qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->setReadOnly( !isEditable );
311 void SMESHGUI_FilterTable::AdditionalWidget::SetEditable (const bool isEditable)
313 QList<int> aParams = GetParameters();
314 QList<int>::const_iterator anIter;
315 for (anIter = aParams.begin(); anIter != aParams.end(); ++anIter)
316 SetEditable( *anIter, isEditable );
319 void SMESHGUI_FilterTable::AdditionalWidget::SetPrecision(const int theId, const char* precision)
321 if ( myWidgets.contains( theId ) ) {
322 if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) ) {
323 SMESHGUI_SpinBox* sb = qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] );
324 double val = sb->GetValue();
325 double min = pow(10.0, -(sb->decimals()));
326 sb->RangeStepAndValidator( 0., 1.e20, 0.1, precision ? precision : "len_tol_precision" );
327 sb->SetValue( qMax( val, min ) );
333 Class : SMESHGUI_FilterTable::ComboItem
334 Description : Combo table item. Identificator corresponding to string may be assigned
337 class SMESHGUI_FilterTable::ComboItem : public QTableWidgetItem
342 ComboItem( const QMap<int, QString>& );
344 void setItems( const QMap<int, QString>& );
349 void setValue( const int );
353 int index( int ) const;
356 QMap<int, int> myIdToIdx;
359 int SMESHGUI_FilterTable::ComboItem::Type()
361 return QTableWidgetItem::UserType + 1;
364 SMESHGUI_FilterTable::ComboItem::ComboItem( const QMap<int, QString>& theIds )
365 : QTableWidgetItem( Type() )
370 void SMESHGUI_FilterTable::ComboItem::setItems( const QMap<int, QString>& theIds )
373 QMap<int, QString>::const_iterator it;
375 for ( it = theIds.begin(); it != theIds.end(); ++it ) {
376 myIdToIdx[it.key()] = items.count();
377 items.append( it.value() );
379 setData( Qt::UserRole, items );
383 void SMESHGUI_FilterTable::ComboItem::clear()
385 QMap<int, QString> empty;
389 int SMESHGUI_FilterTable::ComboItem::count() const
391 return myIdToIdx.count();
394 int SMESHGUI_FilterTable::ComboItem::value() const
396 return( id( data( Qt::UserRole ).toStringList().indexOf( text() ) ) );
399 void SMESHGUI_FilterTable::ComboItem::setValue( const int theId )
401 int idx = index( theId );
402 QStringList items = data( Qt::UserRole ).toStringList();
403 setText( idx >= 0 && idx < items.count() ? items[idx] : "" );
406 int SMESHGUI_FilterTable::ComboItem::id( int idx ) const
408 QMap<int,int>::const_iterator it;
409 for ( it = myIdToIdx.begin(); it != myIdToIdx.end(); ++it )
410 if ( it.value() == idx ) return it.key();
414 int SMESHGUI_FilterTable::ComboItem::index( int i ) const
416 return myIdToIdx.contains( i ) ? myIdToIdx[i] : -1;
419 Class : SMESHGUI_FilterTable::CheckItem
420 Description : Check table item.
423 class SMESHGUI_FilterTable::CheckItem : public QTableWidgetItem
428 CheckItem( bool = false );
429 CheckItem( const QString&, bool = false );
432 void setChecked( bool );
433 bool checked() const;
436 int SMESHGUI_FilterTable::CheckItem::Type()
438 return QTableWidgetItem::UserType + 2;
441 SMESHGUI_FilterTable::CheckItem::CheckItem( bool value )
442 : QTableWidgetItem( Type() )
444 Qt::ItemFlags f = flags();
445 f = f | Qt::ItemIsUserCheckable;
446 f = f & ~Qt::ItemIsTristate;
447 f = f & ~Qt::ItemIsEditable;
452 SMESHGUI_FilterTable::CheckItem::CheckItem( const QString& text, bool value )
453 : QTableWidgetItem( Type() )
455 Qt::ItemFlags f = flags();
456 f = f | Qt::ItemIsUserCheckable;
457 f = f & ~Qt::ItemIsTristate;
458 f = f & ~Qt::ItemIsEditable;
464 SMESHGUI_FilterTable::CheckItem::~CheckItem()
468 void SMESHGUI_FilterTable::CheckItem::setChecked( bool value )
470 setCheckState( value ? Qt::Checked : Qt::Unchecked );
473 bool SMESHGUI_FilterTable::CheckItem::checked() const
475 return checkState() == Qt::Checked;
479 Class : SMESHGUI_FilterTable::IntSpinItem
480 Description : Integer spin table item.
483 class SMESHGUI_FilterTable::IntSpinItem : public QTableWidgetItem
488 IntSpinItem( const int theValue );
491 void setValue( const int theValue );
496 int SMESHGUI_FilterTable::IntSpinItem::Type()
498 return QTableWidgetItem::UserType + 3;
501 SMESHGUI_FilterTable::IntSpinItem::IntSpinItem( const int theValue )
502 : QTableWidgetItem( Type() )
504 setValue( theValue );
507 int SMESHGUI_FilterTable::IntSpinItem::value() const
510 int value = data( Qt::UserRole ).toInt( &ok );
511 return ok ? value : 0;
514 void SMESHGUI_FilterTable::IntSpinItem::setValue( const int theValue )
516 setData( Qt::UserRole, theValue );
517 setText( QString::number( theValue ) );
520 void SMESHGUI_FilterTable::IntSpinItem::clear()
526 Class : SMESHGUI_FilterTable::DoubleSpinItem
527 Description : Double spin table item.
530 class SMESHGUI_FilterTable::DoubleSpinItem : public QTableWidgetItem
535 DoubleSpinItem( const double theValue );
537 double value() const;
538 void setValue( const double theValue );
540 int precision() const;
541 void setPrecision( const int thePrecision );
546 int SMESHGUI_FilterTable::DoubleSpinItem::Type()
548 return QTableWidgetItem::UserType + 4;
551 SMESHGUI_FilterTable::DoubleSpinItem::DoubleSpinItem( const double theValue )
552 : QTableWidgetItem( Type() )
554 setValue( theValue );
557 double SMESHGUI_FilterTable::DoubleSpinItem::value() const
560 double value = data( Qt::UserRole ).toDouble( &ok );
561 return ok ? value : 0;
564 void SMESHGUI_FilterTable::DoubleSpinItem::setValue( const double theValue )
566 setData( Qt::UserRole, theValue );
567 setText( QString::number( theValue ) );
570 int SMESHGUI_FilterTable::DoubleSpinItem::precision() const
573 int precision = data( Qt::UserRole + 1 ).toInt( &ok );
574 return ok ? precision : 0;
577 void SMESHGUI_FilterTable::DoubleSpinItem::setPrecision( const int thePrecision )
579 setData( Qt::UserRole + 1, thePrecision );
582 void SMESHGUI_FilterTable::DoubleSpinItem::clear()
588 Class : SMESHGUI_FilterTable::ComboDelegate
589 Description : Table used by this widget
592 class SMESHGUI_FilterTable::ComboDelegate : public QItemDelegate
595 ComboDelegate( QObject* = 0 );
598 QWidget* createEditor( QWidget*, const QStyleOptionViewItem&,
599 const QModelIndex& ) const;
601 void setEditorData( QWidget*, const QModelIndex& ) const;
602 void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const;
604 void updateEditorGeometry( QWidget*, const QStyleOptionViewItem&,
605 const QModelIndex& ) const;
607 QTableWidget* myTable;
610 SMESHGUI_FilterTable::ComboDelegate::ComboDelegate( QObject* parent )
611 : QItemDelegate( parent ),
612 myTable( qobject_cast<QTableWidget*>( parent ) )
616 SMESHGUI_FilterTable::ComboDelegate::~ComboDelegate()
620 QWidget* SMESHGUI_FilterTable::ComboDelegate::createEditor( QWidget* parent,
621 const QStyleOptionViewItem& option,
622 const QModelIndex& index ) const
624 QVariant aData = index.data( Qt::UserRole );
625 QVariant::Type aDataType = aData.type();
626 if( aDataType == QVariant::StringList ) {
627 QStringList l = aData.toStringList();
628 if ( !l.isEmpty() ) {
629 QComboBox* cb = new QComboBox( parent );
630 cb->setFrame( false );
635 else if( aDataType == QVariant::Int ) {
637 int aValue = aData.toInt( &ok );
639 SalomeApp_IntSpinBox* intSpin = new SalomeApp_IntSpinBox( 0, 1000, 1, parent, false, true );
640 intSpin->setFrame( false );
641 intSpin->setValue( aValue );
645 else if( aDataType == QVariant::Double ) {
647 double aValue = aData.toDouble( &ok );
649 int aPrecision = index.data( Qt::UserRole + 1 ).toInt( &ok );
653 SalomeApp_DoubleSpinBox* dblSpin = new SalomeApp_DoubleSpinBox( -1.e20, 1.e20, 1, aPrecision, 20, parent, false, true );
654 dblSpin->setFrame( false );
655 dblSpin->setValue( aValue );
659 return QItemDelegate::createEditor( parent, option, index );
662 void SMESHGUI_FilterTable::ComboDelegate::setEditorData( QWidget* editor,
663 const QModelIndex& index ) const
665 QVariant data = index.model()->data( index, Qt::DisplayRole );
666 QString value = data.toString();
668 if ( QComboBox* cb = dynamic_cast<QComboBox*>( editor ) ) {
669 int i = cb->findText( value );
671 cb->setCurrentIndex( i );
675 else if ( SalomeApp_DoubleSpinBox* dblSpin = dynamic_cast<SalomeApp_DoubleSpinBox*>( editor ) ) {
676 if( data.type() == QVariant::Double ) {
677 double valueDouble = data.toDouble( &bOk );
679 dblSpin->setValue( valueDouble );
682 if ( !bOk ) QItemDelegate::setEditorData( editor, index );
685 void SMESHGUI_FilterTable::ComboDelegate::setModelData( QWidget* editor,
686 QAbstractItemModel* model,
687 const QModelIndex& index) const
689 if( QComboBox* cb = dynamic_cast<QComboBox*>( editor ) )
690 model->setData( index, cb->currentText(), Qt::DisplayRole );
691 else if( SalomeApp_IntSpinBox* intSpin = dynamic_cast<SalomeApp_IntSpinBox*>( editor ) )
692 model->setData( index, intSpin->value(), Qt::DisplayRole );
693 else if( SalomeApp_DoubleSpinBox* dblSpin = dynamic_cast<SalomeApp_DoubleSpinBox*>( editor ) )
694 model->setData( index, dblSpin->value(), Qt::DisplayRole );
695 else QItemDelegate::setModelData( editor, model, index );
698 void SMESHGUI_FilterTable::ComboDelegate::updateEditorGeometry( QWidget* editor,
699 const QStyleOptionViewItem& option,
700 const QModelIndex& /*index*/ ) const
702 editor->setGeometry( option.rect );
706 Class : SMESHGUI_FilterTable::Table
707 Description : Table used by this widget
710 class SMESHGUI_FilterTable::Table : public QTableWidget
713 Table( QWidget* = 0 );
714 Table( int, int, QWidget* = 0 );
717 QSize minimumSizeHint() const;
719 void setEditable( bool, int, int );
720 bool isEditable( int, int ) const;
722 void setReadOnly( bool );
723 bool isReadOnly() const;
725 void insertRows( int, int = 1 );
726 QString text( int, int );
728 QList<int> selectedRows();
731 //=======================================================================
732 // name : SMESHGUI_FilterTable::Table::Table
733 // Purpose : Constructor
734 //=======================================================================
735 SMESHGUI_FilterTable::Table::Table (QWidget* parent)
736 : QTableWidget(parent)
738 // set custom item delegate
739 setItemDelegate( new ComboDelegate(this) );
740 // set edit triggers by default
741 setReadOnly( false );
744 //=======================================================================
745 // name : SMESHGUI_FilterTable::Table::Table
746 // Purpose : Constructor
747 //=======================================================================
748 SMESHGUI_FilterTable::Table::Table (int numRows, int numCols, QWidget* parent)
749 : QTableWidget(numRows, numCols, parent)
751 // set custom item delegate
752 setItemDelegate( new ComboDelegate(this) );
753 // set edit triggers by default
754 setReadOnly( false );
757 //=======================================================================
758 // name : SMESHGUI_FilterTable::Table::~Table
759 // Purpose : Destructor
760 //=======================================================================
761 SMESHGUI_FilterTable::Table::~Table()
765 //=======================================================================
766 // name : SMESHGUI_FilterTable::Table::minimumSizeHint
767 // Purpose : Get minimum size for the table
768 //=======================================================================
769 QSize SMESHGUI_FilterTable::Table::minimumSizeHint() const
771 QSize s = QTableWidget::minimumSizeHint();
772 QHeaderView* hv = horizontalHeader();
774 s.setWidth( qMax( s.width(), hv->length() ) );
778 //=======================================================================
779 // name : SMESHGUI_FilterTable::Table::setEditable
780 // Purpose : Set editable of specified cell
781 //=======================================================================
782 void SMESHGUI_FilterTable::Table::setEditable (bool isEditable,
785 QTableWidgetItem* anItem = item( row, col );
787 bool isSignalsBlocked = signalsBlocked();
788 blockSignals( true );
790 Qt::ItemFlags f = anItem->flags();
791 if ( !isEditable ) f = f & ~Qt::ItemIsEditable;
792 else f = f | Qt::ItemIsEditable;
793 anItem->setFlags( f );
795 blockSignals( isSignalsBlocked );
799 //=======================================================================
800 // name : SMESHGUI_FilterTable::Table::isEditable
801 // Purpose : Verify whether cell is editable
802 //=======================================================================
803 bool SMESHGUI_FilterTable::Table::isEditable (int row, int col) const
805 QTableWidgetItem* anItem = item( row, col );
806 return anItem == 0 || anItem->flags() & Qt::ItemIsEditable;
809 void SMESHGUI_FilterTable::Table::setReadOnly( bool on )
811 setEditTriggers( on ?
812 QAbstractItemView::NoEditTriggers :
813 QAbstractItemView::AllEditTriggers );
816 bool SMESHGUI_FilterTable::Table::isReadOnly() const
818 return editTriggers() == QAbstractItemView::NoEditTriggers;
821 //=======================================================================
822 // name : SMESHGUI_FilterTable::Table::insertRows
823 // Purpose : Insert rows (virtual redefined)
824 //=======================================================================
825 void SMESHGUI_FilterTable::Table::insertRows (int row, int count)
827 closePersistentEditor( currentItem() );
828 while ( count-- ) insertRow( row );
831 //=======================================================================
832 // name : SMESHGUI_FilterTable::Table::text
833 // Purpose : Get text from cell (virtual redefined)
834 //=======================================================================
835 QString SMESHGUI_FilterTable::Table::text (int row, int col)
837 closePersistentEditor( currentItem() );
838 QTableWidgetItem* anItem = item( row, col );
839 return anItem ? anItem->text() : QString();
842 QList<int> SMESHGUI_FilterTable::Table::selectedRows()
844 QList<QTableWidgetItem*> selItems = selectedItems();
845 QTableWidgetItem* anItem;
848 foreach( anItem, selItems ) {
849 int r = row( anItem );
850 if ( !rows.contains( r ) ) rows.append( r );
858 Class : SMESHGUI_FilterTable
859 Description : Frame containing
860 - Button group for switching entity type
861 - Table for displaying filter criterions
862 - Buttons for editing table and filter libraries
865 //=======================================================================
866 // name : SMESHGUI_FilterTable::SMESHGUI_FilterTable
867 // Purpose : Constructor
868 //=======================================================================
869 SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
873 mySMESHGUI( theModule ),
883 //=======================================================================
884 // name : SMESHGUI_FilterTable::SMESHGUI_FilterTable
885 // Purpose : Constructor
886 //=======================================================================
887 SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
889 const QList<int>& types )
891 mySMESHGUI( theModule ),
898 SMESHGUI_FilterTable::~SMESHGUI_FilterTable()
902 //=======================================================================
903 // name : SMESHGUI_FilterTable::Init
904 // Purpose : Create table corresponding to the specified type
905 //=======================================================================
906 void SMESHGUI_FilterTable::Init (const QList<int>& theTypes)
908 if (theTypes.isEmpty())
911 // Create buttons if necessary
913 if (myTables.isEmpty())
915 // create main layout
916 QVBoxLayout* aMainLay = new QVBoxLayout(this);
917 aMainLay->setMargin( 0 );
918 aMainLay->setSpacing( SPACING );
920 // create switch of entity types
921 myEntityTypeBox = new QGroupBox(tr("ENTITY_TYPE"), this);
922 QHBoxLayout* myEntityTypeBoxLayout = new QHBoxLayout(myEntityTypeBox);
923 myEntityTypeBoxLayout->setMargin( MARGIN );
924 myEntityTypeBoxLayout->setSpacing( SPACING );
925 myEntityTypeGrp = new QButtonGroup(this);
927 const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
928 QMap<int, QString>::const_iterator anIter;
929 for (anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter)
931 QRadioButton* aBtn = new QRadioButton(anIter.value(), myEntityTypeBox);
932 myEntityTypeGrp->addButton(aBtn, anIter.key());
933 myEntityTypeBoxLayout->addWidget(aBtn);
936 myTableGrp = new QGroupBox(tr("FILTER"), this );
939 mySwitchTableGrp = new QWidget(myTableGrp);
940 QVBoxLayout* mySwitchTableGrpLayout = new QVBoxLayout(mySwitchTableGrp);
941 mySwitchTableGrpLayout->setMargin(0);
942 mySwitchTableGrpLayout->setSpacing(0);
944 QList<int>::const_iterator typeIt = theTypes.begin();
945 for ( ; typeIt != theTypes.end(); ++typeIt ) {
946 Table* aTable = createTable(mySwitchTableGrp, *typeIt);
947 myTables[ *typeIt ] = aTable;
948 mySwitchTableGrpLayout->addWidget(aTable);
949 if ( typeIt != theTypes.begin() )
954 myAddBtn = new QPushButton(tr("ADD"), myTableGrp);
955 myRemoveBtn = new QPushButton(tr("REMOVE"), myTableGrp);
956 myClearBtn = new QPushButton(tr("CLEAR"), myTableGrp);
957 myInsertBtn = new QPushButton(tr("INSERT"), myTableGrp);
958 myCopyFromBtn = new QPushButton(tr("COPY_FROM"), myTableGrp);
959 myAddToBtn = new QPushButton(tr("ADD_TO"), myTableGrp);
961 myAddBtn->setAutoDefault(false);
962 myRemoveBtn->setAutoDefault(false);
963 myClearBtn->setAutoDefault(false);
964 myInsertBtn->setAutoDefault(false);
965 myCopyFromBtn->setAutoDefault(false);
966 myAddToBtn->setAutoDefault(false);
968 myCopyFromBtn->hide();
972 QGridLayout* aLay = new QGridLayout(myTableGrp);
973 aLay->setMargin(MARGIN);
974 aLay->setSpacing(SPACING);
976 aLay->addWidget(mySwitchTableGrp, 0, 0, 7, 1);
977 aLay->addWidget(myAddBtn, 0, 1);
978 aLay->addWidget(myInsertBtn, 1, 1);
979 aLay->addWidget(myRemoveBtn, 2, 1);
980 aLay->addWidget(myClearBtn, 3, 1);
981 aLay->addWidget(myCopyFromBtn, 5, 1);
982 aLay->addWidget(myAddToBtn, 6, 1);
983 aLay->addWidget(createAdditionalFrame(myTableGrp), 7, 0, 1, 2 );
985 aLay->setRowMinimumHeight(4, 10);
986 aLay->setRowStretch(4, 1);
987 aLay->setColumnStretch(0, 1);
988 aLay->setColumnStretch(1, 0);
991 aMainLay->addWidget(myEntityTypeBox);
992 aMainLay->addWidget(myTableGrp);
995 connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAddBtn()));
996 connect(myInsertBtn, SIGNAL(clicked()), this, SLOT(onInsertBtn()));
997 connect(myRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemoveBtn()));
998 connect(myClearBtn, SIGNAL(clicked()), this, SLOT(onClearBtn()));
1000 connect(myCopyFromBtn, SIGNAL(clicked()), this, SLOT(onCopyFromBtn()));
1001 connect(myAddToBtn, SIGNAL(clicked()), this, SLOT(onAddToBtn()));
1003 connect(myEntityTypeGrp, SIGNAL(buttonClicked(int)), this, SLOT(onEntityType(int)));
1009 QList<int>::const_iterator typeIt = theTypes.begin();
1010 for ( ; typeIt != theTypes.end(); ++typeIt ) {
1011 if ( !myTables[ *typeIt ] ) {
1012 Table* aTable = createTable(mySwitchTableGrp, *typeIt);
1013 myTables[ *typeIt ] = aTable;
1014 ((QVBoxLayout*)mySwitchTableGrp->layout())->addWidget(myTables[ *typeIt ]);
1020 // Hide buttons of entity types if necessary
1021 const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
1022 QMap<int, QString>::const_iterator anIt;
1023 for (anIt = aSupportedTypes.begin(); anIt != aSupportedTypes.end(); ++anIt)
1025 QAbstractButton* aBtn = myEntityTypeGrp->button(anIt.key());
1026 if ( aBtn ) aBtn->setVisible( theTypes.contains(anIt.key()) );
1029 // select first button if there is no selected buttons or it is hidden
1030 int aBtnId = myEntityTypeGrp->checkedId();
1031 if ( aBtnId == -1 || !theTypes.contains(aBtnId) ) {
1032 QAbstractButton* aBtn = myEntityTypeGrp->button(theTypes.first());
1033 if ( aBtn ) aBtn->setChecked(true);
1036 myEntityTypeBox->setVisible(theTypes.count() > 1);
1038 myTableGrp->updateGeometry();
1039 int cType = myEntityTypeGrp->checkedId();
1040 onEntityType(cType);
1043 //=======================================================================
1044 // name : SMESHGUI_FilterTable::createAdditionalFrame
1045 // Purpose : Get group box containing table. May be used for adding new widgets in it
1046 //=======================================================================
1047 QWidget* SMESHGUI_FilterTable::createAdditionalFrame (QWidget* theParent)
1049 QWidget* aFrame = new QWidget(theParent);
1051 QFrame* aLine1 = new QFrame(aFrame);
1052 QFrame* aLine2 = new QFrame(aFrame);
1053 aLine1->setFrameStyle(QFrame::HLine | QFrame::Sunken);
1054 aLine2->setFrameStyle(QFrame::HLine | QFrame::Sunken);
1055 aLine1->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
1056 aLine2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
1058 QLabel* aLabel = new QLabel(tr("ADDITIONAL_PARAMETERS"), aFrame);
1060 myWgStack = new QStackedWidget(aFrame);
1062 QGridLayout* aLay = new QGridLayout(aFrame);
1064 aLay->setSpacing(SPACING);
1065 aLay->addWidget(aLine1, 0, 0);
1066 aLay->addWidget(aLabel, 0, 1);
1067 aLay->addWidget(aLine2, 0, 2);
1068 aLay->addWidget(myWgStack, 1, 0, 1, 3);
1073 //=======================================================================
1074 // name : SMESHGUI_FilterTable::GetTableGrp
1075 // Purpose : Get group box containing table. May be used for adding new widgets in it
1076 //=======================================================================
1077 QGroupBox* SMESHGUI_FilterTable::GetTableGrp()
1082 //=======================================================================
1083 // name : SMESHGUI_FilterTable::onEntityType
1084 // Purpose : SLOT. Called when entity type changed.
1085 // Display corresponding table
1086 //=======================================================================
1087 void SMESHGUI_FilterTable::onEntityType (int theType)
1089 if (myEntityType == theType)
1093 emit NeedValidation();
1096 myEntityTypeGrp->button(myEntityType)->setChecked(true);
1100 myEntityType = theType;
1102 if (!myTables.contains(theType)) {
1103 myTables[ theType ] = createTable(mySwitchTableGrp, theType);
1104 ((QVBoxLayout*)mySwitchTableGrp->layout())->addWidget(myTables[ theType ]);
1107 TableMap::iterator anIter;
1108 for (anIter = myTables.begin(); anIter != myTables.end(); ++anIter)
1109 anIter.value()->setVisible( myEntityType == anIter.key() );
1112 qApp->processEvents();
1113 myTables[ myEntityType ]->updateGeometry();
1116 emit EntityTypeChanged(theType);
1119 //=======================================================================
1120 // name : SMESHGUI_FilterTable::IsValid
1121 // Purpose : Verify validity of entered data
1122 //=======================================================================
1123 bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType) const
1125 int aType = theEntityType == -1 ? GetType() : theEntityType;
1127 Table* aTable = myTables[ aType ];
1128 for (int i = 0, n = aTable->rowCount(); i < n; i++)
1130 int aCriterion = GetCriterionType(i, aType);
1132 if (aCriterion == SMESH::FT_GroupColor )
1134 QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(i, 2));
1135 if (clrBtn && !clrBtn->color().isValid())
1136 errMsg = tr( "GROUPCOLOR_ERROR" );
1138 else if (aCriterion == SMESH::FT_RangeOfIds ||
1139 aCriterion == SMESH::FT_BelongToMeshGroup ||
1140 aCriterion == SMESH::FT_BelongToGeom ||
1141 aCriterion == SMESH::FT_BelongToPlane ||
1142 aCriterion == SMESH::FT_BelongToCylinder ||
1143 aCriterion == SMESH::FT_BelongToGenSurface ||
1144 aCriterion == SMESH::FT_ElemGeomType ||
1145 aCriterion == SMESH::FT_EntityType ||
1146 aCriterion == SMESH::FT_CoplanarFaces ||
1147 aCriterion == SMESH::FT_LyingOnGeom ||
1148 aCriterion == SMESH::FT_ConnectedElements )
1150 if (aTable->text(i, 2).isEmpty())
1151 errMsg = tr( "ERROR" );
1153 else // check correctness of a numeric value
1156 bool isSignalsBlocked = aTable->signalsBlocked();
1157 aTable->blockSignals(true);
1158 /*double aThreshold =*/ aTable->text(i, 2).toDouble( &aRes );
1159 aTable->blockSignals(isSignalsBlocked);
1161 if (!aRes && aTable->isEditable(i, 2))
1162 errMsg = tr( "ERROR" );
1165 if (!errMsg.isEmpty()) {
1167 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), errMsg );
1171 QTableWidgetItem* anItem = aTable->item(i, 0);
1172 if (myAddWidgets.contains(anItem) && !myAddWidgets[ anItem ]->IsValid())
1179 //=======================================================================
1180 // name : SMESHGUI_FilterTable::SetValidity
1181 // Purpose : Set validity of the table
1182 //=======================================================================
1183 void SMESHGUI_FilterTable::SetValidity (const bool isValid)
1185 myIsValid = isValid;
1188 //=======================================================================
1189 // name : SMESHGUI_FilterTable::GetType
1190 // Purpose : Get current entity type
1191 //=======================================================================
1192 int SMESHGUI_FilterTable::GetType() const
1194 return myEntityType;
1197 //=======================================================================
1198 // name : SMESHGUI_FilterTable::SetType
1199 // Purpose : Set current entity type
1200 //=======================================================================
1201 void SMESHGUI_FilterTable::SetType (const int type)
1203 myEntityTypeGrp->button(type)->setChecked(true);
1207 //=======================================================================
1208 // name : SMESHGUI_FilterTable::RestorePreviousEntityType
1209 // Purpose : Restore previous entity type
1210 //=======================================================================
1211 void SMESHGUI_FilterTable::RestorePreviousEntityType()
1213 SetType(myEntityType);
1216 //=======================================================================
1217 // name : SMESHGUI_FilterTable::GetCriterionType
1218 // Purpose : Get type of criterion from specified row (corresponding enums in h-file)
1219 //=======================================================================
1220 int SMESHGUI_FilterTable::GetCriterionType (const int theRow, const int theType) const
1222 int aType = theType == -1 ? GetType() : theType;
1223 Table* aTable = myTables[ aType ];
1224 ComboItem* anItem = (ComboItem*)aTable->item(theRow, 0);
1225 return anItem != 0 ? anItem->value() : SMESH::FT_Undefined;
1228 //=======================================================================
1229 // name : SMESHGUI_FilterTable::GetCriterion
1230 // Purpose : Get parameters of criterion from specified row
1231 //=======================================================================
1232 void SMESHGUI_FilterTable::GetCriterion (const int theRow,
1233 SMESH::Filter::Criterion& theCriterion,
1234 const int theEntityType) const
1236 int aType = theEntityType == -1 ? GetType() : theEntityType;
1237 Table* aTable = myTables[ aType ];
1239 theCriterion.Type = ((ComboItem*)aTable->item(theRow, 0))->value();
1240 theCriterion.UnaryOp = ((CheckItem*)aTable->item(theRow, 3))->checked() ? SMESH::FT_LogicalNOT : SMESH::FT_Undefined;
1241 theCriterion.BinaryOp = theRow != aTable->rowCount() - 1 ?
1242 ((ComboItem*)aTable->item(theRow, 4))->value() : SMESH::FT_Undefined;
1243 theCriterion.TypeOfElement = (SMESH::ElementType)aType;
1245 int aCriterionType = GetCriterionType(theRow, aType);
1247 if ( aCriterionType == SMESH::FT_GroupColor )
1249 QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(theRow, 2));
1252 Kernel_Utils::Localizer loc;
1253 const QColor qClr = clrBtn->color();
1254 QString clrStr = QString( "%1;%2;%3" ).
1255 arg( qClr.red()/256. ).arg( qClr.green()/256. ).arg( qClr.blue()/256. );
1256 theCriterion.ThresholdStr = clrStr.toLatin1().constData();
1259 else if ( aCriterionType == SMESH::FT_ElemGeomType ||
1260 aCriterionType == SMESH::FT_EntityType )
1262 theCriterion.Threshold = (double)((ComboItem*)aTable->item(theRow, 2))->value();
1264 else if ( aCriterionType == SMESH::FT_CoplanarFaces )
1266 theCriterion.ThresholdID = aTable->text(theRow, 2).toLatin1().constData();
1268 else if ( aCriterionType == SMESH::FT_ConnectedElements )
1270 QString id = aTable->text(theRow, 5);
1271 if ( !id.isEmpty() ) // shape ID
1273 theCriterion.ThresholdID = id.toLatin1().constData();
1277 QString text = aTable->text(theRow, 2).trimmed();
1278 QString workText = text;
1279 for ( char c = '0'; c <= '9'; ++c )
1280 workText.remove( c );
1282 if ( workText.isEmpty() ) // node ID
1283 theCriterion.Threshold = text.toDouble();
1284 else // point coordinates
1285 theCriterion.ThresholdStr = text.toLatin1().constData();
1288 else if ( aCriterionType != SMESH::FT_RangeOfIds &&
1289 aCriterionType != SMESH::FT_BelongToMeshGroup &&
1290 aCriterionType != SMESH::FT_BelongToGeom &&
1291 aCriterionType != SMESH::FT_BelongToPlane &&
1292 aCriterionType != SMESH::FT_BelongToCylinder &&
1293 aCriterionType != SMESH::FT_BelongToGenSurface &&
1294 aCriterionType != SMESH::FT_LyingOnGeom )
1296 theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->value();
1297 theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble();
1301 theCriterion.ThresholdStr = aTable->text(theRow, 2).toLatin1().constData();
1302 if ( aCriterionType != SMESH::FT_RangeOfIds )
1303 theCriterion.ThresholdID = aTable->text( theRow, 5 ).toLatin1().constData();
1306 QTableWidgetItem* anItem = aTable->item(theRow, 0);
1307 if (myAddWidgets.contains(anItem))
1308 theCriterion.Tolerance = myAddWidgets[ anItem ]->GetDouble(AdditionalWidget::Tolerance);
1311 //=======================================================================
1312 // name : SMESHGUI_FilterTable::SetCriterion
1313 // Purpose : Set parameters of criterion of specified row
1314 //=======================================================================
1315 void SMESHGUI_FilterTable::SetCriterion (const int theRow,
1316 const SMESH::Filter::Criterion& theCriterion,
1317 const int theEntityType)
1319 int aType = theEntityType == -1 ? GetType() : theEntityType;
1321 Table* aTable = myTables[ aType ];
1323 if (theRow > aTable->rowCount() - 1)
1326 ((ComboItem*)aTable->item(theRow, 0))->setValue(theCriterion.Type);
1327 onCriterionChanged(theRow, 0, aType);
1328 if ( theCriterion.Compare == SMESH::FT_Undefined )
1329 ((ComboItem*)aTable->item(theRow, 1))->setValue( SMESH::FT_EqualTo );
1331 ((ComboItem*)aTable->item(theRow, 1))->setValue(theCriterion.Compare);
1332 ((CheckItem*)aTable->item(theRow, 3))->setChecked(theCriterion.UnaryOp == SMESH::FT_LogicalNOT);
1334 if (theCriterion.BinaryOp != SMESH::FT_Undefined)
1336 if (!aTable->isEditable(theRow, 4))
1337 aTable->setItem(theRow, 4, getBinaryItem());
1338 ((ComboItem*)aTable->item(theRow, 4))->setValue(theCriterion.BinaryOp);
1341 aTable->setEditable(false, theRow, 4);
1343 if (theCriterion.Type == SMESH::FT_GroupColor )
1345 QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(theRow, 2));
1349 QString clrStr( theCriterion.ThresholdStr );
1350 QStringList clrVals = clrStr.split( ";" );
1351 if ( clrVals.count() > 2 )
1352 qClr.setRgb( (int)256*clrVals[0].toDouble(),
1353 (int)256*clrVals[1].toDouble(),
1354 (int)256*clrVals[2].toDouble() );
1355 clrBtn->setColor( qClr );
1358 else if (theCriterion.Type == SMESH::FT_ElemGeomType ||
1359 theCriterion.Type == SMESH::FT_EntityType )
1361 ComboItem* typeBox = (ComboItem*)aTable->item(theRow, 2);
1362 typeBox->setValue( (int)(theCriterion.Threshold + 0.5) );
1364 else if (theCriterion.Type == SMESH::FT_CoplanarFaces )
1366 aTable->item( theRow, 2 )->setText( QString( theCriterion.ThresholdID ) );
1368 else if (theCriterion.Type == SMESH::FT_ConnectedElements )
1370 if ( strlen( theCriterion.ThresholdID ) > 0 ) // shape ID -> name
1372 _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( theCriterion.ThresholdID.in() );
1374 aTable->item( theRow, 2 )->setText( QString( theCriterion.ThresholdID ) );
1376 aTable->item( theRow, 2 )->setText( QString( sobj->GetName().c_str() ));
1378 else if ( strlen( theCriterion.ThresholdStr ) > 0 ) // point coords
1380 aTable->item( theRow, 2 )->setText( QString( theCriterion.ThresholdStr ));
1384 aTable->item( theRow, 2 )->setText( QString("%1").arg((int) theCriterion.Threshold ));
1387 else if (theCriterion.Type != SMESH::FT_RangeOfIds &&
1388 theCriterion.Type != SMESH::FT_BelongToMeshGroup &&
1389 theCriterion.Type != SMESH::FT_BelongToGeom &&
1390 theCriterion.Type != SMESH::FT_BelongToPlane &&
1391 theCriterion.Type != SMESH::FT_BelongToCylinder &&
1392 theCriterion.Type != SMESH::FT_BelongToGenSurface &&
1393 theCriterion.Type != SMESH::FT_LyingOnGeom &&
1394 theCriterion.Type != SMESH::FT_FreeBorders &&
1395 theCriterion.Type != SMESH::FT_FreeEdges &&
1396 theCriterion.Type != SMESH::FT_FreeNodes &&
1397 theCriterion.Type != SMESH::FT_FreeFaces &&
1398 theCriterion.Type != SMESH::FT_BadOrientedVolume &&
1399 theCriterion.Type != SMESH::FT_BareBorderFace &&
1400 theCriterion.Type != SMESH::FT_BareBorderVolume &&
1401 theCriterion.Type != SMESH::FT_OverConstrainedFace &&
1402 theCriterion.Type != SMESH::FT_OverConstrainedVolume &&
1403 theCriterion.Type != SMESH::FT_LinearOrQuadratic)
1405 // Numeric criterion
1406 aTable->item( theRow, 2 )->setText(QString("%1").arg(theCriterion.Threshold, 0, 'g', 15));
1410 aTable->item( theRow, 2 )->setText(QString(theCriterion.ThresholdStr));
1411 if ( theCriterion.Type != SMESH::FT_RangeOfIds )
1412 aTable->item( theRow, 5 )->setText( QString( theCriterion.ThresholdID ) );
1415 if (theCriterion.Compare == SMESH::FT_EqualTo ||
1416 theCriterion.Type == SMESH::FT_BelongToPlane ||
1417 theCriterion.Type == SMESH::FT_BelongToCylinder ||
1418 theCriterion.Type == SMESH::FT_BelongToGenSurface ||
1419 theCriterion.Type == SMESH::FT_BelongToGeom ||
1420 theCriterion.Type == SMESH::FT_LyingOnGeom ||
1421 theCriterion.Type == SMESH::FT_CoplanarFaces ||
1422 theCriterion.Type == SMESH::FT_EqualNodes)
1424 QTableWidgetItem* anItem = aTable->item(theRow, 0);
1425 if (!myAddWidgets.contains(anItem))
1427 myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack);
1428 myAddWidgets[ anItem ]->SetPrecision( AdditionalWidget::Tolerance, getPrecision( theCriterion.Type ) );
1429 myWgStack->addWidget(myAddWidgets[ anItem ]);
1431 myAddWidgets[ anItem ]->SetDouble(AdditionalWidget::Tolerance, theCriterion.Tolerance);
1434 emit CriterionChanged(theRow, aType);
1437 //=======================================================================
1438 // name : SMESHGUI_FilterTable::Update
1439 // Purpose : Update table
1440 //=======================================================================
1441 void SMESHGUI_FilterTable::Update()
1443 Table* aTable = myTables[ GetType() ];
1444 int aCurrRow = aTable->currentRow();
1445 int numRows = aTable->rowCount();
1446 if ((aCurrRow < 0 || aCurrRow >= numRows) && numRows > 0)
1447 aTable->setCurrentCell(0, 0);
1448 updateAdditionalWidget();
1451 //=======================================================================
1452 // name : SMESHGUI_FilterTable::AddCriterion
1453 // Purpose : Add criterion with parameters
1454 //=======================================================================
1455 void SMESHGUI_FilterTable::AddCriterion (const SMESH::Filter::Criterion& theCriterion,
1456 const int theEntityType)
1458 int aType = theEntityType == -1 ? GetType() : theEntityType;
1459 Table* aTable = myTables[ aType ];
1460 addRow(aTable, aType);
1461 SetCriterion(aTable->rowCount() - 1, theCriterion);
1464 //=======================================================================
1465 // name : SMESHGUI_FilterTable::NumRows
1466 // Purpose : Get number of criterions of current type
1467 //=======================================================================
1468 int SMESHGUI_FilterTable::NumRows (const int theEntityType) const
1470 return myTables[ theEntityType == -1 ? GetType() : theEntityType ]->rowCount();
1473 //=======================================================================
1474 // name : SMESHGUI_FilterTable::Clear
1475 // Purpose : Clear current table
1476 //=======================================================================
1477 void SMESHGUI_FilterTable::Clear (const int theType)
1479 int aType = theType == -1 ? GetType() : theType;
1480 Table* aTable = myTables[ aType ];
1482 if (aTable->rowCount() == 0)
1485 while (aTable->rowCount() > 0)
1487 removeAdditionalWidget(aTable, 0);
1488 aTable->removeRow(0);
1494 //=======================================================================
1495 // name : SMESHGUI_FilterTable::onAddBtn
1496 // Purpose : SLOT. Called then "Add" button pressed.
1497 // Adds new string to table
1498 //=======================================================================
1499 void SMESHGUI_FilterTable::onAddBtn()
1501 int aType = GetType();
1502 addRow(myTables[ aType ], aType);
1507 //=======================================================================
1508 // name : SMESHGUI_FilterTable::onInsertBtn
1509 // Purpose : SLOT. Called then "Insert" button pressed.
1510 // Inserts new string before current one
1511 //=======================================================================
1512 void SMESHGUI_FilterTable::onInsertBtn()
1514 addRow(myTables[ GetType() ], GetType(), false);
1517 //=======================================================================
1518 // name : SMESHGUI_FilterTable::onRemoveBtn
1519 // Purpose : SLOT. Called then "Remove" button pressed.
1520 // Removes current string from table
1521 //=======================================================================
1522 void SMESHGUI_FilterTable::onRemoveBtn()
1524 Table* aTable = myTables[ GetType() ];
1526 if (aTable->rowCount() == 0)
1529 QList<QTableWidgetItem*> items = aTable->selectedItems();
1531 QList<int> aRows = aTable->selectedRows(); // already sorted
1535 removeAdditionalWidget(aTable, i);
1536 aTable->removeRow(i);
1539 // remove control of binary logical operation from last row
1540 if (aTable->rowCount() > 0)
1541 aTable->setEditable(false, aTable->rowCount() - 1, 4);
1546 //=======================================================================
1547 // name : SMESHGUI_FilterTable::updateAdditionalWidget
1548 // Purpose : Enable/Disable widget with additional parameters
1549 //=======================================================================
1550 void SMESHGUI_FilterTable::updateAdditionalWidget()
1552 Table* aTable = myTables[ GetType() ];
1553 int aRow = aTable->currentRow();
1554 if (aRow < 0 || aRow >= aTable->rowCount())
1556 myWgStack->setEnabled(false);
1560 ComboItem* anItem = ((ComboItem*)aTable->item(aRow, 0));
1561 int aCriterion = GetCriterionType(aRow);
1562 bool isDbl = ( aCriterion == SMESH::FT_AspectRatio ||
1563 aCriterion == SMESH::FT_AspectRatio3D ||
1564 aCriterion == SMESH::FT_Warping ||
1565 aCriterion == SMESH::FT_MinimumAngle ||
1566 aCriterion == SMESH::FT_Taper ||
1567 aCriterion == SMESH::FT_Skew ||
1568 aCriterion == SMESH::FT_Area ||
1569 aCriterion == SMESH::FT_Volume3D ||
1570 aCriterion == SMESH::FT_MaxElementLength2D ||
1571 aCriterion == SMESH::FT_MaxElementLength3D ||
1572 aCriterion == SMESH::FT_Length ||
1573 aCriterion == SMESH::FT_Length2D ||
1574 aCriterion == SMESH::FT_Length3D ||
1575 aCriterion == SMESH::FT_Deflection2D ||
1576 aCriterion == SMESH::FT_BallDiameter );
1578 bool toEnable = (( isDbl && ((ComboItem*)aTable->item(aRow, 1))->value() == SMESH::FT_EqualTo) ||
1579 aCriterion == SMESH::FT_BelongToPlane ||
1580 aCriterion == SMESH::FT_BelongToCylinder ||
1581 aCriterion == SMESH::FT_BelongToGenSurface ||
1582 aCriterion == SMESH::FT_BelongToGeom ||
1583 aCriterion == SMESH::FT_LyingOnGeom ||
1584 aCriterion == SMESH::FT_CoplanarFaces ||
1585 aCriterion == SMESH::FT_EqualNodes);
1587 if (!myAddWidgets.contains(anItem))
1589 myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack);
1590 myWgStack->addWidget(myAddWidgets[ anItem ]);
1593 myWgStack->setCurrentWidget(myAddWidgets[ anItem ]);
1594 myAddWidgets[ anItem ]->SetPrecision( AdditionalWidget::Tolerance, getPrecision( aCriterion ) );
1595 myWgStack->setEnabled(toEnable);
1598 const char* SMESHGUI_FilterTable::getPrecision( const int aType )
1600 const char* retval = 0;
1602 case SMESH::FT_AspectRatio:
1603 case SMESH::FT_AspectRatio3D:
1604 case SMESH::FT_Taper:
1605 retval = "parametric_precision"; break;
1606 case SMESH::FT_Warping:
1607 case SMESH::FT_MinimumAngle:
1608 case SMESH::FT_Skew:
1609 case SMESH::FT_CoplanarFaces:
1610 retval = "angle_precision"; break;
1611 case SMESH::FT_Area:
1612 retval = "area_precision"; break;
1613 case SMESH::FT_BelongToGeom:
1614 case SMESH::FT_BelongToPlane:
1615 case SMESH::FT_BelongToCylinder:
1616 case SMESH::FT_BelongToGenSurface:
1617 case SMESH::FT_LyingOnGeom:
1618 case SMESH::FT_EqualNodes:
1619 retval = "len_tol_precision"; break;
1620 case SMESH::FT_Length:
1621 case SMESH::FT_Length2D:
1622 case SMESH::FT_Length3D:
1623 case SMESH::FT_Deflection2D:
1624 case SMESH::FT_MaxElementLength2D:
1625 case SMESH::FT_MaxElementLength3D:
1626 case SMESH::FT_BallDiameter:
1627 retval = "length_precision"; break;
1628 case SMESH::FT_Volume3D:
1629 retval = "vol_precision"; break;
1636 //=======================================================================
1637 // name : SMESHGUI_FilterTable::removeAdditionalWidget
1638 // Purpose : Remove widgets containing additional parameters from widget
1639 // stack and internal map
1640 //=======================================================================
1641 void SMESHGUI_FilterTable::removeAdditionalWidget (QTableWidget* theTable, const int theRow)
1643 QTableWidgetItem* anItem = theTable->item(theRow, 0);
1644 if (myAddWidgets.contains(anItem))
1646 myWgStack->removeWidget(myAddWidgets[ anItem ]);
1647 myAddWidgets[ anItem ]->setParent(0);
1648 delete myAddWidgets[ anItem ];
1649 myAddWidgets.remove(anItem);
1653 //=======================================================================
1654 // name : SMESHGUI_FilterTable::onClearBtn
1655 // Purpose : SLOT. Called then "Clear" button pressed.
1656 // Removes all strings from table
1657 //=======================================================================
1658 void SMESHGUI_FilterTable::onClearBtn()
1660 Table* aTable = myTables[ GetType() ];
1662 if (aTable->rowCount() == 0)
1665 while (aTable->rowCount() > 0)
1667 removeAdditionalWidget(aTable, 0);
1668 aTable->removeRow(0);
1674 //=======================================================================
1675 // name : SMESHGUI_FilterTable::onCurrentChanged()
1676 // Purpose : SLOT. Called when current cell changed
1677 //=======================================================================
1678 void SMESHGUI_FilterTable::onCurrentChanged (int theRow, int theCol)
1681 updateAdditionalWidget();
1682 emit CurrentChanged(theRow, theCol);
1685 //=======================================================================
1687 // Purpose : returns available geometry types of elements
1688 //=======================================================================
1689 static QList<int> geomTypes( const int theType )
1692 if ( theType == SMESH::NODE )
1693 typeIds.append( SMESH::Geom_POINT );
1694 if ( theType == SMESH::ALL || theType == SMESH::EDGE )
1695 typeIds.append( SMESH::Geom_EDGE );
1696 if ( theType == SMESH::ALL || theType == SMESH::FACE )
1698 typeIds.append( SMESH::Geom_TRIANGLE );
1699 typeIds.append( SMESH::Geom_QUADRANGLE );
1700 typeIds.append( SMESH::Geom_POLYGON );
1702 if ( theType == SMESH::ALL || theType == SMESH::VOLUME )
1704 typeIds.append( SMESH::Geom_TETRA );
1705 typeIds.append( SMESH::Geom_PYRAMID );
1706 typeIds.append( SMESH::Geom_HEXA );
1707 typeIds.append( SMESH::Geom_PENTA );
1708 typeIds.append( SMESH::Geom_HEXAGONAL_PRISM );
1709 typeIds.append( SMESH::Geom_POLYHEDRA );
1711 if ( theType == SMESH::ALL || theType == SMESH::ELEM0D )
1713 typeIds.append( SMESH::Geom_POINT );
1715 if ( theType == SMESH::ALL || theType == SMESH::BALL )
1717 typeIds.append( SMESH::Geom_BALL );
1722 //=======================================================================
1723 // name : entityTypes
1724 // Purpose : returns available entity types of elements
1725 //=======================================================================
1727 static QList<int> entityTypes( const int theType )
1734 typeIds.append( SMDSEntity_Node );
1737 typeIds.append( SMDSEntity_Edge );
1738 typeIds.append( SMDSEntity_Quad_Edge );
1741 typeIds.append( SMDSEntity_Triangle );
1742 typeIds.append( SMDSEntity_Quad_Triangle );
1743 typeIds.append( SMDSEntity_BiQuad_Triangle );
1744 typeIds.append( SMDSEntity_Quadrangle );
1745 typeIds.append( SMDSEntity_Quad_Quadrangle );
1746 typeIds.append( SMDSEntity_BiQuad_Quadrangle );
1747 typeIds.append( SMDSEntity_Polygon );
1748 typeIds.append( SMDSEntity_Quad_Polygon );
1751 typeIds.append( SMDSEntity_Tetra );
1752 typeIds.append( SMDSEntity_Quad_Tetra );
1753 typeIds.append( SMDSEntity_Pyramid );
1754 typeIds.append( SMDSEntity_Quad_Pyramid );
1755 typeIds.append( SMDSEntity_Hexa );
1756 typeIds.append( SMDSEntity_Quad_Hexa );
1757 typeIds.append( SMDSEntity_TriQuad_Hexa );
1758 typeIds.append( SMDSEntity_Penta );
1759 typeIds.append( SMDSEntity_Quad_Penta );
1760 typeIds.append( SMDSEntity_BiQuad_Penta );
1761 typeIds.append( SMDSEntity_Hexagonal_Prism );
1762 typeIds.append( SMDSEntity_Polyhedra );
1763 //typeIds.append( SMDSEntity_Quad_Polyhedra );
1766 typeIds.append( SMDSEntity_0D );
1769 typeIds.append( SMDSEntity_Ball );
1775 //=======================================================================
1776 // name : SMESHGUI_FilterTable::onCriterionChanged()
1777 // Purpose : Provides reaction on change of criterion
1778 //=======================================================================
1780 void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int /*col*/, const int entityType)
1782 int aType = entityType == -1 ? GetType() : entityType;
1783 Table* aTable = myTables[ aType ];
1784 ComboItem* aCompareItem = (ComboItem*)aTable->item(row, 1);
1786 // find out type of a existing threshould table item
1787 QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(row, 2));
1788 bool isComboItem = false;
1789 bool isIntSpinItem = false;
1790 bool isDoubleSpinItem = false;
1791 if ( QTableWidgetItem* aTableItem = aTable->item(row, 2) )
1793 int aTableType = aTableItem->type();
1794 isComboItem = ( aTableType == ComboItem::Type() );
1795 isIntSpinItem = ( aTableType == IntSpinItem::Type() );
1796 isDoubleSpinItem = ( aTableType == DoubleSpinItem::Type() );
1799 // find out a type of item required by a new criterion and other table features
1800 int aCriterionType = GetCriterionType(row);
1801 bool anIsDoubleCriterion = false;
1802 bool anIsIntCriterion = false;
1803 bool anIsComboCriterion = false;
1805 QList<int> comboIDs; // values to show in a combo item
1806 int nbCompareSigns = 0; // possible values are 0,1,3
1807 bool isThresholdEditable = false; // actual for "simple" item types
1808 switch ( aCriterionType )
1810 case SMESH::FT_AspectRatio:
1811 case SMESH::FT_AspectRatio3D:
1812 case SMESH::FT_Warping:
1813 case SMESH::FT_MinimumAngle:
1814 case SMESH::FT_Taper:
1815 case SMESH::FT_Skew:
1816 case SMESH::FT_Area:
1817 case SMESH::FT_Volume3D:
1818 case SMESH::FT_MaxElementLength2D:
1819 case SMESH::FT_MaxElementLength3D: anIsDoubleCriterion = true; break;
1821 case SMESH::FT_FreeBorders:
1822 case SMESH::FT_FreeEdges:
1823 case SMESH::FT_FreeNodes:
1824 case SMESH::FT_FreeFaces:
1825 case SMESH::FT_EqualNodes:
1826 case SMESH::FT_EqualEdges:
1827 case SMESH::FT_EqualFaces:
1828 case SMESH::FT_EqualVolumes: break;
1830 case SMESH::FT_NodeConnectivityNumber:
1831 case SMESH::FT_MultiConnection:
1832 case SMESH::FT_MultiConnection2D: anIsIntCriterion = true; nbCompareSigns = 3; break;
1834 case SMESH::FT_Length:
1835 case SMESH::FT_Length2D:
1836 case SMESH::FT_Length3D:
1837 case SMESH::FT_Deflection2D: anIsDoubleCriterion = true; break;
1839 case SMESH::FT_BelongToMeshGroup: break;
1841 case SMESH::FT_BelongToGeom:
1842 case SMESH::FT_BelongToPlane:
1843 case SMESH::FT_BelongToCylinder:
1844 case SMESH::FT_BelongToGenSurface:
1845 case SMESH::FT_LyingOnGeom: nbCompareSigns = 0; isThresholdEditable = true; break;
1847 case SMESH::FT_RangeOfIds: nbCompareSigns = 0; isThresholdEditable = true; break;
1849 case SMESH::FT_BadOrientedVolume:
1850 case SMESH::FT_BareBorderVolume:
1851 case SMESH::FT_BareBorderFace:
1852 case SMESH::FT_OverConstrainedVolume:
1853 case SMESH::FT_OverConstrainedFace:
1854 case SMESH::FT_LinearOrQuadratic: break;
1856 case SMESH::FT_GroupColor: nbCompareSigns = 1; isThresholdEditable = true; break;
1858 case SMESH::FT_ElemGeomType:
1859 comboIDs = geomTypes( aType ); anIsComboCriterion = true; nbCompareSigns = 1; break;
1861 case SMESH::FT_EntityType:
1862 comboIDs = entityTypes( aType ); anIsComboCriterion = true; nbCompareSigns = 1; break;
1864 case SMESH::FT_CoplanarFaces: isThresholdEditable = true; break;
1866 case SMESH::FT_BallDiameter: anIsDoubleCriterion = true; break;
1868 case SMESH::FT_ConnectedElements: isThresholdEditable = true; break;
1870 case SMESH::FT_LessThan:
1871 case SMESH::FT_MoreThan:
1872 case SMESH::FT_EqualTo:
1873 case SMESH::FT_LogicalNOT:
1874 case SMESH::FT_LogicalAND:
1875 case SMESH::FT_LogicalOR:
1876 case SMESH::FT_Undefined:
1880 // get a precision of a double criterion
1882 if ( anIsDoubleCriterion ) {
1883 const char* aPrecisionType = getPrecision( aCriterionType );
1884 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr( mySMESHGUI );
1885 if( aPrecisionType && aResourceMgr )
1886 aPrecision = aResourceMgr->integerValue( "SMESH", aPrecisionType, aPrecision );
1889 // check if the current item type satisfies the criterion
1891 ( aCriterionType == SMESH::FT_GroupColor && !clrBtn) ||
1892 ( anIsComboCriterion && !isComboItem ) ||
1893 ( anIsIntCriterion && !isIntSpinItem ) ||
1894 ( anIsDoubleCriterion && !isDoubleSpinItem );
1898 if ( anIsDoubleCriterion )
1900 // if the precision is to be changed we should remove the existing
1901 // spin item and create another one with new precision
1902 if ( DoubleSpinItem* aDoubleSpinItem = dynamic_cast<DoubleSpinItem*>( aTable->item( row, 2 )))
1903 itemTypeKO = ( aDoubleSpinItem->precision() != aPrecision );
1907 else if ( anIsComboCriterion )
1909 if ( ComboItem* aComboItem = dynamic_cast<ComboItem*>( aTable->item( row, 2 )))
1910 itemTypeKO = ( aComboItem->count() != comboIDs.count() );
1914 else if ( !anIsIntCriterion && aCriterionType != SMESH::FT_GroupColor )
1916 itemTypeKO = ( clrBtn || isComboItem || isIntSpinItem || isDoubleSpinItem );
1920 // update the table row
1922 bool isSignalsBlocked = aTable->signalsBlocked();
1923 aTable->blockSignals( true );
1925 // update threshold table item
1928 aTable->removeCellWidget( row, 2 );
1930 if ( aCriterionType == SMESH::FT_GroupColor ) // ---------------------- QtxColorButton
1932 aTable->setCellWidget( row, 2, new QtxColorButton( aTable ) );
1934 else if ( anIsComboCriterion ) // -------------------------------------------ComboItem
1937 ( aCriterionType == SMESH::FT_ElemGeomType ? "GEOM_TYPE_%1" : "ENTITY_TYPE_%1" );
1938 QMap<int, QString> names;
1939 QList<int>::const_iterator id = comboIDs.begin();
1940 for ( ; id != comboIDs.end(); ++id )
1942 QString name = msgPrefix.arg( *id );
1943 names[ *id ] = tr( name.toLatin1().data() );
1945 ComboItem* comboBox = new ComboItem( names );
1946 aTable->setItem( row, 2, comboBox );
1948 else if ( anIsIntCriterion ) // ------------------------------------------ IntSpinItem
1950 IntSpinItem* intSpin = new IntSpinItem( 0 );
1951 aTable->setItem( row, 2, intSpin );
1953 else if ( anIsDoubleCriterion ) // -------------------------------------DoubleSpinItem
1955 DoubleSpinItem* dblSpin = new DoubleSpinItem( 0 );
1956 dblSpin->setPrecision( aPrecision );
1957 aTable->setItem( row, 2, dblSpin );
1959 else // --------------------------------------------------------------QTableWidgetItem
1961 aTable->setItem( row, 2, new QTableWidgetItem() );
1966 if ( anIsDoubleCriterion )
1968 if ( aCompareItem->count() != nbCompareSigns )
1970 switch ( nbCompareSigns ) {
1972 aCompareItem->clear();
1976 QMap<int, QString> aMap;
1977 aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO");
1978 aCompareItem->setItems(aMap);
1982 int oldValue = aCompareItem->value();
1983 aCompareItem->setItems(getCompare());
1984 if ( oldValue >= 0 )
1985 aCompareItem->setValue( oldValue );
1990 aTable->setEditable( nbCompareSigns == 3, row, 1);
1992 // enable/desable Threshold
1993 if ( aCriterionType == SMESH::FT_GroupColor ||
1994 anIsComboCriterion ||
1996 anIsDoubleCriterion )
1998 isThresholdEditable = true;
2000 if ( !isThresholdEditable )
2002 aTable->setItem( row, 2, new QTableWidgetItem() );
2004 aTable->setEditable( isThresholdEditable, row, 2);
2007 aTable->blockSignals( isSignalsBlocked );
2009 updateAdditionalWidget();
2011 emit CriterionChanged(row, entityType);
2014 //=======================================================================
2015 // name : SMESHGUI_FilterTable::onCriterionChanged()
2016 // Purpose : SLOT. Called then contents of table changed
2017 // Provides reaction on change of criterion
2018 //=======================================================================
2019 void SMESHGUI_FilterTable::onCriterionChanged (int row, int col)
2022 onCriterionChanged(row, col, -1);
2023 else if ( col == 2 )
2024 emit ThresholdChanged(row, GetType());
2027 //=======================================================================
2028 // name : SMESHGUI_FilterTable::getFirstSelectedRow
2029 // Purpose : Get first selected row
2030 //=======================================================================
2031 int SMESHGUI_FilterTable::getFirstSelectedRow() const
2033 Table* aTable = myTables[ GetType() ];
2035 QList<int> selRows = aTable->selectedRows(); // already sorted
2036 int aRow = selRows.count() > 0 ? selRows[0] : aTable->currentRow();
2038 return aRow >= 0 && aRow < aTable->rowCount() ? aRow : -1;
2041 //=======================================================================
2042 // name : SMESHGUI_FilterTable::addRow
2043 // Purpose : Add row at the end of table
2044 //=======================================================================
2045 void SMESHGUI_FilterTable::addRow (Table* theTable, const int theType, const bool toTheEnd)
2048 int aSelectedRow = getFirstSelectedRow();
2049 int aCurrCol = theTable->currentColumn();
2052 if (toTheEnd || aSelectedRow == -1)
2054 theTable->insertRows(theTable->rowCount());
2055 aCurrRow = theTable->rowCount() - 1;
2059 theTable->insertRows(aSelectedRow);
2060 aCurrRow = aSelectedRow;
2064 // IPAL19372 - to prevent calling onCriterionChanged() slot before completion of setItem()
2065 bool isSignalsBlocked = theTable->signalsBlocked();
2066 theTable->blockSignals( true );
2069 theTable->setItem(aCurrRow, 0, getCriterionItem(theType));
2072 theTable->setItem(aCurrRow, 1, getCompareItem());
2075 theTable->setItem(aCurrRow, 2, new QTableWidgetItem());
2077 // Logical operation NOT
2078 theTable->setItem(aCurrRow, 3, getUnaryItem());
2080 // Logical operation AND / OR
2081 theTable->setItem(aCurrRow, 4, new QTableWidgetItem());
2083 theTable->setItem(aCurrRow, 5, new QTableWidgetItem());
2085 theTable->blockSignals( isSignalsBlocked );
2087 // Logical binary operation for previous value
2088 int anAddBinOpStr = -1;
2089 if (aCurrRow == theTable->rowCount() - 1)
2090 anAddBinOpStr = aCurrRow - 1;
2091 else if (aCurrRow >= 0 )
2092 anAddBinOpStr = aCurrRow;
2094 if (theTable->item(aCurrRow, 4) == 0 ||
2095 theTable->item(aCurrRow, 4)->type() != ComboItem::Type())
2097 if (anAddBinOpStr >= 0 &&
2098 (theTable->item(anAddBinOpStr, 4) == 0 ||
2099 theTable->item(anAddBinOpStr, 4)->type() != ComboItem::Type()))
2100 theTable->setItem(anAddBinOpStr, 4, getBinaryItem());
2103 theTable->setEditable(false, theTable->rowCount() - 1, 4);
2105 if (aCurrRow >=0 && aCurrRow < theTable->rowCount() &&
2106 aCurrCol >=0 && aCurrCol < theTable->rowCount())
2107 theTable->setCurrentCell(aCurrRow, aCurrCol);
2109 onCriterionChanged(aCurrRow, 0);
2114 //=======================================================================
2115 // name : SMESHGUI_FilterTable::getCriterionItem
2116 // Purpose : Get combo table item for criteria of specified type
2117 //=======================================================================
2118 QTableWidgetItem* SMESHGUI_FilterTable::getCriterionItem (const int theType) const
2120 return new ComboItem(getCriteria(theType));
2123 //=======================================================================
2124 // name : SMESHGUI_FilterTable::getCompareItem
2125 // Purpose : Get combo table item for operation of comparison
2126 //=======================================================================
2127 QTableWidgetItem* SMESHGUI_FilterTable::getCompareItem () const
2129 return new ComboItem(getCompare());
2132 //=======================================================================
2133 // name : SMESHGUI_FilterTable::getBinaryItem
2135 //=======================================================================
2136 QTableWidgetItem* SMESHGUI_FilterTable::getBinaryItem () const
2138 static QMap<int, QString> aMap;
2141 aMap[ SMESH::FT_LogicalAND ] = tr("AND");
2142 aMap[ SMESH::FT_LogicalOR ] = tr("OR");
2145 return new ComboItem(aMap);
2148 //=======================================================================
2149 // name : SMESHGUI_FilterTable::getUnaryItem
2150 // Purpose : Get check table item
2151 //=======================================================================
2152 QTableWidgetItem* SMESHGUI_FilterTable::getUnaryItem () const
2154 return new CheckItem(tr("NOT"));
2157 //=======================================================================
2158 // name : SMESHGUI_FilterTable::getSupportedTypes
2159 // Purpose : Get all supported type
2160 //=======================================================================
2161 const QMap<int, QString>& SMESHGUI_FilterTable::getSupportedTypes() const
2163 static QMap<int, QString> aTypes;
2164 if (aTypes.isEmpty())
2166 aTypes[ SMESH::NODE ] = tr("NODES");
2167 aTypes[ SMESH::ELEM0D ] = tr("ELEM0D");
2168 aTypes[ SMESH::BALL ] = tr("BALLS");
2169 aTypes[ SMESH::EDGE ] = tr("EDGES");
2170 aTypes[ SMESH::FACE ] = tr("FACES");
2171 aTypes[ SMESH::VOLUME ] = tr("VOLUMES");
2172 aTypes[ SMESH::ALL ] = tr("ELEMENTS");
2178 //=======================================================================
2179 // name : SMESHGUI_FilterTable::getCriteria
2180 // Purpose : Get criteria for specified type
2181 //=======================================================================
2182 const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria (const int theType) const
2184 if (theType == SMESH::NODE)
2186 static QMap<int, QString> aCriteria;
2187 if (aCriteria.isEmpty())
2189 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
2190 aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
2191 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
2192 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
2193 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
2194 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
2195 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
2196 aCriteria[ SMESH::FT_FreeNodes ] = tr("FREE_NODES");
2197 aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
2198 aCriteria[ SMESH::FT_EqualNodes ] = tr("EQUAL_NODE");
2199 aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
2200 aCriteria[ SMESH::FT_NodeConnectivityNumber ] = tr("NODE_CONN_NUMBER");
2204 else if (theType == SMESH::EDGE)
2206 static QMap<int, QString> aCriteria;
2207 if (aCriteria.isEmpty())
2209 aCriteria[ SMESH::FT_FreeBorders ] = tr("FREE_BORDERS");
2210 aCriteria[ SMESH::FT_MultiConnection ] = tr("MULTI_BORDERS");
2211 aCriteria[ SMESH::FT_Length ] = tr("LENGTH");
2212 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
2213 aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
2214 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
2215 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
2216 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
2217 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
2218 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
2219 aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
2220 aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
2221 aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
2222 aCriteria[ SMESH::FT_EqualEdges ] = tr("EQUAL_EDGE");
2223 aCriteria[ SMESH::FT_EntityType ] = tr("ENTITY_TYPE");
2224 aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
2228 else if (theType == SMESH::FACE)
2230 static QMap<int, QString> aCriteria;
2231 if (aCriteria.isEmpty())
2233 aCriteria[ SMESH::FT_AspectRatio ] = tr("ASPECT_RATIO");
2234 aCriteria[ SMESH::FT_Warping ] = tr("WARPING");
2235 aCriteria[ SMESH::FT_MinimumAngle ] = tr("MINIMUM_ANGLE");
2236 aCriteria[ SMESH::FT_Taper ] = tr("TAPER");
2237 aCriteria[ SMESH::FT_Skew ] = tr("SKEW");
2238 aCriteria[ SMESH::FT_Area ] = tr("AREA");
2239 aCriteria[ SMESH::FT_MaxElementLength2D ] = tr("MAX_ELEMENT_LENGTH_2D");
2240 aCriteria[ SMESH::FT_FreeEdges ] = tr("FREE_EDGES");
2241 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
2242 aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
2243 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
2244 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
2245 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
2246 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
2247 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
2248 aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D");
2249 aCriteria[ SMESH::FT_Deflection2D ] = tr("DEFLECTION2D");
2250 aCriteria[ SMESH::FT_MultiConnection2D ] = tr("MULTI2D_BORDERS");
2251 aCriteria[ SMESH::FT_FreeFaces ] = tr("FREE_FACES");
2252 aCriteria[ SMESH::FT_BareBorderFace ] = tr("BARE_BORDER_FACE");
2253 aCriteria[ SMESH::FT_OverConstrainedFace] = tr("OVER_CONSTRAINED_FACE");
2254 aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
2255 aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
2256 aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
2257 aCriteria[ SMESH::FT_CoplanarFaces ] = tr("COPLANAR_FACES");
2258 aCriteria[ SMESH::FT_EqualFaces ] = tr("EQUAL_FACE");
2259 aCriteria[ SMESH::FT_EntityType ] = tr("ENTITY_TYPE");
2260 aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
2264 else if (theType == SMESH::VOLUME)
2266 static QMap<int, QString> aCriteria;
2267 if (aCriteria.isEmpty())
2269 aCriteria[ SMESH::FT_AspectRatio3D ] = tr("ASPECT_RATIO_3D");
2270 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
2271 aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
2272 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
2273 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
2274 aCriteria[ SMESH::FT_BadOrientedVolume ] = tr("BAD_ORIENTED_VOLUME");
2275 aCriteria[ SMESH::FT_BareBorderVolume ] = tr("BARE_BORDER_VOLUME");
2276 aCriteria[ SMESH::FT_OverConstrainedVolume] = tr("OVER_CONSTRAINED_VOLUME");
2277 aCriteria[ SMESH::FT_Length3D ] = tr("LENGTH3D");
2278 aCriteria[ SMESH::FT_Volume3D ] = tr("VOLUME_3D");
2279 aCriteria[ SMESH::FT_MaxElementLength3D ] = tr("MAX_ELEMENT_LENGTH_3D");
2280 aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
2281 aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
2282 aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
2283 aCriteria[ SMESH::FT_EqualVolumes ] = tr("EQUAL_VOLUME");
2284 aCriteria[ SMESH::FT_EntityType ] = tr("ENTITY_TYPE");
2285 aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
2289 else if (theType == SMESH::ELEM0D)
2291 static QMap<int, QString> aCriteria;
2292 if (aCriteria.isEmpty())
2294 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
2295 aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
2296 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
2297 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
2298 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
2299 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
2300 aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
2301 aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
2305 else if (theType == SMESH::BALL)
2307 static QMap<int, QString> aCriteria;
2308 if (aCriteria.isEmpty())
2310 aCriteria[ SMESH::FT_BallDiameter ] = tr("BALL_DIAMETER");
2311 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
2312 aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
2313 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
2314 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
2315 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
2316 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
2317 aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
2318 aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
2322 else if (theType == SMESH::ELEM0D)
2324 static QMap<int, QString> aCriteria;
2325 if (aCriteria.isEmpty())
2327 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
2328 aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
2329 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
2330 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
2331 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
2332 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
2333 aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
2334 aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
2340 static QMap<int, QString> aCriteria;
2341 if (aCriteria.isEmpty())
2343 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
2344 aCriteria[ SMESH::FT_BelongToMeshGroup ] = tr("BELONG_TO_MESH_GROUP");
2345 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
2346 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
2347 aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
2348 aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
2349 aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
2350 aCriteria[ SMESH::FT_ConnectedElements ] = tr("CONNECTED_ELEMS");
2358 //=======================================================================
2359 // name : SMESHGUI_FilterTable::getCompare
2360 // Purpose : Get operation of comparison
2361 //=======================================================================
2362 const QMap<int, QString>& SMESHGUI_FilterTable::getCompare() const
2364 static QMap<int, QString> aMap;
2368 aMap[ SMESH::FT_LessThan ] = tr("LESS_THAN");
2369 aMap[ SMESH::FT_MoreThan ] = tr("MORE_THAN");
2370 aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO" );
2376 //=======================================================================
2377 // name : SMESHGUI_FilterTable::createTable
2378 // Purpose : Create table
2379 //=======================================================================
2380 SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable (QWidget* theParent,
2381 const int /*theType*/)
2384 Table* aTable= new Table(0, 6, theParent);
2386 QHeaderView* aHeaders = aTable->horizontalHeader();
2388 QFontMetrics aMetrics(aHeaders->font());
2390 // append spaces to the header of criteria in order to
2391 // provide visibility of criterion inside comboboxes
2392 static int aMaxLenCr = 0;
2396 const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
2397 QMap<int, QString>::const_iterator anIter;
2398 for (anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter)
2399 aMaxLenCr = qMax(maxLength(getCriteria(anIter.key()), aMetrics), aMaxLenCr);
2402 static int aLenCr = qAbs( aMaxLenCr -
2403 aMetrics.width(tr("CRITERION"))) / aMetrics.width(' ') + 5;
2406 aCrStr.fill(' ', aLenCr);
2408 aCoStr.fill(' ', 10);
2410 QStringList aHeaderLabels;
2411 aHeaderLabels.append( tr("CRITERION") + aCrStr );
2412 aHeaderLabels.append( tr("COMPARE") + aCoStr );
2413 aHeaderLabels.append( tr("THRESHOLD_VALUE") );
2414 aHeaderLabels.append( tr("UNARY") );
2415 aHeaderLabels.append( tr("BINARY") + " " );
2416 aHeaderLabels.append( tr("ID") );
2417 aTable->setHorizontalHeaderLabels( aHeaderLabels );
2419 // set geometry of the table
2420 for (int i = 0; i <= 4; i++)
2421 aTable->resizeColumnToContents(i);
2423 // set the ID column invisible
2424 aTable->hideColumn( 5 );
2426 aTable->updateGeometry();
2427 QSize aSize = aTable->sizeHint();
2428 int aWidth = aSize.width();
2429 aTable->setMinimumSize(QSize(aWidth, aWidth / 2));
2430 aTable->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
2432 connect(aTable, SIGNAL(cellChanged(int, int)),
2433 this, SLOT(onCriterionChanged(int, int)));
2435 connect(aTable, SIGNAL(currentCellChanged(int, int, int, int)),
2436 this, SLOT(onCurrentChanged(int, int)));
2441 //=======================================================================
2442 // name : SMESHGUI_FilterTable::updateBtnState
2443 // Purpose : Update button state
2444 //=======================================================================
2445 void SMESHGUI_FilterTable::updateBtnState()
2447 myRemoveBtn->setEnabled(myTables[ GetType() ]->rowCount() > 0);
2448 myClearBtn->setEnabled(myTables[ GetType() ]->rowCount() > 0);
2451 //=======================================================================
2452 // name : SMESHGUI_FilterTable::SetEditable
2453 // Purpose : Set read only flag for tables. Show/hide buttons for work with rows
2454 //=======================================================================
2455 void SMESHGUI_FilterTable::SetEditable (const bool isEditable)
2457 TableMap::iterator anIter;
2458 for (anIter = myTables.begin(); anIter != myTables.end(); ++anIter)
2460 anIter.value()->setReadOnly(!isEditable);
2462 // Set Flags for CheckItems directly IPAL 19974
2463 Table* aTable = anIter.value();
2464 for (int i = 0, n = aTable->rowCount(); i < n; i++)
2465 for (int j = 0, m = aTable->columnCount(); j < m; j++)
2467 QTableWidgetItem* anItem = aTable->item(i, j);
2468 if ( dynamic_cast<SMESHGUI_FilterTable::CheckItem*>( anItem ) ) {
2469 Qt::ItemFlags f = anItem->flags();
2470 if (!isEditable) f = f & ~Qt::ItemIsUserCheckable;
2471 else f = f | Qt::ItemIsUserCheckable;
2472 anItem->setFlags( f );
2480 myInsertBtn->show();
2481 myRemoveBtn->show();
2487 myInsertBtn->hide();
2488 myRemoveBtn->hide();
2493 QMap<QTableWidgetItem*, AdditionalWidget*>::iterator anIter2;
2494 for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2)
2495 anIter2.value()->SetEditable(isEditable);
2498 //=======================================================================
2499 // name : SMESHGUI_FilterTable::SetEnabled
2500 // Purpose : Enable/Disable table. Switching type of elements already enabled
2501 //=======================================================================
2502 void SMESHGUI_FilterTable::SetEnabled (const bool isEnabled)
2504 myAddBtn->setEnabled(isEnabled);
2505 myInsertBtn->setEnabled(isEnabled);
2506 myRemoveBtn->setEnabled(isEnabled);
2507 myClearBtn->setEnabled(isEnabled);
2512 QMap<QTableWidgetItem*, AdditionalWidget*>::iterator anIter2;
2513 for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2)
2514 anIter2.value()->setEnabled(isEnabled);
2517 //=======================================================================
2518 // name : SMESHGUI_FilterTable::IsEditable
2519 // Purpose : Verify whether table is editable
2520 //=======================================================================
2521 bool SMESHGUI_FilterTable::IsEditable() const
2523 return !myTables[ GetType() ]->isReadOnly();
2526 //=======================================================================
2527 // name : SMESHGUI_FilterTable::SetLibsEnabled
2528 // Purpose : Show/hide buttons for work with libraries
2529 //=======================================================================
2530 void SMESHGUI_FilterTable::SetLibsEnabled (const bool isEnabled)
2534 myCopyFromBtn->show();
2539 myCopyFromBtn->hide();
2544 //=======================================================================
2545 // name : SMESHGUI_FilterTable::onCopyFromBtn
2546 // Purpose : SLOT. Called the "Copy from ..." button clicked
2547 // Display filter library dialog
2548 //=======================================================================
2549 void SMESHGUI_FilterTable::onCopyFromBtn()
2552 myLibDlg = new SMESHGUI_FilterLibraryDlg(
2553 mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
2555 myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
2557 if (myLibDlg->exec() == QDialog::Accepted)
2559 Copy(myLibDlg->GetTable());
2564 //=======================================================================
2565 // name : SMESHGUI_FilterTable::onAddToBtn
2566 // Purpose : SLOT. Called the "Add to ..." button clicked
2567 // Display filter library dialog
2568 //=======================================================================
2569 void SMESHGUI_FilterTable::onAddToBtn()
2574 myLibDlg = new SMESHGUI_FilterLibraryDlg(
2575 mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
2577 myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
2579 myLibDlg->SetTable(this);
2584 //=======================================================================
2585 // name : SMESHGUI_FilterTable::Copy
2586 // Purpose : Initialise table with values of other table
2587 //=======================================================================
2588 void SMESHGUI_FilterTable::Copy (const SMESHGUI_FilterTable* theTable)
2592 for (int i = 0, n = theTable->NumRows(); i < n; i++)
2594 SMESH::Filter::Criterion aCriterion = SMESHGUI_FilterDlg::createCriterion();
2595 theTable->GetCriterion(i, aCriterion);
2596 AddCriterion(aCriterion);
2600 //=======================================================================
2601 // name : SMESHGUI_FilterTable::CurrentCell
2602 // Purpose : Returns current cell
2603 //=======================================================================
2604 bool SMESHGUI_FilterTable::CurrentCell (int& theRow, int& theCol) const
2606 theRow = myTables[ GetType() ]->currentRow();
2607 theCol = myTables[ GetType() ]->currentColumn();
2608 return theRow >= 0 && theCol >= 0;
2611 //=======================================================================
2612 // name : SMESHGUI_FilterTable::SetText
2613 // Purpose : Set text and internal value in cell of threshold value
2614 //=======================================================================
2615 void SMESHGUI_FilterTable::SetThreshold (const int theRow,
2616 const QString& theText,
2617 const int theEntityType)
2619 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
2621 bool isSignalsBlocked = aTable->signalsBlocked();
2622 aTable->blockSignals(true);
2624 aTable->item( theRow, 2 )->setText(theText);
2626 aTable->blockSignals(isSignalsBlocked);
2629 //=======================================================================
2630 // name : SMESHGUI_FilterTable::SetText
2631 // Purpose : Get text and internal value from cell of threshold value
2632 //=======================================================================
2633 bool SMESHGUI_FilterTable::GetThreshold (const int theRow,
2635 const int theEntityType)
2637 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
2638 QTableWidgetItem* anItem = aTable->item(theRow, 2);
2641 theText = anItem->text();
2648 //=======================================================================
2649 // name : SMESHGUI_FilterTable::SetID
2650 // Purpose : Set text and internal value in cell of ID value
2651 //=======================================================================
2652 void SMESHGUI_FilterTable::SetID( const int theRow,
2653 const QString& theText,
2654 const int theEntityType )
2656 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
2657 aTable->item( theRow, 5 )->setText( theText );
2660 //=======================================================================
2661 // name : SMESHGUI_FilterTable::GetID
2662 // Purpose : Get text and internal value from cell of ID value
2663 //=======================================================================
2664 bool SMESHGUI_FilterTable::GetID( const int theRow,
2666 const int theEntityType )
2668 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
2669 QTableWidgetItem* anItem = aTable->item( theRow, 5 );
2672 theText = anItem->text();
2680 Class : SMESHGUI_FilterDlg
2681 Description : Dialog to specify filters for VTK viewer
2685 //=======================================================================
2686 // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
2687 // Purpose : Constructor
2688 //=======================================================================
2689 SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
2690 const QList<int>& theTypes )
2691 : QDialog( SMESH::GetDesktop( theModule ) ),
2692 mySMESHGUI( theModule ),
2693 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
2694 myInitSourceWgOnApply( true ),
2695 myInsertEnabled( true ),
2696 myDiffSourcesEnabled( true )
2698 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
2699 mySelector = aViewWindow->GetSelector();
2701 construct(theTypes);
2704 //=======================================================================
2705 // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
2706 // Purpose : Constructor
2707 //=======================================================================
2708 SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
2710 : QDialog( SMESH::GetDesktop( theModule ) ),
2711 mySMESHGUI( theModule ),
2712 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
2713 myInitSourceWgOnApply( true ),
2714 myInsertEnabled( true ),
2715 myDiffSourcesEnabled( true )
2717 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
2718 mySelector = aViewWindow->GetSelector();
2720 aTypes.append(theType);
2724 //=======================================================================
2725 // name : SMESHGUI_FilterDlg::construct
2726 // Purpose : Construct dialog (called by constructor)
2727 //=======================================================================
2728 void SMESHGUI_FilterDlg::construct (const QList<int>& theTypes)
2733 //setAttribute(Qt::WA_DeleteOnClose, true); // VSR ??? is it required?
2734 setWindowTitle(tr("CAPTION"));
2736 QVBoxLayout* aDlgLay = new QVBoxLayout (this);
2737 aDlgLay->setMargin(MARGIN);
2738 aDlgLay->setSpacing(SPACING);
2740 myMainFrame = createMainFrame (this);
2741 QWidget* aBtnFrame = createButtonFrame(this);
2743 aDlgLay->addWidget(myMainFrame);
2744 aDlgLay->addWidget(aBtnFrame);
2746 aDlgLay->setStretchFactor(myMainFrame, 1);
2748 myHelpFileName = "selection_filter_library.html";
2753 //=======================================================================
2754 // name : SMESHGUI_FilterDlg::createMainFrame
2755 // Purpose : Create frame containing dialog's input fields
2756 //=======================================================================
2757 QWidget* SMESHGUI_FilterDlg::createMainFrame (QWidget* theParent)
2759 QWidget* aMainFrame = new QWidget(theParent);
2760 QVBoxLayout* aMainLay = new QVBoxLayout(aMainFrame);
2761 aMainLay->setMargin(0);
2762 aMainLay->setSpacing(SPACING);
2766 myTable = new SMESHGUI_FilterTable( mySMESHGUI, aMainFrame, myTypes );
2767 myTable->SetLibsEnabled(true);
2769 QGroupBox* aGrp = myTable->GetTableGrp();
2770 QGridLayout* aLay = qobject_cast<QGridLayout*>( aGrp->layout() );
2771 int rows = aLay->rowCount();
2772 int cols = aLay->columnCount();
2774 // This line looks strange when all additional parameters and mySetInViewer are hidden
2775 QFrame* aLine = new QFrame(aGrp);
2776 aLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);
2777 aLay->addWidget(aLine, rows++, 0, 1, cols);
2779 mySetInViewer = new QCheckBox(tr("SET_IN_VIEWER"), aGrp);
2780 mySetInViewer->setChecked(true);
2781 aLay->addWidget(mySetInViewer, rows++, 0, 1, cols);
2784 QWidget* aSourceGrp = createSourceGroup(aMainFrame);
2786 connect(myTable, SIGNAL(CriterionChanged(const int, const int)),
2787 SLOT(onCriterionChanged(const int, const int)));
2789 connect(myTable, SIGNAL(CurrentChanged(int, int)),
2790 SLOT(onCurrentChanged(int, int)));
2792 aMainLay->addWidget(myTable);
2793 aMainLay->addWidget(aSourceGrp);
2798 //=======================================================================
2799 // name : SMESHGUI_FilterDlg::createSourceFrame
2800 // Purpose : Create frame containing source radio button
2801 //=======================================================================
2802 QWidget* SMESHGUI_FilterDlg::createSourceGroup (QWidget* theParent)
2804 QGroupBox* aBox = new QGroupBox(tr("SOURCE"), theParent);
2805 QHBoxLayout* aLay = new QHBoxLayout(aBox);
2806 aLay->setMargin(MARGIN);
2807 aLay->setSpacing(SPACING);
2809 mySourceGrp = new QButtonGroup(theParent);
2811 QRadioButton* aMeshBtn = new QRadioButton(tr("MESH"), aBox);
2812 QRadioButton* aSelBtn = new QRadioButton(tr("SELECTION"), aBox);
2813 QRadioButton* aDlgBtn = new QRadioButton(tr("CURRENT_DIALOG"),aBox);
2815 aLay->addWidget(aMeshBtn);
2816 aLay->addWidget(aSelBtn);
2817 aLay->addWidget(aDlgBtn);
2819 mySourceGrp->addButton(aMeshBtn, Mesh);
2820 mySourceGrp->addButton(aSelBtn, Selection);
2821 mySourceGrp->addButton(aDlgBtn, Dialog);
2823 aMeshBtn->setChecked(true);
2828 //=======================================================================
2829 // name : SMESHGUI_FilterDlg::updateMainButtons
2830 // Purpose : Update visibility of main buttons (OK, Cancel, Close ...)
2831 //=======================================================================
2832 void SMESHGUI_FilterDlg::updateMainButtons()
2834 myButtons[ BTN_Close ]->show();
2835 if (myTypes.count() == 1)
2837 myButtons[ BTN_Apply ]->hide();
2841 myButtons[ BTN_Apply ]->show();
2843 // updateGeometry();
2846 //=======================================================================
2847 // name : SMESHGUI_FilterDlg::createButtonFrame
2848 // Purpose : Create frame containing buttons
2849 //=======================================================================
2850 QWidget* SMESHGUI_FilterDlg::createButtonFrame (QWidget* theParent)
2852 QGroupBox* aGrp = new QGroupBox(theParent);
2853 QHBoxLayout* aLay = new QHBoxLayout(aGrp);
2854 aLay->setMargin(MARGIN);
2855 aLay->setSpacing(SPACING);
2857 myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGrp);
2858 myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp);
2859 myButtons[ BTN_Close ] = new QPushButton(tr("SMESH_BUT_CLOSE"), aGrp);
2860 myButtons[ BTN_Help ] = new QPushButton(tr("SMESH_BUT_HELP"), aGrp);
2862 aLay->addWidget(myButtons[ BTN_OK ]);
2863 aLay->addSpacing(10);
2864 aLay->addWidget(myButtons[ BTN_Apply ]);
2865 aLay->addSpacing(10);
2867 aLay->addWidget(myButtons[ BTN_Close ]);
2868 aLay->addWidget(myButtons[ BTN_Help ]);
2870 connect(myButtons[ BTN_OK ], SIGNAL(clicked()), SLOT(onOk()));
2871 connect(myButtons[ BTN_Close ], SIGNAL(clicked()), SLOT(reject()));
2872 connect(myButtons[ BTN_Apply ], SIGNAL(clicked()), SLOT(onApply()));
2873 connect(myButtons[ BTN_Help ], SIGNAL(clicked()), SLOT(onHelp()));
2875 updateMainButtons();
2880 //=======================================================================
2881 // name : SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg
2882 // Purpose : Destructor
2883 //=======================================================================
2884 SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg()
2888 //=======================================================================
2889 // name : SMESHGUI_FilterDlg::Init
2890 // Purpose : Init dialog fields, connect signals and slots, show dialog
2891 //=======================================================================
2892 void SMESHGUI_FilterDlg::Init (const int type, const bool setInViewer)
2895 aTypes.append(type);
2896 Init(aTypes,setInViewer);
2899 //=======================================================================
2900 // name : SMESHGUI_FilterDlg::Init
2901 // Purpose : Init dialog fields, connect signals and slots, show dialog
2902 //=======================================================================
2903 void SMESHGUI_FilterDlg::Init (const QList<int>& theTypes, const bool setInViewer)
2905 if ( theTypes.empty() )
2907 Init( SMESH::ALL, setInViewer );
2912 myMesh = SMESH::SMESH_Mesh::_nil();
2913 myGroup = SMESH::SMESH_GroupOnFilter::_nil();
2915 myIsSelectionChanged = false;
2916 myToRestoreSelMode = false;
2918 myTable->Init(theTypes);
2921 if (theTypes.count() == 1)
2923 int aType = theTypes.first();
2924 if (aType == SMESH::NODE ) setWindowTitle(tr("NODES_TLT"));
2925 else if (aType == SMESH::ELEM0D) setWindowTitle(tr("ELEM0D_TLT"));
2926 else if (aType == SMESH::BALL ) setWindowTitle(tr("BALL_TLT"));
2927 else if (aType == SMESH::EDGE ) setWindowTitle(tr("EDGES_TLT"));
2928 else if (aType == SMESH::FACE ) setWindowTitle(tr("FACES_TLT"));
2929 else if (aType == SMESH::VOLUME) setWindowTitle(tr("VOLUMES_TLT"));
2930 else if (aType == SMESH::ALL) setWindowTitle(tr("TLT"));
2933 setWindowTitle(tr("TLT"));
2935 qApp->processEvents();
2940 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
2942 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
2943 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject()));
2944 connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), SLOT(onOpenView()));
2945 connect(mySMESHGUI, SIGNAL(SignalCloseView()), SLOT(onCloseView()));
2947 updateMainButtons();
2950 // Initialise filter table with values of previous filter
2951 QList<int>::const_iterator anIter;
2952 for (anIter = theTypes.begin(); anIter != theTypes.end(); ++anIter)
2954 myTable->Clear(*anIter);
2955 if (!myFilter[ *anIter ]->_is_nil())
2957 SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
2958 if (myFilter[ *anIter ]->GetCriteria(aCriteria))
2960 for (int i = 0, n = aCriteria->length(); i < n; i++)
2961 myTable->AddCriterion(aCriteria[ i ], *anIter);
2966 if (myInsertState.contains(theTypes.first()))
2967 mySetInViewer->setChecked(myInsertState[ theTypes.first() ]);
2969 mySetInViewer->setChecked(setInViewer);
2971 mySourceGrp->button(myApplyToState.contains(theTypes.first()) ?
2972 myApplyToState[ theTypes.first() ] :
2973 Mesh)->setChecked(true);
2976 //=======================================================================
2977 // name : SMESHGUI_FilterDlg::onOk
2978 // Purpose : SLOT called when "Ok" button pressed.
2979 // Assign filters VTK viewer and close dialog
2980 //=======================================================================
2981 void SMESHGUI_FilterDlg::onOk()
2986 mySelectionMgr->clearFilters();
2987 disconnect(mySMESHGUI, 0, this, 0);
2988 disconnect(mySelectionMgr, 0, this, 0);
2989 mySMESHGUI->ResetState();
2995 //=======================================================================
2996 // name : SMESHGUI_FilterDlg::reject
2997 // Purpose : SLOT called when "Close" button pressed. Close dialog
2998 //=======================================================================
2999 void SMESHGUI_FilterDlg::reject()
3002 // Restore previously selected object
3005 SALOME_ListIO aList;
3006 mySelectionMgr->clearFilters();
3007 mySelectionMgr->clearSelected();
3008 SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter (myIObjects);
3009 for ( ; anIter.More(); anIter.Next())
3011 aList.Append(anIter.Key());
3013 TColStd_MapOfInteger aResMap;
3014 const TColStd_IndexedMapOfInteger& anIndMap = anIter.Value();
3015 for (int i = 1, n = anIndMap.Extent(); i <= n; i++)
3016 aResMap.Add(anIndMap(i));
3018 mySelector->AddOrRemoveIndex( anIter.Key(), aResMap, false);
3019 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
3020 aViewWindow->highlight( anIter.Key(), true, true );
3022 mySelectionMgr->setSelectedObjects(aList, false);
3025 disconnect(mySMESHGUI, 0, this, 0);
3026 disconnect(mySelectionMgr, 0, this, 0);
3027 mySMESHGUI->ResetState();
3031 //=================================================================================
3032 // function : onOpenView()
3034 //=================================================================================
3035 void SMESHGUI_FilterDlg::onOpenView()
3038 SMESH::SetPointRepresentation(false);
3041 mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
3045 //=================================================================================
3046 // function : onCloseView()
3048 //=================================================================================
3049 void SMESHGUI_FilterDlg::onCloseView()
3054 //=================================================================================
3055 // function : onHelp()
3057 //=================================================================================
3058 void SMESHGUI_FilterDlg::onHelp()
3060 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
3062 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
3066 platform = "winapplication";
3068 platform = "application";
3070 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
3071 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
3072 arg(app->resourceMgr()->stringValue("ExternalBrowser",
3074 arg(myHelpFileName));
3078 //=======================================================================
3079 // name : SMESHGUI_FilterDlg::onDeactivate
3080 // Purpose : SLOT called when dialog must be deactivated
3081 //=======================================================================
3082 void SMESHGUI_FilterDlg::onDeactivate()
3087 //=======================================================================
3088 // name : SMESHGUI_FilterDlg::enterEvent
3089 // Purpose : Event filter
3090 //=======================================================================
3091 void SMESHGUI_FilterDlg::enterEvent (QEvent*)
3093 // mySMESHGUI->EmitSignalDeactivateDialog();
3094 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
3095 mySMESHGUI->ResetState();
3099 //=======================================================================
3100 // name : SMESHGUI_FilterDlg::getIdsFromWg
3101 // Purpose : Retrieve list of ids from given widget
3102 //=======================================================================
3103 void SMESHGUI_FilterDlg::getIdsFromWg (const QWidget* theWg, QList<int>& theRes) const
3109 if (theWg->inherits("QListWidget"))
3111 const QListWidget* aListBox = qobject_cast<const QListWidget*>( theWg );
3113 for (int i = 0, n = aListBox->count(); i < n; i++)
3115 int anId = aListBox->item(i)->text().toInt(&b);
3117 theRes.append(anId);
3120 else if (theWg->inherits("QLineEdit"))
3122 const QLineEdit* aLineEdit = qobject_cast<const QLineEdit*>( theWg );
3123 QString aStr = aLineEdit->text();
3124 QRegExp aRegExp("(\\d+)");
3129 aPos = aRegExp.indexIn(aStr, aPos);
3132 int anId = aRegExp.cap(1).toInt(&b);
3134 theRes.append(anId);
3135 aPos += aRegExp.matchedLength();
3141 //=======================================================================
3142 // name : SMESHGUI_FilterDlg::getSelMode
3143 // Purpose : Get selection mode of specified type
3144 //=======================================================================
3145 Selection_Mode SMESHGUI_FilterDlg::getSelMode (const int theType) const
3149 case SMESH::NODE : return NodeSelection;
3150 case SMESH::ELEM0D : return Elem0DSelection;
3151 case SMESH::BALL : return BallSelection;
3152 case SMESH::EDGE : return EdgeSelection;
3153 case SMESH::FACE : return FaceSelection;
3154 case SMESH::VOLUME : return VolumeSelection;
3155 case SMESH::ALL : return CellSelection;
3156 default : return ActorSelection;
3161 //=======================================================================
3162 // name : SMESHGUI_FilterDlg::setIdsToWg
3163 // Purpose : Insert identifiers in specified widgets
3164 //=======================================================================
3165 void SMESHGUI_FilterDlg::setIdsToWg (QWidget* theWg, const QList<int>& theIds)
3170 QStringList aStrList;
3171 foreach(int id, theIds)
3172 aStrList << QString::number(id);
3174 if (theWg->inherits("QListWidget"))
3176 qobject_cast<QListWidget*>(theWg)->clear();
3177 qobject_cast<QListWidget*>(theWg)->addItems(aStrList);
3179 else if (theWg->inherits("QLineEdit"))
3181 qobject_cast<QLineEdit*>( theWg )->setText(aStrList.join(" "));
3185 //=======================================================================
3186 // name : SMESHGUI_FilterDlg::isValid
3187 // Purpose : Verify validity of input data
3188 //=======================================================================
3189 bool SMESHGUI_FilterDlg::isValid() const
3191 if (!myTable->IsValid())
3194 for (int i = 0, n = myTable->NumRows(); i < n; i++)
3196 int aType = myTable->GetCriterionType(i);
3197 if (aType == SMESH::FT_BelongToGeom ||
3198 aType == SMESH::FT_BelongToPlane ||
3199 aType == SMESH::FT_BelongToCylinder ||
3200 aType == SMESH::FT_BelongToGenSurface ||
3201 aType == SMESH::FT_LyingOnGeom)
3204 myTable->GetThreshold(i, aName);
3206 std::vector<_PTR(SObject)> aList = SMESH::getStudy()->FindObjectByName(aName.toUtf8().constData(), "GEOM");
3207 if (aList.size() == 0)
3208 aList = SMESH::getStudy()->FindObjectByName(aName.toUtf8().constData(), "SHAPERSTUDY");
3209 if (aList.size() == 0) {
3210 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
3211 tr("BAD_SHAPE_NAME").arg(aName));
3215 if (aType == SMESH::FT_BelongToCylinder ||
3216 aType == SMESH::FT_BelongToPlane ||
3217 aType == SMESH::FT_BelongToGenSurface ) {
3218 CORBA::Object_var anObject = SMESH::SObjectToObject(aList[ 0 ]);
3219 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObject);
3220 if (!aGeomObj->_is_nil()) {
3222 if (!GEOMBase::GetShape(aGeomObj, aFace) ||
3224 aFace.ShapeType() != TopAbs_FACE) {
3225 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
3226 tr("SHAPE_IS_NOT_A_FACE").arg(aName));
3230 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace));
3231 if (aSurf.IsNull()) {
3232 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
3233 tr("SHAPE_IS_NOT_A_FACE").arg(aName));
3237 if (aType == SMESH::FT_BelongToPlane && !aSurf->IsKind(STANDARD_TYPE(Geom_Plane))) {
3238 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
3239 tr("SHAPE_IS_NOT_A_PLANE").arg(aName));
3243 if (aType == SMESH::FT_BelongToCylinder && !aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
3244 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
3245 tr("SHAPE_IS_NOT_A_CYLINDER").arg(aName));
3251 else if (aType == SMESH::FT_CoplanarFaces)
3254 myTable->GetThreshold(i, faceID);
3255 if ( faceID.isEmpty() )
3257 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
3258 tr("FACE_ID_NOT_SELECTED"));
3261 if ( myMesh->_is_nil() )
3263 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
3264 tr("MESH_IS_NOT_SELECTED"));
3267 if ( myMesh->GetElementType( faceID.toLong(), /*iselem=*/true) != SMESH::FACE )
3269 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
3270 tr("NOT_FACE_ID").arg(faceID));
3279 //=======================================================================
3280 // name : SMESHGUI_FilterDlg::SetSourceWg
3281 // Purpose : Set widget of parent dialog containing ids to be filtered if
3282 // user select corresponding source radio button
3283 //=======================================================================
3284 void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg,
3285 const bool initOnApply)
3288 myInitSourceWgOnApply = initOnApply;
3291 //=======================================================================
3292 //function : EnableFiltering
3293 //purpose : Enables "Insert filter in the viewer"
3294 // and different "Source"s (Mesh, Initial Selection, Current Group)
3295 //=======================================================================
3297 void SMESHGUI_FilterDlg::SetEnabled( bool setInViewer, bool diffSources )
3299 myInsertEnabled = setInViewer;
3300 myDiffSourcesEnabled = diffSources;
3302 mySetInViewer->setVisible( myInsertEnabled );
3303 mySourceGrp->button(0)->parentWidget()->setVisible( myDiffSourcesEnabled );
3306 //=======================================================================
3307 // name : SMESHGUI_FilterDlg::SetMesh
3308 // Purpose : Set mesh
3309 //=======================================================================
3310 void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_var theMesh)
3312 if ( !theMesh->_is_nil() ) {
3314 if ( !myFilter[ myTable->GetType() ]->_is_nil())
3315 myFilter[ myTable->GetType() ]->SetMesh( theMesh );
3317 const bool isEnable = !(myMesh->_is_nil());
3318 myButtons[BTN_OK]->setEnabled(isEnable);
3319 myButtons[BTN_Apply]->setEnabled(isEnable);
3322 //=======================================================================
3323 // name : SMESHGUI_FilterDlg::SetGroup
3324 // Purpose : Set a group being edited
3325 //=======================================================================
3326 void SMESHGUI_FilterDlg::SetGroup(SMESH::SMESH_GroupOnFilter_var group)
3331 //=======================================================================
3332 // name : SMESHGUI_FilterDlg::SetSelection
3333 // Purpose : Get filtered ids
3334 //=======================================================================
3335 void SMESHGUI_FilterDlg::SetSelection()
3338 disconnect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone()));
3340 if (mySelectionMgr) {
3342 const SALOME_ListIO& anObjs = mySelector->StoredIObjects();
3343 SALOME_ListIteratorOfListIO anIter (anObjs);
3344 for ( ; anIter.More(); anIter.Next()) {
3345 TColStd_IndexedMapOfInteger aMap;
3346 mySelector->GetIndex(anIter.Value(), aMap);
3347 myIObjects.Bind(anIter.Value(), aMap);
3350 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
3358 //=======================================================================
3359 // name : SMESHGUI_FilterDlg::onApply
3360 // Purpose : SLOT called when "Apply" button pressed.
3361 // Assign filters to VTK viewer
3362 //=======================================================================
3363 bool SMESHGUI_FilterDlg::onApply()
3368 SUIT_OverrideCursor wc;
3370 int aCurrType = myTable->GetType();
3372 if (!createFilter(aCurrType))
3375 insertFilterInViewer();
3377 if (!myFilter[ aCurrType ]->GetPredicate()->_is_nil()) {
3379 bool toFilter = (( getActor() ) ||
3380 ( myInitSourceWgOnApply && mySourceWg ) ||
3381 ( mySourceGrp->checkedId() == Dialog && mySourceWg ));
3383 QList<int> aResultIds;
3384 filterSource(aCurrType, aResultIds);
3386 selectInViewer(aCurrType, aResultIds);
3387 // set ids to the dialog
3388 if ( myInitSourceWgOnApply || mySourceGrp->checkedId() == Dialog )
3389 setIdsToWg(mySourceWg, aResultIds);
3393 myInsertState[ aCurrType ] = mySetInViewer->isChecked();
3394 myApplyToState[ aCurrType ] = mySourceGrp->checkedId();
3396 catch(const SALOME::SALOME_Exception& S_ex)
3398 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3409 //=======================================================================
3410 // name : SMESHGUI_FilterDlg::createFilter
3411 // Purpose : Create predicate for given type
3412 //=======================================================================
3413 bool SMESHGUI_FilterDlg::createFilter (const int theType)
3415 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
3416 if (aFilterMgr->_is_nil())
3419 int n = myTable->NumRows();
3421 SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
3422 aCriteria->length(n);
3424 long aPrecision = -1;
3425 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
3427 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
3428 aPrecision = mgr->integerValue( "SMESH", "controls_precision", aPrecision );
3430 for ( int i = 0; i < n; i++) {
3431 SMESH::Filter::Criterion aCriterion = createCriterion();
3432 myTable->GetCriterion(i, aCriterion);
3433 aCriterion.Precision = aPrecision;
3434 aCriteria[ i ] = aCriterion;
3437 if ( !myFilter[ theType ]->_is_nil() )
3438 myFilter[ theType ]->UnRegister();
3439 myFilter[ theType ] = aFilterMgr->CreateFilter();
3440 myFilter[ theType ]->SetCriteria(aCriteria.inout());
3445 //================================================================================
3447 * \brief Return the current filter
3449 //================================================================================
3451 SMESH::Filter_var SMESHGUI_FilterDlg::GetFilter() const
3453 SMESH::Filter_var filter;
3455 int aCurrType = myTable->GetType();
3456 filter = myFilter[ aCurrType ];
3461 return filter._retn();
3464 //================================================================================
3466 * \brief Sets a filter to the table
3468 //================================================================================
3470 void SMESHGUI_FilterDlg::SetFilter(SMESH::Filter_var filter, int type)
3472 if ( !filter->_is_nil() )
3474 if ( !myFilter[ type ]->_is_nil() )
3475 myFilter[ type ]->UnRegister();
3477 myFilter[ type ] = filter;
3480 //================================================================================
3482 * \brief call UnRegister() for myFilter's
3484 //================================================================================
3486 void SMESHGUI_FilterDlg::UnRegisterFilters()
3488 QMap< int, SMESH::Filter_var >::iterator i_f = myFilter.begin();
3489 for ( ; i_f != myFilter.end(); ++i_f )
3490 if ( !i_f.value()->_is_nil() )
3491 i_f.value()->UnRegister();
3495 //=======================================================================
3496 // name : SMESHGUI_FilterDlg::insertFilterInViewer
3497 // Purpose : Insert filter in viewer
3498 //=======================================================================
3499 void SMESHGUI_FilterDlg::insertFilterInViewer()
3501 if (SVTK_Selector* aSelector = SMESH::GetSelector())
3503 SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType();
3505 if (myFilter[ myTable->GetType() ]->_is_nil() ||
3506 myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() ||
3507 !mySetInViewer->isChecked() ||
3510 SMESH::RemoveFilter(getFilterId(anEntType), aSelector);
3514 Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter();
3515 aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate());
3516 SMESH::RemoveFilter(getFilterId(anEntType), aSelector); //skl for IPAL12631
3517 SMESH::SetFilter(aFilter, aSelector);
3522 //=======================================================================
3523 // name : SMESHGUI_FilterDlg::filterSource
3524 // Purpose : Filter source ids
3525 //=======================================================================
3526 void SMESHGUI_FilterDlg::filterSource (const int theType,
3527 QList<int>& theResIds)
3530 if (myFilter[ theType ]->_is_nil())
3533 int aSourceId = mySourceGrp->checkedId();
3535 if (aSourceId == Mesh || !myDiffSourcesEnabled )
3537 if (myMesh->_is_nil())
3539 SMESH::long_array_var anIds = myFilter[ theType ]->GetElementsId(myMesh);
3540 for (int i = 0, n = anIds->length(); i < n; i++)
3541 theResIds.append(anIds[ i ]);
3543 else if (aSourceId == Selection)
3545 filterSelectionSource(theType, theResIds);
3547 else if (aSourceId == Dialog)
3549 // retrieve ids from dialog
3550 QList<int> aDialogIds;
3551 getIdsFromWg(mySourceWg, aDialogIds);
3553 if (myMesh->_is_nil())
3555 theResIds = aDialogIds;
3560 SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate();
3561 myFilter[ theType ]->SetMesh(myMesh);
3562 QList<int>::const_iterator anIter;
3563 for (anIter = aDialogIds.begin(); anIter != aDialogIds.end(); ++ anIter)
3564 if (aPred->IsSatisfy(*anIter))
3565 theResIds.append(*anIter);
3569 //=======================================================================
3570 // name : SMESHGUI_FilterDlg::filterSelectionSource
3571 // Purpose : Filter source selection
3572 //=======================================================================
3573 void SMESHGUI_FilterDlg::filterSelectionSource (const int theType,
3574 QList<int>& theResIds)
3577 if (myMesh->_is_nil() || mySelectionMgr == 0)
3580 // Create map of entities to be filtered
3581 TColStd_MapOfInteger aToBeFiltered;
3582 SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter(myIObjects);
3584 for ( ; anIter.More(); anIter.Next())
3587 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIter.Key());
3588 if (!aSubMesh->_is_nil())
3590 if (aSubMesh->GetFather()->GetId() == myMesh->GetId())
3592 SMESH::long_array_var anIds =
3593 theType == SMESH::NODE ? aSubMesh->GetNodesId() : aSubMesh->GetElementsId();
3594 for (int i = 0, n = anIds->length(); i < n; i++)
3595 aToBeFiltered.Add(anIds[ i ]);
3600 SMESH::SMESH_GroupBase_var aGroup =
3601 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Key());
3602 if (!aGroup->_is_nil())
3604 if (aGroup->GetType() == theType && aGroup->GetMesh()->GetId() == myMesh->GetId())
3606 SMESH::long_array_var anIds = aGroup->GetListOfID();
3607 for (int i = 0, n = anIds->length(); i < n; i++)
3608 aToBeFiltered.Add(anIds[ i ]);
3613 SMESH::SMESH_Mesh_var aMeshPtr = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIter.Key());
3614 if (!aMeshPtr->_is_nil() && aMeshPtr->GetId() == myMesh->GetId())
3616 const TColStd_IndexedMapOfInteger& aSelMap = anIter.Value();
3618 if (aSelMap.Extent() > 0)
3620 if(SMESH::FindActorByEntry(anIter.Key()->getEntry()))
3622 for (int i = 1; i <= aSelMap.Extent(); i++)
3623 aToBeFiltered.Add(aSelMap(i));
3630 SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate();
3631 myFilter[ theType ]->SetMesh(myMesh);
3632 TColStd_MapIteratorOfMapOfInteger aResIter(aToBeFiltered);
3633 for ( ; aResIter.More(); aResIter.Next())
3634 if (aPred->IsSatisfy(aResIter.Key()))
3635 theResIds.append(aResIter.Key());
3638 //=======================================================================
3639 //function : getActor
3640 //purpose : Returns an actor to show filtered entities
3641 //=======================================================================
3643 SMESH_Actor* SMESHGUI_FilterDlg::getActor()
3645 SMESH_Actor* meshActor = SMESH::FindActorByObject( myMesh );
3646 if ( meshActor && meshActor->GetVisibility() )
3649 SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter(myIObjects);
3650 for ( ; anIter.More(); anIter.Next())
3652 Handle(SALOME_InteractiveObject) io = anIter.Key();
3653 if ( io->hasEntry() )
3655 SMESH_Actor* actor = SMESH::FindActorByEntry( io->getEntry() );
3658 if ( actor->GetVisibility() )
3667 //=======================================================================
3668 // name : SMESHGUI_FilterDlg::selectInViewer
3669 // Purpose : Select given entities in viewer
3670 //=======================================================================
3671 void SMESHGUI_FilterDlg::selectInViewer (const int theType, const QList<int>& theIds)
3673 if (mySelectionMgr == 0 || myMesh->_is_nil() )
3676 mySelectionMgr->clearFilters();
3678 // Set new selection mode if necessary
3679 Selection_Mode aSelMode = getSelMode(theType);
3680 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
3681 if ( aViewWindow && aViewWindow->SelectionMode() != aSelMode )
3683 mySelectionMgr->clearSelected();
3684 mySelectionMgr->clearFilters();
3685 SMESH::SetPointRepresentation( aSelMode == NodeSelection );
3686 aViewWindow->SetSelectionMode(aSelMode);
3690 SMESH_Actor* anActor = getActor();
3691 if ( !anActor || !anActor->hasIO() )
3694 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
3695 SALOME_ListIO aList;
3697 mySelectionMgr->setSelectedObjects(aList, false);
3699 // Remove filter corresponding to the current type from viewer
3700 int aType = myTable->GetType();
3701 int aFilterId = SMESH::UnknownFilter;
3702 if (aType == SMESH::EDGE ) aFilterId = SMESH::EdgeFilter;
3703 else if (aType == SMESH::FACE ) aFilterId = SMESH::FaceFilter;
3704 else if (aType == SMESH::VOLUME) aFilterId = SMESH::VolumeFilter;
3705 Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter(aFilterId);
3706 SMESH::RemoveFilter(aFilterId);
3709 TColStd_MapOfInteger aMap;
3710 QList<int>::const_iterator anIter;
3711 for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
3715 // Set new selection
3716 mySelector->AddOrRemoveIndex(anIO, aMap, false);
3717 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
3718 aViewWindow->highlight( anIO, true, true );
3720 // insert previously stored filter in viewer if necessary
3721 if (!aFilter.IsNull())
3722 SMESH::SetFilter(aFilter);
3725 //=======================================================================
3726 // name : SMESHGUI_FilterDlg::createCriterion
3727 // Purpose : Create criterion structure with default values
3728 //=======================================================================
3729 SMESH::Filter::Criterion SMESHGUI_FilterDlg::createCriterion()
3731 SMESH::Filter::Criterion aCriterion;
3733 aCriterion.Type = SMESH::FT_Undefined;
3734 aCriterion.Compare = SMESH::FT_Undefined;
3735 aCriterion.Threshold = 0;
3736 aCriterion.UnaryOp = SMESH::FT_Undefined;
3737 aCriterion.BinaryOp = SMESH::FT_Undefined;
3738 aCriterion.ThresholdStr = "";
3739 aCriterion.ThresholdID = "";
3740 aCriterion.TypeOfElement = SMESH::ALL;
3745 //=======================================================================
3746 // name : SMESHGUI_FilterDlg::onSelectionDone
3747 // Purpose : SLOT called when selection changed.
3748 // If current cell corresponds to the threshold value of
3749 // BelongToGeom criterion name of selected object is set in this cell
3750 //=======================================================================
3751 void SMESHGUI_FilterDlg::onSelectionDone()
3753 const SALOME_ListIO& aList = mySelector->StoredIObjects();
3754 if ( myMesh->_is_nil() && aList.Extent() > 0 )
3756 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(aList.First());
3757 if ( !(myMesh->_is_nil()) ) {
3758 myButtons[BTN_OK]->setEnabled(true);
3759 myButtons[BTN_Apply]->setEnabled(true);
3763 if (aList.Extent() != 1 || !myTable->CurrentCell(aRow, aCol))
3766 const int type = myTable->GetCriterionType(aRow);
3768 types << SMESH::FT_BelongToGeom << SMESH::FT_BelongToPlane
3769 << SMESH::FT_BelongToCylinder << SMESH::FT_BelongToGenSurface
3770 << SMESH::FT_LyingOnGeom << SMESH::FT_CoplanarFaces
3771 << SMESH::FT_ConnectedElements << SMESH::FT_BelongToMeshGroup;
3772 if ( !types.contains( type ))
3775 Handle(SALOME_InteractiveObject) anIO = aList.First();
3778 case SMESH::FT_CoplanarFaces: // get ID of a selected mesh face
3781 int nbElems = SMESH::GetNameOfSelectedElements(mySelector, anIO, aString);
3783 myTable->SetThreshold(aRow, aString);
3786 case SMESH::FT_ConnectedElements: // get either VERTEX or a node ID
3788 GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
3789 if (!anObj->_is_nil())
3791 myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
3792 myTable->SetID (aRow, anIO->getEntry());
3797 int nbElems = SMESH::GetNameOfSelectedElements(mySelector, anIO, aString);
3799 myTable->SetThreshold(aRow, aString);
3803 case SMESH::FT_BelongToMeshGroup: // get a group Name and Entry
3805 SMESH::SMESH_GroupBase_var grp = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIO);
3806 if ( !grp->_is_nil() )
3808 if ( !myMesh->_is_nil() )
3810 SMESH::SMESH_Mesh_var mesh = grp->GetMesh();
3811 if ( ! myMesh->_is_equivalent( mesh ))
3814 if ( !myGroup->_is_nil() && myGroup->IsInDependency( grp ))
3815 return; // avoid cyclic dependencies between Groups on Filter
3817 myTable->SetThreshold(aRow, SMESH::toQStr( grp->GetName() ));
3818 myTable->SetID (aRow, anIO->getEntry() );
3822 default: // get a GEOM object
3824 GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
3825 if (!anObj->_is_nil())
3827 myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
3828 myTable->SetID (aRow, anIO->getEntry());
3835 //=======================================================================
3836 // name : SMESHGUI_FilterDlg::onCriterionChanged
3837 // Purpose : SLOT called when cretarion of current row changed. Update selection
3838 //=======================================================================
3839 void SMESHGUI_FilterDlg::onCriterionChanged (const int, const int)
3844 //=======================================================================
3845 // name : SMESHGUI_FilterDlg::onThresholdChanged
3846 // Purpose : SLOT called when a threshold value is changed by the user and
3847 // not by myTable->SetThreshold()
3848 //=======================================================================
3849 void SMESHGUI_FilterDlg::onThresholdChanged( const int row, const int type )
3851 if ( myTable->GetCriterionType( row, type ) == SMESH::FT_ConnectedElements )
3853 // to differ the text entered by the user from that got from selection
3854 myTable->SetID( row, "", type );
3858 //=======================================================================
3859 // name : SMESHGUI_FilterDlg::onCurrentChanged
3860 // Purpose : SLOT called when current row changed. Update selection
3861 //=======================================================================
3862 void SMESHGUI_FilterDlg::onCurrentChanged (int, int)
3867 //=======================================================================
3868 // name : SMESHGUI_FilterDlg::updateSelection
3869 // Purpose : UpdateSelection in accordance with current row
3870 //=======================================================================
3871 void SMESHGUI_FilterDlg::updateSelection()
3873 if (mySelectionMgr == 0)
3876 // TColStd_MapOfInteger allTypes;
3877 // for( int i=0; i<10; i++ )
3878 // allTypes.Add( i );
3879 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
3885 mySelectionMgr->clearFilters();
3889 bool isCurrentCell = myTable->CurrentCell(aRow, aCol);
3890 int aCriterionType = myTable->GetCriterionType(aRow);
3891 if ( isCurrentCell &&
3892 (aCriterionType == SMESH::FT_BelongToGeom ||
3893 aCriterionType == SMESH::FT_BelongToPlane ||
3894 aCriterionType == SMESH::FT_BelongToCylinder ||
3895 aCriterionType == SMESH::FT_BelongToGenSurface ||
3896 aCriterionType == SMESH::FT_LyingOnGeom))
3898 if (aCriterionType == SMESH::FT_BelongToGeom ||
3899 aCriterionType == SMESH::FT_BelongToGenSurface ||
3900 aCriterionType == SMESH::FT_LyingOnGeom) {
3902 mySelectionMgr->installFilter(new GEOM_SelectionFilter( aStudy, true ));
3904 } else if (aCriterionType == SMESH::FT_BelongToPlane) {
3905 mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) );
3907 } else if (aCriterionType == SMESH::FT_BelongToCylinder) {
3908 mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Cylinder ) );
3910 myIsSelectionChanged = true;
3913 else if ( aCriterionType == SMESH::FT_BelongToMeshGroup )
3915 SMESH_TypeFilter* typeFilter = 0;
3916 switch ( myTable->GetType() )
3918 case SMESH::NODE : typeFilter = new SMESH_TypeFilter( SMESH::GROUP_NODE ); break;
3919 case SMESH::ELEM0D : typeFilter = new SMESH_TypeFilter( SMESH::GROUP_0D ); break;
3920 case SMESH::BALL : typeFilter = new SMESH_TypeFilter( SMESH::GROUP_BALL ); break;
3921 case SMESH::EDGE : typeFilter = new SMESH_TypeFilter( SMESH::GROUP_EDGE ); break;
3922 case SMESH::FACE : typeFilter = new SMESH_TypeFilter( SMESH::GROUP_FACE ); break;
3923 case SMESH::VOLUME : typeFilter = new SMESH_TypeFilter( SMESH::GROUP_VOLUME ); break;
3924 case SMESH::ALL : typeFilter = new SMESH_TypeFilter( SMESH::GROUP ); break;
3925 default : typeFilter = 0;
3928 mySelectionMgr->installFilter( typeFilter );
3930 else if ( aCriterionType == SMESH::FT_ConnectedElements )
3932 QList<SUIT_SelectionFilter*> fList;
3933 fList.push_back( new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX ));
3934 fList.push_back( new SMESH_TypeFilter( SMESH::IDSOURCE ));
3935 mySelectionMgr->installFilter
3936 ( new SMESH_LogicalFilter( fList, SMESH_LogicalFilter::LO_OR,
3937 !mySelectionMgr->autoDeleteFilter() ));
3939 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
3941 mySelModeToRestore = aViewWindow->SelectionMode();
3942 aViewWindow->SetSelectionMode( NodeSelection );
3943 myToRestoreSelMode = ( mySelModeToRestore != NodeSelection );
3944 if ( myToRestoreSelMode )
3945 SMESH::SetPointRepresentation( true );
3950 mySelector->SetSelectionMode( getSelMode( myTable->GetType() ));
3952 if (myIsSelectionChanged) {
3953 // mySelectionMgr->installFilter( new GEOM_TypeFilter( aStudy, -1 ) ); // This filter deactivates selection
3954 // Impossible to select any object in the OB on the second opening of FilterDlg
3959 //=================================================================================
3960 // function : keyPressEvent()
3962 //=================================================================================
3963 void SMESHGUI_FilterDlg::keyPressEvent( QKeyEvent* e )
3965 QDialog::keyPressEvent( e );
3966 if ( e->isAccepted() )
3969 if ( e->key() == Qt::Key_F1 ) {
3975 //================================================================================
3977 * \brief Restores a selection mode if it was changed to set up some criterion
3979 //================================================================================
3981 void SMESHGUI_FilterDlg::restoreSelMode()
3983 if ( myToRestoreSelMode )
3985 SMESH::SetPointRepresentation( mySelModeToRestore == NodeSelection );
3987 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
3988 aViewWindow->SetSelectionMode( mySelModeToRestore );
3990 myToRestoreSelMode = false;