-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormWaveParams.cpp
102 lines (82 loc) · 3.18 KB
/
FormWaveParams.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
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <algorithm>
#include "FormWaveParams.h"
using std::min;
using std::max;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
//TfrmWaveParameters *frmWaveParameters;
//---------------------------------------------------------------------------
__fastcall TfrmWaveParameters::TfrmWaveParameters(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmWaveParameters::actOKExecute(TObject *Sender)
{
ModalResult = mrOk;
}
//---------------------------------------------------------------------------
void __fastcall TfrmWaveParameters::actOKUpdate(TObject *Sender)
{
TAction& Act = static_cast<TAction&>( *Sender );
Act.Enabled = IsPeakDetMinDurationValid() && IsPeakDetConfidenceValid() &&
IsPeakMinDetectionTimeDistanceValid();
}
//---------------------------------------------------------------------------
void __fastcall TfrmWaveParameters::actCancelExecute(TObject *Sender)
{
ModalResult = mrCancel;
}
//---------------------------------------------------------------------------
bool TfrmWaveParameters::IsPeakDetMinDurationValid() const
{
auto Val = edtPeakDetMinDuration->Text.ToIntDef( -1 );
return Val >= 20 && Val <= 500;
}
//---------------------------------------------------------------------------
bool TfrmWaveParameters::IsPeakDetConfidenceValid() const
{
auto Val = edtPeakDetConf->Text.ToIntDef( -1 );
return Val >= 10 && Val <= 100;
}
//---------------------------------------------------------------------------
bool TfrmWaveParameters::IsPeakMinDetectionTimeDistanceValid() const
{
auto Val = edtPeakDetMinDuration->Text.ToIntDef( -1 );
return Val >= 0 && Val <= 10000;
}
//---------------------------------------------------------------------------
int TfrmWaveParameters::GetPeakDetectionMinDuration() const
{
return min( max( edtPeakDetMinDuration->Text.ToIntDef( 70 ), 20 ), 500 );
}
//---------------------------------------------------------------------------
void TfrmWaveParameters::SetPeakDetectionMinDuration( int Val )
{
edtPeakDetMinDuration->Text = Val;
}
//---------------------------------------------------------------------------
int TfrmWaveParameters::GetPeakDetectionConfidence() const
{
return min( max( edtPeakDetConf->Text.ToIntDef( 80 ), 10 ), 100 );
}
//---------------------------------------------------------------------------
void TfrmWaveParameters::SetPeakDetectionConfidence( int Val )
{
edtPeakDetConf->Text = Val;
}
//---------------------------------------------------------------------------
int TfrmWaveParameters::GetPeakMinDetectionTimeDistance() const
{
return min( max( edtPeakDMinDetectionTimeDistance->Text.ToIntDef( 70 ), 0 ), 10000 );
}
//---------------------------------------------------------------------------
void TfrmWaveParameters::SetPeakMinDetectionTimeDistance( int Val )
{
edtPeakDMinDetectionTimeDistance->Text = Val;
}
//---------------------------------------------------------------------------