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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESHGUI_FilterDlg.h
25 // Author : Sergey LITONIN
29 #ifndef SMESHGUI_FilterDlg_H
30 #define SMESHGUI_FilterDlg_H
32 #include "SMESH_SMESHGUI.hxx"
37 #include <qvaluelist.h>
39 #include "LightApp_SelectionMgr.h"
40 #include "SALOME_InteractiveObject.hxx"
41 #include "SALOME_DataMapOfIOMapOfInteger.hxx"
42 #include "SVTK_Selection.h"
44 #include <TColStd_IndexedMapOfInteger.hxx>
46 #include <SALOMEconfig.h>
47 #include CORBA_SERVER_HEADER(SMESH_Filter)
48 #include CORBA_SERVER_HEADER(SMESH_Mesh)
61 class LightApp_SelectionMgr;
63 class SMESHGUI_FilterLibraryDlg;
65 class SVTK_ViewWindow;
68 * Class : SMESHGUI_FilterTable
69 * Description : Frame containig
70 * - Button group for switching entity type
71 * - Table for displaying filter criterions
72 * - Buttons for editing table
75 class SMESHGUI_EXPORT SMESHGUI_FilterTable : public QFrame
81 class AdditionalWidget;
83 typedef QMap<int, Table*> TableMap;
86 SMESHGUI_FilterTable( SMESHGUI*,
89 SMESHGUI_FilterTable( SMESHGUI*,
91 const QValueList<int>& type);
92 virtual ~SMESHGUI_FilterTable();
94 void Init (const int type);
95 void Init (const QValueList<int>& types);
97 QGroupBox* GetTableGrp();
99 bool IsValid (const bool = true, const int theEntityType = -1) const;
101 void SetType (const int);
102 void RestorePreviousEntityType();
103 int NumRows (const int theEntityType = -1) const;
104 void Clear (const int theEntityType = -1);
105 void SetEditable (const bool);
106 void SetEnabled (const bool);
107 void SetLibsEnabled (const bool);
108 bool IsEditable() const;
110 int GetCriterionType (const int theRow, const int theType = -1) const;
112 void GetCriterion (const int theRow,
113 SMESH::Filter::Criterion& theCriterion,
114 const int theEntityType = -1) const;
116 void SetCriterion (const int theRow,
117 const SMESH::Filter::Criterion& theCriterion,
118 const int theEntityType = -1);
120 void AddCriterion (const SMESH::Filter::Criterion& theCriterion,
121 const int theEntityType = -1);
123 void Copy (const SMESHGUI_FilterTable*);
124 void SetValidity (const bool);
126 bool CurrentCell (int& theRow, int& theCol) const;
127 void SetThreshold (const int theRow,
128 const QString& theText,
129 const int theEntityType = -1);
131 bool GetThreshold (const int theRow,
133 const int theEntityType = -1);
135 void SetID( const int theRow,
136 const QString& theText,
137 const int theEntityType = -1 );
139 bool GetID( const int theRow,
141 const int theEntityType = -1 );
147 void CopyFromClicked();
149 void EntityTypeChanged (const int);
150 void NeedValidation();
151 void CriterionChanged (const int theRow, const int theEntityType);
152 void CurrentChanged (int, int);
160 void onCopyFromBtn();
162 void onCriterionChanged (int, int);
163 void onEntityType (int);
164 void onCurrentChanged (int, int);
168 void addRow (Table*, const int, const bool toTheEnd = true);
169 QTableItem* getCriterionItem (QTable*, const int);
170 QTableItem* getCompareItem (QTable*);
171 QTableItem* getUnaryItem (QTable*);
172 QTableItem* getBinaryItem (QTable*);
173 const QMap<int, QString>& getCriteria (const int theType) const;
174 const QMap<int, QString>& getCompare() const;
175 Table* createTable (QWidget*, const int);
176 QWidget* createAdditionalFrame (QWidget* theParent);
177 int getFirstSelectedRow() const;
178 void onCriterionChanged (const int, const int, const int);
180 void updateBtnState();
181 void removeAdditionalWidget (QTable* theTable, const int theRow);
182 void updateAdditionalWidget();
184 const QMap<int, QString>& getSupportedTypes() const;
187 SMESHGUI* mySMESHGUI;
189 QGroupBox* myTableGrp;
190 QGroupBox* mySwitchTableGrp;
193 QPushButton* myAddBtn;
194 QPushButton* myInsertBtn;
195 QPushButton* myRemoveBtn;
196 QPushButton* myClearBtn;
197 QPushButton* myCopyFromBtn;
198 QPushButton* myAddToBtn;
200 QButtonGroup* myEntityTypeGrp;
205 SMESHGUI_FilterLibraryDlg* myLibDlg;
207 QWidgetStack* myWgStack;
209 QMap<QTableItem*, AdditionalWidget*> myAddWidgets;
214 * Class : SMESHGUI_FilterDlg
215 * Description : Dialog to specify filters for VTK viewer
218 class SMESHGUI_FilterDlg : public QDialog
222 // Source elements to be selected
223 enum { Mesh, Selection, Dialog, None };
226 enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close, BTN_Help };
229 SMESHGUI_FilterDlg( SMESHGUI*,
230 const QValueList<int>& types,
231 const char* name = 0);
233 SMESHGUI_FilterDlg( SMESHGUI*,
235 const char* name = 0);
236 virtual ~SMESHGUI_FilterDlg();
238 void Init (const QValueList<int>& types);
239 void Init (const int type);
242 void SetMesh (SMESH::SMESH_Mesh_ptr);
243 void SetSourceWg (QWidget*);
245 static SMESH::Filter::Criterion createCriterion();
258 void onSelectionDone();
259 void onCriterionChanged (const int, const int);
260 void onCurrentChanged (int, int);
264 void construct (const QValueList<int>& types);
266 void closeEvent (QCloseEvent*);
267 void enterEvent (QEvent*);
270 QFrame* createButtonFrame (QWidget*);
271 QFrame* createMainFrame (QWidget*);
272 QButtonGroup* createSourceGroup (QWidget*);
273 void updateMainButtons();
276 bool isValid() const;
277 bool createFilter (const int theType);
278 void insertFilterInViewer();
279 void selectInViewer (const int theType,
280 const QValueList<int>& theIds);
281 void filterSource (const int theType,
282 QValueList<int>& theResIds);
283 void filterSelectionSource (const int theType,
284 QValueList<int>& theResIds);
285 void getIdsFromWg (const QWidget*, QValueList<int>&) const;
286 void setIdsToWg (QWidget*, const QValueList<int>&);
287 Selection_Mode getSelMode (const int) const;
288 void updateSelection();
294 QButtonGroup* mySourceGrp;
296 QCheckBox* mySetInViewer;
298 QMap<int, QPushButton*> myButtons;
300 SMESHGUI_FilterTable* myTable;
303 QValueList<int> myTypes;
304 SMESHGUI* mySMESHGUI;
305 LightApp_SelectionMgr* mySelectionMgr;
306 SVTK_Selector* mySelector;
307 SMESH::SMESH_Mesh_ptr myMesh;
310 SALOME_DataMapOfIOMapOfInteger myIObjects;
311 bool myIsSelectionChanged;
312 QMap< int, SMESH::Filter_var > myFilter;
313 QMap< int, bool > myInsertState;
314 QMap< int, int > myApplyToState;
316 QString myHelpFileName;