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 );
134 void CopyFromClicked();
136 void EntityTypeChanged( const int );
137 void NeedValidation();
138 void CretarionChanged( const int theRow, const int theEntityType );
139 void CurrentChanged( int, int );
147 void onCopyFromBtn();
149 void onCriterionChanged( int, int );
150 void onEntityType( int );
151 void onCurrentChanged( int, int );
155 void addRow( Table*, const int, const bool toTheEnd = true );
156 QTableItem* getCriterionItem( QTable*, const int );
157 QTableItem* getCompareItem( QTable* );
158 QTableItem* getUnaryItem( QTable* );
159 QTableItem* getBinaryItem( QTable* );
160 const QMap<int, QString>& getCriteria( const int theType ) const;
161 const QMap<int, QString>& getCompare() const;
162 Table* createTable( QWidget*, const int );
163 QWidget* createAdditionalFrame( QWidget* theParent );
164 int getFirstSelectedRow() const;
165 void onCriterionChanged( const int, const int, const int );
167 void updateBtnState();
168 void removeAdditionalWidget( QTable* theTable, const int theRow );
169 void updateAdditionalWidget();
171 const QMap<int, QString>& getSupportedTypes() const;
175 QGroupBox* myTableGrp;
176 QGroupBox* mySwitchTableGrp;
179 QPushButton* myAddBtn;
180 QPushButton* myInsertBtn;
181 QPushButton* myRemoveBtn;
182 QPushButton* myClearBtn;
183 QPushButton* myCopyFromBtn;
184 QPushButton* myAddToBtn;
186 QButtonGroup* myEntityTypeGrp;
191 SMESHGUI_FilterLibraryDlg* myLibDlg;
193 QWidgetStack* myWgStack;
194 QMap<QTableItem*, AdditionalWidget*> myAddWidgets;
199 Class : SMESHGUI_FilterDlg
200 Description : Dialog to specify filters for VTK viewer
203 class SMESHGUI_FilterDlg : public QDialog
207 // Source elements to be selected
208 enum { Mesh, Selection, Dialog, None };
211 enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close };
214 SMESHGUI_FilterDlg( QWidget* parent,
215 const QValueList<int>& types,
216 const char* name = 0 );
218 SMESHGUI_FilterDlg( QWidget* parent,
220 const char* name = 0 );
221 virtual ~SMESHGUI_FilterDlg();
223 void Init( const QValueList<int>& types );
224 void Init( const int type );
226 void SetSelection( SALOME_Selection* );
227 void SetMesh( SMESH::SMESH_Mesh_ptr );
228 void SetSourceWg( QWidget* );
230 static SMESH::Filter::Criterion createCriterion();
242 void onSelectionDone();
243 void onCriterionChanged( const int, const int );
244 void onCurrentChanged( int, int );
248 void construct( const QValueList<int>& types );
250 void closeEvent( QCloseEvent* e );
251 void enterEvent ( QEvent * );
254 QFrame* createButtonFrame( QWidget* );
255 QFrame* createMainFrame( QWidget* );
256 QButtonGroup* createSourceGroup( QWidget* );
257 void updateMainButtons();
260 bool isValid() const;
261 bool createFilter( const int theType );
262 void insertFilterInViewer();
263 void selectInViewer( const int theType,
264 const QValueList<int>& theIds );
265 void filterSource( const int theType,
266 QValueList<int>& theResIds );
267 void filterSelectionSource( const int theType,
268 QValueList<int>& theResIds );
269 void getIdsFromWg( const QWidget*, QValueList<int>& ) const;
270 void setIdsToWg( QWidget*, const QValueList<int>& );
271 Selection_Mode getSelMode( const int ) const;
272 void updateSelection();
278 QButtonGroup* mySourceGrp;
280 QCheckBox* mySetInViewer;
282 QMap<int, QPushButton*> myButtons;
284 SMESHGUI_FilterTable* myTable;
287 QValueList<int> myTypes;
288 SMESHGUI* mySMESHGUI;
289 SALOME_Selection* mySelection;
290 SMESH::SMESH_Mesh_ptr myMesh;
293 SALOME_DataMapOfIOMapOfInteger myIObjects;
294 bool myIsSelectionChanged;
295 QMap< int, SMESH::Filter_var > myFilter;
296 QMap< int, bool > myInsertState;
297 QMap< int, int > myApplyToState;