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