1 // Copyright (C) 2007-2008 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
22 // VISU VISUGUI : GUI of VISU component
23 // File : VisuGUI_Tools.h
24 // Author : Sergey Anikin
27 #ifndef VisuGUI_Tools_HeaderFile
28 #define VisuGUI_Tools_HeaderFile
30 #include "SALOME_InteractiveObject.hxx"
32 #include "VISUConfig.hh"
33 #include "VISU_ColoredPrs3d_i.hh"
35 #include "SALOMEDSClient_Study.hxx"
37 #include "SALOMEconfig.h"
38 #include CORBA_SERVER_HEADER(MED_Gen)
46 class SUIT_ViewWindow;
48 class SVTK_ViewWindow;
51 class Plot2d_ViewFrame;
53 class LightApp_SelectionMgr;
54 class SalomeApp_Module;
55 class SalomeApp_Study;
60 #include "VISU_Mesh_i.hh"
71 typedef std::vector<SVTK_ViewWindow*> TViewWindows;
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);
78 bool IsStudyLocked( _PTR(Study) theStudy );
79 bool CheckLock( _PTR(Study) theStudy,
82 //----------------------------------------------------------------------------
83 int runAndWait( QDialog* dlg, const bool modal );
85 void UpdateObjBrowser(SalomeApp_Module* theModule,
86 bool theIsUpdateDataModel = true,
87 _PTR(SObject) theSObject = _PTR(SObject)());
89 //----------------------------------------------------------------------------
90 VISU_Gen_i* GetVisuGen(const CAM_Module* theModule);
91 SALOME_MED::MED_Gen_var GetMEDEngine();
94 LightApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule);
96 //----------------------------------------------------------------------------
100 _PTR(SObject) mySObject;
106 struct TSelectionItem
108 TObjectInfo myObjectInfo;
109 Handle(SALOME_InteractiveObject) myIO;
112 typedef std::vector<TSelectionItem> TSelectionInfo;
114 TSelectionInfo GetSelectedObjects(const SalomeApp_Module* theModule);
116 TObjectInfo GetObjectByEntry(const SalomeApp_Study* theStudy,
117 const std::string& theEntry);
119 VISU::Prs3d_i* GetPrs3dToModify(const SalomeApp_Module* theModule,
122 VISU::Prs3d_i* GetPrs3dFromBase(Base_i* theBase);
124 bool GetPrs3dSelectionInfo( const SalomeApp_Module* theModule,
125 VISU::Prs3d_i*& thePrs3d,
126 SVTK_ViewWindow*& theViewWindow,
127 VISU_Actor*& thenActor );
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);
135 bool IsRemovable (const std::string theEntry,
136 const SalomeApp_Module* theModule);
137 bool IsRemovableSelected(const SalomeApp_Module* theModule);
139 void DeleteSObject(VisuGUI* theModule,
140 _PTR(Study) theStudy,
141 _PTR(SObject) theSObject);
142 void DeletePrs3d(VisuGUI* theModule,
143 VISU::Prs3d_i* thePrs);
145 // Presentation management
146 void ChangeRepresentation (const SalomeApp_Module* theModule,
147 VISU::PresentationType theType);
150 void ChangeQuadratic2DRepresentation (const SalomeApp_Module* theModule,
151 VISU::Quadratic2DPresentationType theType);
155 void SetShading ( const SalomeApp_Module* theModule, bool theOn = true );
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);
167 /*! Display mesh presentation in given VTK view window
169 VISU_Actor* PublishMeshInView(const SalomeApp_Module* theModule,
170 VISU::Prs3d_i* thePrs,
171 SVTK_ViewWindow* theViewWindow);
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).
178 void RepaintViewWindows(const SalomeApp_Module* theModule,
179 const Handle(SALOME_InteractiveObject)& theIObject);
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);
190 bool ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
191 vtkFloatingPointType allBounds[6],
192 const char* theActorClassName = "VISU_Actor");
195 * \brief Advanced FitAll, sets view projection in accordance with current view contents
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.
201 * \param theViewWindow - the view to perform FitAll in.
203 void SetFitAll(SVTK_ViewWindow* theViewWindow);
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,
211 void PlotCurve( const SalomeApp_Module* theModule,
212 VISU::Curve_i* curve,
214 void PlotRemoveCurve(const SalomeApp_Module* theModule,
215 VISU::Curve_i* curve);
216 void PlotContainer( const SalomeApp_Module* theModule,
217 VISU::Container_i* container,
219 void CreatePlot( SalomeApp_Module* theModule,
220 _PTR(SObject) theSobj );
222 /*! Create mesh presentation and display it in \a theViewWindow.
223 * If \a theViewWindow is NULL, no displaying will be done.
225 VISU::Mesh_i* CreateMesh(VisuGUI* theModule,
226 const Handle(SALOME_InteractiveObject)& theIO,
227 SVTK_ViewWindow* theViewWindow);
230 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
231 const Handle(SALOME_InteractiveObject)& theIO,
233 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
234 _PTR(SObject) theObject,
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 );
245 #define CLIP_PLANES_FOLDER "Clipping Planes"
247 bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject);