Salome HOME
Prevent exception at shape selection if no mesh was pre-selected
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_EditHypothesesDlg.h
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESHGUI_EditHypothesesDlg.h
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef DIALOGBOX_EDIT_HYPOTHESES_H
30 #define DIALOGBOX_EDIT_HYPOTHESES_H
31
32 #include "SALOME_Selection.h"
33 #include "SALOME_TypeFilter.hxx"
34 #include "SMESH_TypeFilter.hxx"
35
36 // QT Includes
37 #include <qdialog.h>
38
39 // IDL Headers
40 #include <SALOMEconfig.h>
41 #include CORBA_SERVER_HEADER(GEOM_Gen)
42 #include CORBA_SERVER_HEADER(SMESH_Mesh)
43
44 #include <map>
45 #include <string>
46
47 class QGroupBox;
48 class QLabel;
49 class QLineEdit;
50 class QPushButton;
51 class QListBox;
52 class QListBoxItem;
53 class SMESHGUI;
54
55 typedef map<string, int> MapIOR;
56
57 //=================================================================================
58 // class    : SMESHGUI_EditHypothesesDlg
59 // purpose  :
60 //=================================================================================
61 class SMESHGUI_EditHypothesesDlg : public QDialog
62
63     Q_OBJECT
64
65 public:
66     SMESHGUI_EditHypothesesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
67     ~SMESHGUI_EditHypothesesDlg();
68
69 protected:
70     virtual void closeEvent( QCloseEvent* e ); 
71     virtual void enterEvent ( QEvent* );
72
73 private:
74     void Init( SALOME_Selection* Sel ) ;
75
76     void InitHypDefinition();
77     void InitAlgoDefinition();
78     void InitHypAssignation();
79     void InitAlgoAssignation();
80
81     void InitGeom();
82
83     void UpdateControlState();
84
85     bool StoreMesh();
86     bool StoreSubMesh();
87
88     bool IsOld(QListBoxItem* hypItem);
89
90 private:
91     SMESHGUI*                     mySMESHGUI ;
92     SALOME_Selection*             mySelection ;
93              
94     GEOM::GEOM_Object_var         myGeomShape ;
95     QLineEdit*                    myEditCurrentArgument; 
96
97     SMESH::SMESH_Mesh_var         myMesh;
98     SMESH::SMESH_subMesh_var      mySubMesh;
99
100     Handle(SALOME_TypeFilter)     myGeomFilter;
101     Handle(SMESH_TypeFilter)      myMeshOrSubMeshFilter;
102
103     MapIOR                        myMapOldHypos, myMapOldAlgos;
104     int                           myNbModification;
105
106     bool                          myImportedMesh;
107  
108     QGroupBox*    GroupButtons;
109     QPushButton*  buttonOk;
110     QPushButton*  buttonApply;
111     QPushButton*  buttonCancel;
112
113     QGroupBox*    GroupC1;
114     QLabel*       TextLabelC1A1;
115     QPushButton*  SelectButtonC1A1;
116     QLineEdit*    LineEditC1A1;
117     QLabel*       TextLabelC1A2;
118     QPushButton*  SelectButtonC1A2;
119     QLineEdit*    LineEditC1A2;
120
121     QGroupBox*    GroupHypotheses;
122     QLabel*       TextHypDefinition;
123     QListBox*     ListHypDefinition;
124     QLabel*       TextHypAssignation;
125     QListBox*     ListHypAssignation;
126
127     QGroupBox*    GroupAlgorithms;
128     QLabel*       TextAlgoDefinition;
129     QListBox*     ListAlgoDefinition;
130     QLabel*       TextAlgoAssignation;
131     QListBox*     ListAlgoAssignation;
132
133 private slots:
134     void ClickOnOk();
135     bool ClickOnApply();
136     void ClickOnCancel();
137     void SetEditCurrentArgument() ;
138     void SelectionIntoArgument() ;
139     void DeactivateActiveDialog() ;
140     void ActivateThisDialog() ;
141
142     void removeItem(QListBoxItem*);
143     void addItem(QListBoxItem*);
144 };
145
146 #endif // DIALOGBOX_EDIT_HYPOTHESES_H