MathgeomGLS

Форк
0
/
fVolumeY.pas 
332 строки · 7.9 Кб
1
unit fVolumeY;
2

3
interface
4

5
uses
6
  Winapi.Windows,
7
  Winapi.Messages,
8
  System.SysUtils,
9
  System.Variants,
10
  System.Classes,
11
  System.Math,
12
  Vcl.Clipbrd,
13
  Vcl.Graphics,
14
  Vcl.Controls,
15
  Vcl.Forms,
16
  Vcl.Dialogs,
17
  Vcl.Menus,
18
  Vcl.StdCtrls,
19
  Vcl.Buttons,
20
  Vcl.ComCtrls,
21
  Vcl.ExtCtrls;
22

23
type
24
  TVolumeYForm = class(TForm)
25
    Label3: TLabel;
26
    Label4: TLabel;
27
    Label5: TLabel;
28
    Label6: TLabel;
29
    Label1: TLabel;
30
    Label2: TLabel;
31
    Label7: TLabel;
32
    Label8: TLabel;
33
    PositiveButton: TSpeedButton;
34
    NegativeButton: TSpeedButton;
35
    TotalVolumeLabel: TLabel;
36
    EditIntegMin: TEdit;
37
    EditIntegMax: TEdit;
38
    EditCount: TEdit;
39
    UpDown1: TUpDown;
40
    EditOpacity: TEdit;
41
    UpDown2: TUpDown;
42
    RecalcBtn: TBitBtn;
43
    CloseBtn: TBitBtn;
44
    KeepRangeCheckBox: TCheckBox;
45
    ColorDialog: TColorDialog;
46
    HideFunctionCheckBox: TCheckBox;
47
    PositivePanel: TPanel;
48
    NegativePanel: TPanel;
49
    SurfaceAreaLabel: TLabel;
50
    procedure FormShow(Sender: TObject);
51
    procedure FormActivate(Sender: TObject);
52
    procedure FormKeyPress(Sender: TObject; var Key: Char);
53
    procedure FormDeactivate(Sender: TObject);
54
    procedure ParseKeyPress(Sender: TObject; var Key: Char);
55
    procedure IntKeyPress(Sender: TObject; var Key: Char);
56
    procedure EditIntegMinKeyUp(Sender: TObject; var Key: Word;
57
                                 Shift: TShiftState);
58
    procedure EditIntegMaxKeyUp(Sender: TObject; var Key: Word;
59
                                 Shift: TShiftState);
60
    procedure EditCountKeyUp(Sender: TObject; var Key: Word;
61
                              Shift: TShiftState);
62
    procedure EditOpacityKeyUp(Sender: TObject; var Key: Word;
63
                                Shift: TShiftState);
64
    procedure UpDown1Click(Sender: TObject; Button: TUDBtnType);
65
    procedure UpDown2Click(Sender: TObject; Button: TUDBtnType);
66
    procedure UpDown1MouseUp(Sender: TObject; Button: TMouseButton;
67
                              Shift: TShiftState; X, Y: Integer);
68
    procedure PositiveButtonClick(Sender: TObject);
69
    procedure NegativeButtonClick(Sender: TObject);
70
    procedure RecalcBtnClick(Sender: TObject);
71
    procedure IntegLabelClick(Sender: TObject);
72
    procedure KeepRangeCheckBoxClick(Sender: TObject);
73
    procedure CloseBtnClick(Sender: TObject);
74
    procedure HideFunctionCheckBoxClick(Sender: TObject);
75
  private
76
    procedure UpdateRangeData;
77
  public
78
    procedure ShowData;
79
  end;
80

81
var
82
  VolumeYForm: TVolumeYForm;
83

84
//=================================================================
85
implementation
86
//=================================================================
87

88
uses
89
  uParser,
90
  uGlobal,
91
  fFuncts,
92
  fPlot1D;
93

94
{$R *.dfm}
95

96
procedure TVolumeYForm.FormShow(Sender: TObject);
97
begin
98
  KeepRangeCheckBox.Checked := KeepRange;
99
  ShowData;
100
end;
101

102
procedure TVolumeYForm.HideFunctionCheckBoxClick(Sender: TObject);
103
begin
104
  MainForm.GLViewer.Invalidate;
105
end;
106

107
procedure TVolumeYForm.FormActivate(Sender: TObject);
108
begin
109
  EditIntegMin.SetFocus;
110
  EditIntegMin.SelText;
111
end;
112

113
procedure TVolumeYForm.FormKeyPress(Sender: TObject; var Key: Char);
114
begin
115
  case Key of
116
#13:begin
117
      RecalcBtnClick(Sender);
118
      Key := #0;
119
    end;
120
#27:begin
121
      Key := #0;
122
      Close;
123
    end;
124
  end;
125
end;
126

127
procedure TVolumeYForm.FormDeactivate(Sender: TObject);
128
begin
129
  if KeepRange then UpdateRangeData;
130
end;
131

132
procedure TVolumeYForm.ParseKeyPress(Sender: TObject; var Key: Char);
133
begin
134
  with Sender as TEdit do
135
  begin
136
    if not CharInSet(UpCase(Key),
137
   [' ', '!', '(', ')', '*', '+', '-', '.', ',', '/', '0'..'9',
138
    'A'..'C', 'E', 'G'..'I', 'L', 'N'..'T', 'X', '^', '`', #8]) then
139
    begin
140
      Key := #0;
141
      Exit;
142
    end;
143
    if Key = '`' then Key := '�';
144
  end;
145
end;
146

147
procedure TVolumeYForm.RecalcBtnClick(Sender: TObject);
148
begin
149
  MainForm.GLViewer.Invalidate;
150
end;
151

152
procedure TVolumeYForm.IntegLabelClick(Sender: TObject);
153
begin
154
  Clipboard.Clear;
155
  with Sender as TLabel do
156
  Clipboard.AsText := Copy(Caption,  pos('=', Caption)+2, Length(Caption));
157
end;
158

159
procedure TVolumeYForm.IntKeyPress(Sender: TObject; var Key: Char);
160
begin
161
  with Sender as TEdit do
162
  if not CharInSet(Key, ['0'..'9', #8]) then Key := #0
163
end;
164

165
procedure TVolumeYForm.KeepRangeCheckBoxClick(Sender: TObject);
166
begin
167
  KeepRange := KeepRangeCheckBox.Checked;
168
end;
169

170
procedure TVolumeYForm.NegativeButtonClick(Sender: TObject);
171
begin
172
  ColorDialog.Color := GraphData.NegAreaColor;
173
  if ColorDialog.Execute then
174
  begin
175
    GraphData.NegAreaColor := ColorDialog.Color;
176
    NegativePanel.Color := GraphData.NegAreaColor;
177
    MainForm.GLViewer.Invalidate;
178
    Altered := TRUE
179
  end;
180
end;
181

182
procedure TVolumeYForm.PositiveButtonClick(Sender: TObject);
183
begin
184
  ColorDialog.Color := GraphData.PosAreaColor;
185
  if ColorDialog.Execute then
186
  begin
187
    GraphData.PosAreaColor := ColorDialog.Color;
188
    PositivePanel.Color := GraphData.PosAreaColor;
189
    MainForm.GLViewer.Invalidate;
190
    Altered := TRUE
191
  end;
192
end;
193

194
procedure TVolumeYForm.UpDown1Click(Sender: TObject; Button: TUDBtnType);
195
var
196
  k: word;
197

198
begin
199
  k := 0;
200
  EditCountKeyUp(Sender, k, []);
201
end;
202

203
procedure TVolumeYForm.UpDown1MouseUp(Sender: TObject; Button: TMouseButton;
204
                                       Shift: TShiftState; X, Y: Integer);
205
begin
206
  RecalcBtnClick(Sender);
207
end;
208

209
procedure TVolumeYForm.UpDown2Click(Sender: TObject; Button: TUDBtnType);
210
var
211
  k: word;
212

213
begin
214
  k := 0;
215
  EditOpacityKeyUp(Sender, k, []);
216
end;
217

218
procedure TVolumeYForm.EditIntegMinKeyUp(Sender: TObject; var Key: Word;
219
                                         Shift: TShiftState);
220
var
221
  s: string;
222
  e: byte;
223

224
begin
225
  s := ScanText(EditIntegMin.Text);
226
  IntegMin := ParseAndEvaluate(s, e);
227
//if isNAN(IntegMin) then IntegMin := 0;
228
//if e > 0 then IntegMin := 0;
229
  if isNAN(IntegMin) or isInfinite(IntegMin) or (e > 0) then IntegMin := 0;
230
end;
231

232
procedure TVolumeYForm.EditIntegMaxKeyUp(Sender: TObject; var Key: Word;
233
                                         Shift: TShiftState);
234
var
235
  s: string;
236
  e: byte;
237

238
begin
239
  s := ScanText(EditIntegMax.Text);
240
  IntegMax := ParseAndEvaluate(s, e);
241
//if isNAN(IntegMax) then IntegMax := 0;
242
//if e > 0 then IntegMax := 0;
243
  if isNAN(IntegMax) or isInfinite(IntegMax) or (e > 0) then IntegMax := 0;
244
end;
245

246
procedure TVolumeYForm.CloseBtnClick(Sender: TObject);
247
begin
248
  Close;
249
end;
250

251
procedure TVolumeYForm.EditCountKeyUp(Sender: TObject; var Key: Word;
252
                                      Shift: TShiftState);
253
begin
254
  with GraphData do
255
  begin
256
    try
257
      IntegCount := StrToInt(EditCount.Text);
258
      if IntegCount = 0 then IntegCount := IntegCountPos;
259
    except
260
      IntegCount := IntegCountPos;
261
    end;
262
    if IntegCount > IntegCountMax then IntegCount := IntegCountMax;
263
  end;
264
  Altered := true;
265
end;
266

267
procedure TVolumeYForm.EditOpacityKeyUp(Sender: TObject; var Key: Word;
268
                                        Shift: TShiftState);
269
var
270
  n: integer;
271

272
begin
273
  try
274
    n := StrToInt(EditOpacity.Text);
275
  except
276
    n := 1;
277
  end;
278
  GraphData.AreaAlpha := n/100;
279
  Altered := true;
280
  MainForm.GLViewer.Invalidate;
281
end;
282

283
procedure TVolumeYForm.UpdateRangeData;
284
begin
285
  KeptMin := IntegMin;
286
  KeptMax := IntegMax;
287
end;
288

289
procedure TVolumeYForm.ShowData;
290
begin
291
  with GraphData, PlotData do
292
  begin
293
    EditCount.Text := IntToStr(IntegCount);
294
    UpDown2.Position := round(AreaAlpha*100);
295
    if TextStr = '' then Caption := '' else Caption := 'y = '+TextStr;
296

297
    KeepRangeCheckBox.Checked := KeepRange;
298
    PositivePanel.Color := PosAreaColor;
299
    NegativePanel.Color := NegAreaColor;
300

301
    if IsSegment then
302
    begin
303
      if KeepRange then
304
      begin
305
        IntegMin := KeptMin;
306
        IntegMax := KeptMax;
307
      end
308
      else
309
      begin
310
        IntegMin := SegMin;
311
        IntegMax := SegMax;
312
      end;
313
    end
314
    else
315
    begin
316
      if KeepRange then
317
      begin
318
        IntegMin := KeptMin;
319
        IntegMax := KeptMax;
320
      end
321
      else
322
      begin
323
        IntegMin := xMin;
324
        IntegMax := xMax;
325
      end;
326
    end;
327
  end;
328
  EditIntegMin.Text := FloatToStrF(IntegMin, ffGeneral, 13, 4);
329
  EditIntegMax.Text := FloatToStrF(IntegMax, ffGeneral, 13, 4);
330
end;
331

332
end.
333

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.