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();
172 const QMap<int, QString>& getSupportedTypes() const;
175 SMESHGUI* mySMESHGUI;
177 QGroupBox* myTableGrp;
178 QWidget* mySwitchTableGrp;
181 QPushButton* myAddBtn;
182 QPushButton* myInsertBtn;
183 QPushButton* myRemoveBtn;
184 QPushButton* myClearBtn;
185 QPushButton* myCopyFromBtn;
186 QPushButton* myAddToBtn;
188 QGroupBox* myEntityTypeBox;
189 QButtonGroup* myEntityTypeGrp;
194 SMESHGUI_FilterLibraryDlg* myLibDlg;
196 QStackedWidget* myWgStack;
198 QMap<QTableWidgetItem*, AdditionalWidget*> myAddWidgets;
203 * Class : SMESHGUI_FilterDlg
204 * Description : Dialog to specify filters for VTK viewer
207 class SMESHGUI_FilterDlg : public QDialog
211 // Source elements to be selected
212 enum { Mesh, Selection, Dialog, None };
215 enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close, BTN_Help };
218 SMESHGUI_FilterDlg( SMESHGUI*, const QList<int>& );
219 SMESHGUI_FilterDlg( SMESHGUI*, const int );
220 virtual ~SMESHGUI_FilterDlg();
222 void Init( const QList<int>& );
223 void Init( const int );
226 void SetMesh (SMESH::SMESH_Mesh_var);
227 void SetSourceWg( QWidget*, const bool initOnApply = true );
229 static SMESH::Filter::Criterion createCriterion();
242 void onSelectionDone();
243 void onCriterionChanged( const int, const int );
244 void onCurrentChanged( int, int );
248 void construct( const QList<int>& );
250 void closeEvent( QCloseEvent* );
251 void enterEvent( QEvent* );
252 void keyPressEvent( QKeyEvent* );
255 QWidget* createButtonFrame( QWidget* );
256 QWidget* createMainFrame( QWidget* );
257 QWidget* createSourceGroup( QWidget* );
258 void updateMainButtons();
261 bool isValid() const;
262 bool createFilter( const int );
263 void insertFilterInViewer();
264 void selectInViewer( const int, const QList<int>& );
265 void filterSource( const int, QList<int>& );
266 void filterSelectionSource( const int, QList<int>& );
267 void getIdsFromWg( const QWidget*, QList<int>& ) const;
268 void setIdsToWg( QWidget*, const QList<int>& );
269 Selection_Mode getSelMode( const int ) const;
270 void updateSelection();
274 QWidget* myMainFrame;
275 QButtonGroup* mySourceGrp;
277 QCheckBox* mySetInViewer;
279 QMap<int, QPushButton*> myButtons;
281 SMESHGUI_FilterTable* myTable;
285 SMESHGUI* mySMESHGUI;
286 LightApp_SelectionMgr* mySelectionMgr;
287 SVTK_Selector* mySelector;
288 SMESH::SMESH_Mesh_var myMesh;
289 bool myInitSourceWgOnApply;
292 SALOME_DataMapOfIOMapOfInteger myIObjects;
293 bool myIsSelectionChanged;
294 QMap< int, SMESH::Filter_var > myFilter;
295 QMap< int, bool > myInsertState;
296 QMap< int, int > myApplyToState;
298 QString myHelpFileName;
301 #endif // SMESHGUI_FILTERDLG_H