1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_FilterDlg.h
25 // Author : Sergey LITONIN, Open CASCADE S.A.S.
27 #ifndef SMESHGUI_FILTERDLG_H
28 #define SMESHGUI_FILTERDLG_H
31 #include "SMESH_SMESHGUI.hxx"
39 // SALOME GUI includes
40 #include <SALOME_DataMapOfIOMapOfInteger.hxx>
41 #include <SVTK_Selection.h>
44 #include <SALOMEconfig.h>
45 #include CORBA_SERVER_HEADER(SMESH_Filter)
46 #include CORBA_SERVER_HEADER(SMESH_Mesh)
54 class QTableWidgetItem;
56 class LightApp_SelectionMgr;
58 class SMESHGUI_FilterLibraryDlg;
62 * Class : SMESHGUI_FilterTable
63 * Description : Frame containig
64 * - Button group for switching entity type
65 * - Table for displaying filter criterions
66 * - Buttons for editing table
69 class SMESHGUI_EXPORT SMESHGUI_FilterTable : public QWidget
76 class AdditionalWidget;
79 typedef QMap<int, Table*> TableMap;
82 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const int );
83 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const QList<int>& );
84 virtual ~SMESHGUI_FilterTable();
86 void Init( const QList<int>& );
88 QGroupBox* GetTableGrp();
90 bool IsValid( const bool = true, const int = -1 ) const;
92 void SetType(const int);
93 void RestorePreviousEntityType();
94 int NumRows( const int = -1 ) const;
95 void Clear( const int = -1 );
96 void SetEditable( const bool );
97 void SetEnabled( const bool );
98 void SetLibsEnabled( const bool );
99 bool IsEditable() const;
101 int GetCriterionType( const int, const int = -1 ) const;
103 void GetCriterion( const int,
104 SMESH::Filter::Criterion&,
105 const int = -1 ) const;
107 void SetCriterion( const int,
108 const SMESH::Filter::Criterion&,
111 void AddCriterion( const SMESH::Filter::Criterion&,
114 void Copy( const SMESHGUI_FilterTable* );
115 void SetValidity( const bool );
117 bool CurrentCell( int&, int& ) const;
118 void SetThreshold( const int,
122 bool GetThreshold( const int,
126 void SetID( const int,
130 bool GetID( const int,
137 void CopyFromClicked();
139 void EntityTypeChanged( const int );
140 void NeedValidation();
141 void CriterionChanged( const int, const int );
142 void CurrentChanged( int, int );
149 void onCopyFromBtn();
151 void onCriterionChanged( int, int );
152 void onEntityType( int );
153 void onCurrentChanged( int, int );
156 void addRow( Table*, const int, const bool = true );
157 QTableWidgetItem* getCriterionItem( const int ) const;
158 QTableWidgetItem* getCompareItem() const;
159 QTableWidgetItem* getUnaryItem() const;
160 QTableWidgetItem* getBinaryItem() const;
161 const QMap<int, QString>& getCriteria( const int ) const;
162 const QMap<int, QString>& getCompare() const;
163 Table* createTable( QWidget*, const int );
164 QWidget* createAdditionalFrame( QWidget* );
165 int getFirstSelectedRow() const;
166 void onCriterionChanged( const int, const int, const int );
168 void updateBtnState();
169 void removeAdditionalWidget( QTableWidget*, const int );
170 void updateAdditionalWidget();
171 const char* getPrecision( const int );
173 const QMap<int, QString>& getSupportedTypes() const;
176 SMESHGUI* mySMESHGUI;
178 QGroupBox* myTableGrp;
179 QWidget* mySwitchTableGrp;
182 QPushButton* myAddBtn;
183 QPushButton* myInsertBtn;
184 QPushButton* myRemoveBtn;
185 QPushButton* myClearBtn;
186 QPushButton* myCopyFromBtn;
187 QPushButton* myAddToBtn;
189 QGroupBox* myEntityTypeBox;
190 QButtonGroup* myEntityTypeGrp;
195 SMESHGUI_FilterLibraryDlg* myLibDlg;
197 QStackedWidget* myWgStack;
199 QMap<QTableWidgetItem*, 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, BTN_Help };
219 SMESHGUI_FilterDlg( SMESHGUI*, const QList<int>& );
220 SMESHGUI_FilterDlg( SMESHGUI*, const int );
221 virtual ~SMESHGUI_FilterDlg();
223 void Init( const QList<int>& );
224 void Init( const int );
227 void SetMesh (SMESH::SMESH_Mesh_var);
228 void SetSourceWg( QWidget*, const bool initOnApply = true );
230 static SMESH::Filter::Criterion createCriterion();
243 void onSelectionDone();
244 void onCriterionChanged( const int, const int );
245 void onCurrentChanged( int, int );
249 void construct( const QList<int>& );
251 void closeEvent( QCloseEvent* );
252 void enterEvent( QEvent* );
253 void keyPressEvent( QKeyEvent* );
256 QWidget* createButtonFrame( QWidget* );
257 QWidget* createMainFrame( QWidget* );
258 QWidget* createSourceGroup( QWidget* );
259 void updateMainButtons();
262 bool isValid() const;
263 bool createFilter( const int );
264 void insertFilterInViewer();
265 void selectInViewer( const int, const QList<int>& );
266 void filterSource( const int, QList<int>& );
267 void filterSelectionSource( const int, QList<int>& );
268 void getIdsFromWg( const QWidget*, QList<int>& ) const;
269 void setIdsToWg( QWidget*, const QList<int>& );
270 Selection_Mode getSelMode( const int ) const;
271 void updateSelection();
275 QWidget* myMainFrame;
276 QButtonGroup* mySourceGrp;
278 QCheckBox* mySetInViewer;
280 QMap<int, QPushButton*> myButtons;
282 SMESHGUI_FilterTable* myTable;
286 SMESHGUI* mySMESHGUI;
287 LightApp_SelectionMgr* mySelectionMgr;
288 SVTK_Selector* mySelector;
289 SMESH::SMESH_Mesh_var myMesh;
290 bool myInitSourceWgOnApply;
293 SALOME_DataMapOfIOMapOfInteger myIObjects;
294 bool myIsSelectionChanged;
295 QMap< int, SMESH::Filter_var > myFilter;
296 QMap< int, bool > myInsertState;
297 QMap< int, int > myApplyToState;
299 QString myHelpFileName;
302 #endif // SMESHGUI_FILTERDLG_H