1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 // Author : Nicolas REJNERI
29 #ifndef SMESHGUI_HeaderFile
30 #define SMESHGUI_HeaderFile
32 #include "TColStd_MapOfInteger.hxx"
34 #include "SMESHDS_Document.hxx"
37 #include "QAD_Desktop.h"
38 #include "SALOME_Selection.h"
39 #include "SALOME_InteractiveObject.hxx"
41 #include "SMESH_Actor.h"
43 #include "SMESHGUI_StudyAPI.h"
46 #include <SALOMEconfig.h>
47 #include CORBA_SERVER_HEADER(SMESH_Gen)
48 #include CORBA_SERVER_HEADER(SMESH_Mesh)
49 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
50 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
51 #include CORBA_SERVER_HEADER(GEOM_Gen)
52 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
55 #include <qstringlist.h>
58 #include <vtkScalarBarActor.h>
60 //=================================================================================
63 //=================================================================================
64 class SMESHGUI : public QObject
70 QAD_Desktop* myDesktop;
71 QAD_Study* myActiveStudy;
72 SMESH::SMESH_Gen_var myComponentMesh;
73 GEOM::GEOM_Gen_var myComponentGeom;
75 QDialog* myActiveDialogBox;
79 vtkActorCollection* mySimulationActors;
80 vtkActor2DCollection* mySimulationActors2D;
82 SMESH_Actor* myCurrentMesh;
84 SALOMEDS::Study_var myStudy;
87 SMESHGUI_StudyAPI myStudyAPI;
89 // vtkScalarBarActor* myScalarBar;
91 SMESHDS_Document * myDocument;//NBU
93 bool myAutomaticUpdate;
100 static SMESHGUI* GetOrCreateSMESHGUI( QAD_Desktop* desktop );
101 static SMESHGUI* GetSMESHGUI() ;
103 QAD_Study* GetActiveStudy() ;
104 QAD_Desktop* GetDesktop() ;
105 SALOMEDS::Study_ptr GetStudy();
106 SMESHGUI_StudyAPI GetStudyAPI();
108 vtkScalarBarActor* GetScalarBar();
110 QDialog* GetActiveDialogBox() ;
111 void SetActiveDialogBox(QDialog* aDlg) ;
113 void SetState(int aState) ;
115 bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
118 /* Managed by IAPP */
119 Standard_EXPORT static bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ;
120 Standard_EXPORT static bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent,
121 QAD_StudyFrame* studyFrame );
122 Standard_EXPORT static bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent,
123 QAD_StudyFrame* studyFrame );
124 Standard_EXPORT static bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent,
125 QAD_StudyFrame* studyFrame );
126 Standard_EXPORT static void activeStudyChanged ( QAD_Desktop* parent );
127 Standard_EXPORT static bool SetSettings ( QAD_Desktop* parent );
128 Standard_EXPORT static void DefinePopup( QString & theContext,
130 QString & theObject );
131 Standard_EXPORT static bool CustomPopup ( QAD_Desktop* parent,
133 const QString& theContext,
134 const QString& theParent,
135 const QString& theObject );
136 Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
140 /* Mesh Management */
141 SMESH::SMESH_Mesh_ptr InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
142 SMESH::SMESH_subMesh_ptr AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
144 /* Hypothesis Management */
145 SMESH::SMESH_Hypothesis_ptr CreateHypothesis( QString TypeHypothesis, QString NameHypothesis );
146 void AddHypothesisOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
147 void AddHypothesisOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
149 void RemoveHypothesisOrAlgorithmOnMesh( const Handle(SALOME_InteractiveObject)& IObject ) ;
150 void RemoveHypothesisOrAlgorithmOnMesh( SALOMEDS::SObject_ptr MorSM, SMESH::SMESH_Hypothesis_ptr anHyp ) ;
152 void CreateLocalLength( QString TypeHypothesis, QString NameHypothesis, double Length );
153 void CreateNbSegments( QString TypeHypothesis, QString NameHypothesis, int nbSegments );
154 void CreateMaxElementArea( QString TypeHypothesis, QString NameHypothesis, double MaxArea );
155 void CreateMaxElementVolume( QString TypeHypothesis, QString NameHypothesis, double MaxVolume );
157 /* Algorithms Management */
158 void AddAlgorithmOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
159 void AddAlgorithmOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
160 void CreateAlgorithm( QString TypeAlgo, QString NameAlgo );
164 vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode);
165 void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z);
166 void AddNode(SMESH_Actor*, int idnode, float x, float y, float z) ;
167 void AddNodes( SMESH_Actor* Mactor, int number,
168 const SMESH::double_array& coords, const SMESH::long_array& indexes);
170 void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
171 void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z);
173 void RemoveNode(SMESH_Actor*, int idnode) ;
174 void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
175 void RemoveNodes(SMESH_Actor* Mactor, int number,
176 const SMESH::double_array& coords, const SMESH::long_array& indexes);
179 void AddEdge(SMESH_Actor*, int idedge, int idnode1, int idnode2) ;
180 void AddEdges( SMESH_Actor* Mactor, int number,
181 const SMESH::double_array& coords, const SMESH::long_array& indexes);
182 void DisplayEdges(SMESH_Actor* ac, bool visibility = true);
183 void DisplayEdgesConnectivityLegendBox(vtkActor *ac);
184 void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
187 void AddTriangle(SMESH_Actor*, int idtri, int idnode1, int idnode2, int idnode3) ;
188 void AddTriangles( SMESH_Actor* Mactor, int number,
189 const SMESH::double_array& coords, const SMESH::long_array& indexes);
190 void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
193 void AddQuadrangle(SMESH_Actor*, int idquad, int idnode1, int idnode2,
194 int idnode3, int idnode4) ;
195 void AddQuadrangles( SMESH_Actor* Mactor, int number,
196 const SMESH::double_array& coords, const SMESH::long_array& indexes);
197 void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
200 void AddTetra(SMESH_Actor*, int idtetra, int idnode1, int idnode2,
201 int idnode3, int idnode4) ;
202 void AddHexaedre(SMESH_Actor*, int idhexa, int idnode1, int idnode2,
203 int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) ;
204 void AddTetras( SMESH_Actor* Mactor, int number,
205 const SMESH::double_array& coords, const SMESH::long_array& indexes);
206 void AddHexaedres( SMESH_Actor* Mactor, int number,
207 const SMESH::double_array& coords, const SMESH::long_array& indexes);
208 void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
209 void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
212 void RemoveElement(SMESH_Actor*, int idnode);
213 void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
214 void RemoveElements(SMESH_Actor* Mactor, int number,
215 const SMESH::double_array& coords, const SMESH::long_array& indexes);
216 void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
217 void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
219 void AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
220 void AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
221 void AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
222 void AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
224 /* Simulation management */
225 void EraseSimulationActors() ;
227 /* Non modal dialog boxes magement */
228 void EmitSignalDeactivateDialog() ;
229 void EmitSignalCloseAllDialogs() ;
231 /* Selection management */
232 int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
233 int GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) ;
234 int GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) ;
235 int GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) ;
237 SMESH::SMESH_Hypothesis_ptr ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO,
238 Standard_Boolean& testResult ) ;
240 SMESH::SMESH_Mesh_ptr ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
241 SMESH::SMESH_subMesh_ptr ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
243 /* Geometry Client */
244 GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
245 Standard_Boolean& testResult ) ;
247 /* Popup management */
248 QString CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO);
249 QString CheckHomogeneousSelection();
251 /* Scripts management */
252 SMESH_Actor* ReadScript(SMESH::SMESH_Mesh_ptr aMesh);
254 /* Actors management */
255 void Dump(SMESH_Actor* Mactor);
257 void SetViewMode(int commandId);
258 void ChangeRepresentation( SMESH_Actor* ac, int type );
260 SMESH_Actor* FindActor(SMESH::SMESH_Mesh_ptr aMesh,
261 Standard_Boolean& testResult,
262 bool onlyInActiveView);
263 SMESH_Actor* FindActorByEntry(QString entry,
264 Standard_Boolean& testResult,
265 bool onlyInActiveView);
267 void InitActor(SMESH::SMESH_Mesh_ptr aMesh);
268 void DisplayActor(SMESH_Actor* ac, bool visibility = true);
269 void EraseActor(SMESH_Actor* ac);
270 bool AddActorInSelection(SMESH_Actor* ac);
275 void Update(const Handle(SALOME_InteractiveObject)& IO);
277 void ScalarVisibilityOff();
280 /* Settings management */
281 void SetSettingsScalarBar(vtkScalarBarActor* theScalarBar,
282 QString Bold, QString Italic, QString Shadow, QString Font,
283 QString Orientation, float Width, float Height,
284 int NbColors, int NbLabels);
285 void DisplayScalarBar(bool visibility);
286 void UpdateScalarBar(float MinRange, float MaxRange);
288 void SetDisplaySettings();
290 SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ;
292 /* Control management */
293 void Control(int theCommandID);
295 /* Parameter functions */
296 double Parameter( Standard_Boolean& res, const double aValue,
297 const char* aLabel, const char* aTitle,
298 const double bottom, const double top, const int decimals ) ;
299 int Parameter( Standard_Boolean& res, const int aValue,
300 const char* aLabel, const char* aTitle,
301 const int bottom, const int top ) ;
303 static void setOrb();
305 /* Import/Export */ //NBU
306 static void Import_Document(QAD_Desktop* parent, int theCommandID);
307 static void Export_Document(QAD_Desktop* parent, int theCommandID);
308 static void Import_Mesh(QAD_Desktop* parent, int theCommandID);
309 static void Export_Mesh(QAD_Desktop* parent, int theCommandID);
312 void SignalDeactivateActiveDialog() ;
313 void SignalCloseAllDialogs() ;