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;
42
43//----------------------------------------------------------------------------
44// Constant:
45//----------------------------------------------------------------------------
46#define ID_albaRWIBase_TIMER 1001
47
48//----------------------------------------------------------------------------
49// albaRWIBase :
50//----------------------------------------------------------------------------
60class ALBA_EXPORT albaRWIBase : public wxWindow, public vtkRenderWindowInteractor
61{
62 DECLARE_DYNAMIC_CLASS(albaRWIBase)
63
64protected:
65 wxTimer m_Timer;
66
67public:
68
69 vtkTypeMacro(albaRWIBase,vtkRenderWindowInteractor);
70
72 albaRWIBase(wxWindow *parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition,
73 const wxSize &size = wxDefaultSize, long style = wxWANTS_CHARS , const wxString &name = wxPanelNameStr);
75 static albaRWIBase * New();
76
77 void SetListener(albaObserver *listener) {m_Listener = listener;};
78
81
84
86 void SetStereoMovieDirectory(const char *dir);
87
90 void EnableStereoMovie(bool enable = true);
91
92 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
93 // vtk render window interactor methods
94 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
95
98 void Initialize();
101 void Enable();
104 void Disable();
107 void Start();
110 void UpdateSize(int x, int y);
116 wxBitmap* GetImage(int magnification = 1);
119 void SaveImage(albaString filename = "", int magnification = 1);
120
123 void SaveImageRecursive(albaString filename = "", albaViewCompound *v = NULL, int magnification = 1);
124 void RecursiveSaving(albaString filename="", albaViewCompound *v=NULL,int magnification=1);
127 void SaveAllImages(albaString filename = "", albaViewCompound *v = NULL);
130 vtkCamera* GetCamera();
131
132 int CreateTimer(int timertype);
134
135 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
136 // event handlers
137 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
138
140 void OnPaint(wxPaintEvent &event);
142 void OnEraseBackground (wxEraseEvent& event);
144 virtual void OnLeftMouseDoubleClick(wxMouseEvent &event);
146 virtual void OnLeftMouseButtonDown(wxMouseEvent &event);
148 virtual void OnLeftMouseButtonUp(wxMouseEvent &event);
150 virtual void OnMiddleMouseButtonDown(wxMouseEvent &event);
152 virtual void OnMiddleMouseButtonUp(wxMouseEvent &event);
154 virtual void OnRightMouseButtonDown(wxMouseEvent &event);
156 virtual void OnRightMouseButtonUp(wxMouseEvent &event);
158 virtual void OnMouseMotion(wxMouseEvent &event);
160 virtual void OnMouseWheel(wxMouseEvent &event);
162 virtual void OnTimer(wxTimerEvent &event);
164 virtual void OnKeyDown(wxKeyEvent &event);
166 virtual void OnKeyUp(wxKeyEvent &event);
168 virtual void OnChar(wxKeyEvent &event);
170 virtual void OnSize(wxSizeEvent &event);
172 virtual void OnIdle(wxIdleEvent& event);
174 virtual void OnMouseCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(evt));
175
177 void SetInteractorStyle(vtkInteractorObserver *o);
178
182
185
186protected:
191 vtkWindowToImageFilter *m_StereoMovieLeftEye;
192 vtkWindowToImageFilter *m_StereoMovieRightEye;
193 vtkImageAppend *m_StereoImage;
195
197 vtkCamera *m_Camera;
201
204
205 DECLARE_EVENT_TABLE()
206};
207#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:61
void Start()
Redefined method to take the control on event loop.
vtkCamera * m_Camera
Definition: albaRWIBase.h:197
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:188
wxTimer m_Timer
Definition: albaRWIBase.h:65
vtkPNGWriter * m_StereoMoviewFrameWriter
Definition: albaRWIBase.h:194
vtkImageAppend * m_StereoImage
Definition: albaRWIBase.h:193
virtual void OnKeyDown(wxKeyEvent &event)
Send an event with key code information.
void Initialize()
Initialize the render window interactor.
void SetInteractorStyle(vtkInteractorObserver *o)
Redefined to set the m_CustomInteractorStyle flag.
bool m_StereoFrameGenerate
Definition: albaRWIBase.h:190
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:200
void RecursiveSaving(albaString filename="", albaViewCompound *v=NULL, int magnification=1)
virtual void OnLeftMouseDoubleClick(wxMouseEvent &event)
Capture left mouse double click and notify it.
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:196
void Enable()
Enable the render window interactor.
virtual void OnTimer(wxTimerEvent &event)
Send an event with timer information.
void SaveImageRecursive(albaString filename="", albaViewCompound *v=NULL, int magnification=1)
Save all images of a view compound creating a view for every subview.
albaString m_StereoMovieDir
Definition: albaRWIBase.h:187
void GenerateStereoFrames()
Generate stereo frames for movie.
vtkCamera * GetCamera()
Return the current used camera.
void SetListener(albaObserver *listener)
Definition: albaRWIBase.h:77
void SaveAllImages(albaString filename="", albaViewCompound *v=NULL)
Save all images of the compound view.
vtkWindowToImageFilter * m_StereoMovieRightEye
Definition: albaRWIBase.h:192
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:198
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.
vtkWindowToImageFilter * m_StereoMovieLeftEye
Definition: albaRWIBase.h:191
virtual void OnKeyUp(wxKeyEvent &event)
Send an event with key code information.
bool m_CustomInteractorStyle
Definition: albaRWIBase.h:199
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:189
void SaveImage(albaString filename="", int magnification=1)
Save an image of the render window.
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.