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);
149 void SetShading ( const SalomeApp_Module* theModule, bool theOn = true );
152 bool CheckTimeStamp(const SalomeApp_Module* theModule,
153 _PTR(SObject)& theSObject,
154 Handle(SALOME_InteractiveObject)& theIO,
155 ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode);
156 VISU::Result_i* CheckResult(const SalomeApp_Module* theModule,
157 _PTR(SObject) theSource,
158 VISU::Result_var& theResult);
159 bool IsSObjectTable(_PTR(SObject) theSObject);
161 /*! Display mesh presentation in given VTK view window
163 VISU_Actor* PublishMeshInView(const SalomeApp_Module* theModule,
164 VISU::Prs3d_i* thePrs,
165 SVTK_ViewWindow* theViewWindow);
168 * \brief Repaint all SVTK view windows, where the given object is displayed.
169 * \param theModule - is used to access application.
170 * \param theIObject - is supposed to be selected (is highlighted in this method).
172 void RepaintViewWindows(const SalomeApp_Module* theModule,
173 const Handle(SALOME_InteractiveObject)& theIObject);
175 VISU_Actor* FindActor(const SalomeApp_Study* theStudy,
176 SVTK_ViewWindow* theViewWindow,
177 const QString& theEntry);
178 VISU_ActorBase* FindActorBase(const SalomeApp_Study* theStudy,
179 SVTK_ViewWindow* theViewWindow,
180 const QString& theEntry);
181 void RecreateActor(const SalomeApp_Module* theModule,
182 VISU::Prs3d_i* thePrs);
184 bool ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
185 vtkFloatingPointType allBounds[6],
186 const char* theActorClassName = "VISU_Actor");
189 * \brief Advanced FitAll, sets view projection in accordance with current view contents
191 * If common bounding box of all actors in \a theViewWindow has
192 * at least one small side, then corresponding projection will be set
193 * (Top, Left or Front), else 3D projection will be used.
195 * \param theViewWindow - the view to perform FitAll in.
197 void SetFitAll(SVTK_ViewWindow* theViewWindow);
200 SPlot2d_Viewer* GetPlot2dViewer(const SalomeApp_Module* theModule,
201 const bool theCreate = false);
202 void PlotTable( const SalomeApp_Module* theModule,
203 VISU::Table_i* table,
205 void PlotCurve( const SalomeApp_Module* theModule,
206 VISU::Curve_i* curve,
208 void PlotRemoveCurve(const SalomeApp_Module* theModule,
209 VISU::Curve_i* curve);
210 void PlotContainer( const SalomeApp_Module* theModule,
211 VISU::Container_i* container,
213 void CreatePlot( SalomeApp_Module* theModule,
214 _PTR(SObject) theSobj );
216 /*! Display/Erase/Update a curve presentation.
217 * Parameter \a frame may be NULL, in this case there is only update without display/erase
219 void UpdateCurve( VISU::Curve_i*,
220 Plot2d_ViewFrame* frame,
224 /*! Create mesh presentation and display it in \a theViewWindow.
225 * If \a theViewWindow is NULL, no displaying will be done.
227 VISU::Mesh_i* CreateMesh(VisuGUI* theModule,
228 const Handle(SALOME_InteractiveObject)& theIO,
229 SVTK_ViewWindow* theViewWindow);
232 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
233 const Handle(SALOME_InteractiveObject)& theIO);
234 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
235 _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);