-
Notifications
You must be signed in to change notification settings - Fork 1
/
BasicImageStyle.cpp
136 lines (111 loc) · 2.7 KB
/
BasicImageStyle.cpp
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "BasicImageStyle.h"
SPTR<BasicImageStyle> BasicImageStyle::New(const ViewType& type)
{
return SPTR<BasicImageStyle>(new BasicImageStyle(type));
}
//构造函数
BasicImageStyle::BasicImageStyle(const ViewType& type) :vtkInteractorStyleTrackballCamera(), view_type_(type)
{
}
void BasicImageStyle::updataSlicer()
{
auto c_origin = reslice_->GetResliceAxesOrigin();
auto mat1 = reslice_->GetResliceAxes();
vtkNew<vtkMatrix4x4> mat;
mat->SetElement(1, 1, -1);
mat->SetElement(2, 2, -1);
double k[3];
k[0] = mat->GetElement(0, 0) * c_origin[0];
k[1] = mat->GetElement(1, 1) * c_origin[1];
k[0] = mat->GetElement(2, 2) * c_origin[2];
int index = 3 - view_type_;
int cur_index = (c_origin[index] - origin_[index]) / spacing_[index] + 1;
int max_count = size_[3 - view_type_];
//RENDER_DATA_MODEL->updataInfoSlicer(cur_index, max_count, view_type_);
}
//析构函数
BasicImageStyle::~BasicImageStyle()
{
}
void BasicImageStyle::setImageParameter(const int size[3], const double spacing[3], const double origin[3])
{
size_[0] = size[0];
size_[1] = size[1];
size_[2] = size[2];
spacing_[0] = spacing[0];
spacing_[1] = spacing[1];
spacing_[2] = spacing[2];
origin_[0] = origin[0];
origin_[1] = origin[1];
origin_[2] = origin[2];
}
void BasicImageStyle::OnMouseMove()
{
}
void BasicImageStyle::OnLeftButtonDown()
{
}
void BasicImageStyle::OnLeftButtonUp()
{
}
void BasicImageStyle::OnMiddleButtonDown()
{
}
void BasicImageStyle::OnMiddleButtonUp()
{
}
void BasicImageStyle::OnRightButtonDown()
{
}
void BasicImageStyle::OnRightButtonUp()
{
}
void BasicImageStyle::OnMouseWheelForward()
{
//if (view_type_ == VOL)
//{
// vtkInteractorStyleTrackballCamera::OnMouseWheelForward();
// return;
//}
if (reslice_)
{
double spacing = reslice_->GetOutput()->GetSpacing()[2];
auto matrix = reslice_->GetResliceAxes();
double point[4], center[4];
point[0] = 0.0;
point[1] = 0.0;
point[2] = spacing * 1;
point[3] = 1.0;
matrix->MultiplyPoint(point, center);
matrix->SetElement(0, 3, center[0]);
matrix->SetElement(1, 3, center[1]);
matrix->SetElement(2, 3, center[2]);
reslice_->Update();
}
updataSlicer();
}
void BasicImageStyle::OnMouseWheelBackward()
{
/*if (view_type_ == VOL_M)
{
vtkInteractorStyleTrackballCamera::OnMouseWheelForward();
return;
}*/
if (reslice_)
{
double spacing = reslice_->GetOutput()->GetSpacing()[2];
auto matrix = reslice_->GetResliceAxes();
double point[4], center[4];
point[0] = 0.0;
point[1] = 0.0;
point[2] = -spacing * 1;
point[3] = 1.0;
matrix->MultiplyPoint(point, center);
matrix->SetElement(0, 3, center[0]);
matrix->SetElement(1, 3, center[1]);
matrix->SetElement(2, 3, center[2]);
reslice_->Update();
}
updataSlicer();
}