-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkResliceCursorCallback.h
97 lines (88 loc) · 3 KB
/
vtkResliceCursorCallback.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef VTK_RESLICE_CURSOR_CALL_BACK_H_
#define VTK_RESLICE_CURSOR_CALL_BACK_H_
#include "vtkCommand.h"
#include "vtkResliceCursorWidget.h"
#include "vtkImagePlaneWidget.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderWindow.h"
#include "vtkResliceCursorLineRepresentation.h"
#include "vtkPlaneSource.h"
class vtkResliceCursorCallback : public vtkCommand
{
public:
static vtkResliceCursorCallback *New()
{ return new vtkResliceCursorCallback; }
~vtkResliceCursorCallback()
{
}
void Execute( vtkObject * caller , unsigned long ev,
void *callData )
{
if (ev == vtkResliceCursorWidget::WindowLevelEvent ||
ev == vtkCommand::WindowLevelEvent ||
ev == vtkResliceCursorWidget::ResliceThicknessChangedEvent)
{
// Render everything
for (int i = 0; i < 3; i++)
{
this->RCW[i]->Render();
}
this->IPW[0]->GetInteractor()->GetRenderWindow()->Render();
return;
}
vtkImagePlaneWidget* ipw =
dynamic_cast< vtkImagePlaneWidget* >( caller );
if (ipw)
{
double* wl = static_cast<double*>( callData );
if ( ipw == this->IPW[0] )
{
this->IPW[1]->SetWindowLevel(wl[0],wl[1],1);
this->IPW[2]->SetWindowLevel(wl[0],wl[1],1);
}
else if( ipw == this->IPW[1] )
{
this->IPW[0]->SetWindowLevel(wl[0],wl[1],1);
this->IPW[2]->SetWindowLevel(wl[0],wl[1],1);
}
else if (ipw == this->IPW[2])
{
this->IPW[0]->SetWindowLevel(wl[0],wl[1],1);
this->IPW[1]->SetWindowLevel(wl[0],wl[1],1);
}
}
vtkResliceCursorWidget *rcw = dynamic_cast<
vtkResliceCursorWidget * >(caller);
if (rcw)
{
vtkResliceCursorLineRepresentation *rep = dynamic_cast<
vtkResliceCursorLineRepresentation * >(rcw->GetRepresentation());
// Although the return value is not used, we keep the get calls
// in case they had side-effects
rep->GetResliceCursorActor()->GetCursorAlgorithm()->GetResliceCursor();
for (int i = 0; i < 3; i++)
{
vtkPlaneSource *ps = static_cast< vtkPlaneSource * >(
this->IPW[i]->GetPolyDataAlgorithm());
ps->SetOrigin(this->RCW[i]->GetResliceCursorRepresentation()->
GetPlaneSource()->GetOrigin());
ps->SetPoint1(this->RCW[i]->GetResliceCursorRepresentation()->
GetPlaneSource()->GetPoint1());
ps->SetPoint2(this->RCW[i]->GetResliceCursorRepresentation()->
GetPlaneSource()->GetPoint2());
// If the reslice plane has modified, update it on the 3D widget
this->IPW[i]->UpdatePlacement();
}
}
// Render everything
for (int i = 0; i < 3; i++)
{
this->RCW[i]->Render();
}
this->IPW[0]->GetInteractor()->GetRenderWindow()->Render();
}
vtkResliceCursorCallback() {}
vtkImagePlaneWidget* IPW[3];
vtkResliceCursorWidget *RCW[3];
};
#endif