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 "SalomeApp_SelectionMgr.h"
38 #include "SALOME_InteractiveObject.hxx"
39 #include "SALOME_DataMapOfIOMapOfInteger.hxx"
40 #include "SVTK_Selection.h"
42 #include <TColStd_IndexedMapOfInteger.hxx>
44 #include <SALOMEconfig.h>
45 #include CORBA_SERVER_HEADER(SMESH_Filter)
46 #include CORBA_SERVER_HEADER(SMESH_Mesh)
59 class SalomeApp_SelectionMgr;
61 class SMESHGUI_FilterLibraryDlg;
63 class SVTK_ViewWindow;
66 * Class : SMESHGUI_FilterTable
67 * Description : Frame containig
68 * - Button group for switching entity type
69 * - Table for displaying filter criterions
70 * - Buttons for editing table
73 class SMESHGUI_FilterTable : public QFrame
79 class AdditionalWidget;
81 typedef QMap<int, Table*> TableMap;
84 SMESHGUI_FilterTable (QWidget* parent,
86 SMESHGUI_FilterTable (QWidget* parent,
87 const QValueList<int>& type);
88 virtual ~SMESHGUI_FilterTable();
90 void Init (const int type);
91 void Init (const QValueList<int>& types);
93 QGroupBox* GetTableGrp();
95 bool IsValid (const bool = true, const int theEntityType = -1) const;
97 void SetType (const int);
98 void RestorePreviousEntityType();
99 int NumRows (const int theEntityType = -1) const;
100 void Clear (const int theEntityType = -1);
101 void SetEditable (const bool);
102 void SetEnabled (const bool);
103 void SetLibsEnabled (const bool);
104 bool IsEditable() const;
106 int GetCriterionType (const int theRow, const int theType = -1) const;
108 void GetCriterion (const int theRow,
109 SMESH::Filter::Criterion& theCriterion,
110 const int theEntityType = -1) const;
112 void SetCriterion (const int theRow,
113 const SMESH::Filter::Criterion& theCriterion,
114 const int theEntityType = -1);
116 void AddCriterion (const SMESH::Filter::Criterion& theCriterion,
117 const int theEntityType = -1);
119 void Copy (const SMESHGUI_FilterTable*);
120 void SetValidity (const bool);
122 bool CurrentCell (int& theRow, int& theCol) const;
123 void SetThreshold (const int theRow,
124 const QString& theText,
125 const int theEntityType = -1);
127 bool GetThreshold (const int theRow,
129 const int theEntityType = -1);
135 void CopyFromClicked();
137 void EntityTypeChanged (const int);
138 void NeedValidation();
139 void CretarionChanged (const int theRow, const int theEntityType);
140 void CurrentChanged (int, int);
148 void onCopyFromBtn();
150 void onCriterionChanged (int, int);
151 void onEntityType (int);
152 void onCurrentChanged (int, int);
156 void addRow (Table*, const int, const bool toTheEnd = true);
157 QTableItem* getCriterionItem (QTable*, const int);
158 QTableItem* getCompareItem (QTable*);
159 QTableItem* getUnaryItem (QTable*);
160 QTableItem* getBinaryItem (QTable*);
161 const QMap<int, QString>& getCriteria (const int theType) const;
162 const QMap<int, QString>& getCompare() const;
163 Table* createTable (QWidget*, const int);
164 QWidget* createAdditionalFrame (QWidget* theParent);
165 int getFirstSelectedRow() const;
166 void onCriterionChanged (const int, const int, const int);
168 void updateBtnState();
169 void removeAdditionalWidget (QTable* theTable, const int theRow);
170 void updateAdditionalWidget();
172 const QMap<int, QString>& getSupportedTypes() const;
176 QGroupBox* myTableGrp;
177 QGroupBox* mySwitchTableGrp;
180 QPushButton* myAddBtn;
181 QPushButton* myInsertBtn;
182 QPushButton* myRemoveBtn;
183 QPushButton* myClearBtn;
184 QPushButton* myCopyFromBtn;
185 QPushButton* myAddToBtn;
187 QButtonGroup* myEntityTypeGrp;
191 SMESHGUI_FilterLibraryDlg* myLibDlg;
193 QWidgetStack* myWgStack;
195 QMap<QTableItem*, AdditionalWidget*> myAddWidgets;
200 * Class : SMESHGUI_FilterDlg
201 * Description : Dialog to specify filters for VTK viewer
204 class SMESHGUI_FilterDlg : public QDialog
208 // Source elements to be selected
209 enum { Mesh, Selection, Dialog, None };
212 enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close };
215 SMESHGUI_FilterDlg( SMESHGUI*,
216 const QValueList<int>& types,
217 const char* name = 0);
219 SMESHGUI_FilterDlg( SMESHGUI*,
221 const char* name = 0);
222 virtual ~SMESHGUI_FilterDlg();
224 void Init (const QValueList<int>& types);
225 void Init (const int type);
228 void SetMesh (SMESH::SMESH_Mesh_ptr);
229 void SetSourceWg (QWidget*);
231 static SMESH::Filter::Criterion createCriterion();
243 void onSelectionDone();
244 void onCriterionChanged (const int, const int);
245 void onCurrentChanged (int, int);
249 void construct (const QValueList<int>& types);
251 void closeEvent (QCloseEvent*);
252 void enterEvent (QEvent*);
255 QFrame* createButtonFrame (QWidget*);
256 QFrame* createMainFrame (QWidget*);
257 QButtonGroup* createSourceGroup (QWidget*);
258 void updateMainButtons();
261 bool isValid() const;
262 bool createFilter (const int theType);
263 void insertFilterInViewer();
264 void selectInViewer (const int theType,
265 const QValueList<int>& theIds);
266 void filterSource (const int theType,
267 QValueList<int>& theResIds);
268 void filterSelectionSource (const int theType,
269 QValueList<int>& theResIds);
270 void getIdsFromWg (const QWidget*, QValueList<int>&) const;
271 void setIdsToWg (QWidget*, const QValueList<int>&);
272 Selection_Mode getSelMode (const int) const;
273 void updateSelection();
279 QButtonGroup* mySourceGrp;
281 QCheckBox* mySetInViewer;
283 QMap<int, QPushButton*> myButtons;
285 SMESHGUI_FilterTable* myTable;
288 QValueList<int> myTypes;
289 SMESHGUI* mySMESHGUI;
290 SalomeApp_SelectionMgr* mySelectionMgr;
291 SVTK_Selector* mySelector;
292 SVTK_ViewWindow* myViewWindow;
293 SMESH::SMESH_Mesh_ptr myMesh;
296 SALOME_DataMapOfIOMapOfInteger myIObjects;
297 bool myIsSelectionChanged;
298 QMap< int, SMESH::Filter_var > myFilter;
299 QMap< int, bool > myInsertState;
300 QMap< int, int > myApplyToState;