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 bool myAutomaticUpdate;
98 static SMESHGUI* GetOrCreateSMESHGUI( QAD_Desktop* desktop );
99 static SMESHGUI* GetSMESHGUI() ;
101 QAD_Study* GetActiveStudy() ;
102 QAD_Desktop* GetDesktop() ;
103 SALOMEDS::Study_ptr GetStudy();
104 SMESHGUI_StudyAPI GetStudyAPI();
106 vtkScalarBarActor* GetScalarBar();
108 QDialog* GetActiveDialogBox() ;
109 void SetActiveDialogBox(QDialog* aDlg) ;
111 void SetState(int aState) ;
113 bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
116 /* Managed by IAPP */
117 Standard_EXPORT static bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ;
118 Standard_EXPORT static bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent,
119 QAD_StudyFrame* studyFrame );
120 Standard_EXPORT static bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent,
121 QAD_StudyFrame* studyFrame );
122 Standard_EXPORT static bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent,
123 QAD_StudyFrame* studyFrame );
124 Standard_EXPORT static void activeStudyChanged ( QAD_Desktop* parent );
125 Standard_EXPORT static bool SetSettings ( QAD_Desktop* parent );
126 Standard_EXPORT static void DefinePopup( QString & theContext,
128 QString & theObject );
129 Standard_EXPORT static bool CustomPopup ( QAD_Desktop* parent,
131 const QString& theContext,
132 const QString& theParent,
133 const QString& theObject );
134 Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
138 /* Mesh Management */
139 SMESH::SMESH_Mesh_ptr InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
140 SMESH::SMESH_subMesh_ptr AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
142 /* Hypothesis Management */
143 SMESH::SMESH_Hypothesis_ptr CreateHypothesis( QString TypeHypothesis, QString NameHypothesis );
144 void AddHypothesisOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
145 void AddHypothesisOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
147 void RemoveHypothesisOrAlgorithmOnMesh( const Handle(SALOME_InteractiveObject)& IObject ) ;
148 void RemoveHypothesisOrAlgorithmOnMesh( SALOMEDS::SObject_ptr MorSM, SMESH::SMESH_Hypothesis_ptr anHyp ) ;
150 void CreateLocalLength( QString TypeHypothesis, QString NameHypothesis, double Length );
151 void CreateNbSegments( QString TypeHypothesis, QString NameHypothesis, int nbSegments );
152 void CreateMaxElementArea( QString TypeHypothesis, QString NameHypothesis, double MaxArea );
153 void CreateMaxElementVolume( QString TypeHypothesis, QString NameHypothesis, double MaxVolume );
155 /* Algorithms Management */
156 void AddAlgorithmOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
157 void AddAlgorithmOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
158 void CreateAlgorithm( QString TypeAlgo, QString NameAlgo );
162 vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode);
163 void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z);
164 void AddNode(SMESH_Actor*, int idnode, float x, float y, float z) ;
165 void AddNodes( SMESH_Actor* Mactor, int number,
166 const SMESH::double_array& coords, const SMESH::long_array& indexes);
168 void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
169 void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z);
171 void RemoveNode(SMESH_Actor*, int idnode) ;
172 void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
173 void RemoveNodes(SMESH_Actor* Mactor, int number,
174 const SMESH::double_array& coords, const SMESH::long_array& indexes);
177 void AddEdge(SMESH_Actor*, int idedge, int idnode1, int idnode2) ;
178 void AddEdges( SMESH_Actor* Mactor, int number,
179 const SMESH::double_array& coords, const SMESH::long_array& indexes);
180 void DisplayEdges(SMESH_Actor* ac, bool visibility = true);
181 void DisplayEdgesConnectivityLegendBox(vtkActor *ac);
182 void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
185 void AddTriangle(SMESH_Actor*, int idtri, int idnode1, int idnode2, int idnode3) ;
186 void AddTriangles( SMESH_Actor* Mactor, int number,
187 const SMESH::double_array& coords, const SMESH::long_array& indexes);
188 void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
191 void AddQuadrangle(SMESH_Actor*, int idquad, int idnode1, int idnode2,
192 int idnode3, int idnode4) ;
193 void AddQuadrangles( SMESH_Actor* Mactor, int number,
194 const SMESH::double_array& coords, const SMESH::long_array& indexes);
195 void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
198 void AddTetra(SMESH_Actor*, int idtetra, int idnode1, int idnode2,
199 int idnode3, int idnode4) ;
200 void AddHexaedre(SMESH_Actor*, int idhexa, int idnode1, int idnode2,
201 int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) ;
202 void AddTetras( SMESH_Actor* Mactor, int number,
203 const SMESH::double_array& coords, const SMESH::long_array& indexes);
204 void AddHexaedres( SMESH_Actor* Mactor, int number,
205 const SMESH::double_array& coords, const SMESH::long_array& indexes);
206 void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
207 void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
210 void RemoveElement(SMESH_Actor*, int idnode);
211 void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
212 void RemoveElements(SMESH_Actor* Mactor, int number,
213 const SMESH::double_array& coords, const SMESH::long_array& indexes);
214 void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
215 void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
217 void AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
218 void AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
219 void AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
220 void AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
222 /* Simulation management */
223 void EraseSimulationActors() ;
225 /* Non modal dialog boxes magement */
226 void EmitSignalDeactivateDialog() ;
227 void EmitSignalCloseAllDialogs() ;
229 /* Selection management */
230 int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
231 int GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) ;
232 int GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) ;
233 int GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) ;
235 SMESH::SMESH_Hypothesis_ptr ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO,
236 Standard_Boolean& testResult ) ;
238 SMESH::SMESH_Mesh_ptr ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
239 SMESH::SMESH_subMesh_ptr ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
241 /* Geometry Client */
242 GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
243 Standard_Boolean& testResult ) ;
245 /* Popup management */
246 QString CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO);
247 QString CheckHomogeneousSelection();
249 /* Scripts management */
250 SMESH_Actor* ReadScript(SMESH::SMESH_Mesh_ptr aMesh);
252 /* Actors management */
253 void Dump(SMESH_Actor* Mactor);
255 void SetViewMode(int commandId);
256 void ChangeRepresentation( SMESH_Actor* ac, int type );
258 SMESH_Actor* FindActor(SMESH::SMESH_Mesh_ptr aMesh,
259 Standard_Boolean& testResult,
260 bool onlyInActiveView);
261 SMESH_Actor* FindActorByEntry(QString entry,
262 Standard_Boolean& testResult,
263 bool onlyInActiveView);
265 void InitActor(SMESH::SMESH_Mesh_ptr aMesh);
266 void DisplayActor(SMESH_Actor* ac, bool visibility = true);
267 void EraseActor(SMESH_Actor* ac);
268 bool AddActorInSelection(SMESH_Actor* ac);
273 void Update(const Handle(SALOME_InteractiveObject)& IO);
275 void ScalarVisibilityOff();
278 /* Settings management */
279 void SetSettingsScalarBar(vtkScalarBarActor* theScalarBar,
280 QString Bold, QString Italic, QString Shadow, QString Font,
281 QString Orientation, float Width, float Height,
282 int NbColors, int NbLabels);
283 void DisplayScalarBar(bool visibility);
284 void UpdateScalarBar(float MinRange, float MaxRange);
286 void SetDisplaySettings();
288 SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ;
290 /* Control management */
291 void Control(int theCommandID);
293 /* Parameter functions */
294 double Parameter( Standard_Boolean& res, const double aValue,
295 const char* aLabel, const char* aTitle,
296 const double bottom, const double top, const int decimals ) ;
297 int Parameter( Standard_Boolean& res, const int aValue,
298 const char* aLabel, const char* aTitle,
299 const int bottom, const int top ) ;
301 static void setOrb();
303 /* Import/Export */ //NBU
304 void Import_Document(QAD_Desktop* parent, int theCommandID);
305 static void Export_Mesh(QAD_Desktop* parent, int theCommandID);
308 void SignalDeactivateActiveDialog() ;
309 void SignalCloseAllDialogs() ;