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;
190 SMESHGUI_FilterLibraryDlg* myLibDlg;
192 QWidgetStack* myWgStack;
193 QMap<QTableItem*, AdditionalWidget*> myAddWidgets;
198 Class : SMESHGUI_FilterDlg
199 Description : Dialog to specify filters for VTK viewer
202 class SMESHGUI_FilterDlg : public QDialog
206 // Source elements to be selected
207 enum { Mesh, Selection, Dialog, None };
210 enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close };
213 SMESHGUI_FilterDlg( QWidget* parent,
214 const QValueList<int>& types,
215 const char* name = 0 );
217 SMESHGUI_FilterDlg( QWidget* parent,
219 const char* name = 0 );
220 virtual ~SMESHGUI_FilterDlg();
222 void Init( const QValueList<int>& types );
223 void Init( const int type );
225 void SetSelection( SALOME_Selection* );
226 void SetMesh( SMESH::SMESH_Mesh_ptr );
227 void SetSourceWg( QWidget* );
229 static SMESH::Filter::Criterion createCriterion();
241 void onSelectionDone();
242 void onCriterionChanged( const int, const int );
243 void onCurrentChanged( int, int );
247 void construct( const QValueList<int>& types );
249 void closeEvent( QCloseEvent* e );
250 void enterEvent ( QEvent * );
253 QFrame* createButtonFrame( QWidget* );
254 QFrame* createMainFrame( QWidget* );
255 QButtonGroup* createSourceGroup( QWidget* );
256 void updateMainButtons();
259 bool isValid() const;
260 bool createFilter( const int theType );
261 void insertFilterInViewer();
262 void selectInViewer( const int theType,
263 const QValueList<int>& theIds );
264 void filterSource( const int theType,
265 QValueList<int>& theResIds );
266 void filterSelectionSource( const int theType,
267 QValueList<int>& theResIds );
268 void getIdsFromWg( const QWidget*, QValueList<int>& ) const;
269 void setIdsToWg( QWidget*, const QValueList<int>& );
270 Selection_Mode getSelMode( const int ) const;
271 void updateSelection();
277 QButtonGroup* mySourceGrp;
279 QCheckBox* mySetInViewer;
281 QMap<int, QPushButton*> myButtons;
283 SMESHGUI_FilterTable* myTable;
286 QValueList<int> myTypes;
287 SMESHGUI* mySMESHGUI;
288 SALOME_Selection* mySelection;
289 SMESH::SMESH_Mesh_ptr myMesh;
292 SALOME_DataMapOfIOMapOfInteger myIObjects;
293 bool myIsSelectionChanged;
294 QMap< int, SMESH::Filter_var > myFilter;
295 QMap< int, bool > myInsertState;
296 QMap< int, int > myApplyToState;