1 // Copyright (C) 2007-2021 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>
42 #include <SVTK_Hash.h>
45 #include <SALOMEconfig.h>
46 #include CORBA_SERVER_HEADER(SMESH_Filter)
47 #include CORBA_SERVER_HEADER(SMESH_Mesh)
49 class LightApp_SelectionMgr;
57 class QTableWidgetItem;
59 class SMESHGUI_FilterLibraryDlg;
63 typedef NCollection_DataMap<Handle(SALOME_InteractiveObject), SVTK_TIndexedMapOfVtkId> SALOME_DataMapOfIOMapOfVtk;
64 typedef SALOME_DataMapOfIOMapOfVtk::Iterator SALOME_DataMapIteratorOfIOMapOfVtk;
67 * Class : SMESHGUI_FilterTable
68 * Description : Frame containing
69 * - Button group for switching entity type
70 * - Table for displaying filter criterions
71 * - Buttons for editing table
74 class SMESHGUI_EXPORT SMESHGUI_FilterTable : public QWidget
83 class AdditionalWidget;
86 typedef QMap<int, Table*> TableMap;
89 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const int );
90 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const QList<int>& );
91 virtual ~SMESHGUI_FilterTable();
93 void Init( const QList<int>& );
95 QGroupBox* GetTableGrp();
97 bool IsValid( const bool = true, const int = -1 ) const;
99 void SetType(const int);
100 void RestorePreviousEntityType();
101 int NumRows( const int = -1 ) const;
102 void Clear( const int = -1 );
103 void SetEditable( const bool );
104 void SetEnabled( const bool );
105 void SetLibsEnabled( const bool );
106 bool IsEditable() const;
108 int GetCriterionType( const int, const int = -1 ) const;
110 void GetCriterion( const int,
111 SMESH::Filter::Criterion&,
112 const int = -1 ) const;
114 void SetCriterion( const int,
115 const SMESH::Filter::Criterion&,
118 void AddCriterion( const SMESH::Filter::Criterion&,
121 void Copy( const SMESHGUI_FilterTable* );
122 void SetValidity( const bool );
124 bool CurrentCell( int&, int& ) const;
125 void SetThreshold( const int,
129 bool GetThreshold( const int,
133 void SetID( const int,
137 bool GetID( const int,
144 void CopyFromClicked();
146 void EntityTypeChanged( const int );
147 void NeedValidation();
148 void CriterionChanged( const int, const int );
149 void ThresholdChanged( const int, const int );
150 void CurrentChanged( int, int );
157 void onCopyFromBtn();
159 void onCriterionChanged( int, int );
160 void onEntityType( int );
161 void onCurrentChanged( int, int );
164 void addRow( Table*, const int, const bool = true );
165 QTableWidgetItem* getCriterionItem( const int ) const;
166 QTableWidgetItem* getCompareItem() const;
167 QTableWidgetItem* getUnaryItem() const;
168 QTableWidgetItem* getBinaryItem() const;
169 const QMap<int, QString>& getCriteria( const int ) const;
170 const QMap<int, QString>& getCompare() const;
171 Table* createTable( QWidget*, const int );
172 QWidget* createAdditionalFrame( QWidget* );
173 int getFirstSelectedRow() const;
174 void onCriterionChanged( const int, const int, const int );
176 void updateBtnState();
177 void removeAdditionalWidget( QTableWidget*, const int );
178 void updateAdditionalWidget();
179 const char* getPrecision( const int );
181 const QMap<int, QString>& getSupportedTypes() const;
184 SMESHGUI* mySMESHGUI;
186 QGroupBox* myTableGrp;
187 QWidget* mySwitchTableGrp;
190 QPushButton* myAddBtn;
191 QPushButton* myInsertBtn;
192 QPushButton* myRemoveBtn;
193 QPushButton* myClearBtn;
194 QPushButton* myCopyFromBtn;
195 QPushButton* myAddToBtn;
197 QGroupBox* myEntityTypeBox;
198 QButtonGroup* myEntityTypeGrp;
203 SMESHGUI_FilterLibraryDlg* myLibDlg;
205 QStackedWidget* myWgStack;
207 QMap<QTableWidgetItem*, AdditionalWidget*> myAddWidgets;
212 * Class : SMESHGUI_FilterDlg
213 * Description : Dialog to specify filters for VTK viewer
216 class SMESHGUI_FilterDlg : public QDialog
220 // Source elements to be selected
221 enum { Mesh, Selection, Dialog, None };
224 enum { BTN_OK, BTN_Apply, BTN_Close, BTN_Help };
227 SMESHGUI_FilterDlg( SMESHGUI*, const QList<int>& );
228 SMESHGUI_FilterDlg( SMESHGUI*, const int );
229 virtual ~SMESHGUI_FilterDlg();
231 void Init( const QList<int>&, const bool setInViewer=true );
232 void Init( const int, const bool setInViewer=true );
235 void SetMesh (SMESH::SMESH_Mesh_var);
236 void SetGroup (SMESH::SMESH_GroupOnFilter_var);
237 void SetSourceWg( QWidget*, const bool initOnApply = true );
238 void SetEnabled( bool setInViewer, bool diffSources );
240 static SMESH::Filter::Criterion createCriterion();
242 SMESH::Filter_var GetFilter() const;
243 void SetFilter(SMESH::Filter_var filter, int type);
244 void UnRegisterFilters();
251 virtual void reject();
259 void onSelectionDone();
260 void onCriterionChanged( const int, const int );
261 void onThresholdChanged( const int, const int );
262 void onCurrentChanged( int, int );
268 void construct( const QList<int>& );
270 void enterEvent( QEvent* );
271 void keyPressEvent( QKeyEvent* );
274 QWidget* createButtonFrame( QWidget* );
275 QWidget* createMainFrame( QWidget* );
276 QWidget* createSourceGroup( QWidget* );
277 void updateMainButtons();
280 bool isValid() const;
281 bool createFilter( const int );
282 void insertFilterInViewer();
283 void selectInViewer( const int, const QList<int>& );
284 void filterSource( const int, QList<int>& );
285 void filterSelectionSource( const int, QList<int>& );
286 void getIdsFromWg( const QWidget*, QList<int>& ) const;
287 void setIdsToWg( QWidget*, const QList<int>& );
288 Selection_Mode getSelMode( const int ) const;
289 void updateSelection();
290 SMESH_Actor* getActor();
294 QWidget* myMainFrame;
295 QButtonGroup* mySourceGrp;
297 QCheckBox* mySetInViewer;
299 QMap<int, QPushButton*> myButtons;
301 SMESHGUI_FilterTable* myTable;
305 SMESHGUI* mySMESHGUI;
306 LightApp_SelectionMgr* mySelectionMgr;
307 SVTK_Selector* mySelector;
308 SMESH::SMESH_Mesh_var myMesh;
309 SMESH::SMESH_GroupOnFilter_var myGroup;
310 bool myInitSourceWgOnApply;
311 bool myInsertEnabled;
312 bool myDiffSourcesEnabled;
315 SALOME_DataMapOfIOMapOfVtk myIObjects;
316 bool myIsSelectionChanged;
317 QMap< int, SMESH::Filter_var > myFilter;
318 QMap< int, bool > myInsertState;
319 QMap< int, int > myApplyToState;
321 QString myHelpFileName;
323 bool myToRestoreSelMode;
324 int mySelModeToRestore;
325 void restoreSelMode();
328 #endif // SMESHGUI_FILTERDLG_H