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;
382 f = f & ~Qt::ItemIsEditable;
387 SMESHGUI_FilterTable::CheckItem::CheckItem( const QString& text, bool value )
388 : QTableWidgetItem( Type() )
390 Qt::ItemFlags f = flags();
391 f = f | Qt::ItemIsUserCheckable;
392 f = f & ~Qt::ItemIsTristate;
393 f = f & ~Qt::ItemIsEditable;
399 SMESHGUI_FilterTable::CheckItem::~CheckItem()
403 void SMESHGUI_FilterTable::CheckItem::setChecked( bool value )
405 setCheckState( value ? Qt::Checked : Qt::Unchecked );
408 bool SMESHGUI_FilterTable::CheckItem::checked() const
410 return checkState() == Qt::Checked;
414 Class : SMESHGUI_FilterTable::ComboDelegate
415 Description : Table used by this widget
418 class SMESHGUI_FilterTable::ComboDelegate : public QItemDelegate
421 ComboDelegate( QObject* = 0 );
424 QWidget* createEditor( QWidget*, const QStyleOptionViewItem&,
425 const QModelIndex& ) const;
427 void setEditorData( QWidget*, const QModelIndex& ) const;
428 void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const;
430 void updateEditorGeometry( QWidget*, const QStyleOptionViewItem&,
431 const QModelIndex& ) const;
433 QTableWidget* myTable;
436 SMESHGUI_FilterTable::ComboDelegate::ComboDelegate( QObject* parent )
437 : QItemDelegate( parent ),
438 myTable( qobject_cast<QTableWidget*>( parent ) )
442 SMESHGUI_FilterTable::ComboDelegate::~ComboDelegate()
446 QWidget* SMESHGUI_FilterTable::ComboDelegate::createEditor( QWidget* parent,
447 const QStyleOptionViewItem& option,
448 const QModelIndex& index ) const
450 QStringList l = index.data( Qt::UserRole ).toStringList();
451 if ( !l.isEmpty() ) {
452 QComboBox* cb = new QComboBox( parent );
453 cb->setFrame( false );
457 return QItemDelegate::createEditor( parent, option, index );
460 void SMESHGUI_FilterTable::ComboDelegate::setEditorData( QWidget* editor,
461 const QModelIndex& index ) const
463 QString value = index.model()->data( index, Qt::DisplayRole ).toString();
464 QComboBox* cb = dynamic_cast<QComboBox*>( editor );
467 int i = cb->findText( value );
469 cb->setCurrentIndex( i );
473 if ( !bOk ) QItemDelegate::setEditorData( editor, index );
476 void SMESHGUI_FilterTable::ComboDelegate::setModelData( QWidget* editor,
477 QAbstractItemModel* model,
478 const QModelIndex& index) const
480 QComboBox* cb = dynamic_cast<QComboBox*>( editor );
481 if ( cb ) model->setData( index, cb->currentText(), Qt::DisplayRole );
482 else QItemDelegate::setModelData( editor, model, index );
485 void SMESHGUI_FilterTable::ComboDelegate::updateEditorGeometry( QWidget* editor,
486 const QStyleOptionViewItem& option,
487 const QModelIndex& index ) const
489 editor->setGeometry( option.rect );
493 Class : SMESHGUI_FilterTable::Table
494 Description : Table used by this widget
497 class SMESHGUI_FilterTable::Table : public QTableWidget
500 Table( QWidget* = 0 );
501 Table( int, int, QWidget* = 0 );
504 void setEditable( bool, int, int );
505 bool isEditable( int, int ) const;
507 void setReadOnly( bool );
508 bool isReadOnly() const;
510 void insertRows( int, int = 1 );
511 QString text( int, int );
513 QList<int> selectedRows();
516 //=======================================================================
517 // name : SMESHGUI_FilterTable::Table::Table
518 // Purpose : Constructor
519 //=======================================================================
520 SMESHGUI_FilterTable::Table::Table (QWidget* parent)
521 : QTableWidget(parent)
523 // set custom item delegate
524 setItemDelegate( new ComboDelegate(this) );
525 // set edit triggers by default
526 setReadOnly( false );
529 SMESHGUI_FilterTable::Table::Table (int numRows, int numCols, QWidget* parent)
530 : QTableWidget(numRows, numCols, parent)
532 // set custom item delegate
533 setItemDelegate( new ComboDelegate(this) );
534 // set edit triggers by default
535 setReadOnly( false );
538 SMESHGUI_FilterTable::Table::~Table()
542 //=======================================================================
543 // name : SMESHGUI_FilterTable::Table::setEditable
544 // Purpose : Set editable of specified cell
545 //=======================================================================
546 void SMESHGUI_FilterTable::Table::setEditable (bool isEditable,
549 QTableWidgetItem* anItem = item( row, col );
551 bool isSignalsBlocked = signalsBlocked();
552 blockSignals( true );
554 Qt::ItemFlags f = anItem->flags();
555 if ( !isEditable ) f = f & ~Qt::ItemIsEditable;
556 else f = f | Qt::ItemIsEditable;
557 anItem->setFlags( f );
559 blockSignals( isSignalsBlocked );
563 //=======================================================================
564 // name : SMESHGUI_FilterTable::Table::isEditable
565 // Purpose : Verify wheter cell is editable
566 //=======================================================================
567 bool SMESHGUI_FilterTable::Table::isEditable (int row, int col) const
569 QTableWidgetItem* anItem = item( row, col );
570 return anItem == 0 || anItem->flags() & Qt::ItemIsEditable;
573 void SMESHGUI_FilterTable::Table::setReadOnly( bool on )
575 setEditTriggers( on ?
576 QAbstractItemView::NoEditTriggers :
577 QAbstractItemView::DoubleClicked |
578 QAbstractItemView::SelectedClicked |
579 QAbstractItemView::EditKeyPressed |
580 QAbstractItemView::AnyKeyPressed );
583 bool SMESHGUI_FilterTable::Table::isReadOnly() const
585 return editTriggers() != QAbstractItemView::NoEditTriggers;
588 //=======================================================================
589 // name : SMESHGUI_FilterTable::Table::insertRows
590 // Purpose : Insert rows (virtual redefined)
591 //=======================================================================
592 void SMESHGUI_FilterTable::Table::insertRows (int row, int count)
594 closePersistentEditor( currentItem() );
595 while ( count-- ) insertRow( row );
598 //=======================================================================
599 // name : SMESHGUI_FilterTable::Table::text
600 // Purpose : Get text from cell (virtual redefined)
601 //=======================================================================
602 QString SMESHGUI_FilterTable::Table::text (int row, int col)
604 closePersistentEditor( currentItem() );
605 QTableWidgetItem* anItem = item( row, col );
606 return anItem ? anItem->text() : QString();
609 QList<int> SMESHGUI_FilterTable::Table::selectedRows()
611 QList<QTableWidgetItem*> selItems = selectedItems();
612 QTableWidgetItem* anItem;
615 foreach( anItem, selItems ) {
616 int r = row( anItem );
617 if ( !rows.contains( r ) ) rows.append( r );
625 Class : SMESHGUI_FilterTable
626 Description : Frame containig
627 - Button group for switching entity type
628 - Table for displaying filter criterions
629 - Buttons for editing table and filter libraries
632 //=======================================================================
633 // name : SMESHGUI_FilterTable::SMESHGUI_FilterTable
634 // Purpose : Constructor
635 //=======================================================================
636 SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
641 mySMESHGUI( theModule )
650 //=======================================================================
651 // name : SMESHGUI_FilterTable::SMESHGUI_FilterTable
652 // Purpose : Constructor
653 //=======================================================================
654 SMESHGUI_FilterTable::SMESHGUI_FilterTable( SMESHGUI* theModule,
656 const QList<int>& types )
659 mySMESHGUI( theModule )
665 SMESHGUI_FilterTable::~SMESHGUI_FilterTable()
669 //=======================================================================
670 // name : SMESHGUI_FilterTable::Init
671 // Purpose : Create table corresponding to the specified type
672 //=======================================================================
673 void SMESHGUI_FilterTable::Init (const QList<int>& theTypes)
675 if (theTypes.isEmpty())
678 // Create buttons if necessary
680 if (myTables.isEmpty())
682 int aType = theTypes.first();
684 // create main layout
685 QVBoxLayout* aMainLay = new QVBoxLayout(this);
686 aMainLay->setMargin( 0 );
687 aMainLay->setSpacing( SPACING );
689 // create switch of entity types
690 myEntityTypeBox = new QGroupBox(tr("ENTITY_TYPE"), this);
691 QHBoxLayout* myEntityTypeBoxLayout = new QHBoxLayout(myEntityTypeBox);
692 myEntityTypeBoxLayout->setMargin( MARGIN );
693 myEntityTypeBoxLayout->setSpacing( SPACING );
694 myEntityTypeGrp = new QButtonGroup(this);
696 const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
697 QMap<int, QString>::const_iterator anIter;
698 for (anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter)
700 QRadioButton* aBtn = new QRadioButton(anIter.value(), myEntityTypeBox);
701 myEntityTypeGrp->addButton(aBtn, anIter.key());
702 myEntityTypeBoxLayout->addWidget(aBtn);
705 myTableGrp = new QGroupBox(tr("FILTER"), this );
708 mySwitchTableGrp = new QWidget(myTableGrp);
709 QVBoxLayout* mySwitchTableGrpLayout = new QVBoxLayout(mySwitchTableGrp);
710 mySwitchTableGrpLayout->setMargin(0);
711 mySwitchTableGrpLayout->setSpacing(0);
713 myTables[ aType ] = createTable(mySwitchTableGrp, aType);
714 mySwitchTableGrpLayout->addWidget(myTables[ aType ]);
717 myAddBtn = new QPushButton(tr("ADD"), myTableGrp);
718 myRemoveBtn = new QPushButton(tr("REMOVE"), myTableGrp);
719 myClearBtn = new QPushButton(tr("CLEAR"), myTableGrp);
720 myInsertBtn = new QPushButton(tr("INSERT"), myTableGrp);
721 myCopyFromBtn = new QPushButton(tr("COPY_FROM"), myTableGrp);
722 myAddToBtn = new QPushButton(tr("ADD_TO"), myTableGrp);
724 myAddBtn->setAutoDefault(false);
725 myRemoveBtn->setAutoDefault(false);
726 myClearBtn->setAutoDefault(false);
727 myInsertBtn->setAutoDefault(false);
728 myCopyFromBtn->setAutoDefault(false);
729 myAddToBtn->setAutoDefault(false);
731 myCopyFromBtn->hide();
735 QGridLayout* aLay = new QGridLayout(myTableGrp);
737 aLay->setSpacing(SPACING);
739 aLay->addWidget(mySwitchTableGrp, 0, 0, 7, 1);
740 aLay->addWidget(myAddBtn, 0, 1);
741 aLay->addWidget(myInsertBtn, 1, 1);
742 aLay->addWidget(myRemoveBtn, 2, 1);
743 aLay->addWidget(myClearBtn, 3, 1);
744 aLay->addWidget(myCopyFromBtn, 5, 1);
745 aLay->addWidget(myAddToBtn, 6, 1);
746 aLay->addWidget(createAdditionalFrame(myTableGrp), 7, 0, 1, 2 );
748 aLay->setRowMinimumHeight(4, 10);
749 aLay->setRowStretch(4, 1);
750 aLay->setColumnStretch(0, 1);
751 aLay->setColumnStretch(1, 0);
754 aMainLay->addWidget(myEntityTypeBox);
755 aMainLay->addWidget(myTableGrp);
758 connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAddBtn()));
759 connect(myInsertBtn, SIGNAL(clicked()), this, SLOT(onInsertBtn()));
760 connect(myRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemoveBtn()));
761 connect(myClearBtn, SIGNAL(clicked()), this, SLOT(onClearBtn()));
763 connect(myCopyFromBtn, SIGNAL(clicked()), this, SLOT(onCopyFromBtn()));
764 connect(myAddToBtn, SIGNAL(clicked()), this, SLOT(onAddToBtn()));
766 connect(myEntityTypeGrp, SIGNAL(buttonClicked(int)), this, SLOT(onEntityType(int)));
771 // Hide buttons of entity types if necessary
772 const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
773 QMap<int, QString>::const_iterator anIt;
774 for (anIt = aSupportedTypes.begin(); anIt != aSupportedTypes.end(); ++anIt)
776 QAbstractButton* aBtn = myEntityTypeGrp->button(anIt.key());
777 if ( aBtn ) aBtn->setVisible( theTypes.contains(anIt.key()) );
780 // select first button if there is no selected buttons or it is hidden
781 int aBtnId = myEntityTypeGrp->checkedId();
782 if ( aBtnId == -1 || !theTypes.contains(aBtnId) ) {
783 QAbstractButton* aBtn = myEntityTypeGrp->button(theTypes.first());
784 if ( aBtn ) aBtn->setChecked(true);
787 myEntityTypeBox->setVisible(theTypes.count() > 1);
789 myTableGrp->updateGeometry();
790 int cType = myEntityTypeGrp->checkedId();
794 //=======================================================================
795 // name : SMESHGUI_FilterTable::createAdditionalFrame
796 // Purpose : Get group box containing table. May be used for adding new widgets in it
797 //=======================================================================
798 QWidget* SMESHGUI_FilterTable::createAdditionalFrame (QWidget* theParent)
800 QWidget* aFrame = new QWidget(theParent);
802 QFrame* aLine1 = new QFrame(aFrame);
803 QFrame* aLine2 = new QFrame(aFrame);
804 aLine1->setFrameStyle(QFrame::HLine | QFrame::Sunken);
805 aLine2->setFrameStyle(QFrame::HLine | QFrame::Sunken);
806 aLine1->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
807 aLine2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
809 QLabel* aLabel = new QLabel(tr("ADDITIONAL_PARAMETERS"), aFrame);
811 myWgStack = new QStackedWidget(aFrame);
813 QGridLayout* aLay = new QGridLayout(aFrame);
815 aLay->setSpacing(SPACING);
816 aLay->addWidget(aLine1, 0, 0);
817 aLay->addWidget(aLabel, 0, 1);
818 aLay->addWidget(aLine2, 0, 2);
819 aLay->addWidget(myWgStack, 1, 0, 1, 3);
824 //=======================================================================
825 // name : SMESHGUI_FilterTable::GetTableGrp
826 // Purpose : Get group box containing table. May be used for adding new widgets in it
827 //=======================================================================
828 QGroupBox* SMESHGUI_FilterTable::GetTableGrp()
833 //=======================================================================
834 // name : SMESHGUI_FilterTable::onEntityType
835 // Purpose : SLOT. Called when entity type changed.
836 // Display corresponding table
837 //=======================================================================
838 void SMESHGUI_FilterTable::onEntityType (int theType)
840 if (myEntityType == theType)
844 emit NeedValidation();
847 myEntityTypeGrp->button(myEntityType)->setChecked(true);
851 myEntityType = theType;
853 if (!myTables.contains(theType)) {
854 myTables[ theType ] = createTable(mySwitchTableGrp, theType);
855 ((QVBoxLayout*)mySwitchTableGrp->layout())->addWidget(myTables[ theType ]);
858 TableMap::iterator anIter;
859 for (anIter = myTables.begin(); anIter != myTables.end(); ++anIter)
860 anIter.value()->setVisible( myEntityType == anIter.key() );
863 qApp->processEvents();
864 myTables[ myEntityType ]->updateGeometry();
867 emit EntityTypeChanged(theType);
870 //=======================================================================
871 // name : SMESHGUI_FilterTable::IsValid
872 // Purpose : Verify validity of entered data
873 //=======================================================================
874 bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType) const
876 int aType = theEntityType == -1 ? GetType() : theEntityType;
878 Table* aTable = myTables[ aType ];
879 for (int i = 0, n = aTable->rowCount(); i < n; i++)
881 int aCriterion = GetCriterionType(i, aType);
883 if (aCriterion == SMESH::FT_RangeOfIds ||
884 aCriterion == SMESH::FT_BelongToGeom ||
885 aCriterion == SMESH::FT_BelongToPlane ||
886 aCriterion == SMESH::FT_BelongToCylinder ||
887 aCriterion == SMESH::FT_BelongToGenSurface ||
888 aCriterion == SMESH::FT_LyingOnGeom) {
889 if (aTable->text(i, 2).isEmpty()) {
891 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
897 bool isSignalsBlocked = aTable->signalsBlocked();
898 aTable->blockSignals(true);
899 double aThreshold = (int)aTable->text(i, 2).toDouble(&aRes);
900 aTable->blockSignals(isSignalsBlocked);
902 if (!aRes && aTable->isEditable(i, 2)) {
904 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
908 else if (aType == SMESH::EDGE &&
909 GetCriterionType(i, aType) == SMESH::FT_MultiConnection &&
913 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
914 tr("MULTIEDGES_ERROR"));
919 QTableWidgetItem* anItem = aTable->item(i, 0);
920 if (myAddWidgets.contains(anItem) && !myAddWidgets[ anItem ]->IsValid())
927 //=======================================================================
928 // name : SMESHGUI_FilterTable::SetValidity
929 // Purpose : Set validity of the table
930 //=======================================================================
931 void SMESHGUI_FilterTable::SetValidity (const bool isValid)
936 //=======================================================================
937 // name : SMESHGUI_FilterTable::GetType
938 // Purpose : Get current entity type
939 //=======================================================================
940 int SMESHGUI_FilterTable::GetType() const
945 //=======================================================================
946 // name : SMESHGUI_FilterTable::SetType
947 // Purpose : Set current entity type
948 //=======================================================================
949 void SMESHGUI_FilterTable::SetType (const int type)
951 myEntityTypeGrp->button(type)->setChecked(true);
955 //=======================================================================
956 // name : SMESHGUI_FilterTable::RestorePreviousEntityType
957 // Purpose : Restore previous entity type
958 //=======================================================================
959 void SMESHGUI_FilterTable::RestorePreviousEntityType()
961 SetType(myEntityType);
964 //=======================================================================
965 // name : SMESHGUI_FilterTable::GetCriterionType
966 // Purpose : Get type of criterion from specified row (corresponding enums in h-file)
967 //=======================================================================
968 int SMESHGUI_FilterTable::GetCriterionType (const int theRow, const int theType) const
970 int aType = theType == -1 ? GetType() : theType;
971 Table* aTable = myTables[ aType ];
972 ComboItem* anItem = (ComboItem*)aTable->item(theRow, 0);
973 return anItem != 0 ? anItem->value() : SMESH::FT_Undefined;
976 //=======================================================================
977 // name : SMESHGUI_FilterTable::GetCriterion
978 // Purpose : Get parameters of criterion from specified row
979 //=======================================================================
980 void SMESHGUI_FilterTable::GetCriterion (const int theRow,
981 SMESH::Filter::Criterion& theCriterion,
982 const int theEntityType) const
984 int aType = theEntityType == -1 ? GetType() : theEntityType;
985 Table* aTable = myTables[ aType ];
987 theCriterion.Type = ((ComboItem*)aTable->item(theRow, 0))->value();
988 theCriterion.UnaryOp = ((CheckItem*)aTable->item(theRow, 3))->checked() ? SMESH::FT_LogicalNOT : SMESH::FT_Undefined;
989 theCriterion.BinaryOp = theRow != aTable->rowCount() - 1 ?
990 ((ComboItem*)aTable->item(theRow, 4))->value() : SMESH::FT_Undefined;
991 theCriterion.TypeOfElement = (SMESH::ElementType)aType;
993 int aCriterionType = GetCriterionType(theRow, aType);
995 if ( aCriterionType != SMESH::FT_RangeOfIds &&
996 aCriterionType != SMESH::FT_BelongToGeom &&
997 aCriterionType != SMESH::FT_BelongToPlane &&
998 aCriterionType != SMESH::FT_BelongToCylinder &&
999 aCriterionType != SMESH::FT_BelongToGenSurface &&
1000 aCriterionType != SMESH::FT_LyingOnGeom)
1002 theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->value();
1003 theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble();
1007 theCriterion.ThresholdStr = aTable->text(theRow, 2).toLatin1().data();
1008 if ( aCriterionType != SMESH::FT_RangeOfIds )
1009 theCriterion.ThresholdID = aTable->text( theRow, 5 ).toLatin1().data();
1012 QTableWidgetItem* anItem = aTable->item(theRow, 0);
1013 if (myAddWidgets.contains(anItem))
1014 theCriterion.Tolerance = myAddWidgets[ anItem ]->GetDouble(AdditionalWidget::Tolerance);
1017 //=======================================================================
1018 // name : SMESHGUI_FilterTable::SetCriterion
1019 // Purpose : Set parameters of criterion of specified row
1020 //=======================================================================
1021 void SMESHGUI_FilterTable::SetCriterion (const int theRow,
1022 const SMESH::Filter::Criterion& theCriterion,
1023 const int theEntityType)
1025 int aType = theEntityType == -1 ? GetType() : theEntityType;
1027 Table* aTable = myTables[ aType ];
1029 if (theRow > aTable->rowCount() - 1)
1032 ((ComboItem*)aTable->item(theRow, 0))->setValue(theCriterion.Type);
1033 onCriterionChanged(theRow, 0, aType);
1034 ((ComboItem*)aTable->item(theRow, 1))->setValue(theCriterion.Compare);
1035 ((CheckItem*)aTable->item(theRow, 3))->setChecked(theCriterion.UnaryOp == SMESH::FT_LogicalNOT);
1037 if (theCriterion.BinaryOp != SMESH::FT_Undefined)
1039 if (!aTable->isEditable(theRow, 4))
1040 aTable->setItem(theRow, 4, getBinaryItem());
1041 ((ComboItem*)aTable->item(theRow, 4))->setValue(theCriterion.BinaryOp);
1044 aTable->setEditable(false, theRow, 4);
1046 if (theCriterion.Type != SMESH::FT_RangeOfIds &&
1047 theCriterion.Type != SMESH::FT_BelongToGeom &&
1048 theCriterion.Type != SMESH::FT_BelongToPlane &&
1049 theCriterion.Type != SMESH::FT_BelongToCylinder &&
1050 theCriterion.Type != SMESH::FT_BelongToGenSurface &&
1051 theCriterion.Type != SMESH::FT_LyingOnGeom &&
1052 theCriterion.Type != SMESH::FT_FreeBorders &&
1053 theCriterion.Type != SMESH::FT_FreeEdges &&
1054 theCriterion.Type != SMESH::FT_BadOrientedVolume)
1055 aTable->item( theRow, 2 )->setText(QString("%1").arg(theCriterion.Threshold, 0, 'g', 15));
1058 aTable->item( theRow, 2 )->setText(QString(theCriterion.ThresholdStr));
1059 if ( theCriterion.Type != SMESH::FT_RangeOfIds )
1060 aTable->item( theRow, 5 )->setText( QString( theCriterion.ThresholdID ) );
1063 if (theCriterion.Compare == SMESH::FT_EqualTo ||
1064 theCriterion.Type == SMESH::FT_BelongToPlane ||
1065 theCriterion.Type == SMESH::FT_BelongToCylinder ||
1066 theCriterion.Type == SMESH::FT_BelongToGenSurface)
1068 QTableWidgetItem* anItem = aTable->item(theRow, 0);
1069 if (!myAddWidgets.contains(anItem))
1071 myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack);
1072 myWgStack->addWidget(myAddWidgets[ anItem ]);
1074 myAddWidgets[ anItem ]->SetDouble(AdditionalWidget::Tolerance, theCriterion.Tolerance);
1077 emit CriterionChanged(theRow, aType);
1081 //=======================================================================
1082 // name : SMESHGUI_FilterTable::Update
1083 // Purpose : Update table
1084 //=======================================================================
1085 void SMESHGUI_FilterTable::Update()
1087 Table* aTable = myTables[ GetType() ];
1088 int aCurrRow = aTable->currentRow();
1089 int numRows = aTable->rowCount();
1090 if ((aCurrRow < 0 || aCurrRow >= numRows) && numRows > 0)
1091 aTable->setCurrentCell(0, 0);
1092 updateAdditionalWidget();
1095 //=======================================================================
1096 // name : SMESHGUI_FilterTable::AddCriterion
1097 // Purpose : Add criterion with parameters
1098 //=======================================================================
1099 void SMESHGUI_FilterTable::AddCriterion (const SMESH::Filter::Criterion& theCriterion,
1100 const int theEntityType)
1102 int aType = theEntityType == -1 ? GetType() : theEntityType;
1103 Table* aTable = myTables[ aType ];
1104 addRow(aTable, aType);
1105 SetCriterion(aTable->rowCount() - 1, theCriterion);
1108 //=======================================================================
1109 // name : SMESHGUI_FilterTable::NumRows
1110 // Purpose : Get number of criterions of current type
1111 //=======================================================================
1112 int SMESHGUI_FilterTable::NumRows (const int theEntityType) const
1114 return myTables[ theEntityType == -1 ? GetType() : theEntityType ]->rowCount();
1117 //=======================================================================
1118 // name : SMESHGUI_FilterTable::Clear
1119 // Purpose : Clear current table
1120 //=======================================================================
1121 void SMESHGUI_FilterTable::Clear (const int theType)
1123 int aType = theType == -1 ? GetType() : theType;
1124 Table* aTable = myTables[ aType ];
1126 if (aTable->rowCount() == 0)
1129 while (aTable->rowCount() > 0)
1131 removeAdditionalWidget(aTable, 0);
1132 aTable->removeRow(0);
1138 //=======================================================================
1139 // name : SMESHGUI_FilterTable::onAddBtn
1140 // Purpose : SLOT. Called then "Add" button pressed.
1141 // Adds new string to table
1142 //=======================================================================
1143 void SMESHGUI_FilterTable::onAddBtn()
1145 int aType = GetType();
1146 addRow(myTables[ aType ], aType);
1151 //=======================================================================
1152 // name : SMESHGUI_FilterTable::onInsertBtn
1153 // Purpose : SLOT. Called then "Insert" button pressed.
1154 // Inserts new string before current one
1155 //=======================================================================
1156 void SMESHGUI_FilterTable::onInsertBtn()
1158 addRow(myTables[ GetType() ], GetType(), false);
1161 //=======================================================================
1162 // name : SMESHGUI_FilterTable::onRemoveBtn
1163 // Purpose : SLOT. Called then "Remove" button pressed.
1164 // Removes current string from table
1165 //=======================================================================
1166 void SMESHGUI_FilterTable::onRemoveBtn()
1168 Table* aTable = myTables[ GetType() ];
1170 if (aTable->rowCount() == 0)
1173 QList<QTableWidgetItem*> items = aTable->selectedItems();
1175 QList<int> aRows = aTable->selectedRows(); // already sorted
1179 removeAdditionalWidget(aTable, i);
1180 aTable->removeRow(i);
1183 // remove control of binary logical operation from last row
1184 if (aTable->rowCount() > 0)
1185 aTable->setEditable(false, aTable->rowCount() - 1, 4);
1190 //=======================================================================
1191 // name : SMESHGUI_FilterTable::updateAdditionalWidget
1192 // Purpose : Enable/Disable widget with additonal parameters
1193 //=======================================================================
1194 void SMESHGUI_FilterTable::updateAdditionalWidget()
1196 Table* aTable = myTables[ GetType() ];
1197 int aRow = aTable->currentRow();
1198 if (aRow < 0 || aRow >= aTable->rowCount())
1200 myWgStack->setEnabled(false);
1204 ComboItem* anItem = ((ComboItem*)aTable->item(aRow, 0));
1205 bool toEnable = ((ComboItem*)aTable->item(aRow, 1))->value() == SMESH::FT_EqualTo &&
1206 GetCriterionType(aRow) != SMESH::FT_BelongToGeom &&
1207 GetCriterionType(aRow) != SMESH::FT_LyingOnGeom &&
1208 GetCriterionType(aRow) != SMESH::FT_RangeOfIds &&
1209 GetCriterionType(aRow) != SMESH::FT_FreeEdges &&
1210 GetCriterionType(aRow) != SMESH::FT_BadOrientedVolume;
1211 if (!myAddWidgets.contains(anItem))
1213 myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack);
1214 myWgStack->addWidget(myAddWidgets[ anItem ]);
1217 myWgStack->setCurrentWidget(myAddWidgets[ anItem ]);
1218 myWgStack->setEnabled(toEnable);
1221 //=======================================================================
1222 // name : SMESHGUI_FilterTable::removeAdditionalWidget
1223 // Purpose : Remove widgets containing additional parameters from widget
1224 // stack and internal map
1225 //=======================================================================
1226 void SMESHGUI_FilterTable::removeAdditionalWidget (QTableWidget* theTable, const int theRow)
1228 QTableWidgetItem* anItem = theTable->item(theRow, 0);
1229 if (myAddWidgets.contains(anItem))
1231 myWgStack->removeWidget(myAddWidgets[ anItem ]);
1232 myAddWidgets[ anItem ]->setParent(0);
1233 delete myAddWidgets[ anItem ];
1234 myAddWidgets.remove(anItem);
1238 //=======================================================================
1239 // name : SMESHGUI_FilterTable::onClearBtn
1240 // Purpose : SLOT. Called then "Clear" button pressed.
1241 // Removes all strings from table
1242 //=======================================================================
1243 void SMESHGUI_FilterTable::onClearBtn()
1245 Table* aTable = myTables[ GetType() ];
1247 if (aTable->rowCount() == 0)
1250 while (aTable->rowCount() > 0)
1252 removeAdditionalWidget(aTable, 0);
1253 aTable->removeRow(0);
1259 //=======================================================================
1260 // name : SMESHGUI_FilterTable::onCurrentChanged()
1261 // Purpose : SLOT. Called when current cell changed
1262 //=======================================================================
1263 void SMESHGUI_FilterTable::onCurrentChanged (int theRow, int theCol)
1266 updateAdditionalWidget();
1267 emit CurrentChanged(theRow, theCol);
1270 //=======================================================================
1271 // name : SMESHGUI_FilterTable::onCriterionChanged()
1272 // Purpose : Provides reaction on change of criterion
1273 //=======================================================================
1274 void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, const int entityType)
1276 int aType = entityType == -1 ? GetType() : entityType;
1277 Table* aTable = myTables[ aType ];
1278 ComboItem* aCompareItem = (ComboItem*)aTable->item(row, 1);
1280 int aCriterionType = GetCriterionType(row);
1282 if (aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders ||
1283 aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges ||
1284 aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume)
1286 bool isSignalsBlocked = aTable->signalsBlocked();
1287 aTable->blockSignals( true );
1289 if (aCompareItem->count() > 0)
1290 aCompareItem->clear();
1291 aTable->setEditable(false, row, 2);
1293 aTable->blockSignals( isSignalsBlocked );
1295 else if (aCriterionType == SMESH::FT_RangeOfIds ||
1296 aCriterionType == SMESH::FT_BelongToGeom ||
1297 aCriterionType == SMESH::FT_BelongToPlane ||
1298 aCriterionType == SMESH::FT_BelongToCylinder ||
1299 aCriterionType == SMESH::FT_BelongToGenSurface ||
1300 aCriterionType == SMESH::FT_LyingOnGeom)
1302 QMap<int, QString> aMap;
1303 aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO");
1304 aCompareItem->setItems(aMap);
1305 if (!aTable->isEditable(row, 2))
1306 aTable->setEditable(true, row, 2);
1310 if (aCompareItem->count() != 3)
1312 aCompareItem->setItems(getCompare());
1315 QString aText = aTable->text(row, 2);
1317 aText.toDouble(&isOk);
1318 aTable->item( row, 2 )->setText(isOk ? aText : QString(""));
1319 if (!aTable->isEditable(row, 2))
1320 aTable->setEditable(true, row, 2);
1323 updateAdditionalWidget();
1325 emit CriterionChanged(row, entityType);
1328 //=======================================================================
1329 // name : SMESHGUI_FilterTable::onCriterionChanged()
1330 // Purpose : SLOT. Called then contents of table changed
1331 // Provides reaction on change of criterion
1332 //=======================================================================
1333 void SMESHGUI_FilterTable::onCriterionChanged (int row, int col)
1335 onCriterionChanged(row, col, -1);
1338 //=======================================================================
1339 // name : SMESHGUI_FilterTable::getFirstSelectedRow
1340 // Purpose : Get first selected row
1341 //=======================================================================
1342 int SMESHGUI_FilterTable::getFirstSelectedRow() const
1344 Table* aTable = myTables[ GetType() ];
1346 QList<int> selRows = aTable->selectedRows(); // already sorted
1347 int aRow = selRows.count() > 0 ? selRows[0] : aTable->currentRow();
1349 return aRow >= 0 && aRow < aTable->rowCount() ? aRow : -1;
1352 //=======================================================================
1353 // name : SMESHGUI_FilterTable::addRow
1354 // Purpose : Add row at the end of table
1355 //=======================================================================
1356 void SMESHGUI_FilterTable::addRow (Table* theTable, const int theType, const bool toTheEnd)
1359 int aSelectedRow = getFirstSelectedRow();
1360 int aCurrCol = theTable->currentColumn();
1363 if (toTheEnd || aSelectedRow == -1)
1365 theTable->insertRows(theTable->rowCount());
1366 aCurrRow = theTable->rowCount() - 1;
1370 theTable->insertRows(aSelectedRow);
1371 aCurrRow = aSelectedRow;
1375 // IPAL19372 - to prevent calling onCriterionChaged() slot before completion of setItem()
1376 bool isSignalsBlocked = theTable->signalsBlocked();
1377 theTable->blockSignals( true );
1380 theTable->setItem(aCurrRow, 0, getCriterionItem(theType));
1383 theTable->setItem(aCurrRow, 1, getCompareItem());
1386 theTable->setItem(aCurrRow, 2, new QTableWidgetItem());
1388 // Logical operation NOT
1389 theTable->setItem(aCurrRow, 3, getUnaryItem());
1391 // Logical operation AND / OR
1392 theTable->setItem(aCurrRow, 4, new QTableWidgetItem());
1394 theTable->blockSignals( isSignalsBlocked );
1396 // Logical binary operation for previous value
1397 int anAddBinOpStr = -1;
1398 if (aCurrRow == theTable->rowCount() - 1)
1399 anAddBinOpStr = aCurrRow - 1;
1400 else if (aCurrRow >= 0 )
1401 anAddBinOpStr = aCurrRow;
1403 if (theTable->item(aCurrRow, 4) == 0 ||
1404 theTable->item(aCurrRow, 4)->type() != ComboItem::Type())
1408 if (anAddBinOpStr >= 0 &&
1409 (theTable->item(anAddBinOpStr, 4) == 0 ||
1410 theTable->item(anAddBinOpStr, 4)->type() != ComboItem::Type()))
1411 theTable->setItem(anAddBinOpStr, 4, getBinaryItem());
1414 theTable->setEditable(false, theTable->rowCount() - 1, 4);
1416 if (aCurrRow >=0 && aCurrRow < theTable->rowCount() &&
1417 aCurrCol >=0 && aCurrCol < theTable->rowCount())
1418 theTable->setCurrentCell(aCurrRow, aCurrCol);
1420 onCriterionChanged(aCurrRow, 0);
1425 //=======================================================================
1426 // name : SMESHGUI_FilterTable::getCriterionItem
1427 // Purpose : Get combo table item for criteria of specified type
1428 //=======================================================================
1429 QTableWidgetItem* SMESHGUI_FilterTable::getCriterionItem (const int theType) const
1431 return new ComboItem(getCriteria(theType));
1434 //=======================================================================
1435 // name : SMESHGUI_FilterTable::getCompareItem
1436 // Purpose : Get combo table item for operation of comparision
1437 //=======================================================================
1438 QTableWidgetItem* SMESHGUI_FilterTable::getCompareItem () const
1440 return new ComboItem(getCompare());
1443 //=======================================================================
1444 // name : SMESHGUI_FilterTable::getBinaryItem
1446 //=======================================================================
1447 QTableWidgetItem* SMESHGUI_FilterTable::getBinaryItem () const
1449 static QMap<int, QString> aMap;
1452 aMap[ SMESH::FT_LogicalAND ] = tr("AND");
1453 aMap[ SMESH::FT_LogicalOR ] = tr("OR");
1456 return new ComboItem(aMap);
1459 //=======================================================================
1460 // name : SMESHGUI_FilterTable::getUnaryItem
1461 // Purpose : Get check table item
1462 //=======================================================================
1463 QTableWidgetItem* SMESHGUI_FilterTable::getUnaryItem () const
1465 return new CheckItem(tr("NOT"));
1468 //=======================================================================
1469 // name : SMESHGUI_FilterTable::getSupportedTypes
1470 // Purpose : Get all supported type
1471 //=======================================================================
1472 const QMap<int, QString>& SMESHGUI_FilterTable::getSupportedTypes() const
1474 static QMap<int, QString> aTypes;
1475 if (aTypes.isEmpty())
1477 aTypes[ SMESH::NODE ] = tr("NODES");
1478 aTypes[ SMESH::EDGE ] = tr("EDGES");
1479 aTypes[ SMESH::FACE ] = tr("FACES");
1480 aTypes[ SMESH::VOLUME ] = tr("VOLUMES");
1486 //=======================================================================
1487 // name : SMESHGUI_FilterTable::getCriteria
1488 // Purpose : Get criteria for specified type
1489 //=======================================================================
1490 const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria (const int theType) const
1492 if (theType == SMESH::NODE)
1494 static QMap<int, QString> aCriteria;
1495 if (aCriteria.isEmpty())
1497 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
1498 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
1499 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
1500 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
1501 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
1502 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
1506 else if (theType == SMESH::EDGE)
1508 static QMap<int, QString> aCriteria;
1509 if (aCriteria.isEmpty())
1511 aCriteria[ SMESH::FT_FreeBorders ] = tr("FREE_BORDERS");
1512 aCriteria[ SMESH::FT_MultiConnection ] = tr("MULTI_BORDERS");
1513 aCriteria[ SMESH::FT_Length ] = tr("LENGTH");
1514 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
1515 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
1516 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
1517 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
1518 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
1519 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
1523 else if (theType == SMESH::FACE)
1525 static QMap<int, QString> aCriteria;
1526 if (aCriteria.isEmpty())
1528 aCriteria[ SMESH::FT_AspectRatio ] = tr("ASPECT_RATIO");
1529 aCriteria[ SMESH::FT_Warping ] = tr("WARPING");
1530 aCriteria[ SMESH::FT_MinimumAngle ] = tr("MINIMUM_ANGLE");
1531 aCriteria[ SMESH::FT_Taper ] = tr("TAPER");
1532 aCriteria[ SMESH::FT_Skew ] = tr("SKEW");
1533 aCriteria[ SMESH::FT_Area ] = tr("AREA");
1534 aCriteria[ SMESH::FT_FreeEdges ] = tr("FREE_EDGES");
1535 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
1536 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
1537 aCriteria[ SMESH::FT_BelongToPlane ] = tr("BELONG_TO_PLANE");
1538 aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
1539 aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
1540 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
1541 aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D");
1542 aCriteria[ SMESH::FT_MultiConnection2D ] = tr("MULTI2D_BORDERS");
1546 else if (theType == SMESH::VOLUME)
1548 static QMap<int, QString> aCriteria;
1549 if (aCriteria.isEmpty())
1551 aCriteria[ SMESH::FT_AspectRatio3D ] = tr("ASPECT_RATIO_3D");
1552 aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
1553 aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
1554 aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
1555 aCriteria[ SMESH::FT_BadOrientedVolume ] = tr("BAD_ORIENTED_VOLUME");
1556 aCriteria[ SMESH::FT_Volume3D ] = tr("VOLUME_3D");
1562 static QMap<int, QString> aCriteria;
1568 //=======================================================================
1569 // name : SMESHGUI_FilterTable::getCompare
1570 // Purpose : Get operation of comparison
1571 //=======================================================================
1572 const QMap<int, QString>& SMESHGUI_FilterTable::getCompare() const
1574 static QMap<int, QString> aMap;
1578 aMap[ SMESH::FT_LessThan ] = tr("LESS_THAN");
1579 aMap[ SMESH::FT_MoreThan ] = tr("MORE_THAN");
1580 aMap[ SMESH::FT_EqualTo ] = tr("EQUAL_TO" );
1586 //=======================================================================
1587 // name : SMESHGUI_FilterTable::createTable
1588 // Purpose : Create table
1589 //=======================================================================
1590 SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable (QWidget* theParent,
1594 Table* aTable= new Table(0, 6, theParent);
1596 QHeaderView* aHeaders = aTable->horizontalHeader();
1598 QFontMetrics aMetrics(aHeaders->font());
1600 // append spaces to the header of criteria in order to
1601 // provide visibility of criterion inside comboboxes
1602 static int aMaxLenCr = 0;
1606 const QMap<int, QString>& aSupportedTypes = getSupportedTypes();
1607 QMap<int, QString>::const_iterator anIter;
1608 for (anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter)
1609 aMaxLenCr = qMax(maxLength(getCriteria(anIter.key()), aMetrics), aMaxLenCr);
1612 static int aLenCr = qAbs( aMaxLenCr -
1613 aMetrics.width(tr("CRITERION"))) / aMetrics.width(' ') + 5;
1616 aCrStr.fill(' ', aLenCr);
1618 aCoStr.fill(' ', 10);
1620 QStringList aHeaderLabels;
1621 aHeaderLabels.append( tr("CRITERION") + aCrStr );
1622 aHeaderLabels.append( tr("COMPARE") + aCoStr );
1623 aHeaderLabels.append( tr("THRESHOLD_VALUE") );
1624 aHeaderLabels.append( tr("UNARY") );
1625 aHeaderLabels.append( tr("BINARY") + " " );
1626 aHeaderLabels.append( tr("ID") );
1627 aTable->setHorizontalHeaderLabels( aHeaderLabels );
1629 // set geometry of the table
1630 for (int i = 0; i <= 4; i++)
1631 aTable->resizeColumnToContents(i);
1633 // set the ID column invisible
1634 aTable->hideColumn( 5 );
1636 aTable->updateGeometry();
1637 QSize aSize = aTable->sizeHint();
1638 int aWidth = aSize.width();
1639 aTable->setMinimumSize(QSize(aWidth, aWidth / 2));
1640 aTable->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
1642 connect(aTable, SIGNAL(cellChanged(int, int)),
1643 this, SLOT(onCriterionChanged(int, int)));
1645 connect(aTable, SIGNAL(currentCellChanged(int, int, int, int)),
1646 this, SLOT(onCurrentChanged(int, int)));
1651 //=======================================================================
1652 // name : SMESHGUI_FilterTable::updateBtnState
1653 // Purpose : Update button state
1654 //=======================================================================
1655 void SMESHGUI_FilterTable::updateBtnState()
1657 myRemoveBtn->setEnabled(myTables[ GetType() ]->rowCount() > 0);
1658 myClearBtn->setEnabled(myTables[ GetType() ]->rowCount() > 0);
1661 //=======================================================================
1662 // name : SMESHGUI_FilterTable::SetEditable
1663 // Purpose : Set read only flag for tables. Show/hide buttons for work with rows
1664 //=======================================================================
1665 void SMESHGUI_FilterTable::SetEditable (const bool isEditable)
1667 TableMap::iterator anIter;
1668 for (anIter = myTables.begin(); anIter != myTables.end(); ++anIter)
1670 anIter.value()->setReadOnly(!isEditable);
1675 myInsertBtn->show();
1676 myRemoveBtn->show();
1682 myInsertBtn->hide();
1683 myRemoveBtn->hide();
1688 QMap<QTableWidgetItem*, AdditionalWidget*>::iterator anIter2;
1689 for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2)
1690 anIter2.value()->SetEditable(isEditable);
1693 //=======================================================================
1694 // name : SMESHGUI_FilterTable::SetEnabled
1695 // Purpose : Enable/Disable table. Switching type of elements already enabled
1696 //=======================================================================
1697 void SMESHGUI_FilterTable::SetEnabled (const bool isEnabled)
1699 myAddBtn->setEnabled(isEnabled);
1700 myInsertBtn->setEnabled(isEnabled);
1701 myRemoveBtn->setEnabled(isEnabled);
1702 myClearBtn->setEnabled(isEnabled);
1707 QMap<QTableWidgetItem*, AdditionalWidget*>::iterator anIter2;
1708 for (anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2)
1709 anIter2.value()->setEnabled(isEnabled);
1712 //=======================================================================
1713 // name : SMESHGUI_FilterTable::IsEditable
1714 // Purpose : Verify whether table is editable
1715 //=======================================================================
1716 bool SMESHGUI_FilterTable::IsEditable() const
1718 return !myTables[ GetType() ]->isReadOnly();
1721 //=======================================================================
1722 // name : SMESHGUI_FilterTable::SetLibsEnabled
1723 // Purpose : Show/hide buttons for work with libraries
1724 //=======================================================================
1725 void SMESHGUI_FilterTable::SetLibsEnabled (const bool isEnabled)
1729 myCopyFromBtn->show();
1734 myCopyFromBtn->hide();
1739 //=======================================================================
1740 // name : SMESHGUI_FilterTable::onCopyFromBtn
1741 // Purpose : SLOT. Called the "Copy from ..." button clicked
1742 // Display filter library dialog
1743 //=======================================================================
1744 void SMESHGUI_FilterTable::onCopyFromBtn()
1747 myLibDlg = new SMESHGUI_FilterLibraryDlg(
1748 mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
1750 myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM);
1752 if (myLibDlg->exec() == QDialog::Accepted)
1754 Copy(myLibDlg->GetTable());
1759 //=======================================================================
1760 // name : SMESHGUI_FilterTable::onAddToBtn
1761 // Purpose : SLOT. Called the "Add to ..." button clicked
1762 // Display filter library dialog
1763 //=======================================================================
1764 void SMESHGUI_FilterTable::onAddToBtn()
1769 myLibDlg = new SMESHGUI_FilterLibraryDlg(
1770 mySMESHGUI, this, GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
1772 myLibDlg->Init(GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO);
1774 myLibDlg->SetTable(this);
1779 //=======================================================================
1780 // name : SMESHGUI_FilterTable::Copy
1781 // Purpose : Initialise table with values of other table
1782 //=======================================================================
1783 void SMESHGUI_FilterTable::Copy (const SMESHGUI_FilterTable* theTable)
1787 for (int i = 0, n = theTable->NumRows(); i < n; i++)
1789 SMESH::Filter::Criterion aCriterion = SMESHGUI_FilterDlg::createCriterion();
1790 theTable->GetCriterion(i, aCriterion);
1791 AddCriterion(aCriterion);
1795 //=======================================================================
1796 // name : SMESHGUI_FilterTable::CurrentCell
1797 // Purpose : Returns current cell
1798 //=======================================================================
1799 bool SMESHGUI_FilterTable::CurrentCell (int& theRow, int& theCol) const
1801 theRow = myTables[ GetType() ]->currentRow();
1802 theCol = myTables[ GetType() ]->currentColumn();
1803 return theRow >= 0 && theCol >= 0;
1806 //=======================================================================
1807 // name : SMESHGUI_FilterTable::SetText
1808 // Purpose : Set text and internal value in cell of threshold value
1809 //=======================================================================
1810 void SMESHGUI_FilterTable::SetThreshold (const int theRow,
1811 const QString& theText,
1812 const int theEntityType)
1814 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
1815 aTable->item( theRow, 2 )->setText(theText);
1818 //=======================================================================
1819 // name : SMESHGUI_FilterTable::SetText
1820 // Purpose : Get text and internal value from cell of threshold value
1821 //=======================================================================
1822 bool SMESHGUI_FilterTable::GetThreshold (const int theRow,
1824 const int theEntityType)
1826 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
1827 QTableWidgetItem* anItem = aTable->item(theRow, 2);
1830 theText = anItem->text();
1837 //=======================================================================
1838 // name : SMESHGUI_FilterTable::SetID
1839 // Purpose : Set text and internal value in cell of ID value
1840 //=======================================================================
1841 void SMESHGUI_FilterTable::SetID( const int theRow,
1842 const QString& theText,
1843 const int theEntityType )
1845 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
1846 aTable->item( theRow, 5 )->setText( theText );
1849 //=======================================================================
1850 // name : SMESHGUI_FilterTable::GetID
1851 // Purpose : Get text and internal value from cell of ID value
1852 //=======================================================================
1853 bool SMESHGUI_FilterTable::GetID( const int theRow,
1855 const int theEntityType )
1857 Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ];
1858 QTableWidgetItem* anItem = aTable->item( theRow, 5 );
1861 theText = anItem->text();
1869 Class : SMESHGUI_FilterDlg
1870 Description : Dialog to specify filters for VTK viewer
1874 //=======================================================================
1875 // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
1876 // Purpose : Constructor
1877 //=======================================================================
1878 SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
1879 const QList<int>& theTypes )
1880 : QDialog( SMESH::GetDesktop( theModule ) ),
1881 mySMESHGUI( theModule ),
1882 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
1884 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1885 mySelector = aViewWindow->GetSelector();
1887 construct(theTypes);
1890 //=======================================================================
1891 // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
1892 // Purpose : Constructor
1893 //=======================================================================
1894 SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
1896 : QDialog( SMESH::GetDesktop( theModule ) ),
1897 mySMESHGUI( theModule ),
1898 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
1900 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1901 mySelector = aViewWindow->GetSelector();
1903 aTypes.append(theType);
1907 //=======================================================================
1908 // name : SMESHGUI_FilterDlg::construct
1909 // Purpose : Construct dialog (called by constructor)
1910 //=======================================================================
1911 void SMESHGUI_FilterDlg::construct (const QList<int>& theTypes)
1916 //setAttribute(Qt::WA_DeleteOnClose, true); // VSR ??? is it required?
1917 setWindowTitle(tr("CAPTION"));
1919 QVBoxLayout* aDlgLay = new QVBoxLayout (this);
1920 aDlgLay->setMargin(MARGIN);
1921 aDlgLay->setSpacing(SPACING);
1923 myMainFrame = createMainFrame (this);
1924 QWidget* aBtnFrame = createButtonFrame(this);
1926 aDlgLay->addWidget(myMainFrame);
1927 aDlgLay->addWidget(aBtnFrame);
1929 aDlgLay->setStretchFactor(myMainFrame, 1);
1931 myHelpFileName = "selection_filter_library_page.html";
1936 //=======================================================================
1937 // name : SMESHGUI_FilterDlg::createMainFrame
1938 // Purpose : Create frame containing dialog's input fields
1939 //=======================================================================
1940 QWidget* SMESHGUI_FilterDlg::createMainFrame (QWidget* theParent)
1942 QWidget* aMainFrame = new QWidget(theParent);
1943 QVBoxLayout* aMainLay = new QVBoxLayout(aMainFrame);
1944 aMainLay->setMargin(0);
1945 aMainLay->setSpacing(SPACING);
1949 myTable = new SMESHGUI_FilterTable( mySMESHGUI, aMainFrame, myTypes );
1950 myTable->SetLibsEnabled(true);
1952 QGroupBox* aGrp = myTable->GetTableGrp();
1953 QGridLayout* aLay = qobject_cast<QGridLayout*>( aGrp->layout() );
1954 int rows = aLay->rowCount();
1955 int cols = aLay->columnCount();
1957 QFrame* aLine = new QFrame(aGrp);
1958 aLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);
1959 aLay->addWidget(aLine, rows++, 0, 1, cols);
1961 mySetInViewer = new QCheckBox(tr("SET_IN_VIEWER"), aGrp);
1962 mySetInViewer->setChecked(true);
1963 aLay->addWidget(mySetInViewer, rows++, 0, 1, cols);
1966 QWidget* aSourceGrp = createSourceGroup(aMainFrame);
1968 connect(myTable, SIGNAL(CriterionChanged(const int, const int)),
1969 SLOT(onCriterionChanged(const int, const int)));
1971 connect(myTable, SIGNAL(CurrentChanged(int, int)),
1972 SLOT(onCurrentChanged(int, int)));
1974 aMainLay->addWidget(myTable);
1975 aMainLay->addWidget(aSourceGrp);
1980 //=======================================================================
1981 // name : SMESHGUI_FilterDlg::createSourceFrame
1982 // Purpose : Create frame containing source radio button
1983 //=======================================================================
1984 QWidget* SMESHGUI_FilterDlg::createSourceGroup (QWidget* theParent)
1986 QGroupBox* aBox = new QGroupBox(tr("SOURCE"), theParent);
1987 QHBoxLayout* aLay = new QHBoxLayout(aBox);
1988 aLay->setMargin(MARGIN);
1989 aLay->setSpacing(SPACING);
1991 mySourceGrp = new QButtonGroup(theParent);
1993 QRadioButton* aMeshBtn = new QRadioButton(tr("MESH"), aBox);
1994 QRadioButton* aSelBtn = new QRadioButton(tr("SELECTION"), aBox);
1995 QRadioButton* aGrpBtn = new QRadioButton(tr("CURRENT_GROUP"), aBox);
1997 aLay->addWidget(aMeshBtn);
1998 aLay->addWidget(aSelBtn);
1999 aLay->addWidget(aGrpBtn);
2001 mySourceGrp->addButton(aMeshBtn, Mesh);
2002 mySourceGrp->addButton(aSelBtn, Selection);
2003 mySourceGrp->addButton(aGrpBtn, Dialog);
2005 aSelBtn->setChecked(true);
2010 //=======================================================================
2011 // name : SMESHGUI_FilterDlg::updateMainButtons
2012 // Purpose : Update visibility of main buttons (OK, Cancel, Close ...)
2013 //=======================================================================
2014 void SMESHGUI_FilterDlg::updateMainButtons()
2016 if (myTypes.count() == 1)
2018 myButtons[ BTN_Cancel ]->show();
2019 myButtons[ BTN_Apply ]->hide();
2020 myButtons[ BTN_Close ]->hide();
2024 myButtons[ BTN_Cancel ]->hide();
2025 myButtons[ BTN_Apply ]->show();
2026 myButtons[ BTN_Close ]->show();
2029 // updateGeometry();
2032 //=======================================================================
2033 // name : SMESHGUI_FilterDlg::createButtonFrame
2034 // Purpose : Create frame containing buttons
2035 //=======================================================================
2036 QWidget* SMESHGUI_FilterDlg::createButtonFrame (QWidget* theParent)
2038 QGroupBox* aGrp = new QGroupBox(theParent);
2039 QHBoxLayout* aLay = new QHBoxLayout(aGrp);
2040 aLay->setMargin(MARGIN);
2041 aLay->setSpacing(SPACING);
2043 myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_OK" ), aGrp);
2044 myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp);
2045 myButtons[ BTN_Cancel ] = new QPushButton(tr("SMESH_BUT_CANCEL"), aGrp);
2046 myButtons[ BTN_Close ] = new QPushButton(tr("SMESH_BUT_CLOSE"), aGrp);
2047 myButtons[ BTN_Help ] = new QPushButton(tr("SMESH_BUT_HELP"), aGrp);
2049 aLay->addWidget(myButtons[ BTN_OK ]);
2050 aLay->addSpacing(10);
2051 aLay->addWidget(myButtons[ BTN_Apply ]);
2052 aLay->addSpacing(10);
2054 aLay->addWidget(myButtons[ BTN_Cancel ]);
2055 aLay->addWidget(myButtons[ BTN_Close ]);
2056 aLay->addWidget(myButtons[ BTN_Help ]);
2058 connect(myButtons[ BTN_OK ], SIGNAL(clicked()), SLOT(onOk()));
2059 connect(myButtons[ BTN_Cancel ], SIGNAL(clicked()), SLOT(onClose()));
2060 connect(myButtons[ BTN_Close ], SIGNAL(clicked()), SLOT(onClose()));
2061 connect(myButtons[ BTN_Apply ], SIGNAL(clicked()), SLOT(onApply()));
2062 connect(myButtons[ BTN_Help ], SIGNAL(clicked()), SLOT(onHelp()));
2064 updateMainButtons();
2069 //=======================================================================
2070 // name : SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg
2071 // Purpose : Destructor
2072 //=======================================================================
2073 SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg()
2077 //=======================================================================
2078 // name : SMESHGUI_FilterDlg::Init
2079 // Purpose : Init dialog fields, connect signals and slots, show dialog
2080 //=======================================================================
2081 void SMESHGUI_FilterDlg::Init (const int type)
2084 aTypes.append(type);
2088 //=======================================================================
2089 // name : SMESHGUI_FilterDlg::Init
2090 // Purpose : Init dialog fields, connect signals and slots, show dialog
2091 //=======================================================================
2092 void SMESHGUI_FilterDlg::Init (const QList<int>& theTypes)
2096 myMesh = SMESH::SMESH_Mesh::_nil();
2098 myIsSelectionChanged = false;
2100 myTable->Init(theTypes);
2103 if (theTypes.count() == 1)
2105 int aType = theTypes.first();
2106 if (aType == SMESH::NODE ) setWindowTitle(tr("NODES_TLT"));
2107 else if (aType == SMESH::EDGE ) setWindowTitle(tr("EDGES_TLT"));
2108 else if (aType == SMESH::FACE ) setWindowTitle(tr("FACES_TLT"));
2109 else if (aType == SMESH::VOLUME) setWindowTitle(tr("VOLUMES_TLT"));
2112 setWindowTitle(tr("TLT"));
2114 qApp->processEvents();
2119 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
2121 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
2122 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
2124 updateMainButtons();
2127 // Initialise filter table with values of previous filter
2128 QList<int>::const_iterator anIter;
2129 for (anIter = theTypes.begin(); anIter != theTypes.end(); ++anIter)
2131 myTable->Clear(*anIter);
2132 if (!myFilter[ *anIter ]->_is_nil())
2134 SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
2135 if (myFilter[ *anIter ]->GetCriteria(aCriteria))
2137 for (int i = 0, n = aCriteria->length(); i < n; i++)
2138 myTable->AddCriterion(aCriteria[ i ], *anIter);
2143 if (myInsertState.contains(theTypes.first()))
2144 mySetInViewer->setChecked(myInsertState[ theTypes.first() ]);
2146 mySetInViewer->setChecked(true);
2148 mySourceGrp->button(myApplyToState.contains(theTypes.first()) ?
2149 myApplyToState[ theTypes.first() ] :
2150 Selection)->setChecked(true);
2153 //=======================================================================
2154 // name : SMESHGUI_FilterDlg::onOk
2155 // Purpose : SLOT called when "Ok" button pressed.
2156 // Assign filters VTK viewer and close dialog
2157 //=======================================================================
2158 void SMESHGUI_FilterDlg::onOk()
2162 mySelectionMgr->clearFilters();
2163 disconnect(mySMESHGUI, 0, this, 0);
2164 disconnect(mySelectionMgr, 0, this, 0);
2165 mySMESHGUI->ResetState();
2171 //=======================================================================
2172 // name : SMESHGUI_FilterDlg::onClose
2173 // Purpose : SLOT called when "Close" button pressed. Close dialog
2174 //=======================================================================
2175 void SMESHGUI_FilterDlg::onClose()
2177 // Restore previously selected object
2180 SALOME_ListIO aList;
2181 mySelectionMgr->clearFilters();
2182 mySelectionMgr->clearSelected();
2183 SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter (myIObjects);
2184 for ( ; anIter.More(); anIter.Next())
2186 aList.Append(anIter.Key());
2188 TColStd_MapOfInteger aResMap;
2189 const TColStd_IndexedMapOfInteger& anIndMap = anIter.Value();
2190 for (int i = 1, n = anIndMap.Extent(); i <= n; i++)
2191 aResMap.Add(anIndMap(i));
2193 mySelector->AddOrRemoveIndex( anIter.Key(), aResMap, false);
2194 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
2195 aViewWindow->highlight( anIter.Key(), true, true );
2197 mySelectionMgr->setSelectedObjects(aList, false);
2200 disconnect(mySMESHGUI, 0, this, 0);
2201 disconnect(mySelectionMgr, 0, this, 0);
2202 mySMESHGUI->ResetState();
2207 //=================================================================================
2208 // function : onHelp()
2210 //=================================================================================
2211 void SMESHGUI_FilterDlg::onHelp()
2213 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
2215 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
2219 platform = "winapplication";
2221 platform = "application";
2223 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
2224 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
2225 arg(app->resourceMgr()->stringValue("ExternalBrowser",
2227 arg(myHelpFileName));
2231 //=======================================================================
2232 // name : SMESHGUI_FilterDlg::onDeactivate
2233 // Purpose : SLOT called when dialog must be deativated
2234 //=======================================================================
2235 void SMESHGUI_FilterDlg::onDeactivate()
2240 //=======================================================================
2241 // name : SMESHGUI_FilterDlg::enterEvent
2242 // Purpose : Event filter
2243 //=======================================================================
2244 void SMESHGUI_FilterDlg::enterEvent (QEvent*)
2246 // mySMESHGUI->EmitSignalDeactivateDialog();
2247 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
2248 mySMESHGUI->ResetState();
2252 //=======================================================================
2253 // name : closeEvent()
2255 //=======================================================================
2256 void SMESHGUI_FilterDlg::closeEvent (QCloseEvent*)
2261 //=======================================================================
2262 // name : SMESHGUI_FilterDlg::getIdsFromWg
2263 // Purpose : Retrieve list of ids from given widget
2264 //=======================================================================
2265 void SMESHGUI_FilterDlg::getIdsFromWg (const QWidget* theWg, QList<int>& theRes) const
2271 if (theWg->inherits("QListWidget"))
2273 const QListWidget* aListBox = qobject_cast<const QListWidget*>( theWg );
2275 for (int i = 0, n = aListBox->count(); i < n; i++)
2277 int anId = aListBox->item(i)->text().toInt(&b);
2279 theRes.append(anId);
2282 else if (theWg->inherits("QLineEdit"))
2284 const QLineEdit* aLineEdit = qobject_cast<const QLineEdit*>( theWg );
2285 QString aStr = aLineEdit->text();
2286 QRegExp aRegExp("(\\d+)");
2291 aPos = aRegExp.indexIn(aStr, aPos);
2294 int anId = aRegExp.cap(1).toInt(&b);
2296 theRes.append(anId);
2297 aPos += aRegExp.matchedLength();
2303 //=======================================================================
2304 // name : SMESHGUI_FilterDlg::getSelMode
2305 // Purpose : Get selection mode of specified type
2306 //=======================================================================
2307 Selection_Mode SMESHGUI_FilterDlg::getSelMode (const int theType) const
2311 case SMESH::NODE : return NodeSelection;
2312 case SMESH::EDGE : return EdgeSelection;
2313 case SMESH::FACE : return FaceSelection;
2314 case SMESH::VOLUME : return VolumeSelection;
2315 default : return ActorSelection;
2320 //=======================================================================
2321 // name : SMESHGUI_FilterDlg::setIdsToWg
2322 // Purpose : Insert identifiers in specified widgets
2323 //=======================================================================
2324 void SMESHGUI_FilterDlg::setIdsToWg (QWidget* theWg, const QList<int>& theIds)
2329 if (theWg->inherits("QListWidget"))
2331 QListWidget* aListBox = qobject_cast<QListWidget*>( theWg );
2334 QStringList aStrList;
2335 QList<int>::const_iterator anIter;
2336 for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter)
2337 aStrList.append(QString("%1").arg(*anIter));
2339 aListBox->addItems(aStrList);
2341 else if (theWg->inherits("QLineEdit"))
2343 QLineEdit* aLineEdit = qobject_cast<QLineEdit*>( theWg );
2345 QList<int>::const_iterator anIter;
2347 for (anIter = theIds.begin(); anIter != theIds.end(); ++ anIter)
2348 aStr += QString("%1 ").arg(*anIter);
2350 if (!aStr.isEmpty())
2351 aStr.remove(aStr.length() - 1, 1);
2353 aLineEdit->setText(aStr);
2357 //=======================================================================
2358 // name : SMESHGUI_FilterDlg::isValid
2359 // Purpose : Verify validity of input data
2360 //=======================================================================
2361 bool SMESHGUI_FilterDlg::isValid() const
2363 if (!myTable->IsValid())
2366 for (int i = 0, n = myTable->NumRows(); i < n; i++)
2368 int aType = myTable->GetCriterionType(i);
2369 if (aType == SMESH::FT_BelongToGeom ||
2370 aType == SMESH::FT_BelongToPlane ||
2371 aType == SMESH::FT_BelongToCylinder ||
2372 aType == SMESH::FT_BelongToGenSurface ||
2373 aType == SMESH::FT_LyingOnGeom) {
2375 myTable->GetThreshold(i, aName);
2377 std::vector<_PTR(SObject)> aList =
2378 SMESH::GetActiveStudyDocument()->FindObjectByName(aName.toLatin1().data(), "GEOM");
2379 if (aList.size() == 0) {
2380 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2381 tr("BAD_SHAPE_NAME").arg(aName));
2385 if (aType == SMESH::FT_BelongToCylinder ||
2386 aType == SMESH::FT_BelongToPlane ||
2387 aType == SMESH::FT_BelongToGenSurface ) {
2388 CORBA::Object_var anObject = SMESH::SObjectToObject(aList[ 0 ]);
2389 //GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(aList[ 0 ]->GetObject());
2390 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObject);
2391 if (!aGeomObj->_is_nil()) {
2393 if (!GEOMBase::GetShape(aGeomObj, aFace) ||
2395 aFace.ShapeType() != TopAbs_FACE) {
2396 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2397 tr("SHAPE_IS_NOT_A_FACE").arg(aName));
2401 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace));
2402 if (aSurf.IsNull()) {
2403 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2404 tr("SHAPE_IS_NOT_A_FACE").arg(aName));
2408 if (aType == SMESH::FT_BelongToPlane && !aSurf->IsKind(STANDARD_TYPE(Geom_Plane))) {
2409 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2410 tr("SHAPE_IS_NOT_A_PLANE").arg(aName));
2414 if (aType == SMESH::FT_BelongToCylinder && !aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
2415 SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
2416 tr("SHAPE_IS_NOT_A_CYLINDER").arg(aName));
2427 //=======================================================================
2428 // name : SMESHGUI_FilterDlg::SetSourceWg
2429 // Purpose : Set widget of parent dialog containing idsto be filtered if
2430 // user select corresponding source radio button
2431 //=======================================================================
2432 void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg)
2437 //=======================================================================
2438 // name : SMESHGUI_FilterDlg::SetGroupIds
2439 // Purpose : Set mesh
2440 //=======================================================================
2441 void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_ptr theMesh)
2446 //=======================================================================
2447 // name : SMESHGUI_FilterDlg::SetSelection
2448 // Purpose : Get filtered ids
2449 //=======================================================================
2450 void SMESHGUI_FilterDlg::SetSelection()
2453 disconnect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone()));
2455 if (mySelectionMgr) {
2457 const SALOME_ListIO& anObjs = mySelector->StoredIObjects();
2458 SALOME_ListIteratorOfListIO anIter (anObjs);
2459 for ( ; anIter.More(); anIter.Next()) {
2460 TColStd_IndexedMapOfInteger aMap;
2461 mySelector->GetIndex(anIter.Value(), aMap);
2462 myIObjects.Bind(anIter.Value(), aMap);
2465 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
2473 //=======================================================================
2474 // name : SMESHGUI_FilterDlg::onApply
2475 // Purpose : SLOT called when "Apply" button pressed.
2476 // Assign filters to VTK viewer
2477 //=======================================================================
2478 bool SMESHGUI_FilterDlg::onApply()
2484 int aCurrType = myTable->GetType();
2486 if (!createFilter(aCurrType))
2489 insertFilterInViewer();
2491 if (!myFilter[ aCurrType ]->GetPredicate()->_is_nil()) {
2492 QList<int> aResultIds;
2493 filterSource(aCurrType, aResultIds);
2494 selectInViewer(aCurrType, aResultIds);
2497 myInsertState[ aCurrType ] = mySetInViewer->isChecked();
2498 myApplyToState[ aCurrType ] = mySourceGrp->checkedId();
2500 catch(const SALOME::SALOME_Exception& S_ex)
2502 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2511 //=======================================================================
2512 // name : SMESHGUI_FilterDlg::createFilter
2513 // Purpose : Create predicate for given type
2514 //=======================================================================
2515 bool SMESHGUI_FilterDlg::createFilter (const int theType)
2517 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
2518 if (aFilterMgr->_is_nil())
2521 int n = myTable->NumRows();
2523 SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
2524 aCriteria->length(n);
2526 long aPrecision = -1;
2527 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
2529 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
2530 aPrecision = mgr->integerValue( "SMESH", "controls_precision", aPrecision );
2532 for (CORBA::ULong i = 0; i < n; i++) {
2533 SMESH::Filter::Criterion aCriterion = createCriterion();
2534 myTable->GetCriterion(i, aCriterion);
2535 aCriterion.Precision = aPrecision;
2536 aCriteria[ i ] = aCriterion;
2539 myFilter[ theType ] = aFilterMgr->CreateFilter();
2540 myFilter[ theType ]->SetCriteria(aCriteria.inout());
2545 //=======================================================================
2546 // name : SMESHGUI_FilterDlg::insertFilterInViewer
2547 // Purpose : Insert filter in viewer
2548 //=======================================================================
2549 void SMESHGUI_FilterDlg::insertFilterInViewer()
2551 if (SVTK_Selector* aSelector = SMESH::GetSelector()) {
2552 SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType();
2554 if (myFilter[ myTable->GetType() ]->_is_nil() ||
2555 myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() ||
2556 !mySetInViewer->isChecked()) {
2557 SMESH::RemoveFilter(getFilterId(anEntType), aSelector);
2560 Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter();
2561 aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate());
2562 SMESH::RemoveFilter(getFilterId(anEntType), aSelector); //skl for IPAL12631
2563 SMESH::SetFilter(aFilter, aSelector);
2568 //=======================================================================
2569 // name : SMESHGUI_FilterDlg::filterSource
2570 // Purpose : Filter source ids
2571 //=======================================================================
2572 void SMESHGUI_FilterDlg::filterSource (const int theType,
2573 QList<int>& theResIds)
2576 if (myFilter[ theType ]->_is_nil())
2579 int aSourceId = mySourceGrp->checkedId();
2581 if (aSourceId == Mesh)
2583 if (myMesh->_is_nil())
2585 SMESH::long_array_var anIds = myFilter[ theType ]->GetElementsId(myMesh);
2586 for (int i = 0, n = anIds->length(); i < n; i++)
2587 theResIds.append(anIds[ i ]);
2589 else if (aSourceId == Selection)
2591 filterSelectionSource(theType, theResIds);
2593 else if (aSourceId == Dialog)
2595 // retrieve ids from dialog
2596 QList<int> aDialogIds;
2597 getIdsFromWg(mySourceWg, aDialogIds);
2599 if (myMesh->_is_nil())
2601 theResIds = aDialogIds;
2606 SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate();
2607 aPred->SetMesh(myMesh);
2608 QList<int>::const_iterator anIter;
2609 for (anIter = aDialogIds.begin(); anIter != aDialogIds.end(); ++ anIter)
2610 if (aPred->IsSatisfy(*anIter))
2611 theResIds.append(*anIter);
2613 // set ids to the dialog
2614 setIdsToWg(mySourceWg, theResIds);
2618 //=======================================================================
2619 // name : SMESHGUI_FilterDlg::filterSelectionSource
2620 // Purpose : Filter source selection
2621 //=======================================================================
2622 void SMESHGUI_FilterDlg::filterSelectionSource (const int theType,
2623 QList<int>& theResIds)
2626 if (myMesh->_is_nil() || mySelectionMgr == 0)
2629 // Create map of entities to be filtered
2630 TColStd_MapOfInteger aToBeFiltered;
2631 SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter(myIObjects);
2633 for ( ; anIter.More(); anIter.Next())
2636 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIter.Key());
2637 if (!aSubMesh->_is_nil())
2639 if (aSubMesh->GetFather()->GetId() == myMesh->GetId())
2641 SMESH::long_array_var anIds =
2642 theType == SMESH::NODE ? aSubMesh->GetNodesId() : aSubMesh->GetElementsId();
2643 for (int i = 0, n = anIds->length(); i < n; i++)
2644 aToBeFiltered.Add(anIds[ i ]);
2649 SMESH::SMESH_GroupBase_var aGroup =
2650 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Key());
2651 if (!aGroup->_is_nil())
2653 if (aGroup->GetType() == theType && aGroup->GetMesh()->GetId() == myMesh->GetId())
2655 SMESH::long_array_var anIds = aGroup->GetListOfID();
2656 for (int i = 0, n = anIds->length(); i < n; i++)
2657 aToBeFiltered.Add(anIds[ i ]);
2662 SMESH::SMESH_Mesh_var aMeshPtr = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIter.Key());
2663 if (!aMeshPtr->_is_nil() && aMeshPtr->GetId() == myMesh->GetId())
2665 const TColStd_IndexedMapOfInteger& aSelMap = anIter.Value();
2667 if (aSelMap.Extent() > 0)
2669 if(SMESH::FindActorByEntry(anIter.Key()->getEntry()))
2671 for (int i = 1; i <= aSelMap.Extent(); i++)
2672 aToBeFiltered.Add(aSelMap(i));
2679 SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate();
2680 aPred->SetMesh(myMesh);
2681 TColStd_MapIteratorOfMapOfInteger aResIter(aToBeFiltered);
2682 for ( ; aResIter.More(); aResIter.Next())
2683 if (aPred->IsSatisfy(aResIter.Key()))
2684 theResIds.append(aResIter.Key());
2687 //=======================================================================
2688 // name : SMESHGUI_FilterDlg::selectInViewer
2689 // Purpose : Select given entities in viewer
2690 //=======================================================================
2691 void SMESHGUI_FilterDlg::selectInViewer (const int theType, const QList<int>& theIds)
2693 if (mySelectionMgr == 0 || myMesh->_is_nil())
2696 mySelectionMgr->clearFilters();
2698 // Set new selection mode if necessary
2699 Selection_Mode aSelMode = getSelMode(theType);
2700 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
2701 if ( aViewWindow && aViewWindow->SelectionMode()!=aSelMode) {
2702 mySelectionMgr->clearSelected();
2703 mySelectionMgr->clearFilters();
2704 if (aSelMode == NodeSelection)
2705 SMESH::SetPointRepresentation(true);
2706 aViewWindow->SetSelectionMode(aSelMode);
2710 SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
2711 if (!anActor || !anActor->hasIO())
2714 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
2715 //mySelectionMgr->clearSelected();
2716 //mySelectionMgr->AddIObject(anIO, false);
2717 SALOME_ListIO aList;
2719 mySelectionMgr->setSelectedObjects(aList, false);
2721 // Remove filter corresponding to the current type from viewer
2722 int aType = myTable->GetType();
2723 int aFilterId = SMESH::UnknownFilter;
2724 if (aType == SMESH::EDGE ) aFilterId = SMESH::EdgeFilter;
2725 else if (aType == SMESH::FACE ) aFilterId = SMESH::FaceFilter;
2726 else if (aType == SMESH::VOLUME) aFilterId = SMESH::VolumeFilter;
2727 Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter(aFilterId);
2728 SMESH::RemoveFilter(aFilterId);
2731 TColStd_MapOfInteger aMap;
2732 QList<int>::const_iterator anIter;
2733 for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
2737 // Set new selection
2738 mySelector->AddOrRemoveIndex(anIO, aMap, false);
2739 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
2740 aViewWindow->highlight( anIO, true, true );
2742 // insert previously stored filter in viewer if necessary
2743 if (!aFilter.IsNull())
2744 SMESH::SetFilter(aFilter);
2747 //=======================================================================
2748 // name : SMESHGUI_FilterDlg::createCriterion
2749 // Purpose : Create criterion structure with default values
2750 //=======================================================================
2751 SMESH::Filter::Criterion SMESHGUI_FilterDlg::createCriterion()
2753 SMESH::Filter::Criterion aCriterion;
2755 aCriterion.Type = SMESH::FT_Undefined;
2756 aCriterion.Compare = SMESH::FT_Undefined;
2757 aCriterion.Threshold = 0;
2758 aCriterion.UnaryOp = SMESH::FT_Undefined;
2759 aCriterion.BinaryOp = SMESH::FT_Undefined;
2760 aCriterion.ThresholdStr = "";
2761 aCriterion.ThresholdID = "";
2762 aCriterion.TypeOfElement = SMESH::ALL;
2767 //=======================================================================
2768 // name : SMESHGUI_FilterDlg::onSelectionDone
2769 // Purpose : SLOT called when selection changed.
2770 // If current cell corresponds to the threshold value of
2771 // BelongToGeom criterion name of selected object is set in this cell
2772 //=======================================================================
2773 void SMESHGUI_FilterDlg::onSelectionDone()
2776 const SALOME_ListIO& aList = mySelector->StoredIObjects();
2778 if (aList.Extent() != 1 ||
2779 !myTable->CurrentCell(aRow, aCol) ||
2780 myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGeom &&
2781 myTable->GetCriterionType(aRow) != SMESH::FT_BelongToPlane &&
2782 myTable->GetCriterionType(aRow) != SMESH::FT_BelongToCylinder &&
2783 myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGenSurface &&
2784 myTable->GetCriterionType(aRow) != SMESH::FT_LyingOnGeom)
2787 Handle(SALOME_InteractiveObject) anIO = aList.First();
2788 GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
2789 if (!anObj->_is_nil())
2791 myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
2792 //myTable->SetID( aRow, GEOMBase::GetIORFromObject(anObj));
2793 myTable->SetID(aRow, anIO->getEntry());
2797 //=======================================================================
2798 // name : SMESHGUI_FilterDlg::onCriterionChanged
2799 // Purpose : SLOT called when cretarion of current row changed. Update selection
2800 //=======================================================================
2801 void SMESHGUI_FilterDlg::onCriterionChanged (const int, const int)
2806 //=======================================================================
2807 // name : SMESHGUI_FilterDlg::onCurrentChanged
2808 // Purpose : SLOT called when current row changed. Update selection
2809 //=======================================================================
2810 void SMESHGUI_FilterDlg::onCurrentChanged (int, int)
2815 //=======================================================================
2816 // name : SMESHGUI_FilterDlg::updateSelection
2817 // Purpose : UpdateSelection in accordance with current row
2818 //=======================================================================
2819 void SMESHGUI_FilterDlg::updateSelection()
2821 if (mySelectionMgr == 0)
2824 TColStd_MapOfInteger allTypes;
2825 for( int i=0; i<10; i++ )
2827 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
2832 mySelectionMgr->clearFilters();
2836 if (myTable->CurrentCell(aRow, aCol) &&
2837 (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGeom ||
2838 myTable->GetCriterionType(aRow) == SMESH::FT_BelongToPlane ||
2839 myTable->GetCriterionType(aRow) == SMESH::FT_BelongToCylinder ||
2840 myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGenSurface ||
2841 myTable->GetCriterionType(aRow) == SMESH::FT_LyingOnGeom)) {
2843 if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGeom ||
2844 myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGenSurface ||
2845 myTable->GetCriterionType(aRow) == SMESH::FT_LyingOnGeom) {
2847 mySelectionMgr->installFilter(new GEOM_SelectionFilter( aStudy, true ));
2849 } else if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToPlane) {
2850 mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) );
2852 } else if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToCylinder) {
2853 mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Cylinder ) );
2855 myIsSelectionChanged = true;
2858 if (myIsSelectionChanged) {
2859 mySelectionMgr->installFilter( new GEOM_TypeFilter( aStudy, -1 ) ); // This filter deactivates selection
2864 //=================================================================================
2865 // function : keyPressEvent()
2867 //=================================================================================
2868 void SMESHGUI_FilterDlg::keyPressEvent( QKeyEvent* e )
2870 QDialog::keyPressEvent( e );
2871 if ( e->isAccepted() )
2874 if ( e->key() == Qt::Key_F1 ) {