Salome HOME
Fix problems with compilation
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.h
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU VISUGUI : GUI of VISU component
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 #include "VISU_ColoredPrs3d_i.hh"
35
36 #include "SALOMEDSClient_Study.hxx"
37
38 #ifdef WITH_MEDGEN
39 #include "SALOMEconfig.h"
40 #include CORBA_SERVER_HEADER(MED_Gen)
41 #endif // WITH_MEDGEN
42
43 class QWidget;
44 class QDialog;
45 class QSpinBox;
46 class QDoubleSpinBox;
47
48 class SUIT_Desktop;
49 class SUIT_ViewWindow;
50 class VISU_Actor;
51 class SVTK_ViewWindow;
52 class SPlot2d_Viewer;
53 class SPlot2d_Curve;
54 class Plot2d_ViewFrame;
55 class CAM_Module;
56 class LightApp_SelectionMgr;
57 class SalomeApp_DoubleSpinBox;
58 class SalomeApp_IntSpinBox;
59 class SalomeApp_Module;
60 class SalomeApp_Study;
61 class VisuGUI;
62
63 #include <vector>
64 #include <utility>
65 #include "VISU_Mesh_i.hh"
66
67 namespace VISU 
68 {
69   class Base_i;
70   class Prs3d_i;
71   class Result_i;
72   class Table_i;
73   class Curve_i;
74   class Container_i;
75
76   typedef std::vector<SVTK_ViewWindow*> TViewWindows;
77
78   //----------------------------------------------------------------------------
79   SUIT_Desktop*                        GetDesktop(const CAM_Module* theModule);
80   SalomeApp_Study*                     GetAppStudy(const CAM_Module* theModule);
81   _PTR(Study)                          GetCStudy(const SalomeApp_Study* theStudy);
82
83   bool                                 IsStudyLocked( _PTR(Study) theStudy );
84   bool                                 CheckLock( _PTR(Study) theStudy,
85                                                   QWidget* theWidget );
86
87   //----------------------------------------------------------------------------
88   int                                  runAndWait( QDialog* dlg, const bool modal );
89
90   void                                 UpdateObjBrowser(SalomeApp_Module* theModule,
91                                                         bool theIsUpdateDataModel = true,
92                                                         _PTR(SObject) theSObject = _PTR(SObject)());
93
94   //----------------------------------------------------------------------------
95   VISU_Gen_i*                          GetVisuGen(const CAM_Module* theModule);
96 #ifdef WITH_MEDGEN
97   SALOME_MED::MED_Gen_var              GetMEDEngine();
98 #endif // WITH_MEDGEN
99
100   // Selection
101   LightApp_SelectionMgr*               GetSelectionMgr(const SalomeApp_Module* theModule);
102
103   //----------------------------------------------------------------------------
104   struct TObjectInfo
105   {
106     Base_i* myBase;
107     _PTR(SObject) mySObject;
108     TObjectInfo():
109       myBase(NULL)
110     {}
111   };
112
113   struct TSelectionItem
114   {
115     TObjectInfo myObjectInfo;
116     Handle(SALOME_InteractiveObject) myIO;
117   };
118
119   typedef std::vector<TSelectionItem>  TSelectionInfo;
120
121   TSelectionInfo                       GetSelectedObjects(const SalomeApp_Module* theModule);
122
123   TObjectInfo                          GetObjectByEntry(const SalomeApp_Study* theStudy,
124                                                         const std::string& theEntry);
125   
126   VISU::Prs3d_i*                       GetPrs3dToModify(const SalomeApp_Module* theModule,
127                                                         Base_i* theBase);
128
129   VISU::Prs3d_i*                       GetPrs3dFromBase(Base_i* theBase);
130
131   bool                                 GetPrs3dSelectionInfo( const SalomeApp_Module* theModule,
132                                                               VISU::Prs3d_i*& thePrs3d,
133                                                               SVTK_ViewWindow*& theViewWindow,
134                                                               VISU_Actor*& thenActor );
135
136   //----------------------------------------------------------------------------
137   void                                 Add(LightApp_SelectionMgr* theSelectionMgr,
138                                            const Handle(SALOME_InteractiveObject)& theIO);
139   void                                 Remove(LightApp_SelectionMgr* theSelectionMgr,
140                                               const Handle(SALOME_InteractiveObject)& theIO);
141
142   bool                                 IsRemovable        (const std::string theEntry,
143                                                            const SalomeApp_Module* theModule);
144   bool                                 IsRemovableSelected(const SalomeApp_Module* theModule);
145
146   void                                 DeleteSObject(VisuGUI* theModule,
147                                                      _PTR(Study)       theStudy,
148                                                      _PTR(SObject)     theSObject);
149   void                                 DeletePrs3d(VisuGUI* theModule,
150                                                    VISU::Prs3d_i* thePrs);
151
152   // Presentation management
153   void ChangeRepresentation (const SalomeApp_Module* theModule,
154                              VISU::PresentationType  theType);
155
156
157   void ChangeQuadratic2DRepresentation (const SalomeApp_Module* theModule,
158                                         VISU::Quadratic2DPresentationType  theType);
159   
160
161
162   void SetShading ( const SalomeApp_Module* theModule, bool theOn = true );
163
164   // SObject type
165   bool                                 CheckTimeStamp(const SalomeApp_Module* theModule,
166                                                       _PTR(SObject)&          theSObject,
167                                                       Handle(SALOME_InteractiveObject)& theIO,
168                                                       ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode);
169   VISU::Result_i*                      CheckResult(const SalomeApp_Module* theModule,
170                                                    _PTR(SObject) theSource,
171                                                    VISU::Result_var& theResult);
172   bool                                 IsSObjectTable(_PTR(SObject) theSObject);
173
174   /*! Display mesh presentation in given VTK view window
175    */
176   VISU_Actor*                          PublishMeshInView(const SalomeApp_Module* theModule,
177                                                          VISU::Prs3d_i* thePrs,
178                                                          SVTK_ViewWindow* theViewWindow);
179
180   /*!
181    * \brief Repaint all SVTK view windows, where the given object is displayed.
182    * \param theModule  - is used to access application.
183    * \param theIObject - is supposed to be selected (is highlighted in this method).
184    */
185   void                                 RepaintViewWindows(const SalomeApp_Module* theModule,
186                                                           const Handle(SALOME_InteractiveObject)& theIObject);
187
188   VISU_Actor*                          FindActor(const SalomeApp_Study* theStudy,
189                                                  SVTK_ViewWindow* theViewWindow,
190                                                  const QString& theEntry);
191   VISU_ActorBase*                      FindActorBase(const SalomeApp_Study* theStudy,
192                                                      SVTK_ViewWindow* theViewWindow,
193                                                      const QString& theEntry);
194   void                                 RecreateActor(const SalomeApp_Module* theModule,
195                                                      VISU::Prs3d_i* thePrs);
196
197   bool                                 ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
198                                                                 double allBounds[6], 
199                                                                 const char* theActorClassName = "VISU_Actor");
200
201   /*!
202    * \brief Advanced FitAll, sets view projection in accordance with current view contents
203    *
204    * If common bounding box of all actors in \a theViewWindow has
205    * at least one small side, then corresponding projection will be set
206    * (Top, Left or Front), else 3D projection will be used.
207    *
208    * \param theViewWindow - the view to perform FitAll in.
209    */
210   void                                 SetFitAll(SVTK_ViewWindow* theViewWindow);
211
212   // Plot2d View
213   SPlot2d_Viewer*                      GetPlot2dViewer(const SalomeApp_Module* theModule,
214                                                        const bool theCreate = false);
215   void                                 PlotTable( const SalomeApp_Module* theModule,
216                                                   VISU::Table_i* table,
217                                                   int theDisplaying );
218   void                                 PlotCurve( const SalomeApp_Module* theModule,
219                                                   VISU::Curve_i* curve,
220                                                   int theDisplaying );
221   void                                 PlotRemoveCurve(const SalomeApp_Module* theModule,
222                                                        VISU::Curve_i* curve);
223   void                                 PlotContainer( const SalomeApp_Module* theModule,
224                                                       VISU::Container_i* container,
225                                                       int theDisplaying );
226   void                                 CreatePlot( SalomeApp_Module* theModule,
227                                                    _PTR(SObject) theSobj );
228
229   /*! Create mesh presentation and display it in \a theViewWindow.
230    *  If \a theViewWindow is NULL, no displaying will be done.
231    */
232   VISU::Mesh_i* CreateMesh(VisuGUI* theModule,
233                            const Handle(SALOME_InteractiveObject)& theIO,
234                            SVTK_ViewWindow* theViewWindow);
235   
236   // Others
237   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
238                                             const Handle(SALOME_InteractiveObject)& theIO,
239                                             bool theGP = false);
240   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
241                                             _PTR(SObject) theObject,
242                                             bool theGP = false);
243   
244   int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow);
245   void AddScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
246                             VISU::Prs3d_i* thePrs3d, int pos);
247   void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
248                                VISU::Prs3d_i* thePrs3d);
249
250 #define CLIP_PLANES_FOLDER "Clipping Planes"
251
252   bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject);
253
254   void initSpinBox( SalomeApp_IntSpinBox*, const int, const int, const int );
255   void initSpinBox( SalomeApp_DoubleSpinBox*, const double&, const double&, const double&, const char* );
256 }
257
258 #endif