1 // Copyright (C) 2007-2020 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, or (at your option) any later version.
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)
48 class LightApp_SelectionMgr;
56 class QTableWidgetItem;
58 class SMESHGUI_FilterLibraryDlg;
63 * Class : SMESHGUI_FilterTable
64 * Description : Frame containing
65 * - Button group for switching entity type
66 * - Table for displaying filter criterions
67 * - Buttons for editing table
70 class SMESHGUI_EXPORT SMESHGUI_FilterTable : public QWidget
79 class AdditionalWidget;
82 typedef QMap<int, Table*> TableMap;
85 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const int );
86 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const QList<int>& );
87 virtual ~SMESHGUI_FilterTable();
89 void Init( const QList<int>& );
91 QGroupBox* GetTableGrp();
93 bool IsValid( const bool = true, const int = -1 ) const;
95 void SetType(const int);
96 void RestorePreviousEntityType();
97 int NumRows( const int = -1 ) const;
98 void Clear( const int = -1 );
99 void SetEditable( const bool );
100 void SetEnabled( const bool );
101 void SetLibsEnabled( const bool );
102 bool IsEditable() const;
104 int GetCriterionType( const int, const int = -1 ) const;
106 void GetCriterion( const int,
107 SMESH::Filter::Criterion&,
108 const int = -1 ) const;
110 void SetCriterion( const int,
111 const SMESH::Filter::Criterion&,
114 void AddCriterion( const SMESH::Filter::Criterion&,
117 void Copy( const SMESHGUI_FilterTable* );
118 void SetValidity( const bool );
120 bool CurrentCell( int&, int& ) const;
121 void SetThreshold( const int,
125 bool GetThreshold( const int,
129 void SetID( const int,
133 bool GetID( const int,
140 void CopyFromClicked();
142 void EntityTypeChanged( const int );
143 void NeedValidation();
144 void CriterionChanged( const int, const int );
145 void ThresholdChanged( const int, const int );
146 void CurrentChanged( int, int );
153 void onCopyFromBtn();
155 void onCriterionChanged( int, int );
156 void onEntityType( int );
157 void onCurrentChanged( int, int );
160 void addRow( Table*, const int, const bool = true );
161 QTableWidgetItem* getCriterionItem( const int ) const;
162 QTableWidgetItem* getCompareItem() const;
163 QTableWidgetItem* getUnaryItem() const;
164 QTableWidgetItem* getBinaryItem() const;
165 const QMap<int, QString>& getCriteria( const int ) const;
166 const QMap<int, QString>& getCompare() const;
167 Table* createTable( QWidget*, const int );
168 QWidget* createAdditionalFrame( QWidget* );
169 int getFirstSelectedRow() const;
170 void onCriterionChanged( const int, const int, const int );
172 void updateBtnState();
173 void removeAdditionalWidget( QTableWidget*, const int );
174 void updateAdditionalWidget();
175 const char* getPrecision( const int );
177 const QMap<int, QString>& getSupportedTypes() const;
180 SMESHGUI* mySMESHGUI;
182 QGroupBox* myTableGrp;
183 QWidget* mySwitchTableGrp;
186 QPushButton* myAddBtn;
187 QPushButton* myInsertBtn;
188 QPushButton* myRemoveBtn;
189 QPushButton* myClearBtn;
190 QPushButton* myCopyFromBtn;
191 QPushButton* myAddToBtn;
193 QGroupBox* myEntityTypeBox;
194 QButtonGroup* myEntityTypeGrp;
199 SMESHGUI_FilterLibraryDlg* myLibDlg;
201 QStackedWidget* myWgStack;
203 QMap<QTableWidgetItem*, AdditionalWidget*> myAddWidgets;
208 * Class : SMESHGUI_FilterDlg
209 * Description : Dialog to specify filters for VTK viewer
212 class SMESHGUI_FilterDlg : public QDialog
216 // Source elements to be selected
217 enum { Mesh, Selection, Dialog, None };
220 enum { BTN_OK, BTN_Apply, BTN_Close, BTN_Help };
223 SMESHGUI_FilterDlg( SMESHGUI*, const QList<int>& );
224 SMESHGUI_FilterDlg( SMESHGUI*, const int );
225 virtual ~SMESHGUI_FilterDlg();
227 void Init( const QList<int>&, const bool setInViewer=true );
228 void Init( const int, const bool setInViewer=true );
231 void SetMesh (SMESH::SMESH_Mesh_var);
232 void SetGroup (SMESH::SMESH_GroupOnFilter_var);
233 void SetSourceWg( QWidget*, const bool initOnApply = true );
234 void SetEnabled( bool setInViewer, bool diffSources );
236 static SMESH::Filter::Criterion createCriterion();
238 SMESH::Filter_var GetFilter() const;
239 void SetFilter(SMESH::Filter_var filter, int type);
240 void UnRegisterFilters();
247 virtual void reject();
255 void onSelectionDone();
256 void onCriterionChanged( const int, const int );
257 void onThresholdChanged( const int, const int );
258 void onCurrentChanged( int, int );
264 void construct( const QList<int>& );
266 void enterEvent( QEvent* );
267 void keyPressEvent( QKeyEvent* );
270 QWidget* createButtonFrame( QWidget* );
271 QWidget* createMainFrame( QWidget* );
272 QWidget* createSourceGroup( QWidget* );
273 void updateMainButtons();
276 bool isValid() const;
277 bool createFilter( const int );
278 void insertFilterInViewer();
279 void selectInViewer( const int, const QList<int>& );
280 void filterSource( const int, QList<int>& );
281 void filterSelectionSource( const int, QList<int>& );
282 void getIdsFromWg( const QWidget*, QList<int>& ) const;
283 void setIdsToWg( QWidget*, const QList<int>& );
284 Selection_Mode getSelMode( const int ) const;
285 void updateSelection();
286 SMESH_Actor* getActor();
290 QWidget* myMainFrame;
291 QButtonGroup* mySourceGrp;
293 QCheckBox* mySetInViewer;
295 QMap<int, QPushButton*> myButtons;
297 SMESHGUI_FilterTable* myTable;
301 SMESHGUI* mySMESHGUI;
302 LightApp_SelectionMgr* mySelectionMgr;
303 SVTK_Selector* mySelector;
304 SMESH::SMESH_Mesh_var myMesh;
305 SMESH::SMESH_GroupOnFilter_var myGroup;
306 bool myInitSourceWgOnApply;
307 bool myInsertEnabled;
308 bool myDiffSourcesEnabled;
311 SALOME_DataMapOfIOMapOfInteger myIObjects;
312 bool myIsSelectionChanged;
313 QMap< int, SMESH::Filter_var > myFilter;
314 QMap< int, bool > myInsertState;
315 QMap< int, int > myApplyToState;
317 QString myHelpFileName;
319 bool myToRestoreSelMode;
320 int mySelModeToRestore;
321 void restoreSelMode();
324 #endif // SMESHGUI_FILTERDLG_H