-
Notifications
You must be signed in to change notification settings - Fork 25
/
cutout.pas
executable file
·195 lines (171 loc) · 5.51 KB
/
cutout.pas
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
unit cutout;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
Spin;
const
kMaxFrac = 1000;//e.g. if 100 then cutouts are done by percent, if 1000 then 0.001
type
{ TCutoutForm }
TCutoutForm = class(TForm)
CutoutBiasDrop: TComboBox;
CutoutLUTDrop: TComboBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
PreviewBtn: TButton;
DefBtn: TButton;
OKBtn: TButton;
CutoutBox: TGroupBox;
PreviewBtn1: TButton;
RenderCutoutCheck: TCheckBox;
XLo: TSpinEdit;
XHi: TSpinEdit;
YLo: TSpinEdit;
YHi: TSpinEdit;
ZLo: TSpinEdit;
ZHi: TSpinEdit;
procedure Prep;
procedure DefBtnClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormShow(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
procedure PreviewBtn1Click(Sender: TObject);
procedure PreviewClick(Sender: TObject);
procedure RenderCutoutCheckClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
CutoutForm: TCutoutForm;
implementation
{$DEFINE REND} //if you define "REND" render form will be interactively adjusted
uses render_composite{grender}, nifti_img_view {LUTdrop},define_types {sortcutout}
{$IFDEF REND}, render {$ENDIF}{azimuth,elevation,timer}
;
var gInit: boolean = false;
{ TCutoutForm }
procedure TCutoutForm.Prep;
begin
gInit := true;
CutoutForm.caption := 'Cutouts: '+inttostr(kMaxFrac)+'= 100%';
cutoutlutdrop.Items := ImgForm.LUTdrop.items;
if (gRender.cutoutLUTindex < 1) or (gRender.cutoutLUTindex > cutoutlutdrop.Items.Count) then
cutoutlutdrop.itemindex := 0
else
cutoutlutdrop.itemindex := gRender.cutoutLUTindex;
if gRender.CutoutFrac.Lo[1] < 0 then
SliceToFrac(gBGImg);
SortCutout(gRender.CutoutFrac);
Xlo.maxValue := kMaxFrac;//gBGImg.ScrnDim[1];
Xhi.maxValue := kMaxFrac;//gBGImg.ScrnDim[1];
Ylo.maxValue := kMaxFrac;//gBGImg.ScrnDim[2];
Yhi.maxValue := kMaxFrac;//gBGImg.ScrnDim[2];
Zlo.maxValue := kMaxFrac;//gBGImg.ScrnDim[3];
Zhi.maxValue := kMaxFrac;//gBGImg.ScrnDim[3];
Xlo.Value := gRender.CutoutFrac.Lo[1];
Xhi.Value := gRender.CutoutFrac.Hi[1];
Ylo.Value := gRender.CutoutFrac.Lo[2];
Yhi.Value := gRender.CutoutFrac.Hi[2];
Zlo.Value := gRender.CutoutFrac.Lo[3];
Zhi.Value := gRender.CutoutFrac.Hi[3];
//OverlayClipEdit.value := gRender.OverlayNearClipFrac;
//BGClipEdit.value := gRender.BGNearClipFrac;
RenderCutoutCheck.checked := gRender.ShowCutout;
CutoutBiasDrop.ItemIndex:=( gRender.CutoutBias);
RenderCutoutCheckClick(nil);
gInit := false;
end;
procedure ReadCutoutForm;
begin
with CutoutForm do begin
gRender.CutoutFrac.Lo[1] := round(Xlo.Value);
gRender.CutoutFrac.Hi[1] := round(Xhi.Value);
gRender.CutoutFrac.Lo[2] := round(Ylo.Value);
gRender.CutoutFrac.Hi[2] := round(Yhi.Value);
gRender.CutoutFrac.Lo[3] := round(Zlo.Value);
gRender.CutoutFrac.Hi[3] := round(Zhi.Value);
SortCutout(gRender.CutoutFrac);
gRender.ShowCutout := RenderCutoutCheck.checked;
gRender.CutoutBias := CutoutBiasDrop.ItemIndex;
gRender.cutoutLUTindex := cutoutlutdrop.itemindex;
//gRender.OverlayNearClipFrac := round(OverlayClipEdit.value);
// gRender.BGNearClipFrac := round(BGClipEdit.value);
end;
end;
procedure TCutoutForm.RenderCutoutCheckClick(Sender: TObject);
begin
CutoutBox.visible := RenderCutoutCheck.Checked;
PreviewClick(nil);
end;
procedure TCutoutForm.PreviewClick(Sender: TObject);
begin
if gInit then
exit;
ReadCutoutForm;
{$IFDEF REND}
gZoom := 0.5;
RenderForm.RenderRefreshTimer.Tag := -1; //force a new rotation matrix to be generated
RenderForm.RenderRefreshTimer.enabled := true;
{$ENDIF}
end;
procedure TCutoutForm.DefBtnClick(Sender: TObject);
begin
gInit := true;
Ylo.Value := kMaxFrac shr 1;
Yhi.Value := kMaxFrac ;
Zlo.Value := kMaxFrac shr 1;
Zhi.Value := kMaxFrac ;
//OverlayClipEdit.value := 0;
//BGClipEdit.value := 0;
RenderCutoutCheck.checked := true;
CutoutLUTdrop.ItemIndex := 0;
CutoutBiasDrop.ItemIndex:= 3;
{$IFDEF REND}
if renderForm.FlipLRcheck.checked then begin
Xlo.Value := 0;
Xhi.Value := kMaxFrac shr 1;
end else begin
Xlo.Value := kMaxFrac shr 1;
Xhi.Value := kMaxFrac ;
end;
RenderForm.AzimuthEdit.value := 120;
RenderForm.ElevationEdit.value := 45;
{$ELSE}
Xlo.Value := 0;
Xhi.Value := kMaxFrac shr 1;
{$ENDIF}
gInit := false;
RenderCutoutCheckClick(nil);//PreviewClick(nil);
end;
procedure TCutoutForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
ReadCutoutForm;
//note: exit if no changes
{$IFDEF REND}
RenderForm.RenderRefreshTimer.Tag := -1; //force a new rotation matrix to be generated
RenderForm.RenderRefreshTimer.enabled := true;
{$ENDIF}
end;
procedure TCutoutForm.FormShow(Sender: TObject);
begin
Prep;
end;
procedure TCutoutForm.OKBtnClick(Sender: TObject);
begin
CutoutForm.close;
end;
procedure TCutoutForm.PreviewBtn1Click(Sender: TObject);
begin
ReadCutoutForm;
RenderForm.RenderRefreshTimer.Tag := -1; //force a new rotation matrix to be generated
RenderForm.RenderRefreshTimer.enabled := true;
end;
initialization
{$I cutout.lrs}
end.