ALBA
albaGUIDialogTransferFunction2D.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaGUIDialogTransferFunction2D
5 Authors: Alexander Savenko
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 __albaGUIDialogTransferFunction2D_H__
18#define __albaGUIDialogTransferFunction2D_H__
19
20//----------------------------------------------------------------------------
21// Include :
22//----------------------------------------------------------------------------
23#include "albaGUIDialog.h"
24
25#include "vtkProp.h"
26#include "vtkALBATransferFunction2D.h"
27
28//----------------------------------------------------------------------------
29// forward refs :
30//----------------------------------------------------------------------------
31class wxNotebook;
32
33class albaVME;
35class albaRWIBase;
36class albaGUI;
38
39class vtkViewport;
40class vtkRenderWindow;
41class vtkRenderer;
42class vtkVolumeProperty2;
43class vtkALBATransferFunction2D;
44class vtkALBAAdaptiveVolumeMapper;
45class vtkImageMapper;
46class vtkALBAImageMapToWidgetColors;
47class vtkImageResample;
48class vtkActor;
49class vtkActor2D;
50class vtkVolume;
51class vtkTextActor;
52class vtkCriticalSection;
53class vtkWidgetActor;
56
57//----------------------------------------------------------------------------
58// albaGUIDialogTransferFunction2D :
59//----------------------------------------------------------------------------
63{
66
67public:
68 albaGUIDialogTransferFunction2D(); // reads materials from file
69 ~albaGUIDialogTransferFunction2D(); // store materials to file
70 void ShowModal(albaVME *vme);
71 void OnEvent(albaEventBase *alba_event);
72
73protected:
74 void CreateGUI();
80
83
86
87 // create/update widgets
89
90 void OnIdle(wxIdleEvent& event);
91 void OnSize(wxSizeEvent& event) { this->ResizePreviewWindow(); event.Skip(); }
92 void OnCommand(wxCommandEvent &event) { this->OnEvent(&albaEvent(this, event.GetId())); }
93 void OnMotion(wxMouseEvent &event) { m_StatusBar->SetStatusText("", 0); m_StatusBar->SetStatusText("", 1); }
94 void SetWidget(const tfWidget &widget);
95
96 // vme
99 vtkVolumeProperty2 *m_VolumeProperty;
100 vtkALBATransferFunction2D *m_TransferFunction;
101
102 // slice preview
103 wxNotebook *m_PreviewBook;
105 vtkRenderWindow *m_SliceWindow;
106 vtkTextActor *m_WaitActor;
107 vtkRenderer *m_SliceRenderer;
108 vtkImageResample *m_SliceResampler;
109 vtkImageMapper *m_SliceMapper;
110 vtkALBAImageMapToWidgetColors *m_SliceFilter;
111 vtkActor2D *m_SliceActor;
112
113 // 3d preview
115 vtkRenderer *m_Renderer3D;
116 vtkRenderWindow *m_Window3D;
117 vtkALBAAdaptiveVolumeMapper *m_Mapper3D;
118 vtkVolume *m_Volume3D;
119
120 // graph/widget window
122 vtkRenderer *m_GraphRenderer;
123 vtkRenderWindow *m_GraphWindow;
125
126 vtkCriticalSection *m_CriticalSection;
127
128 tfWidget m_Widget;
129 wxListBox *m_WidgetList;
131
136 wxString m_WidgetName;
138 wxString m_Filename;
141
142 wxStatusBar *m_StatusBar;
143
144 double m_DataRange[2];
145 double m_GradientRange[2];
146
147 // pipeline status
148 enum { PipeNotReady, PipeReady, PipePlugged};
149
153
154 static VTK_THREAD_RETURN_TYPE CreatePipe(void *ptr);
155
156DECLARE_EVENT_TABLE()
157};
158
159//----------------------------------------------------------------------------
160// vtkWidgetActor :
161//----------------------------------------------------------------------------
162class ALBA_EXPORT vtkWidgetActor : public vtkProp
163{
164public:
165 static vtkWidgetActor *New() { return new vtkWidgetActor(); }
167
168 int RenderOverlay (vtkViewport *);
169
170 void SetTransferFunction(vtkALBATransferFunction2D *tf);
171 void SetViewportRange(double xmin, double xmax, double ymin, double ymax) { ViewportRange[0] = xmin; ViewportRange[1] = xmax; ViewportRange[2] = ymin; ViewportRange[3] = ymax; }
172 const double *GetViewportRange() const { return this->ViewportRange; }
173
174 void SetSelection(int index) { this->SelectedWidget = index; }
175 void HighlightPoint(int widget, int point) { this->HighlightedWidget = widget; this->HighlightedPoint = point; }
176
177 void SetCurrentPosition(double value, double gradient) { this->CurrentPoint[0] = value; this->CurrentPoint[1] = gradient; }
178
179 int Pick(vtkViewport *viewport, int x, int y, int &pickedPoint);
180
181protected:
184
185 vtkWidgetActor(const vtkWidgetActor&); // no implementation
186 void operator=(const vtkWidgetActor&); // no implementation
187
188 vtkALBATransferFunction2D *TransferFunction;
189 double ViewportRange[4]; // xmin, xmax, ymin, ymax
193
194 double CurrentPoint[2];
195};
196
198
199#include "vtkInteractorStyleImage.h"
200
201//----------------------------------------------------------------------------
202// vtkInteractorStylePreviewImage :
203//----------------------------------------------------------------------------
204class ALBA_EXPORT vtkInteractorStylePreviewImage : public vtkInteractorStyleImage
205{
206public:
209
210 vtkInteractorStylePreviewImage() { this->m_Dialog = NULL; this->m_ActiveButton[0] = this->m_ActiveButton[1] = this->m_ActiveButton[2] = false; }
211
212 void SetDialog(albaGUIDialogTransferFunction2D *dialog) { this->m_Dialog = dialog; }
213
215 void OnLeftButtonUp() { this->m_ActiveButton[0] = false; }
216 void OnMiddleButtonUp() { this->m_ActiveButton[1] = false; }
217 void OnRightButtonUp() { this->m_ActiveButton[2] = false; }
218
222
223protected:
226
227 bool m_ActiveButton[3];
228 int m_StartPosition[3][2];
229
230 tfWidget m_Widget;
231
233
234 bool FindValueAndGradient(int x, int y, double &value, double &gradient);
235};
236
237//----------------------------------------------------------------------------
238// vtkInteractorStyleWidget :
239//----------------------------------------------------------------------------
241{
242public:
245
248
251
252protected:
254
257};
258#endif // _albaGUIDialogTransferFunction2D_H_
Implementation of the message object for the Subject/Observer design pattern.
Definition: albaEventBase.h:49
albaEvent - Class implementing ALBA application events.
Definition: albaEvent.h:55
This dialog is used to define a 2D transfer function to make a volume Ray Cast.
vtkALBAImageMapToWidgetColors * m_SliceFilter
void LoadTransferFunction()
Load volume transfer function from vme tag.
void ShowModal(albaVME *vme)
void OnSize(wxSizeEvent &event)
Handle on size event.
static VTK_THREAD_RETURN_TYPE CreatePipe(void *ptr)
void SaveTransferFunction()
Save volume transfer function to vme tag.
void OnIdle(wxIdleEvent &event)
void OnEvent(albaEventBase *alba_event)
process the events sent by subjects
void SetWidget(const tfWidget &widget)
albaGUIDialog is the base class for albaDialogs.
Definition: albaGUIDialog.h:76
void OnEvent(albaEventBase *alba_event)
process the events sent by subjects
class name: albaGUIRangeSlider Class that handles a slider for visualising or changing range.
albaGUI is a panel with function to easily create GUI.
Definition: albaGUI.h:110
albaRWIBase is a vtkRenderWindowInteractor placed on a wxWindow
Definition: albaRWIBase.h:61
albaVME -
Definition: albaVME.h:150
bool FindValueAndGradient(int x, int y, double &value, double &gradient)
static vtkInteractorStylePreviewImage * New()
vtkInteractorStylePreviewImage(const vtkInteractorStylePreviewImage &)
vtkTypeMacro(vtkInteractorStylePreviewImage, vtkInteractorStyleImage)
albaGUIDialogTransferFunction2D * m_Dialog
void operator=(const vtkInteractorStylePreviewImage &)
void SetDialog(albaGUIDialogTransferFunction2D *dialog)
static vtkInteractorStyleWidget * New()
vtkInteractorStyleWidget(const vtkInteractorStyleWidget &)
void operator=(const vtkInteractorStyleWidget &)
vtkTypeMacro(vtkInteractorStyleWidget, vtkInteractorStylePreviewImage)
static vtkWidgetActor * New()
vtkWidgetActor(const vtkWidgetActor &)
vtkALBATransferFunction2D * TransferFunction
void SetViewportRange(double xmin, double xmax, double ymin, double ymax)
void HighlightPoint(int widget, int point)
int RenderOverlay(vtkViewport *)
void SetCurrentPosition(double value, double gradient)
int Pick(vtkViewport *viewport, int x, int y, int &pickedPoint)
void operator=(const vtkWidgetActor &)
vtkTypeMacro(vtkWidgetActor, vtkProp)
void SetTransferFunction(vtkALBATransferFunction2D *tf)
const double * GetViewportRange() const