Salome HOME
d74249b0e69c47b0791edac24e07b54096844afe
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshPatternDlg.h
1 // Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 //
4 // This library is free software; you can redistribute it and/or 
5 // modify it under the terms of the GNU Lesser General Public 
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License. 
8 //
9 // This library is distributed in the hope that it will be useful, 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details. 
13 //
14 // You should have received a copy of the GNU Lesser General Public 
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 // File   : SMESHGUI_MeshPatternDlg.h
21 // Author : Sergey LITONIN, Open CASCADE S.A.S.
22 //
23
24 #ifndef SMESHGUI_MESHPATTERNDLG_H
25 #define SMESHGUI_MESHPATTERNDLG_H
26
27 // SMESH includes
28 #include "SMESH_SMESHGUI.hxx"
29
30 // Qt includes
31 #include <QDialog>
32 #include <QMap>
33
34 // IDL includes
35 #include <SALOMEconfig.h>
36 #include CORBA_SERVER_HEADER(SMESH_Mesh)
37 #include CORBA_SERVER_HEADER(SMESH_Pattern)
38
39 class QFrame;
40 class QLineEdit;
41 class QPushButton;
42 class QRadioButton;
43 class QCheckBox;
44 class QButtonGroup;
45 class QLabel;
46 class QSpinBox;
47 class vtkUnstructuredGrid;
48 class SALOME_Actor;
49 class SVTK_Selector;
50 class LightApp_SelectionMgr;
51 class SMESHGUI;
52 class SMESHGUI_CreatePatternDlg;
53 class SMESHGUI_PatternWidget;
54
55 /*
56   Class       : SMESHGUI_MeshPatternDlg
57   Description : Dialog to specify filters for VTK viewer
58 */
59
60 class SMESHGUI_EXPORT SMESHGUI_MeshPatternDlg : public QDialog
61 {
62   Q_OBJECT
63
64   // Pattern type
65   enum { Type_2d, Type_3d };
66
67   // selection input
68   enum { Mesh, Object, Vertex1, Vertex2, Ids };
69
70 public:
71   SMESHGUI_MeshPatternDlg( SMESHGUI* );
72   virtual ~SMESHGUI_MeshPatternDlg();
73
74   void                                Init();
75   
76 private slots:
77   void                                onOk();
78   bool                                onApply();
79   void                                onClose();
80   void                                onHelp();
81
82   void                                onDeactivate();
83
84   void                                onSelectionDone();
85   void                                onSelInputChanged();
86
87   void                                onTypeChanged( int );
88   void                                onModeToggled( bool );
89   void                                onOpen();
90   void                                onNew();
91   void                                onReverse( bool );
92   void                                onPreview( bool );
93   void                                onOkCreationDlg();
94   void                                onCloseCreationDlg();
95   void                                onTextChanged( const QString& );
96   void                                onNodeChanged( int );
97
98 private:
99   QWidget*                            createButtonFrame( QWidget* );
100   QWidget*                            createMainFrame( QWidget* );
101   void                                displayPreview();
102   vtkUnstructuredGrid*                getGrid();
103   void                                erasePreview();
104   void                                updateWgState();
105   bool                                loadFromFile( const QString& );
106   void                                activateSelection();
107   QStringList                         prepareFilters() const;
108   QString                             autoExtension( const QString& ) const;
109   void                                closeEvent( QCloseEvent* );
110   void                                enterEvent( QEvent* );
111   void                                keyPressEvent( QKeyEvent* );
112   bool                                isValid( const bool = true );
113   void                                resetSelInput();
114   bool                                isRefine() const;
115
116   bool                                getIds( QList<int>& ) const;
117   int                                 getNode( bool = false ) const;
118
119 private:
120   QPushButton*                        myOkBtn;
121   QPushButton*                        myApplyBtn;
122   QPushButton*                        myCloseBtn;
123   QPushButton*                        myHelpBtn;
124
125   QButtonGroup*                       myTypeGrp;
126   QRadioButton*                       mySwitch2d;
127   QRadioButton*                       mySwitch3d;
128
129   QCheckBox*                          myRefine;
130
131   QFrame*                             myRefineGrp;
132   QSpinBox*                           myNode1;
133   QSpinBox*                           myNode2;
134   QLabel*                             myNode2Lbl;
135
136   QFrame*                             myGeomGrp;
137   QMap<int, QPushButton*>             mySelBtn;
138   QMap<int, QLineEdit*>               mySelEdit;
139   QMap<int, QLabel*>                  mySelLbl;
140
141   QLineEdit*                          myName;
142   QPushButton*                        myOpenBtn;
143   QPushButton*                        myNewBtn;
144
145   QCheckBox*                          myReverseChk;
146   QCheckBox*                          myCreatePolygonsChk;
147   QCheckBox*                          myCreatePolyedrsChk;
148   SMESHGUI_PatternWidget*             myPicture2d;
149   QLabel*                             myPicture3d;
150
151   QCheckBox*                          myPreviewChk;
152
153   SMESHGUI*                           mySMESHGUI;
154   SVTK_Selector*                      mySelector;
155   LightApp_SelectionMgr*              mySelectionMgr;
156   int                                 mySelInput;
157   int                                 myNbPoints;
158   int                                 myType;
159   bool                                myIsCreateDlgOpen;
160   bool                                myBusy;
161
162   SMESH::SMESH_Mesh_var               myMesh;
163   GEOM::GEOM_Object_var               myMeshShape;
164   QMap<int, GEOM::GEOM_Object_var>    myGeomObj;
165   
166   SMESHGUI_CreatePatternDlg*          myCreationDlg;
167   SMESH::SMESH_Pattern_var            myPattern;
168   SALOME_Actor*                       myPreviewActor;
169
170   QString                             myHelpFileName;
171 };
172
173 #endif // SMESHGUI_MESHPATTERNDLG_H