1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // VISU VISUGUI : GUI of VISU component
24 // File : VisuGUI_Tools.h
25 // Author : Sergey Anikin
28 #ifndef VisuGUI_Tools_HeaderFile
29 #define VisuGUI_Tools_HeaderFile
31 #include "SALOME_InteractiveObject.hxx"
33 #include "VISUConfig.hh"
34 #include "VISU_ColoredPrs3d_i.hh"
36 #include "SALOMEDSClient_Study.hxx"
38 #include "SALOMEconfig.h"
39 #include CORBA_SERVER_HEADER(MED_Gen)
47 class SUIT_ViewWindow;
49 class SVTK_ViewWindow;
52 class Plot2d_ViewFrame;
54 class LightApp_SelectionMgr;
55 class SalomeApp_DoubleSpinBox;
56 class SalomeApp_IntSpinBox;
57 class SalomeApp_Module;
58 class SalomeApp_Study;
63 #include "VISU_Mesh_i.hh"
74 typedef std::vector<SVTK_ViewWindow*> TViewWindows;
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);
81 bool IsStudyLocked( _PTR(Study) theStudy );
82 bool CheckLock( _PTR(Study) theStudy,
85 //----------------------------------------------------------------------------
86 int runAndWait( QDialog* dlg, const bool modal );
88 void UpdateObjBrowser(SalomeApp_Module* theModule,
89 bool theIsUpdateDataModel = true,
90 _PTR(SObject) theSObject = _PTR(SObject)());
92 //----------------------------------------------------------------------------
93 VISU_Gen_i* GetVisuGen(const CAM_Module* theModule);
94 SALOME_MED::MED_Gen_var GetMEDEngine();
97 LightApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule);
99 //----------------------------------------------------------------------------
103 _PTR(SObject) mySObject;
109 struct TSelectionItem
111 TObjectInfo myObjectInfo;
112 Handle(SALOME_InteractiveObject) myIO;
115 typedef std::vector<TSelectionItem> TSelectionInfo;
117 TSelectionInfo GetSelectedObjects(const SalomeApp_Module* theModule);
119 TObjectInfo GetObjectByEntry(const SalomeApp_Study* theStudy,
120 const std::string& theEntry);
122 VISU::Prs3d_i* GetPrs3dToModify(const SalomeApp_Module* theModule,
125 VISU::Prs3d_i* GetPrs3dFromBase(Base_i* theBase);
127 bool GetPrs3dSelectionInfo( const SalomeApp_Module* theModule,
128 VISU::Prs3d_i*& thePrs3d,
129 SVTK_ViewWindow*& theViewWindow,
130 VISU_Actor*& thenActor );
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);
138 bool IsRemovable (const std::string theEntry,
139 const SalomeApp_Module* theModule);
140 bool IsRemovableSelected(const SalomeApp_Module* theModule);
142 void DeleteSObject(VisuGUI* theModule,
143 _PTR(Study) theStudy,
144 _PTR(SObject) theSObject);
145 void DeletePrs3d(VisuGUI* theModule,
146 VISU::Prs3d_i* thePrs);
148 // Presentation management
149 void ChangeRepresentation (const SalomeApp_Module* theModule,
150 VISU::PresentationType theType);
153 void ChangeQuadratic2DRepresentation (const SalomeApp_Module* theModule,
154 VISU::Quadratic2DPresentationType theType);
158 void SetShading ( const SalomeApp_Module* theModule, bool theOn = true );
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);
170 /*! Display mesh presentation in given VTK view window
172 VISU_Actor* PublishMeshInView(const SalomeApp_Module* theModule,
173 VISU::Prs3d_i* thePrs,
174 SVTK_ViewWindow* theViewWindow);
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).
181 void RepaintViewWindows(const SalomeApp_Module* theModule,
182 const Handle(SALOME_InteractiveObject)& theIObject);
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);
193 bool ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
194 vtkFloatingPointType allBounds[6],
195 const char* theActorClassName = "VISU_Actor");
198 * \brief Advanced FitAll, sets view projection in accordance with current view contents
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.
204 * \param theViewWindow - the view to perform FitAll in.
206 void SetFitAll(SVTK_ViewWindow* theViewWindow);
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,
214 void PlotCurve( const SalomeApp_Module* theModule,
215 VISU::Curve_i* curve,
217 void PlotRemoveCurve(const SalomeApp_Module* theModule,
218 VISU::Curve_i* curve);
219 void PlotContainer( const SalomeApp_Module* theModule,
220 VISU::Container_i* container,
222 void CreatePlot( SalomeApp_Module* theModule,
223 _PTR(SObject) theSobj );
225 /*! Create mesh presentation and display it in \a theViewWindow.
226 * If \a theViewWindow is NULL, no displaying will be done.
228 VISU::Mesh_i* CreateMesh(VisuGUI* theModule,
229 const Handle(SALOME_InteractiveObject)& theIO,
230 SVTK_ViewWindow* theViewWindow);
233 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
234 const Handle(SALOME_InteractiveObject)& theIO,
236 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
237 _PTR(SObject) theObject,
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);
246 #define CLIP_PLANES_FOLDER "Clipping Planes"
248 bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject);
250 void initSpinBox( SalomeApp_IntSpinBox*, const int, const int, const int );
251 void initSpinBox( SalomeApp_DoubleSpinBox*, const double&, const double&, const double&, const char* );