1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 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
22 // File : SMESHGUI_FilterDlg.h
23 // Author : Sergey LITONIN, Open CASCADE S.A.S.
26 #ifndef SMESHGUI_FILTERDLG_H
27 #define SMESHGUI_FILTERDLG_H
30 #include "SMESH_SMESHGUI.hxx"
38 // SALOME GUI includes
39 #include <SALOME_DataMapOfIOMapOfInteger.hxx>
40 #include <SVTK_Selection.h>
43 #include <SALOMEconfig.h>
44 #include CORBA_SERVER_HEADER(SMESH_Filter)
45 #include CORBA_SERVER_HEADER(SMESH_Mesh)
53 class QTableWidgetItem;
55 class LightApp_SelectionMgr;
57 class SMESHGUI_FilterLibraryDlg;
61 * Class : SMESHGUI_FilterTable
62 * Description : Frame containig
63 * - Button group for switching entity type
64 * - Table for displaying filter criterions
65 * - Buttons for editing table
68 class SMESHGUI_EXPORT SMESHGUI_FilterTable : public QWidget
75 class AdditionalWidget;
78 typedef QMap<int, Table*> TableMap;
81 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const int );
82 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const QList<int>& );
83 virtual ~SMESHGUI_FilterTable();
85 void Init( const QList<int>& );
87 QGroupBox* GetTableGrp();
89 bool IsValid( const bool = true, const int = -1 ) const;
91 void SetType(const int);
92 void RestorePreviousEntityType();
93 int NumRows( const int = -1 ) const;
94 void Clear( const int = -1 );
95 void SetEditable( const bool );
96 void SetEnabled( const bool );
97 void SetLibsEnabled( const bool );
98 bool IsEditable() const;
100 int GetCriterionType( const int, const int = -1 ) const;
102 void GetCriterion( const int,
103 SMESH::Filter::Criterion&,
104 const int = -1 ) const;
106 void SetCriterion( const int,
107 const SMESH::Filter::Criterion&,
110 void AddCriterion( const SMESH::Filter::Criterion&,
113 void Copy( const SMESHGUI_FilterTable* );
114 void SetValidity( const bool );
116 bool CurrentCell( int&, int& ) const;
117 void SetThreshold( const int,
121 bool GetThreshold( const int,
125 void SetID( const int,
129 bool GetID( const int,
136 void CopyFromClicked();
138 void EntityTypeChanged( const int );
139 void NeedValidation();
140 void CriterionChanged( const int, const int );
141 void CurrentChanged( int, int );
148 void onCopyFromBtn();
150 void onCriterionChanged( int, int );
151 void onEntityType( int );
152 void onCurrentChanged( int, int );
155 void addRow( Table*, const int, const bool = true );
156 QTableWidgetItem* getCriterionItem( const int ) const;
157 QTableWidgetItem* getCompareItem() const;
158 QTableWidgetItem* getUnaryItem() const;
159 QTableWidgetItem* getBinaryItem() const;
160 const QMap<int, QString>& getCriteria( const int ) const;
161 const QMap<int, QString>& getCompare() const;
162 Table* createTable( QWidget*, const int );
163 QWidget* createAdditionalFrame( QWidget* );
164 int getFirstSelectedRow() const;
165 void onCriterionChanged( const int, const int, const int );
167 void updateBtnState();
168 void removeAdditionalWidget( QTableWidget*, const int );
169 void updateAdditionalWidget();
171 const QMap<int, QString>& getSupportedTypes() const;
174 SMESHGUI* mySMESHGUI;
176 QGroupBox* myTableGrp;
177 QWidget* mySwitchTableGrp;
180 QPushButton* myAddBtn;
181 QPushButton* myInsertBtn;
182 QPushButton* myRemoveBtn;
183 QPushButton* myClearBtn;
184 QPushButton* myCopyFromBtn;
185 QPushButton* myAddToBtn;
187 QGroupBox* myEntityTypeBox;
188 QButtonGroup* myEntityTypeGrp;
193 SMESHGUI_FilterLibraryDlg* myLibDlg;
195 QStackedWidget* myWgStack;
197 QMap<QTableWidgetItem*, AdditionalWidget*> myAddWidgets;
202 * Class : SMESHGUI_FilterDlg
203 * Description : Dialog to specify filters for VTK viewer
206 class SMESHGUI_FilterDlg : public QDialog
210 // Source elements to be selected
211 enum { Mesh, Selection, Dialog, None };
214 enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close, BTN_Help };
217 SMESHGUI_FilterDlg( SMESHGUI*, const QList<int>& );
218 SMESHGUI_FilterDlg( SMESHGUI*, const int );
219 virtual ~SMESHGUI_FilterDlg();
221 void Init( const QList<int>& );
222 void Init( const int );
225 void SetMesh (SMESH::SMESH_Mesh_var);
226 void SetSourceWg( QWidget* );
228 static SMESH::Filter::Criterion createCriterion();
241 void onSelectionDone();
242 void onCriterionChanged( const int, const int );
243 void onCurrentChanged( int, int );
247 void construct( const QList<int>& );
249 void closeEvent( QCloseEvent* );
250 void enterEvent( QEvent* );
251 void keyPressEvent( QKeyEvent* );
254 QWidget* createButtonFrame( QWidget* );
255 QWidget* createMainFrame( QWidget* );
256 QWidget* createSourceGroup( QWidget* );
257 void updateMainButtons();
260 bool isValid() const;
261 bool createFilter( const int );
262 void insertFilterInViewer();
263 void selectInViewer( const int, const QList<int>& );
264 void filterSource( const int, QList<int>& );
265 void filterSelectionSource( const int, QList<int>& );
266 void getIdsFromWg( const QWidget*, QList<int>& ) const;
267 void setIdsToWg( QWidget*, const QList<int>& );
268 Selection_Mode getSelMode( const int ) const;
269 void updateSelection();
273 QWidget* myMainFrame;
274 QButtonGroup* mySourceGrp;
276 QCheckBox* mySetInViewer;
278 QMap<int, QPushButton*> myButtons;
280 SMESHGUI_FilterTable* myTable;
284 SMESHGUI* mySMESHGUI;
285 LightApp_SelectionMgr* mySelectionMgr;
286 SVTK_Selector* mySelector;
287 SMESH::SMESH_Mesh_var myMesh;
290 SALOME_DataMapOfIOMapOfInteger myIObjects;
291 bool myIsSelectionChanged;
292 QMap< int, SMESH::Filter_var > myFilter;
293 QMap< int, bool > myInsertState;
294 QMap< int, int > myApplyToState;
296 QString myHelpFileName;
299 #endif // SMESHGUI_FILTERDLG_H