-
Notifications
You must be signed in to change notification settings - Fork 3
/
DPFilter.cpp
65 lines (50 loc) · 1.82 KB
/
DPFilter.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
//---------------------------------------------------------------------------
#include <vcl.h>
#include <math.h>
#include <System.IniFiles.hpp>
#pragma hdrstop
#include "DPFilter.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TDPForm *DPForm;
//---------------------------------------------------------------------------
__fastcall TDPForm::TDPForm(TComponent* Owner)
: TForm(Owner)
{
TIniFile *pini = new TIniFile(ChangeFileExt(Application->ExeName, ".ini"));
double dEpsilon = pini->ReadFloat("Douglas-Peucker", "Epsilon", 1.0);
delete pini;
Epsilon->Text = AnsiString(dEpsilon);
}
//---------------------------------------------------------------------------
void __fastcall TDPForm::GoClick(TObject *Sender)
{
if(m_pCurrentTrack && m_pCurrentTrack->PointCount > 2)
{
ProgressBar->Max = m_pCurrentTrack->PointCount * (int)log10((double)m_pCurrentTrack->PointCount);
ProgressBar->Position = 0;
Exit->Enabled = false;
Go->Enabled = false;
TCursor Save_Cursor = Screen->Cursor;
Screen->Cursor = crHourGlass;
DouglasPeucker *pDP = new DouglasPeucker(Handle);
pDP->Epsilon = Epsilon->Text.ToDouble();
TIniFile *pini = new TIniFile(ChangeFileExt(Application->ExeName, ".ini"));
pini->WriteFloat("Douglas-Peucker", "Epsilon", pDP->Epsilon);
delete pini;
pDP->CurrentTrack = m_pCurrentTrack;
pDP->Simplify();
delete pDP;
ProgressBar->Position = 0;
Exit->Enabled = true;
Go->Enabled = true;
Screen->Cursor = Save_Cursor;
}
}
//---------------------------------------------------------------------------
void __fastcall TDPForm::OnPoint(TMessage & msg)
{
if(ProgressBar->Position == ProgressBar->Max) ProgressBar->Position = 0;
ProgressBar->Position = ProgressBar->Position + 1;
}