Salome HOME
d514b4b3a223fe691bcfc90bbf20f8767653b46c
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.h
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2005  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_Tools.h
25 //  Author : Sergey Anikin
26 //  Module : VISU
27
28 #ifndef VisuGUI_Tools_HeaderFile
29 #define VisuGUI_Tools_HeaderFile
30
31 #include "SALOME_InteractiveObject.hxx"
32
33 #include "VISUConfig.hh"
34
35 #include "SALOMEDSClient_Study.hxx"
36
37 #include "SALOMEconfig.h"
38 #include CORBA_SERVER_HEADER(MED_Gen)
39
40 class QWidget;
41
42 class SUIT_Desktop;
43 class SUIT_ViewWindow;
44 class VISU_Actor;
45 class SVTK_ViewWindow;
46 class SPlot2d_Viewer;
47 class SPlot2d_Curve;
48 class Plot2d_ViewFrame;
49 class CAM_Module;
50 class LightApp_SelectionMgr;
51 class SalomeApp_Module;
52 class SalomeApp_Study;
53 class VisuGUI;
54
55 namespace VISU {
56   class Prs3d_i;
57   class Result_i;
58   class Table_i;
59   class Curve_i;
60   class Container_i;
61
62   typedef std::vector<SVTK_ViewWindow*> TViewWindows;
63
64   SUIT_Desktop*                        GetDesktop(const CAM_Module* theModule);
65   SalomeApp_Study*                     GetAppStudy(const CAM_Module* theModule);
66   _PTR(Study)                          GetCStudy(const SalomeApp_Study* theStudy);
67
68   bool                                 IsStudyLocked( _PTR(Study) theStudy );
69   bool                                 CheckLock( _PTR(Study) theStudy,
70                                                   QWidget* theWidget );
71
72   void                                 UpdateObjBrowser(SalomeApp_Module* theModule,
73                                                         bool theIsUpdateDataModel = true,
74                                                         _PTR(SObject) theSObject = _PTR(SObject)());
75
76   VISU_Gen_i*                          GetVisuGen(const CAM_Module* theModule);
77   SALOME_MED::MED_Gen_var              GetMEDEngine();
78
79   VISU::Storable::TRestoringMap        getMapOfValue(_PTR(SObject) theSObject);
80   QString                              getValue(_PTR(SObject) theSObject, QString theKey);
81
82   // Selection
83   LightApp_SelectionMgr*               GetSelectionMgr(const SalomeApp_Module* theModule);
84   CORBA::Object_var                    GetSelectedObj(const SalomeApp_Study* theStudy,
85                                                       const QString& theEntry,
86                                                       VISU::Storable::TRestoringMap* theMap = NULL);
87   CORBA::Object_var                    GetSelectedObj(const SalomeApp_Module* theModule,
88                                                       Handle(SALOME_InteractiveObject)* theIO = NULL,
89                                                       VISU::Storable::TRestoringMap* theMap = NULL);
90   VISU::Prs3d_i*                       GetPrsToModify(const SalomeApp_Module* theModule,
91                                                       Handle(SALOME_InteractiveObject)* theIO = NULL,
92                                                       VISU::Storable::TRestoringMap* theMap = NULL);
93
94   void                                 Add(LightApp_SelectionMgr* theSelectionMgr,
95                                            const Handle(SALOME_InteractiveObject)& theIO);
96   void                                 Remove(LightApp_SelectionMgr* theSelectionMgr,
97                                               const Handle(SALOME_InteractiveObject)& theIO);
98
99   bool                                 IsRemovableSelected(const SalomeApp_Module* theModule);
100
101   // Display/Erase
102   void                                 ErasePrs(const SalomeApp_Module* theModule,
103                                                 CORBA::Object_ptr theObject,
104                                                 bool theUpdate = true);
105   void                                 DeleteSObject(VisuGUI* theModule,
106                                                      _PTR(Study)       theStudy,
107                                                      _PTR(SObject)     theSObject);
108   void                                 DeletePrs3d(VisuGUI* theModule,
109                                                    VISU::Prs3d_i* thePrs,
110                                                    const Handle(SALOME_InteractiveObject)& theIO);
111   void                                 ErasePrs3d(const SalomeApp_Module* theModule,
112                                                   VISU::Prs3d_i* thePrs);
113
114   // Presentation management
115   void ChangeRepresentation (const SalomeApp_Module* theModule,
116                              VISU::PresentationType  theType);
117
118   void SetShading ( const SalomeApp_Module* theModule, bool theOn = true );
119
120   // SObject type
121   bool                                 CheckTimeStamp(const SalomeApp_Module* theModule,
122                                                       _PTR(SObject)&          theSObject,
123                                                       Handle(SALOME_InteractiveObject)* theIO = NULL);
124   VISU::Result_i*                      CheckResult(const SalomeApp_Module* theModule,
125                                                    _PTR(SObject) theSource,
126                                                    VISU::Result_var& theResult);
127   bool                                 IsSObjectTable(_PTR(SObject) theSObject);
128
129   // Views
130   SUIT_ViewWindow*                     GetActiveView(const SalomeApp_Module* theModule,
131                                                      QString theType = QString::null);
132
133   // VTK View
134   TViewWindows                         GetViews(const SalomeApp_Module* theModule);
135   SVTK_ViewWindow*                     GetViewWindow(const SalomeApp_Module* theModule,
136                                                      const bool theCreate = false );
137   SVTK_ViewWindow*                     GetViewWindow();
138
139   VISU_Actor*                          PublishInView(const SalomeApp_Module* theModule,
140                                                      VISU::Prs3d_i* thePrs);
141   VISU_Actor*                          UpdateViewer(const SalomeApp_Module* theModule,
142                                                     VISU::Prs3d_i* thePrs,
143                                                     bool theDispOnly = false);
144
145   /*!
146    * \brief Repaint all SVTK view windows, where the given object is displayed.
147    * \param theModule  - is used to access application.
148    * \param theIObject - is supposed to be selected (is highlighted in this method).
149    */
150   void                                 RepaintViewWindows(const SalomeApp_Module* theModule,
151                                                           const Handle(SALOME_InteractiveObject)& theIObject);
152
153   VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
154                                                  const char* theEntry);
155   VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
156                                                  VISU::Prs3d_i* thePrs);
157   void                                 RecreateActor(const SalomeApp_Module* theModule,
158                                                      VISU::Prs3d_i* thePrs);
159
160   /*!
161    * \brief Advanced FitAll, sets view projection in accordance with current view contents
162    *
163    * If common bounding box of all actors in \a theViewWindow has
164    * at least one small side, then corresponding projection will be set
165    * (Top, Left or Front), else 3D projection will be used.
166    *
167    * \param theViewWindow - the view to perform FitAll in.
168    */
169   void                                 SetFitAll(SVTK_ViewWindow* theViewWindow);
170
171   // Plot2d View
172   SPlot2d_Viewer*                      GetPlot2dViewer(const SalomeApp_Module* theModule,
173                                                        const bool theCreate = false);
174   void                                 PlotTable( const SalomeApp_Module* theModule,
175                                                   VISU::Table_i* table,
176                                                   int theDisplaying );
177   void                                 PlotCurve( const SalomeApp_Module* theModule,
178                                                   VISU::Curve_i* curve,
179                                                   int theDisplaying );
180   void                                 PlotContainer( const SalomeApp_Module* theModule,
181                                                       VISU::Container_i* container,
182                                                       int theDisplaying );
183   void                                 CreatePlot( SalomeApp_Module* theModule,
184                                                    _PTR(SObject) theSobj );
185
186   void                                 UpdateCurve( VISU::Curve_i*,
187                                                     Plot2d_ViewFrame* frame,
188                                                     SPlot2d_Curve*,
189                                                     int theDisplaying );
190   //parameter frame may be 0, in this case there is only update without display/erase 
191
192   // Others
193   void CreateMesh (const SalomeApp_Module* theModule,
194                    const Handle(SALOME_InteractiveObject)& theIO);
195
196   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
197                                             const Handle(SALOME_InteractiveObject)& theIO);
198   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
199                                             _PTR(SObject) theObject);
200   
201   int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule);
202   void AddScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d, int pos);
203   void RemoveScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d);
204   void RemoveScalarBarPosition(VisuGUI* theModule,SVTK_ViewWindow* vw,VISU::Prs3d_i* thePrs3d);
205   void RemoveScalarBarPosition(VisuGUI* theModule,CORBA::Object_ptr theObject);
206 }
207
208 #endif