Salome HOME
Merge from V6_5_BR 05/06/2012
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshPatternDlg.h
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File   : SMESHGUI_MeshPatternDlg.h
24 // Author : Sergey LITONIN, Open CASCADE S.A.S.
25 //
26 #ifndef SMESHGUI_MESHPATTERNDLG_H
27 #define SMESHGUI_MESHPATTERNDLG_H
28
29 // SMESH includes
30 #include "SMESH_SMESHGUI.hxx"
31
32 // Qt includes
33 #include <QDialog>
34 #include <QMap>
35
36 // IDL includes
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(SMESH_Mesh)
39 #include CORBA_SERVER_HEADER(SMESH_Pattern)
40
41 class QFrame;
42 class QLineEdit;
43 class QPushButton;
44 class QRadioButton;
45 class QCheckBox;
46 class QButtonGroup;
47 class QLabel;
48 class SalomeApp_IntSpinBox;
49 class vtkUnstructuredGrid;
50 class SALOME_Actor;
51 class SVTK_Selector;
52 class LightApp_SelectionMgr;
53 class SMESHGUI;
54 class SMESHGUI_CreatePatternDlg;
55 class SMESHGUI_PatternWidget;
56
57 /*
58   Class       : SMESHGUI_MeshPatternDlg
59   Description : Dialog to specify filters for VTK viewer
60 */
61
62 class SMESHGUI_EXPORT SMESHGUI_MeshPatternDlg : public QDialog
63 {
64   Q_OBJECT
65
66   // Pattern type
67   enum { Type_2d, Type_3d };
68
69   // selection input
70   enum { Mesh, Object, Vertex1, Vertex2, Ids };
71
72 public:
73   SMESHGUI_MeshPatternDlg( SMESHGUI* );
74   virtual ~SMESHGUI_MeshPatternDlg();
75
76   void                                Init();
77   
78 private slots:
79   void                                onOk();
80   bool                                onApply();
81   void                                onClose();
82   void                                onHelp();
83
84   void                                onDeactivate();
85
86   void                                onSelectionDone();
87   void                                onSelInputChanged();
88
89   void                                onTypeChanged( int );
90   void                                onModeToggled( bool );
91   void                                onOpen();
92   void                                onNew();
93   void                                onReverse( bool );
94   void                                onPreview( bool );
95   void                                onOkCreationDlg();
96   void                                onCloseCreationDlg();
97   void                                onTextChanged( const QString& );
98   void                                onNodeChanged( int );
99
100 private:
101   QWidget*                            createButtonFrame( QWidget* );
102   QWidget*                            createMainFrame( QWidget* );
103   void                                displayPreview();
104   vtkUnstructuredGrid*                getGrid();
105   void                                erasePreview();
106   void                                updateWgState();
107   bool                                loadFromFile( const QString& );
108   void                                activateSelection();
109   QStringList                         prepareFilters() const;
110   QString                             autoExtension( const QString& ) const;
111   void                                closeEvent( QCloseEvent* );
112   void                                enterEvent( QEvent* );
113   void                                keyPressEvent( QKeyEvent* );
114   bool                                isValid( const bool = true );
115   void                                resetSelInput();
116   bool                                isRefine() const;
117
118   bool                                getIds( QList<int>& ) const;
119   int                                 getNode( bool = false ) const;
120
121 private:
122   QPushButton*                        myOkBtn;
123   QPushButton*                        myApplyBtn;
124   QPushButton*                        myCloseBtn;
125   QPushButton*                        myHelpBtn;
126
127   QButtonGroup*                       myTypeGrp;
128   QRadioButton*                       mySwitch2d;
129   QRadioButton*                       mySwitch3d;
130
131   QCheckBox*                          myRefine;
132
133   QFrame*                             myRefineGrp;
134   SalomeApp_IntSpinBox*               myNode1;
135   SalomeApp_IntSpinBox*               myNode2;
136   QLabel*                             myNode2Lbl;
137
138   QFrame*                             myGeomGrp;
139   QMap<int, QPushButton*>             mySelBtn;
140   QMap<int, QLineEdit*>               mySelEdit;
141   QMap<int, QLabel*>                  mySelLbl;
142
143   QLineEdit*                          myName;
144   QPushButton*                        myOpenBtn;
145   QPushButton*                        myNewBtn;
146
147   QCheckBox*                          myReverseChk;
148   QCheckBox*                          myCreatePolygonsChk;
149   QCheckBox*                          myCreatePolyedrsChk;
150   SMESHGUI_PatternWidget*             myPicture2d;
151   QLabel*                             myPicture3d;
152
153   QCheckBox*                          myPreviewChk;
154
155   SMESHGUI*                           mySMESHGUI;
156   SVTK_Selector*                      mySelector;
157   LightApp_SelectionMgr*              mySelectionMgr;
158   int                                 mySelInput;
159   int                                 myNbPoints;
160   int                                 myType;
161   bool                                myIsCreateDlgOpen;
162   bool                                myBusy;
163
164   SMESH::SMESH_Mesh_var               myMesh;
165   GEOM::GEOM_Object_var               myMeshShape;
166   QMap<int, GEOM::GEOM_Object_var>    myGeomObj;
167   
168   SMESHGUI_CreatePatternDlg*          myCreationDlg;
169   SMESH::SMESH_Pattern_var            myPattern;
170   SALOME_Actor*                       myPreviewActor;
171
172   QString                             myHelpFileName;
173 };
174
175 #endif // SMESHGUI_MESHPATTERNDLG_H