1 // Copyright (C) 2007-2013 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 ThresholdChanged( const int, const int );
145 void CurrentChanged( int, int );
152 void onCopyFromBtn();
154 void onCriterionChanged( int, int );
155 void onEntityType( int );
156 void onCurrentChanged( int, int );
159 void addRow( Table*, const int, const bool = true );
160 QTableWidgetItem* getCriterionItem( const int ) const;
161 QTableWidgetItem* getCompareItem() const;
162 QTableWidgetItem* getUnaryItem() const;
163 QTableWidgetItem* getBinaryItem() const;
164 const QMap<int, QString>& getCriteria( const int ) const;
165 const QMap<int, QString>& getCompare() const;
166 Table* createTable( QWidget*, const int );
167 QWidget* createAdditionalFrame( QWidget* );
168 int getFirstSelectedRow() const;
169 void onCriterionChanged( const int, const int, const int );
171 void updateBtnState();
172 void removeAdditionalWidget( QTableWidget*, const int );
173 void updateAdditionalWidget();
174 const char* getPrecision( const int );
176 const QMap<int, QString>& getSupportedTypes() const;
179 SMESHGUI* mySMESHGUI;
181 QGroupBox* myTableGrp;
182 QWidget* mySwitchTableGrp;
185 QPushButton* myAddBtn;
186 QPushButton* myInsertBtn;
187 QPushButton* myRemoveBtn;
188 QPushButton* myClearBtn;
189 QPushButton* myCopyFromBtn;
190 QPushButton* myAddToBtn;
192 QGroupBox* myEntityTypeBox;
193 QButtonGroup* myEntityTypeGrp;
198 SMESHGUI_FilterLibraryDlg* myLibDlg;
200 QStackedWidget* myWgStack;
202 QMap<QTableWidgetItem*, AdditionalWidget*> myAddWidgets;
207 * Class : SMESHGUI_FilterDlg
208 * Description : Dialog to specify filters for VTK viewer
211 class SMESHGUI_FilterDlg : public QDialog
215 // Source elements to be selected
216 enum { Mesh, Selection, Dialog, None };
219 enum { BTN_OK, BTN_Apply, BTN_Close, BTN_Help };
222 SMESHGUI_FilterDlg( SMESHGUI*, const QList<int>& );
223 SMESHGUI_FilterDlg( SMESHGUI*, const int );
224 virtual ~SMESHGUI_FilterDlg();
226 void Init( const QList<int>&, const bool setInViewer=true );
227 void Init( const int, const bool setInViewer=true );
230 void SetMesh (SMESH::SMESH_Mesh_var);
231 void SetSourceWg( QWidget*, const bool initOnApply = true );
233 static SMESH::Filter::Criterion createCriterion();
235 SMESH::Filter_var GetFilter() const;
236 void SetFilter(SMESH::Filter_var filter, int type);
237 void UnRegisterFilters();
244 virtual void reject();
252 void onSelectionDone();
253 void onCriterionChanged( const int, const int );
254 void onThresholdChanged( const int, const int );
255 void onCurrentChanged( int, int );
259 void construct( const QList<int>& );
261 void enterEvent( QEvent* );
262 void keyPressEvent( QKeyEvent* );
265 QWidget* createButtonFrame( QWidget* );
266 QWidget* createMainFrame( QWidget* );
267 QWidget* createSourceGroup( QWidget* );
268 void updateMainButtons();
271 bool isValid() const;
272 bool createFilter( const int );
273 void insertFilterInViewer();
274 void selectInViewer( const int, const QList<int>& );
275 void filterSource( const int, QList<int>& );
276 void filterSelectionSource( const int, QList<int>& );
277 void getIdsFromWg( const QWidget*, QList<int>& ) const;
278 void setIdsToWg( QWidget*, const QList<int>& );
279 Selection_Mode getSelMode( const int ) const;
280 void updateSelection();
284 QWidget* myMainFrame;
285 QButtonGroup* mySourceGrp;
287 QCheckBox* mySetInViewer;
289 QMap<int, QPushButton*> myButtons;
291 SMESHGUI_FilterTable* myTable;
295 SMESHGUI* mySMESHGUI;
296 LightApp_SelectionMgr* mySelectionMgr;
297 SVTK_Selector* mySelector;
298 SMESH::SMESH_Mesh_var myMesh;
299 bool myInitSourceWgOnApply;
302 SALOME_DataMapOfIOMapOfInteger myIObjects;
303 bool myIsSelectionChanged;
304 QMap< int, SMESH::Filter_var > myFilter;
305 QMap< int, bool > myInsertState;
306 QMap< int, int > myApplyToState;
308 QString myHelpFileName;
310 bool myToRestoreSelMode;
311 int mySelModeToRestore;
312 void restoreSelMode();
315 #endif // SMESHGUI_FILTERDLG_H