Salome HOME
Fix for problem: SIGSEGV appears if to select group after opening "Edit Group" dialog...
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 //
20 //
21 //
22 //  File   : SMESHGUI_MeshPatternDlg.h
23 //  Author : Sergey LITONIN
24 //  Module : SMESH
25
26
27 #ifndef SMESHGUI_MeshPatternDlg_H
28 #define SMESHGUI_MeshPatternDlg_H
29
30 #include <qdialog.h>
31
32 // IDL Headers
33 #include <SALOMEconfig.h>
34 #include CORBA_SERVER_HEADER(GEOM_Gen)
35 #include CORBA_SERVER_HEADER(SMESH_Mesh)
36 #include CORBA_SERVER_HEADER(SMESH_Pattern)
37
38 class QCloseEvent;
39 class QFrame;
40 class QLineEdit;
41 class SMESHGUI_SpinBox;
42 class QPushButton;
43 class SalomeApp_SelectionMgr;
44 class QRadioButton;
45 class QCheckBox;
46 class QButtonGroup;
47 class QLabel;
48 class QSpinBox;
49 class QGroupBox;
50 class SMESHGUI_CreatePatternDlg;
51 class SMESHGUI_PatternWidget;
52 class vtkUnstructuredGrid;
53 class SALOME_Actor;
54 class SVTK_ViewWindow;
55 class SVTK_Selector;
56 class SMESHGUI;
57
58 /*
59   Class       : SMESHGUI_MeshPatternDlg
60   Description : Dialog to specify filters for VTK viewer
61 */
62
63 class SMESHGUI_MeshPatternDlg : public QDialog
64 {
65   Q_OBJECT
66
67   // Pattern type
68   enum { Type_2d, Type_3d };
69
70   // selection input
71   enum { Mesh, Object, Vertex1, Vertex2, Ids };
72
73 public:
74                                       SMESHGUI_MeshPatternDlg( SMESHGUI*,
75                                                                const char* = 0 );
76   virtual                             ~SMESHGUI_MeshPatternDlg();
77
78   void                                Init();
79   
80 private slots:
81
82   void                                onOk();
83   bool                                onApply();
84   void                                onClose();
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 value );
101
102 private:
103
104   QFrame*                             createButtonFrame( QWidget* );
105   QFrame*                             createMainFrame  ( QWidget* );
106   void                                displayPreview();
107   vtkUnstructuredGrid*                getGrid();
108   void                                erasePreview();
109   void                                updateWgState();
110   bool                                loadFromFile( const QString& );
111   void                                activateSelection();
112   QStringList                         prepareFilters() const;
113   QString                             autoExtension( const QString& theFileName ) const;
114   void                                closeEvent( QCloseEvent* e ) ;
115   void                                enterEvent ( QEvent * ) ;
116   bool                                isValid( const bool theMess = true );
117   void                                resetSelInput();
118   bool                                isRefine() const;
119
120   bool                                getIds( QValueList<int>& ) const;
121   int                                 getNode( bool = false ) const;
122
123 private:
124
125   QPushButton*                        myOkBtn;
126   QPushButton*                        myApplyBtn;
127   QPushButton*                        myCloseBtn;
128
129   QButtonGroup*                       myTypeGrp;
130   QRadioButton*                       mySwitch2d;
131   QRadioButton*                       mySwitch3d;
132
133   QCheckBox*                          myRefine;
134
135   QFrame*                             myRefineGrp;
136   QSpinBox*                           myNode1;
137   QSpinBox*                           myNode2;
138   QLabel*                             myNode2Lbl;
139
140   QGroupBox*                          myGeomGrp;
141   QMap< int, QPushButton* >           mySelBtn;
142   QMap< int, QLineEdit* >             mySelEdit;
143   QMap< int, QLabel* >                mySelLbl;
144
145   QLineEdit*                          myName;
146   QPushButton*                        myOpenBtn;
147   QPushButton*                        myNewBtn;
148
149   QCheckBox*                          myReverseChk;
150   QCheckBox*                          myCreatePolygonsChk;
151   QCheckBox*                          myCreatePolyedrsChk;
152   SMESHGUI_PatternWidget*             myPicture2d;
153   QFrame*                             myPicture3d;
154   QLabel*                             myPreview3d;
155
156   QCheckBox*                          myPreviewChk;
157
158   SMESHGUI*                           mySMESHGUI;
159   SVTK_Selector*                      mySelector;
160   SalomeApp_SelectionMgr*             mySelectionMgr;
161   int                                 mySelInput;
162   int                                 myNbPoints;
163   int                                 myType;
164   bool                                myIsCreateDlgOpen;
165   bool                                myBusy;
166
167   SMESH::SMESH_Mesh_var               myMesh;
168   GEOM::GEOM_Object_var               myMeshShape;
169   QMap< int, GEOM::GEOM_Object_var >  myGeomObj;
170   
171   SMESHGUI_CreatePatternDlg*          myCreationDlg;
172   SMESH::SMESH_Pattern_var            myPattern;
173   SALOME_Actor*                       myPreviewActor;
174 };
175
176 #endif