Salome HOME
53754a31319517c2674148345d5c42928c8bd193
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
19
20 #ifndef SMESHGUI_VTKUtils_HeaderFile
21 #define SMESHGUI_VTKUtils_HeaderFile
22
23 class QString;
24 class vtkRenderer;
25 class TColStd_IndexedMapOfInteger;
26
27 #include "SALOMEDSClient_definitions.hxx"
28 #include "SALOME_InteractiveObject.hxx"
29 #include "VTKViewer_Filter.h"
30
31 class SALOMEDSClient_Study;
32
33 class SUIT_Study;
34 class SUIT_ViewWindow;
35 class SUIT_ViewManager;
36
37 class SVTK_InteractorStyle;
38 class SVTK_ViewWindow;
39 class SVTK_Selector;
40
41 class LightApp_SelectionMgr;
42 class SMESHGUI;
43
44 #include <CORBA.h>
45
46 #include "SALOMEconfig.h"
47 #include CORBA_CLIENT_HEADER(SALOMEDS)
48
49 #include <boost/shared_ptr.hpp>
50 #include "SMESH_Object.h"
51
52 class SMESH_Actor;
53 class SALOME_Actor;
54 class SVTK_ViewWindow;
55 class SalomeApp_Module;
56
57 namespace SMESH{
58
59   //----------------------------------------------------------------------------
60   typedef pair<int,string> TKeyOfVisualObj;
61   
62   TVisualObjPtr GetVisualObj(int theStudyId, 
63                              const char* theEntry);
64
65   //----------------------------------------------------------------------------
66   SVTK_ViewWindow* GetViewWindow(const SalomeApp_Module* theModule);
67
68   SUIT_ViewWindow* GetActiveWindow();
69
70   SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager*,
71                                       SUIT_ViewWindow* );
72
73   SVTK_ViewWindow* GetVtkViewWindow( SUIT_ViewWindow* );
74
75   SVTK_ViewWindow* GetCurrentVtkView();
76
77   void RepaintViewWindow(SVTK_ViewWindow*);
78   void RenderViewWindow(SVTK_ViewWindow*);
79
80   //----------------------------------------------------------------------------
81   SMESH_Actor* FindActorByEntry (SUIT_ViewWindow*, const char* theEntry);
82   SMESH_Actor* FindActorByEntry (const char* theEntry);
83
84   SMESH_Actor* FindActorByObject (CORBA::Object_ptr theObject);
85
86   //----------------------------------------------------------------------------
87   SMESH_Actor* CreateActor (_PTR(Study), const char*, int = false);
88   void DisplayActor (SUIT_ViewWindow*, SMESH_Actor* theActor);
89   void RemoveActor  (SUIT_ViewWindow*, SMESH_Actor* theActor);
90
91   //----------------------------------------------------------------------------
92   enum EDisplaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll};
93   void UpdateView (SUIT_ViewWindow*, 
94                    EDisplaing theAction, 
95                    const char* theEntry = "");
96   void UpdateView (EDisplaing theAction, 
97                    const char* theEntry = "");
98
99   void UpdateView();
100
101   void Update(const Handle(SALOME_InteractiveObject)& theIO,
102               bool theDisplay);
103
104
105   //----------------------------------------------------------------------------
106   void FitAll();
107
108   void RepaintCurrentView();
109
110   vtkRenderer* GetCurrentRenderer();
111
112
113   //----------------------------------------------------------------------------
114   void SetPointRepresentation(bool theIsVisible);
115
116   void SetPickable(SMESH_Actor* theActor = NULL);
117
118   void UpdateSelectionProp( SMESHGUI* );
119
120
121   //----------------------------------------------------------------------------
122   SVTK_InteractorStyle* 
123     GetInteractorStyle (SUIT_ViewWindow* = GetActiveWindow());
124
125   void SetFilter (const Handle(VTKViewer_Filter)& theFilter,
126                   SVTK_InteractorStyle* theStyle = GetInteractorStyle());
127
128   Handle(VTKViewer_Filter) 
129     GetFilter (int theId, SVTK_InteractorStyle* theStyle = GetInteractorStyle());
130
131   bool IsFilterPresent (int theId, 
132                         SVTK_InteractorStyle* theStyle = GetInteractorStyle());
133
134   void RemoveFilter (int theId, 
135                      SVTK_InteractorStyle* theStyle = GetInteractorStyle());
136
137   void RemoveFilters (SVTK_InteractorStyle* theStyle = GetInteractorStyle());
138
139   bool IsValid (SALOME_Actor* theActor, int theCellId,
140                 SVTK_InteractorStyle* theStyle = GetInteractorStyle());
141
142   //----------------------------------------------------------------------------
143   int GetNameOfSelectedNodes(SVTK_Selector* theSelector, 
144                              const Handle(SALOME_InteractiveObject)& theIO, 
145                              QString& theName);
146   
147   int GetNameOfSelectedElements(SVTK_Selector* theSelector, 
148                                 const Handle(SALOME_InteractiveObject)& theIO, 
149                                 QString& theName);
150   
151   int GetEdgeNodes(SVTK_Selector* theSelector, 
152                    const TVisualObjPtr& theVisualObj,
153                    int& theId1, 
154                    int& theId2);
155
156   //----------------------------------------------------------------------------
157   int GetNameOfSelectedNodes (LightApp_SelectionMgr*, 
158                               const Handle(SALOME_InteractiveObject)& theIO, 
159                               QString& theName);
160
161   int GetNameOfSelectedNodes (LightApp_SelectionMgr*, 
162                               QString& aName);
163
164   int GetNameOfSelectedElements (LightApp_SelectionMgr*, 
165                                  const Handle(SALOME_InteractiveObject)& theIO, 
166                                  QString& theName);
167
168   int GetNameOfSelectedElements (LightApp_SelectionMgr*, 
169                                  QString& aName);
170
171   int GetSelected (LightApp_SelectionMgr*, 
172                    TColStd_IndexedMapOfInteger& theMap, 
173                    const bool theIsElement = true );
174
175   int GetEdgeNodes (LightApp_SelectionMgr*, int& theId1, int& theId2);
176
177   void SetControlsPrecision (const long theVal);
178 };
179
180 #endif