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