00001 /*========================================================================= 00002 00003 Program: Image Guided Surgery Software Toolkit 00004 Module: $RCSfile: igstkQTWidget.h,v $ 00005 Language: C++ 00006 Date: $Date: 2008-02-11 01:41:51 $ 00007 Version: $Revision: 1.1 $ 00008 00009 Copyright (c) ISC Insight Software Consortium. All rights reserved. 00010 See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef __igstkQTWidget_h 00019 #define __igstkQTWidget_h 00020 00021 #ifdef _MSC_VER 00022 #pragma warning ( disable : 4018 ) 00023 //Warning about: identifier was truncated to '255' characters in the debug 00024 //information (MVC6.0 Debug) 00025 #pragma warning( disable : 4284 ) 00026 #endif 00027 00028 // QT dared to define macro called DEBUG!! 00029 #define QT_NO_DEBUG 1 00030 00031 // VTK declarations 00032 class vtkRenderer; 00033 class vtkRenderWindowInteractor; 00034 00035 // ITK headers 00036 #include "itkCommand.h" 00037 #include "itkLogger.h" 00038 00039 // IGSTK headers 00040 #include "igstkMacros.h" 00041 #include "igstkStateMachine.h" 00042 #include "igstkView.h" 00043 #include "igstkViewProxy.h" 00044 00045 // VTK header 00046 #include "QVTKWidget.h" 00047 00048 namespace igstk { 00049 00065 class QTWidget : public QVTKWidget 00066 { 00067 public: 00068 00069 typedef QTWidget Self; 00070 typedef QVTKWidget Superclass; 00071 typedef View ViewType; 00072 00073 igstkTypeMacro( QTWidget, QVTKWidget ); 00074 00076 igstkStateMachineMacro(); 00077 00079 void Print( std::ostream& os, ::itk::Indent indent=0) const; 00080 00082 igstkLoggerMacro() 00083 00084 00085 #if QT_VERSION < 0x040000 00086 00087 QTWidget(QWidget* parent = NULL, 00088 const char* name = NULL, Qt::WFlags f = 0); 00089 #else 00090 00091 QTWidget(QWidget* parent = NULL, Qt::WFlags f = 0); 00092 #endif 00093 00095 virtual ~QTWidget( void ); 00096 00098 void RequestSetView( const ViewType * view ); 00099 00100 typedef ViewProxy< QTWidget > ProxyType; 00101 00102 friend class ViewProxy< QTWidget >; 00103 00105 void RequestDisableInteractions(); 00106 00108 void RequestEnableInteractions(); 00109 00111 vtkRenderWindowInteractor * GetRenderWindowInteractor() const; 00112 00113 protected: 00114 00116 virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const; 00117 00120 void mouseReleaseEvent(QMouseEvent* e); 00121 00124 void mouseMoveEvent(QMouseEvent* e); 00125 void mousePressEvent(QMouseEvent* e); 00126 void wheelEvent(QWheelEvent* e); 00127 00128 00129 private: 00131 void ReportInvalidRequestProcessing(); 00132 00134 void ReportInvalidViewConnectedProcessing(); 00135 00137 void ConnectViewProcessing(); 00138 00140 void DisableInteractionsProcessing(); 00141 00143 void EnableInteractionsProcessing(); 00144 00147 void SetRenderer( vtkRenderer * renderer ); 00148 00151 void SetRenderWindowInteractor( vtkRenderWindowInteractor * interactor ); 00152 00153 private: 00154 00155 ViewType::Pointer m_View; 00156 ProxyType m_ProxyView; 00157 vtkRenderer * m_Renderer; 00158 vtkRenderWindowInteractor * m_RenderWindowInteractor; 00159 bool m_InteractionHandling; 00160 00162 igstkDeclareStateMacro( Idle ); 00163 igstkDeclareStateMacro( ViewConnected ); 00164 00166 igstkDeclareInputMacro( ValidView ); 00167 igstkDeclareInputMacro( InValidView ); 00168 igstkDeclareInputMacro( EnableInteractions ); 00169 igstkDeclareInputMacro( DisableInteractions ); 00170 00171 }; 00172 00173 std::ostream& operator<<(std::ostream& os, const QTWidget& o); 00174 00175 } // end namespace igstk 00176 00177 #endif