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 "SALOMEGUI.h"
39 #include "QAD_Desktop.h"
40 #include "SALOME_Selection.h"
41 #include "SALOME_InteractiveObject.hxx"
43 #include "SMESHGUI_StudyAPI.h"
44 #include "SMESHGUI_Hypotheses.h"
47 #include <SALOMEconfig.h>
48 #include CORBA_SERVER_HEADER(SMESH_Gen)
49 #include CORBA_SERVER_HEADER(SMESH_Mesh)
50 #include CORBA_SERVER_HEADER(SMESH_Group)
51 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
52 #include CORBA_SERVER_HEADER(GEOM_Gen)
53 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
54 #include CORBA_SERVER_HEADER(SMESH_Filter)
57 #include <qstringlist.h>
61 class vtkActorCollection;
62 class vtkActor2DCollection;
63 class vtkScalarBarActor;
68 //=================================================================================
71 //=================================================================================
72 class SMESHGUI : public SALOMEGUI
78 QAD_Desktop* myDesktop;
79 QAD_Study* myActiveStudy;
80 SMESH::SMESH_Gen_var myComponentMesh;
81 GEOM::GEOM_Gen_var myComponentGeom;
83 QDialog* myActiveDialogBox;
87 vtkActorCollection* mySimulationActors;
88 vtkActor2DCollection* mySimulationActors2D;
90 SMESH_Actor* myCurrentMesh;
92 SALOMEDS::Study_var myStudy;
95 SMESHGUI_StudyAPI myStudyAPI;
97 // vtkScalarBarActor* myScalarBar;
99 SMESHDS_Document * myDocument;//NBU
101 bool myAutomaticUpdate;
103 SMESH::FilterManager_var myFilterMgr;
105 // Hypotheses/algorithms from plugin libraries
106 map<string, HypothesisData*> myHypothesesMap;
107 map<string, HypothesisData*> myAlgorithmsMap;
108 map<string, SMESHGUI_GenericHypothesisCreator*> myHypCreatorMap;
112 SMESHGUI( const QString& name = "", QObject* parent = 0 );
115 static SMESHGUI* GetOrCreateSMESHGUI( QAD_Desktop* desktop );
116 static SMESHGUI* GetSMESHGUI() ;
118 QAD_Study* GetActiveStudy() ;
119 QAD_Desktop* GetDesktop() ;
120 SALOMEDS::Study_ptr GetStudy();
121 SMESHGUI_StudyAPI GetStudyAPI();
123 QDialog* GetActiveDialogBox() ;
124 void SetActiveDialogBox(QDialog* aDlg) ;
126 void SetState(int aState) ;
128 bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
131 virtual bool OnGUIEvent (int theCommandID, QAD_Desktop* parent);
132 virtual bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
133 virtual bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
134 virtual bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
135 virtual bool ActiveStudyChanged( QAD_Desktop* parent );
136 virtual bool SetSettings ( QAD_Desktop* parent );
137 virtual void DefinePopup ( QString & theContext, QString & theParent, QString & theObject );
138 virtual bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
139 const QString & theParent, const QString & theObject );
140 virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)& theIO );
141 virtual void SupportedViewType (int* buffer, int bufferSize);
142 virtual void Deactivate ();
146 /* Mesh Management */
147 SMESH::SMESH_Mesh_ptr InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
148 SMESH::SMESH_subMesh_ptr AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
149 SMESH::SMESH_Group_ptr AddGroup( SMESH::SMESH_Mesh_ptr aMesh, SMESH::ElementType aType, QString aName );
151 /* Hypotheses and Algorithms Management */
152 void InitAvailableHypotheses ();
153 QStringList GetAvailableHypotheses (const bool isAlgo);
154 HypothesisData* GetHypothesisData (const char* aHypType);
155 SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator (const QString& aHypType);
157 SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const QString& aHypType,
158 const QString& aHypName,
159 const bool isAlgo = false);
161 bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
162 bool AddAlgorithmOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
164 bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
165 bool AddAlgorithmOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
167 bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject);
168 bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM,
169 SMESH::SMESH_Hypothesis_ptr anHyp);
171 void SetPickable(SMESH_Actor* theActor = NULL);
175 vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode);
176 void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z);
178 void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
179 void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z);
181 void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
184 void DisplayEdges(SMESH_Actor* ac, bool visibility = true);
185 void DisplayEdgesConnectivityLegendBox(vtkActor *ac);
186 void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
189 void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
192 void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
195 void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
196 void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
199 void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
200 void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
201 void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
203 void AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
204 void AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
205 void AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
206 void AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
208 /* Simulation management */
209 void EraseSimulationActors() ;
211 /* Non modal dialog boxes magement */
212 void EmitSignalDeactivateDialog() ;
213 void EmitSignalCloseAllDialogs() ;
215 /* Selection management */
216 int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
217 int GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) ;
218 int GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) ;
219 int GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) ;
221 SMESH::SMESH_Hypothesis_ptr ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO,
222 Standard_Boolean& testResult ) ;
224 SMESH::SMESH_Mesh_ptr ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
225 SMESH::SMESH_subMesh_ptr ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
226 SMESH::SMESH_Group_ptr ConvertIOinSMESHGroup(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
228 /* Geometry Client */
229 GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
230 Standard_Boolean& testResult ) ;
232 /* Popup management */
233 QString CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO);
234 QString CheckHomogeneousSelection();
236 /* Scripts management */
237 SMESH_Actor* ReadScript(SMESH::SMESH_Mesh_ptr aMesh);
239 /* Actors management */
240 void Dump(SMESH_Actor* Mactor);
242 void SetViewMode(int commandId);
243 void ChangeRepresentation( SMESH_Actor* ac, int type );
245 SMESH_Actor* FindActor(CORBA::Object_ptr theObj,
246 Standard_Boolean& testResult,
247 bool onlyInActiveView);
248 SMESH_Actor* FindActorByEntry(QString entry,
249 Standard_Boolean& testResult,
250 bool onlyInActiveView);
252 void InitActor(SMESH::SMESH_Mesh_ptr aMesh);
253 void DisplayActor(SMESH_Actor* ac, bool visibility = true);
254 void EraseActor(SMESH_Actor* ac);
255 bool AddActorInSelection(SMESH_Actor* ac);
260 void Update(const Handle(SALOME_InteractiveObject)& IO);
262 void ScalarVisibilityOff();
265 /* Settings management */
266 void SetSettingsScalarBar(vtkScalarBarActor* theScalarBar,
267 QString Bold, QString Italic, QString Shadow, QString Font,
268 QString Orientation, float Width, float Height,
269 int NbColors, int NbLabels);
270 void SetDisplaySettings();
272 SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ;
274 /* Control management */
275 void Control(int theCommandID);
277 /* Parameter functions */
278 double Parameter( Standard_Boolean& res, const double aValue,
279 const char* aLabel, const char* aTitle,
280 const double bottom, const double top, const int decimals ) ;
281 int Parameter( Standard_Boolean& res, const int aValue,
282 const char* aLabel, const char* aTitle,
283 const int bottom, const int top ) ;
285 static void setOrb();
287 /* Import/Export */ //NBU
288 static void Import_Mesh(QAD_Desktop* parent, int theCommandID);
289 static void Export_Mesh(QAD_Desktop* parent, int theCommandID);
292 SMESH::FilterManager_ptr GetFilterMgr();
295 void SignalDeactivateActiveDialog() ;
296 void SignalCloseAllDialogs() ;