IGSTK
igstkAnnotation2D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkAnnotation2D.h,v $
5  Language: C++
6  Date: $Date: 2008-02-11 01:41:50 $
7  Version: $Revision: 1.6 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __igstkAnnotation2D_h
19 #define __igstkAnnotation2D_h
20 
21 #ifdef _MSC_VER
22 #pragma warning ( disable : 4786 )
23 // Disabling warning C4355: 'this' : used in base member initializer list
24 #pragma warning ( disable : 4355 )
25 #endif
26 
27 #include <string>
28 #include "vtkTextActor.h"
29 #include "vtkTextMapper.h"
30 #include "vtkTextProperty.h"
31 #include "igstkObject.h"
32 #include "igstkStateMachine.h"
33 #include "vtkViewport.h"
34 
35 
36 namespace igstk
37 {
38 
39 class View;
40 
54  : public Object
55 {
56 
57 public:
58 
59 
60  /* Macro with standard traits declarations. */
62 
63  /* Add annotation text */
64  void RequestSetAnnotationText( int , const std::string & );
65 
67  void RequestSetFontColor( int index, double red,
68  double green, double blue );
69 
71  void RequestSetFontSize( int index, int fontSize );
72 
74  void RequestAddAnnotations();
75 
78 
80  typedef std::vector< vtkTextActor* > ActorsListType;
81 
84 
85  friend class View;
86 
88  friend class QView;
89 
90 protected:
91 
92  Annotation2D( void );
93  ~Annotation2D( void );
94 
95 
97  void AddActors( vtkTextActor* );
98 
100  void DeleteActors( );
101 
103  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
104 
106  void RequestSetAnnotationsViewPort( int horizontal, int vertical );
107 
108 private:
109 
110  Annotation2D( const Self & ); //purposely not implemented
111  void operator=(const Self&); //purposely not implemented
112 
113  ActorsListType m_Actors;
114 
115  std::string m_AnnotationText[4];
116  std::string m_AnnotationTextToBeAdded;
117  vtkTextActor * m_AnnotationActor[4];
118  vtkTextActor * m_ActorToBeAdded;
119  vtkTextProperty * m_TextProperty[4];
120 
121  int m_ViewPortHorizontalSize;
122  int m_ViewPortVerticalSize;
123  int m_ViewPortHorizontalSizeToBeSet;
124  int m_ViewPortVerticalSizeToBeSet;
125 
126  double m_FontColor[3];
127  int m_AnnotationIndexFontColorToBeChanged;
128 
129  int m_FontSize;
130  int m_AnnotationIndexFontSizeToBeChanged;
131 
133  void AddActorProcessing();
134  void SetAnnotationTextProcessing();
135  void SetViewPortProcessing();
136  void AddAnnotationsProcessing();
137  void ReportInvalidAnnotationIndexProcessing();
138  void ReportInvalidRequestProcessing();
139  void ChangeTextColorProcessing();
140  void ChangeFontSizeProcessing();
141 
143  int m_IndexForAnnotationToBeAdded;
144 
146  igstkDeclareInputMacro( ValidAnnotations );
147  igstkDeclareInputMacro( InvalidAnnotations );
148  igstkDeclareInputMacro( ValidViewPort );
149  igstkDeclareInputMacro( ValidAnnotationIndex );
150  igstkDeclareInputMacro( InvalidAnnotationIndex );
151  igstkDeclareInputMacro( ValidColorProperty );
152  igstkDeclareInputMacro( InvalidColorProperty );
153  igstkDeclareInputMacro( ValidFontSizeProperty );
154  igstkDeclareInputMacro( InvalidFontSizeProperty );
155 
157  igstkDeclareStateMacro( Idle );
158  igstkDeclareStateMacro( ViewPortSet );
159  igstkDeclareStateMacro( AnnotationsAdded );
160 };
161 
162 } // end namespace igstk
163 
164 #endif // __igstkAnnotation2D_h