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