1 // Copyright (C) 2007-2011 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
78 class AdditionalWidget;
81 typedef QMap<int, Table*> TableMap;
84 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const int );
85 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const QList<int>& );
86 virtual ~SMESHGUI_FilterTable();
88 void Init( const QList<int>& );
90 QGroupBox* GetTableGrp();
92 bool IsValid( const bool = true, const int = -1 ) const;
94 void SetType(const int);
95 void RestorePreviousEntityType();
96 int NumRows( const int = -1 ) const;
97 void Clear( const int = -1 );
98 void SetEditable( const bool );
99 void SetEnabled( const bool );
100 void SetLibsEnabled( const bool );
101 bool IsEditable() const;
103 int GetCriterionType( const int, const int = -1 ) const;
105 void GetCriterion( const int,
106 SMESH::Filter::Criterion&,
107 const int = -1 ) const;
109 void SetCriterion( const int,
110 const SMESH::Filter::Criterion&,
113 void AddCriterion( const SMESH::Filter::Criterion&,
116 void Copy( const SMESHGUI_FilterTable* );
117 void SetValidity( const bool );
119 bool CurrentCell( int&, int& ) const;
120 void SetThreshold( const int,
124 bool GetThreshold( const int,
128 void SetID( const int,
132 bool GetID( const int,
139 void CopyFromClicked();
141 void EntityTypeChanged( const int );
142 void NeedValidation();
143 void CriterionChanged( const int, const int );
144 void CurrentChanged( int, int );
151 void onCopyFromBtn();
153 void onCriterionChanged( int, int );
154 void onEntityType( int );
155 void onCurrentChanged( int, int );
158 void addRow( Table*, const int, const bool = true );
159 QTableWidgetItem* getCriterionItem( const int ) const;
160 QTableWidgetItem* getCompareItem() const;
161 QTableWidgetItem* getUnaryItem() const;
162 QTableWidgetItem* getBinaryItem() const;
163 const QMap<int, QString>& getCriteria( const int ) const;
164 const QMap<int, QString>& getCompare() const;
165 Table* createTable( QWidget*, const int );
166 QWidget* createAdditionalFrame( QWidget* );
167 int getFirstSelectedRow() const;
168 void onCriterionChanged( const int, const int, const int );
170 void updateBtnState();
171 void removeAdditionalWidget( QTableWidget*, const int );
172 void updateAdditionalWidget();
173 const char* getPrecision( const int );
175 const QMap<int, QString>& getSupportedTypes() const;
178 SMESHGUI* mySMESHGUI;
180 QGroupBox* myTableGrp;
181 QWidget* mySwitchTableGrp;
184 QPushButton* myAddBtn;
185 QPushButton* myInsertBtn;
186 QPushButton* myRemoveBtn;
187 QPushButton* myClearBtn;
188 QPushButton* myCopyFromBtn;
189 QPushButton* myAddToBtn;
191 QGroupBox* myEntityTypeBox;
192 QButtonGroup* myEntityTypeGrp;
197 SMESHGUI_FilterLibraryDlg* myLibDlg;
199 QStackedWidget* myWgStack;
201 QMap<QTableWidgetItem*, AdditionalWidget*> myAddWidgets;
206 * Class : SMESHGUI_FilterDlg
207 * Description : Dialog to specify filters for VTK viewer
210 class SMESHGUI_FilterDlg : public QDialog
214 // Source elements to be selected
215 enum { Mesh, Selection, Dialog, None };
218 enum { BTN_OK, BTN_Apply, BTN_Close, BTN_Help };
221 SMESHGUI_FilterDlg( SMESHGUI*, const QList<int>& );
222 SMESHGUI_FilterDlg( SMESHGUI*, const int );
223 virtual ~SMESHGUI_FilterDlg();
225 void Init( const QList<int>& );
226 void Init( const int );
229 void SetMesh (SMESH::SMESH_Mesh_var);
230 void SetSourceWg( QWidget*, const bool initOnApply = true );
232 static SMESH::Filter::Criterion createCriterion();
234 SMESH::Filter_var GetFilter() const;
235 void SetFilter(SMESH::Filter_var filter, int type);
248 void onSelectionDone();
249 void onCriterionChanged( const int, const int );
250 void onCurrentChanged( int, int );
254 void construct( const QList<int>& );
256 void closeEvent( QCloseEvent* );
257 void enterEvent( QEvent* );
258 void keyPressEvent( QKeyEvent* );
261 QWidget* createButtonFrame( QWidget* );
262 QWidget* createMainFrame( QWidget* );
263 QWidget* createSourceGroup( QWidget* );
264 void updateMainButtons();
267 bool isValid() const;
268 bool createFilter( const int );
269 void insertFilterInViewer();
270 void selectInViewer( const int, const QList<int>& );
271 void filterSource( const int, QList<int>& );
272 void filterSelectionSource( const int, QList<int>& );
273 void getIdsFromWg( const QWidget*, QList<int>& ) const;
274 void setIdsToWg( QWidget*, const QList<int>& );
275 Selection_Mode getSelMode( const int ) const;
276 void updateSelection();
280 QWidget* myMainFrame;
281 QButtonGroup* mySourceGrp;
283 QCheckBox* mySetInViewer;
285 QMap<int, QPushButton*> myButtons;
287 SMESHGUI_FilterTable* myTable;
291 SMESHGUI* mySMESHGUI;
292 LightApp_SelectionMgr* mySelectionMgr;
293 SVTK_Selector* mySelector;
294 SMESH::SMESH_Mesh_var myMesh;
295 bool myInitSourceWgOnApply;
298 SALOME_DataMapOfIOMapOfInteger myIObjects;
299 bool myIsSelectionChanged;
300 QMap< int, SMESH::Filter_var > myFilter;
301 QMap< int, bool > myInsertState;
302 QMap< int, int > myApplyToState;
304 QString myHelpFileName;
307 #endif // SMESHGUI_FILTERDLG_H