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( SMESHGUI*,
87 SMESHGUI_FilterTable( SMESHGUI*,
89 const QValueList<int>& type);
90 virtual ~SMESHGUI_FilterTable();
92 void Init (const int type);
93 void Init (const QValueList<int>& types);
95 QGroupBox* GetTableGrp();
97 bool IsValid (const bool = true, const int theEntityType = -1) const;
99 void SetType (const int);
100 void RestorePreviousEntityType();
101 int NumRows (const int theEntityType = -1) const;
102 void Clear (const int theEntityType = -1);
103 void SetEditable (const bool);
104 void SetEnabled (const bool);
105 void SetLibsEnabled (const bool);
106 bool IsEditable() const;
108 int GetCriterionType (const int theRow, const int theType = -1) const;
110 void GetCriterion (const int theRow,
111 SMESH::Filter::Criterion& theCriterion,
112 const int theEntityType = -1) const;
114 void SetCriterion (const int theRow,
115 const SMESH::Filter::Criterion& theCriterion,
116 const int theEntityType = -1);
118 void AddCriterion (const SMESH::Filter::Criterion& theCriterion,
119 const int theEntityType = -1);
121 void Copy (const SMESHGUI_FilterTable*);
122 void SetValidity (const bool);
124 bool CurrentCell (int& theRow, int& theCol) const;
125 void SetThreshold (const int theRow,
126 const QString& theText,
127 const int theEntityType = -1);
129 bool GetThreshold (const int theRow,
131 const int theEntityType = -1);
137 void CopyFromClicked();
139 void EntityTypeChanged (const int);
140 void NeedValidation();
141 void CriterionChanged (const int theRow, const int theEntityType);
142 void CurrentChanged (int, int);
150 void onCopyFromBtn();
152 void onCriterionChanged (int, int);
153 void onEntityType (int);
154 void onCurrentChanged (int, int);
158 void addRow (Table*, const int, const bool toTheEnd = true);
159 QTableItem* getCriterionItem (QTable*, const int);
160 QTableItem* getCompareItem (QTable*);
161 QTableItem* getUnaryItem (QTable*);
162 QTableItem* getBinaryItem (QTable*);
163 const QMap<int, QString>& getCriteria (const int theType) const;
164 const QMap<int, QString>& getCompare() const;
165 Table* createTable (QWidget*, const int);
166 QWidget* createAdditionalFrame (QWidget* theParent);
167 int getFirstSelectedRow() const;
168 void onCriterionChanged (const int, const int, const int);
170 void updateBtnState();
171 void removeAdditionalWidget (QTable* theTable, const int theRow);
172 void updateAdditionalWidget();
174 const QMap<int, QString>& getSupportedTypes() const;
177 SMESHGUI* mySMESHGUI;
179 QGroupBox* myTableGrp;
180 QGroupBox* mySwitchTableGrp;
183 QPushButton* myAddBtn;
184 QPushButton* myInsertBtn;
185 QPushButton* myRemoveBtn;
186 QPushButton* myClearBtn;
187 QPushButton* myCopyFromBtn;
188 QPushButton* myAddToBtn;
190 QButtonGroup* myEntityTypeGrp;
195 SMESHGUI_FilterLibraryDlg* myLibDlg;
197 QWidgetStack* myWgStack;
199 QMap<QTableItem*, AdditionalWidget*> myAddWidgets;
204 * Class : SMESHGUI_FilterDlg
205 * Description : Dialog to specify filters for VTK viewer
208 class SMESHGUI_FilterDlg : public QDialog
212 // Source elements to be selected
213 enum { Mesh, Selection, Dialog, None };
216 enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close };
219 SMESHGUI_FilterDlg( SMESHGUI*,
220 const QValueList<int>& types,
221 const char* name = 0);
223 SMESHGUI_FilterDlg( SMESHGUI*,
225 const char* name = 0);
226 virtual ~SMESHGUI_FilterDlg();
228 void Init (const QValueList<int>& types);
229 void Init (const int type);
232 void SetMesh (SMESH::SMESH_Mesh_ptr);
233 void SetSourceWg (QWidget*);
235 static SMESH::Filter::Criterion createCriterion();
247 void onSelectionDone();
248 void onCriterionChanged (const int, const int);
249 void onCurrentChanged (int, int);
253 void construct (const QValueList<int>& types);
255 void closeEvent (QCloseEvent*);
256 void enterEvent (QEvent*);
259 QFrame* createButtonFrame (QWidget*);
260 QFrame* createMainFrame (QWidget*);
261 QButtonGroup* createSourceGroup (QWidget*);
262 void updateMainButtons();
265 bool isValid() const;
266 bool createFilter (const int theType);
267 void insertFilterInViewer();
268 void selectInViewer (const int theType,
269 const QValueList<int>& theIds);
270 void filterSource (const int theType,
271 QValueList<int>& theResIds);
272 void filterSelectionSource (const int theType,
273 QValueList<int>& theResIds);
274 void getIdsFromWg (const QWidget*, QValueList<int>&) const;
275 void setIdsToWg (QWidget*, const QValueList<int>&);
276 Selection_Mode getSelMode (const int) const;
277 void updateSelection();
283 QButtonGroup* mySourceGrp;
285 QCheckBox* mySetInViewer;
287 QMap<int, QPushButton*> myButtons;
289 SMESHGUI_FilterTable* myTable;
292 QValueList<int> myTypes;
293 SMESHGUI* mySMESHGUI;
294 SalomeApp_SelectionMgr* mySelectionMgr;
295 SVTK_Selector* mySelector;
296 SMESH::SMESH_Mesh_ptr myMesh;
299 SALOME_DataMapOfIOMapOfInteger myIObjects;
300 bool myIsSelectionChanged;
301 QMap< int, SMESH::Filter_var > myFilter;
302 QMap< int, bool > myInsertState;
303 QMap< int, int > myApplyToState;