Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
unit Unit1;
2
 
3
interface
4
 
5
uses
6
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
  Dialogs, StdCtrls, ExtCtrls, OleCtrls, VCFI, Menus;
8
 
9
type
10
  TForm1 = class(TForm)
11
    vykreslit: TButton;
12
    Button2: TButton;
13
    reset: TButton;
14
    vypis: TButton;
15
    Obrazovka: TPaintBox;
16
    Posuv: TScrollBar;
17
    ScrollBar2: TScrollBar;
18
    ScrollBar3: TScrollBar;
19
    zoom: TScrollBar;
20
    StaticText1: TStaticText;
21
    procedure vykreslitClick(Sender: TObject);
22
 
23
    procedure obrazovkaShow(Sender: TObject);
24
    procedure Button2Click(Sender: TObject);
25
    procedure resetClick(Sender: TObject);
26
    procedure vypisClick(Sender: TObject);
27
    procedure ScrollBar2Change(Sender: TObject);
28
    procedure ScrollBar3Change(Sender: TObject);
29
    procedure zoomChange(Sender: TObject);
30
    procedure PosuvChange(Sender: TObject);
31
    procedure Button1Click(Sender: TObject);
32
 
33
   private
34
    { Private declarations }
35
  public
36
procedure smazat;
37
    { Public declarations }
38
  end;
39
 
40
const
41
  MAX=455;
42
  pametMAX=6*MAX;
43
var
44
  Form1: TForm1;
45
  PobrazovkaYMIN: array [0..MAX] of word;
46
  PobrazovkaYMAX: array [0..MAX] of word;
47
  pamet: array[0..pametMAX{,0..pametMAX}]of word;
48
 
49
implementation
50
 
51
uses Unit2;
52
 
53
{$R *.dfm}
54
 
55
procedure Tform1.smazat;
56
begin
57
  Form1.Canvas.Pen.Mode:=pmNop;
58
 
59
  Form1.Obrazovka.Canvas.Brush.Color:=clblack;
60
  Form1.Obrazovka.Canvas.Rectangle(0,0,455,256);
61
  Form1.Obrazovka.Canvas.Pen.Color:=cllime;
62
end;
63
 
64
procedure Draw;
65
var
66
 x: word;
67
begin
68
 
69
  Form1.Obrazovka.Canvas.MoveTo(0,PobrazovkaYMAX[0]);
70
  for x:=1 to MAX do
71
  begin
72
    Form1.Obrazovka.Canvas.LineTo(x,PobrazovkaYMAX[x]);
73
    Form1.Obrazovka.Canvas.LineTo(x,PobrazovkaYMIN[x]);
74
  end
75
end;
76
 
77
procedure TForm1.vykreslitClick(Sender: TObject);
78
  (*  ble:extended;*)
79
var i,x: integer;
80
begin
81
 
82
  smazat;
83
  for x:=0 to pametMAX do
84
   begin
85
     pamet[x]:=random(200); //round((sin(x/1)*100)+100);
86
   end;
87
  PosuvChange(Self);
88
end;
89
 
90
 
91
procedure TForm1.obrazovkaShow(Sender: TObject);
92
begin
93
  smazat;
94
end;
95
 
96
procedure TForm1.Button2Click(Sender: TObject);
97
var n: integer;
98
begin
99
  n:=0;
100
  while n<256 do
101
  begin
102
    Obrazovka.Canvas.Pen.Color:=clYellow;
103
    Obrazovka.Canvas.MoveTo(0,n);
104
    Obrazovka.Canvas.LineTo(455,n);
105
    n:=n+70;
106
  end;
107
  n:=0;
108
  while n<455 do
109
  begin
110
    Obrazovka.Canvas.Pen.Color:=clSilver;
111
    Obrazovka.Canvas.MoveTo(n,0);
112
    Obrazovka.Canvas.LineTo(n,455);
113
    n:=n+70;
114
  end;
115
  Obrazovka.Canvas.Pen.Color:=cllime
116
end;
117
 
118
procedure TForm1.resetClick(Sender: TObject);
119
var j:word;
120
begin
121
  smazat;
122
  for j:=0 to MAX do
123
  PobrazovkaYMIN[j]:=0;
124
  PobrazovkaYMAX[j]:=0;
125
  for j:=0 to pametMAX do
126
  pamet[j]:=0;
127
end;
128
 
129
procedure TForm1.vypisClick(Sender: TObject);
130
var faut:TextFile;
131
    x:word;
132
    ble: string;
133
begin
134
  Form2.ShowModal;
135
  if Form2.Edit1.Text<>'' then
136
  begin
137
    AssignFile(faut,Form2.Edit1.Text);
138
    Rewrite(faut);
139
 
140
    for x:=0 to 455 do
141
    begin
142
      str(x,ble);
143
      Write(faut,'x='+ble+',');
144
      str(PobrazovkaYMIN[x],ble);
145
      Write(faut,'Ymin='+ble+',');
146
      str(PobrazovkaYMAX[x],ble);
147
      Writeln(faut,'Ymax='+ble+'; ');
148
    end;
149
    CloseFile(faut);
150
  end
151
end;
152
 
153
 
154
procedure TForm1.ScrollBar2Change(Sender: TObject);
155
 var
156
   xold:word;
157
   zoom: integer;
158
   code: integer;
159
begin
160
  xold:=ScrollBar2.Position;
161
 
162
  Obrazovka.Canvas.Pen.Color:=clred;
163
  Obrazovka.Canvas.Pen.Mode:=pmNotXor;
164
  Form1.Obrazovka.Canvas.MoveTo(xold,Obrazovka.Height);
165
  Form1.Obrazovka.Canvas.LineTo(xold,0);
166
 
167
end;
168
 
169
procedure TForm1.ScrollBar3Change(Sender: TObject);
170
var
171
  x,y:word;
172
begin
173
  obrazovka.Canvas.Pen.Color:=clred;
174
  obrazovka.Canvas.Pen.Mode:=pmNotXor;
175
  Form1.obrazovka.Canvas.MoveTo(0,ScrollBar3.Position);
176
  Form1.obrazovka.Canvas.LineTo(obrazovka.Width,ScrollBar3.Position);
177
  obrazovka.Canvas.Pen.Mode:=pmNop;
178
end;
179
 
180
procedure TForm1.zoomChange(Sender: TObject);
181
var
182
  zoom, Xpamet, Xobraz, i, Ymax, Ymin : word;
183
begin
184
  zoom:=Form1.zoom.Position;
185
  Xpamet:=Posuv.Position;
186
 
187
  Xobraz:=0;
188
  while Xpamet < pametMAX do
189
  begin
190
    Ymax:=pamet[Xpamet];
191
    Ymin:=pamet[Xpamet];
192
    for i:=Xpamet to Xpamet+(zoom-1) do
193
      begin
194
        if pamet[Xpamet]<Ymin then Ymin:=pamet[Xpamet]
195
          else if pamet[Xpamet]>Ymax then Ymax:=pamet[Xpamet]
196
      end;
197
  end;
198
  smazat;
199
  Draw;
200
end;
201
 
202
procedure TForm1.PosuvChange(Sender: TObject);
203
begin
204
  Posuv.Max:=pametMAX-MAX;
205
  zoomChange(Self);
206
end;
207
 
208
procedure TForm1.Button1Click(Sender: TObject);
209
begin
210
 smazat;
211
end;
212
 
213
end.