Salome HOME
Merge branch 'master' of ssh://git.salome-platform.org/modules/hydro
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Actor.cxx
1 // Copyright (C) 2007-2015  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 #include <HYDROGUI_Actor.h>
24 #include <GEOM_PainterPolyDataMapper.h>
25 #include <GEOM_DeviceActor.h>
26 #include <GEOM_VertexSource.h>
27 #include <GEOM_EdgeSource.h>
28 #include <GEOM_WireframeFace.h>
29 #include <GEOM_ShadingFace.h>
30 #include <VTKViewer_TransformFilter.h>
31 #include <vtkAppendPolyData.h>
32 #include <VTKViewer_Transform.h>
33
34 HYDROGUI_Actor::HYDROGUI_Actor()
35
36   myVertexActor->GetDeviceActor()->SetMapper( myVertexActor->GetDeviceActor()->GetMapper() );
37   myIsolatedEdgeActor->GetDeviceActor()->SetMapper( myIsolatedEdgeActor->GetDeviceActor()->GetMapper() );
38   myOneFaceEdgeActor->GetDeviceActor()->SetMapper( myOneFaceEdgeActor->GetDeviceActor()->GetMapper() );
39   mySharedEdgeActor->GetDeviceActor()->SetMapper( mySharedEdgeActor->GetDeviceActor()->GetMapper() );
40   myWireframeFaceActor->GetDeviceActor()->SetMapper( myWireframeFaceActor->GetDeviceActor()->GetMapper() );
41   myShadingFaceActor->SetInput(myShadingFaceSource->GetOutputPort(),false); 
42   myShadingFaceActor->GetDeviceActor()->SetMapper( myShadingFaceActor->GetDeviceActor()->GetMapper() );
43   GEOM_Actor::myHighlightActor->GetDeviceActor()->SetMapper( GEOM_Actor::myHighlightActor->GetDeviceActor()->GetMapper() );
44
45  
46  
47 HYDROGUI_Actor::~HYDROGUI_Actor() 
48
49
50
51 HYDROGUI_Actor* HYDROGUI_Actor::New()
52 {
53   HYDROGUI_Actor* anObject = new HYDROGUI_Actor(); 
54   anObject->SetMapper( anObject->myPolyDataMapper.Get()); 
55   return anObject; 
56 }
57
58 void HYDROGUI_Actor::SetMapper( vtkMapper* theMapper )
59 {
60   SALOME_Actor::SetMapper( theMapper );
61 }
62
63 void HYDROGUI_Actor::SetTransform( VTKViewer_Transform* theTransform )
64 {
65   Superclass::SetTransform(theTransform);
66   myVertexActor       ->GetDeviceActor()->SetTransform( theTransform );
67   myIsolatedEdgeActor ->GetDeviceActor()->SetTransform( theTransform );
68   myOneFaceEdgeActor  ->GetDeviceActor()->SetTransform( theTransform );
69   mySharedEdgeActor   ->GetDeviceActor()->SetTransform( theTransform );
70   myWireframeFaceActor->GetDeviceActor()->SetTransform( theTransform );
71   myShadingFaceActor  ->GetDeviceActor()->SetTransform( theTransform );
72   GEOM_Actor::myHighlightActor->GetDeviceActor()->SetTransform( theTransform );
73 }
74
75 void HYDROGUI_Actor::SetShape( const TopoDS_Shape& theShape,
76                                float theDeflection,
77                                bool theIsVector )
78 {
79   GEOM_Actor::SetShape( theShape, theDeflection, theIsVector ); 
80
81   if( myIsolatedEdgeSource->IsEmpty() )
82     myIsolatedEdgeActor->GetDeviceActor()->SetInfinitive( true );
83
84   if( myOneFaceEdgeSource->IsEmpty() )
85     myOneFaceEdgeActor->GetDeviceActor()->SetInfinitive( true );
86
87   if( mySharedEdgeSource->IsEmpty() )
88     mySharedEdgeActor->GetDeviceActor()->SetInfinitive( true );
89
90   if( myWireframeFaceSource->IsEmpty() )
91     myWireframeFaceActor->GetDeviceActor()->SetInfinitive( true );
92
93   if( myShadingFaceSource->IsEmpty() )
94   {
95     myShadingFaceActor->GetDeviceActor()->SetInfinitive( true );
96   }
97   else
98   {
99     myShadingFaceSource->Update();
100   }
101 }