1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 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.
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
22 // File : SMESHGUI_FilterDlg.cxx
23 // Author : Sergey LITONIN, Open CASCADE S.A.S.
27 #include "SMESHGUI_FilterDlg.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_Filter.h"
33 #include "SMESHGUI_FilterUtils.h"
34 #include "SMESHGUI_FilterLibraryDlg.h"
36 #include <SMESH_Actor.h>
37 #include <SMESH_NumberFilter.hxx>
38 #include <SMESH_TypeFilter.hxx>
40 // SALOME GEOM includes
42 #include <GEOM_FaceFilter.h>
43 #include <GEOM_TypeFilter.h>
45 // SALOME GUI includes
46 #include <SUIT_Desktop.h>
47 #include <SUIT_ResourceMgr.h>
48 #include <SUIT_Session.h>
49 #include <SUIT_MessageBox.h>
51 #include <LightApp_Application.h>
52 #include <LightApp_SelectionMgr.h>
53 #include <SalomeApp_Tools.h>
54 #include <SalomeApp_Study.h>
56 #include <SALOME_ListIO.hxx>
57 #include <SALOME_ListIteratorOfListIO.hxx>
58 #include <SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx>
60 #include <SVTK_ViewWindow.h>
62 // SALOME KERNEL includes
63 #include <SALOMEDSClient_Study.hxx>
66 #include <StdSelect_TypeOfFace.hxx>
67 #include <BRep_Tool.hxx>
69 #include <TopoDS_Shape.hxx>
70 #include <Geom_Plane.hxx>
71 #include <Geom_CylindricalSurface.hxx>
72 #include <Precision.hxx>
73 #include <TColStd_MapOfInteger.hxx>
74 #include <TColStd_IndexedMapOfInteger.hxx>
75 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
80 #include <QPushButton>
82 #include <QTableWidget>
83 #include <QStringList>
84 #include <QHBoxLayout>
85 #include <QVBoxLayout>
86 #include <QGridLayout>
87 #include <QStackedWidget>
88 #include <QApplication>
90 #include <QFontMetrics>
92 #include <QButtonGroup>
93 #include <QRadioButton>
95 #include <QListWidget>
97 #include <QItemDelegate>
98 #include <QDoubleValidator>
100 #include <QHeaderView>
103 #include <SALOMEconfig.h>
104 #include CORBA_SERVER_HEADER(SMESH_Group)
109 //---------------------------------------
111 //---------------------------------------
112 static int maxLength (const QMap<int, QString> theMap, const QFontMetrics& theMetrics)
115 QMap<int, QString>::const_iterator anIter;
116 for (anIter = theMap.begin(); anIter != theMap.end(); ++anIter)
117 aRes = qMax(aRes, theMetrics.width(anIter.value()));
121 //---------------------------------------
123 //---------------------------------------
124 static int getFilterId (SMESH::ElementType theType)
128 case SMESH::NODE : return SMESH::NodeFilter;
129 case SMESH::EDGE : return SMESH::EdgeFilter;
130 case SMESH::FACE : return SMESH::FaceFilter;
131 case SMESH::VOLUME : return SMESH::VolumeFilter;
132 case SMESH::ALL : return SMESH::AllElementsFilter;
133 default : return SMESH::UnknownFilter;
138 Class : SMESHGUI_FilterTable::AdditionalWidget
139 Description : Class for storing additional parameters of criterion
142 class SMESHGUI_FilterTable::AdditionalWidget : public QWidget
148 AdditionalWidget(QWidget* theParent);
149 virtual ~AdditionalWidget();
151 virtual QList<int> GetParameters() const;
152 virtual bool IsValid(const bool = true) const;
153 virtual double GetDouble(const int) const;
154 virtual int GetInteger(const int) const;
155 virtual QString GetString(const int) const;
156 virtual void SetDouble(const int, const double);
157 virtual void SetInteger(const int, const int);
158 virtual void SetString(const int, const QString&);
159 void SetEditable(const int, const bool);
160 void SetEditable(const bool);
163 QMap< int, QLineEdit* > myLineEdits;
166 SMESHGUI_FilterTable::AdditionalWidget::AdditionalWidget (QWidget* theParent)
169 QLabel* aLabel = new QLabel(tr("SMESH_TOLERANCE"), this);
170 myLineEdits[ Tolerance ] = new QLineEdit(this);
171 QDoubleValidator* aValidator = new QDoubleValidator(myLineEdits[ Tolerance ]);
172 aValidator->setBottom(0);
173 myLineEdits[ Tolerance ]->setValidator(aValidator);
175 QHBoxLayout* aLay = new QHBoxLayout(this);
176 aLay->setSpacing(SPACING);
179 aLay->addWidget(aLabel);
180 aLay->addWidget(myLineEdits[ Tolerance ]);
183 QString aText = QString("%1").arg(Precision::Confusion());
184 myLineEdits[ Tolerance ]->setText(aText);
187 SMESHGUI_FilterTable::AdditionalWidget::~AdditionalWidget()
191 QList<int> SMESHGUI_FilterTable::AdditionalWidget::GetParameters() const
194 theList.append(Tolerance);
198 bool SMESHGUI_FilterTable::AdditionalWidget::IsValid (const bool theMsg) const
203 QList<int> aParams = GetParameters();
204 QList<int>::const_iterator anIter;
205 for (anIter = aParams.begin(); anIter != aParams.end(); ++anIter) {
206 const QLineEdit* aWg = myLineEdits[ *anIter ];
208 QString aText = aWg->text();
209 if (aWg->isEnabled() && aWg->validator()->validate(aText, p) != QValidator::Acceptable) {
211 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
212 tr("SMESHGUI_INVALID_PARAMETERS"));
220 double SMESHGUI_FilterTable::AdditionalWidget::GetDouble (const int theId) const
222 return myLineEdits.contains(theId) ? myLineEdits[ theId ]->text().toDouble() : 0;
225 int SMESHGUI_FilterTable::AdditionalWidget::GetInteger (const int theId) const
227 return myLineEdits.contains(theId) ? myLineEdits[ theId ]->text().toInt() : 0;
230 QString SMESHGUI_FilterTable::AdditionalWidget::GetString (const int theId) const
232 return myLineEdits.contains(theId) ? myLineEdits[ theId ]->text() : QString("");
235 void SMESHGUI_FilterTable::AdditionalWidget::SetDouble (const int theId, const double theVal)
237 if (myLineEdits.contains(theId))
238 myLineEdits[ theId ]->setText(QString("%1").arg(theVal));
241 void SMESHGUI_FilterTable::AdditionalWidget::SetInteger (const int theId, const int theVal)
243 if (myLineEdits.contains(theId))
244 myLineEdits[ theId ]->setText(QString("%1").arg(theVal));
247 void SMESHGUI_FilterTable::AdditionalWidget::SetString (const int theId, const QString& theVal)
249 if (myLineEdits.contains(theId))
250 myLineEdits[ theId ]->setText(theVal);
253 void SMESHGUI_FilterTable::AdditionalWidget::SetEditable (const int theId, const bool isEditable)
255 if (myLineEdits.contains(theId))
256 myLineEdits[ theId ]->setReadOnly(!isEditable);
259 void SMESHGUI_FilterTable::AdditionalWidget::SetEditable (const bool isEditable)
261 QList<int> aParams = GetParameters();
262 QList<int>::const_iterator anIter;
263 for (anIter = aParams.begin(); anIter != aParams.end(); ++anIter)
264 SetEditable( *anIter, isEditable );
268 Class : SMESHGUI_FilterTable::ComboItem
269 Description : Combo table item. Identificator corresponding to string may be assigned
272 class SMESHGUI_FilterTable::ComboItem : public QTableWidgetItem
277 ComboItem( const QMap<int, QString>& );
279 void setItems( const QMap<int, QString>& );
284 void setValue( const int );
288 int index( int ) const;
291 QMap<int, int> myIdToIdx;
294 int SMESHGUI_FilterTable::ComboItem::Type()
296 return QTableWidgetItem::UserType + 1;
299 SMESHGUI_FilterTable::ComboItem::ComboItem( const QMap<int, QString>& theIds )
300 : QTableWidgetItem( Type() )
305 void SMESHGUI_FilterTable::ComboItem::setItems( const QMap<int, QString>& theIds )
308 QMap<int, QString>::const_iterator it;
310 for ( it = theIds.begin(); it != theIds.end(); ++it ) {
311 myIdToIdx[it.key()] = items.count();
312 items.append( it.value() );
314 setData( Qt::UserRole, items );
318 void SMESHGUI_FilterTable::ComboItem::clear()
320 QMap<int, QString> empty;
324 int SMESHGUI_FilterTable::ComboItem::count() const
326 return myIdToIdx.count();
329 int SMESHGUI_FilterTable::ComboItem::value() const
331 return( id( data( Qt::UserRole ).toStringList().indexOf( text() ) ) );
334 void SMESHGUI_FilterTable::ComboItem::setValue( const int theId )
336 int idx = index( theId );
337 QStringList items = data( Qt::UserRole ).toStringList();
338 setText( idx >= 0 && idx < items.count() ? items[idx] : "" );
341 int SMESHGUI_FilterTable::ComboItem::id( int idx ) const
343 QMap<int,int>::const_iterator it;
344 for ( it = myIdToIdx.begin(); it != myIdToIdx.end(); ++it )
345 if ( it.value() == idx ) return it.key();
349 int SMESHGUI_FilterTable::ComboItem::index( int i ) const
351 return myIdToIdx.contains( i ) ? myIdToIdx[i] : -1;
354 Class : SMESHGUI_FilterTable::CheckItem
355 Description : Check table item.
358 class SMESHGUI_FilterTable::CheckItem : public QTableWidgetItem
363 CheckItem( bool = false );
364 CheckItem( const QString&, bool = false );
367 void setChecked( bool );
368 bool checked() const;
371 int SMESHGUI_FilterTable::CheckItem::Type()
373 return QTableWidgetItem::UserType + 2;
376 SMESHGUI_FilterTable::CheckItem::CheckItem( bool value )
377 : QTableWidgetItem( Type() )
379 Qt::ItemFlags f = flags();
380 f = f | Qt::ItemIsUserCheckable;
381 f = f & ~Qt::ItemIsTristate;
386 SMESHGUI_FilterTable::CheckItem::CheckItem( const QString& text, bool value )
387 : QTableWidgetItem( Type() )
389 Qt::ItemFlags f = flags();
390 f = f | Qt::ItemIsUserCheckable;
391 f = f & ~Qt::ItemIsTristate;
397 SMESHGUI_FilterTable::CheckItem::~CheckItem()
401 void SMESHGUI_FilterTable::CheckItem::setChecked( bool value )
403 setCheckState( value ? Qt::Checked : Qt::Unchecked );
406 bool SMESHGUI_FilterTable::CheckItem::checked() const
408 return checkState() == Qt::Checked;
412 Class : SMESHGUI_FilterTable::ComboDelegate
413 Description : Table used by this widget
416 class SMESHGUI_FilterTable::ComboDelegate : public QItemDelegate
419 ComboDelegate( QObject* = 0 );
422 QWidget* createEditor( QWidget*, const QStyleOptionViewItem&,
423 const QModelIndex& ) const;
425 void setEditorData( QWidget*, const QModelIndex& ) const;
426 void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const;
428 void updateEditorGeometry( QWidget*, const QStyleOptionViewItem&,
429 const QModelIndex& ) const;
431 QTableWidget* myTable;
434 SMESHGUI_FilterTable::ComboDelegate::ComboDelegate( QObject* parent )
435 : QItemDelegate( parent ),
436 myTable( qobject_cast<QTableWidget*>( parent ) )
440 SMESHGUI_FilterTable::ComboDelegate::~ComboDelegate()
444 QWidget* SMESHGUI_FilterTable::ComboDelegate::createEditor( QWidget* parent,
445 const QStyleOptionViewItem& option,
446 const QModelIndex& index ) const
448 QStringList l = index.data( Qt::UserRole ).toStringList();
449 if ( !l.isEmpty() ) {
450 QComboBox* cb = new QComboBox( parent );
451 cb->setFrame( false );
455 return QItemDelegate::createEditor( parent, option, index );
458 void SMESHGUI_FilterTable::ComboDelegate::setEditorData( QWidget* editor,
459 const QModelIndex& index ) const
461 QString value = index.model()->data( index, Qt::DisplayRole ).toString();
462 QComboBox* cb = static_cast<QComboBox*>( editor );
465 int i = cb->findText( value );
467 cb->setCurrentIndex( i );
471 if ( !bOk ) QItemDelegate::setEditorData( editor, index );
474 void SMESHGUI_FilterTable::ComboDelegate::setModelData( QWidget* editor,
475 QAbstractItemModel* model,
476 const QModelIndex& index) const
478 QComboBox* cb = static_cast<QComboBox*>( editor );
479 if ( cb ) model->setData( index, cb->currentText(), Qt::DisplayRole );
480 else QItemDelegate::setModelData( editor, model, index );
483 void SMESHGUI_FilterTable::ComboDelegate::updateEditorGeometry( QWidget* editor,
484 const QStyleOptionViewItem& option,
485 const QModelIndex& index ) const
487 editor->setGeometry( option.rect );
491 Class : SMESHGUI_FilterTable::Table
492 Description : Table used by this widget
495 class SMESHGUI_FilterTable::Table : public QTableWidget
498 Table( QWidget* = 0 );
499 Table( int, int, QWidget* = 0 );
502 void setEditable( bool, int, int );
503 bool isEditable( int, int ) const;
505 void setReadOnly( bool );
506 bool isReadOnly() const;
508 void insertRows( int, int = 1 );
509 QString text( int, int );
511 QList<int> selectedRows();
514 //=======================================================================
515 // name : SMESHGUI_FilterTable::Table::Table
516 // Purpose : Constructor
517 //=======================================================================
518 SMESHGUI_FilterTable::Table::Table (QWidget* parent)
519 : QTableWidget(parent)
521 // set custom item delegate
522 setItemDelegate( new ComboDelegate(this) );
523 // set edit triggers by default
524 setReadOnly( false );
527 SMESHGUI_FilterTable::Table::Table (int numRows, int numCols, QWidget* parent)
528 : QTableWidget(numRows, numCols, parent)
530 // set custom item delegate
531 setItemDelegate( new ComboDelegate(this) );
532 // set edit triggers by default
533 setReadOnly( false );
536 SMESHGUI_FilterTable::Table::~Table()
540 //=======================================================================
541 // name : SMESHGUI_FilterTable::Table::setEditable
542 // Purpose : Set editable of specified cell
543 //=======================================================================
544 void SMESHGUI_FilterTable::Table::setEditable (bool isEditable,
547 QTableWidgetItem* anItem = item( row, col );
549 Qt::ItemFlags f = anItem->flags();
550 if ( !isEditable ) f = f & ~Qt::ItemIsEditable;
551 else f = f | Qt::ItemIsEditable;
552 anItem->setFlags( f );
556 //=======================================================================
557 // name : SMESHGUI_FilterTable::Table::isEditable
558 // Purpose : Verify wheter cell is editable
559 //=======================================================================
560 bool SMESHGUI_FilterTable::Table::isEditable (int row, int col) const
562 QTableWidgetItem* anItem = item( row, col );
563 return anItem == 0 || anItem->flags() & Qt::ItemIsEditable;
566 void SMESHGUI_FilterTable::Table::setReadOnly( bool on )
568 setEditTriggers( on ?
569 QAbstractItemView::DoubleClicked |
570 QAbstractItemView::SelectedClicked |
571 QAbstractItemView::EditKeyPressed |
572 QAbstractItemView::AnyKeyPressed :
573 QAbstractItemView::NoEditTriggers );
576 bool SMESHGUI_FilterTable::Table::isReadOnly() const
578 return editTriggers() != QAbstractItemView::NoEditTriggers;
581 //=======================================================================
582 // name : SMESHGUI_FilterTable::Table::insertRows
583 // Purpose : Insert rows (virtual redefined)
584 //=======================================================================
585 void SMESHGUI_FilterTable::Table::insertRows (int row, int count)
587 closePersistentEditor( currentItem() );
588 while ( count-- ) insertRow( row );
591 //=======================================================================
592 // name : SMESHGUI_FilterTable::Table::text
593 // Purpose : Get text from cell (virtual redefined)
594 //=======================================================================
595 QString SMESHGUI_FilterTable::Table::text (int row, int col)
597 closePersistentEditor( currentItem() );
598 QTableWidgetItem* anItem = item( row, col );
599 return anItem ? anItem->text() : QString();
602 QList<int> SMESHGUI_FilterTable::Table::selectedRows()
604 QList<QTableWidgetItem*> selItems = selectedItems();
605 QTableWidgetItem* anItem;
608 foreach( anItem, selItems ) {
609 int r = row( anItem );
610 if ( !rows.contains( r ) ) rows.append( r );
618 Class : SMESHGUI_FilterTable
619 Description : Frame containig
620 - Button group for switching entity type
621 - Table for displaying filter criterions
622 - Buttons for editing table and filter libraries
625 //=======================================================================
626 // name : SMESHGUI_FilterTable::SMESHGUI_FilterTable
627 // Purpose : Constructor
628 //=======================================================================
629 SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
634 mySMESHGUI( theModule )
643 //=======================================================================
644 // name : SMESHGUI_FilterTable::SMESHGUI_FilterTable
645 // Purpose : Constructor
646 //=======================================================================
647 SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
649 const QList<int>& types )
652 mySMESHGUI( theModule )
658 SMESHGUI_FilterTable::~SMESHGUI_FilterTable()
662 //=======================================================================
663 // name : SMESHGUI_FilterTable::Init
664 // Purpose : Create table corresponding to the specified type
665 //=======================================================================
666 void SMESHGUI_FilterTable::Init (const QList<int>& theTypes)
668 if (theTypes.isEmpty())
671 // Create buttons if necessary
673 if (myTables.isEmpty())
675 int aType = theTypes.first();
677 // create main layout
678 QVBoxLayout* aMainLay = new QVBoxLayout(this);
679 aMainLay->setMargin( 0 );
680 aMainLay->setSpacing( SPACING );
682 // create switch of entity types
683 myEntityTypeBox = new QGroupBox(tr("ENTITY_TYPE"), this);
684 QHBoxLayout* myEntityTypeBoxLayout = new QHBoxLayout(myEntityTypeBox);
685 myEntityTypeBoxLayout->setMargin( MARGIN );
686 myEntityTypeBoxLayout->setSpacing( SPACING );
687 myEntityTypeGrp = new QButtonGroup(this);
689 const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
690 QMap<int, QString>::const_iterator anIter;
691 for (anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter)
693 QRadioButton* aBtn = new QRadioButton(anIter.value(), myEntityTypeBox);
694 myEntityTypeGrp->addButton(aBtn, anIter.key());
695 myEntityTypeBoxLayout->addWidget(aBtn);
698 myTableGrp = new QGroupBox(tr("FILTER"), this );
701 mySwitchTableGrp = new QWidget(myTableGrp);
702 QVBoxLayout* mySwitchTableGrpLayout = new QVBoxLayout(mySwitchTableGrp);
703 mySwitchTableGrpLayout->setMargin(0);
704 mySwitchTableGrpLayout->setSpacing(0);
706 myTables[ aType ] = createTable(mySwitchTableGrp, aType);
707 mySwitchTableGrpLayout->addWidget(myTables[ aType ]);
710 myAddBtn = new QPushButton(tr("ADD"), myTableGrp);
711 myRemoveBtn = new QPushButton(tr("REMOVE"), myTableGrp);
712 myClearBtn = new QPushButton(tr("CLEAR"), myTableGrp);
713 myInsertBtn = new QPushButton(tr("INSERT"), myTableGrp);
714 myCopyFromBtn = new QPushButton(tr("COPY_FROM"), myTableGrp);
715 myAddToBtn = new QPushButton(tr("ADD_TO"), myTableGrp);
717 myAddBtn->setAutoDefault(false);
718 myRemoveBtn->setAutoDefault(false);
719 myClearBtn->setAutoDefault(false);
720 myInsertBtn->setAutoDefault(false);
721 myCopyFromBtn->setAutoDefault(false);
722 myAddToBtn->setAutoDefault(false);
724 myCopyFromBtn->hide();
728 QGridLayout* aLay = new QGridLayout(myTableGrp);
730 aLay->setSpacing(SPACING);
732 aLay->addWidget(mySwitchTableGrp, 0, 0, 7, 1);
733 aLay->addWidget(myAddBtn, 0, 1);
734 aLay->addWidget(myInsertBtn, 1, 1);
735 aLay->addWidget(myRemoveBtn, 2, 1);
736 aLay->addWidget(myClearBtn, 3, 1);
737 aLay->addWidget(myCopyFromBtn, 5, 1);
738 aLay->addWidget(myAddToBtn, 6, 1);
739 aLay->addWidget(createAdditionalFrame(myTableGrp), 7, 0, 1, 2 );
741 aLay->setRowMinimumHeight(4, 10);
742 aLay->setRowStretch(4, 1);
743 aLay->setColumnStretch(0, 1);
744 aLay->setColumnStretch(1, 0);
747 aMainLay->addWidget(myEntityTypeBox);
748 aMainLay->addWidget(myTableGrp);
751 connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAddBtn()));
752 connect(myInsertBtn, SIGNAL(clicked()), this, SLOT(onInsertBtn()));
753 connect(myRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemoveBtn()));
754 connect(myClearBtn, SIGNAL(clicked()), this, SLOT(onClearBtn()));
756 connect(myCopyFromBtn, SIGNAL(clicked()), this, SLOT(onCopyFromBtn()));
757 connect(myAddToBtn, SIGNAL(clicked()), this, SLOT(onAddToBtn()));
759 connect(myEntityTypeGrp, SIGNAL(buttonClicked(int)), this, SLOT(onEntityType(int)));
764 // Hide buttons of entity types if necessary
765 const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
766 QMap<int, QString>::const_iterator anIt;
767 for (anIt = aSupportedTypes.begin(); anIt != aSupportedTypes.end(); ++anIt)
769 QAbstractButton* aBtn = myEntityTypeGrp->button(anIt.key());
770 if ( aBtn ) aBtn->setVisible( theTypes.contains(anIt.key()) );
773 // select first button if there is no selected buttons or it is hidden
774 int aBtnId = myEntityTypeGrp->checkedId();
775 if ( aBtnId == -1 || !theTypes.contains(aBtnId) ) {
776 QAbstractButton* aBtn = myEntityTypeGrp->button(theTypes.first());
777 if ( aBtn ) aBtn->setChecked(true);
780 myEntityTypeBox->setVisible(theTypes.count() > 1);
782 myTableGrp->updateGeometry();
783 int cType = myEntityTypeGrp->checkedId();
787 //=======================================================================
788 // name : SMESHGUI_FilterTable::createAdditionalFrame
789 // Purpose : Get group box containing table. May be used for adding new widgets in it
790 //=======================================================================
791 QWidget* SMESHGUI_FilterTable::createAdditionalFrame (QWidget* theParent)
793 QWidget* aFrame = new QWidget(theParent);
795 QFrame* aLine1 = new QFrame(aFrame);
796 QFrame* aLine2 = new QFrame(aFrame);
797 aLine1->setFrameStyle(QFrame::HLine | QFrame::Sunken);
798 aLine2->setFrameStyle(QFrame::HLine | QFrame::Sunken);
799 aLine1->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
800 aLine2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
802 QLabel* aLabel = new QLabel(tr("ADDITIONAL_PARAMETERS"), aFrame);
804 myWgStack = new QStackedWidget(aFrame);
806 QGridLayout* aLay = new QGridLayout(aFrame);
808 aLay->setSpacing(SPACING);
809 aLay->addWidget(aLine1, 0, 0);
810 aLay->addWidget(aLabel, 0, 1);
811 aLay->addWidget(aLine2, 0, 2);
812 aLay->addWidget(myWgStack, 1, 0, 1, 3);
817 //=======================================================================
818 // name : SMESHGUI_FilterTable::GetTableGrp
819 // Purpose : Get group box containing table. May be used for adding new widgets in it
820 //=======================================================================
821 QGroupBox* SMESHGUI_FilterTable::GetTableGrp()
826 //=======================================================================
827 // name : SMESHGUI_FilterTable::onEntityType
828 // Purpose : SLOT. Called when entity type changed.
829 // Display corresponding table
830 //=======================================================================
831 void SMESHGUI_FilterTable::onEntityType (int theType)
833 if (myEntityType == theType)
837 emit NeedValidation();
840 myEntityTypeGrp->button(myEntityType)->setChecked(true);
844 myEntityType = theType;
846 if (!myTables.contains(theType)) {
847 myTables[ theType ] = createTable(mySwitchTableGrp, theType);
848 ((QVBoxLayout*)mySwitchTableGrp->layout())->addWidget(myTables[ theType ]);
851 TableMap::iterator anIter;
852 for (anIter = myTables.begin(); anIter != myTables.end(); ++anIter)
853 anIter.value()->setVisible( myEntityType == anIter.key() );
856 qApp->processEvents();
857 myTables[ myEntityType ]->updateGeometry();
860 emit EntityTypeChanged(theType);
863 //=======================================================================
864 // name : SMESHGUI_FilterTable::IsValid
865 // Purpose : Verify validity of entered data
866 //=======================================================================
867 bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType) const
869 int aType = theEntityType == -1 ? GetType() : theEntityType;
871 Table* aTable = myTables[ aType ];
872 for (int i = 0, n = aTable->rowCount(); i < n; i++)
874 int aCriterion = GetCriterionType(i, aType);
876 if (aCriterion == SMESH::FT_RangeOfIds ||
877 aCriterion == SMESH::FT_BelongToGeom ||
878 aCriterion == SMESH::FT_BelongToPlane ||
879 aCriterion == SMESH::FT_BelongToCylinder ||
880 aCriterion == SMESH::FT_BelongToGenSurface ||
881 aCriterion == SMESH::FT_LyingOnGeom) {
882 if (aTable->text(i, 2).isEmpty()) {
884 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
890 aTable->blockSignals(true);
891 double aThreshold = (int)aTable->text(i, 2).toDouble(&aRes);
892 aTable->blockSignals(false);
894 if (!aRes && aTable->isEditable(i, 2)) {
896 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
900 else if (aType == SMESH::EDGE &&
901 GetCriterionType(i, aType) == SMESH::FT_MultiConnection &&
905 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
906 tr("MULTIEDGES_ERROR"));
911 QTableWidgetItem* anItem = aTable->item(i, 0);
912 if (myAddWidgets.contains(anItem) && !myAddWidgets[ anItem ]->IsValid())
919 //=======================================================================
920 // name : SMESHGUI_FilterTable::SetValidity
921 // Purpose : Set validity of the table
922 //=======================================================================
923 void SMESHGUI_FilterTable::SetValidity (const bool isValid)
928 //=======================================================================
929 // name : SMESHGUI_FilterTable::GetType
930 // Purpose : Get current entity type
931 //=======================================================================
932 int SMESHGUI_FilterTable::GetType() const
937 //=======================================================================
938 // name : SMESHGUI_FilterTable::SetType
939 // Purpose : Set current entity type
940 //=======================================================================
941 void SMESHGUI_FilterTable::SetType (const int type)
943 myEntityTypeGrp->button(type)->setChecked(true);
947 //=======================================================================
948 // name : SMESHGUI_FilterTable::RestorePreviousEntityType
949 // Purpose : Restore previous entity type
950 //=======================================================================
951 void SMESHGUI_FilterTable::RestorePreviousEntityType()
953 SetType(myEntityType);
956 //=======================================================================
957 // name : SMESHGUI_FilterTable::GetCriterionType
958 // Purpose : Get type of criterion from specified row (corresponding enums in h-file)
959 //=======================================================================
960 int SMESHGUI_FilterTable::GetCriterionType (const int theRow, const int theType) const
962 int aType = theType == -1 ? GetType() : theType;
963 Table* aTable = myTables[ aType ];
964 ComboItem* anItem = (ComboItem*)aTable->item(theRow, 0);
965 return anItem != 0 ? anItem->value() : SMESH::FT_Undefined;
968 //=======================================================================
969 // name : SMESHGUI_FilterTable::GetCriterion
970 // Purpose : Get parameters of criterion from specified row
971 //=======================================================================
972 void SMESHGUI_FilterTable::GetCriterion (const int theRow,
973 SMESH::Filter::Criterion& theCriterion,
974 const int theEntityType) const
976 int aType = theEntityType == -1 ? GetType() : theEntityType;
977 Table* aTable = myTables[ aType ];
979 theCriterion.Type = ((ComboItem*)aTable->item(theRow, 0))->value();
980 theCriterion.UnaryOp = ((CheckItem*)aTable->item(theRow, 3))->checked() ? SMESH::FT_LogicalNOT : SMESH::FT_Undefined;
981 theCriterion.BinaryOp = theRow != aTable->rowCount() - 1 ?
982 ((ComboItem*)aTable->item(theRow, 4))->value() : SMESH::FT_Undefined;
983 theCriterion.TypeOfElement = (SMESH::ElementType)aType;
985 int aCriterionType = GetCriterionType(theRow, aType);
987 if ( aCriterionType != SMESH::FT_RangeOfIds &&
988 aCriterionType != SMESH::FT_BelongToGeom &&
989 aCriterionType != SMESH::FT_BelongToPlane &&
990 aCriterionType != SMESH::FT_BelongToCylinder &&
991 aCriterionType != SMESH::FT_BelongToGenSurface &&
992 aCriterionType != SMESH::FT_LyingOnGeom)
994 theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->value();
995 theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble();
999 theCriterion.ThresholdStr = aTable->text(theRow, 2).toLatin1().data();
1000 if ( aCriterionType != SMESH::FT_RangeOfIds )
1001 theCriterion.ThresholdID = aTable->text( theRow, 5 ).toLatin1().data();
1004 QTableWidgetItem* anItem = aTable->item(theRow, 0);
1005 if (myAddWidgets.contains(anItem))
1006 theCriterion.Tolerance = myAddWidgets[ anItem ]->GetDouble(AdditionalWidget::Tolerance);
1009 //=======================================================================
1010 // name : SMESHGUI_FilterTable::SetCriterion
1011 // Purpose : Set parameters of criterion of specified row
1012 //=======================================================================
1013 void SMESHGUI_FilterTable::SetCriterion (const int theRow,
1014 const SMESH::Filter::Criterion& theCriterion,
1015 const int theEntityType)
1017 int aType = theEntityType == -1 ? GetType() : theEntityType;
1019 Table* aTable = myTables[ aType ];
1021 if (theRow > aTable->rowCount() - 1)
1024 ((ComboItem*)aTable->item(theRow, 0))->setValue(theCriterion.Type);
1025 onCriterionChanged(theRow, 0, aType);
1026 ((ComboItem*)aTable->item(theRow, 1))->setValue(theCriterion.Compare);
1027 ((CheckItem*)aTable->item(theRow, 3))->setChecked(theCriterion.UnaryOp == SMESH::FT_LogicalNOT);
1029 if (theCriterion.BinaryOp != SMESH::FT_Undefined)
1031 if (!aTable->isEditable(theRow, 4))
1032 aTable->setItem(theRow, 4, getBinaryItem());
1033 ((ComboItem*)aTable->item(theRow, 4))->setValue(theCriterion.BinaryOp);
1036 aTable->setEditable(false, theRow, 4);
1038 if (theCriterion.Type != SMESH::FT_RangeOfIds &&
1039 theCriterion.Type != SMESH::FT_BelongToGeom &&
1040 theCriterion.Type != SMESH::FT_BelongToPlane &&
1041 theCriterion.Type != SMESH::FT_BelongToCylinder &&
1042 theCriterion.Type != SMESH::FT_BelongToGenSurface &&
1043 theCriterion.Type != SMESH::FT_LyingOnGeom &&
1044 theCriterion.Type != SMESH::FT_FreeBorders &&
1045 theCriterion.Type != SMESH::FT_FreeEdges &&
1046 theCriterion.Type != SMESH::FT_BadOrientedVolume)
1047 aTable->item( theRow, 2 )->setText(QString("%1").arg(theCriterion.Threshold, 0, 'g', 15));
1050 aTable->item( theRow, 2 )->setText(QString(theCriterion.ThresholdStr));
1051 if ( theCriterion.Type != SMESH::FT_RangeOfIds )
1052 aTable->item( theRow, 5 )->setText( QString( theCriterion.ThresholdID ) );
1055 if (theCriterion.Compare == SMESH::FT_EqualTo ||
1056 theCriterion.Type == SMESH::FT_BelongToPlane ||
1057 theCriterion.Type == SMESH::FT_BelongToCylinder ||
1058 theCriterion.Type == SMESH::FT_BelongToGenSurface)
1060 QTableWidgetItem* anItem = aTable->item(theRow, 0);
1061 if (!myAddWidgets.contains(anItem))
1063 myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack);
1064 myWgStack->addWidget(myAddWidgets[ anItem ]);
1066 myAddWidgets[ anItem ]->SetDouble(AdditionalWidget::Tolerance, theCriterion.Tolerance);
1069 emit CriterionChanged(theRow, aType);
1073 //=======================================================================
1074 // name : SMESHGUI_FilterTable::Update
1075 // Purpose : Update table
1076 //=======================================================================
1077 void SMESHGUI_FilterTable::Update()
1079 Table* aTable = myTables[ GetType() ];
1080 int aCurrRow = aTable->currentRow();
1081 int numRows = aTable->rowCount();
1082 if ((aCurrRow < 0 || aCurrRow >= numRows) && numRows > 0)
1083 aTable->setCurrentCell(0, 0);
1084 updateAdditionalWidget();
1087 //=======================================================================
1088 // name : SMESHGUI_FilterTable::AddCriterion
1089 // Purpose : Add criterion with parameters
1090 //=======================================================================
1091 void SMESHGUI_FilterTable::AddCriterion (const SMESH::Filter::Criterion& theCriterion,
1092 const int theEntityType)
1094 int aType = theEntityType == -1 ? GetType() : theEntityType;
1095 Table* aTable = myTables[ aType ];
1096 addRow(aTable, aType);
1097 SetCriterion(aTable->rowCount() - 1, theCriterion);
1100 //=======================================================================
1101 // name : SMESHGUI_FilterTable::NumRows
1102 // Purpose : Get number of criterions of current type
1103 //=======================================================================
1104 int SMESHGUI_FilterTable::NumRows (const int theEntityType) const
1106 return myTables[ theEntityType == -1 ? GetType() : theEntityType ]->rowCount();
1109 //=======================================================================
1110 // name : SMESHGUI_FilterTable::Clear
1111 // Purpose : Clear current table
1112 //=======================================================================
1113 void SMESHGUI_FilterTable::Clear (const int theType)
1115 int aType = theType == -1 ? GetType() : theType;
1116 Table* aTable = myTables[ aType ];
1118 if (aTable->rowCount() == 0)
1121 while (aTable->rowCount() > 0)
1123 removeAdditionalWidget(aTable, 0);
1124 aTable->removeRow(0);
1130 //=======================================================================
1131 // name : SMESHGUI_FilterTable::onAddBtn
1132 // Purpose : SLOT. Called then "Add" button pressed.
1133 // Adds new string to table
1134 //=======================================================================
1135 void SMESHGUI_FilterTable::onAddBtn()
1137 int aType = GetType();
1138 addRow(myTables[ aType ], aType);
1143 //=======================================================================
1144 // name : SMESHGUI_FilterTable::onInsertBtn
1145 // Purpose : SLOT. Called then "Insert" button pressed.
1146 // Inserts new string before current one
1147 //=======================================================================
1148 void SMESHGUI_FilterTable::onInsertBtn()
1150 addRow(myTables[ GetType() ], GetType(), false);
1153 //=======================================================================
1154 // name : SMESHGUI_FilterTable::onRemoveBtn
1155 // Purpose : SLOT. Called then "Remove" button pressed.
1156 // Removes current string from table
1157 //=======================================================================
1158 void SMESHGUI_FilterTable::onRemoveBtn()
1160 Table* aTable = myTables[ GetType() ];
1162 if (aTable->rowCount() == 0)
1165 QList<QTableWidgetItem*> items = aTable->selectedItems();
1167 QList<int> aRows = aTable->selectedRows(); // already sorted
1171 removeAdditionalWidget(aTable, i);
1172 aTable->removeRow(i);
1175 // remove control of binary logical operation from last row
1176 if (aTable->rowCount() > 0)
1177 aTable->setEditable(false, aTable->rowCount() - 1, 4);
1182 //=======================================================================
1183 // name : SMESHGUI_FilterTable::updateAdditionalWidget
1184 // Purpose : Enable/Disable widget with additonal parameters
1185 //=======================================================================
1186 void SMESHGUI_FilterTable::updateAdditionalWidget()
1188 Table* aTable = myTables[ GetType() ];
1189 int aRow = aTable->currentRow();
1190 if (aRow < 0 || aRow >= aTable->rowCount())
1192 myWgStack->setEnabled(false);
1196 ComboItem* anItem = ((ComboItem*)aTable->item(aRow, 0));
1197 bool toEnable = ((ComboItem*)aTable->item(aRow, 1))->value() == SMESH::FT_EqualTo &&
1198 GetCriterionType(aRow) != SMESH::FT_BelongToGeom &&
1199 GetCriterionType(aRow) != SMESH::FT_LyingOnGeom &&
1200 GetCriterionType(aRow) != SMESH::FT_RangeOfIds &&
1201 GetCriterionType(aRow) != SMESH::FT_FreeEdges &&
1202 GetCriterionType(aRow) != SMESH::FT_BadOrientedVolume;
1203 if (!myAddWidgets.contains(anItem))
1205 myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack);
1206 myWgStack->addWidget(myAddWidgets[ anItem ]);
1209 myWgStack->setCurrentWidget(myAddWidgets[ anItem ]);
1210 myWgStack->setEnabled(toEnable);
1213 //=======================================================================
1214 // name : SMESHGUI_FilterTable::removeAdditionalWidget
1215 // Purpose : Remove widgets containing additional parameters from widget
1216 // stack and internal map
1217 //=======================================================================
1218 void SMESHGUI_FilterTable::removeAdditionalWidget (QTableWidget* theTable, const int theRow)
1220 QTableWidgetItem* anItem = theTable->item(theRow, 0);
1221 if (myAddWidgets.contains(anItem))
1223 myWgStack->removeWidget(myAddWidgets[ anItem ]);
1224 myAddWidgets[ anItem ]->setParent(0);
1225 delete myAddWidgets[ anItem ];
1226 myAddWidgets.remove(anItem);
1230 //=======================================================================
1231 // name : SMESHGUI_FilterTable::onClearBtn
1232 // Purpose : SLOT. Called then "Clear" button pressed.
1233 // Removes all strings from table
1234 //=======================================================================
1235 void SMESHGUI_FilterTable::onClearBtn()
1237 Table* aTable = myTables[ GetType() ];
1239 if (aTable->rowCount() == 0)
1242 while (aTable->rowCount() > 0)
1244 removeAdditionalWidget(aTable, 0);
1245 aTable->removeRow(0);
1251 //=======================================================================
1252 // name : SMESHGUI_FilterTable::onCurrentChanged()
1253 // Purpose : SLOT. Called when current cell changed
1254 //=======================================================================
1255 void SMESHGUI_FilterTable::onCurrentChanged (int theRow, int theCol)
1258 updateAdditionalWidget();
1259 emit CurrentChanged(theRow, theCol);
1262 //=======================================================================
1263 // name : SMESHGUI_FilterTable::onCriterionChanged()
1264 // Purpose : Provides reaction on change of criterion
1265 //=======================================================================
1266 void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, const int entityType)
1268 int aType = entityType == -1 ? GetType() : entityType;
1269 Table* aTable = myTables[ aType ];
1270 ComboItem* aCompareItem = (ComboItem*)aTable->item(row, 1);
1272 int aCriterionType = GetCriterionType(row);
1274 if (aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders ||
1275 aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges ||
1276 aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume)
1278 if (aCompareItem->count() > 0)
1279 aCompareItem->clear();
1280 aTable->setEditable(false, row, 2);
1282 else if (aCriterionType == SMESH::FT_RangeOfIds ||
1283 aCriterionType == SMESH::FT_BelongToGeom ||
1284 aCriterionType == SMESH::FT_BelongToPlane ||
1285 aCriterionType == SMESH::FT_BelongToCylinder ||
1286 aCriterionType == SMESH::FT_BelongToGenSurface ||
1287 aCriterionType == SMESH::FT_LyingOnGeom)
1289 QMap<int, QString> aMap;
1290 aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO");
1291 aCompareItem->setItems(aMap);
1292 if (!aTable->isEditable(row, 2))
1293 aTable->setEditable(true, row, 2);
1297 if (aCompareItem->count() != 3)
1299 aCompareItem->setItems(getCompare());
1302 QString aText = aTable->text(row, 2);
1304 aText.toDouble(&isOk);
1305 aTable->item( row, 2 )->setText(isOk ? aText : QString(""));
1306 if (!aTable->isEditable(row, 2))
1307 aTable->setEditable(true, row, 2);
1310 updateAdditionalWidget();
1312 emit CriterionChanged(row, entityType);
1315 //=======================================================================
1316 // name : SMESHGUI_FilterTable::onCriterionChanged()
1317 // Purpose : SLOT. Called then contents of table changed
1318 // Provides reaction on change of criterion
1319 //=======================================================================
1320 void SMESHGUI_FilterTable::onCriterionChanged (int row, int col)
1322 onCriterionChanged(row, col, -1);
1325 //=======================================================================
1326 // name : SMESHGUI_FilterTable::getFirstSelectedRow
1327 // Purpose : Get first selected row
1328 //=======================================================================
1329 int SMESHGUI_FilterTable::getFirstSelectedRow() const
1331 Table* aTable = myTables[ GetType() ];
1333 QList<int> selRows = aTable->selectedRows(); // already sorted
1334 int aRow = selRows.count() > 0 ? selRows[0] : aTable->currentRow();
1336 return aRow >= 0 && aRow < aTable->rowCount() ? aRow : -1;
1339 //=======================================================================
1340 // name : SMESHGUI_FilterTable::addRow
1341 // Purpose : Add row at the end of table
1342 //=======================================================================
1343 void SMESHGUI_FilterTable::addRow (Table* theTable, const int theType, const bool toTheEnd)
1346 int aSelectedRow = getFirstSelectedRow();
1347 int aCurrCol = theTable->currentColumn();
1350 if (toTheEnd || aSelectedRow == -1)
1352 theTable->insertRows(theTable->rowCount());
1353 aCurrRow = theTable->rowCount() - 1;
1357 theTable->insertRows(aSelectedRow);
1358 aCurrRow = aSelectedRow;
1363 theTable->setItem(aCurrRow, 0, getCriterionItem(theType));
1366 theTable->setItem(aCurrRow, 1, getCompareItem());
1369 //theTable->setItem(aCurrRow, 2, new QTableWidgetItem());
1371 //Logical operation NOT
1372 theTable->setItem(aCurrRow, 3, getUnaryItem());
1374 // Logical binary operation for previous value
1375 int anAddBinOpStr = -1;
1376 if (aCurrRow == theTable->rowCount() - 1)
1377 anAddBinOpStr = aCurrRow - 1;
1378 else if (aCurrRow >= 0 )
1379 anAddBinOpStr = aCurrRow;
1381 if (theTable->item(aCurrRow, 4) == 0 ||
1382 theTable->item(aCurrRow, 4)->type() != ComboItem::Type())
1386 if (anAddBinOpStr >= 0 &&
1387 (theTable->item(anAddBinOpStr, 4) == 0 ||
1388 theTable->item(anAddBinOpStr, 4)->type() != ComboItem::Type()))
1389 theTable->setItem(anAddBinOpStr, 4, getBinaryItem());
1392 theTable->setEditable(false, theTable->rowCount() - 1, 4);
1394 if (aCurrRow >=0 && aCurrRow < theTable->rowCount() &&
1395 aCurrCol >=0 && aCurrCol < theTable->rowCount())
1396 theTable->setCurrentCell(aCurrRow, aCurrCol);
1398 onCriterionChanged(aCurrRow, 0);
1403 //=======================================================================
1404 // name : SMESHGUI_FilterTable::getCriterionItem
1405 // Purpose : Get combo table item for criteria of specified type
1406 //=======================================================================
1407 QTableWidgetItem* SMESHGUI_FilterTable::getCriterionItem (const int theType) const
1409 return new ComboItem(getCriteria(theType));
1412 //=======================================================================
1413 // name : SMESHGUI_FilterTable::getCompareItem
1414 // Purpose : Get combo table item for operation of comparision
1415 //=======================================================================
1416 QTableWidgetItem* SMESHGUI_FilterTable::getCompareItem () const
1418 return new ComboItem(getCompare());
1421 //=======================================================================
1422 // name : SMESHGUI_FilterTable::getBinaryItem
1424 //=======================================================================
1425 QTableWidgetItem* SMESHGUI_FilterTable::getBinaryItem () const
1427 static QMap<int, QString> aMap;
1430 aMap[ SMESH::FT_LogicalAND ] = tr("AND");
1431 aMap[ SMESH::FT_LogicalOR ] = tr("OR");
1434 return new ComboItem(aMap);
1437 //=======================================================================
1438 // name : SMESHGUI_FilterTable::getUnaryItem
1439 // Purpose : Get check table item
1440 //=======================================================================
1441 QTableWidgetItem* SMESHGUI_FilterTable::getUnaryItem () const
1443 return new CheckItem(tr("NOT"));
1446 //=======================================================================
1447 // name : SMESHGUI_FilterTable::getSupportedTypes
1448 // Purpose : Get all supported type
1449 //=======================================================================
1450 const QMap<int, QString>& SMESHGUI_FilterTable::getSupportedTypes() const
1452 static QMap<int, QString> aTypes;
1453 if (aTypes.isEmpty())
1455 aTypes[ SMESH::NODE ] = tr("NODES");
1456 aTypes[ SMESH::EDGE ] = tr("EDGES");
1457 aTypes[ SMESH::FACE ] = tr("FACES");
1458 aTypes[ SMESH::VOLUME ] = tr("VOLUMES");
1464 //=======================================================================
1465 // name : SMESHGUI_FilterTable::getCriteria
1466 // Purpose : Get criteria for specified type
1467 //=======================================================================
1468 const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria (const int theType) const
1470 if (theType == SMESH::NODE)
1472 static QMap<int, QString> aCriteria;
1473 if (aCriteria.isEmpty())
1475 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
1476 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
1477 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
1478 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
1479 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
1480 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
1484 else if (theType == SMESH::EDGE)
1486 static QMap<int, QString> aCriteria;
1487 if (aCriteria.isEmpty())
1489 aCriteria[ SMESH::FT_FreeBorders ] = tr("FREE_BORDERS");
1490 aCriteria[ SMESH::FT_MultiConnection ] = tr("MULTI_BORDERS");
1491 aCriteria[ SMESH::FT_Length ] = tr("LENGTH");
1492 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
1493 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
1494 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
1495 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
1496 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
1497 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
1501 else if (theType == SMESH::FACE)
1503 static QMap<int, QString> aCriteria;
1504 if (aCriteria.isEmpty())
1506 aCriteria[ SMESH::FT_AspectRatio ] = tr("ASPECT_RATIO");
1507 aCriteria[ SMESH::FT_Warping ] = tr("WARPING");
1508 aCriteria[ SMESH::FT_MinimumAngle ] = tr("MINIMUM_ANGLE");
1509 aCriteria[ SMESH::FT_Taper ] = tr("TAPER");
1510 aCriteria[ SMESH::FT_Skew ] = tr("SKEW");
1511 aCriteria[ SMESH::FT_Area ] = tr("AREA");
1512 aCriteria[ SMESH::FT_FreeEdges ] = tr("FREE_EDGES");
1513 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
1514 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
1515 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
1516 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
1517 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
1518 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
1519 aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D");
1520 aCriteria[ SMESH::FT_MultiConnection2D ] = tr("MULTI2D_BORDERS");
1524 else if (theType == SMESH::VOLUME)
1526 static QMap<int, QString> aCriteria;
1527 if (aCriteria.isEmpty())
1529 aCriteria[ SMESH::FT_AspectRatio3D ] = tr("ASPECT_RATIO_3D");
1530 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
1531 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
1532 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
1533 aCriteria[ SMESH::FT_BadOrientedVolume ] = tr("BAD_ORIENTED_VOLUME");
1534 aCriteria[ SMESH::FT_Volume3D ] = tr("VOLUME_3D");
1540 static QMap<int, QString> aCriteria;
1546 //=======================================================================
1547 // name : SMESHGUI_FilterTable::getCompare
1548 // Purpose : Get operation of comparison
1549 //=======================================================================
1550 const QMap<int, QString>& SMESHGUI_FilterTable::getCompare() const
1552 static QMap<int, QString> aMap;
1556 aMap[ SMESH::FT_LessThan ] = tr("LESS_THAN");
1557 aMap[ SMESH::FT_MoreThan ] = tr("MORE_THAN");
1558 aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO" );
1564 //=======================================================================
1565 // name : SMESHGUI_FilterTable::createTable
1566 // Purpose : Create table
1567 //=======================================================================
1568 SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable (QWidget* theParent,
1572 Table* aTable= new Table(0, 6, theParent);
1574 QHeaderView* aHeaders = aTable->horizontalHeader();
1576 QFontMetrics aMetrics(aHeaders->font());
1578 // append spaces to the header of criteria in order to
1579 // provide visibility of criterion inside comboboxes
1580 static int aMaxLenCr = 0;
1584 const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
1585 QMap<int, QString>::const_iterator anIter;
1586 for (anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter)
1587 aMaxLenCr = qMax(maxLength(getCriteria(anIter.key()), aMetrics), aMaxLenCr);
1590 static int aLenCr = qAbs( aMaxLenCr -
1591 aMetrics.width(tr("CRITERION"))) / aMetrics.width(' ') + 5;
1594 aCrStr.fill(' ', aLenCr);
1596 aCoStr.fill(' ', 10);
1598 QStringList aHeaderLabels;
1599 aHeaderLabels.append( tr("CRITERION") + aCrStr );
1600 aHeaderLabels.append( tr("COMPARE") + aCoStr );
1601 aHeaderLabels.append( tr("THRESHOLD_VALUE") );
1602 aHeaderLabels.append( tr("UNARY") );
1603 aHeaderLabels.append( tr("BINARY") + " " );
1604 aHeaderLabels.append( tr("ID") );
1605 aTable->setHorizontalHeaderLabels( aHeaderLabels );
1607 // set geometry of the table
1608 for (int i = 0; i <= 4; i++)
1609 aTable->resizeColumnToContents(i);
1611 // set the ID column invisible
1612 aTable->hideColumn( 5 );
1614 aTable->updateGeometry();
1615 QSize aSize = aTable->sizeHint();
1616 int aWidth = aSize.width();
1617 aTable->setMinimumSize(QSize(aWidth, aWidth / 2));
1618 aTable->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
1620 connect(aTable, SIGNAL(cellChanged(int, int)),
1621 this, SLOT(onCriterionChanged(int, int)));
1623 connect(aTable, SIGNAL(currentCellChanged(int, int, int, int)),
1624 this, SLOT(onCurrentChanged(int, int)));
1629 //=======================================================================
1630 // name : SMESHGUI_FilterTable::updateBtnState
1631 // Purpose : Update button state
1632 //=======================================================================
1633 void SMESHGUI_FilterTable::updateBtnState()
1635 myRemoveBtn->setEnabled(myTables[ GetType() ]->rowCount() > 0);
1636 myClearBtn->setEnabled(myTables[ GetType() ]->rowCount() > 0);
1639 //=======================================================================
1640 // name : SMESHGUI_FilterTable::SetEditable
1641 // Purpose : Set read only flag for tables. Show/hide buttons for work with rows
1642 //=======================================================================
1643 void SMESHGUI_FilterTable::SetEditable (const bool isEditable)
1645 TableMap::iterator anIter;
1646 for (anIter = myTables.begin(); anIter != myTables.end(); ++anIter)
1648 anIter.value()->setReadOnly(!isEditable);
1653 myInsertBtn->show();
1654 myRemoveBtn->show();
1660 myInsertBtn->hide();
1661 myRemoveBtn->hide();
1666 QMap<QTableWidgetItem*, AdditionalWidget*>::iterator anIter2;
1667 for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2)
1668 anIter2.value()->SetEditable(isEditable);
1671 //=======================================================================
1672 // name : SMESHGUI_FilterTable::SetEnabled
1673 // Purpose : Enable/Disable table. Switching type of elements already enabled
1674 //=======================================================================
1675 void SMESHGUI_FilterTable::SetEnabled (const bool isEnabled)
1677 myAddBtn->setEnabled(isEnabled);
1678 myInsertBtn->setEnabled(isEnabled);
1679 myRemoveBtn->setEnabled(isEnabled);
1680 myClearBtn->setEnabled(isEnabled);
1685 QMap<QTableWidgetItem*, AdditionalWidget*>::iterator anIter2;
1686 for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2)
1687 anIter2.value()->setEnabled(isEnabled);
1690 //=======================================================================
1691 // name : SMESHGUI_FilterTable::IsEditable
1692 // Purpose : Verify whether table is editable
1693 //=======================================================================
1694 bool SMESHGUI_FilterTable::IsEditable() const
1696 return !myTables[ GetType() ]->isReadOnly();
1699 //=======================================================================
1700 // name : SMESHGUI_FilterTable::SetLibsEnabled
1701 // Purpose : Show/hide buttons for work with libraries
1702 //=======================================================================
1703 void SMESHGUI_FilterTable::SetLibsEnabled (const bool isEnabled)
1707 myCopyFromBtn->show();
1712 myCopyFromBtn->hide();
1717 //=======================================================================
1718 // name : SMESHGUI_FilterTable::onCopyFromBtn
1719 // Purpose : SLOT. Called the "Copy from ..." button clicked
1720 // Display filter library dialog
1721 //=======================================================================
1722 void SMESHGUI_FilterTable::onCopyFromBtn()
1725 myLibDlg = new SMESHGUI_FilterLibraryDlg(
1726 mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
1728 myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
1730 if (myLibDlg->exec() == QDialog::Accepted)
1732 Copy(myLibDlg->GetTable());
1737 //=======================================================================
1738 // name : SMESHGUI_FilterTable::onAddToBtn
1739 // Purpose : SLOT. Called the "Add to ..." button clicked
1740 // Display filter library dialog
1741 //=======================================================================
1742 void SMESHGUI_FilterTable::onAddToBtn()
1747 myLibDlg = new SMESHGUI_FilterLibraryDlg(
1748 mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
1750 myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
1752 myLibDlg->SetTable(this);
1757 //=======================================================================
1758 // name : SMESHGUI_FilterTable::Copy
1759 // Purpose : Initialise table with values of other table
1760 //=======================================================================
1761 void SMESHGUI_FilterTable::Copy (const SMESHGUI_FilterTable* theTable)
1765 for (int i = 0, n = theTable->NumRows(); i < n; i++)
1767 SMESH::Filter::Criterion aCriterion = SMESHGUI_FilterDlg::createCriterion();
1768 theTable->GetCriterion(i, aCriterion);
1769 AddCriterion(aCriterion);
1773 //=======================================================================
1774 // name : SMESHGUI_FilterTable::CurrentCell
1775 // Purpose : Returns current cell
1776 //=======================================================================
1777 bool SMESHGUI_FilterTable::CurrentCell (int& theRow, int& theCol) const
1779 theRow = myTables[ GetType() ]->currentRow();
1780 theCol = myTables[ GetType() ]->currentColumn();
1781 return theRow >= 0 && theCol >= 0;
1784 //=======================================================================
1785 // name : SMESHGUI_FilterTable::SetText
1786 // Purpose : Set text and internal value in cell of threshold value
1787 //=======================================================================
1788 void SMESHGUI_FilterTable::SetThreshold (const int theRow,
1789 const QString& theText,
1790 const int theEntityType)
1792 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
1793 aTable->item( theRow, 2 )->setText(theText);
1796 //=======================================================================
1797 // name : SMESHGUI_FilterTable::SetText
1798 // Purpose : Get text and internal value from cell of threshold value
1799 //=======================================================================
1800 bool SMESHGUI_FilterTable::GetThreshold (const int theRow,
1802 const int theEntityType)
1804 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
1805 QTableWidgetItem* anItem = aTable->item(theRow, 2);
1808 theText = anItem->text();
1815 //=======================================================================
1816 // name : SMESHGUI_FilterTable::SetID
1817 // Purpose : Set text and internal value in cell of ID value
1818 //=======================================================================
1819 void SMESHGUI_FilterTable::SetID( const int theRow,
1820 const QString& theText,
1821 const int theEntityType )
1823 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
1824 aTable->item( theRow, 5 )->setText( theText );
1827 //=======================================================================
1828 // name : SMESHGUI_FilterTable::GetID
1829 // Purpose : Get text and internal value from cell of ID value
1830 //=======================================================================
1831 bool SMESHGUI_FilterTable::GetID( const int theRow,
1833 const int theEntityType )
1835 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
1836 QTableWidgetItem* anItem = aTable->item( theRow, 5 );
1839 theText = anItem->text();
1847 Class : SMESHGUI_FilterDlg
1848 Description : Dialog to specify filters for VTK viewer
1852 //=======================================================================
1853 // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
1854 // Purpose : Constructor
1855 //=======================================================================
1856 SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
1857 const QList<int>& theTypes )
1858 : QDialog( SMESH::GetDesktop( theModule ) ),
1859 mySMESHGUI( theModule ),
1860 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
1862 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1863 mySelector = aViewWindow->GetSelector();
1865 construct(theTypes);
1868 //=======================================================================
1869 // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
1870 // Purpose : Constructor
1871 //=======================================================================
1872 SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
1874 : QDialog( SMESH::GetDesktop( theModule ) ),
1875 mySMESHGUI( theModule ),
1876 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
1878 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1879 mySelector = aViewWindow->GetSelector();
1881 aTypes.append(theType);
1885 //=======================================================================
1886 // name : SMESHGUI_FilterDlg::construct
1887 // Purpose : Construct dialog (called by constructor)
1888 //=======================================================================
1889 void SMESHGUI_FilterDlg::construct (const QList<int>& theTypes)
1894 //setAttribute(Qt::WA_DeleteOnClose, true); // VSR ??? is it required?
1895 setWindowTitle(tr("CAPTION"));
1897 QVBoxLayout* aDlgLay = new QVBoxLayout (this);
1898 aDlgLay->setMargin(MARGIN);
1899 aDlgLay->setSpacing(SPACING);
1901 myMainFrame = createMainFrame (this);
1902 QWidget* aBtnFrame = createButtonFrame(this);
1904 aDlgLay->addWidget(myMainFrame);
1905 aDlgLay->addWidget(aBtnFrame);
1907 aDlgLay->setStretchFactor(myMainFrame, 1);
1909 myHelpFileName = "selection_filter_library_page.html";
1914 //=======================================================================
1915 // name : SMESHGUI_FilterDlg::createMainFrame
1916 // Purpose : Create frame containing dialog's input fields
1917 //=======================================================================
1918 QWidget* SMESHGUI_FilterDlg::createMainFrame (QWidget* theParent)
1920 QWidget* aMainFrame = new QWidget(theParent);
1921 QVBoxLayout* aMainLay = new QVBoxLayout(aMainFrame);
1922 aMainLay->setMargin(0);
1923 aMainLay->setSpacing(SPACING);
1927 myTable = new SMESHGUI_FilterTable( mySMESHGUI, aMainFrame, myTypes );
1928 myTable->SetLibsEnabled(true);
1930 QGroupBox* aGrp = myTable->GetTableGrp();
1931 QGridLayout* aLay = qobject_cast<QGridLayout*>( aGrp->layout() );
1932 int rows = aLay->rowCount();
1933 int cols = aLay->columnCount();
1935 QFrame* aLine = new QFrame(aGrp);
1936 aLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);
1937 aLay->addWidget(aLine, rows++, 0, 1, cols);
1939 mySetInViewer = new QCheckBox(tr("SET_IN_VIEWER"), aGrp);
1940 mySetInViewer->setChecked(true);
1941 aLay->addWidget(mySetInViewer, rows++, 0, 1, cols);
1944 QWidget* aSourceGrp = createSourceGroup(aMainFrame);
1946 connect(myTable, SIGNAL(CriterionChanged(const int, const int)),
1947 SLOT(onCriterionChanged(const int, const int)));
1949 connect(myTable, SIGNAL(CurrentChanged(int, int)),
1950 SLOT(onCurrentChanged(int, int)));
1952 aMainLay->addWidget(myTable);
1953 aMainLay->addWidget(aSourceGrp);
1958 //=======================================================================
1959 // name : SMESHGUI_FilterDlg::createSourceFrame
1960 // Purpose : Create frame containing source radio button
1961 //=======================================================================
1962 QWidget* SMESHGUI_FilterDlg::createSourceGroup (QWidget* theParent)
1964 QGroupBox* aBox = new QGroupBox(tr("SOURCE"), theParent);
1965 QHBoxLayout* aLay = new QHBoxLayout(aBox);
1966 aLay->setMargin(MARGIN);
1967 aLay->setSpacing(SPACING);
1969 mySourceGrp = new QButtonGroup(theParent);
1971 QRadioButton* aMeshBtn = new QRadioButton(tr("MESH"), aBox);
1972 QRadioButton* aSelBtn = new QRadioButton(tr("SELECTION"), aBox);
1973 QRadioButton* aGrpBtn = new QRadioButton(tr("CURRENT_GROUP"), aBox);
1975 aLay->addWidget(aMeshBtn);
1976 aLay->addWidget(aSelBtn);
1977 aLay->addWidget(aGrpBtn);
1979 mySourceGrp->addButton(aMeshBtn, Mesh);
1980 mySourceGrp->addButton(aSelBtn, Selection);
1981 mySourceGrp->addButton(aGrpBtn, Dialog);
1983 aSelBtn->setChecked(true);
1988 //=======================================================================
1989 // name : SMESHGUI_FilterDlg::updateMainButtons
1990 // Purpose : Update visibility of main buttons (OK, Cancel, Close ...)
1991 //=======================================================================
1992 void SMESHGUI_FilterDlg::updateMainButtons()
1994 if (myTypes.count() == 1)
1996 myButtons[ BTN_Cancel ]->show();
1997 myButtons[ BTN_Apply ]->hide();
1998 myButtons[ BTN_Close ]->hide();
2002 myButtons[ BTN_Cancel ]->hide();
2003 myButtons[ BTN_Apply ]->show();
2004 myButtons[ BTN_Close ]->show();
2007 // updateGeometry();
2010 //=======================================================================
2011 // name : SMESHGUI_FilterDlg::createButtonFrame
2012 // Purpose : Create frame containing buttons
2013 //=======================================================================
2014 QWidget* SMESHGUI_FilterDlg::createButtonFrame (QWidget* theParent)
2016 QGroupBox* aGrp = new QGroupBox(theParent);
2017 QHBoxLayout* aLay = new QHBoxLayout(aGrp);
2018 aLay->setMargin(MARGIN);
2019 aLay->setSpacing(SPACING);
2021 myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_OK" ), aGrp);
2022 myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp);
2023 myButtons[ BTN_Cancel ] = new QPushButton(tr("SMESH_BUT_CANCEL"), aGrp);
2024 myButtons[ BTN_Close ] = new QPushButton(tr("SMESH_BUT_CLOSE"), aGrp);
2025 myButtons[ BTN_Help ] = new QPushButton(tr("SMESH_BUT_HELP"), aGrp);
2027 aLay->addWidget(myButtons[ BTN_OK ]);
2028 aLay->addSpacing(10);
2029 aLay->addWidget(myButtons[ BTN_Apply ]);
2030 aLay->addSpacing(10);
2032 aLay->addWidget(myButtons[ BTN_Cancel ]);
2033 aLay->addWidget(myButtons[ BTN_Close ]);
2034 aLay->addWidget(myButtons[ BTN_Help ]);
2036 connect(myButtons[ BTN_OK ], SIGNAL(clicked()), SLOT(onOk()));
2037 connect(myButtons[ BTN_Cancel ], SIGNAL(clicked()), SLOT(onClose()));
2038 connect(myButtons[ BTN_Close ], SIGNAL(clicked()), SLOT(onClose()));
2039 connect(myButtons[ BTN_Apply ], SIGNAL(clicked()), SLOT(onApply()));
2040 connect(myButtons[ BTN_Help ], SIGNAL(clicked()), SLOT(onHelp()));
2042 updateMainButtons();
2047 //=======================================================================
2048 // name : SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg
2049 // Purpose : Destructor
2050 //=======================================================================
2051 SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg()
2055 //=======================================================================
2056 // name : SMESHGUI_FilterDlg::Init
2057 // Purpose : Init dialog fields, connect signals and slots, show dialog
2058 //=======================================================================
2059 void SMESHGUI_FilterDlg::Init (const int type)
2062 aTypes.append(type);
2066 //=======================================================================
2067 // name : SMESHGUI_FilterDlg::Init
2068 // Purpose : Init dialog fields, connect signals and slots, show dialog
2069 //=======================================================================
2070 void SMESHGUI_FilterDlg::Init (const QList<int>& theTypes)
2074 myMesh = SMESH::SMESH_Mesh::_nil();
2076 myIsSelectionChanged = false;
2078 myTable->Init(theTypes);
2081 if (theTypes.count() == 1)
2083 int aType = theTypes.first();
2084 if (aType == SMESH::NODE ) setWindowTitle(tr("NODES_TLT"));
2085 else if (aType == SMESH::EDGE ) setWindowTitle(tr("EDGES_TLT"));
2086 else if (aType == SMESH::FACE ) setWindowTitle(tr("FACES_TLT"));
2087 else if (aType == SMESH::VOLUME) setWindowTitle(tr("VOLUMES_TLT"));
2090 setWindowTitle(tr("TLT"));
2092 qApp->processEvents();
2097 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
2099 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
2100 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
2102 updateMainButtons();
2105 // Initialise filter table with values of previous filter
2106 QList<int>::const_iterator anIter;
2107 for (anIter = theTypes.begin(); anIter != theTypes.end(); ++anIter)
2109 myTable->Clear(*anIter);
2110 if (!myFilter[ *anIter ]->_is_nil())
2112 SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
2113 if (myFilter[ *anIter ]->GetCriteria(aCriteria))
2115 for (int i = 0, n = aCriteria->length(); i < n; i++)
2116 myTable->AddCriterion(aCriteria[ i ], *anIter);
2121 if (myInsertState.contains(theTypes.first()))
2122 mySetInViewer->setChecked(myInsertState[ theTypes.first() ]);
2124 mySetInViewer->setChecked(true);
2126 mySourceGrp->button(myApplyToState.contains(theTypes.first()) ?
2127 myApplyToState[ theTypes.first() ] :
2128 Selection)->setChecked(true);
2131 //=======================================================================
2132 // name : SMESHGUI_FilterDlg::onOk
2133 // Purpose : SLOT called when "Ok" button pressed.
2134 // Assign filters VTK viewer and close dialog
2135 //=======================================================================
2136 void SMESHGUI_FilterDlg::onOk()
2140 mySelectionMgr->clearFilters();
2141 disconnect(mySMESHGUI, 0, this, 0);
2142 disconnect(mySelectionMgr, 0, this, 0);
2143 mySMESHGUI->ResetState();
2149 //=======================================================================
2150 // name : SMESHGUI_FilterDlg::onClose
2151 // Purpose : SLOT called when "Close" button pressed. Close dialog
2152 //=======================================================================
2153 void SMESHGUI_FilterDlg::onClose()
2155 // Restore previously selected object
2158 SALOME_ListIO aList;
2159 mySelectionMgr->clearFilters();
2160 mySelectionMgr->clearSelected();
2161 SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter (myIObjects);
2162 for ( ; anIter.More(); anIter.Next())
2164 aList.Append(anIter.Key());
2166 TColStd_MapOfInteger aResMap;
2167 const TColStd_IndexedMapOfInteger& anIndMap = anIter.Value();
2168 for (int i = 1, n = anIndMap.Extent(); i <= n; i++)
2169 aResMap.Add(anIndMap(i));
2171 mySelector->AddOrRemoveIndex( anIter.Key(), aResMap, false);
2172 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
2173 aViewWindow->highlight( anIter.Key(), true, true );
2175 mySelectionMgr->setSelectedObjects(aList, false);
2178 disconnect(mySMESHGUI, 0, this, 0);
2179 disconnect(mySelectionMgr, 0, this, 0);
2180 mySMESHGUI->ResetState();
2185 //=================================================================================
2186 // function : onHelp()
2188 //=================================================================================
2189 void SMESHGUI_FilterDlg::onHelp()
2191 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
2193 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
2197 platform = "winapplication";
2199 platform = "application";
2201 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
2202 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
2203 arg(app->resourceMgr()->stringValue("ExternalBrowser",
2205 arg(myHelpFileName));
2209 //=======================================================================
2210 // name : SMESHGUI_FilterDlg::onDeactivate
2211 // Purpose : SLOT called when dialog must be deativated
2212 //=======================================================================
2213 void SMESHGUI_FilterDlg::onDeactivate()
2218 //=======================================================================
2219 // name : SMESHGUI_FilterDlg::enterEvent
2220 // Purpose : Event filter
2221 //=======================================================================
2222 void SMESHGUI_FilterDlg::enterEvent (QEvent*)
2224 // mySMESHGUI->EmitSignalDeactivateDialog();
2225 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
2226 mySMESHGUI->ResetState();
2230 //=======================================================================
2231 // name : closeEvent()
2233 //=======================================================================
2234 void SMESHGUI_FilterDlg::closeEvent (QCloseEvent*)
2239 //=======================================================================
2240 // name : SMESHGUI_FilterDlg::getIdsFromWg
2241 // Purpose : Retrieve list of ids from given widget
2242 //=======================================================================
2243 void SMESHGUI_FilterDlg::getIdsFromWg (const QWidget* theWg, QList<int>& theRes) const
2249 if (theWg->inherits("QListWidget"))
2251 const QListWidget* aListBox = qobject_cast<const QListWidget*>( theWg );
2253 for (int i = 0, n = aListBox->count(); i < n; i++)
2255 int anId = aListBox->item(i)->text().toInt(&b);
2257 theRes.append(anId);
2260 else if (theWg->inherits("QLineEdit"))
2262 const QLineEdit* aLineEdit = qobject_cast<const QLineEdit*>( theWg );
2263 QString aStr = aLineEdit->text();
2264 QRegExp aRegExp("(\\d+)");
2269 aPos = aRegExp.indexIn(aStr, aPos);
2272 int anId = aRegExp.cap(1).toInt(&b);
2274 theRes.append(anId);
2275 aPos += aRegExp.matchedLength();
2281 //=======================================================================
2282 // name : SMESHGUI_FilterDlg::getSelMode
2283 // Purpose : Get selection mode of specified type
2284 //=======================================================================
2285 Selection_Mode SMESHGUI_FilterDlg::getSelMode (const int theType) const
2289 case SMESH::NODE : return NodeSelection;
2290 case SMESH::EDGE : return EdgeSelection;
2291 case SMESH::FACE : return FaceSelection;
2292 case SMESH::VOLUME : return VolumeSelection;
2293 default : return ActorSelection;
2298 //=======================================================================
2299 // name : SMESHGUI_FilterDlg::setIdsToWg
2300 // Purpose : Insert identifiers in specified widgets
2301 //=======================================================================
2302 void SMESHGUI_FilterDlg::setIdsToWg (QWidget* theWg, const QList<int>& theIds)
2307 if (theWg->inherits("QListWidget"))
2309 QListWidget* aListBox = qobject_cast<QListWidget*>( theWg );
2312 QStringList aStrList;
2313 QList<int>::const_iterator anIter;
2314 for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter)
2315 aStrList.append(QString("%1").arg(*anIter));
2317 aListBox->addItems(aStrList);
2319 else if (theWg->inherits("QLineEdit"))
2321 QLineEdit* aLineEdit = qobject_cast<QLineEdit*>( theWg );
2323 QList<int>::const_iterator anIter;
2325 for (anIter = theIds.begin(); anIter != theIds.end(); ++ anIter)
2326 aStr += QString("%1 ").arg(*anIter);
2328 if (!aStr.isEmpty())
2329 aStr.remove(aStr.length() - 1, 1);
2331 aLineEdit->setText(aStr);
2335 //=======================================================================
2336 // name : SMESHGUI_FilterDlg::isValid
2337 // Purpose : Verify validity of input data
2338 //=======================================================================
2339 bool SMESHGUI_FilterDlg::isValid() const
2341 if (!myTable->IsValid())
2344 for (int i = 0, n = myTable->NumRows(); i < n; i++)
2346 int aType = myTable->GetCriterionType(i);
2347 if (aType == SMESH::FT_BelongToGeom ||
2348 aType == SMESH::FT_BelongToPlane ||
2349 aType == SMESH::FT_BelongToCylinder ||
2350 aType == SMESH::FT_BelongToGenSurface ||
2351 aType == SMESH::FT_LyingOnGeom) {
2353 myTable->GetThreshold(i, aName);
2355 std::vector<_PTR(SObject)> aList =
2356 SMESH::GetActiveStudyDocument()->FindObjectByName(aName.toLatin1().data(), "GEOM");
2357 if (aList.size() == 0) {
2358 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2359 tr("BAD_SHAPE_NAME").arg(aName));
2363 if (aType == SMESH::FT_BelongToCylinder ||
2364 aType == SMESH::FT_BelongToPlane ||
2365 aType == SMESH::FT_BelongToGenSurface ) {
2366 CORBA::Object_var anObject = SMESH::SObjectToObject(aList[ 0 ]);
2367 //GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(aList[ 0 ]->GetObject());
2368 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObject);
2369 if (!aGeomObj->_is_nil()) {
2371 if (!GEOMBase::GetShape(aGeomObj, aFace) ||
2373 aFace.ShapeType() != TopAbs_FACE) {
2374 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2375 tr("SHAPE_IS_NOT_A_FACE").arg(aName));
2379 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace));
2380 if (aSurf.IsNull()) {
2381 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2382 tr("SHAPE_IS_NOT_A_FACE").arg(aName));
2386 if (aType == SMESH::FT_BelongToPlane && !aSurf->IsKind(STANDARD_TYPE(Geom_Plane))) {
2387 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2388 tr("SHAPE_IS_NOT_A_PLANE").arg(aName));
2392 if (aType == SMESH::FT_BelongToCylinder && !aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
2393 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2394 tr("SHAPE_IS_NOT_A_CYLINDER").arg(aName));
2405 //=======================================================================
2406 // name : SMESHGUI_FilterDlg::SetSourceWg
2407 // Purpose : Set widget of parent dialog containing idsto be filtered if
2408 // user select corresponding source radio button
2409 //=======================================================================
2410 void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg)
2415 //=======================================================================
2416 // name : SMESHGUI_FilterDlg::SetGroupIds
2417 // Purpose : Set mesh
2418 //=======================================================================
2419 void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_ptr theMesh)
2424 //=======================================================================
2425 // name : SMESHGUI_FilterDlg::SetSelection
2426 // Purpose : Get filtered ids
2427 //=======================================================================
2428 void SMESHGUI_FilterDlg::SetSelection()
2431 disconnect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone()));
2433 if (mySelectionMgr) {
2435 const SALOME_ListIO& anObjs = mySelector->StoredIObjects();
2436 SALOME_ListIteratorOfListIO anIter (anObjs);
2437 for ( ; anIter.More(); anIter.Next()) {
2438 TColStd_IndexedMapOfInteger aMap;
2439 mySelector->GetIndex(anIter.Value(), aMap);
2440 myIObjects.Bind(anIter.Value(), aMap);
2443 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
2451 //=======================================================================
2452 // name : SMESHGUI_FilterDlg::onApply
2453 // Purpose : SLOT called when "Apply" button pressed.
2454 // Assign filters to VTK viewer
2455 //=======================================================================
2456 bool SMESHGUI_FilterDlg::onApply()
2462 int aCurrType = myTable->GetType();
2464 if (!createFilter(aCurrType))
2467 insertFilterInViewer();
2469 if (!myFilter[ aCurrType ]->GetPredicate()->_is_nil()) {
2470 QList<int> aResultIds;
2471 filterSource(aCurrType, aResultIds);
2472 selectInViewer(aCurrType, aResultIds);
2475 myInsertState[ aCurrType ] = mySetInViewer->isChecked();
2476 myApplyToState[ aCurrType ] = mySourceGrp->checkedId();
2478 catch(const SALOME::SALOME_Exception& S_ex)
2480 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2489 //=======================================================================
2490 // name : SMESHGUI_FilterDlg::createFilter
2491 // Purpose : Create predicate for given type
2492 //=======================================================================
2493 bool SMESHGUI_FilterDlg::createFilter (const int theType)
2495 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
2496 if (aFilterMgr->_is_nil())
2499 int n = myTable->NumRows();
2501 SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
2502 aCriteria->length(n);
2504 long aPrecision = -1;
2505 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
2507 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
2508 aPrecision = mgr->integerValue( "SMESH", "controls_precision", aPrecision );
2510 for (CORBA::ULong i = 0; i < n; i++) {
2511 SMESH::Filter::Criterion aCriterion = createCriterion();
2512 myTable->GetCriterion(i, aCriterion);
2513 aCriterion.Precision = aPrecision;
2514 aCriteria[ i ] = aCriterion;
2517 myFilter[ theType ] = aFilterMgr->CreateFilter();
2518 myFilter[ theType ]->SetCriteria(aCriteria.inout());
2523 //=======================================================================
2524 // name : SMESHGUI_FilterDlg::insertFilterInViewer
2525 // Purpose : Insert filter in viewer
2526 //=======================================================================
2527 void SMESHGUI_FilterDlg::insertFilterInViewer()
2529 if (SVTK_Selector* aSelector = SMESH::GetSelector()) {
2530 SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType();
2532 if (myFilter[ myTable->GetType() ]->_is_nil() ||
2533 myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() ||
2534 !mySetInViewer->isChecked()) {
2535 SMESH::RemoveFilter(getFilterId(anEntType), aSelector);
2538 Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter();
2539 aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate());
2540 SMESH::RemoveFilter(getFilterId(anEntType), aSelector); //skl for IPAL12631
2541 SMESH::SetFilter(aFilter, aSelector);
2546 //=======================================================================
2547 // name : SMESHGUI_FilterDlg::filterSource
2548 // Purpose : Filter source ids
2549 //=======================================================================
2550 void SMESHGUI_FilterDlg::filterSource (const int theType,
2551 QList<int>& theResIds)
2554 if (myFilter[ theType ]->_is_nil())
2557 int aSourceId = mySourceGrp->checkedId();
2559 if (aSourceId == Mesh)
2561 if (myMesh->_is_nil())
2563 SMESH::long_array_var anIds = myFilter[ theType ]->GetElementsId(myMesh);
2564 for (int i = 0, n = anIds->length(); i < n; i++)
2565 theResIds.append(anIds[ i ]);
2567 else if (aSourceId == Selection)
2569 filterSelectionSource(theType, theResIds);
2571 else if (aSourceId == Dialog)
2573 // retrieve ids from dialog
2574 QList<int> aDialogIds;
2575 getIdsFromWg(mySourceWg, aDialogIds);
2577 if (myMesh->_is_nil())
2579 theResIds = aDialogIds;
2584 SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate();
2585 aPred->SetMesh(myMesh);
2586 QList<int>::const_iterator anIter;
2587 for (anIter = aDialogIds.begin(); anIter != aDialogIds.end(); ++ anIter)
2588 if (aPred->IsSatisfy(*anIter))
2589 theResIds.append(*anIter);
2591 // set ids to the dialog
2592 setIdsToWg(mySourceWg, theResIds);
2596 //=======================================================================
2597 // name : SMESHGUI_FilterDlg::filterSelectionSource
2598 // Purpose : Filter source selection
2599 //=======================================================================
2600 void SMESHGUI_FilterDlg::filterSelectionSource (const int theType,
2601 QList<int>& theResIds)
2604 if (myMesh->_is_nil() || mySelectionMgr == 0)
2607 // Create map of entities to be filtered
2608 TColStd_MapOfInteger aToBeFiltered;
2609 SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter(myIObjects);
2611 for ( ; anIter.More(); anIter.Next())
2614 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIter.Key());
2615 if (!aSubMesh->_is_nil())
2617 if (aSubMesh->GetFather()->GetId() == myMesh->GetId())
2619 SMESH::long_array_var anIds =
2620 theType == SMESH::NODE ? aSubMesh->GetNodesId() : aSubMesh->GetElementsId();
2621 for (int i = 0, n = anIds->length(); i < n; i++)
2622 aToBeFiltered.Add(anIds[ i ]);
2627 SMESH::SMESH_GroupBase_var aGroup =
2628 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Key());
2629 if (!aGroup->_is_nil())
2631 if (aGroup->GetType() == theType && aGroup->GetMesh()->GetId() == myMesh->GetId())
2633 SMESH::long_array_var anIds = aGroup->GetListOfID();
2634 for (int i = 0, n = anIds->length(); i < n; i++)
2635 aToBeFiltered.Add(anIds[ i ]);
2640 SMESH::SMESH_Mesh_var aMeshPtr = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIter.Key());
2641 if (!aMeshPtr->_is_nil() && aMeshPtr->GetId() == myMesh->GetId())
2643 const TColStd_IndexedMapOfInteger& aSelMap = anIter.Value();
2645 if (aSelMap.Extent() > 0)
2647 if(SMESH::FindActorByEntry(anIter.Key()->getEntry()))
2649 for (int i = 1; i <= aSelMap.Extent(); i++)
2650 aToBeFiltered.Add(aSelMap(i));
2657 SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate();
2658 aPred->SetMesh(myMesh);
2659 TColStd_MapIteratorOfMapOfInteger aResIter(aToBeFiltered);
2660 for ( ; aResIter.More(); aResIter.Next())
2661 if (aPred->IsSatisfy(aResIter.Key()))
2662 theResIds.append(aResIter.Key());
2665 //=======================================================================
2666 // name : SMESHGUI_FilterDlg::selectInViewer
2667 // Purpose : Select given entities in viewer
2668 //=======================================================================
2669 void SMESHGUI_FilterDlg::selectInViewer (const int theType, const QList<int>& theIds)
2671 if (mySelectionMgr == 0 || myMesh->_is_nil())
2674 mySelectionMgr->clearFilters();
2676 // Set new selection mode if necessary
2677 Selection_Mode aSelMode = getSelMode(theType);
2678 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
2679 if ( aViewWindow && aViewWindow->SelectionMode()!=aSelMode) {
2680 mySelectionMgr->clearSelected();
2681 mySelectionMgr->clearFilters();
2682 if (aSelMode == NodeSelection)
2683 SMESH::SetPointRepresentation(true);
2684 aViewWindow->SetSelectionMode(aSelMode);
2688 SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
2689 if (!anActor || !anActor->hasIO())
2692 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
2693 //mySelectionMgr->clearSelected();
2694 //mySelectionMgr->AddIObject(anIO, false);
2695 SALOME_ListIO aList;
2697 mySelectionMgr->setSelectedObjects(aList, false);
2699 // Remove filter corresponding to the current type from viewer
2700 int aType = myTable->GetType();
2701 int aFilterId = SMESH::UnknownFilter;
2702 if (aType == SMESH::EDGE ) aFilterId = SMESH::EdgeFilter;
2703 else if (aType == SMESH::FACE ) aFilterId = SMESH::FaceFilter;
2704 else if (aType == SMESH::VOLUME) aFilterId = SMESH::VolumeFilter;
2705 Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter(aFilterId);
2706 SMESH::RemoveFilter(aFilterId);
2709 TColStd_MapOfInteger aMap;
2710 QList<int>::const_iterator anIter;
2711 for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
2715 // Set new selection
2716 mySelector->AddOrRemoveIndex(anIO, aMap, false);
2717 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
2718 aViewWindow->highlight( anIO, true, true );
2720 // insert previously stored filter in viewer if necessary
2721 if (!aFilter.IsNull())
2722 SMESH::SetFilter(aFilter);
2725 //=======================================================================
2726 // name : SMESHGUI_FilterDlg::createCriterion
2727 // Purpose : Create criterion structure with default values
2728 //=======================================================================
2729 SMESH::Filter::Criterion SMESHGUI_FilterDlg::createCriterion()
2731 SMESH::Filter::Criterion aCriterion;
2733 aCriterion.Type = SMESH::FT_Undefined;
2734 aCriterion.Compare = SMESH::FT_Undefined;
2735 aCriterion.Threshold = 0;
2736 aCriterion.UnaryOp = SMESH::FT_Undefined;
2737 aCriterion.BinaryOp = SMESH::FT_Undefined;
2738 aCriterion.ThresholdStr = "";
2739 aCriterion.ThresholdID = "";
2740 aCriterion.TypeOfElement = SMESH::ALL;
2745 //=======================================================================
2746 // name : SMESHGUI_FilterDlg::onSelectionDone
2747 // Purpose : SLOT called when selection changed.
2748 // If current cell corresponds to the threshold value of
2749 // BelongToGeom criterion name of selected object is set in this cell
2750 //=======================================================================
2751 void SMESHGUI_FilterDlg::onSelectionDone()
2754 const SALOME_ListIO& aList = mySelector->StoredIObjects();
2756 if (aList.Extent() != 1 ||
2757 !myTable->CurrentCell(aRow, aCol) ||
2758 myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGeom &&
2759 myTable->GetCriterionType(aRow) != SMESH::FT_BelongToPlane &&
2760 myTable->GetCriterionType(aRow) != SMESH::FT_BelongToCylinder &&
2761 myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGenSurface &&
2762 myTable->GetCriterionType(aRow) != SMESH::FT_LyingOnGeom)
2765 Handle(SALOME_InteractiveObject) anIO = aList.First();
2766 GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
2767 if (!anObj->_is_nil())
2769 myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
2770 //myTable->SetID( aRow, GEOMBase::GetIORFromObject(anObj));
2771 myTable->SetID(aRow, anIO->getEntry());
2775 //=======================================================================
2776 // name : SMESHGUI_FilterDlg::onCriterionChanged
2777 // Purpose : SLOT called when cretarion of current row changed. Update selection
2778 //=======================================================================
2779 void SMESHGUI_FilterDlg::onCriterionChanged (const int, const int)
2784 //=======================================================================
2785 // name : SMESHGUI_FilterDlg::onCurrentChanged
2786 // Purpose : SLOT called when current row changed. Update selection
2787 //=======================================================================
2788 void SMESHGUI_FilterDlg::onCurrentChanged (int, int)
2793 //=======================================================================
2794 // name : SMESHGUI_FilterDlg::updateSelection
2795 // Purpose : UpdateSelection in accordance with current row
2796 //=======================================================================
2797 void SMESHGUI_FilterDlg::updateSelection()
2799 if (mySelectionMgr == 0)
2802 TColStd_MapOfInteger allTypes;
2803 for( int i=0; i<10; i++ )
2805 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
2810 mySelectionMgr->clearFilters();
2814 if (myTable->CurrentCell(aRow, aCol) &&
2815 (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGeom ||
2816 myTable->GetCriterionType(aRow) == SMESH::FT_BelongToPlane ||
2817 myTable->GetCriterionType(aRow) == SMESH::FT_BelongToCylinder ||
2818 myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGenSurface ||
2819 myTable->GetCriterionType(aRow) == SMESH::FT_LyingOnGeom)) {
2821 if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGeom ||
2822 myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGenSurface ||
2823 myTable->GetCriterionType(aRow) == SMESH::FT_LyingOnGeom) {
2825 mySelectionMgr->installFilter(new GEOM_SelectionFilter( aStudy, true ));
2827 } else if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToPlane) {
2828 mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) );
2830 } else if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToCylinder) {
2831 mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Cylinder ) );
2833 myIsSelectionChanged = true;
2836 if (myIsSelectionChanged) {
2837 mySelectionMgr->installFilter( new GEOM_TypeFilter( aStudy, -1 ) ); // This filter deactivates selection
2842 //=================================================================================
2843 // function : keyPressEvent()
2845 //=================================================================================
2846 void SMESHGUI_FilterDlg::keyPressEvent( QKeyEvent* e )
2848 QDialog::keyPressEvent( e );
2849 if ( e->isAccepted() )
2852 if ( e->key() == Qt::Key_F1 ) {