]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI.h
Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/visu.git] / src / VISUGUI / VisuGUI.h
1 //  File      : VisuGUI.h
2 //  Created   : Wed Aug 01 10:23:06 2001
3 //  Author    : Laurent CORNABE & Hubert ROLLAND 
4 //  Project   : SALOME
5 //  Module    : VISUGUI
6 //  Copyright : PRINCIPIA
7 //  $Header$
8
9 #ifndef VisuGUI_HeaderFile
10 #define VisuGUI_HeaderFile
11
12 #ifndef _Standard_HeaderFile
13 #include <Standard.hxx>
14 #endif
15  
16 #include <SALOMEconfig.h>
17 #include CORBA_SERVER_HEADER(VISU_Gen)
18 #include CORBA_SERVER_HEADER(SALOMEDS)
19 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
20
21 #include "QAD_Desktop.h"
22 #include "VISU_Actor.h"
23 #include "VISU_PrsObject_i.hh"
24 #include "VISU_Table_i.hh"
25 #include "VISU_ViewManager_i.hh"
26
27 #include <TColStd_MapOfInteger.hxx>
28 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
29 #include "SALOME_ListIteratorOfListIO.hxx"
30
31 #include <vtkRenderer.h>
32 #include <vtkRenderWindow.h>
33 #include <vtkRenderWindowInteractor.h>
34 #include <vtkWindowToImageFilter.h>
35 #include <vtkTIFFWriter.h>
36 #include <vtkActor.h>
37 #include <vtkActor2D.h>
38 #include <vtkActorCollection.h>
39 #include <vtkActor2DCollection.h>
40
41 static QString filters[] = { "DAT Files (*.dat)",
42                         "Pressures Files (*.pre)",
43                         "Displacements Files (*.dis)",
44                         "Scalars Files (*.sca)",
45                         "Vectors Files (*.vec)",
46                         "Data Files (*.dat )",
47                         "Vtk Files (*.vtk )",
48                         "Med Files (*.med)",
49                         "Results Files (*.res )",
50                         "Print Files (*.tif)",
51                         "Plot Files (*.plt)",
52                         "Test Files (*.tst)" };
53
54 typedef enum {SOLVER,DAT_FILE,VTK_FILE,RES_FILE,MED_FILE,SMESH_FILE,VISU_FILE,SCALAR_FILE,ERROR} result ;
55
56 enum RepresentType { POINTS, WIREFRAME, SURFACE, SHRINK };
57
58
59
60 // ======================================================================
61 //                              CLASS VIUSGUI
62 // ======================================================================
63 // 
64 class VisuGUI : public QObject
65 {
66   Q_OBJECT
67
68 public :
69 VisuGUI();        
70 ~VisuGUI();       
71
72 // Methods PUBLIC for Visualization
73 // 
74  static SALOMEDS::Study_var GetCurrentStudy() { return myStudy; }
75  static QAD_Study* GetGUICurrentStudy() { return myActiveStudy; }
76  static VTKViewer_ViewFrame* GetVtkViewFrame();
77  static SALOMEDS::StudyBuilder_var GetStudyBuilder() { return myStudyBuilder;}
78  static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject);
79
80  static vtkRenderer* GetRenderer(QAD_Study* theStudy);
81
82
83 static  VisuGUI* GetOrCreateVisuGUI( QAD_Desktop* desktop );
84 static  VisuGUI* GetVisuGUI() ;
85 static VISU::Result_i*  CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult);
86
87 bool CreateScalarMap(SALOMEDS::SObject_var theField);
88 static VISU::ScalarMap_i* CreateScalarMapPrs(SALOMEDS::SObject_var theField, 
89                                              const char* theMeshName, VISU::Entity theEntity, 
90                                              const char* theFieldName, double theTimeId);
91 bool CreateDeformedShape(SALOMEDS::SObject_var theField);
92 static VISU::DeformedShape_i* CreateDeformedShapePrs(SALOMEDS::SObject_var theField, 
93                                                      const char* theMeshName, VISU::Entity theEntity, 
94                                                      const char* theFieldName, double theTimeId);
95 bool CreateVectors(SALOMEDS::SObject_var theField);
96 static VISU::Vectors_i* CreateVectorsPrs(SALOMEDS::SObject_var theField, 
97                                          const char* theMeshName, VISU::Entity theEntity, 
98                                          const char* theFieldName, double theTimeId);
99 bool CreateIsoSurfaces(SALOMEDS::SObject_var theField);
100 static VISU::IsoSurfaces_i* CreateIsoSurfacesPrs(SALOMEDS::SObject_var theField, 
101                                                  const char* theMeshName, VISU::Entity theEntity, 
102                                                  const char* theFieldName, double theTimeId);
103 bool CreateCutPlanes(SALOMEDS::SObject_var theField);
104 static VISU::CutPlanes_i* CreateCutPlanesPrs(SALOMEDS::SObject_var theField, 
105                                              const char* theMeshName, VISU::Entity theEntity, 
106                                              const char* theFieldName, double theTimeId);
107 bool CreateStreamLines(SALOMEDS::SObject_var theField);
108 static VISU::StreamLines_i* CreateStreamLinesPrs(SALOMEDS::SObject_var theField, 
109                                                  const char* theMeshName, VISU::Entity theEntity, 
110                                                  const char* theFieldName, double theTimeId);
111 bool    TestObjectBrowser(SALOMEDS::SObject_var *objVisu);
112
113 static  void    ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor);
114 static  void    ShowTrihedron(bool Show);
115 static  void    ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type);
116
117 static  void    NewColor(VISU_Actor *Actor);
118 static  void    NewOutlineColor(VISU_Actor *Actor);
119 static  void    NewOpacity(VISU_Actor *Actor);
120 static  void    NewLinewidth(VISU_Actor *Actor);
121
122 static  void    ChangeScalarBar();
123 static  void    SetSweepingPreferences();
124 static  VISU_Actor *ReferenceActor(QAD_Desktop* parent);
125
126 static  void    PlotTable( VISU::Table_i* table, int theDisplaying );
127 static  void    PlotCurve( VISU::Curve_i* curve, int theDisplaying );
128 static  void    PlotContainer( VISU::Container_i* container, int theDisplaying );
129
130 void    PrintRW(QString prFile, bool toPrinter);
131
132 static  QString getVisuInputDir();
133 static  QString getVisuOutputDir();
134
135 static  VISU_Actor      *ActorSelected(QAD_Desktop* parent, bool InViewer, int *Mode);
136 static  VISU_Actor      *GetActorObjBrowser(SALOMEDS::SObject_var objVisu, vtkRenderer *ren);
137 static  VISU_Actor      *GetActor(QAD_Desktop* parent, Handle_SALOME_InteractiveObject IO, vtkRenderer *ren);
138
139  static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey);
140
141
142 VISU_Actor* UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly=false);
143 bool IsDisplayed(VISU::Prs3d_i* thePrs);
144 void ErasePrs(VISU::Prs3d_i* thePrs);
145
146 VISU_Actor* GetActor(VISU::Prs3d_i* thePrs);
147 static VISU::Prs3d_i* GetSelectedPrs();
148 void RecreateActor(VISU::Prs3d_i* thePrs);
149 static void CreateActor(VISU::Prs3d_i* thePrs);
150
151 void VisuGUI::ChangeRepresentation(RepresentType theType);
152 void DeletePresentation(VISU::Prs3d_i* thePrs);
153
154
155 void    SetState(int aState );
156 void    ResetState();
157 void    EmitSignalDeactivateDialog();
158 void    EmitSignalCloseAllDialogs();
159 QDialog*        GetActiveDialogBox();
160 void    SetActiveDialogBox(QDialog* aDlg);
161 QAD_Study*      GetActiveStudy();
162 QAD_Desktop*    GetDesktop();
163
164 // ----------------------------------------
165 // All method of standard EXPORT
166 // ----------------------------------------
167 // 
168 Standard_EXPORT static  bool    OnGUIEvent (int theCommandID, QAD_Desktop* parent);
169  
170 Standard_EXPORT static  bool setSettings (QAD_Desktop* parent);
171
172 Standard_EXPORT static  void DefinePopup(QString & theContext,
173                         QString & theParent, 
174                         QString & theObject ) ;
175
176 Standard_EXPORT static  bool CustomPopup (QAD_Desktop* parent,
177                          QPopupMenu* popup,
178                          const QString & theContext,
179                          const QString & theParent,
180                          const QString & theObject);
181
182 Standard_EXPORT  static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
183
184 Standard_EXPORT static bool OnMousePress (QMouseEvent* pe ,
185                                           QAD_Desktop* parent, 
186                                           QAD_StudyFrame* studyFrame);
187  
188 Standard_EXPORT static bool OnMouseMove (QMouseEvent* pe ,
189                                          QAD_Desktop* parent, 
190                                          QAD_StudyFrame* studyFrame);
191
192 Standard_EXPORT static bool OnKeyPress (QKeyEvent* pe,
193                                         QAD_Desktop* parent,
194                                         QAD_StudyFrame* studyFrame);
195
196 Standard_EXPORT static bool APIreaderVTK (QString FileMesh, QString FileResultat);
197
198 Standard_EXPORT static bool getObjectRef(QAD_Desktop* parent, SALOMEDS::SObject_ptr obj, 
199                                          _CORBA_ObjRef_OUT_arg< SALOMEDS::_objref_SObject, SALOMEDS::SObject_Helper > objres,
200                                          const char* Type);   
201
202 public slots:
203  void ImportTablesFromFile();
204  void ImportFromFile();
205  void ExportToFile();
206  void CreateMesh();
207  void CreateScalarMap();
208  void CreateDeformedShape();
209  void CreateVectors();
210  void CreateIsoSurfaces();
211  void CreateCutPlanes();
212  void CreateStreamLines();
213
214  void DisplayPrs();
215  void DisplayOnlyPrs();
216  void ErasePrs();
217  void EditPrs();
218  void EditScalarBar();
219
220  void MakeWireframe();
221  void MakeSurface();
222  void MakePoints();
223  void MakeShrink();
224
225  void ChageColor();
226  void ChangeOutlineColor();
227  void ChangeOpacity();
228  void ChangeLines();
229
230  void ShowTable();
231  void PlotData();
232  void CurveProperties();
233  void ClearContainer();
234
235  void SaveViewParams();
236  void RestoreViewParams();
237
238  void DeletePrs();
239  void Rename();
240  void Sweep();
241  void TimeAnimation();
242
243  void ImportMedField();
244  //void ImportMedMesh();
245
246  void DeleteViewParams();
247  void CopyPresentation();
248
249  void InfoOnPoint();
250  void InfoOnCell();
251  void SelectPoint();
252  void SelectCell();
253
254 protected:
255   
256  // Methods PROTECTED
257  // 
258
259
260  // Fields PROTECTED
261  //
262
263 private :
264   static VISU::VISU_Gen_var myComponent;
265   static SALOMEDS::Study_var myStudy;
266   static SALOMEDS::StudyBuilder_var myStudyBuilder;
267   static QAD_Desktop* myDesktop;
268   static QAD_Study*  myActiveStudy;
269         QDialog*                        myActiveDialogBox;
270         int                             myState ;
271         int                             myStudyId;
272
273 signals:
274         void SignalDeactivateActiveDialog();
275         void SignalCloseAllDialogs();
276 };
277
278 #endif