1 // Copyright (C) 2007-2013 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"
39 #include "SALOMEconfig.h"
40 #include CORBA_SERVER_HEADER(MED_Gen)
49 class SUIT_ViewWindow;
51 class SVTK_ViewWindow;
54 class Plot2d_ViewFrame;
56 class LightApp_SelectionMgr;
57 class SalomeApp_DoubleSpinBox;
58 class SalomeApp_IntSpinBox;
59 class SalomeApp_Module;
60 class SalomeApp_Study;
65 #include "VISU_Mesh_i.hh"
76 typedef std::vector<SVTK_ViewWindow*> TViewWindows;
78 //----------------------------------------------------------------------------
79 SUIT_Desktop* GetDesktop(const CAM_Module* theModule);
80 SalomeApp_Study* GetAppStudy(const CAM_Module* theModule);
81 _PTR(Study) GetCStudy(const SalomeApp_Study* theStudy);
83 bool IsStudyLocked( _PTR(Study) theStudy );
84 bool CheckLock( _PTR(Study) theStudy,
87 //----------------------------------------------------------------------------
88 int runAndWait( QDialog* dlg, const bool modal );
90 void UpdateObjBrowser(SalomeApp_Module* theModule,
91 bool theIsUpdateDataModel = true,
92 _PTR(SObject) theSObject = _PTR(SObject)());
94 //----------------------------------------------------------------------------
95 VISU_Gen_i* GetVisuGen(const CAM_Module* theModule);
97 SALOME_MED::MED_Gen_var GetMEDEngine();
101 LightApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule);
103 //----------------------------------------------------------------------------
107 _PTR(SObject) mySObject;
113 struct TSelectionItem
115 TObjectInfo myObjectInfo;
116 Handle(SALOME_InteractiveObject) myIO;
119 typedef std::vector<TSelectionItem> TSelectionInfo;
121 TSelectionInfo GetSelectedObjects(const SalomeApp_Module* theModule);
123 TObjectInfo GetObjectByEntry(const SalomeApp_Study* theStudy,
124 const std::string& theEntry);
126 VISU::Prs3d_i* GetPrs3dToModify(const SalomeApp_Module* theModule,
129 VISU::Prs3d_i* GetPrs3dFromBase(Base_i* theBase);
131 bool GetPrs3dSelectionInfo( const SalomeApp_Module* theModule,
132 VISU::Prs3d_i*& thePrs3d,
133 SVTK_ViewWindow*& theViewWindow,
134 VISU_Actor*& thenActor );
136 //----------------------------------------------------------------------------
137 void Add(LightApp_SelectionMgr* theSelectionMgr,
138 const Handle(SALOME_InteractiveObject)& theIO);
139 void Remove(LightApp_SelectionMgr* theSelectionMgr,
140 const Handle(SALOME_InteractiveObject)& theIO);
142 bool IsRemovable (const std::string theEntry,
143 const SalomeApp_Module* theModule);
144 bool IsRemovableSelected(const SalomeApp_Module* theModule);
146 void DeleteSObject(VisuGUI* theModule,
147 _PTR(Study) theStudy,
148 _PTR(SObject) theSObject);
149 void DeletePrs3d(VisuGUI* theModule,
150 VISU::Prs3d_i* thePrs);
152 // Presentation management
153 void ChangeRepresentation (const SalomeApp_Module* theModule,
154 VISU::PresentationType theType);
157 void ChangeQuadratic2DRepresentation (const SalomeApp_Module* theModule,
158 VISU::Quadratic2DPresentationType theType);
162 void SetShading ( const SalomeApp_Module* theModule, bool theOn = true );
165 bool CheckTimeStamp(const SalomeApp_Module* theModule,
166 _PTR(SObject)& theSObject,
167 Handle(SALOME_InteractiveObject)& theIO,
168 ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode);
169 VISU::Result_i* CheckResult(const SalomeApp_Module* theModule,
170 _PTR(SObject) theSource,
171 VISU::Result_var& theResult);
172 bool IsSObjectTable(_PTR(SObject) theSObject);
174 /*! Display mesh presentation in given VTK view window
176 VISU_Actor* PublishMeshInView(const SalomeApp_Module* theModule,
177 VISU::Prs3d_i* thePrs,
178 SVTK_ViewWindow* theViewWindow);
181 * \brief Repaint all SVTK view windows, where the given object is displayed.
182 * \param theModule - is used to access application.
183 * \param theIObject - is supposed to be selected (is highlighted in this method).
185 void RepaintViewWindows(const SalomeApp_Module* theModule,
186 const Handle(SALOME_InteractiveObject)& theIObject);
188 VISU_Actor* FindActor(const SalomeApp_Study* theStudy,
189 SVTK_ViewWindow* theViewWindow,
190 const QString& theEntry);
191 VISU_ActorBase* FindActorBase(const SalomeApp_Study* theStudy,
192 SVTK_ViewWindow* theViewWindow,
193 const QString& theEntry);
194 void RecreateActor(const SalomeApp_Module* theModule,
195 VISU::Prs3d_i* thePrs);
197 bool ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
199 const char* theActorClassName = "VISU_Actor");
202 * \brief Advanced FitAll, sets view projection in accordance with current view contents
204 * If common bounding box of all actors in \a theViewWindow has
205 * at least one small side, then corresponding projection will be set
206 * (Top, Left or Front), else 3D projection will be used.
208 * \param theViewWindow - the view to perform FitAll in.
210 void SetFitAll(SVTK_ViewWindow* theViewWindow);
213 SPlot2d_Viewer* GetPlot2dViewer(const SalomeApp_Module* theModule,
214 const bool theCreate = false);
215 void PlotTable( const SalomeApp_Module* theModule,
216 VISU::Table_i* table,
218 void PlotCurve( const SalomeApp_Module* theModule,
219 VISU::Curve_i* curve,
221 void PlotRemoveCurve(const SalomeApp_Module* theModule,
222 VISU::Curve_i* curve);
223 void PlotContainer( const SalomeApp_Module* theModule,
224 VISU::Container_i* container,
226 void CreatePlot( SalomeApp_Module* theModule,
227 _PTR(SObject) theSobj );
229 /*! Create mesh presentation and display it in \a theViewWindow.
230 * If \a theViewWindow is NULL, no displaying will be done.
232 VISU::Mesh_i* CreateMesh(VisuGUI* theModule,
233 const Handle(SALOME_InteractiveObject)& theIO,
234 SVTK_ViewWindow* theViewWindow);
237 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
238 const Handle(SALOME_InteractiveObject)& theIO,
240 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
241 _PTR(SObject) theObject,
244 int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow);
245 void AddScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
246 VISU::Prs3d_i* thePrs3d, int pos);
247 void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
248 VISU::Prs3d_i* thePrs3d);
250 #define CLIP_PLANES_FOLDER "Clipping Planes"
252 bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject);
254 void initSpinBox( SalomeApp_IntSpinBox*, const int, const int, const int );
255 void initSpinBox( SalomeApp_DoubleSpinBox*, const double&, const double&, const double&, const char* );