Salome HOME
sources v1.2c
[modules/visu.git] / src / VISUGUI / VisuGUI.h
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VisuGUI.h
25 //  Author : Laurent CORNABE & Hubert ROLLAND 
26 //  Module : VISU
27 //  $Header$
28
29 #ifndef VisuGUI_HeaderFile
30 #define VisuGUI_HeaderFile
31
32 #ifndef _Standard_HeaderFile
33 #include <Standard.hxx>
34 #endif
35  
36 #include <SALOMEconfig.h>
37 #include CORBA_SERVER_HEADER(VISU_Gen)
38 #include CORBA_SERVER_HEADER(SALOMEDS)
39 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
40
41 #include "QAD_Desktop.h"
42 class VTKViewer_ViewFrame;
43
44 #include "VISUConfig.hh"
45 class VISU_Actor;
46 class VISU_MeshAct;
47 class VISU_ScalarMapAct;
48
49 #include <vtkDataSet.h>
50 class vtkRenderer;
51
52 #include <TColStd_MapOfInteger.hxx>
53 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
54 #include "SALOME_ListIteratorOfListIO.hxx"
55
56 namespace VISU{
57   class VISU_Gen_i;
58
59   class Result_i;
60
61   class Prs3d_i;
62   class ScalarMap_i;
63   class DeformedShape_i;
64   class IsoSurfaces_i;
65   class CutPlanes_i;
66   class CutLines_i;
67   class Vectors_i;
68   class StreamLines_i;
69
70   class Table_i;
71   class Curve_i;
72   class Container_i;
73 }
74
75 // ======================================================================
76 //                              CLASS VIUSGUI
77 // ======================================================================
78 // 
79
80 class VisuGUI : public QObject{
81   Q_OBJECT;
82  public:
83   VisuGUI();      
84   ~VisuGUI();     
85   
86   static VISU::VISU_Gen_i* GetVisuGen();
87
88   static QAD_Desktop* GetDesktop();
89   static QAD_Study* GetActiveStudy();
90   static vtkRenderer* GetRenderer();
91   static VTKViewer_ViewFrame* GetVtkViewFrame();
92   static SALOMEDS::Study_var GetStudyDocument();
93   static SALOMEDS::StudyBuilder_var NewBuilder();
94   static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject);
95
96   static VISU::Result_i*  CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult);
97
98   enum CameraOrient {e3D, eFront, eLeft, eTop};
99   static CameraOrient SetFitAll( VTKViewer_ViewFrame* vf);
100
101   bool CreateScalarMap(SALOMEDS::SObject_var theField);
102   static VISU::ScalarMap_i* CreateScalarMapPrs(SALOMEDS::SObject_var theField, 
103                                                const char* theMeshName, VISU::Entity theEntity, 
104                                                const char* theFieldName, int theTimeId);
105   bool CreateDeformedShape(SALOMEDS::SObject_var theField);
106   static VISU::DeformedShape_i* CreateDeformedShapePrs(SALOMEDS::SObject_var theField, 
107                                                        const char* theMeshName, VISU::Entity theEntity, 
108                                                        const char* theFieldName, int theTimeId);
109   bool CreateVectors(SALOMEDS::SObject_var theField);
110   static VISU::Vectors_i* CreateVectorsPrs(SALOMEDS::SObject_var theField, 
111                                            const char* theMeshName, VISU::Entity theEntity, 
112                                            const char* theFieldName, int theTimeId);
113   bool CreateIsoSurfaces(SALOMEDS::SObject_var theField);
114   static VISU::IsoSurfaces_i* CreateIsoSurfacesPrs(SALOMEDS::SObject_var theField, 
115                                                    const char* theMeshName, VISU::Entity theEntity, 
116                                                    const char* theFieldName, int theTimeId);
117   bool CreateCutPlanes(SALOMEDS::SObject_var theField);
118   static VISU::CutPlanes_i* CreateCutPlanesPrs(SALOMEDS::SObject_var theField, 
119                                                const char* theMeshName, VISU::Entity theEntity, 
120                                                const char* theFieldName, int theTimeId);
121   bool CreateCutLines(SALOMEDS::SObject_var theField);
122   static VISU::CutLines_i* CreateCutLinesPrs(SALOMEDS::SObject_var theField, 
123                                              const char* theMeshName, VISU::Entity theEntity, 
124                                              const char* theFieldName, int theTimeId);
125   bool CreateStreamLines(SALOMEDS::SObject_var theField);
126   static VISU::StreamLines_i* CreateStreamLinesPrs(SALOMEDS::SObject_var theField, 
127                                                    const char* theMeshName, VISU::Entity theEntity, 
128                                                    const char* theFieldName, int theTimeId);
129   bool TestObjectBrowser(SALOMEDS::SObject_var& objVisu);
130
131   typedef void (*TGetInfoFun)(QAD_Study *theActiveStudy, vtkDataSet *theDataSet, int theId);
132   void GetInfo(int theSelectionMode, TGetInfoFun theGetInfoFun);
133
134   typedef int (vtkDataSet::* TSelectFun)();
135   void Select(int theSelectionMode, TSelectFun theSelectFun, 
136               const char* theTitle, const char* theRequest);
137   
138   static void ShowTrihedron(bool Show);
139   static void ChangeViewer(int theType);
140              
141   static void NewColor(VISU_Actor *Actor);
142   static void NewWireframeColor(VISU_MeshAct *Actor);
143   static void NewOpacity(VISU_Actor *Actor);
144   static void NewLinewidth(VISU_Actor *Actor);
145              
146   static void ChangeScalarBar();
147   static void SetSweepingPreferences();
148              
149   static void  PlotTable( VISU::Table_i* table, int theDisplaying );
150   static void  PlotCurve( VISU::Curve_i* curve, int theDisplaying );
151   static void  PlotContainer( VISU::Container_i* container, int theDisplaying );
152   
153   static QString getVisuInputDir();
154   static QString getVisuOutputDir();
155   
156   static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey);
157   static int checkHomoSelection();
158   
159   VISU_Actor* UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly=false);
160   bool IsDisplayed(VISU::Prs3d_i* thePrs);
161   void ErasePrs(VISU::Prs3d_i* thePrs);
162   
163   static VISU::Prs3d_i* GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO = NULL);
164   static void RecreateActor(VISU::Prs3d_i* thePrs);
165   static void CreateActor(VISU::Prs3d_i* thePrs);
166   static VISU_Actor* GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame = NULL);
167   
168   void VisuGUI::ChangeRepresentation(VISU::PresentationType theType);
169   void DeletePresentation(VISU::Prs3d_i* thePrs);
170   
171   void  SetState(int aState );
172   void  ResetState();
173   void  EmitSignalDeactivateDialog();
174   void  EmitSignalCloseAllDialogs();
175   QDialog*      GetActiveDialogBox();
176   void  SetActiveDialogBox(QDialog* aDlg);
177   
178 // ----------------------------------------
179 // All method of standard EXPORT
180 // ----------------------------------------
181   Standard_EXPORT static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent);
182   Standard_EXPORT static bool setSettings(QAD_Desktop* parent);
183   Standard_EXPORT static void DefinePopup(QString & theContext,
184                                           QString & theParent, 
185                                           QString & theObject ) ;
186   Standard_EXPORT static bool CustomPopup(QAD_Desktop* parent,
187                                           QPopupMenu* popup,
188                                           const QString & theContext,
189                                           const QString & theParent,
190                                           const QString & theObject);
191   Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
192   Standard_EXPORT static bool OnMousePress(QMouseEvent* pe ,
193                                            QAD_Desktop* parent, 
194                                            QAD_StudyFrame* studyFrame);
195   Standard_EXPORT static bool OnMouseMove(QMouseEvent* pe ,
196                                           QAD_Desktop* parent, 
197                                           QAD_StudyFrame* studyFrame);
198   Standard_EXPORT static bool OnKeyPress(QKeyEvent* pe,
199                                          QAD_Desktop* parent,
200                                          QAD_StudyFrame* studyFrame);
201   public slots:
202   void ImportTablesFromFile();
203   void ImportFromFile();
204   void ExportToFile();
205   void CreateMesh();
206   void CreateScalarMap();
207   void CreateDeformedShape();
208   void CreateVectors();
209   void CreateIsoSurfaces();
210   void CreateCutPlanes();
211   void CreateCutLines();
212   void CreateStreamLines();
213   void CreateManyMesh();
214   
215   void DisplayPrs();
216   void DisplayOnlyPrs();
217   void ErasePrs();
218   void EditPrs();
219   void EditScalarBar();
220   void DisplayManyPrs();
221   void DisplayOnlyManyPrs();
222   void EraseManyPrs();
223   
224   void MakeSurfaceframe();
225   void MakeInsideframe();
226   void MakeWireframe();
227   void MakeSurface();
228   void MakePoints();
229   void MakeShrink();
230   
231   void ChageColor();
232   void ChangeWireframeColor();
233   void ChangeOpacity();
234   void ChangeLines();
235   
236   void ShowTable();
237   void CreateTable();
238   void PlotData();
239   void CurveProperties();
240   void ClearContainer();
241   
242   void SaveViewParams();
243   void RestoreViewParams();
244   
245   void DeletePrs();
246   void Rename();
247   void RenameTable();
248   void RenameContainer();
249   void Sweep();
250   void TimeAnimation();
251   
252   void ImportMedField();
253   //void ImportMedMesh();
254   
255   void DeleteViewParams();
256   void CopyPresentation();
257
258   void InfoOnPoint();
259   void InfoOnCell();
260
261   void SelectPoint();
262   void SelectCell();
263   
264 private :
265   QDialog* myActiveDialogBox;
266   int myState ;
267   
268 signals:
269   void SignalDeactivateActiveDialog();
270   void SignalCloseAllDialogs();
271 };
272
273 #endif