root / UFResBesGestT.pas @ 5
Historique | Voir | Annoter | Télécharger (27,221 ko)
1 | 3 | avalancogn | unit UFResBesGestT;
|
---|---|---|---|
2 | |||
3 | interface
|
||
4 | |||
5 | uses
|
||
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
||
7 | Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, CheckLst, Menus, Printers, |
||
8 | Math, Contnrs, PBNumEdit, PBSuperSpin, Grids, TeEngine, Series, TeeProcs, |
||
9 | Chart, TeeEdit, UVariables, gnugettext; |
||
10 | |||
11 | type
|
||
12 | TFResBesGestT = class(TForm)
|
||
13 | PC: TPageControl; |
||
14 | TabNRJ: TTabSheet; |
||
15 | TabAA: TTabSheet; |
||
16 | CBAA1: TComboBox; |
||
17 | CBAA3: TComboBox; |
||
18 | CBAA4: TComboBox; |
||
19 | CBAA2: TComboBox; |
||
20 | GBAAT: TGroupBox; |
||
21 | GBAAY: TGroupBox; |
||
22 | GBAAX: TGroupBox; |
||
23 | Graph: TChart; |
||
24 | GBNRJX: TGroupBox; |
||
25 | GBNRJY: TGroupBox; |
||
26 | CBNRJ3: TComboBox; |
||
27 | CBNRJ4: TComboBox; |
||
28 | GBNRJT: TGroupBox; |
||
29 | CBNRJ1: TComboBox; |
||
30 | CBNRJ2: TComboBox; |
||
31 | LBAA: TListBox; |
||
32 | LBNRJ: TListBox; |
||
33 | TSAli: TTabSheet; |
||
34 | GBAli1: TGroupBox; |
||
35 | GBAli2: TGroupBox; |
||
36 | GBAli3: TGroupBox; |
||
37 | GBAliMoy: TGroupBox; |
||
38 | PBDuree2: TPBNumEdit; |
||
39 | LAliDuree: TLabel; |
||
40 | LAliQuantite: TLabel; |
||
41 | PBQuantite2: TPBNumEdit; |
||
42 | PBDuree1: TPBSuperSpin; |
||
43 | PBQuantite1: TPBSuperSpin; |
||
44 | PBDureeMoy: TPBNumEdit; |
||
45 | PBQuantiteMoy: TPBNumEdit; |
||
46 | PBDuree3: TPBSuperSpin; |
||
47 | PBQuantite3: TPBSuperSpin; |
||
48 | GBAliX: TGroupBox; |
||
49 | CBAli2: TComboBox; |
||
50 | PM: TPopupMenu; |
||
51 | MI3D: TMenuItem; |
||
52 | MIPreview: TMenuItem; |
||
53 | MIPrint: TMenuItem; |
||
54 | PD: TPrintDialog; |
||
55 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
||
56 | procedure FormShow(Sender: TObject);
|
||
57 | procedure PCChange(Sender: TObject);
|
||
58 | procedure CBNRJ1Change(Sender: TObject);
|
||
59 | procedure CBNRJ2Change(Sender: TObject);
|
||
60 | procedure CBNRJ3Change(Sender: TObject);
|
||
61 | procedure CBNRJ4Change(Sender: TObject);
|
||
62 | procedure CBAA1Change(Sender: TObject);
|
||
63 | procedure CBAA2Change(Sender: TObject);
|
||
64 | procedure CBAA3Change(Sender: TObject);
|
||
65 | procedure CBAA4Change(Sender: TObject);
|
||
66 | procedure PBDuree1Change(Sender: TObject);
|
||
67 | procedure PBDuree3Change(Sender: TObject);
|
||
68 | procedure PBQuantite1Change(Sender: TObject);
|
||
69 | procedure PBQuantite3Change(Sender: TObject);
|
||
70 | procedure CBAli2Change(Sender: TObject);
|
||
71 | procedure MI3DClick(Sender: TObject);
|
||
72 | procedure MIPreviewClick(Sender: TObject);
|
||
73 | procedure MIPrintClick(Sender: TObject);
|
||
74 | procedure FormCreate(Sender: TObject);
|
||
75 | procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND; |
||
76 | private
|
||
77 | { D?clarations priv?es }
|
||
78 | ListNRJ : TStrings ; |
||
79 | PieNRJ : TPieSeries ; |
||
80 | AreaNRJ : array of TAreaSeries ; |
||
81 | LineNRJ : TLineSeries ; |
||
82 | ListAA : TStrings ; |
||
83 | BarAA35 : THorizBarSeries ; |
||
84 | BarAA105 : THorizBarSeries ; |
||
85 | AreaAA : array of TAreaSeries ; |
||
86 | LineAA : TLineSeries ; |
||
87 | LineAli : array[1..2] of TLineSeries ; |
||
88 | procedure ResetGraph ;
|
||
89 | procedure InitNRJ ;
|
||
90 | procedure AffGraphNRJ ;
|
||
91 | procedure InitAA ;
|
||
92 | procedure AffGraphAA ;
|
||
93 | procedure InitAli ;
|
||
94 | procedure AffGraphAli ;
|
||
95 | public
|
||
96 | { D?clarations publiques }
|
||
97 | end;
|
||
98 | |||
99 | var
|
||
100 | FResBesGestT: TFResBesGestT; |
||
101 | |||
102 | implementation
|
||
103 | |||
104 | uses
|
||
105 | UStrings, UFindRec, UUtil, UEchelle, UFBesGestT, UFPrevGraph, UFWarning; |
||
106 | |||
107 | {$R *.dfm}
|
||
108 | |||
109 | { TFResBesGestT }
|
||
110 | |||
111 | procedure TFResBesGestT.FormCreate(Sender: TObject);
|
||
112 | begin
|
||
113 | if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
||
114 | then
|
||
115 | Font.Name := 'Arial Unicode MS';
|
||
116 | TranslateComponent(Self); |
||
117 | Constraints.MinWidth := 544 + (Width - ClientWidth);
|
||
118 | Width := 640;
|
||
119 | Constraints.MinHeight := 400 + (Height - ClientHeight);
|
||
120 | Height := 480;
|
||
121 | CBAli2.ItemIndex := 0;
|
||
122 | CBNRJ1.ItemIndex := 0;
|
||
123 | CBNRJ2.ItemIndex := 0;
|
||
124 | CBNRJ3.ItemIndex := 0;
|
||
125 | CBNRJ4.Items.Add(Format('%s/%s', [StrMJ, StrJ]));
|
||
126 | CBNRJ4.Items.Add('%');
|
||
127 | CBNRJ4.ItemIndex := 0;
|
||
128 | CBAA1.ItemIndex := 0;
|
||
129 | CBAA2.ItemIndex := 0;
|
||
130 | CBAA3.ItemIndex := 0;
|
||
131 | CBAA4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
||
132 | CBAA4.Items.Add('%');
|
||
133 | CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
||
134 | CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrMJ, StrED]));
|
||
135 | CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrMJ, StrEM]));
|
||
136 | CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrMJ, StrEN]));
|
||
137 | CBAA4.ItemIndex := 0;
|
||
138 | end;
|
||
139 | |||
140 | procedure TFResBesGestT.FormShow (Sender : TObject) ;
|
||
141 | begin
|
||
142 | MIPrint.Enabled := IsComplete or IsEducation ;
|
||
143 | // Aliment
|
||
144 | InitAli ; |
||
145 | // Energie
|
||
146 | InitNRJ ; |
||
147 | // Acides Amin?s
|
||
148 | InitAA ; |
||
149 | // Initialisation des valeurs
|
||
150 | PBDureeMoy.AsInteger := DureeGest ; |
||
151 | PBQuantiteMoy.AsFloat := FBesGestT.PBAliment.AsFloat ; |
||
152 | case TypeAliGest of |
||
153 | 0 : // Une p?riode - Quantit? constante |
||
154 | begin
|
||
155 | PBDuree2.AsInteger := PBDureeMoy.AsInteger ; |
||
156 | PBQuantite1.AsFloat := PBQuantiteMoy.AsFloat ; |
||
157 | PBQuantite3.AsFloat := PBQuantiteMoy.AsFloat ; |
||
158 | end ;
|
||
159 | 1 : // Deux p?riodes - Quantit? finale fix?e |
||
160 | begin
|
||
161 | PBDuree3.AsInteger := Duree3 ; |
||
162 | PBQuantite1.AsFloat := PBQuantiteMoy.AsFloat ; |
||
163 | PBQuantite3.AsFloat := Quantite3 ; |
||
164 | end ;
|
||
165 | 2 : // Deux p?riodes - Augmentation fix?e |
||
166 | begin
|
||
167 | PBDuree3.AsInteger := Duree3 ; |
||
168 | PBQuantite1.AsFloat := PBQuantiteMoy.AsFloat ; |
||
169 | PBQuantite3.AsFloat := (PBQuantiteMoy.AsFloat * PBDureeMoy.AsInteger |
||
170 | + Augment * PBDuree2.AsInteger) |
||
171 | / (PBDuree2.AsInteger + Duree3) ; |
||
172 | end ;
|
||
173 | 3 : // Trois p?riodes - Augmentation et quantit? finale fix?es |
||
174 | begin
|
||
175 | PBDuree1.AsInteger := Duree1 ; |
||
176 | PBDuree3.AsInteger := Duree3 ; |
||
177 | PBQuantite3.AsFloat := Quantite3 ; |
||
178 | PBQuantite1.AsFloat := (PBQuantiteMoy.AsFloat * PBDureeMoy.AsInteger |
||
179 | - (Quantite3 - Augment) * PBDuree2.AsInteger |
||
180 | - Quantite3 * Duree3) |
||
181 | / Duree1 ; |
||
182 | end ;
|
||
183 | 4 : // Trois p?riodes - Quantit?s des p?riodes 2 et 3 fix?es |
||
184 | begin
|
||
185 | PBDuree1.AsInteger := Duree1 ; |
||
186 | PBDuree3.AsInteger := Duree3 ; |
||
187 | PBQuantite3.AsFloat := Quantite3 ; |
||
188 | PBQuantite1.AsFloat := (PBQuantiteMoy.AsFloat * PBDureeMoy.AsInteger |
||
189 | - Quantite2 * PBDuree2.AsInteger |
||
190 | - Quantite3 * Duree3) |
||
191 | / Duree1 ; |
||
192 | end ;
|
||
193 | 5 : // Trois p?riodes - Augmentation et quantit? initiale fix?es |
||
194 | begin
|
||
195 | PBDuree1.AsInteger := Duree1 ; |
||
196 | PBDuree3.AsInteger := Duree3 ; |
||
197 | PBQuantite1.AsFloat := Quantite1 ; |
||
198 | PBQuantite3.AsFloat := (PBQuantiteMoy.AsFloat * PBDureeMoy.AsInteger |
||
199 | - Quantite1 * Duree1 |
||
200 | + Augment * PBDuree2.AsInteger) |
||
201 | / (Duree3 + PBDuree2.AsInteger) ; |
||
202 | end ;
|
||
203 | end ;
|
||
204 | // Affichage principal
|
||
205 | PC.ActivePageIndex := 0 ;
|
||
206 | PCChange (nil) ;
|
||
207 | end ;
|
||
208 | |||
209 | procedure TFResBesGestT.FormClose (Sender : TObject ; var Action : TCloseAction) ; |
||
210 | var
|
||
211 | i : integer ; |
||
212 | begin
|
||
213 | // Aliment
|
||
214 | for i := 1 to 2 do |
||
215 | LineAli[i].Free ; |
||
216 | // Energie
|
||
217 | LineNRJ.Free ; |
||
218 | for i := 0 to ListNRJ.Count - 1 do |
||
219 | AreaNRJ[i].Free ; |
||
220 | SetLength (AreaNRJ, 0) ;
|
||
221 | PieNRJ.Free ; |
||
222 | ListNRJ.Free ; |
||
223 | // Acides Amin?s
|
||
224 | LineAA.Free ; |
||
225 | for i := 0 to ListAA.Count - 1 do |
||
226 | AreaAA[i].Free ; |
||
227 | SetLength (AreaAA, 0) ;
|
||
228 | BarAA35.Free ; |
||
229 | BarAA105.Free ; |
||
230 | ListAA.Free ; |
||
231 | end ;
|
||
232 | |||
233 | procedure TFResBesGestT.PCChange (Sender : TObject) ;
|
||
234 | begin
|
||
235 | case PC.ActivePageIndex of |
||
236 | 0 : // Aliment |
||
237 | AffGraphAli ; |
||
238 | 1 : // Energie |
||
239 | AffGraphNRJ ; |
||
240 | 2 : // Acides Amin?s |
||
241 | AffGraphAA ; |
||
242 | end ;
|
||
243 | end ;
|
||
244 | |||
245 | procedure TFResBesGestT.ResetGraph ;
|
||
246 | var
|
||
247 | i : integer ; |
||
248 | begin
|
||
249 | Graph.UndoZoom ; |
||
250 | Graph.View3D := FALSE ; |
||
251 | Graph.Legend.Visible := TRUE ; |
||
252 | Graph.Legend.Inverted := TRUE ; |
||
253 | Graph.Title.Text.Clear ; |
||
254 | Graph.SubTitle.Text.Clear ; |
||
255 | Graph.LeftAxis.Automatic := FALSE ; |
||
256 | Graph.BottomAxis.MinimumOffset := 0;
|
||
257 | Graph.BottomAxis.MaximumOffset := 0;
|
||
258 | // Aliment
|
||
259 | for i := 1 to 2 do |
||
260 | LineAli[i].Active := FALSE ; |
||
261 | // Energie
|
||
262 | PieNRJ.Active := FALSE ; |
||
263 | for i := 0 to ListNRJ.Count - 1 do |
||
264 | AreaNRJ[i].Active := FALSE ; |
||
265 | LineNRJ.Active := FALSE ; |
||
266 | // Acides Amin?s
|
||
267 | BarAA35.Active := FALSE ; |
||
268 | BarAA105.Active := FALSE ; |
||
269 | for i := 0 to ListAA.Count - 1 do |
||
270 | AreaAA[i].Active := FALSE ; |
||
271 | LineAA.Active := FALSE ; |
||
272 | end ;
|
||
273 | |||
274 | procedure TFResBesGestT.MI3DClick (Sender : TObject) ;
|
||
275 | begin
|
||
276 | Graph.View3D := not (Graph.View3D) ;
|
||
277 | end ;
|
||
278 | |||
279 | procedure TFResBesGestT.MIPreviewClick (Sender : TObject) ;
|
||
280 | begin
|
||
281 | FPrevGraph := TFPrevGraph.Create (Self) ; |
||
282 | with FPrevGraph do |
||
283 | begin
|
||
284 | TPPGraph.Panels.Add (Graph) ; |
||
285 | ShowModal ; |
||
286 | Release ; |
||
287 | end ;
|
||
288 | end ;
|
||
289 | |||
290 | procedure TFResBesGestT.MIPrintClick (Sender : TObject) ;
|
||
291 | begin
|
||
292 | if PD.Execute
|
||
293 | then
|
||
294 | begin
|
||
295 | Printer.Orientation := poLandscape ; |
||
296 | Graph.Print ; |
||
297 | end ;
|
||
298 | end ;
|
||
299 | |||
300 | /////////////////
|
||
301 | // Aliment //
|
||
302 | /////////////////
|
||
303 | procedure TFResBesGestT.InitAli ;
|
||
304 | const
|
||
305 | TabColor : array[0..1] of TColor |
||
306 | = (clBlack, clRed) ; |
||
307 | var
|
||
308 | i : integer ; |
||
309 | begin
|
||
310 | // LineAli : s?ries (lignes) graphiques
|
||
311 | for i := 1 to 2 do |
||
312 | begin
|
||
313 | LineAli[i] := TLineSeries.Create (Graph) ; |
||
314 | LineAli[i].ParentChart := Graph ; |
||
315 | if i = 1 |
||
316 | then // R?f?rence |
||
317 | LineAli[i].Title := StrReference |
||
318 | else // Besoin |
||
319 | LineAli[i].Title := StrBesoin ; |
||
320 | LineAli[i].SeriesColor := TabColor[i - 1] ;
|
||
321 | LineAli[i].LinePen.Color := LineAli[i].SeriesColor ; |
||
322 | LineAli[i].LinePen.Width := 2 ;
|
||
323 | Graph.AddSeries (LineAli[i]) ; |
||
324 | end ;
|
||
325 | end ;
|
||
326 | |||
327 | procedure TFResBesGestT.AffGraphAli ;
|
||
328 | var
|
||
329 | i, j : integer ; |
||
330 | |||
331 | // Abscisse
|
||
332 | function AliX : double ;
|
||
333 | begin
|
||
334 | case CBAli2.ItemIndex of |
||
335 | 0 : // Age |
||
336 | result := FBesGestT.PBAgeSail.AsInteger + (j - 1) ;
|
||
337 | 1 : // Dur?e |
||
338 | result := j - 1 ;
|
||
339 | else
|
||
340 | result := 0 ;
|
||
341 | end ;
|
||
342 | end ;
|
||
343 | |||
344 | // Ordonn?e
|
||
345 | function AliY : double ;
|
||
346 | begin
|
||
347 | |||
348 | case i of |
||
349 | 1 : // R?f?rence |
||
350 | result := FBesGestT.AppAli[j] ; |
||
351 | 2 : // Besoin |
||
352 | if (j <= PBDuree1.AsInteger)
|
||
353 | then
|
||
354 | result := PBQuantite1.AsFloat |
||
355 | else
|
||
356 | if (j > PBDureeMoy.AsInteger - PBDuree3.AsInteger)
|
||
357 | then
|
||
358 | result := PBQuantite3.AsFloat |
||
359 | else
|
||
360 | result := PBQuantite2.AsFloat ; |
||
361 | else
|
||
362 | result := 0 ;
|
||
363 | end ;
|
||
364 | |||
365 | end ;
|
||
366 | |||
367 | // AffGraphAli
|
||
368 | begin
|
||
369 | ResetGraph ; |
||
370 | Graph.Title.Text.Add (TSAli.Caption) ; |
||
371 | Graph.LeftAxis.Title.Caption := Format ('%s (%s/%s)', [TSAli.Caption, StrKg, StrJ]) ;
|
||
372 | Graph.BottomAxis.Title.Caption := CBAli2.Text ; |
||
373 | // Affichage des lignes
|
||
374 | for i := 1 to 2 do |
||
375 | LineAli[i].Active := TRUE ; |
||
376 | for i := 1 to 2 do |
||
377 | LineAli[i].Clear ; |
||
378 | for i := 1 to 2 do |
||
379 | for j := 1 to DureeGest do |
||
380 | LineAli[i].AddXY (AliX, AliY, '', clTeeColor) ;
|
||
381 | Graph.LeftAxis.Minimum := 0 ;
|
||
382 | Graph.LeftAxis.Increment := 0.5 ;
|
||
383 | Graph.LeftAxis.MinorTickCount := 4 ;
|
||
384 | Graph.LeftAxis.Maximum := 4.5 ;
|
||
385 | Graph.LeftAxis.Minimum := 1.5 ;
|
||
386 | Graph.LeftAxis.AxisValuesFormat := '# ##0.0' ;
|
||
387 | end ;
|
||
388 | |||
389 | procedure TFResBesGestT.PBDuree1Change(Sender: TObject);
|
||
390 | begin
|
||
391 | PBQuantite1.Visible := PBDuree1.AsInteger > 0 ;
|
||
392 | if (PBDuree1.AsInteger >= PBDuree1.MinValue)
|
||
393 | and (PBDuree1.AsInteger <= PBDuree1.MaxValue)
|
||
394 | then
|
||
395 | begin
|
||
396 | PBDuree2.AsInteger := PBDureeMoy.AsInteger |
||
397 | - PBDuree1.AsInteger |
||
398 | - PBDuree3.AsInteger ; |
||
399 | PBQuantite2.AsFloat := (PBQuantiteMoy.AsFloat * PBDureeMoy.AsInteger |
||
400 | - PBQuantite1.AsFloat * PBDuree1.AsInteger |
||
401 | - PBQuantite3.AsFloat * PBDuree3.AsInteger) |
||
402 | / PBDuree2.AsInteger ; |
||
403 | AffGraphAli ; |
||
404 | end ;
|
||
405 | end;
|
||
406 | |||
407 | procedure TFResBesGestT.PBDuree3Change(Sender: TObject);
|
||
408 | begin
|
||
409 | PBQuantite3.Visible := PBDuree3.AsInteger > 0 ;
|
||
410 | if (PBDuree3.AsInteger >= PBDuree3.MinValue)
|
||
411 | and (PBDuree3.AsInteger <= PBDuree3.MaxValue)
|
||
412 | then
|
||
413 | begin
|
||
414 | PBDuree2.AsInteger := PBDureeMoy.AsInteger |
||
415 | - PBDuree1.AsInteger |
||
416 | - PBDuree3.AsInteger ; |
||
417 | PBQuantite2.AsFloat := (PBQuantiteMoy.AsFloat * PBDureeMoy.AsInteger |
||
418 | - PBQuantite1.AsFloat * PBDuree1.AsInteger |
||
419 | - PBQuantite3.AsFloat * PBDuree3.AsInteger) |
||
420 | / PBDuree2.AsInteger ; |
||
421 | AffGraphAli ; |
||
422 | end ;
|
||
423 | end;
|
||
424 | |||
425 | procedure TFResBesGestT.PBQuantite1Change(Sender: TObject);
|
||
426 | begin
|
||
427 | PBQuantite2.AsFloat := (PBQuantiteMoy.AsFloat * PBDureeMoy.AsInteger |
||
428 | - PBQuantite1.AsFloat * PBDuree1.AsInteger |
||
429 | - PBQuantite3.AsFloat * PBDuree3.AsInteger) |
||
430 | / PBDuree2.AsInteger ; |
||
431 | AffGraphAli ; |
||
432 | end;
|
||
433 | |||
434 | procedure TFResBesGestT.PBQuantite3Change(Sender: TObject);
|
||
435 | begin
|
||
436 | PBQuantite2.AsFloat := (PBQuantiteMoy.AsFloat * PBDureeMoy.AsInteger |
||
437 | - PBQuantite1.AsFloat * PBDuree1.AsInteger |
||
438 | - PBQuantite3.AsFloat * PBDuree3.AsInteger) |
||
439 | / PBDuree2.AsInteger ; |
||
440 | AffGraphAli ; |
||
441 | end;
|
||
442 | |||
443 | procedure TFResBesGestT.CBAli2Change(Sender: TObject);
|
||
444 | begin
|
||
445 | AffGraphAli ; |
||
446 | end;
|
||
447 | |||
448 | /////////////////
|
||
449 | // Energie //
|
||
450 | /////////////////
|
||
451 | procedure TFResBesGestT.InitNRJ ;
|
||
452 | const
|
||
453 | TabColor : array[0..4] of TColor |
||
454 | = (clOlive, clGray, clAqua, clPurple, clNavy) ; |
||
455 | var
|
||
456 | i : integer ; |
||
457 | begin
|
||
458 | // ListNRJ : liste pour l'?nergie
|
||
459 | ListNRJ := TStringList.Create ; |
||
460 | ListNRJ.Assign (LBNRJ.Items) ; |
||
461 | // PieNRJ : s?rie (camembert) graphique
|
||
462 | PieNRJ := TPieSeries.Create (Graph) ; |
||
463 | PieNRJ.ParentChart := Graph ; |
||
464 | PieNRJ.Marks.ArrowLength := 24 ;
|
||
465 | PieNRJ.Marks.Arrow.Color := clBlack ; |
||
466 | PieNRJ.Marks.Brush.Style := bsClear ; |
||
467 | PieNRJ.Marks.Frame.Visible := FALSE ; |
||
468 | PieNRJ.ValueFormat := Format ('# ##0.0 %s', [StrMJ]) ;
|
||
469 | PieNRJ.PercentFormat := '##0.0 %' ;
|
||
470 | Graph.AddSeries (PieNRJ) ; |
||
471 | // AreaNRJ : s?ries (aires) graphiques
|
||
472 | SetLength (AreaNRJ, ListNRJ.Count) ; |
||
473 | for i := 0 to ListNRJ.Count - 1 do |
||
474 | begin
|
||
475 | AreaNRJ[i] := TAreaSeries.Create (Graph) ; |
||
476 | AreaNRJ[i].ParentChart := Graph ; |
||
477 | AreaNRJ[i].Title := ListNRJ[i] ; |
||
478 | AreaNRJ[i].SeriesColor := TabColor[i] ; |
||
479 | AreaNRJ[i].AreaLinesPen.Visible := FALSE ; |
||
480 | Graph.AddSeries (AreaNRJ[i]) ; |
||
481 | end ;
|
||
482 | // LineNRJ : s?rie (ligne) graphique
|
||
483 | LineNRJ := TLineSeries.Create (Graph) ; |
||
484 | LineNRJ.ParentChart := Graph ; |
||
485 | LineNRJ.Title := StrReference ; |
||
486 | LineNRJ.SeriesColor := clBlack ; |
||
487 | LineNRJ.LinePen.Color := LineNRJ.SeriesColor ; |
||
488 | LineNRJ.LinePen.Width := 2 ;
|
||
489 | Graph.AddSeries (LineNRJ) ; |
||
490 | end ;
|
||
491 | |||
492 | procedure TFResBesGestT.AffGraphNRJ ;
|
||
493 | var
|
||
494 | i, j : integer ; |
||
495 | y, m, t : double ; |
||
496 | |||
497 | // Abscisse
|
||
498 | function NRJX : double ;
|
||
499 | begin
|
||
500 | case CBNRJ1.ItemIndex of |
||
501 | 1 : // R?partition dynamique |
||
502 | case CBNRJ2.ItemIndex of |
||
503 | 0 : // Age |
||
504 | result := FBesGestT.PBAgeSail.AsInteger + (j - 1) ;
|
||
505 | 1 : // Dur?e |
||
506 | result := j - 1 ;
|
||
507 | else
|
||
508 | result := 0 ;
|
||
509 | end ;
|
||
510 | else
|
||
511 | result := 0 ;
|
||
512 | end ;
|
||
513 | end ;
|
||
514 | |||
515 | // Ordonn?e
|
||
516 | function NRJY : double ;
|
||
517 | var
|
||
518 | BesEM : double ; |
||
519 | begin
|
||
520 | case CBNRJ1.ItemIndex of |
||
521 | 0 : // R?partition globale |
||
522 | case i of |
||
523 | 0 : // Entretien |
||
524 | result := FBesGestT.BesEMEntTot ; |
||
525 | 1 : // Activit? |
||
526 | result := FBesGestT.BesEMActTot ; |
||
527 | 2 : // Thermor?gulation |
||
528 | result := FBesGestT.BesEMTheTot ; |
||
529 | 3 : // Port?e |
||
530 | result := FBesGestT.BesEMPortTot ; |
||
531 | 4 : // R?serve |
||
532 | result := FBesGestT.BesEMResTot ; |
||
533 | else
|
||
534 | result := 0 ;
|
||
535 | end ;
|
||
536 | 1 : // R?partition dynamique |
||
537 | case i of |
||
538 | -1 : // Apport |
||
539 | result := FBesGestT.AppEM[j] ; |
||
540 | 0 : // Entretien |
||
541 | result := FBesGestT.BesEMEnt[j] ; |
||
542 | 1 : // Activit? |
||
543 | result := FBesGestT.BesEMAct[j] ; |
||
544 | 2 : // Thermor?gulation |
||
545 | result := FBesGestT.BesEMThe[j] ; |
||
546 | 3 : // Port?e |
||
547 | result := FBesGestT.BesEMPort[j] ; |
||
548 | 4 : // R?serve |
||
549 | begin
|
||
550 | if (j <= PBDuree1.AsInteger)
|
||
551 | then
|
||
552 | BesEM := PBQuantite1.AsFloat / FBesGestT.AppAliTot * FBesGestT.AppEMTot |
||
553 | else
|
||
554 | if (j > PBDureeMoy.AsInteger - PBDuree3.AsInteger)
|
||
555 | then
|
||
556 | BesEM := PBQuantite3.AsFloat / FBesGestT.AppAliTot * FBesGestT.AppEMTot |
||
557 | else
|
||
558 | BesEM := PBQuantite2.AsFloat / FBesGestT.AppAliTot * FBesGestT.AppEMTot ; |
||
559 | result := Max (BesEM - FBesGestT.BesEMEnt[j] - FBesGestT.BesEMAct[j] - FBesGestT.BesEMPort[j] - FBesGestT.BesEMThe[j], 0) ;
|
||
560 | end ;
|
||
561 | else
|
||
562 | result := 0 ;
|
||
563 | end ;
|
||
564 | else
|
||
565 | result := 0 ;
|
||
566 | end ;
|
||
567 | end ;
|
||
568 | |||
569 | // AffGraphNRJ
|
||
570 | begin
|
||
571 | ResetGraph ; |
||
572 | Graph.Title.Text.Add (Format ('%s : %s', [TabNRJ.Caption, CBNRJ1.Text])) ;
|
||
573 | case CBNRJ3.ItemIndex of |
||
574 | 0 : // Energie digestible |
||
575 | m := FBesGestT.AppEDTot / FBesGestT.AppEMTot ; |
||
576 | 2 : // Energie nette |
||
577 | m := FBesGestT.AppENTot / FBesGestT.AppEMTot ; |
||
578 | else
|
||
579 | m := 1 ;
|
||
580 | end ;
|
||
581 | case CBNRJ1.ItemIndex of |
||
582 | 0 : // R?partition globale |
||
583 | begin
|
||
584 | Graph.View3D := TRUE ; |
||
585 | Graph.Legend.Visible := FALSE ; |
||
586 | // Affichage du camembert
|
||
587 | PieNRJ.Active := TRUE ; |
||
588 | PieNRJ.Clear ; |
||
589 | if (CBNRJ4.ItemIndex = 1) |
||
590 | then
|
||
591 | PieNRJ.Marks.Style := smsLabelPercent |
||
592 | else
|
||
593 | PieNRJ.Marks.Style := smsLabelValue ; |
||
594 | for i := 0 to ListNRJ.Count - 1 do |
||
595 | begin
|
||
596 | y := NRJY * m ; |
||
597 | if (y > PICO)
|
||
598 | then
|
||
599 | PieNRJ.AddPie (y, ListNRJ[i], AreaNRJ[i].SeriesColor) ; |
||
600 | end ;
|
||
601 | t := FBesGestT.BesEMTot * m ; |
||
602 | Graph.SubTitle.Text.Add (Format ('%s : %3.1f %s/%s', [StrTotal, t, StrMJ, StrJ])) ;
|
||
603 | end ;
|
||
604 | 1 : // R?partition dynamique |
||
605 | begin
|
||
606 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBNRJ3.Text, CBNRJ4.Text]) ;
|
||
607 | Graph.BottomAxis.Title.Caption := CBNRJ2.Text ; |
||
608 | // Affichage des aires
|
||
609 | for i := 0 to ListNRJ.Count - 1 do |
||
610 | AreaNRJ[i].Active := TRUE ; |
||
611 | for i := 0 to ListNRJ.Count - 1 do |
||
612 | AreaNRJ[i].Clear ; |
||
613 | if (CBNRJ4.ItemIndex = 1) |
||
614 | then
|
||
615 | for i := 0 to ListNRJ.Count - 1 do |
||
616 | AreaNRJ[i].MultiArea := maStacked100 |
||
617 | else
|
||
618 | for i := 0 to ListNRJ.Count - 1 do |
||
619 | AreaNRJ[i].MultiArea := maStacked ; |
||
620 | for i := 0 to ListNRJ.Count - 1 do |
||
621 | for j := 1 to DureeGest do |
||
622 | AreaNRJ[i].AddXY (NRJX, NRJY * m, '', clTeeColor) ;
|
||
623 | // Affichage de la ligne
|
||
624 | if CBNRJ4.ItemIndex <> 1 |
||
625 | then
|
||
626 | begin
|
||
627 | i := -1 ;
|
||
628 | LineNRJ.Active := TRUE ; |
||
629 | LineNRJ.Clear ; |
||
630 | for j := 1 to DureeGest do |
||
631 | LineNRJ.AddXY (NRJX, NRJY * m, '', clTeeColor) ;
|
||
632 | end ;
|
||
633 | end ;
|
||
634 | end ;
|
||
635 | AjustEchelle (Graph) ; |
||
636 | end ;
|
||
637 | |||
638 | procedure TFResBesGestT.CBNRJ1Change (Sender : TObject) ;
|
||
639 | begin
|
||
640 | case CBNRJ1.ItemIndex of |
||
641 | 0 : // R?partition globale |
||
642 | CBNRJ2.Visible := FALSE ; |
||
643 | 1 : // R?partition dynamique |
||
644 | CBNRJ2.Visible := TRUE ; |
||
645 | end ;
|
||
646 | AffGraphNRJ ; |
||
647 | end ;
|
||
648 | |||
649 | procedure TFResBesGestT.CBNRJ2Change (Sender : TObject) ;
|
||
650 | begin
|
||
651 | AffGraphNRJ ; |
||
652 | end ;
|
||
653 | |||
654 | procedure TFResBesGestT.CBNRJ3Change (Sender : TObject) ;
|
||
655 | begin
|
||
656 | AffGraphNRJ ; |
||
657 | end ;
|
||
658 | |||
659 | procedure TFResBesGestT.CBNRJ4Change (Sender : TObject) ;
|
||
660 | begin
|
||
661 | AffGraphNRJ ; |
||
662 | end ;
|
||
663 | |||
664 | ///////////////////////
|
||
665 | // Acides amin?s //
|
||
666 | ///////////////////////
|
||
667 | procedure TFResBesGestT.InitAA ;
|
||
668 | const
|
||
669 | TabColor : array[0..3] of TColor |
||
670 | = (clOlive, clPurple, clNavy, clGreen) ; |
||
671 | var
|
||
672 | i : integer ; |
||
673 | begin
|
||
674 | // ListAA : liste pour les acides amin?s
|
||
675 | ListAA := TStringList.Create ; |
||
676 | ListAA.Assign (LBAA.Items) ; |
||
677 | // BarAA35 et BarAA105 : s?ries (barres) graphiques
|
||
678 | BarAA35 := THorizBarSeries.Create (Graph) ; |
||
679 | BarAA35.ParentChart := Graph ; |
||
680 | BarAA35.Title := Str35j ; |
||
681 | BarAA35.SeriesColor := clGreen ; |
||
682 | BarAA35.BarPen.Color := BarAA35.SeriesColor ; |
||
683 | BarAA35.Marks.Visible := FALSE ; |
||
684 | BarAA35.MultiBar := mbSide ; |
||
685 | Graph.AddSeries (BarAA35) ; |
||
686 | BarAA105 := THorizBarSeries.Create (Graph) ; |
||
687 | BarAA105.ParentChart := Graph ; |
||
688 | BarAA105.Title := Str105j ; |
||
689 | BarAA105.SeriesColor := clNavy ; |
||
690 | BarAA105.BarPen.Color := BarAA105.SeriesColor ; |
||
691 | BarAA105.Marks.Visible := FALSE ; |
||
692 | BarAA105.MultiBar := mbSide ; |
||
693 | Graph.AddSeries (BarAA105) ; |
||
694 | // AreaAA : s?ries (aires) graphiques
|
||
695 | SetLength (AreaAA, ListAA.Count) ; |
||
696 | for i := 0 to ListAA.Count - 1 do |
||
697 | begin
|
||
698 | AreaAA[i] := TAreaSeries.Create (Graph) ; |
||
699 | AreaAA[i].ParentChart := Graph ; |
||
700 | AreaAA[i].Title := ListAA[i] ; |
||
701 | AreaAA[i].SeriesColor := TabColor[i] ; |
||
702 | AreaAA[i].AreaLinesPen.Visible := FALSE ; |
||
703 | Graph.AddSeries (AreaAA[i]) ; |
||
704 | end ;
|
||
705 | // LineAA : s?rie (ligne) graphique
|
||
706 | LineAA := TLineSeries.Create (Graph) ; |
||
707 | LineAA.ParentChart := Graph ; |
||
708 | LineAA.Title := StrReference ; |
||
709 | LineAA.SeriesColor := clBlack ; |
||
710 | LineAA.LinePen.Color := LineAA.SeriesColor ; |
||
711 | LineAA.LinePen.Width := 2 ;
|
||
712 | Graph.AddSeries (LineAA) ; |
||
713 | end ;
|
||
714 | |||
715 | procedure TFResBesGestT.AffGraphAA ;
|
||
716 | var
|
||
717 | h, i, j : integer ; |
||
718 | s : string ;
|
||
719 | |||
720 | // Abscisse
|
||
721 | function AAX : double ;
|
||
722 | begin
|
||
723 | case CBAA1.ItemIndex of |
||
724 | 0 : // R?partition dynamique |
||
725 | case CBAA2.ItemIndex of |
||
726 | 0 : // Age |
||
727 | result := FBesGestT.PBAgeSail.AsInteger + (j - 1) ;
|
||
728 | 1 : // Dur?e |
||
729 | result := j - 1 ;
|
||
730 | else
|
||
731 | result := 0 ;
|
||
732 | end ;
|
||
733 | else
|
||
734 | result := 0 ;
|
||
735 | end ;
|
||
736 | end ;
|
||
737 | |||
738 | // Ordonn?e
|
||
739 | function AAY : double ;
|
||
740 | var
|
||
741 | a : integer ; |
||
742 | d, BesAA, BesEM : double ; |
||
743 | begin
|
||
744 | case h of |
||
745 | 3 : // met+cys |
||
746 | a := 13 ;
|
||
747 | 7 : // phe+tyr |
||
748 | a := 14 ;
|
||
749 | else
|
||
750 | a := h ; |
||
751 | end ;
|
||
752 | case CBAA1.ItemIndex of |
||
753 | 0 : // R?partition dynamique |
||
754 | begin
|
||
755 | // Diviseur
|
||
756 | if i = -1 |
||
757 | then // Apport |
||
758 | BesEM := 0
|
||
759 | else
|
||
760 | if j <= PBDuree1.AsInteger
|
||
761 | then
|
||
762 | BesEM := PBQuantite1.AsFloat / FBesGestT.AppAliTot * FBesGestT.AppEMTot |
||
763 | else
|
||
764 | if j > PBDureeMoy.AsInteger - PBDuree3.AsInteger
|
||
765 | then
|
||
766 | BesEM := PBQuantite3.AsFloat / FBesGestT.AppAliTot * FBesGestT.AppEMTot |
||
767 | else
|
||
768 | BesEM := PBQuantite2.AsFloat / FBesGestT.AppAliTot * FBesGestT.AppEMTot ; |
||
769 | case CBAA4.ItemIndex of |
||
770 | 2 : // Aliment |
||
771 | if i = -1 |
||
772 | then // Apport |
||
773 | d := FBesGestT.AppAli[j] |
||
774 | else // Besoin |
||
775 | d := BesEM * FBesGestT.AppAliTot / FBesGestT.AppEMTot ; |
||
776 | 3 : // ED |
||
777 | if i = -1 |
||
778 | then // Apport |
||
779 | d := FBesGestT.AppED[j] |
||
780 | else // Besoin |
||
781 | d := BesEM * FBesGestT.AppEDTot / FBesGestT.AppEMTot ; |
||
782 | 4 : // EM |
||
783 | if i = -1 |
||
784 | then // Apport |
||
785 | d := FBesGestT.AppEM[j] |
||
786 | else // Besoin |
||
787 | d := BesEM ; |
||
788 | 5 : // EN |
||
789 | if i = -1 |
||
790 | then // Apport |
||
791 | d := FBesGestT.AppEN[j] |
||
792 | else // Besoin |
||
793 | d := BesEM * FBesGestT.AppENTot / FBesGestT.AppEMTot ; |
||
794 | else
|
||
795 | d := 1 ;
|
||
796 | end ;
|
||
797 | case i of |
||
798 | -1 : // Apport |
||
799 | result := FBesGestT.AppAA[a, j] / d ; |
||
800 | 0 : // Entretien |
||
801 | result := FBesGestT.BesAAEnt[a, j] / d ; |
||
802 | 1 : // Port?e |
||
803 | result := FBesGestT.BesAAPort[a, j] / d ; |
||
804 | 2 : // R?serve |
||
805 | result := FBesGestT.BesAARes[a, j] / d ; |
||
806 | 3 : // Exc?s |
||
807 | begin
|
||
808 | if j <= PBDuree1.AsInteger
|
||
809 | then
|
||
810 | BesAA := PBQuantite1.AsFloat / FBesGestT.PBAliment.AsFloat * FBesGestT.BesAA[a, 105]
|
||
811 | else
|
||
812 | if j > PBDureeMoy.AsInteger - PBDuree3.AsInteger
|
||
813 | then
|
||
814 | BesAA := PBQuantite3.AsFloat / FBesGestT.PBAliment.AsFloat * FBesGestT.BesAA[a, 105]
|
||
815 | else
|
||
816 | BesAA := PBQuantite2.AsFloat / FBesGestT.PBAliment.AsFloat * FBesGestT.BesAA[a, 105] ;
|
||
817 | result := Max (BesAA - FBesGestT.BesAAEnt[a, j] - FBesGestT.BesAAPort[a, j] - FBesGestT.BesAARes[a, j], 0) / d ;
|
||
818 | end ;
|
||
819 | else
|
||
820 | result := 0 ;
|
||
821 | end ;
|
||
822 | end ;
|
||
823 | 1 : // Besoin |
||
824 | begin
|
||
825 | // Diviseur
|
||
826 | case CBAA4.ItemIndex of |
||
827 | 1 : // Lysine |
||
828 | d := FBesGestT.BesAA[1, j] / 100 ; |
||
829 | else
|
||
830 | d := 1 ;
|
||
831 | end ;
|
||
832 | result := FBesGestT.BesAA[a, j] / d ; |
||
833 | end ;
|
||
834 | else
|
||
835 | result := 0 ;
|
||
836 | end ;
|
||
837 | end ;
|
||
838 | |||
839 | // AffGraphAA
|
||
840 | begin
|
||
841 | ResetGraph ; |
||
842 | Graph.Title.Text.Add (CBAA1.Text) ; |
||
843 | Graph.SubTitle.Text.Add(StrDigestStd); |
||
844 | case CBAA1.ItemIndex of |
||
845 | 0 : // R?partition dynamique |
||
846 | begin
|
||
847 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBAA3.Text, CBAA4.Text]) ;
|
||
848 | Graph.BottomAxis.Title.Caption := CBAA2.Text ; |
||
849 | h := CBAA3.ItemIndex + 1 ;
|
||
850 | // Affichage des aires
|
||
851 | for i := 0 to ListAA.Count - 1 do |
||
852 | AreaAA[i].Active := TRUE ; |
||
853 | for i := 0 to ListAA.Count - 1 do |
||
854 | AreaAA[i].Clear ; |
||
855 | if (CBAA4.ItemIndex = 1) |
||
856 | then
|
||
857 | for i := 0 to ListAA.Count - 1 do |
||
858 | AreaAA[i].MultiArea := maStacked100 |
||
859 | else
|
||
860 | for i := 0 to ListAA.Count - 1 do |
||
861 | AreaAA[i].MultiArea := maStacked ; |
||
862 | for i := 0 to ListAA.Count - 1 do |
||
863 | for j := 1 to DureeGest do |
||
864 | AreaAA[i].AddXY (AAX, AAY, '', clTeeColor) ;
|
||
865 | // Affichage de la ligne
|
||
866 | if CBAA4.ItemIndex <> 1 |
||
867 | then
|
||
868 | begin
|
||
869 | i := -1 ;
|
||
870 | LineAA.Active := TRUE ; |
||
871 | LineAA.Clear ; |
||
872 | for j := 1 to DureeGest do |
||
873 | LineAA.AddXY (AAX, AAY, '', clTeeColor) ;
|
||
874 | end ;
|
||
875 | AjustEchelle (Graph) ; |
||
876 | end ;
|
||
877 | 1 : // Besoin |
||
878 | begin
|
||
879 | Graph.Legend.Inverted := FALSE ; |
||
880 | Graph.LeftAxis.Automatic := TRUE ; |
||
881 | Graph.LeftAxis.Title.Caption := TabAA.Caption ; |
||
882 | Graph.BottomAxis.Title.Caption := Format ('%s (%s)', [StrBesoin, CBAA4.Text]) ;
|
||
883 | // Affichage des barres
|
||
884 | BarAA35.Active := TRUE ; |
||
885 | BarAA105.Active := TRUE ; |
||
886 | BarAA35.Clear ; |
||
887 | BarAA105.Clear ; |
||
888 | for h := CBAA3.Items.Count downto 1 do |
||
889 | begin
|
||
890 | s := CBAA3.Items[h - 1] ;
|
||
891 | j := 35 ;
|
||
892 | BarAA35.AddBar (AAY, s, clTeeColor) ; |
||
893 | j := 105 ;
|
||
894 | BarAA105.AddBar (AAY, s, clTeeColor) ; |
||
895 | end ;
|
||
896 | end ;
|
||
897 | end ;
|
||
898 | end ;
|
||
899 | |||
900 | procedure TFResBesGestT.CBAA1Change (Sender : TObject) ;
|
||
901 | begin
|
||
902 | CBAA4.Items.Clear ; |
||
903 | case CBAA1.ItemIndex of |
||
904 | 0 : // R?partition dynamique |
||
905 | begin
|
||
906 | CBAA2.Visible := TRUE ; |
||
907 | CBAA3.Visible := TRUE ; |
||
908 | // Unit?s
|
||
909 | CBAA4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
910 | CBAA4.Items.Add ('%') ;
|
||
911 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrKg, StrAlimentUnit])) ;
|
||
912 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrMJ, StrED])) ;
|
||
913 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrMJ, StrEM])) ;
|
||
914 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrMJ, StrEN])) ;
|
||
915 | end ;
|
||
916 | 1 : // Besoin |
||
917 | begin
|
||
918 | if AffBesoin
|
||
919 | then
|
||
920 | begin
|
||
921 | FWarning := TFWarning.Create (Self) ; |
||
922 | with FWarning do |
||
923 | begin
|
||
924 | Msg := 'Besoin';
|
||
925 | ShowModal ; |
||
926 | Release ; |
||
927 | AffBesoin := FALSE ; |
||
928 | end ;
|
||
929 | end ;
|
||
930 | CBAA2.Visible := FALSE ; |
||
931 | CBAA3.Visible := FALSE ; |
||
932 | // Unit?s
|
||
933 | CBAA4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
934 | CBAA4.Items.Add (Format ('%% %s', [StrLys])) ;
|
||
935 | end ;
|
||
936 | end ;
|
||
937 | CBAA4.ItemIndex := 0 ;
|
||
938 | AffGraphAA ; |
||
939 | end ;
|
||
940 | |||
941 | procedure TFResBesGestT.CBAA2Change (Sender : TObject) ;
|
||
942 | begin
|
||
943 | AffGraphAA ; |
||
944 | end ;
|
||
945 | |||
946 | procedure TFResBesGestT.CBAA3Change (Sender : TObject) ;
|
||
947 | begin
|
||
948 | AffGraphAA ; |
||
949 | end ;
|
||
950 | |||
951 | procedure TFResBesGestT.CBAA4Change (Sender : TObject) ;
|
||
952 | begin
|
||
953 | AffGraphAA ; |
||
954 | end ;
|
||
955 | |||
956 | procedure TFResBesGestT.WMSysCommand(var Message: TWMSysCommand); |
||
957 | begin
|
||
958 | if Message.CmdType = SC_MINIMIZE
|
||
959 | then
|
||
960 | Application.Minimize |
||
961 | else
|
||
962 | inherited;
|
||
963 | end;
|
||
964 | |||
965 | end. |