-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDriftFilter.cpp
81 lines (64 loc) · 2.52 KB
/
DriftFilter.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
//---------------------------------------------------------------------------
#include <vcl.h>
#include <System.IniFiles.hpp>
#pragma hdrstop
#include "DriftFilter.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TDriftForm *DriftForm;
//---------------------------------------------------------------------------
__fastcall TDriftForm::TDriftForm(TComponent* Owner)
: TForm(Owner)
{
TIniFile *pini = new TIniFile(ChangeFileExt(Application->ExeName, ".ini"));
int nAperture = pini->ReadInteger("Drift", "Aperture", 50);
double dSpeed = pini->ReadFloat("Drift", "SpeedTh", 1.0);
int nStrength = pini->ReadInteger("Drift", "Strength", 2);
delete pini;
Aperture->Text = AnsiString(nAperture);
Thereshould->Text = AnsiString(dSpeed);
Strength->ItemIndex = nStrength;
}
//---------------------------------------------------------------------------
void __fastcall TDriftForm::OnPoint(TMessage & msg)
{
ProgressBar->Position = ProgressBar->Position + 1;
}
void __fastcall TDriftForm::GoClick(TObject *Sender)
{
if(m_pCurrentTrack)
{
TCursor Save_Cursor = Screen->Cursor;
Screen->Cursor = crHourGlass;
int nAperture = Aperture->Text.ToInt();
double dThereshould = Thereshould->Text.ToDouble();
int nStrength = Strength->ItemIndex;
TIniFile *pini = new TIniFile(ChangeFileExt(Application->ExeName, ".ini"));
pini->WriteInteger("Drift", "Aperture", nAperture);
pini->WriteFloat("Drift", "SpeedTh", dThereshould);
pini->WriteInteger("Drift", "Strength", nStrength);
delete pini;
eStrength FilterStrength[4] = {eExtremely, eHigh, eAverage, eLow};
Drift *pDrift = new Drift(Handle);
pDrift->m_pCurrentTrack = m_pCurrentTrack;
ProgressBar->Max = m_pCurrentTrack->PointCount;
ProgressBar->Position = 0;
Action->Caption = AnsiString("Detecting Drift Intervals...");
int n = pDrift->FindIntervals(nAperture, dThereshould);
ProgressBar->Max = n;
ProgressBar->Position = 0;
Action->Caption = AnsiString("Merging Drift Intervals...");
n = pDrift->MergeIntervals();
ProgressBar->Max = n;
ProgressBar->Position = 0;
Action->Caption = AnsiString("Processing Drift Intervals...");
pDrift->ProcessIntervals(FilterStrength[nStrength]);
delete pDrift;
m_pCurrentTrack->RecalcDistClimb();
Action->Caption = AnsiString("");
ProgressBar->Position = 0;
Screen->Cursor = Save_Cursor;
}
}
//---------------------------------------------------------------------------