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"
35 #include "SMESHDS_Document.hxx"
38 #include "QAD_Desktop.h"
39 #include "SALOME_Selection.h"
40 #include "SALOME_InteractiveObject.hxx"
42 #include "SMESHGUI_StudyAPI.h"
43 #include "SMESHGUI_Hypotheses.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_Group)
50 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
51 #include CORBA_SERVER_HEADER(GEOM_Gen)
52 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
53 #include CORBA_SERVER_HEADER(SMESH_Filter)
56 #include <qstringlist.h>
60 class vtkActorCollection;
61 class vtkActor2DCollection;
62 class vtkScalarBarActor;
67 //=================================================================================
70 //=================================================================================
71 class SMESHGUI : public QObject
77 QAD_Desktop* myDesktop;
78 QAD_Study* myActiveStudy;
79 SMESH::SMESH_Gen_var myComponentMesh;
80 GEOM::GEOM_Gen_var myComponentGeom;
82 QDialog* myActiveDialogBox;
86 vtkActorCollection* mySimulationActors;
87 vtkActor2DCollection* mySimulationActors2D;
89 SMESH_Actor* myCurrentMesh;
91 SALOMEDS::Study_var myStudy;
94 SMESHGUI_StudyAPI myStudyAPI;
96 // vtkScalarBarActor* myScalarBar;
98 SMESHDS_Document * myDocument;//NBU
100 bool myAutomaticUpdate;
102 SMESH::FilterManager_var myFilterMgr;
104 // Hypotheses/algorithms from plugin libraries
105 map<string, HypothesisData*> myHypothesesMap;
106 map<string, HypothesisData*> myAlgorithmsMap;
107 map<string, SMESHGUI_GenericHypothesisCreator*> myHypCreatorMap;
114 static SMESHGUI* GetOrCreateSMESHGUI( QAD_Desktop* desktop );
115 static SMESHGUI* GetSMESHGUI() ;
117 QAD_Study* GetActiveStudy() ;
118 QAD_Desktop* GetDesktop() ;
119 SALOMEDS::Study_ptr GetStudy();
120 SMESHGUI_StudyAPI GetStudyAPI();
122 QDialog* GetActiveDialogBox() ;
123 void SetActiveDialogBox(QDialog* aDlg) ;
125 void SetState(int aState) ;
127 bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
130 /* Managed by IAPP */
131 Standard_EXPORT static bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ;
132 Standard_EXPORT static bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent,
133 QAD_StudyFrame* studyFrame );
134 Standard_EXPORT static bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent,
135 QAD_StudyFrame* studyFrame );
136 Standard_EXPORT static bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent,
137 QAD_StudyFrame* studyFrame );
138 Standard_EXPORT static void activeStudyChanged ( QAD_Desktop* parent );
139 Standard_EXPORT static bool SetSettings ( QAD_Desktop* parent );
140 Standard_EXPORT static void DefinePopup( QString & theContext,
142 QString & theObject );
143 Standard_EXPORT static bool CustomPopup ( QAD_Desktop* parent,
145 const QString& theContext,
146 const QString& theParent,
147 const QString& theObject );
148 Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
152 /* Mesh Management */
153 SMESH::SMESH_Mesh_ptr InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
154 SMESH::SMESH_subMesh_ptr AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
155 SMESH::SMESH_Group_ptr AddGroup( SMESH::SMESH_Mesh_ptr aMesh, SMESH::ElementType aType, QString aName );
157 /* Hypotheses and Algorithms Management */
158 void InitAvailableHypotheses ();
159 QStringList GetAvailableHypotheses (const bool isAlgo);
160 HypothesisData* GetHypothesisData (const char* aHypType);
161 SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator (const QString& aHypType);
163 SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const QString& aHypType,
164 const QString& aHypName,
165 const bool isAlgo = false);
167 bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
168 bool AddAlgorithmOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
170 bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
171 bool AddAlgorithmOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
173 bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject);
174 bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM,
175 SMESH::SMESH_Hypothesis_ptr anHyp);
177 void SetPickable(SMESH_Actor* theActor = NULL);
181 vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode);
182 void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z);
184 void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
185 void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z);
187 void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
190 void DisplayEdges(SMESH_Actor* ac, bool visibility = true);
191 void DisplayEdgesConnectivityLegendBox(vtkActor *ac);
192 void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
195 void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
198 void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
201 void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
202 void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
205 void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
206 void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
207 void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
209 void AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
210 void AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
211 void AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
212 void AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
214 /* Simulation management */
215 void EraseSimulationActors() ;
217 /* Non modal dialog boxes magement */
218 void EmitSignalDeactivateDialog() ;
219 void EmitSignalCloseAllDialogs() ;
221 /* Selection management */
222 int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
223 int GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) ;
224 int GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) ;
225 int GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) ;
227 SMESH::SMESH_Hypothesis_ptr ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO,
228 Standard_Boolean& testResult ) ;
230 SMESH::SMESH_Mesh_ptr ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
231 SMESH::SMESH_subMesh_ptr ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
232 SMESH::SMESH_Group_ptr ConvertIOinSMESHGroup(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
234 /* Geometry Client */
235 GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
236 Standard_Boolean& testResult ) ;
238 /* Popup management */
239 QString CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO);
240 QString CheckHomogeneousSelection();
242 /* Scripts management */
243 SMESH_Actor* ReadScript(SMESH::SMESH_Mesh_ptr aMesh);
245 /* Actors management */
246 void Dump(SMESH_Actor* Mactor);
248 void SetViewMode(int commandId);
249 void ChangeRepresentation( SMESH_Actor* ac, int type );
251 SMESH_Actor* FindActor(CORBA::Object_ptr theObj,
252 Standard_Boolean& testResult,
253 bool onlyInActiveView);
254 SMESH_Actor* FindActorByEntry(QString entry,
255 Standard_Boolean& testResult,
256 bool onlyInActiveView);
258 void InitActor(SMESH::SMESH_Mesh_ptr aMesh);
259 void DisplayActor(SMESH_Actor* ac, bool visibility = true);
260 void EraseActor(SMESH_Actor* ac);
261 bool AddActorInSelection(SMESH_Actor* ac);
266 void Update(const Handle(SALOME_InteractiveObject)& IO);
268 void ScalarVisibilityOff();
271 /* Settings management */
272 void SetSettingsScalarBar(vtkScalarBarActor* theScalarBar,
273 QString Bold, QString Italic, QString Shadow, QString Font,
274 QString Orientation, float Width, float Height,
275 int NbColors, int NbLabels);
276 void SetDisplaySettings();
278 SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ;
280 /* Control management */
281 void Control(int theCommandID);
283 /* Parameter functions */
284 double Parameter( Standard_Boolean& res, const double aValue,
285 const char* aLabel, const char* aTitle,
286 const double bottom, const double top, const int decimals ) ;
287 int Parameter( Standard_Boolean& res, const int aValue,
288 const char* aLabel, const char* aTitle,
289 const int bottom, const int top ) ;
291 static void setOrb();
293 /* Import/Export */ //NBU
294 static void Import_Mesh(QAD_Desktop* parent, int theCommandID);
295 static void Export_Mesh(QAD_Desktop* parent, int theCommandID);
298 SMESH::FilterManager_ptr GetFilterMgr();
301 void SignalDeactivateActiveDialog() ;
302 void SignalCloseAllDialogs() ;