1 // Copyright (C) 2007-2020 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, or (at your option) any later version.
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 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_VTKUtils.h
25 // Author : Open CASCADE S.A.S.
27 #ifndef SMESHGUI_VTKUTILS_H
28 #define SMESHGUI_VTKUTILS_H
31 #include "SMESH_SMESHGUI.hxx"
33 #include "SMESHGUI_Utils.h"
34 #include <SMESH_Object.h>
36 // SALOME KERNEL includes
37 #include <SALOMEDSClient_definitions.hxx>
39 // SALOME GUI includes
40 #include <SALOME_InteractiveObject.hxx>
41 #include <VTKViewer_Filter.h>
44 #include <TColStd_IndexedMapOfInteger.hxx>
46 class SALOMEDSClient_Study;
48 class SUIT_ViewWindow;
49 class SUIT_ViewManager;
51 class SVTK_ViewWindow;
54 class LightApp_SelectionMgr;
55 class SalomeApp_Module;
65 //----------------------------------------------------------------------------
68 TVisualObjPtr GetVisualObj( const char*, bool nulData =false );
70 void OnVisuException(); // PAL16631
72 //----------------------------------------------------------------------------
74 SVTK_ViewWindow* GetViewWindow( const SalomeApp_Module* = 0,
77 SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager*, SUIT_ViewWindow* );
79 SVTK_ViewWindow* GetVtkViewWindow( SUIT_ViewWindow* );
82 SVTK_ViewWindow* GetCurrentVtkView();
84 //----------------------------------------------------------------------------
86 void RepaintCurrentView();
88 void RepaintViewWindow( SVTK_ViewWindow* );
90 void RenderViewWindow( SVTK_ViewWindow* );
94 //----------------------------------------------------------------------------
96 SMESH_Actor* FindActorByEntry( SUIT_ViewWindow*, const char* );
98 SMESH_Actor* FindActorByEntry( const char* );
101 SMESH_Actor* FindActorByObject( CORBA::Object_ptr );
103 //----------------------------------------------------------------------------
105 SMESH_Actor* CreateActor( const char*, int = false );
107 void DisplayActor( SUIT_ViewWindow*, SMESH_Actor* );
109 void RemoveActor( SUIT_ViewWindow*, SMESH_Actor* );
111 void RemoveVisuData();
113 //----------------------------------------------------------------------------
114 enum EDisplaing { eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll };
117 bool UpdateView( SUIT_ViewWindow*, EDisplaing, const char* = "" );
119 bool UpdateView( EDisplaing, const char* = "" );
122 void UpdateView( bool withChildrenOfSelected = false );
125 bool UpdateNulData( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);
128 bool Update( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);
130 //----------------------------------------------------------------------------
132 void SetPointRepresentation( bool );
135 void SetPickable( SMESH_Actor* = 0 );
138 void UpdateSelectionProp( SMESHGUI* );
141 void UpdateFontProp( SMESHGUI* );
143 //----------------------------------------------------------------------------
145 SVTK_Selector* GetSelector( SUIT_ViewWindow* = GetActiveWindow() );
148 void SetFilter( const Handle(VTKViewer_Filter)&, SVTK_Selector* = GetSelector() );
150 Handle(VTKViewer_Filter) GetFilter( int, SVTK_Selector* = GetSelector() );
152 bool IsFilterPresent( int, SVTK_Selector* = GetSelector() );
154 void RemoveFilter( int, SVTK_Selector* = GetSelector() );
157 void RemoveFilters( SVTK_Selector* = GetSelector());
160 bool IsValid( SALOME_Actor*, int, SVTK_Selector* = GetSelector() );
162 //----------------------------------------------------------------------------
164 int GetNameOfSelectedNodes( SVTK_Selector*,
165 const Handle(SALOME_InteractiveObject)&,
168 int GetNameOfSelectedElements( SVTK_Selector*,
169 const Handle(SALOME_InteractiveObject)&,
172 int GetEdgeNodes( SVTK_Selector*, const TVisualObjPtr&, int&, int& );
174 //----------------------------------------------------------------------------
176 int GetNameOfSelectedNodes( LightApp_SelectionMgr*,
177 const Handle(SALOME_InteractiveObject)&,
180 int GetNameOfSelectedNodes( LightApp_SelectionMgr*, QString& );
182 int GetNameOfSelectedElements( LightApp_SelectionMgr*,
183 const Handle(SALOME_InteractiveObject)&,
186 int GetNameOfSelectedElements( LightApp_SelectionMgr*, QString& );
188 int GetSelected( LightApp_SelectionMgr*, TColStd_IndexedMapOfInteger&,
192 int GetEdgeNodes( LightApp_SelectionMgr*, int&, int& );
195 void SetControlsPrecision( const long );
197 #ifndef DISABLE_PLOT2DVIEWER
199 void ClearPlot2Viewers( SUIT_ViewWindow* theWindow );
202 //----------------------------------------------------------------------------
204 bool ComputeClippingPlaneParameters( std::list<vtkActor*> theActorList,
208 double theOrigin[3] );
210 bool ComputeBounds( std::list<vtkActor*> theActorList,
211 double theBounds[6]);
213 void PositionToDistance( double theBounds[6],
214 double theDirection[3],
218 void RemoveVisualObjectWithActors( const char* theEntry, bool fromAllViews = false );
221 void UpdateActorsAfterUpdateStudy( SUIT_ViewWindow* wnd );
224 void UpdateActorsAfterUpdateStudy();
227 bool NoSmeshActors(SUIT_ViewWindow *theWnd=nullptr);
231 #endif // SMESHGUI_VTKUTILS_H