-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathLinearDs.cpp
More file actions
127 lines (116 loc) · 3.74 KB
/
LinearDs.cpp
File metadata and controls
127 lines (116 loc) · 3.74 KB
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
//Copyright+LGPL
//-----------------------------------------------------------------------------------------------------------------------------------------------
// Copyright 2000-2013 Makoto Mori, Nobuyuki Oba
//-----------------------------------------------------------------------------------------------------------------------------------------------
// This file is part of MMSSTV.
// MMSSTV is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// MMSSTV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License along with MMTTY. If not, see
// <http://www.gnu.org/licenses/>.
//-----------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ComLib.h"
#include "LinearDs.h"
//---------------------------------------------------------------------
#pragma resource "*.dfm"
//---------------------------------------------------------------------
__fastcall TLinearDspDlg::TLinearDspDlg(TComponent* AOwner)
: TForm(AOwner)
{
FormStyle = ((TForm *)AOwner)->FormStyle;
Font->Name = ((TForm *)AOwner)->Font->Name;
Font->Charset = ((TForm *)AOwner)->Font->Charset;
if( MsgEng ){
Caption = "frequency characteristic";
}
pData = NULL;
}
//---------------------------------------------------------------------
void __fastcall TLinearDspDlg::Execute(double *D)
{
pData = D;
ShowModal();
}
//---------------------------------------------------------------------
void __fastcall TLinearDspDlg::PBoxPaint(TObject *Sender)
{
PBox->Canvas->Font->Size = 8;
int XL = PBox->Canvas->TextWidth("-16000") + 10;
int YT = PBox->Canvas->TextHeight("-16000");
int YB = PBox->Height - YT - 10;
int XR = PBox->Width - (XL/2);
int i, fq, x, y;
char bf[32];
PBox->Canvas->Pen->Color = clGray;
for( fq = 1500, i = 0; i <= 16; i++, fq += 50 ){
x = XL + i * (XR - XL)/16;
PBox->Canvas->Pen->Style = i & 1 ? psDot : psSolid;
PBox->Canvas->MoveTo(x, YT);
PBox->Canvas->LineTo(x, YB);
if( !(i & 1) ){
sprintf(bf, "%4u", fq);
int w = PBox->Canvas->TextWidth(bf)/2;
PBox->Canvas->TextOut(x - w, YB + 5, bf);
}
}
int vm;
if( *pData >= 16000 ){
vm = 20000;
}
else if( *pData >= 10000 ){
vm = 16000;
}
else if( *pData >= 8000 ){
vm = 10000;
}
else if( *pData >= 6000 ){
vm = 8000;
}
else if( *pData >= 5000 ){
vm = 6000;
}
else if( *pData >= 4000 ){
vm = 5000;
}
else if( *pData >= 2000 ){
vm = 4000;
}
else if( *pData >= 1000 ){
vm = 2000;
}
else {
vm = 1000;
}
fq = vm;
for( i = 0; i <= 4; i++, fq -= (vm / 2) ){
y = YT + i * (YB - YT)/4;
PBox->Canvas->Pen->Style = i & 1 ? psDot : psSolid;
PBox->Canvas->MoveTo(XL, y);
PBox->Canvas->LineTo(XR, y);
sprintf(bf, "%d", fq);
int w = PBox->Canvas->TextWidth(bf);
int h = PBox->Canvas->TextHeight(bf);
if( i < 4 ) h /= 2;
PBox->Canvas->TextOut(XL-w-3, y - h, bf);
}
if( pData == NULL ) return;
PBox->Canvas->Pen->Color = clBlue;
PBox->Canvas->Pen->Style = psSolid;
for( i = 0; i <= 16; i++ ){
x = XL + i * (XR - XL)/16;
y = pData[i] * (YB - YT) / (vm * 2);
y += (YB - YT)/2;
y = YB - y;
if( i ){
PBox->Canvas->LineTo(x, y);
}
else {
PBox->Canvas->MoveTo(x, y);
}
}
}
//---------------------------------------------------------------------------