Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SVTK_RenderWindowInteractor_h
00030 #define SVTK_RenderWindowInteractor_h
00031
00032 #include "SVTK.h"
00033 #include "SVTK_Selection.h"
00034
00035 #include <vtkSmartPointer.h>
00036 #include <QWidget>
00037
00038
00039
00040 #undef min
00041 #undef max
00042
00043 #include <stack>
00044
00045 class vtkGenericRenderWindowInteractor;
00046 class vtkInteractorStyle;
00047 class vtkCallbackCommand;
00048 class vtkRenderWindow;
00049 class vtkRenderer;
00050 class vtkObject;
00051
00052 class SVTK_Selector;
00053 class SVTK_Renderer;
00054
00055 #ifdef WIN32
00056 #pragma warning ( disable:4251 )
00057 #endif
00058
00066 class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget
00067 {
00068 Q_OBJECT;
00069
00070 public:
00071 QVTK_RenderWindowInteractor(QWidget* theParent,
00072 const char* theName);
00073
00074 ~QVTK_RenderWindowInteractor();
00075
00077 virtual
00078 void
00079 Initialize(vtkGenericRenderWindowInteractor* theDevice);
00080
00081 vtkGenericRenderWindowInteractor*
00082 GetDevice();
00083
00084 vtkRenderWindow*
00085 getRenderWindow();
00086
00088 virtual
00089 void
00090 InvokeEvent(unsigned long theEvent, void* theCallData);
00091
00093 virtual QPaintEngine* paintEngine() const;
00094
00095 public slots:
00097 virtual void show();
00098
00100 virtual void polish();
00101
00103 virtual void resize(int w, int h);
00104
00105 protected:
00106 virtual void paintEvent( QPaintEvent* );
00107 virtual void resizeEvent( QResizeEvent* );
00108
00109 virtual void mouseMoveEvent( QMouseEvent* );
00110 virtual void mousePressEvent( QMouseEvent* );
00111 virtual void mouseReleaseEvent( QMouseEvent* );
00112 virtual void mouseDoubleClickEvent( QMouseEvent* );
00113 virtual void wheelEvent( QWheelEvent* );
00114 virtual void keyPressEvent( QKeyEvent* );
00115 virtual void keyReleaseEvent( QKeyEvent* );
00116 virtual void enterEvent( QEvent * );
00117 virtual void leaveEvent( QEvent * );
00118
00119 virtual void contextMenuEvent( QContextMenuEvent * e );
00120
00121
00122
00123 virtual void focusInEvent( QFocusEvent* );
00124 virtual void focusOutEvent( QFocusEvent* );
00125
00127 #ifdef WIN32
00128 virtual bool winEvent( MSG*, long* );
00129 #else
00130 virtual bool x11Event( XEvent *e );
00131 #endif
00132
00133 vtkSmartPointer<vtkRenderWindow> myRenderWindow;
00134 vtkSmartPointer<vtkGenericRenderWindowInteractor> myDevice;
00135 };
00136
00137
00139
00147 class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteractor
00148 {
00149 Q_OBJECT;
00150
00151 public:
00152 SVTK_RenderWindowInteractor(QWidget* theParent,
00153 const char* theName);
00154
00155 ~SVTK_RenderWindowInteractor();
00156
00158 virtual
00159 void
00160 Initialize(vtkGenericRenderWindowInteractor* theDevice,
00161 SVTK_Renderer* theRenderer,
00162 SVTK_Selector* theSelector);
00163
00164
00166 SVTK_Renderer*
00167 GetRenderer();
00168
00170 vtkRenderer*
00171 getRenderer();
00172
00173
00175 vtkInteractorStyle*
00176 GetInteractorStyle();
00177
00179 void
00180 PushInteractorStyle(vtkInteractorStyle* theStyle);
00181
00183 void
00184 PopInteractorStyle();
00185
00186
00188 SVTK_Selector*
00189 GetSelector();
00190
00192 Selection_Mode
00193 SelectionMode() const;
00194
00196 void
00197 SetSelectionMode(Selection_Mode theMode);
00198
00199 public:
00201 void
00202 onEmitSelectionChanged();
00203
00204 public:
00205 signals:
00206 void MouseMove( QMouseEvent* );
00207 void MouseButtonPressed( QMouseEvent* );
00208 void MouseButtonReleased( QMouseEvent* );
00209 void MouseDoubleClicked( QMouseEvent* );
00210 void ButtonPressed(const QMouseEvent *event);
00211 void ButtonReleased(const QMouseEvent *event);
00212 void WheelMoved( QWheelEvent* );
00213 void KeyPressed( QKeyEvent* );
00214 void KeyReleased( QKeyEvent* );
00215 void contextMenuRequested( QContextMenuEvent *e );
00216
00217 void selectionChanged();
00218
00219 protected:
00220 virtual void mouseMoveEvent( QMouseEvent* );
00221 virtual void mousePressEvent( QMouseEvent* );
00222 virtual void mouseReleaseEvent( QMouseEvent* );
00223 virtual void mouseDoubleClickEvent( QMouseEvent* );
00224 virtual void wheelEvent( QWheelEvent* );
00225 virtual void keyPressEvent( QKeyEvent* );
00226 virtual void keyReleaseEvent( QKeyEvent* );
00227
00228 void
00229 SetRenderer(SVTK_Renderer *theRenderer);
00230
00231 void
00232 SetSelector(SVTK_Selector* theSelector);
00233
00234 void
00235 InitInteractorStyle(vtkInteractorStyle* theStyle);
00236
00237
00238
00239 static
00240 void
00241 ProcessEvents(vtkObject* theObject,
00242 unsigned long theEvent,
00243 void* theClientData,
00244 void* theCallData);
00245
00246
00247 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
00248
00249
00250 float myPriority;
00251
00252
00253 vtkSmartPointer<SVTK_Selector> mySelector;
00254
00255 vtkSmartPointer<SVTK_Renderer> myRenderer;
00256
00257 typedef vtkSmartPointer<vtkInteractorStyle> PInteractorStyle;
00258 typedef std::stack<PInteractorStyle> TInteractorStyles;
00259 TInteractorStyles myInteractorStyles;
00260 };
00261
00262 #ifdef WIN32
00263 #pragma warning ( default:4251 )
00264 #endif
00265
00266 #endif