1 // Copyright (C) 2007-2014 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"
32 #include "SMESH_TypeDefs.hxx"
33 #include "SMDS_MeshNode.hxx"
35 #include "SMESHGUI_Utils.h"
37 #include <SMESH_Object.h>
39 // SALOME KERNEL includes
40 #include <SALOMEDSClient_definitions.hxx>
42 // SALOME GUI includes
43 #include <SALOME_InteractiveObject.hxx>
44 #include <VTKViewer_Filter.h>
46 class TColStd_IndexedMapOfInteger;
48 class SALOMEDSClient_Study;
50 class SUIT_ViewWindow;
51 class SUIT_ViewManager;
53 class SVTK_ViewWindow;
56 class LightApp_SelectionMgr;
57 class SalomeApp_Module;
71 class Handle(Geom_Line);
72 class Handle(Geom_Plane);
75 //----------------------------------------------------------------------------
76 typedef std::pair<int,std::string> TKeyOfVisualObj;
79 TVisualObjPtr GetVisualObj( int, const char*, bool nulData =false );
81 void OnVisuException(); // PAL16631
83 //----------------------------------------------------------------------------
85 SVTK_ViewWindow* GetViewWindow( const SalomeApp_Module* = 0,
88 SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager*, SUIT_ViewWindow* );
90 SVTK_ViewWindow* GetVtkViewWindow( SUIT_ViewWindow* );
93 SVTK_ViewWindow* GetCurrentVtkView();
95 //----------------------------------------------------------------------------
97 void RepaintCurrentView();
99 void RepaintViewWindow( SVTK_ViewWindow* );
101 void RenderViewWindow( SVTK_ViewWindow* );
105 //----------------------------------------------------------------------------
107 SMESH_Actor* FindActorByEntry( SUIT_ViewWindow*, const char* );
109 SMESH_Actor* FindActorByEntry( const char* );
112 SMESH_Actor* FindActorByObject( CORBA::Object_ptr );
114 //----------------------------------------------------------------------------
116 SMESH_Actor* CreateActor( _PTR(Study), const char*, int = false );
118 void DisplayActor( SUIT_ViewWindow*, SMESH_Actor* );
120 void RemoveActor( SUIT_ViewWindow*, SMESH_Actor* );
122 void RemoveVisuData( int );
124 //----------------------------------------------------------------------------
125 enum EDisplaing { eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll };
128 bool UpdateView( SUIT_ViewWindow*, EDisplaing, const char* = "" );
130 bool UpdateView( EDisplaing, const char* = "" );
136 bool UpdateNulData( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);
139 bool Update( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);
141 //----------------------------------------------------------------------------
143 void SetPointRepresentation( bool );
146 void SetPickable( SMESH_Actor* = 0 );
149 void UpdateSelectionProp( SMESHGUI* );
152 void UpdateFontProp( SMESHGUI* );
154 //----------------------------------------------------------------------------
156 SVTK_Selector* GetSelector( SUIT_ViewWindow* = GetActiveWindow() );
159 void SetFilter( const Handle(VTKViewer_Filter)&, SVTK_Selector* = GetSelector() );
161 Handle(VTKViewer_Filter) GetFilter( int, SVTK_Selector* = GetSelector() );
163 bool IsFilterPresent( int, SVTK_Selector* = GetSelector() );
165 void RemoveFilter( int, SVTK_Selector* = GetSelector() );
168 void RemoveFilters( SVTK_Selector* = GetSelector());
171 bool IsValid( SALOME_Actor*, int, SVTK_Selector* = GetSelector() );
173 //----------------------------------------------------------------------------
175 int GetNameOfSelectedSortedNodes( SMDSAbs_EntityType,
181 int GetNameOfSelectedNodes( SVTK_Selector*,
182 const Handle(SALOME_InteractiveObject)&,
185 int GetNameOfSelectedElements( SVTK_Selector*,
186 const Handle(SALOME_InteractiveObject)&,
189 int GetEdgeNodes( SVTK_Selector*, const TVisualObjPtr&, int&, int& );
191 //----------------------------------------------------------------------------
193 int GetNameOfSelectedNodes( LightApp_SelectionMgr*,
194 const Handle(SALOME_InteractiveObject)&,
197 int GetNameOfSelectedNodes( LightApp_SelectionMgr*, QString& );
199 int GetNameOfSelectedElements( LightApp_SelectionMgr*,
200 const Handle(SALOME_InteractiveObject)&,
203 int GetNameOfSelectedElements( LightApp_SelectionMgr*, QString& );
205 int GetSelected( LightApp_SelectionMgr*, TColStd_IndexedMapOfInteger&,
209 int GetEdgeNodes( LightApp_SelectionMgr*, int&, int& );
212 void SetControlsPrecision( const long );
214 #ifndef DISABLE_PLOT2DVIEWER
216 void ClearPlot2Viewers( SUIT_ViewWindow* theWindow );
219 //----------------------------------------------------------------------------
221 bool ComputeClippingPlaneParameters( std::list<vtkActor*> theActorList,
225 double theOrigin[3] );
227 bool ComputeBounds( std::list<vtkActor*> theActorList,
228 double theBounds[6]);
230 void PositionToDistance( double theBounds[6],
231 double theDirection[3],
234 typedef std::pair<SMESH_TNodeXYZ, double> TNodeOfDist;
235 typedef std::pair<SMESH_TNodeXYZ, std::pair<double, double> > TNodeOfAngleAndDist, TNodeOfDistToPlaneAndDist;
236 typedef std::pair<int, std::pair<double, double> > TIdOfDistToPlaneAndDist;
237 bool CreatePlaneOnThreePoints( const gp_Pnt& thePoint1,
238 const gp_Pnt& thePoint2,
239 const gp_Pnt& thePoint3,
242 void FindNbLowestPoint( std::list<gp_Pnt2d> theList, gp_Pnt2d& theNode );
243 bool IsNotPlaneIntersection( std::vector<SMESH_TNodeXYZ>& theVector,
244 const gp_Pln& thePlane );
245 bool GetCorrectSequenceOfId( std::vector<SMESH_TNodeXYZ>& theVector );
246 void GetCorrectSequenceTwoPlaneOfId( std::vector<SMESH_TNodeXYZ>& thePlane1,
247 std::vector<SMESH_TNodeXYZ>& thePlane2,
248 std::list<int>& theResultListId );
249 void GetSortedNodesOnPolygon( std::vector<SMESH_TNodeXYZ>& theVectorOfNode,
250 std::list<int>& theResultListId );
251 void GetSortedNodesOnPyramid( std::vector<SMESH_TNodeXYZ>& theVectorOfNode,
252 std::list<int>& theResultListId );
253 void GetSortedNodesOnPrism( std::vector<SMESH_TNodeXYZ>& theVectorOfNode,
254 std::list<int>& theResultListId );
255 bool Get2BasePlane( std::vector<SMESH_TNodeXYZ>& theVector,
256 std::vector<SMESH_TNodeXYZ>& thePlane1,
257 std::vector<SMESH_TNodeXYZ>& thePlane2);
258 bool GetNextCombination ( std::vector<int> & theVector1,
259 std::vector<int> & theVector2,
261 static bool CompareNodeOfAngleAndDist ( const TNodeOfAngleAndDist& first,
262 const TNodeOfAngleAndDist& second );
263 static bool CompareNodeOfDist ( const TNodeOfAngleAndDist& first,
264 const TNodeOfAngleAndDist& second );
265 static bool CompareDistOfPlane ( const TNodeOfDistToPlaneAndDist& first,
266 const TNodeOfDistToPlaneAndDist& second );
267 static bool CompareDistOfPlaneById ( const TIdOfDistToPlaneAndDist& first,
268 const TIdOfDistToPlaneAndDist& second );
269 static bool CompareDistForCorrectPlane ( const TNodeOfDist& first,
270 const TNodeOfDist& second );
273 void RemoveVisualObjectWithActors( const char* theEntry, bool fromAllViews = false );
276 #endif // SMESHGUI_VTKUTILS_H