IGSTK
igstkQTWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkQTWidget.h,v $
5  Language: C++
6  Date: $Date: 2008-02-11 01:41:51 $
7  Version: $Revision: 1.1 $
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 __igstkQTWidget_h
19 #define __igstkQTWidget_h
20 
21 #ifdef _MSC_VER
22 #pragma warning ( disable : 4018 )
23 //Warning about: identifier was truncated to '255' characters in the debug
24 //information (MVC6.0 Debug)
25 #pragma warning( disable : 4284 )
26 #endif
27 
28 // QT dared to define macro called DEBUG!!
29 #define QT_NO_DEBUG 1
30 
31 // VTK declarations
32 class vtkRenderer;
33 class vtkRenderWindowInteractor;
34 
35 // ITK headers
36 #include "itkCommand.h"
37 #include "itkLogger.h"
38 
39 // IGSTK headers
40 #include "igstkMacros.h"
41 #include "igstkStateMachine.h"
42 #include "igstkView.h"
43 #include "igstkViewProxy.h"
44 
45 // VTK header
46 #include "QVTKWidget.h"
47 
48 namespace igstk {
49 
65 class QTWidget : public QVTKWidget
66 {
67 public:
68 
69  typedef QTWidget Self;
70  typedef QVTKWidget Superclass;
71  typedef View ViewType;
72 
73  igstkTypeMacro( QTWidget, QVTKWidget );
74 
77 
79  void Print( std::ostream& os, ::itk::Indent indent=0) const;
80 
83 
84 
85 #if QT_VERSION < 0x040000
86 
87  QTWidget(QWidget* parent = NULL,
88  const char* name = NULL, Qt::WFlags f = 0);
89 #else
90 
91  QTWidget(QWidget* parent = NULL, Qt::WFlags f = 0);
92 #endif
93 
95  virtual ~QTWidget( void );
96 
98  void RequestSetView( const ViewType * view );
99 
101 
102  friend class ViewProxy< QTWidget >;
103 
106 
109 
111  vtkRenderWindowInteractor * GetRenderWindowInteractor() const;
112 
113 protected:
114 
116  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
117 
120  void mouseReleaseEvent(QMouseEvent* e);
121 
124  void mouseMoveEvent(QMouseEvent* e);
125  void mousePressEvent(QMouseEvent* e);
126  void wheelEvent(QWheelEvent* e);
127 
128 
129 private:
131  void ReportInvalidRequestProcessing();
132 
134  void ReportInvalidViewConnectedProcessing();
135 
137  void ConnectViewProcessing();
138 
140  void DisableInteractionsProcessing();
141 
143  void EnableInteractionsProcessing();
144 
147  void SetRenderer( vtkRenderer * renderer );
148 
151  void SetRenderWindowInteractor( vtkRenderWindowInteractor * interactor );
152 
153 private:
154 
155  ViewType::Pointer m_View;
156  ProxyType m_ProxyView;
157  vtkRenderer * m_Renderer;
158  vtkRenderWindowInteractor * m_RenderWindowInteractor;
159  bool m_InteractionHandling;
160 
162  igstkDeclareStateMacro( Idle );
163  igstkDeclareStateMacro( ViewConnected );
164 
166  igstkDeclareInputMacro( ValidView );
167  igstkDeclareInputMacro( InValidView );
168  igstkDeclareInputMacro( EnableInteractions );
169  igstkDeclareInputMacro( DisableInteractions );
170 
171 };
172 
173 std::ostream& operator<<(std::ostream& os, const QTWidget& o);
174 
175 } // end namespace igstk
176 
177 #endif