2 // Created : Sun May 05 11:45:40 2002
3 // Author : Nicolas REJNERI
6 // Copyright : Open CASCADE 2002
10 #ifndef SMESHGUI_HeaderFile
11 #define SMESHGUI_HeaderFile
13 #include "TColStd_MapOfInteger.hxx"
15 #include "SMESHDS_Document.hxx"
18 #include "QAD_Desktop.h"
19 #include "SALOME_Selection.h"
20 #include "SALOME_InteractiveObject.hxx"
22 #include "SMESH_Actor.h"
24 #include "SMESHGUI_StudyAPI.h"
27 #include <SALOMEconfig.h>
28 #include CORBA_SERVER_HEADER(SMESH_Gen)
29 #include CORBA_SERVER_HEADER(SMESH_Mesh)
30 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
31 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
32 #include CORBA_SERVER_HEADER(GEOM_Gen)
33 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
36 #include <qstringlist.h>
39 #include <vtkScalarBarActor.h>
41 //=================================================================================
44 //=================================================================================
45 class SMESHGUI : public QObject
51 QAD_Desktop* myDesktop;
52 QAD_Study* myActiveStudy;
53 SMESH::SMESH_Gen_var myComponentMesh;
54 GEOM::GEOM_Gen_var myComponentGeom;
56 QDialog* myActiveDialogBox;
60 vtkActorCollection* mySimulationActors;
61 vtkActor2DCollection* mySimulationActors2D;
63 SMESH_Actor* myCurrentMesh;
65 SALOMEDS::Study_var myStudy;
68 SMESHGUI_StudyAPI myStudyAPI;
70 // vtkScalarBarActor* myScalarBar;
72 Handle_SMESHDS_Document myDocument;//NBU
74 bool myAutomaticUpdate;
81 static SMESHGUI* GetOrCreateSMESHGUI( QAD_Desktop* desktop );
82 static SMESHGUI* GetSMESHGUI() ;
84 QAD_Study* GetActiveStudy() ;
85 QAD_Desktop* GetDesktop() ;
86 SALOMEDS::Study_ptr GetStudy();
87 SMESHGUI_StudyAPI GetStudyAPI();
89 vtkScalarBarActor* GetScalarBar();
91 QDialog* GetActiveDialogBox() ;
92 void SetActiveDialogBox(QDialog* aDlg) ;
94 void SetState(int aState) ;
96 bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
100 Standard_EXPORT static bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ;
101 Standard_EXPORT static bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent,
102 QAD_StudyFrame* studyFrame );
103 Standard_EXPORT static bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent,
104 QAD_StudyFrame* studyFrame );
105 Standard_EXPORT static bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent,
106 QAD_StudyFrame* studyFrame );
107 Standard_EXPORT static void activeStudyChanged ( QAD_Desktop* parent );
108 Standard_EXPORT static bool SetSettings ( QAD_Desktop* parent );
109 Standard_EXPORT static void DefinePopup( QString & theContext,
111 QString & theObject );
112 Standard_EXPORT static bool CustomPopup ( QAD_Desktop* parent,
114 const QString& theContext,
115 const QString& theParent,
116 const QString& theObject );
117 Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
121 /* Mesh Management */
122 SMESH::SMESH_Mesh_ptr InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
123 SMESH::SMESH_subMesh_ptr AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
125 /* Hypothesis Management */
126 SMESH::SMESH_Hypothesis_ptr CreateHypothesis( QString TypeHypothesis, QString NameHypothesis );
127 void AddHypothesisOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
128 void AddHypothesisOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
130 void RemoveHypothesisOrAlgorithmOnMesh( const Handle(SALOME_InteractiveObject)& IObject ) ;
131 void RemoveHypothesisOrAlgorithmOnMesh( SALOMEDS::SObject_ptr MorSM, SMESH::SMESH_Hypothesis_ptr anHyp ) ;
133 void CreateLocalLength( QString TypeHypothesis, QString NameHypothesis, double Length );
134 void CreateNbSegments( QString TypeHypothesis, QString NameHypothesis, double nbSegments );
135 void CreateMaxElementArea( QString TypeHypothesis, QString NameHypothesis, double MaxArea );
136 void CreateMaxElementVolume( QString TypeHypothesis, QString NameHypothesis, double MaxVolume );
138 /* Algorithms Management */
139 void AddAlgorithmOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
140 void AddAlgorithmOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
141 void CreateAlgorithm( QString TypeAlgo, QString NameAlgo );
145 vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode);
146 void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z);
147 void AddNode(SMESH_Actor*, int idnode, float x, float y, float z) ;
148 void AddNodes( SMESH_Actor* Mactor, int number,
149 const SMESH::double_array& coords, const SMESH::long_array& indexes);
151 void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
152 void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z);
154 void RemoveNode(SMESH_Actor*, int idnode) ;
155 void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
156 void RemoveNodes(SMESH_Actor* Mactor, int number,
157 const SMESH::double_array& coords, const SMESH::long_array& indexes);
160 void AddEdge(SMESH_Actor*, int idedge, int idnode1, int idnode2) ;
161 void AddEdges( SMESH_Actor* Mactor, int number,
162 const SMESH::double_array& coords, const SMESH::long_array& indexes);
163 void DisplayEdges(SMESH_Actor* ac, bool visibility = true);
164 void DisplayEdgesConnectivityLegendBox(vtkActor *ac);
165 void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
168 void AddTriangle(SMESH_Actor*, int idtri, int idnode1, int idnode2, int idnode3) ;
169 void AddTriangles( SMESH_Actor* Mactor, int number,
170 const SMESH::double_array& coords, const SMESH::long_array& indexes);
171 void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
174 void AddQuadrangle(SMESH_Actor*, int idquad, int idnode1, int idnode2,
175 int idnode3, int idnode4) ;
176 void AddQuadrangles( SMESH_Actor* Mactor, int number,
177 const SMESH::double_array& coords, const SMESH::long_array& indexes);
178 void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
181 void AddTetra(SMESH_Actor*, int idtetra, int idnode1, int idnode2,
182 int idnode3, int idnode4) ;
183 void AddHexaedre(SMESH_Actor*, int idhexa, int idnode1, int idnode2,
184 int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) ;
185 void AddTetras( SMESH_Actor* Mactor, int number,
186 const SMESH::double_array& coords, const SMESH::long_array& indexes);
187 void AddHexaedres( SMESH_Actor* Mactor, int number,
188 const SMESH::double_array& coords, const SMESH::long_array& indexes);
189 void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
190 void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
193 void RemoveElement(SMESH_Actor*, int idnode);
194 void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
195 void RemoveElements(SMESH_Actor* Mactor, int number,
196 const SMESH::double_array& coords, const SMESH::long_array& indexes);
197 void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
198 void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
200 void AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
201 void AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
202 void AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
203 void AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
205 /* Simulation management */
206 void EraseSimulationActors() ;
208 /* Non modal dialog boxes magement */
209 void EmitSignalDeactivateDialog() ;
210 void EmitSignalCloseAllDialogs() ;
212 /* Selection management */
213 int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
214 int GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) ;
215 int GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) ;
216 int GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) ;
218 SMESH::SMESH_Hypothesis_ptr ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO,
219 Standard_Boolean& testResult ) ;
221 SMESH::SMESH_Mesh_ptr ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
222 SMESH::SMESH_subMesh_ptr ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
224 /* Geometry Client */
225 GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
226 Standard_Boolean& testResult ) ;
228 /* Popup management */
229 QString CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO);
230 QString CheckHomogeneousSelection();
232 /* Scripts management */
233 SMESH_Actor* ReadScript(SMESH::SMESH_Mesh_ptr aMesh);
235 /* Actors management */
236 void Dump(SMESH_Actor* Mactor);
238 void SetViewMode(int commandId);
239 void ChangeRepresentation( SMESH_Actor* ac, int type );
241 SMESH_Actor* FindActor(SMESH::SMESH_Mesh_ptr aMesh,
242 Standard_Boolean& testResult,
243 bool onlyInActiveView);
244 SMESH_Actor* FindActorByEntry(QString entry,
245 Standard_Boolean& testResult,
246 bool onlyInActiveView);
248 void InitActor(SMESH::SMESH_Mesh_ptr aMesh);
249 void DisplayActor(SMESH_Actor* ac, bool visibility = true);
250 void EraseActor(SMESH_Actor* ac);
251 bool AddActorInSelection(SMESH_Actor* ac);
256 void Update(const Handle(SALOME_InteractiveObject)& IO);
258 void ScalarVisibilityOff();
261 /* Settings management */
262 void SetSettingsScalarBar(vtkScalarBarActor* theScalarBar,
263 QString Bold, QString Italic, QString Shadow, QString Font,
264 QString Orientation, float Width, float Height,
265 int NbColors, int NbLabels);
266 void DisplayScalarBar(bool visibility);
267 void UpdateScalarBar(float MinRange, float MaxRange);
269 void SetDisplaySettings();
271 SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ;
273 /* Control management */
274 void Control(int theCommandID);
276 /* Parameter functions */
277 double Parameter( Standard_Boolean& res, const double aValue,
278 const char* aLabel, const char* aTitle,
279 const double bottom, const double top, const int decimals ) ;
280 int Parameter( Standard_Boolean& res, const int aValue,
281 const char* aLabel, const char* aTitle,
282 const int bottom, const int top ) ;
284 static void setOrb();
286 /* Import/Export */ //NBU
287 static void Import_Document(QAD_Desktop* parent, int theCommandID);
288 static void Export_Document(QAD_Desktop* parent, int theCommandID);
289 static void Import_Mesh(QAD_Desktop* parent, int theCommandID);
290 static void Export_Mesh(QAD_Desktop* parent, int theCommandID);
293 void SignalDeactivateActiveDialog() ;
294 void SignalCloseAllDialogs() ;