2 // Created : Wed Aug 01 10:23:06 2001
3 // Author : Laurent CORNABE & Hubert ROLLAND
6 // Copyright : PRINCIPIA
9 #ifndef VisuGUI_HeaderFile
10 #define VisuGUI_HeaderFile
12 #ifndef _Standard_HeaderFile
13 #include <Standard.hxx>
16 #include <SALOMEconfig.h>
17 #include CORBA_SERVER_HEADER(VISU_Gen)
18 #include CORBA_SERVER_HEADER(SALOMEDS)
19 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
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"
27 #include <TColStd_MapOfInteger.hxx>
28 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
29 #include "SALOME_ListIteratorOfListIO.hxx"
31 #include <vtkRenderer.h>
32 #include <vtkRenderWindow.h>
33 #include <vtkRenderWindowInteractor.h>
34 #include <vtkWindowToImageFilter.h>
35 #include <vtkTIFFWriter.h>
37 #include <vtkActor2D.h>
38 #include <vtkActorCollection.h>
39 #include <vtkActor2DCollection.h>
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 )",
49 "Results Files (*.res )",
50 "Print Files (*.tif)",
52 "Test Files (*.tst)" };
54 typedef enum {SOLVER,DAT_FILE,VTK_FILE,RES_FILE,MED_FILE,SMESH_FILE,VISU_FILE,SCALAR_FILE,ERROR} result ;
56 enum RepresentType { POINTS, WIREFRAME, SURFACE, SHRINK };
60 // ======================================================================
62 // ======================================================================
64 class VisuGUI : public QObject
72 // Methods PUBLIC for Visualization
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);
80 static vtkRenderer* GetRenderer(QAD_Study* theStudy);
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);
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);
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);
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);
122 static void ChangeScalarBar();
123 static void SetSweepingPreferences();
124 static VISU_Actor *ReferenceActor(QAD_Desktop* parent);
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 );
130 void PrintRW(QString prFile, bool toPrinter);
132 static QString getVisuInputDir();
133 static QString getVisuOutputDir();
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);
139 static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey);
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);
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);
151 void VisuGUI::ChangeRepresentation(RepresentType theType);
152 void DeletePresentation(VISU::Prs3d_i* thePrs);
155 void SetState(int aState );
157 void EmitSignalDeactivateDialog();
158 void EmitSignalCloseAllDialogs();
159 QDialog* GetActiveDialogBox();
160 void SetActiveDialogBox(QDialog* aDlg);
161 QAD_Study* GetActiveStudy();
162 QAD_Desktop* GetDesktop();
164 // ----------------------------------------
165 // All method of standard EXPORT
166 // ----------------------------------------
168 Standard_EXPORT static bool OnGUIEvent (int theCommandID, QAD_Desktop* parent);
170 Standard_EXPORT static bool setSettings (QAD_Desktop* parent);
172 Standard_EXPORT static void DefinePopup(QString & theContext,
174 QString & theObject ) ;
176 Standard_EXPORT static bool CustomPopup (QAD_Desktop* parent,
178 const QString & theContext,
179 const QString & theParent,
180 const QString & theObject);
182 Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
184 Standard_EXPORT static bool OnMousePress (QMouseEvent* pe ,
186 QAD_StudyFrame* studyFrame);
188 Standard_EXPORT static bool OnMouseMove (QMouseEvent* pe ,
190 QAD_StudyFrame* studyFrame);
192 Standard_EXPORT static bool OnKeyPress (QKeyEvent* pe,
194 QAD_StudyFrame* studyFrame);
196 Standard_EXPORT static bool APIreaderVTK (QString FileMesh, QString FileResultat);
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,
203 void ImportTablesFromFile();
204 void ImportFromFile();
207 void CreateScalarMap();
208 void CreateDeformedShape();
209 void CreateVectors();
210 void CreateIsoSurfaces();
211 void CreateCutPlanes();
212 void CreateStreamLines();
215 void DisplayOnlyPrs();
218 void EditScalarBar();
220 void MakeWireframe();
226 void ChangeOutlineColor();
227 void ChangeOpacity();
232 void CurveProperties();
233 void ClearContainer();
235 void SaveViewParams();
236 void RestoreViewParams();
241 void TimeAnimation();
243 void ImportMedField();
244 //void ImportMedMesh();
246 void DeleteViewParams();
247 void CopyPresentation();
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;
274 void SignalDeactivateActiveDialog();
275 void SignalCloseAllDialogs();