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 "LightApp_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 LightApp_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);
133 void SetID( const int theRow,
134 const QString& theText,
135 const int theEntityType = -1 );
137 bool GetID( const int theRow,
139 const int theEntityType = -1 );
145 void CopyFromClicked();
147 void EntityTypeChanged (const int);
148 void NeedValidation();
149 void CriterionChanged (const int theRow, const int theEntityType);
150 void CurrentChanged (int, int);
158 void onCopyFromBtn();
160 void onCriterionChanged (int, int);
161 void onEntityType (int);
162 void onCurrentChanged (int, int);
166 void addRow (Table*, const int, const bool toTheEnd = true);
167 QTableItem* getCriterionItem (QTable*, const int);
168 QTableItem* getCompareItem (QTable*);
169 QTableItem* getUnaryItem (QTable*);
170 QTableItem* getBinaryItem (QTable*);
171 const QMap<int, QString>& getCriteria (const int theType) const;
172 const QMap<int, QString>& getCompare() const;
173 Table* createTable (QWidget*, const int);
174 QWidget* createAdditionalFrame (QWidget* theParent);
175 int getFirstSelectedRow() const;
176 void onCriterionChanged (const int, const int, const int);
178 void updateBtnState();
179 void removeAdditionalWidget (QTable* theTable, const int theRow);
180 void updateAdditionalWidget();
182 const QMap<int, QString>& getSupportedTypes() const;
185 SMESHGUI* mySMESHGUI;
187 QGroupBox* myTableGrp;
188 QGroupBox* mySwitchTableGrp;
191 QPushButton* myAddBtn;
192 QPushButton* myInsertBtn;
193 QPushButton* myRemoveBtn;
194 QPushButton* myClearBtn;
195 QPushButton* myCopyFromBtn;
196 QPushButton* myAddToBtn;
198 QButtonGroup* myEntityTypeGrp;
203 SMESHGUI_FilterLibraryDlg* myLibDlg;
205 QWidgetStack* myWgStack;
207 QMap<QTableItem*, AdditionalWidget*> myAddWidgets;
212 * Class : SMESHGUI_FilterDlg
213 * Description : Dialog to specify filters for VTK viewer
216 class SMESHGUI_FilterDlg : public QDialog
220 // Source elements to be selected
221 enum { Mesh, Selection, Dialog, None };
224 enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close, BTN_Help };
227 SMESHGUI_FilterDlg( SMESHGUI*,
228 const QValueList<int>& types,
229 const char* name = 0);
231 SMESHGUI_FilterDlg( SMESHGUI*,
233 const char* name = 0);
234 virtual ~SMESHGUI_FilterDlg();
236 void Init (const QValueList<int>& types);
237 void Init (const int type);
240 void SetMesh (SMESH::SMESH_Mesh_ptr);
241 void SetSourceWg (QWidget*);
243 static SMESH::Filter::Criterion createCriterion();
256 void onSelectionDone();
257 void onCriterionChanged (const int, const int);
258 void onCurrentChanged (int, int);
262 void construct (const QValueList<int>& types);
264 void closeEvent (QCloseEvent*);
265 void enterEvent (QEvent*);
268 QFrame* createButtonFrame (QWidget*);
269 QFrame* createMainFrame (QWidget*);
270 QButtonGroup* createSourceGroup (QWidget*);
271 void updateMainButtons();
274 bool isValid() const;
275 bool createFilter (const int theType);
276 void insertFilterInViewer();
277 void selectInViewer (const int theType,
278 const QValueList<int>& theIds);
279 void filterSource (const int theType,
280 QValueList<int>& theResIds);
281 void filterSelectionSource (const int theType,
282 QValueList<int>& theResIds);
283 void getIdsFromWg (const QWidget*, QValueList<int>&) const;
284 void setIdsToWg (QWidget*, const QValueList<int>&);
285 Selection_Mode getSelMode (const int) const;
286 void updateSelection();
292 QButtonGroup* mySourceGrp;
294 QCheckBox* mySetInViewer;
296 QMap<int, QPushButton*> myButtons;
298 SMESHGUI_FilterTable* myTable;
301 QValueList<int> myTypes;
302 SMESHGUI* mySMESHGUI;
303 LightApp_SelectionMgr* mySelectionMgr;
304 SVTK_Selector* mySelector;
305 SMESH::SMESH_Mesh_ptr myMesh;
308 SALOME_DataMapOfIOMapOfInteger myIObjects;
309 bool myIsSelectionChanged;
310 QMap< int, SMESH::Filter_var > myFilter;
311 QMap< int, bool > myInsertState;
312 QMap< int, int > myApplyToState;
314 QString myHelpFileName;