Salome HOME
SALOME PAL V1_4_1
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterDlg.h
1 //  SMESH SMESHGUI : GUI for SMESH component\r
2 //\r
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
5 // \r
6 //  This library is free software; you can redistribute it and/or \r
7 //  modify it under the terms of the GNU Lesser General Public \r
8 //  License as published by the Free Software Foundation; either \r
9 //  version 2.1 of the License. \r
10 // \r
11 //  This library is distributed in the hope that it will be useful, \r
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of \r
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU \r
14 //  Lesser General Public License for more details. \r
15 // \r
16 //  You should have received a copy of the GNU Lesser General Public \r
17 //  License along with this library; if not, write to the Free Software \r
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA \r
19 // \r
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
21 //\r
22 //\r
23 //\r
24 //  File   : SMESHGUI_FilterDlg.h\r
25 //  Author : Sergey LITONIN\r
26 //  Module : SMESH\r
27 \r
28 \r
29 #ifndef SMESHGUI_FilterDlg_H\r
30 #define SMESHGUI_FilterDlg_H\r
31 \r
32 #include <qdialog.h>\r
33 #include <qmap.h>\r
34 #include <qvaluelist.h>\r
35 #include <SALOME_Selection.h>\r
36 \r
37 #include <SALOMEconfig.h>\r
38 #include CORBA_SERVER_HEADER(SMESH_Filter)\r
39 #include CORBA_SERVER_HEADER(SMESH_Mesh)\r
40 \r
41 class QCloseEvent;\r
42 class QWidgetStack;\r
43 class QStringList;\r
44 class QTableItem;\r
45 class QFrame;\r
46 class QEvent;\r
47 class QPushButton;\r
48 class QTable;\r
49 class SALOME_Selection;\r
50 class SMESHGUI;\r
51 class QComboBox;\r
52 class QButtonGroup;\r
53 class QCheckBox;\r
54 class QGroupBox;\r
55 \r
56 \r
57 /*\r
58   Class       : SMESHGUI_FilterDlg\r
59   Description : Dialog to specify filters for VTK viewer\r
60 */\r
61 \r
62 class SMESHGUI_FilterDlg : public QDialog\r
63\r
64   Q_OBJECT\r
65 \r
66   class Table;\r
67 \r
68   // Edge criteria\r
69   enum { FreeBorders = 0, MultiBorders, Length }; \r
70 \r
71   // Face criteria\r
72   enum { AspectRatio = 0, Warping, MinimumAngle, Taper, Skew, Area }; \r
73 \r
74   // Comparision\r
75   enum { LessThan = 0, MoreThan, EqualTo };\r
76 \r
77   // Logical operations\r
78   enum { LO_And = 0, LO_Or, LO_Undefined };\r
79 \r
80   // Source elements to be selected\r
81   enum { Mesh, Selection, Dialog, None };\r
82 \r
83   typedef QMap<int, Table*> TableMap;\r
84 \r
85 public:\r
86                             SMESHGUI_FilterDlg( QWidget*    parent, \r
87                                                 const int   type,\r
88                                                 const bool  theModal = true,\r
89                                                 const char* name = 0 );\r
90   virtual                   ~SMESHGUI_FilterDlg();\r
91 \r
92   void                      Init( const int type );\r
93 \r
94   void                      SetSelection( SALOME_Selection* );\r
95   void                      SetMesh( SMESH::SMESH_Mesh_ptr );\r
96   void                      SetSourceWg( QWidget* );\r
97 \r
98 private slots:\r
99 \r
100   void                      onAddBtn();\r
101   void                      onRemoveBtn();\r
102   void                      onClearBtn();\r
103   void                      onCriterionChanged( int, int );\r
104 \r
105   void                      onOk();\r
106   bool                      onApply();\r
107   void                      onClose();\r
108   void                      onDeactivate();\r
109 \r
110 private:\r
111 \r
112   void                      closeEvent( QCloseEvent* e );\r
113   void                      enterEvent ( QEvent * );\r
114 \r
115   void                      updateBtnState();\r
116 \r
117   // dialog creation\r
118   QFrame*                   createButtonFrame( QWidget*, const bool );\r
119   QFrame*                   createMainFrame( QWidget* );\r
120   Table*                    createTable( QWidget*, const int );\r
121   QButtonGroup*             createSourceGroup( QWidget* );\r
122   void                      addRow( Table*, const int );\r
123   QTableItem*               getCriterionItem( QTable*, const int );\r
124   QTableItem*               getCompareItem( QTable* );\r
125   QTableItem*               getNotItem( QTable* );\r
126   QTableItem*               getLogOpItem( QTable* );\r
127   const QStringList&        getCriteria( const int theType ) const;\r
128   const QStringList&        getCompare () const;\r
129   \r
130   // query\r
131   int                       getCurrType() const;\r
132   int                       getCriterion( const int theType, const int theRow ) const;\r
133 \r
134   // execution\r
135   bool                      isValid() const;\r
136   SMESH::Predicate_ptr      createPredicate( const int theType );\r
137   void                      insertFilterInViewer( SMESH::Predicate_ptr thePred );\r
138   void                      selectInViewer( const int theType,\r
139                                             const QValueList<int>& theIds );\r
140   void                      filterSource( const int            theType,\r
141                                           SMESH::Predicate_ptr thePred,\r
142                                           QValueList<int>&     theResIds );\r
143   void                      filterSelectionSource( const int            theType,\r
144                                                    SMESH::Predicate_ptr thePred,\r
145                                                    QValueList<int>&     theResIds );\r
146   void                      getIdsFromWg( const QWidget*, QValueList<int>& ) const;\r
147   void                      setIdsToWg( QWidget*, const QValueList<int>& );\r
148   Selection_Mode            getSelMode( const int ) const;\r
149 \r
150 private:\r
151 \r
152   // widgets\r
153   QFrame*                   myMainFrame;\r
154   QGroupBox*                myTableGrp;\r
155 \r
156   TableMap                  myTables;\r
157   QPushButton*              myAddBtn;\r
158   QPushButton*              myRemoveBtn;\r
159   QPushButton*              myClearBtn;\r
160   QButtonGroup*             mySourceGrp;\r
161   QCheckBox*                mySetInViewer;\r
162 \r
163   QPushButton*              myOkBtn;\r
164   QPushButton*              myApplyBtn;\r
165   QPushButton*              myCloseBtn;\r
166 \r
167   // initial fields\r
168   int                       myType;\r
169   SMESHGUI*                 mySMESHGUI;\r
170   SALOME_Selection*         mySelection;\r
171   SMESH::SMESH_Mesh_ptr     myMesh;\r
172   QWidget*                  mySourceWg;\r
173 };\r
174 \r
175 #endif\r
176 \r
177 \r
178 \r
179 \r
180 \r
181 \r
182 \r
183 \r
184 \r
185 \r
186 \r
187 \r
188 \r
189 \r
190 \r
191 \r
192 \r
193 \r
194 \r
195 \r