Salome HOME
Merge branch 'master' into pre/penta18
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_VTKUtils.h
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_VTKUtils.h
25 // Author : Open CASCADE S.A.S.
26 //
27 #ifndef SMESHGUI_VTKUTILS_H
28 #define SMESHGUI_VTKUTILS_H
29
30 // SMESH includes
31 #include "SMESH_SMESHGUI.hxx"
32
33 #include "SMESHGUI_Utils.h"
34 #include <SMESH_Object.h>
35
36 // SALOME KERNEL includes
37 #include <SALOMEDSClient_definitions.hxx>
38
39 // SALOME GUI includes
40 #include <SALOME_InteractiveObject.hxx>
41 #include <VTKViewer_Filter.h>
42
43 // OCCT includes
44 #include <TColStd_IndexedMapOfInteger.hxx>
45
46 class SALOMEDSClient_Study;
47
48 class SUIT_ViewWindow;
49 class SUIT_ViewManager;
50
51 class SVTK_ViewWindow;
52 class SVTK_Selector;
53
54 class LightApp_SelectionMgr;
55 class SalomeApp_Module;
56
57 class SMESHGUI;
58 class SMESH_Actor;
59 class SALOME_Actor;
60
61 class vtkActor;
62
63 namespace SMESH
64 {
65   //----------------------------------------------------------------------------
66   typedef std::pair<int,std::string> TKeyOfVisualObj;
67   
68 SMESHGUI_EXPORT
69   TVisualObjPtr GetVisualObj( int, const char*, bool nulData =false );
70 SMESHGUI_EXPORT
71   void OnVisuException(); // PAL16631
72
73   //----------------------------------------------------------------------------
74 SMESHGUI_EXPORT
75   SVTK_ViewWindow* GetViewWindow( const SalomeApp_Module* = 0,
76                                   bool = false );
77 SMESHGUI_EXPORT
78   SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager*, SUIT_ViewWindow* );
79 SMESHGUI_EXPORT
80   SVTK_ViewWindow* GetVtkViewWindow( SUIT_ViewWindow* );
81
82 SMESHGUI_EXPORT
83   SVTK_ViewWindow* GetCurrentVtkView();
84
85   //----------------------------------------------------------------------------
86 SMESHGUI_EXPORT
87   void RepaintCurrentView();
88 SMESHGUI_EXPORT
89   void RepaintViewWindow( SVTK_ViewWindow* );
90 SMESHGUI_EXPORT
91   void RenderViewWindow( SVTK_ViewWindow* );
92 SMESHGUI_EXPORT
93   void FitAll();
94
95   //----------------------------------------------------------------------------
96 SMESHGUI_EXPORT
97   SMESH_Actor* FindActorByEntry( SUIT_ViewWindow*, const char* );
98 SMESHGUI_EXPORT
99   SMESH_Actor* FindActorByEntry( const char* );
100
101 SMESHGUI_EXPORT
102   SMESH_Actor* FindActorByObject( CORBA::Object_ptr );
103
104   //----------------------------------------------------------------------------
105 SMESHGUI_EXPORT  
106   SMESH_Actor* CreateActor( _PTR(Study), const char*, int = false );
107 SMESHGUI_EXPORT
108   void DisplayActor( SUIT_ViewWindow*, SMESH_Actor* );
109 SMESHGUI_EXPORT
110   void RemoveActor( SUIT_ViewWindow*, SMESH_Actor* );
111 SMESHGUI_EXPORT
112   void RemoveVisuData( int );
113
114   //----------------------------------------------------------------------------
115   enum EDisplaing { eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll };
116
117 SMESHGUI_EXPORT
118   bool UpdateView( SUIT_ViewWindow*, EDisplaing, const char* = "" );
119 SMESHGUI_EXPORT            
120   bool UpdateView( EDisplaing, const char* = "" );
121
122 SMESHGUI_EXPORT
123   void UpdateView();
124
125 SMESHGUI_EXPORT
126   bool UpdateNulData( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);
127
128 SMESHGUI_EXPORT
129   bool Update( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);
130
131   //----------------------------------------------------------------------------
132 SMESHGUI_EXPORT  
133   void SetPointRepresentation( bool );
134
135 SMESHGUI_EXPORT
136   void SetPickable( SMESH_Actor* = 0 );
137
138 SMESHGUI_EXPORT
139   void UpdateSelectionProp( SMESHGUI* );
140
141 SMESHGUI_EXPORT
142   void UpdateFontProp( SMESHGUI* );
143
144   //----------------------------------------------------------------------------
145 SMESHGUI_EXPORT
146   SVTK_Selector* GetSelector( SUIT_ViewWindow* = GetActiveWindow() );
147
148 SMESHGUI_EXPORT
149   void SetFilter( const Handle(VTKViewer_Filter)&, SVTK_Selector* = GetSelector() );
150 SMESHGUI_EXPORT
151   Handle(VTKViewer_Filter) GetFilter( int, SVTK_Selector* = GetSelector() );
152 SMESHGUI_EXPORT
153   bool IsFilterPresent( int, SVTK_Selector* = GetSelector() );
154 SMESHGUI_EXPORT
155   void RemoveFilter( int, SVTK_Selector* = GetSelector() );
156
157 SMESHGUI_EXPORT
158   void RemoveFilters( SVTK_Selector* = GetSelector());
159
160 SMESHGUI_EXPORT
161   bool IsValid( SALOME_Actor*, int, SVTK_Selector* = GetSelector() );
162
163   //----------------------------------------------------------------------------
164 SMESHGUI_EXPORT  
165   int GetNameOfSelectedNodes( SVTK_Selector*,
166                               const Handle(SALOME_InteractiveObject)&,
167                               QString& );
168 SMESHGUI_EXPORT
169   int GetNameOfSelectedElements( SVTK_Selector*,
170                                  const Handle(SALOME_InteractiveObject)&,
171                                  QString& );
172 SMESHGUI_EXPORT
173   int GetEdgeNodes( SVTK_Selector*, const TVisualObjPtr&, int&, int& );
174
175   //----------------------------------------------------------------------------
176 SMESHGUI_EXPORT  
177   int GetNameOfSelectedNodes( LightApp_SelectionMgr*,
178                               const Handle(SALOME_InteractiveObject)&,
179                               QString& );
180 SMESHGUI_EXPORT
181   int GetNameOfSelectedNodes( LightApp_SelectionMgr*, QString& );
182 SMESHGUI_EXPORT
183   int GetNameOfSelectedElements( LightApp_SelectionMgr*,
184                                  const Handle(SALOME_InteractiveObject)&,
185                                  QString& );
186 SMESHGUI_EXPORT
187   int GetNameOfSelectedElements( LightApp_SelectionMgr*, QString& );
188 SMESHGUI_EXPORT
189   int GetSelected( LightApp_SelectionMgr*, TColStd_IndexedMapOfInteger&, 
190                    const bool = true );
191
192 SMESHGUI_EXPORT
193   int GetEdgeNodes( LightApp_SelectionMgr*, int&, int& );
194
195 SMESHGUI_EXPORT
196   void SetControlsPrecision( const long );
197
198 #ifndef DISABLE_PLOT2DVIEWER
199 SMESHGUI_EXPORT
200   void ClearPlot2Viewers( SUIT_ViewWindow* theWindow );
201 #endif
202
203   //----------------------------------------------------------------------------
204 SMESHGUI_EXPORT
205   bool ComputeClippingPlaneParameters( std::list<vtkActor*> theActorList,
206                                        double theNormal[3],
207                                        double theDist,
208                                        double theBounds[6],
209                                        double theOrigin[3] );
210
211   bool ComputeBounds( std::list<vtkActor*> theActorList,
212                       double theBounds[6]);
213
214   void PositionToDistance( double theBounds[6],
215                            double theDirection[3],
216                            double thePos[3],
217                            double& theDist );
218  SMESHGUI_EXPORT
219    void RemoveVisualObjectWithActors( const char* theEntry, bool fromAllViews = false );
220 };
221
222 #endif // SMESHGUI_VTKUTILS_H