Salome HOME
dc1ed57a9b054f51d43e410579c39edc5812f9c2
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_VTKUtils.h
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 //
4 //  This library is free software; you can redistribute it and/or
5 //  modify it under the terms of the GNU Lesser General Public
6 //  License as published by the Free Software Foundation; either
7 //  version 2.1 of the License.
8 //
9 //  This library is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 //  Lesser General Public License for more details.
13 //
14 //  You should have received a copy of the GNU Lesser General Public
15 //  License along with this library; if not, write to the Free Software
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
20 #ifndef SMESHGUI_VTKUtils_HeaderFile
21 #define SMESHGUI_VTKUtils_HeaderFile
22
23 #include "SMESH_SMESHGUI.hxx"
24
25 #include "SALOMEDSClient_definitions.hxx"
26 #include "SALOME_InteractiveObject.hxx"
27 #include "VTKViewer_Filter.h"
28
29 #include "SMESH_Object.h"
30 #include "SMESHGUI_Utils.h"
31
32 #include <CORBA.h>
33
34 #include "SALOMEconfig.h"
35 #include CORBA_CLIENT_HEADER(SALOMEDS)
36
37 #include <boost/shared_ptr.hpp>
38
39 class QString;
40
41 class TColStd_IndexedMapOfInteger;
42
43 class SALOMEDSClient_Study;
44
45 class SUIT_Study;
46 class SUIT_ViewWindow;
47 class SUIT_ViewManager;
48
49 class SVTK_ViewWindow;
50 class SVTK_Selector;
51
52 class LightApp_SelectionMgr;
53 class SalomeApp_Module;
54
55 class SMESHGUI;
56 class SMESH_Actor;
57 class SALOME_Actor;
58
59 namespace SMESH {
60
61   //----------------------------------------------------------------------------
62   typedef pair<int,string> TKeyOfVisualObj;
63   
64 SMESHGUI_EXPORT
65   TVisualObjPtr GetVisualObj(int theStudyId, 
66                              const char* theEntry);
67 SMESHGUI_EXPORT
68   void OnVisuException(); // PAL16631
69
70   //----------------------------------------------------------------------------
71 SMESHGUI_EXPORT
72   SVTK_ViewWindow* GetViewWindow(const SalomeApp_Module* theModule = NULL,
73                                  bool createIfNotFound = false);
74 SMESHGUI_EXPORT
75   SVTK_ViewWindow* FindVtkViewWindow(SUIT_ViewManager*, SUIT_ViewWindow*);
76 SMESHGUI_EXPORT
77   SVTK_ViewWindow* GetVtkViewWindow(SUIT_ViewWindow*);
78
79 SMESHGUI_EXPORT
80   SVTK_ViewWindow* GetCurrentVtkView();
81
82   //----------------------------------------------------------------------------
83 SMESHGUI_EXPORT
84   void RepaintCurrentView();
85 SMESHGUI_EXPORT
86   void RepaintViewWindow(SVTK_ViewWindow*);
87 SMESHGUI_EXPORT
88   void RenderViewWindow(SVTK_ViewWindow*);
89 SMESHGUI_EXPORT
90   void FitAll();
91
92   //----------------------------------------------------------------------------
93 SMESHGUI_EXPORT
94   SMESH_Actor* FindActorByEntry (SUIT_ViewWindow*, const char* theEntry);
95 SMESHGUI_EXPORT
96   SMESH_Actor* FindActorByEntry (const char* theEntry);
97
98 SMESHGUI_EXPORT
99   SMESH_Actor* FindActorByObject (CORBA::Object_ptr theObject);
100
101   //----------------------------------------------------------------------------
102 SMESHGUI_EXPORT  
103   SMESH_Actor* CreateActor (_PTR(Study), const char*, int = false);
104 SMESHGUI_EXPORT
105   void DisplayActor (SUIT_ViewWindow*, SMESH_Actor* theActor);
106 SMESHGUI_EXPORT
107   void RemoveActor  (SUIT_ViewWindow*, SMESH_Actor* theActor);
108 SMESHGUI_EXPORT
109   void RemoveVisuData(int studyID);
110
111   //----------------------------------------------------------------------------
112   enum EDisplaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll};
113 SMESHGUI_EXPORT
114   bool UpdateView (SUIT_ViewWindow*,
115                    EDisplaing theAction,
116                    const char* theEntry = "" );
117 SMESHGUI_EXPORT            
118   bool UpdateView (EDisplaing theAction,
119                    const char* theEntry = "");
120
121 SMESHGUI_EXPORT
122   void UpdateView();
123
124 SMESHGUI_EXPORT
125   bool Update(const Handle(SALOME_InteractiveObject)& theIO,
126               bool theDisplay);
127
128
129   //----------------------------------------------------------------------------
130 SMESHGUI_EXPORT  
131   void SetPointRepresentation(bool theIsVisible);
132
133 SMESHGUI_EXPORT
134   void SetPickable(SMESH_Actor* theActor = NULL);
135
136 SMESHGUI_EXPORT
137   void UpdateSelectionProp( SMESHGUI* );
138
139
140   //----------------------------------------------------------------------------
141 SMESHGUI_EXPORT
142   SVTK_Selector* GetSelector (SUIT_ViewWindow* = GetActiveWindow());
143
144 SMESHGUI_EXPORT
145   void SetFilter (const Handle(VTKViewer_Filter)& theFilter,
146                   SVTK_Selector* theSelector = GetSelector());
147 SMESHGUI_EXPORT
148   Handle(VTKViewer_Filter) GetFilter (int theId, SVTK_Selector* theSelector = GetSelector());
149 SMESHGUI_EXPORT
150   bool IsFilterPresent (int theId, SVTK_Selector* theSelector = GetSelector());
151 SMESHGUI_EXPORT
152   void RemoveFilter (int theId, SVTK_Selector* theSelector = GetSelector());
153
154 SMESHGUI_EXPORT
155   void RemoveFilters (SVTK_Selector* theSelector = GetSelector());
156
157 SMESHGUI_EXPORT
158   bool IsValid (SALOME_Actor* theActor, int theCellId,
159                 SVTK_Selector* theSelector = GetSelector());
160
161   //----------------------------------------------------------------------------
162 SMESHGUI_EXPORT  
163   int GetNameOfSelectedNodes(SVTK_Selector* theSelector,
164                              const Handle(SALOME_InteractiveObject)& theIO,
165                              QString& theName);
166 SMESHGUI_EXPORT
167   int GetNameOfSelectedElements(SVTK_Selector* theSelector,
168                                 const Handle(SALOME_InteractiveObject)& theIO,
169                                 QString& theName);
170 SMESHGUI_EXPORT
171   int GetEdgeNodes(SVTK_Selector* theSelector,
172                    const TVisualObjPtr& theVisualObj,
173                    int& theId1,
174                    int& theId2);
175
176   //----------------------------------------------------------------------------
177 SMESHGUI_EXPORT  
178   int GetNameOfSelectedNodes (LightApp_SelectionMgr*,
179                               const Handle(SALOME_InteractiveObject)& theIO,
180                               QString& theName);
181 SMESHGUI_EXPORT
182   int GetNameOfSelectedNodes (LightApp_SelectionMgr*,
183                               QString& aName);
184 SMESHGUI_EXPORT
185   int GetNameOfSelectedElements (LightApp_SelectionMgr*,
186                                  const Handle(SALOME_InteractiveObject)& theIO,
187                                  QString& theName);
188 SMESHGUI_EXPORT
189   int GetNameOfSelectedElements (LightApp_SelectionMgr*,
190                                  QString& aName);
191 SMESHGUI_EXPORT
192   int GetSelected (LightApp_SelectionMgr*,
193                    TColStd_IndexedMapOfInteger& theMap,
194                    const bool theIsElement = true );
195
196 SMESHGUI_EXPORT
197   int GetEdgeNodes (LightApp_SelectionMgr*, int& theId1, int& theId2);
198
199 SMESHGUI_EXPORT
200   void SetControlsPrecision (const long theVal);
201 };
202
203 #endif