ALBA
albaRWIBase.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaRWIBase
5 Authors: Silvano Imboden - Paolo Quadrani
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16
17#ifndef __albaRWIBase_H__
18#define __albaRWIBase_H__
19
20//----------------------------------------------------------------------------
21// Include :
22//----------------------------------------------------------------------------
23#include "albaObserver.h"
24#include "albaString.h"
25#include "albaViewCompound.h"
26#include "vtkRenderWindowInteractor.h"
27
28//----------------------------------------------------------------------------
29// Forward References :
30//----------------------------------------------------------------------------
31class wxPaintEvent;
32class wxMouseEvent;
33class wxTimerEvent;
34class wxKeyEvent;
35class wxSizeEvent;
36class vtkInteractorObserver;
37class vtkCamera;
39class vtkImageAppend;
40class vtkPNGWriter;
41class vtkWindowToImageFilter;
42class vtkImageData;
43
44//----------------------------------------------------------------------------
45// Constant:
46//----------------------------------------------------------------------------
47#define ID_albaRWIBase_TIMER 1001
48
49//----------------------------------------------------------------------------
50// albaRWIBase :
51//----------------------------------------------------------------------------
61class ALBA_EXPORT albaRWIBase : public wxWindow, public vtkRenderWindowInteractor
62{
63 DECLARE_DYNAMIC_CLASS(albaRWIBase)
64
65protected:
66 wxTimer m_Timer;
67
68public:
69
70 vtkTypeMacro(albaRWIBase,vtkRenderWindowInteractor);
71
73 albaRWIBase(wxWindow *parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition,
74 const wxSize &size = wxDefaultSize, long style = wxWANTS_CHARS , const wxString &name = wxPanelNameStr);
76 static albaRWIBase * New();
77
78 void SetListener(albaObserver *listener) {m_Listener = listener;};
79
82
85
87 void SetStereoMovieDirectory(const char *dir);
88
91 void EnableStereoMovie(bool enable = true);
92
93 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
94 // vtk render window interactor methods
95 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
96
99 void Initialize();
102 void Enable();
105 void Disable();
108 void Start();
111 void UpdateSize(int x, int y);
117 wxBitmap* GetImage(int magnification = 1);
120 void SaveImage(albaString filename = "");
121
122public:
123 void SaveImageFromImageData(albaString &filename, vtkImageData *imageData);
124
128
131 vtkCamera* GetCamera();
132
133 int CreateTimer(int timertype);
135
136 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
137 // event handlers
138 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
139
141 void OnPaint(wxPaintEvent &event);
143 void OnEraseBackground (wxEraseEvent& event);
145 virtual void OnLeftMouseDoubleClick(wxMouseEvent &event);
147 virtual void OnLeftMouseButtonDown(wxMouseEvent &event);
149 virtual void OnLeftMouseButtonUp(wxMouseEvent &event);
151 virtual void OnMiddleMouseButtonDown(wxMouseEvent &event);
153 virtual void OnMiddleMouseButtonUp(wxMouseEvent &event);
155 virtual void OnRightMouseButtonDown(wxMouseEvent &event);
157 virtual void OnRightMouseButtonUp(wxMouseEvent &event);
159 virtual void OnMouseMotion(wxMouseEvent &event);
161 virtual void OnMouseWheel(wxMouseEvent &event);
163 virtual void OnTimer(wxTimerEvent &event);
165 virtual void OnKeyDown(wxKeyEvent &event);
167 virtual void OnKeyUp(wxKeyEvent &event);
169 virtual void OnChar(wxKeyEvent &event);
171 virtual void OnSize(wxSizeEvent &event);
173 virtual void OnIdle(wxIdleEvent& event);
175 virtual void OnMouseCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(evt));
176
178 void SetInteractorStyle(vtkInteractorObserver *o);
179
183
186
187protected:
192 vtkWindowToImageFilter *m_StereoMovieLeftEye;
193 vtkWindowToImageFilter *m_StereoMovieRightEye;
194 vtkImageAppend *m_StereoImage;
196
198 vtkCamera *m_Camera;
202
205
206 DECLARE_EVENT_TABLE()
207};
208#endif
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36
albaRWIBase is a vtkRenderWindowInteractor placed on a wxWindow
Definition: albaRWIBase.h:62
void Start()
Redefined method to take the control on event loop.
vtkCamera * m_Camera
Definition: albaRWIBase.h:198
albaRWIBase(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxPanelNameStr)
void OnEraseBackground(wxEraseEvent &event)
int m_StereoMovieFrameCounter
Definition: albaRWIBase.h:189
wxTimer m_Timer
Definition: albaRWIBase.h:66
vtkPNGWriter * m_StereoMoviewFrameWriter
Definition: albaRWIBase.h:195
vtkImageAppend * m_StereoImage
Definition: albaRWIBase.h:194
virtual void OnKeyDown(wxKeyEvent &event)
Send an event with key code information.
void Initialize()
Initialize the render window interactor.
void SaveImage(albaString filename="")
Save an image of the render window.
void SetInteractorStyle(vtkInteractorObserver *o)
Redefined to set the m_CustomInteractorStyle flag.
bool m_StereoFrameGenerate
Definition: albaRWIBase.h:191
void OnPaint(wxPaintEvent &event)
Method called whe the render window as to be repainted.
virtual void OnRightMouseButtonUp(wxMouseEvent &event)
Release the mouse and send an event with mouse position.
virtual void OnMouseWheel(wxMouseEvent &event)
Send an event with mouse wheel.
albaObserver * m_Listener
Definition: albaRWIBase.h:201
virtual void OnLeftMouseDoubleClick(wxMouseEvent &event)
The double click is sent as a left button down.
virtual void OnRightMouseButtonDown(wxMouseEvent &event)
Capture mouse and notify the mouse click.
virtual void OnMiddleMouseButtonDown(wxMouseEvent &event)
Capture mouse and notify the mouse click.
virtual void OnMiddleMouseButtonUp(wxMouseEvent &event)
Release the mouse and send an event with mouse position.
void SetStereoMovieDirectory(const char *dir)
Set the directory for the Stereo Movie.
int CreateTimer(int timertype)
virtual void OnLeftMouseButtonUp(wxMouseEvent &event)
Release the mouse and send an event with mouse position.
albaString m_SaveDir
Definition: albaRWIBase.h:197
void Enable()
Enable the render window interactor.
virtual void OnTimer(wxTimerEvent &event)
Send an event with timer information.
albaString m_StereoMovieDir
Definition: albaRWIBase.h:188
void GenerateStereoFrames()
Generate stereo frames for movie.
vtkCamera * GetCamera()
Return the current used camera.
void SetListener(albaObserver *listener)
Definition: albaRWIBase.h:78
vtkWindowToImageFilter * m_StereoMovieRightEye
Definition: albaRWIBase.h:193
virtual void OnSize(wxSizeEvent &event)
Find the current camera and set UseHorizontalViewAngle depending on the win aspect ratio.
virtual void OnLeftMouseButtonDown(wxMouseEvent &event)
Capture mouse and notify the mouse click.
void Disable()
Disable the render window interactor.
albaDeviceButtonsPadMouse * m_Mouse
Definition: albaRWIBase.h:199
vtkTypeMacro(albaRWIBase, vtkRenderWindowInteractor)
void UpdateSize(int x, int y)
Update the size of the render window.
void NotifyClick()
Notify mouse click on a view.
void SetMouse(albaDeviceButtonsPadMouse *mouse)
set the mouse device to which forward events from the view
wxBitmap * GetImage(int magnification=1)
Return an image of the render window.
void SaveAllImages(albaString filename, albaViewCompound *v)
Save all images of the compound view.
vtkWindowToImageFilter * m_StereoMovieLeftEye
Definition: albaRWIBase.h:192
virtual void OnKeyUp(wxKeyEvent &event)
Send an event with key code information.
bool m_CustomInteractorStyle
Definition: albaRWIBase.h:200
void SaveImageFromImageData(albaString &filename, vtkImageData *imageData)
virtual void OnMouseMotion(wxMouseEvent &event)
Send an event with mouse position.
void EnableStereoMovie(bool enable=true)
Enable/disable stereo movie frames generation.
virtual void OnChar(wxKeyEvent &event)
Send an event with key code information.
virtual void OnIdle(wxIdleEvent &event)
Do nothing.
void TerminateApp()
Redefined method to terminate the application.
virtual void OnMouseCaptureLost(wxMouseCaptureLostEvent &WXUNUSED(evt))
Manage Mouse Capture Lost.
bool m_StereoMovieEnable
Definition: albaRWIBase.h:190
static albaRWIBase * New()
int DestroyTimer()
albaString - performs common string operations on c-strings.
Definition: albaString.h:43
albaViewCompound is the base class for Compound Views in ALBA.