OpenDAFF C++ API  v1.7
Directional Audio File Format
DAFFVizPlane.cpp
Go to the documentation of this file.
1 #include <daffviz/DAFFVizPlane.h>
3 
4 #include <vtkActor.h>
5 #include <vtkPlaneSource.h>
6 #include <vtkPolyDataMapper.h>
7 #include <vtkProperty.h>
8 
9 namespace DAFFViz
10 {
11 
12  Plane::Plane( SGNode* pParentNode )
13  : SGNode( pParentNode )
14  , m_pSource( NULL )
15  , m_pMapper( NULL )
16  , m_pActor( NULL )
17  {
18  init();
19  }
20 
21  Plane::Plane( SGNode* pParentNode, double x1, double y1, double z1, double x2, double y2, double z2, double n1, double n2, double n3 )
22  : SGNode( pParentNode )
23  , m_pSource( NULL )
24  , m_pMapper( NULL )
25  , m_pActor( NULL )
26  {
27  init();
28  m_pSource->SetCenter( 1.0, 0.0, 0.0 );
29  m_pSource->SetNormal( 1.0, 0.0, 1.0 );
30  m_pSource->Update();
31  }
32 
34  {
35  RemoveActor( m_pActor );
36  }
37 
38  void Plane::init()
39  {
40  m_pSource = vtkSmartPointer< vtkPlaneSource >::New();
41 
42  m_pMapper = vtkSmartPointer< vtkPolyDataMapper >::New();
43  m_pMapper->SetInputData( m_pSource->GetOutput() );
44 
45  m_pActor = vtkSmartPointer< vtkActor >::New();
46  m_pActor->SetMapper( m_pMapper );
47 
48  AddActor( m_pActor );
49  }
50 
51  // --= object related methods =--
52 
53 
54  // --= general methods =--
55 
56  void Plane::SetColor( double r, double g, double b )
57  {
59  m_pActor->GetProperty()->SetColor( r, g, b );
61  }
62 
63  void Plane::GetColor( double& r, double& g, double& b )
64  {
65  m_pActor->GetProperty()->GetColor( r, g, b );
66  }
67 
68  double Plane::GetAlpha() const
69  {
70  return m_pActor->GetProperty()->GetOpacity();
71  }
72 
73  void Plane::SetAlpha( double a )
74  {
76  m_pActor->GetProperty()->SetOpacity( a );
78  }
79 
80  bool Plane::IsVisible() const
81  {
82  return m_pActor->GetVisibility() > 0 ? true : false;
83  }
84 
85  void Plane::SetVisible( bool bVisible )
86  {
87  SGNode::SetVisible( bVisible );
88 
90  if( bVisible )
91  m_pActor->VisibilityOn();
92  else
93  m_pActor->VisibilityOff();
95  }
96 
97 } // End of namespace "DAFFViz"
void AddActor(vtkSmartPointer< vtkActor > pActor)
Add a VTK actor to the node.
void SetColor(const double r, const double g, const double b)
Color setter.
void RemoveActor(vtkSmartPointer< vtkActor > pActor)
Remove a VTK actor from the assembly of the node.
void SetVisible(bool bVisible)
Visibility setter.
Plane(SGNode *pParentNode=NULL)
#define DAFFVIZ_LOCK_VTK
void SetAlpha(const double a)
Alpha setter.
#define NULL
Definition: DAFFDefs.h:59
void GetColor(double &r, double &g, double &b)
Color getter.
virtual void SetVisible(bool bVisible)
Set visibility.
double GetAlpha() const
Alpha getter.
Base class for scene graph nodes.
Definition: DAFFVizSGNode.h:67
bool IsVisible() const
Visibility getter.
#define DAFFVIZ_UNLOCK_VTK
OpenDAFF is a project from the Institute of Technical Acoustics, RWTH Aachen University, Germany.