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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHGUI_FilterDlg.h
25 // Author : Sergey LITONIN
29 #ifndef SMESHGUI_FilterDlg_H
30 #define SMESHGUI_FilterDlg_H
35 #include <qvaluelist.h>
37 #include "SALOME_Selection.h"
38 #include "SALOME_InteractiveObject.hxx"
39 #include "SALOME_DataMapOfIOMapOfInteger.hxx"
41 #include <TColStd_IndexedMapOfInteger.hxx>
43 #include <SALOMEconfig.h>
44 #include CORBA_SERVER_HEADER(SMESH_Filter)
45 #include CORBA_SERVER_HEADER(SMESH_Mesh)
58 class SALOME_Selection;
60 class SMESHGUI_FilterLibraryDlg;
63 Class : SMESHGUI_FilterTable
64 Description : Frame containig
65 - Button group for switching entity type
66 - Table for displaying filter criterions
67 - Buttons for editing table
70 class SMESHGUI_FilterTable : public QFrame
76 class AdditionalWidget;
78 typedef QMap<int, Table*> TableMap;
82 SMESHGUI_FilterTable( QWidget* parent,
84 SMESHGUI_FilterTable( QWidget* parent,
85 const QValueList<int>& type );
86 virtual ~SMESHGUI_FilterTable();
88 void Init( const int type );
89 void Init( const QValueList<int>& types );
91 QGroupBox* GetTableGrp();
93 bool IsValid( const bool = true, const int theEntityType = -1 ) const;
95 void SetType( const int );
96 void RestorePreviousEntityType();
97 int NumRows( const int theEntityType = -1 ) const;
98 void Clear( const int theEntityType = -1 );
99 void SetEditable( const bool );
100 void SetEnabled( const bool );
101 void SetLibsEnabled( const bool );
102 bool IsEditable() const;
104 int GetCriterionType( const int theRow, const int theType = -1 ) const;
106 void GetCriterion( const int theRow,
107 SMESH::Filter::Criterion& theCriterion,
108 const int theEntityType = -1 ) const;
110 void SetCriterion( const int theRow,
111 const SMESH::Filter::Criterion& theCriterion,
112 const int theEntityType = -1 );
114 void AddCriterion( const SMESH::Filter::Criterion& theCriterion,
115 const int theEntityType = -1 );
117 void Copy( const SMESHGUI_FilterTable* );
118 void SetValidity( const bool );
120 bool CurrentCell( int& theRow, int& theCol ) const;
121 void SetThreshold( const int theRow,
122 const QString& theText,
123 const int theEntityType = -1 );
125 bool GetThreshold( const int theRow,
127 const int theEntityType = -1 );
129 void SetID( const int theRow,
130 const QString& theText,
131 const int theEntityType = -1 );
133 bool GetID( const int theRow,
135 const int theEntityType = -1 );
142 void CopyFromClicked();
144 void EntityTypeChanged( const int );
145 void NeedValidation();
146 void CretarionChanged( const int theRow, const int theEntityType );
147 void CurrentChanged( int, int );
155 void onCopyFromBtn();
157 void onCriterionChanged( int, int );
158 void onEntityType( int );
159 void onCurrentChanged( int, int );
163 void addRow( Table*, const int, const bool toTheEnd = true );
164 QTableItem* getCriterionItem( QTable*, const int );
165 QTableItem* getCompareItem( QTable* );
166 QTableItem* getUnaryItem( QTable* );
167 QTableItem* getBinaryItem( QTable* );
168 const QMap<int, QString>& getCriteria( const int theType ) const;
169 const QMap<int, QString>& getCompare() const;
170 Table* createTable( QWidget*, const int );
171 QWidget* createAdditionalFrame( QWidget* theParent );
172 int getFirstSelectedRow() const;
173 void onCriterionChanged( const int, const int, const int );
175 void updateBtnState();
176 void removeAdditionalWidget( QTable* theTable, const int theRow );
177 void updateAdditionalWidget();
179 const QMap<int, QString>& getSupportedTypes() const;
183 QGroupBox* myTableGrp;
184 QGroupBox* mySwitchTableGrp;
187 QPushButton* myAddBtn;
188 QPushButton* myInsertBtn;
189 QPushButton* myRemoveBtn;
190 QPushButton* myClearBtn;
191 QPushButton* myCopyFromBtn;
192 QPushButton* myAddToBtn;
194 QButtonGroup* myEntityTypeGrp;
199 SMESHGUI_FilterLibraryDlg* myLibDlg;
201 QWidgetStack* myWgStack;
202 QMap<QTableItem*, AdditionalWidget*> myAddWidgets;
207 Class : SMESHGUI_FilterDlg
208 Description : Dialog to specify filters for VTK viewer
211 class SMESHGUI_FilterDlg : public QDialog
215 // Source elements to be selected
216 enum { Mesh, Selection, Dialog, None };
219 enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close };
222 SMESHGUI_FilterDlg( QWidget* parent,
223 const QValueList<int>& types,
224 const char* name = 0 );
226 SMESHGUI_FilterDlg( QWidget* parent,
228 const char* name = 0 );
229 virtual ~SMESHGUI_FilterDlg();
231 void Init( const QValueList<int>& types );
232 void Init( const int type );
234 void SetSelection( SALOME_Selection* );
235 void SetMesh( SMESH::SMESH_Mesh_ptr );
236 void SetSourceWg( QWidget* );
238 static SMESH::Filter::Criterion createCriterion();
250 void onSelectionDone();
251 void onCriterionChanged( const int, const int );
252 void onCurrentChanged( int, int );
256 void construct( const QValueList<int>& types );
258 void closeEvent( QCloseEvent* e );
259 void enterEvent ( QEvent * );
262 QFrame* createButtonFrame( QWidget* );
263 QFrame* createMainFrame( QWidget* );
264 QButtonGroup* createSourceGroup( QWidget* );
265 void updateMainButtons();
268 bool isValid() const;
269 bool createFilter( const int theType );
270 void insertFilterInViewer();
271 void selectInViewer( const int theType,
272 const QValueList<int>& theIds );
273 void filterSource( const int theType,
274 QValueList<int>& theResIds );
275 void filterSelectionSource( const int theType,
276 QValueList<int>& theResIds );
277 void getIdsFromWg( const QWidget*, QValueList<int>& ) const;
278 void setIdsToWg( QWidget*, const QValueList<int>& );
279 Selection_Mode getSelMode( const int ) const;
280 void updateSelection();
286 QButtonGroup* mySourceGrp;
288 QCheckBox* mySetInViewer;
290 QMap<int, QPushButton*> myButtons;
292 SMESHGUI_FilterTable* myTable;
295 QValueList<int> myTypes;
296 SMESHGUI* mySMESHGUI;
297 SALOME_Selection* mySelection;
298 SMESH::SMESH_Mesh_ptr myMesh;
301 SALOME_DataMapOfIOMapOfInteger myIObjects;
302 bool myIsSelectionChanged;
303 QMap< int, SMESH::Filter_var > myFilter;
304 QMap< int, bool > myInsertState;
305 QMap< int, int > myApplyToState;