Salome HOME
NRI : Merge from V1_2.
[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 #include "VISU_Actor.h"
43 #include "VISU_PrsObject_i.hh"
44 #include "VISU_Table_i.hh"
45 #include "VISU_ViewManager_i.hh"
46
47 #include <TColStd_MapOfInteger.hxx>
48 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
49 #include "SALOME_ListIteratorOfListIO.hxx"
50
51 class vtkRenderer;
52
53 enum RepresentType { POINTS, WIREFRAME, SURFACE, SHRINK };
54
55
56
57 // ======================================================================
58 //                              CLASS VIUSGUI
59 // ======================================================================
60 // 
61 class VisuGUI : public QObject{
62   Q_OBJECT;
63  public:
64   VisuGUI();      
65   ~VisuGUI();     
66
67   static VISU::VISU_Gen_i* GetVisuGen();
68
69   static QAD_Desktop* GetDesktop();
70   static QAD_Study* GetActiveStudy();
71   static vtkRenderer* GetRenderer();
72   static VTKViewer_ViewFrame* GetVtkViewFrame();
73   static SALOMEDS::Study_var GetStudyDocument();
74   static SALOMEDS::StudyBuilder_var NewBuilder();
75   static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject);
76
77   static  VisuGUI* GetOrCreateVisuGUI(QAD_Desktop* desktop);
78   static  VisuGUI* GetVisuGUI() ;
79
80   static VISU::Result_i*  CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult);
81
82   bool CreateScalarMap(SALOMEDS::SObject_var theField);
83   static VISU::ScalarMap_i* CreateScalarMapPrs(SALOMEDS::SObject_var theField, 
84                                                const char* theMeshName, VISU::Entity theEntity, 
85                                                const char* theFieldName, double theTimeId);
86   bool CreateDeformedShape(SALOMEDS::SObject_var theField);
87   static VISU::DeformedShape_i* CreateDeformedShapePrs(SALOMEDS::SObject_var theField, 
88                                                        const char* theMeshName, VISU::Entity theEntity, 
89                                                        const char* theFieldName, double theTimeId);
90   bool CreateVectors(SALOMEDS::SObject_var theField);
91   static VISU::Vectors_i* CreateVectorsPrs(SALOMEDS::SObject_var theField, 
92                                            const char* theMeshName, VISU::Entity theEntity, 
93                                            const char* theFieldName, double theTimeId);
94   bool CreateIsoSurfaces(SALOMEDS::SObject_var theField);
95   static VISU::IsoSurfaces_i* CreateIsoSurfacesPrs(SALOMEDS::SObject_var theField, 
96                                                    const char* theMeshName, VISU::Entity theEntity, 
97                                                    const char* theFieldName, double theTimeId);
98   bool CreateCutPlanes(SALOMEDS::SObject_var theField);
99   static VISU::CutPlanes_i* CreateCutPlanesPrs(SALOMEDS::SObject_var theField, 
100                                                const char* theMeshName, VISU::Entity theEntity, 
101                                                const char* theFieldName, double theTimeId);
102   bool CreateCutLines(SALOMEDS::SObject_var theField);
103   static VISU::CutLines_i* CreateCutLinesPrs(SALOMEDS::SObject_var theField, 
104                                              const char* theMeshName, VISU::Entity theEntity, 
105                                              const char* theFieldName, double theTimeId);
106   bool CreateStreamLines(SALOMEDS::SObject_var theField);
107   static VISU::StreamLines_i* CreateStreamLinesPrs(SALOMEDS::SObject_var theField, 
108                                                    const char* theMeshName, VISU::Entity theEntity, 
109                                                    const char* theFieldName, double theTimeId);
110   bool TestObjectBrowser(SALOMEDS::SObject_var& objVisu);
111   
112   static void ShowTrihedron(bool Show);
113   static void ChangeViewer(int theType);
114              
115   static void NewColor(VISU_Actor *Actor);
116   static void NewOutlineColor(VISUMesh_Actor *Actor);
117   static void NewOpacity(VISU_Actor *Actor);
118   static void NewLinewidth(VISU_Actor *Actor);
119              
120   static void ChangeScalarBar();
121   static void SetSweepingPreferences();
122              
123   static void  PlotTable( VISU::Table_i* table, int theDisplaying );
124   static void  PlotCurve( VISU::Curve_i* curve, int theDisplaying );
125   static void  PlotContainer( VISU::Container_i* container, int theDisplaying );
126   
127   static QString getVisuInputDir();
128   static QString getVisuOutputDir();
129   
130   static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey);
131   static int checkHomoSelection();
132   
133   VISU_Actor* UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly=false);
134   bool IsDisplayed(VISU::Prs3d_i* thePrs);
135   void ErasePrs(VISU::Prs3d_i* thePrs);
136   
137   static VISU::Prs3d_i* GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO = NULL);
138   void RecreateActor(VISU::Prs3d_i* thePrs);
139   static void CreateActor(VISU::Prs3d_i* thePrs);
140   static VISU_Actor *GetActor(int* theSelectionType = NULL);
141   static VISU_Actor* GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame = NULL);
142   
143   void VisuGUI::ChangeRepresentation(RepresentType theType);
144   void DeletePresentation(VISU::Prs3d_i* thePrs);
145   
146   void  SetState(int aState );
147   void  ResetState();
148   void  EmitSignalDeactivateDialog();
149   void  EmitSignalCloseAllDialogs();
150   QDialog*      GetActiveDialogBox();
151   void  SetActiveDialogBox(QDialog* aDlg);
152   
153 // ----------------------------------------
154 // All method of standard EXPORT
155 // ----------------------------------------
156   Standard_EXPORT static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent);
157   Standard_EXPORT static bool setSettings(QAD_Desktop* parent);
158   Standard_EXPORT static void DefinePopup(QString & theContext,
159                                           QString & theParent, 
160                                           QString & theObject ) ;
161   Standard_EXPORT static bool CustomPopup(QAD_Desktop* parent,
162                                           QPopupMenu* popup,
163                                           const QString & theContext,
164                                           const QString & theParent,
165                                           const QString & theObject);
166   Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
167   Standard_EXPORT static bool OnMousePress(QMouseEvent* pe ,
168                                            QAD_Desktop* parent, 
169                                            QAD_StudyFrame* studyFrame);
170   Standard_EXPORT static bool OnMouseMove(QMouseEvent* pe ,
171                                           QAD_Desktop* parent, 
172                                           QAD_StudyFrame* studyFrame);
173   Standard_EXPORT static bool OnKeyPress(QKeyEvent* pe,
174                                          QAD_Desktop* parent,
175                                          QAD_StudyFrame* studyFrame);
176   public slots:
177   void ImportTablesFromFile();
178   void ImportFromFile();
179   void ExportToFile();
180   void CreateMesh();
181   void CreateScalarMap();
182   void CreateDeformedShape();
183   void CreateVectors();
184   void CreateIsoSurfaces();
185   void CreateCutPlanes();
186   void CreateCutLines();
187   void CreateStreamLines();
188   void CreateManyMesh();
189   
190   void DisplayPrs();
191   void DisplayOnlyPrs();
192   void ErasePrs();
193   void EditPrs();
194   void EditScalarBar();
195   void DisplayManyPrs();
196   void EraseManyPrs();
197   
198   void MakeWireframe();
199   void MakeSurface();
200   void MakePoints();
201   void MakeShrink();
202   
203   void ChageColor();
204   void ChangeOutlineColor();
205   void ChangeOpacity();
206   void ChangeLines();
207   
208   void ShowTable();
209   void CreateTable();
210   void PlotData();
211   void CurveProperties();
212   void ClearContainer();
213   
214   void SaveViewParams();
215   void RestoreViewParams();
216   
217   void DeletePrs();
218   void Rename();
219   void Sweep();
220   void TimeAnimation();
221   
222   void ImportMedField();
223   //void ImportMedMesh();
224   
225   void DeleteViewParams();
226   void CopyPresentation();
227
228   void InfoOnPoint();
229   void InfoOnCell();
230   void SelectPoint();
231   void SelectCell();
232
233 private :
234   QDialog* myActiveDialogBox;
235   int myState ;
236   
237 signals:
238   void SignalDeactivateActiveDialog();
239   void SignalCloseAllDialogs();
240 };
241
242 #endif