-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPatientShiftViewModel.txt
More file actions
60 lines (56 loc) · 2.15 KB
/
PatientShiftViewModel.txt
File metadata and controls
60 lines (56 loc) · 2.15 KB
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
private PatientShiftModel _xShift;
public PatientShiftModel XShift
{
get { return _xShift; }
set { SetProperty(ref _xShift, value); }
}
private PatientShiftModel _yShift;
public PatientShiftModel YShift
{
get { return _yShift; }
set { SetProperty(ref _yShift, value); }
}
private PatientShiftModel _zShift;
private PlanSetup _plan;
public PatientShiftModel ZShift
{
get { return _zShift; }
set { SetProperty(ref _zShift, value); }
}
public PatientShiftViewModel(PlanSetup plan)
{
_plan = plan;
GetCouchShifts();
}
private void GetCouchShifts()
{
Beam b1 = _plan.Beams.Where(x => !x.IsSetupField).OrderBy(x => x.BeamNumber).FirstOrDefault();
var uo = _plan.StructureSet.Image.UserOrigin;
if (b1 != null)
{
double x = (uo.x - b1.IsocenterPosition.x) / 10.0;
double y = -(uo.y - b1.IsocenterPosition.y) / 10.0;
double z = (uo.z - b1.IsocenterPosition.z) / 10.0;
XShift = new PatientShiftModel
{
Magnitude = x,
ShiftDirection = ShiftDirectionEnum.XDir,
ShiftText = Math.Abs(x) < 0.01 ? "No Shift" :
x < 0 ? $"Left: {Math.Abs(x):F2}" : $"Right: {Math.Abs(x):F2}"
};
YShift = new PatientShiftModel
{
Magnitude = y,
ShiftDirection = ShiftDirectionEnum.YDir,
ShiftText = Math.Abs(y) < 0.01 ? "No Shift" :
y < 0 ? $"Down: {Math.Abs(y):F2}" : $"Up: {Math.Abs(y):F2}"
};
ZShift = new PatientShiftModel
{
Magnitude = z,
ShiftDirection = ShiftDirectionEnum.ZDir,
ShiftText = Math.Abs(z) < 0.01 ? "No Shift" :
z < 0 ? $"Out: {Math.Abs(z):F2}" : $"In: {Math.Abs(z):F2}"
};
}
}