]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/VTK/Image/Observer2D.h
8abbecf0332e06499a606b309a5b4c1c362b20c3
[FrontAlgorithms.git] / lib / fpa / VTK / Image / Observer2D.h
1 #ifndef __FPA__VTK__IMAGE__OBSERVER2D__H__
2 #define __FPA__VTK__IMAGE__OBSERVER2D__H__
3
4 #include <set>
5 #include <itkCommand.h>
6 #include <vtkActor.h>
7 #include <vtkImageActor.h>
8 #include <vtkImageData.h>
9 #include <vtkPolyData.h>
10 #include <vtkSmartPointer.h>
11
12 namespace fpa
13 {
14   namespace VTK
15   {
16     namespace Image
17     {
18       /**
19        */
20       template< class F, class R >
21       class Observer2D
22         : public itk::Command
23       {
24       public:
25         typedef Observer2D                 Self;
26         typedef itk::Command                    Superclass;
27         typedef itk::SmartPointer< Self >       Pointer;
28         typedef itk::SmartPointer< const Self > ConstPointer;
29
30         typedef F                             TFilter;
31         typedef R                             TRenderWindow;
32         typedef typename TFilter::TInputImage TImage;
33         typedef typename TFilter::TVertex     TVertex;
34
35         typedef std::set< TVertex > TVertices;
36
37       public:
38         itkNewMacro( Self );
39         itkTypeMacro( Observer2D, itkCommand );
40
41         itkGetConstMacro( RenderPercentage, double );
42         itkSetMacro( RenderPercentage, double );
43
44       public:
45         void SetRenderWindow( R* rw );
46         void SetPixel(
47           typename TImage::IndexType idx,
48           unsigned char red,
49           unsigned char green,
50           unsigned char blue,
51           unsigned char alpha
52           );
53         void Render( );
54         void Execute( itk::Object* c, const itk::EventObject& e ) ITK_OVERRIDE
55           { this->Execute( ( const itk::Object* )( c ), e ); }
56         void Execute( const itk::Object* c, const itk::EventObject& e ) ITK_OVERRIDE;
57
58       protected:
59         Observer2D( );
60         virtual ~Observer2D( );
61
62       private:
63         Observer2D( const Self& ); // Not impl.
64         void operator=( const Self& );  // Not impl.
65
66       protected:
67         vtkSmartPointer< vtkImageData >  m_Stencil;
68         vtkSmartPointer< vtkImageActor > m_StencilActor;
69
70         R*            m_RenderWindow;
71         unsigned long m_Count;
72         unsigned long m_RenderCount;
73         double        m_RenderPercentage;
74       };
75
76     } // ecapseman
77
78   } // ecapseman
79
80 } // ecapseman
81
82 #ifndef ITK_MANUAL_INSTANTIATION
83 #include <fpa/VTK/Image/Observer2D.hxx>
84 #endif // ITK_MANUAL_INSTANTIATION
85
86 #endif // __FPA__VTK__IMAGE__OBSERVER2D__H__
87
88 // eof - $RCSfile$