-
Notifications
You must be signed in to change notification settings - Fork 33
/
intensityfilter.pas
115 lines (94 loc) · 2.61 KB
/
intensityfilter.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
unit intensityfilter;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
ExtCtrls, math;
type
{ TIntensityFilterForm }
TIntensityFilterForm = class(TForm)
ActionDrop: TComboBox;
CancelBtn: TButton;
Panel1: TPanel;
RampAbove: TTrackBar;
RampBelow: TTrackBar;
OKBtn: TButton;
BackShape: TShape;
FrontShape: TShape;
TimerROI: TTimer;
procedure CancelBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
procedure RampChange(Sender: TObject);
procedure TimerROITimer(Sender: TObject);
private
procedure CreateGraph();
procedure IntensityFilter(isUndo: boolean = true);
public
end;
var
IntensityFilterForm: TIntensityFilterForm;
implementation
{$R *.lfm}
uses mainunit;
procedure TIntensityFilterForm.IntensityFilter(isUndo: boolean = true);
begin
if (isUndo) then
GLForm1.voiUndo();
GLForm1.DrawIntensityFilter(RampAbove.position, RampBelow.position, ActionDrop.itemIndex);
end;
{ TIntensityFilterForm }
procedure TIntensityFilterForm.CreateGraph();
var
Lo,Hi, Wid: single;
begin
Lo := min(RampAbove.Position, RampBelow.Position);
Hi := max(RampAbove.Position, RampBelow.Position);
if (RampAbove.Position < RampBelow.Position) then begin
FrontShape.Brush.Color:=clRed;
BackShape.Brush.Color:=clBlack;
end else begin
FrontShape.Brush.Color:=clBlack;
BackShape.Brush.Color:=clRed;
end;
Wid := BackShape.Width;
FrontShape.Left := round((Lo/RampAbove.Max) * Wid)+1;
FrontShape.Width := round(((Hi-Lo)/RampAbove.Max) * Wid)+1;
end;
procedure TIntensityFilterForm.RampChange(Sender: TObject);
begin
if not IntensityFilterForm.visible then exit;
CreateGraph();
TimerROI.Enabled := true;
end;
procedure TIntensityFilterForm.TimerROITimer(Sender: TObject);
begin
if not IntensityFilterForm.visible then exit;
TimerROI.Enabled := false;
IntensityFilter();
end;
procedure TIntensityFilterForm.FormShow(Sender: TObject);
begin
CreateGraph();
IntensityFilter(false);
end;
procedure TIntensityFilterForm.OKBtnClick(Sender: TObject);
var
Lo, Hi: single;
begin
Lo := min(RampAbove.Position, RampBelow.Position)/RampAbove.Max;
Hi := max(RampAbove.Position, RampBelow.Position)/RampAbove.Max;
Self.ModalResult := mrOK;
Self.close;
if ActionDrop.ItemIndex = 2 then begin
GLForm1.voiUndo(true);
GLForm1.ClipIntensity(Lo, Hi);
end;
end;
procedure TIntensityFilterForm.CancelBtnClick(Sender: TObject);
begin
Self.ModalResult := mrCancel;
GLForm1.voiUndo(true);
Self.Hide;
end;
end.