root / UFResBesLactT.pas @ 3
Historique | Voir | Annoter | Télécharger (19,655 ko)
1 | 3 | avalancogn | unit UFResBesLactT;
|
---|---|---|---|
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 | TFResBesLactT = 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 | GBAliX: TGroupBox; |
||
35 | CBAli2: TComboBox; |
||
36 | PM: TPopupMenu; |
||
37 | MI3D: TMenuItem; |
||
38 | MIPreview: TMenuItem; |
||
39 | MIPrint: TMenuItem; |
||
40 | PD: TPrintDialog; |
||
41 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
||
42 | procedure FormShow(Sender: TObject);
|
||
43 | procedure PCChange(Sender: TObject);
|
||
44 | procedure CBNRJ1Change(Sender: TObject);
|
||
45 | procedure CBNRJ2Change(Sender: TObject);
|
||
46 | procedure CBNRJ3Change(Sender: TObject);
|
||
47 | procedure CBNRJ4Change(Sender: TObject);
|
||
48 | procedure CBAA1Change(Sender: TObject);
|
||
49 | procedure CBAA2Change(Sender: TObject);
|
||
50 | procedure CBAA3Change(Sender: TObject);
|
||
51 | procedure CBAA4Change(Sender: TObject);
|
||
52 | procedure CBAli2Change(Sender: TObject);
|
||
53 | procedure MI3DClick(Sender: TObject);
|
||
54 | procedure MIPreviewClick(Sender: TObject);
|
||
55 | procedure MIPrintClick(Sender: TObject);
|
||
56 | procedure FormCreate(Sender: TObject);
|
||
57 | procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND; |
||
58 | private
|
||
59 | { D?clarations priv?es }
|
||
60 | ListNRJ : TStrings ; |
||
61 | PieNRJ : TPieSeries ; |
||
62 | AreaNRJ : array of TAreaSeries ; |
||
63 | LineNRJ : TLineSeries ; |
||
64 | ListAA : TStrings ; |
||
65 | BarAA : THorizBarSeries ; |
||
66 | AreaAA : array of TAreaSeries ; |
||
67 | LineAA : TLineSeries ; |
||
68 | LineAli : array[1..2] of TLineSeries ; |
||
69 | procedure ResetGraph ;
|
||
70 | procedure InitNRJ ;
|
||
71 | procedure AffGraphNRJ ;
|
||
72 | procedure InitAA ;
|
||
73 | procedure AffGraphAA ;
|
||
74 | procedure InitAli ;
|
||
75 | procedure AffGraphAli ;
|
||
76 | public
|
||
77 | { D?clarations publiques }
|
||
78 | end;
|
||
79 | |||
80 | var
|
||
81 | FResBesLactT: TFResBesLactT; |
||
82 | |||
83 | implementation
|
||
84 | |||
85 | uses
|
||
86 | UStrings, UFindRec, UUtil, UEchelle, UFBesLactT, UFPrevGraph, UFWarning; |
||
87 | |||
88 | {$R *.dfm}
|
||
89 | |||
90 | { TFResBesLactT }
|
||
91 | |||
92 | procedure TFResBesLactT.FormCreate(Sender: TObject);
|
||
93 | begin
|
||
94 | if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
||
95 | then
|
||
96 | Font.Name := 'Arial Unicode MS';
|
||
97 | TranslateComponent(Self); |
||
98 | Constraints.MinWidth := 544 + (Width - ClientWidth);
|
||
99 | Width := 640;
|
||
100 | Constraints.MinHeight := 400 + (Height - ClientHeight);
|
||
101 | Height := 480;
|
||
102 | CBAli2.ItemIndex := 0;
|
||
103 | CBNRJ1.ItemIndex := 0;
|
||
104 | CBNRJ2.ItemIndex := 0;
|
||
105 | CBNRJ3.ItemIndex := 0;
|
||
106 | CBNRJ4.Items.Add(Format('%s/%s', [StrMJ, StrJ]));
|
||
107 | CBNRJ4.Items.Add('%');
|
||
108 | CBNRJ4.ItemIndex := 0;
|
||
109 | CBAA1.ItemIndex := 0;
|
||
110 | CBAA2.ItemIndex := 0;
|
||
111 | CBAA3.ItemIndex := 0;
|
||
112 | CBAA4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
||
113 | CBAA4.Items.Add(Format('%% %s', [StrBesoin]));
|
||
114 | CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
||
115 | CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrMJ, StrED]));
|
||
116 | CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrMJ, StrEM]));
|
||
117 | CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrMJ, StrEN]));
|
||
118 | CBAA4.ItemIndex := 0;
|
||
119 | end;
|
||
120 | |||
121 | procedure TFResBesLactT.FormShow (Sender : TObject) ;
|
||
122 | begin
|
||
123 | MIPrint.Enabled := IsComplete or IsEducation ;
|
||
124 | // Aliment
|
||
125 | InitAli ; |
||
126 | // Energie
|
||
127 | InitNRJ ; |
||
128 | // Acides Amin?s
|
||
129 | InitAA ; |
||
130 | // Affichage principal
|
||
131 | PC.ActivePageIndex := 0 ;
|
||
132 | PCChange (nil) ;
|
||
133 | end ;
|
||
134 | |||
135 | procedure TFResBesLactT.FormClose (Sender : TObject ; var Action : TCloseAction) ; |
||
136 | var
|
||
137 | i : integer ; |
||
138 | begin
|
||
139 | // Aliment
|
||
140 | for i := 1 to 2 do |
||
141 | LineAli[i].Free ; |
||
142 | // Energie
|
||
143 | LineNRJ.Free ; |
||
144 | for i := 0 to ListNRJ.Count - 1 do |
||
145 | AreaNRJ[i].Free ; |
||
146 | SetLength (AreaNRJ, 0) ;
|
||
147 | PieNRJ.Free ; |
||
148 | ListNRJ.Free ; |
||
149 | // Acides Amin?s
|
||
150 | LineAA.Free ; |
||
151 | for i := 0 to ListAA.Count - 1 do |
||
152 | AreaAA[i].Free ; |
||
153 | SetLength (AreaAA, 0) ;
|
||
154 | BarAA.Free ; |
||
155 | ListAA.Free ; |
||
156 | end ;
|
||
157 | |||
158 | procedure TFResBesLactT.PCChange (Sender : TObject) ;
|
||
159 | begin
|
||
160 | case PC.ActivePageIndex of |
||
161 | 0 : // Aliment |
||
162 | AffGraphAli ; |
||
163 | 1 : // Energie |
||
164 | AffGraphNRJ ; |
||
165 | 2 : // Acides Amin?s |
||
166 | AffGraphAA ; |
||
167 | end ;
|
||
168 | end ;
|
||
169 | |||
170 | procedure TFResBesLactT.ResetGraph ;
|
||
171 | var
|
||
172 | i : integer ; |
||
173 | begin
|
||
174 | Graph.UndoZoom ; |
||
175 | Graph.View3D := FALSE ; |
||
176 | Graph.Legend.Visible := TRUE ; |
||
177 | Graph.Title.Text.Clear ; |
||
178 | Graph.SubTitle.Text.Clear ; |
||
179 | Graph.LeftAxis.Automatic := FALSE ; |
||
180 | Graph.BottomAxis.MinimumOffset := 0;
|
||
181 | Graph.BottomAxis.MaximumOffset := 0;
|
||
182 | // Aliment
|
||
183 | for i := 1 to 2 do |
||
184 | LineAli[i].Active := FALSE ; |
||
185 | // Energie
|
||
186 | PieNRJ.Active := FALSE ; |
||
187 | for i := 0 to ListNRJ.Count - 1 do |
||
188 | AreaNRJ[i].Active := FALSE ; |
||
189 | LineNRJ.Active := FALSE ; |
||
190 | // Acides Amin?s
|
||
191 | BarAA.Active := FALSE ; |
||
192 | for i := 0 to ListAA.Count - 1 do |
||
193 | AreaAA[i].Active := FALSE ; |
||
194 | LineAA.Active := FALSE ; |
||
195 | end ;
|
||
196 | |||
197 | procedure TFResBesLactT.MI3DClick (Sender : TObject) ;
|
||
198 | begin
|
||
199 | Graph.View3D := not (Graph.View3D) ;
|
||
200 | end ;
|
||
201 | |||
202 | procedure TFResBesLactT.MIPreviewClick (Sender : TObject) ;
|
||
203 | begin
|
||
204 | FPrevGraph := TFPrevGraph.Create (Self) ; |
||
205 | with FPrevGraph do |
||
206 | begin
|
||
207 | TPPGraph.Panels.Add (Graph) ; |
||
208 | ShowModal ; |
||
209 | Release ; |
||
210 | end ;
|
||
211 | end ;
|
||
212 | |||
213 | procedure TFResBesLactT.MIPrintClick (Sender : TObject) ;
|
||
214 | begin
|
||
215 | if PD.Execute
|
||
216 | then
|
||
217 | begin
|
||
218 | Printer.Orientation := poLandscape ; |
||
219 | Graph.Print ; |
||
220 | end ;
|
||
221 | end ;
|
||
222 | |||
223 | /////////////////
|
||
224 | // Aliment //
|
||
225 | /////////////////
|
||
226 | procedure TFResBesLactT.InitAli ;
|
||
227 | const
|
||
228 | TabColor : array[0..1] of TColor |
||
229 | = (clBlack, clRed) ; |
||
230 | var
|
||
231 | i : integer ; |
||
232 | begin
|
||
233 | // LineAli : s?ries (lignes) graphiques
|
||
234 | for i := 1 to 2 do |
||
235 | begin
|
||
236 | LineAli[i] := TLineSeries.Create (Graph) ; |
||
237 | LineAli[i].ParentChart := Graph ; |
||
238 | if i = 1 |
||
239 | then // R?f?rence |
||
240 | LineAli[i].Title := StrReference |
||
241 | else // Besoin |
||
242 | LineAli[i].Title := StrBesoin ; |
||
243 | LineAli[i].SeriesColor := TabColor[i - 1] ;
|
||
244 | LineAli[i].LinePen.Color := LineAli[i].SeriesColor ; |
||
245 | LineAli[i].LinePen.Width := 2 ;
|
||
246 | Graph.AddSeries (LineAli[i]) ; |
||
247 | end ;
|
||
248 | end ;
|
||
249 | |||
250 | procedure TFResBesLactT.AffGraphAli ;
|
||
251 | var
|
||
252 | i, j : integer ; |
||
253 | |||
254 | // Abscisse
|
||
255 | function AliX : double ;
|
||
256 | begin
|
||
257 | case CBAli2.ItemIndex of |
||
258 | 0 : // Dur?e |
||
259 | result := j - 1 ;
|
||
260 | else
|
||
261 | result := 0 ;
|
||
262 | end ;
|
||
263 | end ;
|
||
264 | |||
265 | // Ordonn?e
|
||
266 | function AliY : double ;
|
||
267 | begin
|
||
268 | case i of |
||
269 | 1 : // R?f?rence |
||
270 | result := FBesLactT.AppAli[j] ; |
||
271 | 2 : // Besoin |
||
272 | if (FBesLactT.AppEMTot = 0) |
||
273 | then
|
||
274 | result := 0
|
||
275 | else
|
||
276 | result := (FBesLactT.BesEMEnt[j] + FBesLactT.BesEMLait[j]) |
||
277 | * FBesLactT.AppAliTot / FBesLactT.AppEMTot ; |
||
278 | else
|
||
279 | result := 0 ;
|
||
280 | end ;
|
||
281 | end ;
|
||
282 | |||
283 | // AffGraphAli
|
||
284 | begin
|
||
285 | ResetGraph ; |
||
286 | Graph.Title.Text.Add (TSAli.Caption) ; |
||
287 | Graph.LeftAxis.Title.Caption := Format ('%s (%s/%s)', [TSAli.Caption, StrKg, StrJ]) ;
|
||
288 | Graph.BottomAxis.Title.Caption := CBAli2.Text ; |
||
289 | // Affichage des lignes
|
||
290 | for i := 1 to 2 do |
||
291 | LineAli[i].Active := TRUE ; |
||
292 | for i := 1 to 2 do |
||
293 | LineAli[i].Clear ; |
||
294 | for i := 1 to 2 do |
||
295 | for j := 1 to FBesLactT.DureeLact do |
||
296 | LineAli[i].AddXY (AliX, AliY, '', clTeeColor) ;
|
||
297 | Graph.LeftAxis.Minimum := 0 ;
|
||
298 | Graph.LeftAxis.Increment := 1 ;
|
||
299 | Graph.LeftAxis.MinorTickCount := 9 ;
|
||
300 | Graph.LeftAxis.Maximum := 10 ;
|
||
301 | Graph.LeftAxis.Minimum := 2 ;
|
||
302 | Graph.LeftAxis.AxisValuesFormat := '# ##0' ;
|
||
303 | end ;
|
||
304 | |||
305 | procedure TFResBesLactT.CBAli2Change(Sender: TObject);
|
||
306 | begin
|
||
307 | AffGraphAli ; |
||
308 | end;
|
||
309 | |||
310 | /////////////////
|
||
311 | // Energie //
|
||
312 | /////////////////
|
||
313 | procedure TFResBesLactT.InitNRJ ;
|
||
314 | const
|
||
315 | TabColor : array[0..1] of TColor |
||
316 | = (clOlive, clWhite) ; |
||
317 | var
|
||
318 | i : integer ; |
||
319 | begin
|
||
320 | // ListNRJ : liste pour l'?nergie
|
||
321 | ListNRJ := TStringList.Create ; |
||
322 | ListNRJ.Assign (LBNRJ.Items) ; |
||
323 | // PieNRJ : s?rie (camembert) graphique
|
||
324 | PieNRJ := TPieSeries.Create (Graph) ; |
||
325 | PieNRJ.ParentChart := Graph ; |
||
326 | PieNRJ.Marks.ArrowLength := 24 ;
|
||
327 | PieNRJ.Marks.Arrow.Color := clBlack ; |
||
328 | PieNRJ.Marks.Brush.Style := bsClear ; |
||
329 | PieNRJ.Marks.Frame.Visible := FALSE ; |
||
330 | PieNRJ.ValueFormat := Format ('# ##0.0 %s', [StrMJ]) ;
|
||
331 | PieNRJ.PercentFormat := '##0.0 %' ;
|
||
332 | Graph.AddSeries (PieNRJ) ; |
||
333 | // AreaNRJ : s?ries (aires) graphiques
|
||
334 | SetLength (AreaNRJ, ListNRJ.Count) ; |
||
335 | for i := 0 to ListNRJ.Count - 1 do |
||
336 | begin
|
||
337 | AreaNRJ[i] := TAreaSeries.Create (Graph) ; |
||
338 | AreaNRJ[i].ParentChart := Graph ; |
||
339 | AreaNRJ[i].Title := ListNRJ[i] ; |
||
340 | AreaNRJ[i].SeriesColor := TabColor[i] ; |
||
341 | AreaNRJ[i].AreaLinesPen.Visible := FALSE ; |
||
342 | Graph.AddSeries (AreaNRJ[i]) ; |
||
343 | end ;
|
||
344 | // LineNRJ : s?rie (ligne) graphique
|
||
345 | LineNRJ := TLineSeries.Create (Graph) ; |
||
346 | LineNRJ.ParentChart := Graph ; |
||
347 | LineNRJ.Title := StrReference ; |
||
348 | LineNRJ.SeriesColor := clBlack ; |
||
349 | LineNRJ.LinePen.Color := LineNRJ.SeriesColor ; |
||
350 | LineNRJ.LinePen.Width := 2 ;
|
||
351 | Graph.AddSeries (LineNRJ) ; |
||
352 | end ;
|
||
353 | |||
354 | procedure TFResBesLactT.AffGraphNRJ ;
|
||
355 | var
|
||
356 | i, j : integer ; |
||
357 | y, m, t : double ; |
||
358 | |||
359 | // Abscisse
|
||
360 | function NRJX : double ;
|
||
361 | begin
|
||
362 | case CBNRJ1.ItemIndex of |
||
363 | 1 : // R?partition dynamique |
||
364 | case CBNRJ2.ItemIndex of |
||
365 | 0 : // Dur?e |
||
366 | result := j - 1 ;
|
||
367 | else
|
||
368 | result := 0 ;
|
||
369 | end ;
|
||
370 | else
|
||
371 | result := 0 ;
|
||
372 | end ;
|
||
373 | end ;
|
||
374 | |||
375 | // Ordonn?e
|
||
376 | function NRJY : double ;
|
||
377 | begin
|
||
378 | case CBNRJ1.ItemIndex of |
||
379 | 0 : // R?partition globale |
||
380 | case i of |
||
381 | 0 : // Entretien |
||
382 | result := FBesLactT.BesEMEntTot ; |
||
383 | 1 : // Lait |
||
384 | result := FBesLactT.BesEMLaitTot ; |
||
385 | else
|
||
386 | result := 0 ;
|
||
387 | end ;
|
||
388 | 1 : // R?partition dynamique |
||
389 | case i of |
||
390 | -1 : // Apport |
||
391 | result := FBesLactT.AppEM[j] ; |
||
392 | 0 : // Entretien |
||
393 | result := FBesLactT.BesEMEnt[j] ; |
||
394 | 1 : // Lait |
||
395 | result := FBesLactT.BesEMLait[j] ; |
||
396 | else
|
||
397 | result := 0 ;
|
||
398 | end ;
|
||
399 | else
|
||
400 | result := 0 ;
|
||
401 | end ;
|
||
402 | end ;
|
||
403 | |||
404 | // AffGraphNRJ
|
||
405 | begin
|
||
406 | ResetGraph ; |
||
407 | Graph.Title.Text.Add (Format ('%s : %s', [TabNRJ.Caption, CBNRJ1.Text])) ;
|
||
408 | case CBNRJ3.ItemIndex of |
||
409 | 0 : // Energie digestible |
||
410 | m := FBesLactT.AppEDTot / FBesLactT.AppEMTot ; |
||
411 | 2 : // Energie nette |
||
412 | m := FBesLactT.AppENTot / FBesLactT.AppEMTot ; |
||
413 | else
|
||
414 | m := 1 ;
|
||
415 | end ;
|
||
416 | case CBNRJ1.ItemIndex of |
||
417 | 0 : // R?partition globale |
||
418 | begin
|
||
419 | Graph.View3D := TRUE ; |
||
420 | Graph.Legend.Visible := FALSE ; |
||
421 | // Affichage du camembert
|
||
422 | PieNRJ.Active := TRUE ; |
||
423 | PieNRJ.Clear ; |
||
424 | if (CBNRJ4.ItemIndex = 1) |
||
425 | then
|
||
426 | PieNRJ.Marks.Style := smsLabelPercent |
||
427 | else
|
||
428 | PieNRJ.Marks.Style := smsLabelValue ; |
||
429 | for i := 0 to ListNRJ.Count - 1 do |
||
430 | begin
|
||
431 | y := NRJY * m ; |
||
432 | if (y > PICO)
|
||
433 | then
|
||
434 | PieNRJ.AddPie (y, ListNRJ[i], AreaNRJ[i].SeriesColor) ; |
||
435 | end ;
|
||
436 | t := FBesLactT.BesEMTot * m ; |
||
437 | Graph.SubTitle.Text.Add (Format ('%s : %3.1f %s', [StrTotal, t, StrMJ])) ;
|
||
438 | end ;
|
||
439 | 1 : // R?partition dynamique |
||
440 | begin
|
||
441 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBNRJ3.Text, CBNRJ4.Text]) ;
|
||
442 | Graph.BottomAxis.Title.Caption := CBNRJ2.Text ; |
||
443 | // Affichage des aires
|
||
444 | for i := 0 to ListNRJ.Count - 1 do |
||
445 | AreaNRJ[i].Active := TRUE ; |
||
446 | for i := 0 to ListNRJ.Count - 1 do |
||
447 | AreaNRJ[i].Clear ; |
||
448 | if (CBNRJ4.ItemIndex = 1) |
||
449 | then
|
||
450 | for i := 0 to ListNRJ.Count - 1 do |
||
451 | AreaNRJ[i].MultiArea := maStacked100 |
||
452 | else
|
||
453 | for i := 0 to ListNRJ.Count - 1 do |
||
454 | AreaNRJ[i].MultiArea := maStacked ; |
||
455 | for i := 0 to ListNRJ.Count - 1 do |
||
456 | for j := 1 to FBesLactT.DureeLact do |
||
457 | AreaNRJ[i].AddXY (NRJX, NRJY * m, '', clTeeColor) ;
|
||
458 | // Affichage de la ligne
|
||
459 | i := -1 ;
|
||
460 | LineNRJ.Active := TRUE ; |
||
461 | LineNRJ.Clear ; |
||
462 | for j := 1 to FBesLactT.DureeLact do |
||
463 | if (CBNRJ4.ItemIndex = 1) |
||
464 | then
|
||
465 | begin
|
||
466 | t := FBesLactT.BesEMEnt[j] + FBesLactT.BesEMLait[j] ; |
||
467 | LineNRJ.AddXY (NRJX, NRJY / t * 100, '', clTeeColor) ; |
||
468 | end
|
||
469 | else
|
||
470 | LineNRJ.AddXY (NRJX, NRJY * m, '', clTeeColor) ;
|
||
471 | end ;
|
||
472 | end ;
|
||
473 | AjustEchelle (Graph) ; |
||
474 | end ;
|
||
475 | |||
476 | procedure TFResBesLactT.CBNRJ1Change (Sender : TObject) ;
|
||
477 | begin
|
||
478 | case CBNRJ1.ItemIndex of |
||
479 | 0 : // R?partition globale |
||
480 | CBNRJ2.Visible := FALSE ; |
||
481 | 1 : // R?partition dynamique |
||
482 | CBNRJ2.Visible := TRUE ; |
||
483 | end ;
|
||
484 | AffGraphNRJ ; |
||
485 | end ;
|
||
486 | |||
487 | procedure TFResBesLactT.CBNRJ2Change (Sender : TObject) ;
|
||
488 | begin
|
||
489 | AffGraphNRJ ; |
||
490 | end ;
|
||
491 | |||
492 | procedure TFResBesLactT.CBNRJ3Change (Sender : TObject) ;
|
||
493 | begin
|
||
494 | AffGraphNRJ ; |
||
495 | end ;
|
||
496 | |||
497 | procedure TFResBesLactT.CBNRJ4Change (Sender : TObject) ;
|
||
498 | begin
|
||
499 | AffGraphNRJ ; |
||
500 | end ;
|
||
501 | |||
502 | ///////////////////////
|
||
503 | // Acides amin?s //
|
||
504 | ///////////////////////
|
||
505 | procedure TFResBesLactT.InitAA ;
|
||
506 | const
|
||
507 | TabColor : array[0..1] of TColor |
||
508 | = (clOlive, clWhite) ; |
||
509 | var
|
||
510 | i : integer ; |
||
511 | begin
|
||
512 | // ListAA : liste pour les acides amin?s
|
||
513 | ListAA := TStringList.Create ; |
||
514 | ListAA.Assign (LBAA.Items) ; |
||
515 | // BarAA : s?rie (barre) graphique
|
||
516 | BarAA := THorizBarSeries.Create (Graph) ; |
||
517 | BarAA.ParentChart := Graph ; |
||
518 | BarAA.Title := ' ' ;
|
||
519 | BarAA.SeriesColor := clTeal ; |
||
520 | BarAA.BarPen.Color := BarAA.SeriesColor ; |
||
521 | BarAA.Marks.Visible := FALSE ; |
||
522 | BarAA.MultiBar := mbSide ; |
||
523 | Graph.AddSeries (BarAA) ; |
||
524 | // AreaAA : s?ries (aires) graphiques
|
||
525 | SetLength (AreaAA, ListAA.Count) ; |
||
526 | for i := 0 to ListAA.Count - 1 do |
||
527 | begin
|
||
528 | AreaAA[i] := TAreaSeries.Create (Graph) ; |
||
529 | AreaAA[i].ParentChart := Graph ; |
||
530 | AreaAA[i].Title := ListAA[i] ; |
||
531 | AreaAA[i].SeriesColor := TabColor[i] ; |
||
532 | AreaAA[i].AreaLinesPen.Visible := FALSE ; |
||
533 | Graph.AddSeries (AreaAA[i]) ; |
||
534 | end ;
|
||
535 | // LineAA : s?rie (ligne) graphique
|
||
536 | LineAA := TLineSeries.Create (Graph) ; |
||
537 | LineAA.ParentChart := Graph ; |
||
538 | LineAA.Title := StrReference ; |
||
539 | LineAA.SeriesColor := clBlack ; |
||
540 | LineAA.LinePen.Color := LineAA.SeriesColor ; |
||
541 | LineAA.LinePen.Width := 2 ;
|
||
542 | Graph.AddSeries (LineAA) ; |
||
543 | end ;
|
||
544 | |||
545 | procedure TFResBesLactT.AffGraphAA ;
|
||
546 | var
|
||
547 | h, i, j : integer ; |
||
548 | t : double ; |
||
549 | |||
550 | // Abscisse
|
||
551 | function AAX : double ;
|
||
552 | begin
|
||
553 | case CBAA1.ItemIndex of |
||
554 | 0 : // R?partition dynamique |
||
555 | case CBAA2.ItemIndex of |
||
556 | 0 : // Dur?e |
||
557 | result := j - 1 ;
|
||
558 | else
|
||
559 | result := 0 ;
|
||
560 | end ;
|
||
561 | else
|
||
562 | result := 0 ;
|
||
563 | end ;
|
||
564 | end ;
|
||
565 | |||
566 | // Ordonn?e
|
||
567 | function AAY : double ;
|
||
568 | var
|
||
569 | a : integer ; |
||
570 | d : double ; |
||
571 | begin
|
||
572 | case h of |
||
573 | 3 : // met+cys |
||
574 | a := 13 ;
|
||
575 | 7 : // phe+tyr |
||
576 | a := 14 ;
|
||
577 | else
|
||
578 | a := h ; |
||
579 | end ;
|
||
580 | case CBAA1.ItemIndex of |
||
581 | 0 : // R?partition dynamique |
||
582 | begin
|
||
583 | // Diviseur
|
||
584 | case CBAA4.ItemIndex of |
||
585 | 2 : // Aliment |
||
586 | d := FBesLactT.AppAli[j] ; |
||
587 | 3 : // ED |
||
588 | d := FBesLactT.AppED[j] ; |
||
589 | 4 : // EM |
||
590 | d := FBesLactT.AppEM[j] ; |
||
591 | 5 : // EN |
||
592 | d := FBesLactT.AppEN[j] ; |
||
593 | else
|
||
594 | d := 1 ;
|
||
595 | end ;
|
||
596 | case i of |
||
597 | -1 : // Apport |
||
598 | result := FBesLactT.AppAA[a, j] / d ; |
||
599 | 0 : // Entretien |
||
600 | result := FBesLactT.BesAAEnt[a, j] / d ; |
||
601 | 1 : // Lait |
||
602 | result := FBesLactT.BesAALait[a, j] / d ; |
||
603 | else
|
||
604 | result := 0 ;
|
||
605 | end ;
|
||
606 | end ;
|
||
607 | 1 : // Besoin |
||
608 | begin
|
||
609 | // Diviseur
|
||
610 | case CBAA4.ItemIndex of |
||
611 | 1 : // Lysine |
||
612 | d := Mean (Slice (FBesLactT.BesAA[1], FBesLactT.DureeLact)) / 100 ; |
||
613 | else
|
||
614 | d := 1 ;
|
||
615 | end ;
|
||
616 | result := Mean (Slice (FBesLactT.BesAA[a], FBesLactT.DureeLact)) / d ; |
||
617 | end ;
|
||
618 | else
|
||
619 | result := 0 ;
|
||
620 | end ;
|
||
621 | end ;
|
||
622 | |||
623 | // AffGraphAA
|
||
624 | begin
|
||
625 | ResetGraph ; |
||
626 | Graph.Title.Text.Add (CBAA1.Text) ; |
||
627 | Graph.SubTitle.Text.Add(StrDigestStd); |
||
628 | case CBAA1.ItemIndex of |
||
629 | 0 : // R?partition dynamique |
||
630 | begin
|
||
631 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBAA3.Text, CBAA4.Text]) ;
|
||
632 | Graph.BottomAxis.Title.Caption := CBAA2.Text ; |
||
633 | h := CBAA3.ItemIndex + 1 ;
|
||
634 | // Affichage des aires
|
||
635 | for i := 0 to ListAA.Count - 1 do |
||
636 | AreaAA[i].Active := TRUE ; |
||
637 | for i := 0 to ListAA.Count - 1 do |
||
638 | AreaAA[i].Clear ; |
||
639 | if (CBAA4.ItemIndex = 1) |
||
640 | then
|
||
641 | for i := 0 to ListAA.Count - 1 do |
||
642 | AreaAA[i].MultiArea := maStacked100 |
||
643 | else
|
||
644 | for i := 0 to ListAA.Count - 1 do |
||
645 | AreaAA[i].MultiArea := maStacked ; |
||
646 | for i := 0 to ListAA.Count - 1 do |
||
647 | for j := 1 to FBesLactT.DureeLact do |
||
648 | AreaAA[i].AddXY (AAX, AAY, '', clTeeColor) ;
|
||
649 | // Affichage de la ligne
|
||
650 | i := -1 ;
|
||
651 | LineAA.Active := TRUE ; |
||
652 | LineAA.Clear ; |
||
653 | for j := 1 to FBesLactT.DureeLact do |
||
654 | if (CBAA4.ItemIndex = 1) |
||
655 | then
|
||
656 | begin
|
||
657 | case h of |
||
658 | 3 : // met+cys |
||
659 | t := FBesLactT.BesAA[13, j] ;
|
||
660 | 7 : // phe+tyr |
||
661 | t := FBesLactT.BesAA[14, j] ;
|
||
662 | else
|
||
663 | t := FBesLactT.BesAA[h, j] ; |
||
664 | end ;
|
||
665 | LineAA.AddXY (AAX, AAY / t * 100, '', clTeeColor) ; |
||
666 | end
|
||
667 | else
|
||
668 | LineAA.AddXY (AAX, AAY, '', clTeeColor) ;
|
||
669 | AjustEchelle (Graph) ; |
||
670 | end ;
|
||
671 | 1 : // Besoin |
||
672 | begin
|
||
673 | Graph.Legend.Visible := FALSE ; |
||
674 | Graph.LeftAxis.Automatic := TRUE ; |
||
675 | Graph.LeftAxis.Title.Caption := TabAA.Caption ; |
||
676 | Graph.BottomAxis.Title.Caption := Format ('%s (%s)', [StrBesoin, CBAA4.Text]) ;
|
||
677 | // Affichage des barres
|
||
678 | BarAA.Active := TRUE ; |
||
679 | BarAA.Clear ; |
||
680 | for h := CBAA3.Items.Count downto 1 do |
||
681 | BarAA.AddBar (AAY, CBAA3.Items[h - 1], clTeeColor) ;
|
||
682 | end ;
|
||
683 | end ;
|
||
684 | end ;
|
||
685 | |||
686 | procedure TFResBesLactT.CBAA1Change (Sender : TObject) ;
|
||
687 | begin
|
||
688 | CBAA4.Items.Clear ; |
||
689 | case CBAA1.ItemIndex of |
||
690 | 0 : // R?partition dynamique |
||
691 | begin
|
||
692 | CBAA2.Visible := TRUE ; |
||
693 | CBAA3.Visible := TRUE ; |
||
694 | // Unit?s
|
||
695 | CBAA4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
696 | CBAA4.Items.Add (Format ('%% %s', [StrBesoin])) ;
|
||
697 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrKg, StrAlimentUnit])) ;
|
||
698 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrMJ, StrED])) ;
|
||
699 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrMJ, StrEM])) ;
|
||
700 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrMJ, StrEN])) ;
|
||
701 | end ;
|
||
702 | 1 : // Besoin |
||
703 | begin
|
||
704 | if AffBesoin
|
||
705 | then
|
||
706 | begin
|
||
707 | FWarning := TFWarning.Create (Self) ; |
||
708 | with FWarning do |
||
709 | begin
|
||
710 | Msg := 'Besoin';
|
||
711 | ShowModal ; |
||
712 | Release ; |
||
713 | AffBesoin := FALSE ; |
||
714 | end ;
|
||
715 | end ;
|
||
716 | CBAA2.Visible := FALSE ; |
||
717 | CBAA3.Visible := FALSE ; |
||
718 | // Unit?s
|
||
719 | CBAA4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
720 | CBAA4.Items.Add (Format ('%% %s', [StrLys])) ;
|
||
721 | end ;
|
||
722 | end ;
|
||
723 | CBAA4.ItemIndex := 0 ;
|
||
724 | AffGraphAA ; |
||
725 | end ;
|
||
726 | |||
727 | procedure TFResBesLactT.CBAA2Change (Sender : TObject) ;
|
||
728 | begin
|
||
729 | AffGraphAA ; |
||
730 | end ;
|
||
731 | |||
732 | procedure TFResBesLactT.CBAA3Change (Sender : TObject) ;
|
||
733 | begin
|
||
734 | AffGraphAA ; |
||
735 | end ;
|
||
736 | |||
737 | procedure TFResBesLactT.CBAA4Change (Sender : TObject) ;
|
||
738 | begin
|
||
739 | AffGraphAA ; |
||
740 | end ;
|
||
741 | |||
742 | procedure TFResBesLactT.WMSysCommand(var Message: TWMSysCommand); |
||
743 | begin
|
||
744 | if Message.CmdType = SC_MINIMIZE
|
||
745 | then
|
||
746 | Application.Minimize |
||
747 | else
|
||
748 | inherited;
|
||
749 | end;
|
||
750 | |||
751 | end. |