]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_Tools.h
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 #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
44 class SUIT_Desktop;
45 class SUIT_ViewWindow;
46 class VISU_Actor;
47 class SVTK_ViewWindow;
48 class SPlot2d_Viewer;
49 class SPlot2d_Curve;
50 class Plot2d_ViewFrame;
51 class CAM_Module;
52 class LightApp_SelectionMgr;
53 class SalomeApp_Module;
54 class SalomeApp_Study;
55 class VisuGUI;
56
57 #include <vector>
58 #include <utility>
59
60 namespace VISU 
61 {
62   class Base_i;
63   class Prs3d_i;
64   class Result_i;
65   class Table_i;
66   class Curve_i;
67   class Container_i;
68
69   typedef std::vector<SVTK_ViewWindow*> TViewWindows;
70
71   //----------------------------------------------------------------------------
72   SUIT_Desktop*                        GetDesktop(const CAM_Module* theModule);
73   SalomeApp_Study*                     GetAppStudy(const CAM_Module* theModule);
74   _PTR(Study)                          GetCStudy(const SalomeApp_Study* theStudy);
75
76   bool                                 IsStudyLocked( _PTR(Study) theStudy );
77   bool                                 CheckLock( _PTR(Study) theStudy,
78                                                   QWidget* theWidget );
79
80   //----------------------------------------------------------------------------
81   int                                  runAndWait( QDialog* dlg, const bool modal );
82
83   void                                 UpdateObjBrowser(SalomeApp_Module* theModule,
84                                                         bool theIsUpdateDataModel = true,
85                                                         _PTR(SObject) theSObject = _PTR(SObject)());
86
87   //----------------------------------------------------------------------------
88   VISU_Gen_i*                          GetVisuGen(const CAM_Module* theModule);
89   SALOME_MED::MED_Gen_var              GetMEDEngine();
90
91   // Selection
92   LightApp_SelectionMgr*               GetSelectionMgr(const SalomeApp_Module* theModule);
93
94   //----------------------------------------------------------------------------
95   struct TObjectInfo
96   {
97     Base_i* myBase;
98     _PTR(SObject) mySObject;
99     TObjectInfo():
100       myBase(NULL)
101     {}
102   };
103
104   struct TSelectionItem
105   {
106     TObjectInfo myObjectInfo;
107     Handle(SALOME_InteractiveObject) myIO;
108   };
109
110   typedef std::vector<TSelectionItem>  TSelectionInfo;
111
112   TSelectionInfo                       GetSelectedObjects(const SalomeApp_Module* theModule);
113
114   TObjectInfo                          GetObjectByEntry(const SalomeApp_Study* theStudy,
115                                                         const std::string& theEntry);
116   
117   VISU::Prs3d_i*                       GetPrs3dToModify(const SalomeApp_Module* theModule,
118                                                         Base_i* theBase);
119
120   VISU::Prs3d_i*                       GetPrs3dFromBase(Base_i* theBase);
121
122   //----------------------------------------------------------------------------
123   void                                 Add(LightApp_SelectionMgr* theSelectionMgr,
124                                            const Handle(SALOME_InteractiveObject)& theIO);
125   void                                 Remove(LightApp_SelectionMgr* theSelectionMgr,
126                                               const Handle(SALOME_InteractiveObject)& theIO);
127
128   bool                                 IsRemovableSelected(const SalomeApp_Module* theModule);
129
130   void                                 DeleteSObject(VisuGUI* theModule,
131                                                      _PTR(Study)       theStudy,
132                                                      _PTR(SObject)     theSObject);
133   void                                 DeletePrs3d(VisuGUI* theModule,
134                                                    VISU::Prs3d_i* thePrs);
135
136   // Presentation management
137   void ChangeRepresentation (const SalomeApp_Module* theModule,
138                              VISU::PresentationType  theType);
139
140   void SetShading ( const SalomeApp_Module* theModule, bool theOn = true );
141
142   // SObject type
143   bool                                 CheckTimeStamp(const SalomeApp_Module* theModule,
144                                                       _PTR(SObject)&          theSObject,
145                                                       Handle(SALOME_InteractiveObject)& theIO,
146                                                       ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode);
147   VISU::Result_i*                      CheckResult(const SalomeApp_Module* theModule,
148                                                    _PTR(SObject) theSource,
149                                                    VISU::Result_var& theResult);
150   bool                                 IsSObjectTable(_PTR(SObject) theSObject);
151
152   /*! Display mesh presentation in given VTK view window
153    */
154   VISU_Actor*                          PublishMeshInView(const SalomeApp_Module* theModule,
155                                                          VISU::Prs3d_i* thePrs,
156                                                          SVTK_ViewWindow* theViewWindow);
157
158   /*!
159    * \brief Repaint all SVTK view windows, where the given object is displayed.
160    * \param theModule  - is used to access application.
161    * \param theIObject - is supposed to be selected (is highlighted in this method).
162    */
163   void                                 RepaintViewWindows(const SalomeApp_Module* theModule,
164                                                           const Handle(SALOME_InteractiveObject)& theIObject);
165
166   VISU_Actor*                          FindActor(const SalomeApp_Study* theStudy,
167                                                  SVTK_ViewWindow* theViewWindow,
168                                                  const QString& theEntry);
169   void                                 RecreateActor(const SalomeApp_Module* theModule,
170                                                      VISU::Prs3d_i* thePrs);
171
172   /*!
173    * \brief Advanced FitAll, sets view projection in accordance with current view contents
174    *
175    * If common bounding box of all actors in \a theViewWindow has
176    * at least one small side, then corresponding projection will be set
177    * (Top, Left or Front), else 3D projection will be used.
178    *
179    * \param theViewWindow - the view to perform FitAll in.
180    */
181   void                                 SetFitAll(SVTK_ViewWindow* theViewWindow);
182
183   // Plot2d View
184   SPlot2d_Viewer*                      GetPlot2dViewer(const SalomeApp_Module* theModule,
185                                                        const bool theCreate = false);
186   void                                 PlotTable( const SalomeApp_Module* theModule,
187                                                   VISU::Table_i* table,
188                                                   int theDisplaying );
189   void                                 PlotCurve( const SalomeApp_Module* theModule,
190                                                   VISU::Curve_i* curve,
191                                                   int theDisplaying );
192   void                                 PlotRemoveCurve(const SalomeApp_Module* theModule,
193                                                        VISU::Curve_i* curve);
194   void                                 PlotContainer( const SalomeApp_Module* theModule,
195                                                       VISU::Container_i* container,
196                                                       int theDisplaying );
197   void                                 CreatePlot( SalomeApp_Module* theModule,
198                                                    _PTR(SObject) theSobj );
199
200   /*! Display/Erase/Update a curve presentation.
201    *  Parameter \a frame may be NULL, in this case there is only update without display/erase
202    */
203   void                                 UpdateCurve( VISU::Curve_i*,
204                                                     Plot2d_ViewFrame* frame,
205                                                     SPlot2d_Curve*,
206                                                     int theDisplaying );
207
208   /*! Create mesh presentation and display it in \a theViewWindow.
209    *  If \a theViewWindow is NULL, no displaying will be done.
210    */
211   void CreateMesh(VisuGUI* theModule,
212                   const Handle(SALOME_InteractiveObject)& theIO,
213                   SVTK_ViewWindow* theViewWindow);
214   
215   // Others
216   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
217                                             const Handle(SALOME_InteractiveObject)& theIO);
218   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
219                                             _PTR(SObject) theObject);
220   
221   int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow);
222   void AddScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
223                             VISU::Prs3d_i* thePrs3d, int pos);
224   void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
225                                VISU::Prs3d_i* thePrs3d);
226 }
227
228 #endif