1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2005 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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"
35 #include "SalomeApp_Module.h"
36 #include "SalomeApp_Application.h"
38 #include "SALOMEDSClient_Study.hxx"
40 #include "SALOMEconfig.h"
41 #include CORBA_SERVER_HEADER(MED_Gen)
44 class SUIT_ViewWindow;
46 class SVTK_ViewWindow;
49 class Plot2d_ViewFrame;
51 class LightApp_SelectionMgr;
52 class SalomeApp_Study;
62 typedef std::vector<SVTK_ViewWindow*> TViewWindows;
64 SUIT_Desktop* GetDesktop(const CAM_Module* theModule);
65 SalomeApp_Study* GetAppStudy(const CAM_Module* theModule);
66 _PTR(Study) GetCStudy(const SalomeApp_Study* theStudy);
68 bool IsStudyLocked( _PTR(Study) theStudy );
69 bool CheckLock( _PTR(Study) theStudy );
71 inline void UpdateObjBrowser(SalomeApp_Module* theModule,
72 bool updateDataModel = true);
74 VISU_Gen_i* GetVisuGen(const CAM_Module* theModule);
75 SALOME_MED::MED_Gen_var GetMEDEngine();
77 VISU::Storable::TRestoringMap getMapOfValue(_PTR(SObject) theSObject);
78 QString getValue(_PTR(SObject) theSObject, QString theKey);
81 LightApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule);
82 CORBA::Object_var GetSelectedObj(const SalomeApp_Study* theStudy,
83 const QString& theEntry,
84 VISU::Storable::TRestoringMap* theMap = NULL);
85 CORBA::Object_var GetSelectedObj(const SalomeApp_Module* theModule,
86 Handle(SALOME_InteractiveObject)* theIO = NULL,
87 VISU::Storable::TRestoringMap* theMap = NULL);
88 VISU::Prs3d_i* GetPrsToModify(const SalomeApp_Module* theModule,
89 Handle(SALOME_InteractiveObject)* theIO = NULL,
90 VISU::Storable::TRestoringMap* theMap = NULL);
92 void Add(LightApp_SelectionMgr* theSelectionMgr,
93 const Handle(SALOME_InteractiveObject)& theIO);
94 void Remove(LightApp_SelectionMgr* theSelectionMgr,
95 const Handle(SALOME_InteractiveObject)& theIO);
97 bool IsRemovableSelected(const SalomeApp_Module* theModule);
100 void ErasePrs(const SalomeApp_Module* theModule,
101 CORBA::Object_ptr theObject,
102 bool theUpdate = true);
103 void DeleteSObject(SalomeApp_Module* theModule,
104 _PTR(Study) theStudy,
105 _PTR(SObject) theSObject);
106 void DeletePrs3d(SalomeApp_Module* theModule,
107 VISU::Prs3d_i* thePrs,
108 const Handle(SALOME_InteractiveObject)& theIO);
109 void ErasePrs3d(const SalomeApp_Module* theModule,
110 VISU::Prs3d_i* thePrs);
112 // Presentation management
113 void ChangeRepresentation (const SalomeApp_Module* theModule,
114 VISU::PresentationType theType);
116 void SetShading ( const SalomeApp_Module* theModule, bool theOn = true );
119 bool CheckTimeStamp(const SalomeApp_Module* theModule,
120 _PTR(SObject)& theSObject,
121 Handle(SALOME_InteractiveObject)* theIO = NULL);
122 VISU::Result_i* CheckResult(const SalomeApp_Module* theModule,
123 _PTR(SObject) theSource,
124 VISU::Result_var& theResult);
125 inline bool IsSObjectTable(_PTR(SObject) theSObject);
128 SUIT_ViewWindow* GetActiveView(const SalomeApp_Module* theModule,
129 QString theType = QString::null);
132 TViewWindows GetViews(const SalomeApp_Module* theModule);
133 SVTK_ViewWindow* GetViewWindow(const SalomeApp_Module* theModule,
134 const bool theCreate = false );
135 SVTK_ViewWindow* GetViewWindow();
137 VISU_Actor* PublishInView(const SalomeApp_Module* theModule,
138 VISU::Prs3d_i* thePrs);
139 VISU_Actor* UpdateViewer(const SalomeApp_Module* theModule,
140 VISU::Prs3d_i* thePrs,
141 bool theDispOnly = false);
144 * \brief Repaint all SVTK view windows, where the given object is displayed.
145 * \param theModule - is used to access application.
146 * \param theIObject - is supposed to be selected (is highlighted in this method).
148 void RepaintViewWindows(const SalomeApp_Module* theModule,
149 const Handle(SALOME_InteractiveObject)& theIObject);
151 VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow,
152 const char* theEntry);
153 VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow,
154 VISU::Prs3d_i* thePrs);
155 void RecreateActor(const SalomeApp_Module* theModule,
156 VISU::Prs3d_i* thePrs);
159 * \brief Advanced FitAll, sets view projection in accordance with current view contents
161 * If common bounding box of all actors in \a theViewWindow has
162 * at least one small side, then corresponding projection will be set
163 * (Top, Left or Front), else 3D projection will be used.
165 * \param theViewWindow - the view to perform FitAll in.
167 void SetFitAll(SVTK_ViewWindow* theViewWindow);
170 SPlot2d_Viewer* GetPlot2dViewer(const SalomeApp_Module* theModule,
171 const bool theCreate = false);
172 void PlotTable( const SalomeApp_Module* theModule,
173 VISU::Table_i* table,
175 void PlotCurve( const SalomeApp_Module* theModule,
176 VISU::Curve_i* curve,
178 void PlotContainer( const SalomeApp_Module* theModule,
179 VISU::Container_i* container,
181 void CreatePlot( SalomeApp_Module* theModule,
182 _PTR(SObject) theSobj );
184 void UpdateCurve( VISU::Curve_i*,
185 Plot2d_ViewFrame* frame,
188 //parameter frame may be 0, in this case there is only update without display/erase
191 void CreateMesh (const SalomeApp_Module* theModule,
192 const Handle(SALOME_InteractiveObject)& theIO);
194 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
195 const Handle(SALOME_InteractiveObject)& theIO);
196 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
197 _PTR(SObject) theObject);
199 int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule);
200 void AddScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d, int pos);
201 void RemoveScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d);
202 void RemoveScalarBarPosition(VisuGUI* theModule,SVTK_ViewWindow* vw,VISU::Prs3d_i* thePrs3d);
203 void RemoveScalarBarPosition(VisuGUI* theModule,CORBA::Object_ptr theObject);
206 bool VISU::IsSObjectTable( _PTR(SObject) theSObject )
209 _PTR(GenericAttribute) anAttr;
210 if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
212 if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
218 void VISU::UpdateObjBrowser(SalomeApp_Module* theModule,
219 bool updateDataModel)
221 theModule->updateObjBrowser(updateDataModel);
222 theModule->getApp()->updateActions();