Salome HOME
Integrated to V7_main: 0022366: EDF SMESH: Create Mesh dialog box improvement: create...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshPatternDlg.h
1 // Copyright (C) 2007-2013  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 protected slots:
79   virtual void                        reject();
80
81 private slots:
82   void                                onOk();
83   bool                                onApply();
84   void                                onHelp();
85
86   void                                onDeactivate();
87
88   void                                onSelectionDone();
89   void                                onSelInputChanged();
90
91   void                                onTypeChanged( int );
92   void                                onModeToggled( bool );
93   void                                onOpen();
94   void                                onNew();
95   void                                onReverse( bool );
96   void                                onPreview( bool );
97   void                                onOkCreationDlg();
98   void                                onCloseCreationDlg();
99   void                                onTextChanged( const QString& );
100   void                                onNodeChanged( int );
101
102 private:
103   QWidget*                            createButtonFrame( QWidget* );
104   QWidget*                            createMainFrame( QWidget* );
105   void                                displayPreview();
106   vtkUnstructuredGrid*                getGrid();
107   void                                erasePreview();
108   void                                updateWgState();
109   bool                                loadFromFile( const QString& );
110   void                                activateSelection();
111   QStringList                         prepareFilters() const;
112   QString                             autoExtension( const QString& ) const;
113   void                                enterEvent( QEvent* );
114   void                                keyPressEvent( QKeyEvent* );
115   bool                                isValid( const bool = true );
116   void                                resetSelInput();
117   bool                                isRefine() const;
118
119   bool                                getIds( QList<int>& ) const;
120   int                                 getNode( bool = false ) const;
121
122 private:
123   QPushButton*                        myOkBtn;
124   QPushButton*                        myApplyBtn;
125   QPushButton*                        myCloseBtn;
126   QPushButton*                        myHelpBtn;
127
128   QButtonGroup*                       myTypeGrp;
129   QRadioButton*                       mySwitch2d;
130   QRadioButton*                       mySwitch3d;
131
132   QCheckBox*                          myRefine;
133
134   QFrame*                             myRefineGrp;
135   SalomeApp_IntSpinBox*               myNode1;
136   SalomeApp_IntSpinBox*               myNode2;
137   QLabel*                             myNode2Lbl;
138
139   QFrame*                             myGeomGrp;
140   QMap<int, QPushButton*>             mySelBtn;
141   QMap<int, QLineEdit*>               mySelEdit;
142   QMap<int, QLabel*>                  mySelLbl;
143
144   QLineEdit*                          myName;
145   QPushButton*                        myOpenBtn;
146   QPushButton*                        myNewBtn;
147
148   QCheckBox*                          myReverseChk;
149   QCheckBox*                          myCreatePolygonsChk;
150   QCheckBox*                          myCreatePolyedrsChk;
151   SMESHGUI_PatternWidget*             myPicture2d;
152   QLabel*                             myPicture3d;
153
154   QCheckBox*                          myPreviewChk;
155
156   SMESHGUI*                           mySMESHGUI;
157   SVTK_Selector*                      mySelector;
158   LightApp_SelectionMgr*              mySelectionMgr;
159   int                                 mySelInput;
160   int                                 myNbPoints;
161   int                                 myType;
162   bool                                myIsCreateDlgOpen;
163   bool                                myBusy;
164
165   SMESH::SMESH_Mesh_var               myMesh;
166   GEOM::GEOM_Object_var               myMeshShape;
167   QMap<int, GEOM::GEOM_Object_var>    myGeomObj;
168   
169   SMESHGUI_CreatePatternDlg*          myCreationDlg;
170   SMESH::SMESH_Pattern_var            myPattern;
171   SALOME_Actor*                       myPreviewActor;
172
173   QString                             myHelpFileName;
174 };
175
176 #endif // SMESHGUI_MESHPATTERNDLG_H