Salome HOME
Merge with OCC-V2_1_0_deb
[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 class VisuGUI_SelectionDlg;
49
50 #include <vtkDataSet.h>
51 class vtkRenderer;
52
53 #include <TColStd_MapOfInteger.hxx>
54 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
55 #include "SALOME_ListIteratorOfListIO.hxx"
56
57 #include "SALOMEGUI.h"
58
59 namespace VISU{
60   class VISU_Gen_i;
61
62   class Result_i;
63
64   class Prs3d_i;
65   class ScalarMap_i;
66   class DeformedShape_i;
67   class IsoSurfaces_i;
68   class CutPlanes_i;
69   class CutLines_i;
70   class Vectors_i;
71   class StreamLines_i;
72
73   class Table_i;
74   class Curve_i;
75   class Container_i;
76 }
77
78 // ======================================================================
79 //                              CLASS VIUSGUI
80 // ======================================================================
81 // 
82
83 class VisuGUI : public SALOMEGUI{
84   Q_OBJECT;
85  public:
86   VisuGUI( const QString& name = "", QObject* parent = 0 );       
87   virtual ~VisuGUI();     
88   
89   static VISU::VISU_Gen_i* GetVisuGen();
90
91   static QAD_Desktop* GetDesktop();
92   static QAD_Study* GetActiveStudy();
93   static vtkRenderer* GetRenderer();
94   static VTKViewer_ViewFrame* GetVtkViewFrame();
95   static SALOMEDS::Study_var GetStudyDocument();
96   static SALOMEDS::StudyBuilder_var NewBuilder();
97   static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject);
98
99   static VISU::Result_i*  CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult);
100
101   enum CameraOrient {e3D, eFront, eLeft, eTop};
102   static CameraOrient SetFitAll( VTKViewer_ViewFrame* vf);
103
104   typedef VISU::Result_ptr (VISU::VISU_Gen_i::* TImportFun)(const char*);
105   void ImportFromFile(TImportFun theImportFun);
106
107   bool CreateScalarMap(SALOMEDS::SObject_var theField);
108   static VISU::ScalarMap_i* CreateScalarMapPrs(SALOMEDS::SObject_var theField, 
109                                                const char* theMeshName, VISU::Entity theEntity, 
110                                                const char* theFieldName, int theTimeId);
111   bool CreateDeformedShape(SALOMEDS::SObject_var theField);
112   static VISU::DeformedShape_i* CreateDeformedShapePrs(SALOMEDS::SObject_var theField, 
113                                                        const char* theMeshName, VISU::Entity theEntity, 
114                                                        const char* theFieldName, int theTimeId);
115   bool CreateVectors(SALOMEDS::SObject_var theField);
116   static VISU::Vectors_i* CreateVectorsPrs(SALOMEDS::SObject_var theField, 
117                                            const char* theMeshName, VISU::Entity theEntity, 
118                                            const char* theFieldName, int theTimeId);
119   bool CreateIsoSurfaces(SALOMEDS::SObject_var theField);
120   static VISU::IsoSurfaces_i* CreateIsoSurfacesPrs(SALOMEDS::SObject_var theField, 
121                                                    const char* theMeshName, VISU::Entity theEntity, 
122                                                    const char* theFieldName, int theTimeId);
123   bool CreateCutPlanes(SALOMEDS::SObject_var theField);
124   static VISU::CutPlanes_i* CreateCutPlanesPrs(SALOMEDS::SObject_var theField, 
125                                                const char* theMeshName, VISU::Entity theEntity, 
126                                                const char* theFieldName, int theTimeId);
127   bool CreateCutLines(SALOMEDS::SObject_var theField);
128   static VISU::CutLines_i* CreateCutLinesPrs(SALOMEDS::SObject_var theField, 
129                                              const char* theMeshName, VISU::Entity theEntity, 
130                                              const char* theFieldName, int theTimeId);
131   bool CreateStreamLines(SALOMEDS::SObject_var theField);
132   static VISU::StreamLines_i* CreateStreamLinesPrs(SALOMEDS::SObject_var theField, 
133                                                    const char* theMeshName, VISU::Entity theEntity, 
134                                                    const char* theFieldName, int theTimeId);
135   bool TestObjectBrowser(SALOMEDS::SObject_var& objVisu);
136  
137   static void ShowTrihedron(bool Show);
138   static void ChangeViewer(int theType);
139              
140   static void NewColor(VISU_Actor *Actor);
141   static void NewWireframeColor(VISU_MeshAct *Actor);
142   static void NewOpacity(VISU_Actor *Actor);
143   static void NewLinewidth(VISU_Actor *Actor);
144              
145   static void ChangeScalarBar();
146   static void SetSweepingPreferences();
147              
148   static void  PlotTable( VISU::Table_i* table, int theDisplaying );
149   static void  PlotCurve( VISU::Curve_i* curve, int theDisplaying );
150   static void  PlotContainer( VISU::Container_i* container, int theDisplaying );
151   
152   static QString getVisuInputDir();
153   static QString getVisuOutputDir();
154   
155   static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey);
156   static int checkHomoSelection();
157   
158   static VISU_Actor* UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly=false);
159   static bool IsDisplayed(VISU::Prs3d_i* thePrs);
160   static void ErasePrs(VISU::Prs3d_i* thePrs);
161   
162   static VISU::Prs3d_i* GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO = NULL);
163   static void RecreateActor(VISU::Prs3d_i* thePrs);
164   static void CreateActor(VISU::Prs3d_i* thePrs);
165   static VISU_Actor* GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame = NULL);
166   
167   void VisuGUI::ChangeRepresentation(VISU::PresentationType theType);
168   void DeletePresentation(VISU::Prs3d_i* thePrs);
169   void DeletePresentation(VISU::Curve_i* theCurve);
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   void CreatePlot(SALOMEDS::SObject_var theTableSO);
179
180 // ----------------------------------------
181 // All method of standard EXPORT
182 // ----------------------------------------
183   virtual bool OnGUIEvent(int theCommandID, QAD_Desktop* parent);
184   virtual bool SetSettings(QAD_Desktop* parent);
185   virtual void DefinePopup(QString & theContext,
186                                           QString & theParent, 
187                                           QString & theObject ) ;
188   virtual bool CustomPopup(QAD_Desktop* parent,
189                                           QPopupMenu* popup,
190                                           const QString & theContext,
191                                           const QString & theParent,
192                                           const QString & theObject);
193   virtual void BuildPresentation( const Handle(SALOME_InteractiveObject)&,
194                                   QAD_ViewFrame*  = 0 );
195   virtual bool OnMousePress(QMouseEvent* pe ,
196                                            QAD_Desktop* parent, 
197                                            QAD_StudyFrame* studyFrame);
198   virtual bool OnMouseMove(QMouseEvent* pe ,
199                                           QAD_Desktop* parent, 
200                                           QAD_StudyFrame* studyFrame);
201   virtual bool OnKeyPress(QKeyEvent* pe,
202                                          QAD_Desktop* parent,
203                                          QAD_StudyFrame* studyFrame);
204   virtual void SupportedViewType (int* buffer, int bufferSize);
205
206 public slots:
207   void ImportTablesFromFile();
208   void ExportTableToFile();
209
210   void ImportFile();
211   void CopyAndImportFile();
212
213   void ExportToFile();
214
215   void CreateMesh();
216   void CreateScalarMap();
217   void CreateDeformedShape();
218   void CreateVectors();
219   void CreateIsoSurfaces();
220   void CreateCutPlanes();
221   void CreateCutLines();
222   void CreateStreamLines();
223   void CreateManyMesh();
224   void CreatePlot2dView();
225   
226   void DisplayPrs();
227   void DisplayOnlyPrs();
228   void ErasePrs();
229   void EditPrs();
230   void DisplayManyPrs();
231   void DisplayOnlyManyPrs();
232   void EraseManyPrs();
233   void EditContainer();
234   
235   void MakeSurfaceframe();
236   void MakeInsideframe();
237   void MakeWireframe();
238   void MakeSurface();
239   void MakePoints();
240   void MakeShrink();
241   
242   void ChageColor();
243   void ChangeWireframeColor();
244   void ChangeOpacity();
245   void ChangeLines();
246   
247   void ShowTable();
248   void CreateTable();
249   void DeleteObject();
250   void PlotData();
251   void CurveProperties();
252   void ClearContainer();
253   
254   void SaveViewParams();
255   void RestoreViewParams();
256   
257   void DeletePrs();
258   void Rename();
259   void RenameTable();
260   void RenameContainer();
261   void Sweep();
262   void TimeAnimation();
263   
264   void ImportMedField();
265   //void ImportMedMesh();
266   
267   void DeleteViewParams();
268   void CopyPresentation();
269
270   void SelectionInfo();
271
272 private :
273   QDialog* myActiveDialogBox;
274   int myState ;
275   VisuGUI_SelectionDlg* mySelectionDlg;
276 };
277
278 #endif