Statistiques
| Révision:

root / UnitFeedsCharts.pas @ 4

Historique | Voir | Annoter | Télécharger (128,406 ko)

1 1 avalancogn
unit UnitFeedsCharts;
2
3
interface
4
5
uses
6
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
  gnugettext, StdCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, Series, Buttons,
8
  Math, ComCtrls, ImgList, ActnList, JvExStdCtrls, JvButton, JvCtrls;
9
10
type
11
  TFormFeedsCharts = class(TForm)
12
    GroupBoxFeed1: TGroupBox;
13
    PanelFeed1: TPanel;
14
    ChartFeed1: TChart;
15
    GroupBoxChartSelection: TGroupBox;
16
    GroupBoxFeed2: TGroupBox;
17
    PanelFeed2: TPanel;
18
    ChartFeed2: TChart;
19
    GroupBoxFeed3: TGroupBox;
20
    PanelFeed3: TPanel;
21
    ChartFeed3: TChart;
22
    GroupBoxFeed4: TGroupBox;
23
    PanelFeed4: TPanel;
24
    ChartFeed4: TChart;
25
    SpeedButton2D3D1: TSpeedButton;
26
    SpeedButton2D3D2: TSpeedButton;
27
    SpeedButton2D3D3: TSpeedButton;
28
    SpeedButton2D3D4: TSpeedButton;
29
    SpeedButtonPrint1: TSpeedButton;
30
    SpeedButtonPrint2: TSpeedButton;
31
    SpeedButtonPrint3: TSpeedButton;
32
    SpeedButtonPrint4: TSpeedButton;
33
    PanelButtons: TPanel;
34
    PageControlFeedsChats: TPageControl;
35
    TabSheetSingleChart: TTabSheet;
36
    TabSheetChartsComparison: TTabSheet;
37
    GroupBoxChart0: TGroupBox;
38
    Chart0: TChart;
39
    SpeedButton2D3D0: TSpeedButton;
40
    SpeedButtonPrint0: TSpeedButton;
41
    LabelDiet1: TLabel;
42
    LabelDiet2: TLabel;
43
    LabelDiet3: TLabel;
44
    LabelDiet4: TLabel;
45
    LabelDiet5: TLabel;
46
    LabelDiet6: TLabel;
47
    ComboBoxRatios0: TComboBox;
48
    ComboBoxAA0: TComboBox;
49
    ComboBoxEnergy0: TComboBox;
50
    ComboBoxMinerals0: TComboBox;
51
    ComboBoxProximal0: TComboBox;
52
    ComboBoxType0: TComboBox;
53
    ComboBoxDiet1: TComboBox;
54
    ComboBoxDiet2: TComboBox;
55
    ComboBoxDiet3: TComboBox;
56
    ComboBoxDiet4: TComboBox;
57
    ComboBoxDiet5: TComboBox;
58
    ComboBoxDiet6: TComboBox;
59
    ComboBoxAA: TComboBox;
60
    ComboBoxEnergy: TComboBox;
61
    ComboBoxMinerals: TComboBox;
62
    ComboBoxProximal: TComboBox;
63
    ComboBoxType: TComboBox;
64
    ComboBoxFeed1: TComboBox;
65
    ComboBoxFeed2: TComboBox;
66
    ComboBoxFeed3: TComboBox;
67
    ComboBoxFeed4: TComboBox;
68
    JvImgBtnClose: TJvImgBtn;
69
    JvImgBtnHelp: TJvImgBtn;
70
    ActionListButtons: TActionList;
71
    ActionHelp: TAction;
72
    ActionClose: TAction;
73
    ImageListIcons: TImageList;
74
    SeriesBar: TBarSeries;
75
    procedure FormCreate(Sender: TObject);
76
    procedure ComboBoxTypeChange(Sender: TObject);
77
    procedure ComboBoxOptionChange(Sender: TObject);
78
    procedure ComboBoxFeed1Change(Sender: TObject);
79
    procedure ComboBoxFeed2Change(Sender: TObject);
80
    procedure ComboBoxFeed3Change(Sender: TObject);
81
    procedure ComboBoxFeed4Change(Sender: TObject);
82
    procedure FormResize(Sender: TObject);
83
    procedure SpeedButton2D3D1Click(Sender: TObject);
84
    procedure SpeedButton2D3D2Click(Sender: TObject);
85
    procedure SpeedButton2D3D3Click(Sender: TObject);
86
    procedure SpeedButton2D3D4Click(Sender: TObject);
87
    procedure SpeedButtonPrint1Click(Sender: TObject);
88
    procedure SpeedButtonPrint2Click(Sender: TObject);
89
    procedure SpeedButtonPrint3Click(Sender: TObject);
90
    procedure SpeedButtonPrint4Click(Sender: TObject);
91
    procedure ComboBoxType0Change(Sender: TObject);
92
    procedure ComboBoxOption0Change(Sender: TObject);
93
    procedure ComboBoxDietChange(Sender: TObject);
94
    procedure SpeedButton2D3D0Click(Sender: TObject);
95
    procedure SpeedButtonPrint0Click(Sender: TObject);
96
    procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
97
    procedure ActionHelpExecute(Sender: TObject);
98
    procedure ActionCloseExecute(Sender: TObject);
99
  private
100
    { D?clarations priv?es }
101
  public
102
    { D?clarations publiques }
103
  end;
104
105
var
106
  FormFeedsCharts: TFormFeedsCharts;
107
108
implementation
109
110
uses
111
  UnitDeclaration, UnitOptions, UnitChartHReport;
112
113
{$R *.dfm}
114
115
procedure TFormFeedsCharts.ActionCloseExecute(Sender: TObject);
116
begin
117
  ModalResult := mrClose;
118
end;
119
120
procedure TFormFeedsCharts.ActionHelpExecute(Sender: TObject);
121
begin
122
  Application.HelpContext(HelpContext);
123
end;
124
125
procedure TFormFeedsCharts.ComboBoxDietChange(Sender: TObject);
126
var
127
//  FeedBar: TBarSeries;
128
  s: string;
129
130
  procedure AddBarValue;
131
  begin
132
    with DataModuleDeclaration do
133
      case ComboBoxType0.ItemIndex of
134
        0: // Analyse proximale
135
          case ComboBoxProximal0.ItemIndex of
136
            0: // MS
137
              if not ClientDataSetFeedsMS.IsNull
138
              then SeriesBar.AddBar(ClientDataSetFeedsMS.Value, s, clTeeColor)
139
              else SeriesBar.AddNull(s);
140
            1: // MM
141
              if not ClientDataSetFeedsMM.IsNull
142
              then SeriesBar.AddBar(ClientDataSetFeedsMM.Value, s, clTeeColor)
143
              else SeriesBar.AddNull(s);
144
            2: // MAT
145
              if not ClientDataSetFeedsMAT.IsNull
146
              then SeriesBar.AddBar(ClientDataSetFeedsMAT.Value, s, clTeeColor)
147
              else SeriesBar.AddNull(s);
148
            3: // MG
149
              if not ClientDataSetFeedsMG.IsNull
150
              then SeriesBar.AddBar(ClientDataSetFeedsMG.Value, s, clTeeColor)
151
              else SeriesBar.AddNull(s);
152
            4: // CB
153
              if not ClientDataSetFeedsCB.IsNull
154
              then SeriesBar.AddBar(ClientDataSetFeedsCB.Value, s, clTeeColor)
155
              else SeriesBar.AddNull(s);
156
            5: // NDF
157
              if not ClientDataSetFeedsNDF.IsNull
158
              then SeriesBar.AddBar(ClientDataSetFeedsNDF.Value, s, clTeeColor)
159
              else SeriesBar.AddNull(s);
160
            6: // ADF
161
              if not ClientDataSetFeedsADF.IsNull
162
              then SeriesBar.AddBar(ClientDataSetFeedsADF.Value, s, clTeeColor)
163
              else SeriesBar.AddNull(s);
164
            7: // ADL
165
              if not ClientDataSetFeedsADL.IsNull
166
              then SeriesBar.AddBar(ClientDataSetFeedsADL.Value, s, clTeeColor)
167
              else SeriesBar.AddNull(s);
168
            8: // Amidon
169
              if not ClientDataSetFeedsAmidon.IsNull
170
              then SeriesBar.AddBar(ClientDataSetFeedsAmidon.Value, s, clTeeColor)
171
              else SeriesBar.AddNull(s);
172
            9: // Sucres
173
              if not ClientDataSetFeedsSucres.IsNull
174
              then SeriesBar.AddBar(ClientDataSetFeedsSucres.Value, s, clTeeColor)
175
              else SeriesBar.AddNull(s);
176
          end;
177
        1: // Valeurs ?nerg?tiques
178
          case ComboBoxEnergy0.ItemIndex of
179
            0: // Energie brute
180
              if not ClientDataSetFeedsEB.IsNull
181
              then SeriesBar.AddBar(ClientDataSetFeedsEB.Value, s, clTeeColor)
182
              else SeriesBar.AddNull(s);
183
            1: // Energie digestible (porc croissance)
184
              if not ClientDataSetFeedsEDc.IsNull
185
              then SeriesBar.AddBar(ClientDataSetFeedsEDc.Value, s, clTeeColor)
186
              else SeriesBar.AddNull(s);
187
            2: // Energie digestible (porc adulte)
188
              if not ClientDataSetFeedsEDt.IsNull
189
              then SeriesBar.AddBar(ClientDataSetFeedsEDt.Value, s, clTeeColor)
190
              else SeriesBar.AddNull(s);
191
            3: // Energie m?tabolisable (porc croissance)
192
              if not ClientDataSetFeedsEMc.IsNull
193
              then SeriesBar.AddBar(ClientDataSetFeedsEMc.Value, s, clTeeColor)
194
              else SeriesBar.AddNull(s);
195
            4: // Energie m?tabolisable (porc adulte)
196
              if not ClientDataSetFeedsEMt.IsNull
197
              then SeriesBar.AddBar(ClientDataSetFeedsEMt.Value, s, clTeeColor)
198
              else SeriesBar.AddNull(s);
199
            5: // Energie nette (porc croissance)
200
              if not ClientDataSetFeedsENc.IsNull
201
              then SeriesBar.AddBar(ClientDataSetFeedsENc.Value, s, clTeeColor)
202
              else SeriesBar.AddNull(s);
203
            6: // Energie nette (porc adulte)
204
              if not ClientDataSetFeedsENt.IsNull
205
              then SeriesBar.AddBar(ClientDataSetFeedsENt.Value, s, clTeeColor)
206
              else SeriesBar.AddNull(s);
207
          end;
208
        2: // Rapports ?nerg?tiques
209
          case ComboBoxRatios0.ItemIndex of
210
            0: // Phosphore digestible / Energie nette (porc croissance)
211
              if not ClientDataSetFeedsPd_ENc.IsNull
212
              then SeriesBar.AddBar(ClientDataSetFeedsPd_ENc.Value, s, clTeeColor)
213
              else SeriesBar.AddNull(s);
214
            1: // Phosphore digestible / Energie nette (porc adulte)
215
              if not ClientDataSetFeedsPd_ENt.IsNull
216
              then SeriesBar.AddBar(ClientDataSetFeedsPd_ENt.Value, s, clTeeColor)
217
              else SeriesBar.AddNull(s);
218
            2: // Lysine digestible / Energie nette (porc croissance)
219
              if not ClientDataSetFeedsLysd_ENc.IsNull
220
              then SeriesBar.AddBar(ClientDataSetFeedsLysd_ENc.Value, s, clTeeColor)
221
              else SeriesBar.AddNull(s);
222
            3: // Lysine digestible / Energie nette (porc adulte)
223
              if not ClientDataSetFeedsLysd_ENt.IsNull
224
              then SeriesBar.AddBar(ClientDataSetFeedsLysd_ENt.Value, s, clTeeColor)
225
              else SeriesBar.AddNull(s);
226
          end;
227
        3: // Acides amin?s totaux
228
          case ComboBoxAA0.ItemIndex of
229
            0: // Lysine
230
              if not ClientDataSetFeedsLys.IsNull
231
              then SeriesBar.AddBar(ClientDataSetFeedsLys.Value, s, clTeeColor)
232
              else SeriesBar.AddNull(s);
233
            1: // Thr?onine
234
              if not ClientDataSetFeedsThr.IsNull
235
              then SeriesBar.AddBar(ClientDataSetFeedsThr.Value, s, clTeeColor)
236
              else SeriesBar.AddNull(s);
237
            2: // M?thionine
238
              if not ClientDataSetFeedsMet.IsNull
239
              then SeriesBar.AddBar(ClientDataSetFeedsMet.Value, s, clTeeColor)
240
              else SeriesBar.AddNull(s);
241
            3: // Cyst?ine
242
              if not ClientDataSetFeedsCys.IsNull
243
              then SeriesBar.AddBar(ClientDataSetFeedsCys.Value, s, clTeeColor)
244
              else SeriesBar.AddNull(s);
245
            4: // M?thionine + Cyst?ine
246
              if not ClientDataSetFeedsMetCys.IsNull
247
              then SeriesBar.AddBar(ClientDataSetFeedsMetCys.Value, s, clTeeColor)
248
              else SeriesBar.AddNull(s);
249
            5: // Tryptophane
250
              if not ClientDataSetFeedsTrp.IsNull
251
              then SeriesBar.AddBar(ClientDataSetFeedsTrp.Value, s, clTeeColor)
252
              else SeriesBar.AddNull(s);
253
            6: // Isoleucine
254
              if not ClientDataSetFeedsIle.IsNull
255
              then SeriesBar.AddBar(ClientDataSetFeedsIle.Value, s, clTeeColor)
256
              else SeriesBar.AddNull(s);
257
            7: // Valine
258
              if not ClientDataSetFeedsVal.IsNull
259
              then SeriesBar.AddBar(ClientDataSetFeedsVal.Value, s, clTeeColor)
260
              else SeriesBar.AddNull(s);
261
            8: // Leucine
262
              if not ClientDataSetFeedsLeu.IsNull
263
              then SeriesBar.AddBar(ClientDataSetFeedsLeu.Value, s, clTeeColor)
264
              else SeriesBar.AddNull(s);
265
            9: // Ph?nylalanine
266
              if not ClientDataSetFeedsPhe.IsNull
267
              then SeriesBar.AddBar(ClientDataSetFeedsPhe.Value, s, clTeeColor)
268
              else SeriesBar.AddNull(s);
269
            10: // Tyrosine
270
              if not ClientDataSetFeedsTyr.IsNull
271
              then SeriesBar.AddBar(ClientDataSetFeedsTyr.Value, s, clTeeColor)
272
              else SeriesBar.AddNull(s);
273
            11: // Ph?nylalanine + Tyrosine
274
              if not ClientDataSetFeedsPheTyr.IsNull
275
              then SeriesBar.AddBar(ClientDataSetFeedsPheTyr.Value, s, clTeeColor)
276
              else SeriesBar.AddNull(s);
277
            12: // Histidine
278
              if not ClientDataSetFeedsHis.IsNull
279
              then SeriesBar.AddBar(ClientDataSetFeedsHis.Value, s, clTeeColor)
280
              else SeriesBar.AddNull(s);
281
            13: // Arginine
282
              if not ClientDataSetFeedsArg.IsNull
283
              then SeriesBar.AddBar(ClientDataSetFeedsArg.Value, s, clTeeColor)
284
              else SeriesBar.AddNull(s);
285
            14: // Alanine
286
              if not ClientDataSetFeedsAla.IsNull
287
              then SeriesBar.AddBar(ClientDataSetFeedsAla.Value, s, clTeeColor)
288
              else SeriesBar.AddNull(s);
289
            15: // Aspartate
290
              if not ClientDataSetFeedsAsp.IsNull
291
              then SeriesBar.AddBar(ClientDataSetFeedsAsp.Value, s, clTeeColor)
292
              else SeriesBar.AddNull(s);
293
            16: // Glutamate
294
              if not ClientDataSetFeedsGlu.IsNull
295
              then SeriesBar.AddBar(ClientDataSetFeedsGlu.Value, s, clTeeColor)
296
              else SeriesBar.AddNull(s);
297
            17: // Glycine
298
              if not ClientDataSetFeedsGly.IsNull
299
              then SeriesBar.AddBar(ClientDataSetFeedsGly.Value, s, clTeeColor)
300
              else SeriesBar.AddNull(s);
301
            18: // S?rine
302
              if not ClientDataSetFeedsSer.IsNull
303
              then SeriesBar.AddBar(ClientDataSetFeedsSer.Value, s, clTeeColor)
304
              else SeriesBar.AddNull(s);
305
            19: // Proline
306
              if not ClientDataSetFeedsPro.IsNull
307
              then SeriesBar.AddBar(ClientDataSetFeedsPro.Value, s, clTeeColor)
308
              else SeriesBar.AddNull(s);
309
          end;
310
        4: // Acides amin?s digestibles
311
          case ComboBoxAA0.ItemIndex of
312
            0: // Lysine
313
              if not ClientDataSetFeedsLysd.IsNull
314
              then SeriesBar.AddBar(ClientDataSetFeedsLysd.Value, s, clTeeColor)
315
              else SeriesBar.AddNull(s);
316
            1: // Thr?onine
317
              if not ClientDataSetFeedsThrd.IsNull
318
              then SeriesBar.AddBar(ClientDataSetFeedsThrd.Value, s, clTeeColor)
319
              else SeriesBar.AddNull(s);
320
            2: // M?thionine
321
              if not ClientDataSetFeedsMetd.IsNull
322
              then SeriesBar.AddBar(ClientDataSetFeedsMetd.Value, s, clTeeColor)
323
              else SeriesBar.AddNull(s);
324
            3: // Cyst?ine
325
              if not ClientDataSetFeedsCysd.IsNull
326
              then SeriesBar.AddBar(ClientDataSetFeedsCysd.Value, s, clTeeColor)
327
              else SeriesBar.AddNull(s);
328
            4: // M?thionine + Cyst?ine
329
              if not ClientDataSetFeedsMetCysd.IsNull
330
              then SeriesBar.AddBar(ClientDataSetFeedsMetCysd.Value, s, clTeeColor)
331
              else SeriesBar.AddNull(s);
332
            5: // Tryptophane
333
              if not ClientDataSetFeedsTrpd.IsNull
334
              then SeriesBar.AddBar(ClientDataSetFeedsTrpd.Value, s, clTeeColor)
335
              else SeriesBar.AddNull(s);
336
            6: // Isoleucine
337
              if not ClientDataSetFeedsIled.IsNull
338
              then SeriesBar.AddBar(ClientDataSetFeedsIled.Value, s, clTeeColor)
339
              else SeriesBar.AddNull(s);
340
            7: // Valine
341
              if not ClientDataSetFeedsVald.IsNull
342
              then SeriesBar.AddBar(ClientDataSetFeedsVald.Value, s, clTeeColor)
343
              else SeriesBar.AddNull(s);
344
            8: // Leucine
345
              if not ClientDataSetFeedsLeud.IsNull
346
              then SeriesBar.AddBar(ClientDataSetFeedsLeud.Value, s, clTeeColor)
347
              else SeriesBar.AddNull(s);
348
            9: // Ph?nylalanine
349
              if not ClientDataSetFeedsPhed.IsNull
350
              then SeriesBar.AddBar(ClientDataSetFeedsPhed.Value, s, clTeeColor)
351
              else SeriesBar.AddNull(s);
352
            10: // Tyrosine
353
              if not ClientDataSetFeedsTyrd.IsNull
354
              then SeriesBar.AddBar(ClientDataSetFeedsTyrd.Value, s, clTeeColor)
355
              else SeriesBar.AddNull(s);
356
            11: // Ph?nylalanine + Tyrosine
357
              if not ClientDataSetFeedsPheTyrd.IsNull
358
              then SeriesBar.AddBar(ClientDataSetFeedsPheTyrd.Value, s, clTeeColor)
359
              else SeriesBar.AddNull(s);
360
            12: // Histidine
361
              if not ClientDataSetFeedsHisd.IsNull
362
              then SeriesBar.AddBar(ClientDataSetFeedsHisd.Value, s, clTeeColor)
363
              else SeriesBar.AddNull(s);
364
            13: // Arginine
365
              if not ClientDataSetFeedsArgd.IsNull
366
              then SeriesBar.AddBar(ClientDataSetFeedsArgd.Value, s, clTeeColor)
367
              else SeriesBar.AddNull(s);
368
            14: // Alanine
369
              if not ClientDataSetFeedsAlad.IsNull
370
              then SeriesBar.AddBar(ClientDataSetFeedsAlad.Value, s, clTeeColor)
371
              else SeriesBar.AddNull(s);
372
            15: // Aspartate
373
              if not ClientDataSetFeedsAspd.IsNull
374
              then SeriesBar.AddBar(ClientDataSetFeedsAspd.Value, s, clTeeColor)
375
              else SeriesBar.AddNull(s);
376
            16: // Glutamate
377
              if not ClientDataSetFeedsGlud.IsNull
378
              then SeriesBar.AddBar(ClientDataSetFeedsGlud.Value, s, clTeeColor)
379
              else SeriesBar.AddNull(s);
380
            17: // Glycine
381
              if not ClientDataSetFeedsGlyd.IsNull
382
              then SeriesBar.AddBar(ClientDataSetFeedsGlyd.Value, s, clTeeColor)
383
              else SeriesBar.AddNull(s);
384
            18: // S?rine
385
              if not ClientDataSetFeedsSerd.IsNull
386
              then SeriesBar.AddBar(ClientDataSetFeedsSerd.Value, s, clTeeColor)
387
              else SeriesBar.AddNull(s);
388
            19: // Proline
389
              if not ClientDataSetFeedsProd.IsNull
390
              then SeriesBar.AddBar(ClientDataSetFeedsProd.Value, s, clTeeColor)
391
              else SeriesBar.AddNull(s);
392
          end;
393
        5: // Profils acides amin?s
394
          case ComboBoxAA0.ItemIndex of
395
            0: // Lysine
396
              if not ClientDataSetFeedsLysd.IsNull and (ClientDataSetFeedsLysd.Value <> 0)
397
              then SeriesBar.AddBar(100, s, clTeeColor)
398
              else SeriesBar.AddNull(s);
399
            1: // Thr?onine
400
              if not ClientDataSetFeedsThrd_Lysd.IsNull
401
              then SeriesBar.AddBar(ClientDataSetFeedsThrd_Lysd.Value, s, clTeeColor)
402
              else SeriesBar.AddNull(s);
403
            2: // M?thionine
404
              if not ClientDataSetFeedsMetd_Lysd.IsNull
405
              then SeriesBar.AddBar(ClientDataSetFeedsMetd_Lysd.Value, s, clTeeColor)
406
              else SeriesBar.AddNull(s);
407
            3: // Cyst?ine
408
              if not ClientDataSetFeedsCysd_Lysd.IsNull
409
              then SeriesBar.AddBar(ClientDataSetFeedsCysd_Lysd.Value, s, clTeeColor)
410
              else SeriesBar.AddNull(s);
411
            4: // M?thionine + Cyst?ine
412
              if not ClientDataSetFeedsMetCysd_Lysd.IsNull
413
              then SeriesBar.AddBar(ClientDataSetFeedsMetCysd_Lysd.Value, s, clTeeColor)
414
              else SeriesBar.AddNull(s);
415
            5: // Tryptophane
416
              if not ClientDataSetFeedsTrpd_Lysd.IsNull
417
              then SeriesBar.AddBar(ClientDataSetFeedsTrpd_Lysd.Value, s, clTeeColor)
418
              else SeriesBar.AddNull(s);
419
            6: // Isoleucine
420
              if not ClientDataSetFeedsIled_Lysd.IsNull
421
              then SeriesBar.AddBar(ClientDataSetFeedsIled_Lysd.Value, s, clTeeColor)
422
              else SeriesBar.AddNull(s);
423
            7: // Valine
424
              if not ClientDataSetFeedsVald_Lysd.IsNull
425
              then SeriesBar.AddBar(ClientDataSetFeedsVald_Lysd.Value, s, clTeeColor)
426
              else SeriesBar.AddNull(s);
427
            8: // Leucine
428
              if not ClientDataSetFeedsLeud_Lysd.IsNull
429
              then SeriesBar.AddBar(ClientDataSetFeedsLeud_Lysd.Value, s, clTeeColor)
430
              else SeriesBar.AddNull(s);
431
            9: // Ph?nylalanine
432
              if not ClientDataSetFeedsPhed_Lysd.IsNull
433
              then SeriesBar.AddBar(ClientDataSetFeedsPhed_Lysd.Value, s, clTeeColor)
434
              else SeriesBar.AddNull(s);
435
            10: // Tyrosine
436
              if not ClientDataSetFeedsTyrd_Lysd.IsNull
437
              then SeriesBar.AddBar(ClientDataSetFeedsTyrd_Lysd.Value, s, clTeeColor)
438
              else SeriesBar.AddNull(s);
439
            11: // Ph?nylalanine + Tyrosine
440
              if not ClientDataSetFeedsPheTyrd_Lysd.IsNull
441
              then SeriesBar.AddBar(ClientDataSetFeedsPheTyrd_Lysd.Value, s, clTeeColor)
442
              else SeriesBar.AddNull(s);
443
            12: // Histidine
444
              if not ClientDataSetFeedsHisd_Lysd.IsNull
445
              then SeriesBar.AddBar(ClientDataSetFeedsHisd_Lysd.Value, s, clTeeColor)
446
              else SeriesBar.AddNull(s);
447
            13: // Arginine
448
              if not ClientDataSetFeedsArgd_Lysd.IsNull
449
              then SeriesBar.AddBar(ClientDataSetFeedsArgd_Lysd.Value, s, clTeeColor)
450
              else SeriesBar.AddNull(s);
451
            14: // Alanine
452
              if not ClientDataSetFeedsAlad_Lysd.IsNull
453
              then SeriesBar.AddBar(ClientDataSetFeedsAlad_Lysd.Value, s, clTeeColor)
454
              else SeriesBar.AddNull(s);
455
            15: // Aspartate
456
              if not ClientDataSetFeedsAspd_Lysd.IsNull
457
              then SeriesBar.AddBar(ClientDataSetFeedsAspd_Lysd.Value, s, clTeeColor)
458
              else SeriesBar.AddNull(s);
459
            16: // Glutamate
460
              if not ClientDataSetFeedsGlud_Lysd.IsNull
461
              then SeriesBar.AddBar(ClientDataSetFeedsGlud_Lysd.Value, s, clTeeColor)
462
              else SeriesBar.AddNull(s);
463
            17: // Glycine
464
              if not ClientDataSetFeedsGlyd_Lysd.IsNull
465
              then SeriesBar.AddBar(ClientDataSetFeedsGlyd_Lysd.Value, s, clTeeColor)
466
              else SeriesBar.AddNull(s);
467
            18: // S?rine
468
              if not ClientDataSetFeedsSerd_Lysd.IsNull
469
              then SeriesBar.AddBar(ClientDataSetFeedsSerd_Lysd.Value, s, clTeeColor)
470
              else SeriesBar.AddNull(s);
471
            19: // Proline
472
              if not ClientDataSetFeedsProd_Lysd.IsNull
473
              then SeriesBar.AddBar(ClientDataSetFeedsProd_Lysd.Value, s, clTeeColor)
474
              else SeriesBar.AddNull(s);
475
          end;
476
        6: // Min?raux
477
          case ComboBoxMinerals0.ItemIndex of
478
            0: // Calcium
479
              if not ClientDataSetFeedsCa.IsNull
480
              then SeriesBar.AddBar(ClientDataSetFeedsCa.Value, s, clTeeColor)
481
              else SeriesBar.AddNull(s);
482
            1: // Phosphore
483
              if not ClientDataSetFeedsP.IsNull
484
              then SeriesBar.AddBar(ClientDataSetFeedsP.Value, s, clTeeColor)
485
              else SeriesBar.AddNull(s);
486 4 avalancogn
            2: // Sodium
487
              if not ClientDataSetFeedsNa.IsNull
488
              then SeriesBar.AddBar(ClientDataSetFeedsNa.Value, s, clTeeColor)
489
              else SeriesBar.AddNull(s);
490
            3: // Potassium
491
              if not ClientDataSetFeedsK.IsNull
492
              then SeriesBar.AddBar(ClientDataSetFeedsK.Value, s, clTeeColor)
493
              else SeriesBar.AddNull(s);
494
            4: // Chlore
495
              if not ClientDataSetFeedsCl.IsNull
496
              then SeriesBar.AddBar(ClientDataSetFeedsCl.Value, s, clTeeColor)
497
              else SeriesBar.AddNull(s);
498
            5: // Phosphore digestible
499 1 avalancogn
              if not ClientDataSetFeedsPd.IsNull
500
              then SeriesBar.AddBar(ClientDataSetFeedsPd.Value, s, clTeeColor)
501
              else SeriesBar.AddNull(s);
502
          end;
503
      end;
504
  end;
505
506
begin
507
  Chart0.Title.Clear;
508
  Chart0.Title.Text.Add(ComboBoxType0.Text);
509
  case ComboBoxType0.ItemIndex of
510
    0: // Analyse proximale
511
      Chart0.Title.Text.Add(ComboBoxProximal0.Text);
512
    1: // Valeurs ?nerg?tiques
513
      Chart0.Title.Text.Add(ComboBoxEnergy0.Text);
514
    2: // Rapports ?nerg?tiques
515
      Chart0.Title.Text.Add(ComboBoxRatios0.Text);
516
    3, 4, 5: // Acides amin?s
517
      Chart0.Title.Text.Add(ComboBoxAA0.Text);
518
    6: // Min?raux
519
      Chart0.Title.Text.Add(ComboBoxMinerals0.Text);
520
  end;
521
  Chart0.SubTitle.Clear;
522
  case ComboBoxType0.ItemIndex of
523
    0: // Analyse proximale
524
      with FormOptions do
525
        if Expression = 0
526
        then // sur frais
527
          Chart0.SubTitle.Text.Add(ComboBoxProximal.Items[Proximal])
528
        else // sur mati?re s?che
529
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxProximal.Items[Proximal], _('DM')]));
530
    1: // Valeurs ?nerg?tiques
531
      with FormOptions do
532
        if Expression = 0
533
        then // sur frais
534
          Chart0.SubTitle.Text.Add(ComboBoxEnergy.Items[Energy])
535
        else // sur mati?re s?che
536
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxEnergy.Items[Energy], _('DM')]));
537
    2: // Rapports ?nerg?tiques
538
      with FormOptions do
539
        if Energy = 0
540
        then // MJ
541
          Chart0.SubTitle.Text.Add(_('g/MJ'))
542
        else // kcal
543
          Chart0.SubTitle.Text.Add(_('g/1000kcal'));
544
    3, 4: // Acides amin?s totaux et digestibles
545
      with FormOptions do
546
        if Expression = 0
547
        then // sur frais
548
          Chart0.SubTitle.Text.Add(ComboBoxAA.Items[AA])
549
        else // sur mati?re s?che
550
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxAA.Items[AA], _('DM')]));
551
    5: // Profils acides amin?s
552
      Chart0.SubTitle.Text.Add('%');
553
    6: // Min?raux
554
      with FormOptions do
555
        if Expression = 0
556
        then // sur frais
557
          Chart0.SubTitle.Text.Add(ComboBoxMinerals.Items[Minerals])
558
        else // sur mati?re s?che
559
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxMinerals.Items[Minerals], _('DM')]));
560
  end;
561
  case ComboBoxType0.ItemIndex of
562
    0: // Analyse proximale
563
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.ProximalFormat;
564
    1: // Valeurs ?nerg?tiques
565
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.EnergyFormat;
566
    2: // Rapports ?nerg?tiques
567
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.DecimalFormat(2);
568
    3, 4: // Acides amin?s totaux et digestibles
569
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.AAFormat;
570
    5: // Profils acides amin?s
571
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.DecimalFormat(0);
572
    6: // Min?raux
573
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.MineralsFormat;
574
  end;
575
  SeriesBar.Clear;
576
  SeriesBar.ValueFormat := Chart0.LeftAxis.AxisValuesFormat;
577
  if ComboBoxDiet1.ItemIndex <> -1
578
  then
579
    with DataModuleDeclaration do
580
    begin
581
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet1.Text, []);
582
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet1.Text) + 1;
583
      s := StrTrunc(ComboBoxDiet1.Text, 30);
584
      AddBarValue;
585
    end;
586
  if ComboBoxDiet2.ItemIndex <> -1
587
  then
588
    with DataModuleDeclaration do
589
    begin
590
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet2.Text, []);
591
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet2.Text) + 1;
592
      s := StrTrunc(ComboBoxDiet2.Text, 30);
593
      AddBarValue;
594
    end;
595
  if ComboBoxDiet3.ItemIndex <> -1
596
  then
597
    with DataModuleDeclaration do
598
    begin
599
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet3.Text, []);
600
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet3.Text) + 1;
601
      s := StrTrunc(ComboBoxDiet3.Text, 30);
602
      AddBarValue;
603
    end;
604
  if ComboBoxDiet4.ItemIndex <> -1
605
  then
606
    with DataModuleDeclaration do
607
    begin
608
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet4.Text, []);
609
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet4.Text) + 1;
610
      s := StrTrunc(ComboBoxDiet4.Text, 30);
611
      AddBarValue;
612
    end;
613
  if ComboBoxDiet5.ItemIndex <> -1
614
  then
615
    with DataModuleDeclaration do
616
    begin
617
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet5.Text, []);
618
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet5.Text) + 1;
619
      s := StrTrunc(ComboBoxDiet5.Text, 30);
620
      AddBarValue;
621
    end;
622
  if ComboBoxDiet6.ItemIndex <> -1
623
  then
624
    with DataModuleDeclaration do
625
    begin
626
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet6.Text, []);
627
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet6.Text) + 1;
628
      s := StrTrunc(ComboBoxDiet6.Text, 30);
629
      AddBarValue;
630
    end;
631
end;
632
633
procedure TFormFeedsCharts.ComboBoxFeed1Change(Sender: TObject);
634
var
635
  IngredientName: String;
636
  Cumul, Ratio, Total, Value: Double;
637
  FeedBar: TBarSeries;
638
begin
639
//  while ChartFeed1.SeriesCount > 0 do
640
//    ChartFeed1.Series[0].Free;
641
  ChartFeed1.FreeAllSeries(nil);
642
  ChartFeed1.Title.Clear;
643
  ChartFeed1.SubTitle.Clear;
644
  if ComboBoxFeed1.ItemIndex <> -1
645
  then
646
    with DataModuleDeclaration do
647
    begin
648
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed1.Text, []);
649
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed1.Text) + 1;
650
      ChartFeed1.AxisVisible := True;
651
      ChartFeed1.Title.Text.Add(ClientDataSetFeedsName.Value);
652
      ChartFeed1.SubTitle.Text.Add(ComboBoxType.Text);
653
      case ComboBoxType.ItemIndex of
654
        0: // Analyse proximale
655
          ChartFeed1.SubTitle.Text.Add(ComboBoxProximal.Text);
656
        1: // Valeurs ?nerg?tiques
657
          ChartFeed1.SubTitle.Text.Add(ComboBoxEnergy.Text);
658
        2, 3: // Acides amin?s
659
          ChartFeed1.SubTitle.Text.Add(ComboBoxAA.Text);
660
        4: // Min?raux
661
          ChartFeed1.SubTitle.Text.Add(ComboBoxMinerals.Text);
662
      end;
663
      case ComboBoxType.ItemIndex of
664
        0: // Analyse proximale
665
          case ComboBoxProximal.ItemIndex of
666
            0: // Composition
667
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
668
            1: // MS
669
              Cumul := ClientDataSetFeedsMS.Value;
670
            2: // MM
671
              Cumul := ClientDataSetFeedsMM.Value;
672
            3: // MAT
673
              Cumul := ClientDataSetFeedsMAT.Value;
674
            4: // MG
675
              Cumul := ClientDataSetFeedsMG.Value;
676
            5: // CB
677
              Cumul := ClientDataSetFeedsCB.Value;
678
            6: // NDF
679
              Cumul := ClientDataSetFeedsNDF.Value;
680
            7: // ADF
681
              Cumul := ClientDataSetFeedsADF.Value;
682
            8: // ADL
683
              Cumul := ClientDataSetFeedsADL.Value;
684
            9: // Amidon
685
              Cumul := ClientDataSetFeedsAmidon.Value;
686
            10: // Sucres
687
              Cumul := ClientDataSetFeedsSucres.Value;
688
            else
689
              Cumul := 0;
690
          end;
691
        1: // Valeurs ?nerg?tiques
692
          case ComboBoxEnergy.ItemIndex of
693
            0: // Energie brute
694
              Cumul := ClientDataSetFeedsEB.Value;
695
            1: // Energie digestible (porc croissance)
696
              Cumul := ClientDataSetFeedsEDc.Value;
697
            2: // Energie digestible (porc adulte)
698
              Cumul := ClientDataSetFeedsEDt.Value;
699
            3: // Energie m?tabolisable (porc croissance)
700
              Cumul := ClientDataSetFeedsEMc.Value;
701
            4: // Energie m?tabolisable (porc adulte)
702
              Cumul := ClientDataSetFeedsEMt.Value;
703
            5: // Energie nette (porc croissance)
704
              Cumul := ClientDataSetFeedsENc.Value;
705
            6: // Energie nette (porc adulte)
706
              Cumul := ClientDataSetFeedsENt.Value;
707
            else
708
              Cumul := 0;
709
          end;
710
        2: // Acides amin?s totaux
711
          case ComboBoxAA.ItemIndex of
712
            0: // Lysine
713
              Cumul := ClientDataSetFeedsLys.Value;
714
            1: // Thr?onine
715
              Cumul := ClientDataSetFeedsThr.Value;
716
            2: // M?thionine
717
              Cumul := ClientDataSetFeedsMet.Value;
718
            3: // Cyst?ine
719
              Cumul := ClientDataSetFeedsCys.Value;
720
            4: // M?thionine + Cyst?ine
721
              Cumul := ClientDataSetFeedsMetCys.Value;
722
            5: // Tryptophane
723
              Cumul := ClientDataSetFeedsTrp.Value;
724
            6: // Isoleucine
725
              Cumul := ClientDataSetFeedsIle.Value;
726
            7: // Valine
727
              Cumul := ClientDataSetFeedsVal.Value;
728
            8: // Leucine
729
              Cumul := ClientDataSetFeedsLeu.Value;
730
            9: // Ph?nylalanine
731
              Cumul := ClientDataSetFeedsPhe.Value;
732
            10: // Tyrosine
733
              Cumul := ClientDataSetFeedsTyr.Value;
734
            11: // Ph?nylalanine + Tyrosine
735
              Cumul := ClientDataSetFeedsPheTyr.Value;
736
            12: // Histidine
737
              Cumul := ClientDataSetFeedsHis.Value;
738
            13: // Arginine
739
              Cumul := ClientDataSetFeedsArg.Value;
740
            14: // Alanine
741
              Cumul := ClientDataSetFeedsAla.Value;
742
            15: // Aspartate
743
              Cumul := ClientDataSetFeedsAsp.Value;
744
            16: // Glutamate
745
              Cumul := ClientDataSetFeedsGlu.Value;
746
            17: // Glycine
747
              Cumul := ClientDataSetFeedsGly.Value;
748
            18: // S?rine
749
              Cumul := ClientDataSetFeedsSer.Value;
750
            19: // Proline
751
              Cumul := ClientDataSetFeedsPro.Value;
752
            else
753
              Cumul := 0;
754
          end;
755
        3: // Acides amin?s digestibles
756
          case ComboBoxAA.ItemIndex of
757
            0: // Lysine
758
              Cumul := ClientDataSetFeedsLysd.Value;
759
            1: // Thr?onine
760
              Cumul := ClientDataSetFeedsThrd.Value;
761
            2: // M?thionine
762
              Cumul := ClientDataSetFeedsMetd.Value;
763
            3: // Cyst?ine
764
              Cumul := ClientDataSetFeedsCysd.Value;
765
            4: // M?thionine + Cyst?ine
766
              Cumul := ClientDataSetFeedsMetCysd.Value;
767
            5: // Tryptophane
768
              Cumul := ClientDataSetFeedsTrpd.Value;
769
            6: // Isoleucine
770
              Cumul := ClientDataSetFeedsIled.Value;
771
            7: // Valine
772
              Cumul := ClientDataSetFeedsVald.Value;
773
            8: // Leucine
774
              Cumul := ClientDataSetFeedsLeud.Value;
775
            9: // Ph?nylalanine
776
              Cumul := ClientDataSetFeedsPhed.Value;
777
            10: // Tyrosine
778
              Cumul := ClientDataSetFeedsTyrd.Value;
779
            11: // Ph?nylalanine + Tyrosine
780
              Cumul := ClientDataSetFeedsPheTyrd.Value;
781
            12: // Histidine
782
              Cumul := ClientDataSetFeedsHisd.Value;
783
            13: // Arginine
784
              Cumul := ClientDataSetFeedsArgd.Value;
785
            14: // Alanine
786
              Cumul := ClientDataSetFeedsAlad.Value;
787
            15: // Aspartate
788
              Cumul := ClientDataSetFeedsAspd.Value;
789
            16: // Glutamate
790
              Cumul := ClientDataSetFeedsGlud.Value;
791
            17: // Glycine
792
              Cumul := ClientDataSetFeedsGlyd.Value;
793
            18: // S?rine
794
              Cumul := ClientDataSetFeedsSerd.Value;
795
            19: // Proline
796
              Cumul := ClientDataSetFeedsProd.Value;
797
            else
798
              Cumul := 0;
799
          end;
800
        4: // Min?raux
801
          case ComboBoxMinerals.ItemIndex of
802
            0: // Calcium
803
              Cumul := ClientDataSetFeedsCa.Value;
804
            1: // Phosphore
805
              Cumul := ClientDataSetFeedsP.Value;
806 4 avalancogn
            2: // Sodium
807
              Cumul := ClientDataSetFeedsNa.Value;
808
            3: // Potassium
809
              Cumul := ClientDataSetFeedsK.Value;
810
            4: // Chlore
811
              Cumul := ClientDataSetFeedsCl.Value;
812
            5: // Phosphore digestible
813 1 avalancogn
              Cumul := ClientDataSetFeedsPd.Value;
814
            else
815
              Cumul := 0;
816
          end;
817
        else
818
          Cumul := 0;
819
      end;
820
      if Cumul = 0
821
      then // Division par z?ro
822
        Cumul := 1;
823
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
824
      ClientDataSetComposition.Filtered := True;
825
      ClientDataSetComposition.First;
826
      Total := 0;
827
      while not ClientDataSetComposition.Eof do
828
      begin
829
        if ClientDataSetCompositionUser.Value
830
        then
831
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
832
        else
833
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
834
        ClientDataSetIngredients.Filtered := True;
835
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
836
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
837
        if (FormOptions.Expression = 0)
838
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
839
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
840
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
841
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
842
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
843
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
844
          Ratio := Ratio * RapMS;
845
        case ComboBoxType.ItemIndex of
846
          0: // Analyse proximale
847
            case ComboBoxProximal.ItemIndex of
848
              0: // Composition
849
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
850
              1: // MS
851
                Value := ClientDataSetCompositionMS.Value * Ratio;
852
              2: // MM
853
                Value := ClientDataSetIngredientsMM.Value * Ratio;
854
              3: // MAT
855
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
856
              4: // MG
857
                Value := ClientDataSetIngredientsMG.Value * Ratio;
858
              5: // CB
859
                Value := ClientDataSetIngredientsCB.Value * Ratio;
860
              6: // NDF
861
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
862
              7: // ADF
863
                Value := ClientDataSetIngredientsADF.Value * Ratio;
864
              8: // ADL
865
                Value := ClientDataSetIngredientsADL.Value * Ratio;
866
              9: // Amidon
867
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
868
              10: // Sucres
869
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
870
              else
871
                Value := 0;
872
            end;
873
          1: // Valeurs ?nerg?tiques
874
            case ComboBoxEnergy.ItemIndex of
875
              0: // Energie brute
876
                Value := ClientDataSetIngredientsEB.Value * Ratio;
877
              1: // Energie digestible (porc croissance)
878
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
879
              2: // Energie digestible (porc adulte)
880
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
881
              3: // Energie m?tabolisable (porc croissance)
882
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
883
              4: // Energie m?tabolisable (porc adulte)
884
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
885
              5: // Energie nette (porc croissance)
886
                Value := ClientDataSetIngredientsENc.Value * Ratio;
887
              6: // Energie nette (porc adulte)
888
                Value := ClientDataSetIngredientsENt.Value * Ratio;
889
              else
890
                Value := 0;
891
            end;
892
          2: // Acides amin?s totaux
893
            case ComboBoxAA.ItemIndex of
894
              0: // Lysine
895
                Value := ClientDataSetIngredientsLys.Value * Ratio;
896
              1: // Thr?onine
897
                Value := ClientDataSetIngredientsThr.Value * Ratio;
898
              2: // M?thionine
899
                Value := ClientDataSetIngredientsMet.Value * Ratio;
900
              3: // Cyst?ine
901
                Value := ClientDataSetIngredientsCys.Value * Ratio;
902
              4: // M?thionine + Cyst?ine
903
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
904
              5: // Tryptophane
905
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
906
              6: // Isoleucine
907
                Value := ClientDataSetIngredientsIle.Value * Ratio;
908
              7: // Valine
909
                Value := ClientDataSetIngredientsVal.Value * Ratio;
910
              8: // Leucine
911
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
912
              9: // Ph?nylalanine
913
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
914
              10: // Tyrosine
915
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
916
              11: // Ph?nylalanine + Tyrosine
917
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
918
              12: // Histidine
919
                Value := ClientDataSetIngredientsHis.Value * Ratio;
920
              13: // Arginine
921
                Value := ClientDataSetIngredientsArg.Value * Ratio;
922
              14: // Alanine
923
                Value := ClientDataSetIngredientsAla.Value * Ratio;
924
              15: // Aspartate
925
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
926
              16: // Glutamate
927
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
928
              17: // Glycine
929
                Value := ClientDataSetIngredientsGly.Value * Ratio;
930
              18: // S?rine
931
                Value := ClientDataSetIngredientsSer.Value * Ratio;
932
              19: // Proline
933
                Value := ClientDataSetIngredientsPro.Value * Ratio;
934
              else
935
                Value := 0;
936
            end;
937
          3: // Acides amin?s digestibles
938
            case ComboBoxAA.ItemIndex of
939
              0: // Lysine
940
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
941
              1: // Thr?onine
942
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
943
              2: // M?thionine
944
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
945
              3: // Cyst?ine
946
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
947
              4: // M?thionine + Cyst?ine
948
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
949
              5: // Tryptophane
950
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
951
              6: // Isoleucine
952
                Value := ClientDataSetIngredientsIled.Value * Ratio;
953
              7: // Valine
954
                Value := ClientDataSetIngredientsVald.Value * Ratio;
955
              8: // Leucine
956
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
957
              9: // Ph?nylalanine
958
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
959
              10: // Tyrosine
960
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
961
              11: // Ph?nylalanine + Tyrosine
962
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
963
              12: // Histidine
964
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
965
              13: // Arginine
966
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
967
              14: // Alanine
968
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
969
              15: // Aspartate
970
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
971
              16: // Glutamate
972
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
973
              17: // Glycine
974
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
975
              18: // S?rine
976
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
977
              19: // Proline
978
                Value := ClientDataSetIngredientsProd.Value * Ratio;
979
              else
980
                Value := 0;
981
            end;
982
          4: // Min?raux
983
            case ComboBoxMinerals.ItemIndex of
984
              0: // Calcium
985
                Value := ClientDataSetIngredientsCa.Value * Ratio;
986
              1: // Phosphore
987
                Value := ClientDataSetIngredientsP.Value * Ratio;
988 4 avalancogn
              2: // Sodium
989
                Value := ClientDataSetIngredientsNa.Value * Ratio;
990
              3: // Potassium
991
                Value := ClientDataSetIngredientsK.Value * Ratio;
992
              4: // Chlore
993
                Value := ClientDataSetIngredientsCl.Value * Ratio;
994
              5: // Phosphore digestible
995 1 avalancogn
                if ClientDataSetFeedsPresentation.Value = 0
996
                then // Farine (dPphy)
997
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
998
                else // Granul?s (dP)
999
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
1000
              else
1001
                Value := 0;
1002
            end;
1003
          else
1004
            Value := 0;
1005
        end;
1006
        if (FormOptions.Expression = 1)
1007
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1008
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
1009
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
1010
        if Value > 0
1011
        then // Prendre en compte la valeur
1012
        begin
1013
          FeedBar := TBarSeries.Create(ChartFeed1);
1014
          FeedBar.ParentChart := ChartFeed1;
1015
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
1016
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
1017
          FeedBar.MultiBar := mbStacked100;
1018
          FeedBar.Marks.Visible := False;
1019
          ChartFeed1.AddSeries(FeedBar);
1020
          FeedBar.AddBar(Value, '', clTeeColor);
1021
          Total := Total + Value;
1022
        end;
1023
        ClientDataSetComposition.Next;
1024
      end;
1025
      ClientDataSetIngredients.Filtered := False;
1026
      ClientDataSetIngredients.Filter := '';
1027
      // Cas particuliers
1028
      if (ComboBoxType.ItemIndex = 1)
1029
      and ((ComboBoxEnergy.ItemIndex = 1)
1030
        or (ComboBoxEnergy.ItemIndex = 3)
1031
        or (ComboBoxEnergy.ItemIndex = 5))
1032
      and (ClientDataSetFeedsBonusC.Value > 0)
1033
      then // Bonus ?nergie (porc croissance)
1034
      begin
1035
        case ComboBoxEnergy.ItemIndex of
1036
          1: Value := ClientDataSetFeedsEDc.Value - Total;
1037
          3: Value := ClientDataSetFeedsEMc.Value - Total;
1038
          5: Value := ClientDataSetFeedsENc.Value - Total;
1039
          else Value := 0;
1040
        end;
1041
        FeedBar := TBarSeries.Create(ChartFeed1);
1042
        FeedBar.ParentChart := ChartFeed1;
1043
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1044
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1045
        FeedBar.MultiBar := mbStacked100;
1046
        FeedBar.Marks.Visible := False;
1047
        ChartFeed1.AddSeries(FeedBar);
1048
        FeedBar.AddBar(Value, '', clTeeColor);
1049
        Total := Total + Value;
1050
      end;
1051
      if (ComboBoxType.ItemIndex = 1)
1052
      and ((ComboBoxEnergy.ItemIndex = 2)
1053
        or (ComboBoxEnergy.ItemIndex = 4)
1054
        or (ComboBoxEnergy.ItemIndex = 6))
1055
      and (ClientDataSetFeedsBonusT.Value > 0)
1056
      then // Bonus ?nergie (porc adulte)
1057
      begin
1058
        case ComboBoxEnergy.ItemIndex of
1059
          2: Value := ClientDataSetFeedsEDt.Value - Total;
1060
          4: Value := ClientDataSetFeedsEMt.Value - Total;
1061
          6: Value := ClientDataSetFeedsENt.Value - Total;
1062
          else Value := 0;
1063
        end;
1064
        FeedBar := TBarSeries.Create(ChartFeed1);
1065
        FeedBar.ParentChart := ChartFeed1;
1066
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1067
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1068
        FeedBar.MultiBar := mbStacked100;
1069
        FeedBar.Marks.Visible := False;
1070
        ChartFeed1.AddSeries(FeedBar);
1071
        FeedBar.AddBar(Value, '', clTeeColor);
1072
        Total := Total + Value;
1073
      end;
1074
      if (ComboBoxType.ItemIndex = 0)
1075
      and (ComboBoxProximal.ItemIndex = 0)
1076
      and not ClientDataSetFeedsPhytaseId.IsNull
1077
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
1078
      then // Phytase (taux d'incorporation)
1079
      begin
1080
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
1081
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1082
        FeedBar := TBarSeries.Create(ChartFeed1);
1083
        FeedBar.ParentChart := ChartFeed1;
1084
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1085
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1086
        FeedBar.MultiBar := mbStacked100;
1087
        FeedBar.Marks.Visible := False;
1088
        ChartFeed1.AddSeries(FeedBar);
1089
        FeedBar.AddBar(Value, '', clTeeColor);
1090
        Total := Total + Value;
1091
      end;
1092
      if (ComboBoxType.ItemIndex = 4)
1093
      and (ComboBoxMinerals.ItemIndex = 2)
1094
      and not ClientDataSetFeedsPhytaseId.IsNull
1095
      and (ClientDataSetFeedsPd.Value > Total)
1096
      then // Phytase (Phosphore digestible)
1097
      begin
1098
        Value := ClientDataSetFeedsPd.Value - Total;
1099
        FeedBar := TBarSeries.Create(ChartFeed1);
1100
        FeedBar.ParentChart := ChartFeed1;
1101
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1102
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1103
        FeedBar.MultiBar := mbStacked100;
1104
        FeedBar.Marks.Visible := False;
1105
        ChartFeed1.AddSeries(FeedBar);
1106
        FeedBar.AddBar(Value, '', clTeeColor);
1107
        Total := Total + Value;
1108
      end;
1109
      // Total
1110
      case ComboBoxType.ItemIndex of
1111
        0: // Analyse proximale
1112
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
1113
          then // sur frais
1114
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
1115
          else // sur mati?re s?che - except? pour Composition et MS
1116
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
1117
        1: // Valeurs ?nerg?tiques
1118
          if FormOptions.Expression = 0
1119
          then // sur frais
1120
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
1121
          else // sur mati?re s?che
1122
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
1123
        2, 3: // Acides amin?s
1124
          if FormOptions.Expression = 0
1125
          then // sur frais
1126
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
1127
          else // sur mati?re s?che
1128
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
1129
        4: // Min?raux
1130
          if FormOptions.Expression = 0
1131
          then // sur frais
1132
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
1133
          else // sur mati?re s?che
1134
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
1135
      end;
1136
      ClientDataSetComposition.Filtered := False;
1137
      ClientDataSetComposition.Filter := '';
1138
    end;
1139
end;
1140
1141
procedure TFormFeedsCharts.ComboBoxFeed2Change(Sender: TObject);
1142
var
1143
  IngredientName: String;
1144
  Cumul, Ratio, Total, Value: Double;
1145
  FeedBar: TBarSeries;
1146
begin
1147
//  while ChartFeed2.SeriesCount > 0 do
1148
//    ChartFeed2.Series[0].Free;
1149
  ChartFeed2.FreeAllSeries(nil);
1150
  ChartFeed2.Title.Clear;
1151
  ChartFeed2.SubTitle.Clear;
1152
  if ComboBoxFeed2.ItemIndex <> -1
1153
  then
1154
    with DataModuleDeclaration do
1155
    begin
1156
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed2.Text, []);
1157
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed2.Text) + 1;
1158
      ChartFeed2.AxisVisible := True;
1159
      ChartFeed2.Title.Text.Add(ClientDataSetFeedsName.Value);
1160
      ChartFeed2.SubTitle.Text.Add(ComboBoxType.Text);
1161
      case ComboBoxType.ItemIndex of
1162
        0: // Analyse proximale
1163
          ChartFeed2.SubTitle.Text.Add(ComboBoxProximal.Text);
1164
        1: // Valeurs ?nerg?tiques
1165
          ChartFeed2.SubTitle.Text.Add(ComboBoxEnergy.Text);
1166
        2, 3: // Acides amin?s
1167
          ChartFeed2.SubTitle.Text.Add(ComboBoxAA.Text);
1168
        4: // Min?raux
1169
          ChartFeed2.SubTitle.Text.Add(ComboBoxMinerals.Text);
1170
      end;
1171
      case ComboBoxType.ItemIndex of
1172
        0: // Analyse proximale
1173
          case ComboBoxProximal.ItemIndex of
1174
            0: // Composition
1175
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
1176
            1: // MS
1177
              Cumul := ClientDataSetFeedsMS.Value;
1178
            2: // MM
1179
              Cumul := ClientDataSetFeedsMM.Value;
1180
            3: // MAT
1181
              Cumul := ClientDataSetFeedsMAT.Value;
1182
            4: // MG
1183
              Cumul := ClientDataSetFeedsMG.Value;
1184
            5: // CB
1185
              Cumul := ClientDataSetFeedsCB.Value;
1186
            6: // NDF
1187
              Cumul := ClientDataSetFeedsNDF.Value;
1188
            7: // ADF
1189
              Cumul := ClientDataSetFeedsADF.Value;
1190
            8: // ADL
1191
              Cumul := ClientDataSetFeedsADL.Value;
1192
            9: // Amidon
1193
              Cumul := ClientDataSetFeedsAmidon.Value;
1194
            10: // Sucres
1195
              Cumul := ClientDataSetFeedsSucres.Value;
1196
            else
1197
              Cumul := 0;
1198
          end;
1199
        1: // Valeurs ?nerg?tiques
1200
          case ComboBoxEnergy.ItemIndex of
1201
            0: // Energie brute
1202
              Cumul := ClientDataSetFeedsEB.Value;
1203
            1: // Energie digestible (porc croissance)
1204
              Cumul := ClientDataSetFeedsEDc.Value;
1205
            2: // Energie digestible (porc adulte)
1206
              Cumul := ClientDataSetFeedsEDt.Value;
1207
            3: // Energie m?tabolisable (porc croissance)
1208
              Cumul := ClientDataSetFeedsEMc.Value;
1209
            4: // Energie m?tabolisable (porc adulte)
1210
              Cumul := ClientDataSetFeedsEMt.Value;
1211
            5: // Energie nette (porc croissance)
1212
              Cumul := ClientDataSetFeedsENc.Value;
1213
            6: // Energie nette (porc adulte)
1214
              Cumul := ClientDataSetFeedsENt.Value;
1215
            else
1216
              Cumul := 0;
1217
          end;
1218
        2: // Acides amin?s totaux
1219
          case ComboBoxAA.ItemIndex of
1220
            0: // Lysine
1221
              Cumul := ClientDataSetFeedsLys.Value;
1222
            1: // Thr?onine
1223
              Cumul := ClientDataSetFeedsThr.Value;
1224
            2: // M?thionine
1225
              Cumul := ClientDataSetFeedsMet.Value;
1226
            3: // Cyst?ine
1227
              Cumul := ClientDataSetFeedsCys.Value;
1228
            4: // M?thionine + Cyst?ine
1229
              Cumul := ClientDataSetFeedsMetCys.Value;
1230
            5: // Tryptophane
1231
              Cumul := ClientDataSetFeedsTrp.Value;
1232
            6: // Isoleucine
1233
              Cumul := ClientDataSetFeedsIle.Value;
1234
            7: // Valine
1235
              Cumul := ClientDataSetFeedsVal.Value;
1236
            8: // Leucine
1237
              Cumul := ClientDataSetFeedsLeu.Value;
1238
            9: // Ph?nylalanine
1239
              Cumul := ClientDataSetFeedsPhe.Value;
1240
            10: // Tyrosine
1241
              Cumul := ClientDataSetFeedsTyr.Value;
1242
            11: // Ph?nylalanine + Tyrosine
1243
              Cumul := ClientDataSetFeedsPheTyr.Value;
1244
            12: // Histidine
1245
              Cumul := ClientDataSetFeedsHis.Value;
1246
            13: // Arginine
1247
              Cumul := ClientDataSetFeedsArg.Value;
1248
            14: // Alanine
1249
              Cumul := ClientDataSetFeedsAla.Value;
1250
            15: // Aspartate
1251
              Cumul := ClientDataSetFeedsAsp.Value;
1252
            16: // Glutamate
1253
              Cumul := ClientDataSetFeedsGlu.Value;
1254
            17: // Glycine
1255
              Cumul := ClientDataSetFeedsGly.Value;
1256
            18: // S?rine
1257
              Cumul := ClientDataSetFeedsSer.Value;
1258
            19: // Proline
1259
              Cumul := ClientDataSetFeedsPro.Value;
1260
            else
1261
              Cumul := 0;
1262
          end;
1263
        3: // Acides amin?s digestibles
1264
          case ComboBoxAA.ItemIndex of
1265
            0: // Lysine
1266
              Cumul := ClientDataSetFeedsLysd.Value;
1267
            1: // Thr?onine
1268
              Cumul := ClientDataSetFeedsThrd.Value;
1269
            2: // M?thionine
1270
              Cumul := ClientDataSetFeedsMetd.Value;
1271
            3: // Cyst?ine
1272
              Cumul := ClientDataSetFeedsCysd.Value;
1273
            4: // M?thionine + Cyst?ine
1274
              Cumul := ClientDataSetFeedsMetCysd.Value;
1275
            5: // Tryptophane
1276
              Cumul := ClientDataSetFeedsTrpd.Value;
1277
            6: // Isoleucine
1278
              Cumul := ClientDataSetFeedsIled.Value;
1279
            7: // Valine
1280
              Cumul := ClientDataSetFeedsVald.Value;
1281
            8: // Leucine
1282
              Cumul := ClientDataSetFeedsLeud.Value;
1283
            9: // Ph?nylalanine
1284
              Cumul := ClientDataSetFeedsPhed.Value;
1285
            10: // Tyrosine
1286
              Cumul := ClientDataSetFeedsTyrd.Value;
1287
            11: // Ph?nylalanine + Tyrosine
1288
              Cumul := ClientDataSetFeedsPheTyrd.Value;
1289
            12: // Histidine
1290
              Cumul := ClientDataSetFeedsHisd.Value;
1291
            13: // Arginine
1292
              Cumul := ClientDataSetFeedsArgd.Value;
1293
            14: // Alanine
1294
              Cumul := ClientDataSetFeedsAlad.Value;
1295
            15: // Aspartate
1296
              Cumul := ClientDataSetFeedsAspd.Value;
1297
            16: // Glutamate
1298
              Cumul := ClientDataSetFeedsGlud.Value;
1299
            17: // Glycine
1300
              Cumul := ClientDataSetFeedsGlyd.Value;
1301
            18: // S?rine
1302
              Cumul := ClientDataSetFeedsSerd.Value;
1303
            19: // Proline
1304
              Cumul := ClientDataSetFeedsProd.Value;
1305
            else
1306
              Cumul := 0;
1307
          end;
1308
        4: // Min?raux
1309
          case ComboBoxMinerals.ItemIndex of
1310
            0: // Calcium
1311
              Cumul := ClientDataSetFeedsCa.Value;
1312
            1: // Phosphore
1313
              Cumul := ClientDataSetFeedsP.Value;
1314 4 avalancogn
            2: // Sodium
1315
              Cumul := ClientDataSetFeedsNa.Value;
1316
            3: // Potassium
1317
              Cumul := ClientDataSetFeedsK.Value;
1318
            4: // Chlore
1319
              Cumul := ClientDataSetFeedsCl.Value;
1320
            5: // Phosphore digestible
1321 1 avalancogn
              Cumul := ClientDataSetFeedsPd.Value;
1322
            else
1323
              Cumul := 0;
1324
          end;
1325
        else
1326
          Cumul := 0;
1327
      end;
1328
      if Cumul = 0
1329
      then // Division par z?ro
1330
        Cumul := 1;
1331
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
1332
      ClientDataSetComposition.Filtered := True;
1333
      ClientDataSetComposition.First;
1334
      Total := 0;
1335
      while not ClientDataSetComposition.Eof do
1336
      begin
1337
        if ClientDataSetCompositionUser.Value
1338
        then
1339
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
1340
        else
1341
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
1342
        ClientDataSetIngredients.Filtered := True;
1343
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
1344
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
1345
        if (FormOptions.Expression = 0)
1346
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1347
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
1348
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
1349
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
1350
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1351
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
1352
          Ratio := Ratio * RapMS;
1353
        case ComboBoxType.ItemIndex of
1354
          0: // Analyse proximale
1355
            case ComboBoxProximal.ItemIndex of
1356
              0: // Composition
1357
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1358
              1: // MS
1359
                Value := ClientDataSetCompositionMS.Value * Ratio;
1360
              2: // MM
1361
                Value := ClientDataSetIngredientsMM.Value * Ratio;
1362
              3: // MAT
1363
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
1364
              4: // MG
1365
                Value := ClientDataSetIngredientsMG.Value * Ratio;
1366
              5: // CB
1367
                Value := ClientDataSetIngredientsCB.Value * Ratio;
1368
              6: // NDF
1369
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
1370
              7: // ADF
1371
                Value := ClientDataSetIngredientsADF.Value * Ratio;
1372
              8: // ADL
1373
                Value := ClientDataSetIngredientsADL.Value * Ratio;
1374
              9: // Amidon
1375
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
1376
              10: // Sucres
1377
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
1378
              else
1379
                Value := 0;
1380
            end;
1381
          1: // Valeurs ?nerg?tiques
1382
            case ComboBoxEnergy.ItemIndex of
1383
              0: // Energie brute
1384
                Value := ClientDataSetIngredientsEB.Value * Ratio;
1385
              1: // Energie digestible (porc croissance)
1386
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
1387
              2: // Energie digestible (porc adulte)
1388
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
1389
              3: // Energie m?tabolisable (porc croissance)
1390
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
1391
              4: // Energie m?tabolisable (porc adulte)
1392
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
1393
              5: // Energie nette (porc croissance)
1394
                Value := ClientDataSetIngredientsENc.Value * Ratio;
1395
              6: // Energie nette (porc adulte)
1396
                Value := ClientDataSetIngredientsENt.Value * Ratio;
1397
              else
1398
                Value := 0;
1399
            end;
1400
          2: // Acides amin?s totaux
1401
            case ComboBoxAA.ItemIndex of
1402
              0: // Lysine
1403
                Value := ClientDataSetIngredientsLys.Value * Ratio;
1404
              1: // Thr?onine
1405
                Value := ClientDataSetIngredientsThr.Value * Ratio;
1406
              2: // M?thionine
1407
                Value := ClientDataSetIngredientsMet.Value * Ratio;
1408
              3: // Cyst?ine
1409
                Value := ClientDataSetIngredientsCys.Value * Ratio;
1410
              4: // M?thionine + Cyst?ine
1411
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
1412
              5: // Tryptophane
1413
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
1414
              6: // Isoleucine
1415
                Value := ClientDataSetIngredientsIle.Value * Ratio;
1416
              7: // Valine
1417
                Value := ClientDataSetIngredientsVal.Value * Ratio;
1418
              8: // Leucine
1419
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
1420
              9: // Ph?nylalanine
1421
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
1422
              10: // Tyrosine
1423
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
1424
              11: // Ph?nylalanine + Tyrosine
1425
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
1426
              12: // Histidine
1427
                Value := ClientDataSetIngredientsHis.Value * Ratio;
1428
              13: // Arginine
1429
                Value := ClientDataSetIngredientsArg.Value * Ratio;
1430
              14: // Alanine
1431
                Value := ClientDataSetIngredientsAla.Value * Ratio;
1432
              15: // Aspartate
1433
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
1434
              16: // Glutamate
1435
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
1436
              17: // Glycine
1437
                Value := ClientDataSetIngredientsGly.Value * Ratio;
1438
              18: // S?rine
1439
                Value := ClientDataSetIngredientsSer.Value * Ratio;
1440
              19: // Proline
1441
                Value := ClientDataSetIngredientsPro.Value * Ratio;
1442
              else
1443
                Value := 0;
1444
            end;
1445
          3: // Acides amin?s digestibles
1446
            case ComboBoxAA.ItemIndex of
1447
              0: // Lysine
1448
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
1449
              1: // Thr?onine
1450
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
1451
              2: // M?thionine
1452
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
1453
              3: // Cyst?ine
1454
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
1455
              4: // M?thionine + Cyst?ine
1456
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
1457
              5: // Tryptophane
1458
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
1459
              6: // Isoleucine
1460
                Value := ClientDataSetIngredientsIled.Value * Ratio;
1461
              7: // Valine
1462
                Value := ClientDataSetIngredientsVald.Value * Ratio;
1463
              8: // Leucine
1464
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
1465
              9: // Ph?nylalanine
1466
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
1467
              10: // Tyrosine
1468
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
1469
              11: // Ph?nylalanine + Tyrosine
1470
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
1471
              12: // Histidine
1472
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
1473
              13: // Arginine
1474
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
1475
              14: // Alanine
1476
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
1477
              15: // Aspartate
1478
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
1479
              16: // Glutamate
1480
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
1481
              17: // Glycine
1482
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
1483
              18: // S?rine
1484
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
1485
              19: // Proline
1486
                Value := ClientDataSetIngredientsProd.Value * Ratio;
1487
              else
1488
                Value := 0;
1489
            end;
1490
          4: // Min?raux
1491
            case ComboBoxMinerals.ItemIndex of
1492
              0: // Calcium
1493
                Value := ClientDataSetIngredientsCa.Value * Ratio;
1494
              1: // Phosphore
1495
                Value := ClientDataSetIngredientsP.Value * Ratio;
1496 4 avalancogn
              2: // Sodium
1497
                Value := ClientDataSetIngredientsNa.Value * Ratio;
1498
              3: // Potassium
1499
                Value := ClientDataSetIngredientsK.Value * Ratio;
1500
              4: // Chlore
1501
                Value := ClientDataSetIngredientsCl.Value * Ratio;
1502
              5: // Phosphore digestible
1503 1 avalancogn
                if ClientDataSetFeedsPresentation.Value = 0
1504
                then // Farine (dPphy)
1505
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
1506
                else // Granul?s (dP)
1507
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
1508
              else
1509
                Value := 0;
1510
            end;
1511
          else
1512
            Value := 0;
1513
        end;
1514
        if (FormOptions.Expression = 1)
1515
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1516
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
1517
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
1518
        if Value > 0
1519
        then // Prendre en compte la valeur
1520
        begin
1521
          FeedBar := TBarSeries.Create(ChartFeed2);
1522
          FeedBar.ParentChart := ChartFeed2;
1523
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
1524
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
1525
          FeedBar.MultiBar := mbStacked100;
1526
          FeedBar.Marks.Visible := False;
1527
          ChartFeed2.AddSeries(FeedBar);
1528
          FeedBar.AddBar(Value, '', clTeeColor);
1529
          Total := Total + Value;
1530
        end;
1531
        ClientDataSetComposition.Next;
1532
      end;
1533
      ClientDataSetIngredients.Filtered := False;
1534
      ClientDataSetIngredients.Filter := '';
1535
      // Cas particuliers
1536
      if (ComboBoxType.ItemIndex = 1)
1537
      and ((ComboBoxEnergy.ItemIndex = 1)
1538
        or (ComboBoxEnergy.ItemIndex = 3)
1539
        or (ComboBoxEnergy.ItemIndex = 5))
1540
      and (ClientDataSetFeedsBonusC.Value > 0)
1541
      then // Bonus ?nergie (porc croissance)
1542
      begin
1543
        case ComboBoxEnergy.ItemIndex of
1544
          1: Value := ClientDataSetFeedsEDc.Value - Total;
1545
          3: Value := ClientDataSetFeedsEMc.Value - Total;
1546
          5: Value := ClientDataSetFeedsENc.Value - Total;
1547
          else Value := 0;
1548
        end;
1549
        FeedBar := TBarSeries.Create(ChartFeed2);
1550
        FeedBar.ParentChart := ChartFeed2;
1551
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1552
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1553
        FeedBar.MultiBar := mbStacked100;
1554
        FeedBar.Marks.Visible := False;
1555
        ChartFeed2.AddSeries(FeedBar);
1556
        FeedBar.AddBar(Value, '', clTeeColor);
1557
        Total := Total + Value;
1558
      end;
1559
      if (ComboBoxType.ItemIndex = 1)
1560
      and ((ComboBoxEnergy.ItemIndex = 2)
1561
        or (ComboBoxEnergy.ItemIndex = 4)
1562
        or (ComboBoxEnergy.ItemIndex = 6))
1563
      and (ClientDataSetFeedsBonusT.Value > 0)
1564
      then // Bonus ?nergie (porc adulte)
1565
      begin
1566
        case ComboBoxEnergy.ItemIndex of
1567
          2: Value := ClientDataSetFeedsEDt.Value - Total;
1568
          4: Value := ClientDataSetFeedsEMt.Value - Total;
1569
          6: Value := ClientDataSetFeedsENt.Value - Total;
1570
          else Value := 0;
1571
        end;
1572
        FeedBar := TBarSeries.Create(ChartFeed2);
1573
        FeedBar.ParentChart := ChartFeed2;
1574
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1575
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1576
        FeedBar.MultiBar := mbStacked100;
1577
        FeedBar.Marks.Visible := False;
1578
        ChartFeed2.AddSeries(FeedBar);
1579
        FeedBar.AddBar(Value, '', clTeeColor);
1580
        Total := Total + Value;
1581
      end;
1582
      if (ComboBoxType.ItemIndex = 0)
1583
      and (ComboBoxProximal.ItemIndex = 0)
1584
      and not ClientDataSetFeedsPhytaseId.IsNull
1585
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
1586
      then // Phytase (taux d'incorporation)
1587
      begin
1588
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
1589
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1590
        FeedBar := TBarSeries.Create(ChartFeed2);
1591
        FeedBar.ParentChart := ChartFeed2;
1592
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1593
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1594
        FeedBar.MultiBar := mbStacked100;
1595
        FeedBar.Marks.Visible := False;
1596
        ChartFeed2.AddSeries(FeedBar);
1597
        FeedBar.AddBar(Value, '', clTeeColor);
1598
        Total := Total + Value;
1599
      end;
1600
      if (ComboBoxType.ItemIndex = 4)
1601
      and (ComboBoxMinerals.ItemIndex = 2)
1602
      and not ClientDataSetFeedsPhytaseId.IsNull
1603
      and (ClientDataSetFeedsPd.Value > Total)
1604
      then // Phytase (Phosphore digestible)
1605
      begin
1606
        Value := ClientDataSetFeedsPd.Value - Total;
1607
        FeedBar := TBarSeries.Create(ChartFeed2);
1608
        FeedBar.ParentChart := ChartFeed2;
1609
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1610
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1611
        FeedBar.MultiBar := mbStacked100;
1612
        FeedBar.Marks.Visible := False;
1613
        ChartFeed2.AddSeries(FeedBar);
1614
        FeedBar.AddBar(Value, '', clTeeColor);
1615
        Total := Total + Value;
1616
      end;
1617
      // Total
1618
      case ComboBoxType.ItemIndex of
1619
        0: // Analyse proximale
1620
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
1621
          then // sur frais
1622
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
1623
          else // sur mati?re s?che - except? pour Composition et MS
1624
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
1625
        1: // Valeurs ?nerg?tiques
1626
          if FormOptions.Expression = 0
1627
          then // sur frais
1628
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
1629
          else // sur mati?re s?che
1630
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
1631
        2, 3: // Acides amin?s
1632
          if FormOptions.Expression = 0
1633
          then // sur frais
1634
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
1635
          else // sur mati?re s?che
1636
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
1637
        4: // Min?raux
1638
          if FormOptions.Expression = 0
1639
          then // sur frais
1640
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
1641
          else // sur mati?re s?che
1642
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
1643
      end;
1644
      ClientDataSetComposition.Filtered := False;
1645
      ClientDataSetComposition.Filter := '';
1646
    end;
1647
end;
1648
1649
procedure TFormFeedsCharts.ComboBoxFeed3Change(Sender: TObject);
1650
var
1651
  IngredientName: String;
1652
  Cumul, Ratio, Total, Value: Double;
1653
  FeedBar: TBarSeries;
1654
begin
1655
//  while ChartFeed3.SeriesCount > 0 do
1656
//    ChartFeed3.Series[0].Free;
1657
  ChartFeed3.FreeAllSeries(nil);
1658
  ChartFeed3.Title.Clear;
1659
  ChartFeed3.SubTitle.Clear;
1660
  if ComboBoxFeed3.ItemIndex <> -1
1661
  then
1662
    with DataModuleDeclaration do
1663
    begin
1664
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed3.Text, []);
1665
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed3.Text) + 1;
1666
      ChartFeed3.AxisVisible := True;
1667
      ChartFeed3.Title.Text.Add(ClientDataSetFeedsName.Value);
1668
      ChartFeed3.SubTitle.Text.Add(ComboBoxType.Text);
1669
      case ComboBoxType.ItemIndex of
1670
        0: // Analyse proximale
1671
          ChartFeed3.SubTitle.Text.Add(ComboBoxProximal.Text);
1672
        1: // Valeurs ?nerg?tiques
1673
          ChartFeed3.SubTitle.Text.Add(ComboBoxEnergy.Text);
1674
        2, 3: // Acides amin?s
1675
          ChartFeed3.SubTitle.Text.Add(ComboBoxAA.Text);
1676
        4: // Min?raux
1677
          ChartFeed3.SubTitle.Text.Add(ComboBoxMinerals.Text);
1678
      end;
1679
      case ComboBoxType.ItemIndex of
1680
        0: // Analyse proximale
1681
          case ComboBoxProximal.ItemIndex of
1682
            0: // Composition
1683
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
1684
            1: // MS
1685
              Cumul := ClientDataSetFeedsMS.Value;
1686
            2: // MM
1687
              Cumul := ClientDataSetFeedsMM.Value;
1688
            3: // MAT
1689
              Cumul := ClientDataSetFeedsMAT.Value;
1690
            4: // MG
1691
              Cumul := ClientDataSetFeedsMG.Value;
1692
            5: // CB
1693
              Cumul := ClientDataSetFeedsCB.Value;
1694
            6: // NDF
1695
              Cumul := ClientDataSetFeedsNDF.Value;
1696
            7: // ADF
1697
              Cumul := ClientDataSetFeedsADF.Value;
1698
            8: // ADL
1699
              Cumul := ClientDataSetFeedsADL.Value;
1700
            9: // Amidon
1701
              Cumul := ClientDataSetFeedsAmidon.Value;
1702
            10: // Sucres
1703
              Cumul := ClientDataSetFeedsSucres.Value;
1704
            else
1705
              Cumul := 0;
1706
          end;
1707
        1: // Valeurs ?nerg?tiques
1708
          case ComboBoxEnergy.ItemIndex of
1709
            0: // Energie brute
1710
              Cumul := ClientDataSetFeedsEB.Value;
1711
            1: // Energie digestible (porc croissance)
1712
              Cumul := ClientDataSetFeedsEDc.Value;
1713
            2: // Energie digestible (porc adulte)
1714
              Cumul := ClientDataSetFeedsEDt.Value;
1715
            3: // Energie m?tabolisable (porc croissance)
1716
              Cumul := ClientDataSetFeedsEMc.Value;
1717
            4: // Energie m?tabolisable (porc adulte)
1718
              Cumul := ClientDataSetFeedsEMt.Value;
1719
            5: // Energie nette (porc croissance)
1720
              Cumul := ClientDataSetFeedsENc.Value;
1721
            6: // Energie nette (porc adulte)
1722
              Cumul := ClientDataSetFeedsENt.Value;
1723
            else
1724
              Cumul := 0;
1725
          end;
1726
        2: // Acides amin?s totaux
1727
          case ComboBoxAA.ItemIndex of
1728
            0: // Lysine
1729
              Cumul := ClientDataSetFeedsLys.Value;
1730
            1: // Thr?onine
1731
              Cumul := ClientDataSetFeedsThr.Value;
1732
            2: // M?thionine
1733
              Cumul := ClientDataSetFeedsMet.Value;
1734
            3: // Cyst?ine
1735
              Cumul := ClientDataSetFeedsCys.Value;
1736
            4: // M?thionine + Cyst?ine
1737
              Cumul := ClientDataSetFeedsMetCys.Value;
1738
            5: // Tryptophane
1739
              Cumul := ClientDataSetFeedsTrp.Value;
1740
            6: // Isoleucine
1741
              Cumul := ClientDataSetFeedsIle.Value;
1742
            7: // Valine
1743
              Cumul := ClientDataSetFeedsVal.Value;
1744
            8: // Leucine
1745
              Cumul := ClientDataSetFeedsLeu.Value;
1746
            9: // Ph?nylalanine
1747
              Cumul := ClientDataSetFeedsPhe.Value;
1748
            10: // Tyrosine
1749
              Cumul := ClientDataSetFeedsTyr.Value;
1750
            11: // Ph?nylalanine + Tyrosine
1751
              Cumul := ClientDataSetFeedsPheTyr.Value;
1752
            12: // Histidine
1753
              Cumul := ClientDataSetFeedsHis.Value;
1754
            13: // Arginine
1755
              Cumul := ClientDataSetFeedsArg.Value;
1756
            14: // Alanine
1757
              Cumul := ClientDataSetFeedsAla.Value;
1758
            15: // Aspartate
1759
              Cumul := ClientDataSetFeedsAsp.Value;
1760
            16: // Glutamate
1761
              Cumul := ClientDataSetFeedsGlu.Value;
1762
            17: // Glycine
1763
              Cumul := ClientDataSetFeedsGly.Value;
1764
            18: // S?rine
1765
              Cumul := ClientDataSetFeedsSer.Value;
1766
            19: // Proline
1767
              Cumul := ClientDataSetFeedsPro.Value;
1768
            else
1769
              Cumul := 0;
1770
          end;
1771
        3: // Acides amin?s digestibles
1772
          case ComboBoxAA.ItemIndex of
1773
            0: // Lysine
1774
              Cumul := ClientDataSetFeedsLysd.Value;
1775
            1: // Thr?onine
1776
              Cumul := ClientDataSetFeedsThrd.Value;
1777
            2: // M?thionine
1778
              Cumul := ClientDataSetFeedsMetd.Value;
1779
            3: // Cyst?ine
1780
              Cumul := ClientDataSetFeedsCysd.Value;
1781
            4: // M?thionine + Cyst?ine
1782
              Cumul := ClientDataSetFeedsMetCysd.Value;
1783
            5: // Tryptophane
1784
              Cumul := ClientDataSetFeedsTrpd.Value;
1785
            6: // Isoleucine
1786
              Cumul := ClientDataSetFeedsIled.Value;
1787
            7: // Valine
1788
              Cumul := ClientDataSetFeedsVald.Value;
1789
            8: // Leucine
1790
              Cumul := ClientDataSetFeedsLeud.Value;
1791
            9: // Ph?nylalanine
1792
              Cumul := ClientDataSetFeedsPhed.Value;
1793
            10: // Tyrosine
1794
              Cumul := ClientDataSetFeedsTyrd.Value;
1795
            11: // Ph?nylalanine + Tyrosine
1796
              Cumul := ClientDataSetFeedsPheTyrd.Value;
1797
            12: // Histidine
1798
              Cumul := ClientDataSetFeedsHisd.Value;
1799
            13: // Arginine
1800
              Cumul := ClientDataSetFeedsArgd.Value;
1801
            14: // Alanine
1802
              Cumul := ClientDataSetFeedsAlad.Value;
1803
            15: // Aspartate
1804
              Cumul := ClientDataSetFeedsAspd.Value;
1805
            16: // Glutamate
1806
              Cumul := ClientDataSetFeedsGlud.Value;
1807
            17: // Glycine
1808
              Cumul := ClientDataSetFeedsGlyd.Value;
1809
            18: // S?rine
1810
              Cumul := ClientDataSetFeedsSerd.Value;
1811
            19: // Proline
1812
              Cumul := ClientDataSetFeedsProd.Value;
1813
            else
1814
              Cumul := 0;
1815
          end;
1816
        4: // Min?raux
1817
          case ComboBoxMinerals.ItemIndex of
1818
            0: // Calcium
1819
              Cumul := ClientDataSetFeedsCa.Value;
1820
            1: // Phosphore
1821
              Cumul := ClientDataSetFeedsP.Value;
1822 4 avalancogn
            2: // Sodium
1823
              Cumul := ClientDataSetFeedsNa.Value;
1824
            3: // Potassium
1825
              Cumul := ClientDataSetFeedsK.Value;
1826
            4: // Chlore
1827
              Cumul := ClientDataSetFeedsCl.Value;
1828
            5: // Phosphore digestible
1829 1 avalancogn
              Cumul := ClientDataSetFeedsPd.Value;
1830
            else
1831
              Cumul := 0;
1832
          end;
1833
        else
1834
          Cumul := 0;
1835
      end;
1836
      if Cumul = 0
1837
      then // Division par z?ro
1838
        Cumul := 1;
1839
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
1840
      ClientDataSetComposition.Filtered := True;
1841
      ClientDataSetComposition.First;
1842
      Total := 0;
1843
      while not ClientDataSetComposition.Eof do
1844
      begin
1845
        if ClientDataSetCompositionUser.Value
1846
        then
1847
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
1848
        else
1849
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
1850
        ClientDataSetIngredients.Filtered := True;
1851
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
1852
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
1853
        if (FormOptions.Expression = 0)
1854
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1855
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
1856
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
1857
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
1858
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1859
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
1860
          Ratio := Ratio * RapMS;
1861
        case ComboBoxType.ItemIndex of
1862
          0: // Analyse proximale
1863
            case ComboBoxProximal.ItemIndex of
1864
              0: // Composition
1865
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1866
              1: // MS
1867
                Value := ClientDataSetCompositionMS.Value * Ratio;
1868
              2: // MM
1869
                Value := ClientDataSetIngredientsMM.Value * Ratio;
1870
              3: // MAT
1871
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
1872
              4: // MG
1873
                Value := ClientDataSetIngredientsMG.Value * Ratio;
1874
              5: // CB
1875
                Value := ClientDataSetIngredientsCB.Value * Ratio;
1876
              6: // NDF
1877
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
1878
              7: // ADF
1879
                Value := ClientDataSetIngredientsADF.Value * Ratio;
1880
              8: // ADL
1881
                Value := ClientDataSetIngredientsADL.Value * Ratio;
1882
              9: // Amidon
1883
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
1884
              10: // Sucres
1885
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
1886
              else
1887
                Value := 0;
1888
            end;
1889
          1: // Valeurs ?nerg?tiques
1890
            case ComboBoxEnergy.ItemIndex of
1891
              0: // Energie brute
1892
                Value := ClientDataSetIngredientsEB.Value * Ratio;
1893
              1: // Energie digestible (porc croissance)
1894
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
1895
              2: // Energie digestible (porc adulte)
1896
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
1897
              3: // Energie m?tabolisable (porc croissance)
1898
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
1899
              4: // Energie m?tabolisable (porc adulte)
1900
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
1901
              5: // Energie nette (porc croissance)
1902
                Value := ClientDataSetIngredientsENc.Value * Ratio;
1903
              6: // Energie nette (porc adulte)
1904
                Value := ClientDataSetIngredientsENt.Value * Ratio;
1905
              else
1906
                Value := 0;
1907
            end;
1908
          2: // Acides amin?s totaux
1909
            case ComboBoxAA.ItemIndex of
1910
              0: // Lysine
1911
                Value := ClientDataSetIngredientsLys.Value * Ratio;
1912
              1: // Thr?onine
1913
                Value := ClientDataSetIngredientsThr.Value * Ratio;
1914
              2: // M?thionine
1915
                Value := ClientDataSetIngredientsMet.Value * Ratio;
1916
              3: // Cyst?ine
1917
                Value := ClientDataSetIngredientsCys.Value * Ratio;
1918
              4: // M?thionine + Cyst?ine
1919
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
1920
              5: // Tryptophane
1921
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
1922
              6: // Isoleucine
1923
                Value := ClientDataSetIngredientsIle.Value * Ratio;
1924
              7: // Valine
1925
                Value := ClientDataSetIngredientsVal.Value * Ratio;
1926
              8: // Leucine
1927
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
1928
              9: // Ph?nylalanine
1929
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
1930
              10: // Tyrosine
1931
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
1932
              11: // Ph?nylalanine + Tyrosine
1933
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
1934
              12: // Histidine
1935
                Value := ClientDataSetIngredientsHis.Value * Ratio;
1936
              13: // Arginine
1937
                Value := ClientDataSetIngredientsArg.Value * Ratio;
1938
              14: // Alanine
1939
                Value := ClientDataSetIngredientsAla.Value * Ratio;
1940
              15: // Aspartate
1941
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
1942
              16: // Glutamate
1943
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
1944
              17: // Glycine
1945
                Value := ClientDataSetIngredientsGly.Value * Ratio;
1946
              18: // S?rine
1947
                Value := ClientDataSetIngredientsSer.Value * Ratio;
1948
              19: // Proline
1949
                Value := ClientDataSetIngredientsPro.Value * Ratio;
1950
              else
1951
                Value := 0;
1952
            end;
1953
          3: // Acides amin?s digestibles
1954
            case ComboBoxAA.ItemIndex of
1955
              0: // Lysine
1956
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
1957
              1: // Thr?onine
1958
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
1959
              2: // M?thionine
1960
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
1961
              3: // Cyst?ine
1962
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
1963
              4: // M?thionine + Cyst?ine
1964
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
1965
              5: // Tryptophane
1966
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
1967
              6: // Isoleucine
1968
                Value := ClientDataSetIngredientsIled.Value * Ratio;
1969
              7: // Valine
1970
                Value := ClientDataSetIngredientsVald.Value * Ratio;
1971
              8: // Leucine
1972
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
1973
              9: // Ph?nylalanine
1974
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
1975
              10: // Tyrosine
1976
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
1977
              11: // Ph?nylalanine + Tyrosine
1978
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
1979
              12: // Histidine
1980
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
1981
              13: // Arginine
1982
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
1983
              14: // Alanine
1984
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
1985
              15: // Aspartate
1986
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
1987
              16: // Glutamate
1988
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
1989
              17: // Glycine
1990
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
1991
              18: // S?rine
1992
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
1993
              19: // Proline
1994
                Value := ClientDataSetIngredientsProd.Value * Ratio;
1995
              else
1996
                Value := 0;
1997
            end;
1998
          4: // Min?raux
1999
            case ComboBoxMinerals.ItemIndex of
2000
              0: // Calcium
2001
                Value := ClientDataSetIngredientsCa.Value * Ratio;
2002
              1: // Phosphore
2003
                Value := ClientDataSetIngredientsP.Value * Ratio;
2004 4 avalancogn
              2: // Sodium
2005
                Value := ClientDataSetIngredientsNa.Value * Ratio;
2006
              3: // Potassium
2007
                Value := ClientDataSetIngredientsK.Value * Ratio;
2008
              4: // Chlore
2009
                Value := ClientDataSetIngredientsCl.Value * Ratio;
2010
              5: // Phosphore digestible
2011 1 avalancogn
                if ClientDataSetFeedsPresentation.Value = 0
2012
                then // Farine (dPphy)
2013
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
2014
                else // Granul?s (dP)
2015
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
2016
              else
2017
                Value := 0;
2018
            end;
2019
          else
2020
            Value := 0;
2021
        end;
2022
        if (FormOptions.Expression = 1)
2023
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2024
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
2025
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
2026
        if Value > 0
2027
        then // Prendre en compte la valeur
2028
        begin
2029
          FeedBar := TBarSeries.Create(ChartFeed3);
2030
          FeedBar.ParentChart := ChartFeed3;
2031
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
2032
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
2033
          FeedBar.MultiBar := mbStacked100;
2034
          FeedBar.Marks.Visible := False;
2035
          ChartFeed3.AddSeries(FeedBar);
2036
          FeedBar.AddBar(Value, '', clTeeColor);
2037
          Total := Total + Value;
2038
        end;
2039
        ClientDataSetComposition.Next;
2040
      end;
2041
      ClientDataSetIngredients.Filtered := False;
2042
      ClientDataSetIngredients.Filter := '';
2043
      // Cas particuliers
2044
      if (ComboBoxType.ItemIndex = 1)
2045
      and ((ComboBoxEnergy.ItemIndex = 1)
2046
        or (ComboBoxEnergy.ItemIndex = 3)
2047
        or (ComboBoxEnergy.ItemIndex = 5))
2048
      and (ClientDataSetFeedsBonusC.Value > 0)
2049
      then // Bonus ?nergie (porc croissance)
2050
      begin
2051
        case ComboBoxEnergy.ItemIndex of
2052
          1: Value := ClientDataSetFeedsEDc.Value - Total;
2053
          3: Value := ClientDataSetFeedsEMc.Value - Total;
2054
          5: Value := ClientDataSetFeedsENc.Value - Total;
2055
          else Value := 0;
2056
        end;
2057
        FeedBar := TBarSeries.Create(ChartFeed3);
2058
        FeedBar.ParentChart := ChartFeed3;
2059
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2060
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2061
        FeedBar.MultiBar := mbStacked100;
2062
        FeedBar.Marks.Visible := False;
2063
        ChartFeed3.AddSeries(FeedBar);
2064
        FeedBar.AddBar(Value, '', clTeeColor);
2065
        Total := Total + Value;
2066
      end;
2067
      if (ComboBoxType.ItemIndex = 1)
2068
      and ((ComboBoxEnergy.ItemIndex = 2)
2069
        or (ComboBoxEnergy.ItemIndex = 4)
2070
        or (ComboBoxEnergy.ItemIndex = 6))
2071
      and (ClientDataSetFeedsBonusT.Value > 0)
2072
      then // Bonus ?nergie (porc adulte)
2073
      begin
2074
        case ComboBoxEnergy.ItemIndex of
2075
          2: Value := ClientDataSetFeedsEDt.Value - Total;
2076
          4: Value := ClientDataSetFeedsEMt.Value - Total;
2077
          6: Value := ClientDataSetFeedsENt.Value - Total;
2078
          else Value := 0;
2079
        end;
2080
        FeedBar := TBarSeries.Create(ChartFeed3);
2081
        FeedBar.ParentChart := ChartFeed3;
2082
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2083
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2084
        FeedBar.MultiBar := mbStacked100;
2085
        FeedBar.Marks.Visible := False;
2086
        ChartFeed3.AddSeries(FeedBar);
2087
        FeedBar.AddBar(Value, '', clTeeColor);
2088
        Total := Total + Value;
2089
      end;
2090
      if (ComboBoxType.ItemIndex = 0)
2091
      and (ComboBoxProximal.ItemIndex = 0)
2092
      and not ClientDataSetFeedsPhytaseId.IsNull
2093
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
2094
      then // Phytase (taux d'incorporation)
2095
      begin
2096
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
2097
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
2098
        FeedBar := TBarSeries.Create(ChartFeed3);
2099
        FeedBar.ParentChart := ChartFeed3;
2100
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2101
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2102
        FeedBar.MultiBar := mbStacked100;
2103
        FeedBar.Marks.Visible := False;
2104
        ChartFeed3.AddSeries(FeedBar);
2105
        FeedBar.AddBar(Value, '', clTeeColor);
2106
        Total := Total + Value;
2107
      end;
2108
      if (ComboBoxType.ItemIndex = 4)
2109
      and (ComboBoxMinerals.ItemIndex = 2)
2110
      and not ClientDataSetFeedsPhytaseId.IsNull
2111
      and (ClientDataSetFeedsPd.Value > Total)
2112
      then // Phytase (Phosphore digestible)
2113
      begin
2114
        Value := ClientDataSetFeedsPd.Value - Total;
2115
        FeedBar := TBarSeries.Create(ChartFeed3);
2116
        FeedBar.ParentChart := ChartFeed3;
2117
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2118
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2119
        FeedBar.MultiBar := mbStacked100;
2120
        FeedBar.Marks.Visible := False;
2121
        ChartFeed3.AddSeries(FeedBar);
2122
        FeedBar.AddBar(Value, '', clTeeColor);
2123
        Total := Total + Value;
2124
      end;
2125
      // Total
2126
      case ComboBoxType.ItemIndex of
2127
        0: // Analyse proximale
2128
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
2129
          then // sur frais
2130
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
2131
          else // sur mati?re s?che - except? pour Composition et MS
2132
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
2133
        1: // Valeurs ?nerg?tiques
2134
          if FormOptions.Expression = 0
2135
          then // sur frais
2136
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
2137
          else // sur mati?re s?che
2138
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
2139
        2, 3: // Acides amin?s
2140
          if FormOptions.Expression = 0
2141
          then // sur frais
2142
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
2143
          else // sur mati?re s?che
2144
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
2145
        4: // Min?raux
2146
          if FormOptions.Expression = 0
2147
          then // sur frais
2148
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
2149
          else // sur mati?re s?che
2150
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
2151
      end;
2152
      ClientDataSetComposition.Filtered := False;
2153
      ClientDataSetComposition.Filter := '';
2154
    end;
2155
end;
2156
2157
procedure TFormFeedsCharts.ComboBoxFeed4Change(Sender: TObject);
2158
var
2159
  IngredientName: String;
2160
  Cumul, Ratio, Total, Value: Double;
2161
  FeedBar: TBarSeries;
2162
begin
2163
//  while ChartFeed4.SeriesCount > 0 do
2164
//    ChartFeed4.Series[0].Free;
2165
  ChartFeed4.FreeAllSeries(nil);
2166
  ChartFeed4.Title.Clear;
2167
  ChartFeed4.SubTitle.Clear;
2168
  if ComboBoxFeed4.ItemIndex <> -1
2169
  then
2170
    with DataModuleDeclaration do
2171
    begin
2172
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed4.Text, []);
2173
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed4.Text) + 1;
2174
      ChartFeed4.AxisVisible := True;
2175
      ChartFeed4.Title.Text.Add(ClientDataSetFeedsName.Value);
2176
      ChartFeed4.SubTitle.Text.Add(ComboBoxType.Text);
2177
      case ComboBoxType.ItemIndex of
2178
        0: // Analyse proximale
2179
          ChartFeed4.SubTitle.Text.Add(ComboBoxProximal.Text);
2180
        1: // Valeurs ?nerg?tiques
2181
          ChartFeed4.SubTitle.Text.Add(ComboBoxEnergy.Text);
2182
        2, 3: // Acides amin?s
2183
          ChartFeed4.SubTitle.Text.Add(ComboBoxAA.Text);
2184
        4: // Min?raux
2185
          ChartFeed4.SubTitle.Text.Add(ComboBoxMinerals.Text);
2186
      end;
2187
      case ComboBoxType.ItemIndex of
2188
        0: // Analyse proximale
2189
          case ComboBoxProximal.ItemIndex of
2190
            0: // Composition
2191
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
2192
            1: // MS
2193
              Cumul := ClientDataSetFeedsMS.Value;
2194
            2: // MM
2195
              Cumul := ClientDataSetFeedsMM.Value;
2196
            3: // MAT
2197
              Cumul := ClientDataSetFeedsMAT.Value;
2198
            4: // MG
2199
              Cumul := ClientDataSetFeedsMG.Value;
2200
            5: // CB
2201
              Cumul := ClientDataSetFeedsCB.Value;
2202
            6: // NDF
2203
              Cumul := ClientDataSetFeedsNDF.Value;
2204
            7: // ADF
2205
              Cumul := ClientDataSetFeedsADF.Value;
2206
            8: // ADL
2207
              Cumul := ClientDataSetFeedsADL.Value;
2208
            9: // Amidon
2209
              Cumul := ClientDataSetFeedsAmidon.Value;
2210
            10: // Sucres
2211
              Cumul := ClientDataSetFeedsSucres.Value;
2212
            else
2213
              Cumul := 0;
2214
          end;
2215
        1: // Valeurs ?nerg?tiques
2216
          case ComboBoxEnergy.ItemIndex of
2217
            0: // Energie brute
2218
              Cumul := ClientDataSetFeedsEB.Value;
2219
            1: // Energie digestible (porc croissance)
2220
              Cumul := ClientDataSetFeedsEDc.Value;
2221
            2: // Energie digestible (porc adulte)
2222
              Cumul := ClientDataSetFeedsEDt.Value;
2223
            3: // Energie m?tabolisable (porc croissance)
2224
              Cumul := ClientDataSetFeedsEMc.Value;
2225
            4: // Energie m?tabolisable (porc adulte)
2226
              Cumul := ClientDataSetFeedsEMt.Value;
2227
            5: // Energie nette (porc croissance)
2228
              Cumul := ClientDataSetFeedsENc.Value;
2229
            6: // Energie nette (porc adulte)
2230
              Cumul := ClientDataSetFeedsENt.Value;
2231
            else
2232
              Cumul := 0;
2233
          end;
2234
        2: // Acides amin?s totaux
2235
          case ComboBoxAA.ItemIndex of
2236
            0: // Lysine
2237
              Cumul := ClientDataSetFeedsLys.Value;
2238
            1: // Thr?onine
2239
              Cumul := ClientDataSetFeedsThr.Value;
2240
            2: // M?thionine
2241
              Cumul := ClientDataSetFeedsMet.Value;
2242
            3: // Cyst?ine
2243
              Cumul := ClientDataSetFeedsCys.Value;
2244
            4: // M?thionine + Cyst?ine
2245
              Cumul := ClientDataSetFeedsMetCys.Value;
2246
            5: // Tryptophane
2247
              Cumul := ClientDataSetFeedsTrp.Value;
2248
            6: // Isoleucine
2249
              Cumul := ClientDataSetFeedsIle.Value;
2250
            7: // Valine
2251
              Cumul := ClientDataSetFeedsVal.Value;
2252
            8: // Leucine
2253
              Cumul := ClientDataSetFeedsLeu.Value;
2254
            9: // Ph?nylalanine
2255
              Cumul := ClientDataSetFeedsPhe.Value;
2256
            10: // Tyrosine
2257
              Cumul := ClientDataSetFeedsTyr.Value;
2258
            11: // Ph?nylalanine + Tyrosine
2259
              Cumul := ClientDataSetFeedsPheTyr.Value;
2260
            12: // Histidine
2261
              Cumul := ClientDataSetFeedsHis.Value;
2262
            13: // Arginine
2263
              Cumul := ClientDataSetFeedsArg.Value;
2264
            14: // Alanine
2265
              Cumul := ClientDataSetFeedsAla.Value;
2266
            15: // Aspartate
2267
              Cumul := ClientDataSetFeedsAsp.Value;
2268
            16: // Glutamate
2269
              Cumul := ClientDataSetFeedsGlu.Value;
2270
            17: // Glycine
2271
              Cumul := ClientDataSetFeedsGly.Value;
2272
            18: // S?rine
2273
              Cumul := ClientDataSetFeedsSer.Value;
2274
            19: // Proline
2275
              Cumul := ClientDataSetFeedsPro.Value;
2276
            else
2277
              Cumul := 0;
2278
          end;
2279
        3: // Acides amin?s digestibles
2280
          case ComboBoxAA.ItemIndex of
2281
            0: // Lysine
2282
              Cumul := ClientDataSetFeedsLysd.Value;
2283
            1: // Thr?onine
2284
              Cumul := ClientDataSetFeedsThrd.Value;
2285
            2: // M?thionine
2286
              Cumul := ClientDataSetFeedsMetd.Value;
2287
            3: // Cyst?ine
2288
              Cumul := ClientDataSetFeedsCysd.Value;
2289
            4: // M?thionine + Cyst?ine
2290
              Cumul := ClientDataSetFeedsMetCysd.Value;
2291
            5: // Tryptophane
2292
              Cumul := ClientDataSetFeedsTrpd.Value;
2293
            6: // Isoleucine
2294
              Cumul := ClientDataSetFeedsIled.Value;
2295
            7: // Valine
2296
              Cumul := ClientDataSetFeedsVald.Value;
2297
            8: // Leucine
2298
              Cumul := ClientDataSetFeedsLeud.Value;
2299
            9: // Ph?nylalanine
2300
              Cumul := ClientDataSetFeedsPhed.Value;
2301
            10: // Tyrosine
2302
              Cumul := ClientDataSetFeedsTyrd.Value;
2303
            11: // Ph?nylalanine + Tyrosine
2304
              Cumul := ClientDataSetFeedsPheTyrd.Value;
2305
            12: // Histidine
2306
              Cumul := ClientDataSetFeedsHisd.Value;
2307
            13: // Arginine
2308
              Cumul := ClientDataSetFeedsArgd.Value;
2309
            14: // Alanine
2310
              Cumul := ClientDataSetFeedsAlad.Value;
2311
            15: // Aspartate
2312
              Cumul := ClientDataSetFeedsAspd.Value;
2313
            16: // Glutamate
2314
              Cumul := ClientDataSetFeedsGlud.Value;
2315
            17: // Glycine
2316
              Cumul := ClientDataSetFeedsGlyd.Value;
2317
            18: // S?rine
2318
              Cumul := ClientDataSetFeedsSerd.Value;
2319
            19: // Proline
2320
              Cumul := ClientDataSetFeedsProd.Value;
2321
            else
2322
              Cumul := 0;
2323
          end;
2324
        4: // Min?raux
2325
          case ComboBoxMinerals.ItemIndex of
2326
            0: // Calcium
2327
              Cumul := ClientDataSetFeedsCa.Value;
2328
            1: // Phosphore
2329
              Cumul := ClientDataSetFeedsP.Value;
2330 4 avalancogn
            2: // Sodium
2331
              Cumul := ClientDataSetFeedsNa.Value;
2332
            3: // Potassium
2333
              Cumul := ClientDataSetFeedsK.Value;
2334
            4: // Chlore
2335
              Cumul := ClientDataSetFeedsCl.Value;
2336
            5: // Phosphore digestible
2337 1 avalancogn
              Cumul := ClientDataSetFeedsPd.Value;
2338
            else
2339
              Cumul := 0;
2340
          end;
2341
        else
2342
          Cumul := 0;
2343
      end;
2344
      if Cumul = 0
2345
      then // Division par z?ro
2346
        Cumul := 1;
2347
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
2348
      ClientDataSetComposition.Filtered := True;
2349
      ClientDataSetComposition.First;
2350
      Total := 0;
2351
      while not ClientDataSetComposition.Eof do
2352
      begin
2353
        if ClientDataSetCompositionUser.Value
2354
        then
2355
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
2356
        else
2357
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
2358
        ClientDataSetIngredients.Filtered := True;
2359
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
2360
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
2361
        if (FormOptions.Expression = 0)
2362
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2363
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
2364
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
2365
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
2366
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2367
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
2368
          Ratio := Ratio * RapMS;
2369
        case ComboBoxType.ItemIndex of
2370
          0: // Analyse proximale
2371
            case ComboBoxProximal.ItemIndex of
2372
              0: // Composition
2373
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
2374
              1: // MS
2375
                Value := ClientDataSetCompositionMS.Value * Ratio;
2376
              2: // MM
2377
                Value := ClientDataSetIngredientsMM.Value * Ratio;
2378
              3: // MAT
2379
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
2380
              4: // MG
2381
                Value := ClientDataSetIngredientsMG.Value * Ratio;
2382
              5: // CB
2383
                Value := ClientDataSetIngredientsCB.Value * Ratio;
2384
              6: // NDF
2385
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
2386
              7: // ADF
2387
                Value := ClientDataSetIngredientsADF.Value * Ratio;
2388
              8: // ADL
2389
                Value := ClientDataSetIngredientsADL.Value * Ratio;
2390
              9: // Amidon
2391
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
2392
              10: // Sucres
2393
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
2394
              else
2395
                Value := 0;
2396
            end;
2397
          1: // Valeurs ?nerg?tiques
2398
            case ComboBoxEnergy.ItemIndex of
2399
              0: // Energie brute
2400
                Value := ClientDataSetIngredientsEB.Value * Ratio;
2401
              1: // Energie digestible (porc croissance)
2402
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
2403
              2: // Energie digestible (porc adulte)
2404
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
2405
              3: // Energie m?tabolisable (porc croissance)
2406
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
2407
              4: // Energie m?tabolisable (porc adulte)
2408
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
2409
              5: // Energie nette (porc croissance)
2410
                Value := ClientDataSetIngredientsENc.Value * Ratio;
2411
              6: // Energie nette (porc adulte)
2412
                Value := ClientDataSetIngredientsENt.Value * Ratio;
2413
              else
2414
                Value := 0;
2415
            end;
2416
          2: // Acides amin?s totaux
2417
            case ComboBoxAA.ItemIndex of
2418
              0: // Lysine
2419
                Value := ClientDataSetIngredientsLys.Value * Ratio;
2420
              1: // Thr?onine
2421
                Value := ClientDataSetIngredientsThr.Value * Ratio;
2422
              2: // M?thionine
2423
                Value := ClientDataSetIngredientsMet.Value * Ratio;
2424
              3: // Cyst?ine
2425
                Value := ClientDataSetIngredientsCys.Value * Ratio;
2426
              4: // M?thionine + Cyst?ine
2427
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
2428
              5: // Tryptophane
2429
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
2430
              6: // Isoleucine
2431
                Value := ClientDataSetIngredientsIle.Value * Ratio;
2432
              7: // Valine
2433
                Value := ClientDataSetIngredientsVal.Value * Ratio;
2434
              8: // Leucine
2435
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
2436
              9: // Ph?nylalanine
2437
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
2438
              10: // Tyrosine
2439
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
2440
              11: // Ph?nylalanine + Tyrosine
2441
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
2442
              12: // Histidine
2443
                Value := ClientDataSetIngredientsHis.Value * Ratio;
2444
              13: // Arginine
2445
                Value := ClientDataSetIngredientsArg.Value * Ratio;
2446
              14: // Alanine
2447
                Value := ClientDataSetIngredientsAla.Value * Ratio;
2448
              15: // Aspartate
2449
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
2450
              16: // Glutamate
2451
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
2452
              17: // Glycine
2453
                Value := ClientDataSetIngredientsGly.Value * Ratio;
2454
              18: // S?rine
2455
                Value := ClientDataSetIngredientsSer.Value * Ratio;
2456
              19: // Proline
2457
                Value := ClientDataSetIngredientsPro.Value * Ratio;
2458
              else
2459
                Value := 0;
2460
            end;
2461
          3: // Acides amin?s digestibles
2462
            case ComboBoxAA.ItemIndex of
2463
              0: // Lysine
2464
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
2465
              1: // Thr?onine
2466
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
2467
              2: // M?thionine
2468
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
2469
              3: // Cyst?ine
2470
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
2471
              4: // M?thionine + Cyst?ine
2472
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
2473
              5: // Tryptophane
2474
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
2475
              6: // Isoleucine
2476
                Value := ClientDataSetIngredientsIled.Value * Ratio;
2477
              7: // Valine
2478
                Value := ClientDataSetIngredientsVald.Value * Ratio;
2479
              8: // Leucine
2480
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
2481
              9: // Ph?nylalanine
2482
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
2483
              10: // Tyrosine
2484
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
2485
              11: // Ph?nylalanine + Tyrosine
2486
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
2487
              12: // Histidine
2488
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
2489
              13: // Arginine
2490
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
2491
              14: // Alanine
2492
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
2493
              15: // Aspartate
2494
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
2495
              16: // Glutamate
2496
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
2497
              17: // Glycine
2498
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
2499
              18: // S?rine
2500
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
2501
              19: // Proline
2502
                Value := ClientDataSetIngredientsProd.Value * Ratio;
2503
              else
2504
                Value := 0;
2505
            end;
2506
          4: // Min?raux
2507
            case ComboBoxMinerals.ItemIndex of
2508
              0: // Calcium
2509
                Value := ClientDataSetIngredientsCa.Value * Ratio;
2510
              1: // Phosphore
2511
                Value := ClientDataSetIngredientsP.Value * Ratio;
2512 4 avalancogn
              2: // Sodium
2513
                Value := ClientDataSetIngredientsNa.Value * Ratio;
2514
              3: // Potassium
2515
                Value := ClientDataSetIngredientsK.Value * Ratio;
2516
              4: // Chlore
2517
                Value := ClientDataSetIngredientsCl.Value * Ratio;
2518
              5: // Phosphore digestible
2519 1 avalancogn
                if ClientDataSetFeedsPresentation.Value = 0
2520
                then // Farine (dPphy)
2521
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
2522
                else // Granul?s (dP)
2523
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
2524
              else
2525
                Value := 0;
2526
            end;
2527
          else
2528
            Value := 0;
2529
        end;
2530
        if (FormOptions.Expression = 1)
2531
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2532
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
2533
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
2534
        if Value > 0
2535
        then // Prendre en compte la valeur
2536
        begin
2537
          FeedBar := TBarSeries.Create(ChartFeed4);
2538
          FeedBar.ParentChart := ChartFeed4;
2539
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
2540
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
2541
          FeedBar.MultiBar := mbStacked100;
2542
          FeedBar.Marks.Visible := False;
2543
          ChartFeed4.AddSeries(FeedBar);
2544
          FeedBar.AddBar(Value, '', clTeeColor);
2545
          Total := Total + Value;
2546
        end;
2547
        ClientDataSetComposition.Next;
2548
      end;
2549
      ClientDataSetIngredients.Filtered := False;
2550
      ClientDataSetIngredients.Filter := '';
2551
      // Cas particuliers
2552
      if (ComboBoxType.ItemIndex = 1)
2553
      and ((ComboBoxEnergy.ItemIndex = 1)
2554
        or (ComboBoxEnergy.ItemIndex = 3)
2555
        or (ComboBoxEnergy.ItemIndex = 5))
2556
      and (ClientDataSetFeedsBonusC.Value > 0)
2557
      then // Bonus ?nergie (porc croissance)
2558
      begin
2559
        case ComboBoxEnergy.ItemIndex of
2560
          1: Value := ClientDataSetFeedsEDc.Value - Total;
2561
          3: Value := ClientDataSetFeedsEMc.Value - Total;
2562
          5: Value := ClientDataSetFeedsENc.Value - Total;
2563
          else Value := 0;
2564
        end;
2565
        FeedBar := TBarSeries.Create(ChartFeed4);
2566
        FeedBar.ParentChart := ChartFeed4;
2567
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2568
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2569
        FeedBar.MultiBar := mbStacked100;
2570
        FeedBar.Marks.Visible := False;
2571
        ChartFeed4.AddSeries(FeedBar);
2572
        FeedBar.AddBar(Value, '', clTeeColor);
2573
        Total := Total + Value;
2574
      end;
2575
      if (ComboBoxType.ItemIndex = 1)
2576
      and ((ComboBoxEnergy.ItemIndex = 2)
2577
        or (ComboBoxEnergy.ItemIndex = 4)
2578
        or (ComboBoxEnergy.ItemIndex = 6))
2579
      and (ClientDataSetFeedsBonusT.Value > 0)
2580
      then // Bonus ?nergie (porc adulte)
2581
      begin
2582
        case ComboBoxEnergy.ItemIndex of
2583
          2: Value := ClientDataSetFeedsEDt.Value - Total;
2584
          4: Value := ClientDataSetFeedsEMt.Value - Total;
2585
          6: Value := ClientDataSetFeedsENt.Value - Total;
2586
          else Value := 0;
2587
        end;
2588
        FeedBar := TBarSeries.Create(ChartFeed4);
2589
        FeedBar.ParentChart := ChartFeed4;
2590
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2591
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2592
        FeedBar.MultiBar := mbStacked100;
2593
        FeedBar.Marks.Visible := False;
2594
        ChartFeed4.AddSeries(FeedBar);
2595
        FeedBar.AddBar(Value, '', clTeeColor);
2596
        Total := Total + Value;
2597
      end;
2598
      if (ComboBoxType.ItemIndex = 0)
2599
      and (ComboBoxProximal.ItemIndex = 0)
2600
      and not ClientDataSetFeedsPhytaseId.IsNull
2601
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
2602
      then // Phytase (taux d'incorporation)
2603
      begin
2604
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
2605
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
2606
        FeedBar := TBarSeries.Create(ChartFeed4);
2607
        FeedBar.ParentChart := ChartFeed4;
2608
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2609
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2610
        FeedBar.MultiBar := mbStacked100;
2611
        FeedBar.Marks.Visible := False;
2612
        ChartFeed4.AddSeries(FeedBar);
2613
        FeedBar.AddBar(Value, '', clTeeColor);
2614
        Total := Total + Value;
2615
      end;
2616
      if (ComboBoxType.ItemIndex = 4)
2617
      and (ComboBoxMinerals.ItemIndex = 2)
2618
      and not ClientDataSetFeedsPhytaseId.IsNull
2619
      and (ClientDataSetFeedsPd.Value > Total)
2620
      then // Phytase (Phosphore digestible)
2621
      begin
2622
        Value := ClientDataSetFeedsPd.Value - Total;
2623
        FeedBar := TBarSeries.Create(ChartFeed4);
2624
        FeedBar.ParentChart := ChartFeed4;
2625
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2626
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2627
        FeedBar.MultiBar := mbStacked100;
2628
        FeedBar.Marks.Visible := False;
2629
        ChartFeed4.AddSeries(FeedBar);
2630
        FeedBar.AddBar(Value, '', clTeeColor);
2631
        Total := Total + Value;
2632
      end;
2633
      // Total
2634
      case ComboBoxType.ItemIndex of
2635
        0: // Analyse proximale
2636
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
2637
          then // sur frais
2638
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
2639
          else // sur mati?re s?che - except? pour Composition et MS
2640
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
2641
        1: // Valeurs ?nerg?tiques
2642
          if FormOptions.Expression = 0
2643
          then // sur frais
2644
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
2645
          else // sur mati?re s?che
2646
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
2647
        2, 3: // Acides amin?s
2648
          if FormOptions.Expression = 0
2649
          then // sur frais
2650
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
2651
          else // sur mati?re s?che
2652
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
2653
        4: // Min?raux
2654
          if FormOptions.Expression = 0
2655
          then // sur frais
2656
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
2657
          else // sur mati?re s?che
2658
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
2659
      end;
2660
      ClientDataSetComposition.Filtered := False;
2661
      ClientDataSetComposition.Filter := '';
2662
    end;
2663
end;
2664
2665
procedure TFormFeedsCharts.ComboBoxOption0Change(Sender: TObject);
2666
begin
2667
  ComboBoxDietChange(nil);
2668
end;
2669
2670
procedure TFormFeedsCharts.ComboBoxOptionChange(Sender: TObject);
2671
begin
2672
  ComboBoxFeed1Change(nil);
2673
  ComboBoxFeed2Change(nil);
2674
  ComboBoxFeed3Change(nil);
2675
  ComboBoxFeed4Change(nil);
2676
end;
2677
2678
procedure TFormFeedsCharts.ComboBoxType0Change(Sender: TObject);
2679
begin
2680
  ComboBoxProximal0.Visible := False;
2681
  ComboBoxEnergy0.Visible := False;
2682
  ComboBoxRatios0.Visible := False;
2683
  ComboBoxAA0.Visible := False;
2684
  ComboBoxMinerals0.Visible := False;
2685
  case ComboBoxType0.ItemIndex of
2686
    0: // Analyse proximale
2687
      ComboBoxProximal0.Visible := True;
2688
    1: // Valeurs ?nerg?tiques
2689
      ComboBoxEnergy0.Visible := True;
2690
    2: // Rapports ?nerg?tiques
2691
      ComboBoxRatios0.Visible := True;
2692
    3, 4, 5: // Acides amin?s
2693
      ComboBoxAA0.Visible := True;
2694
    6: // Min?raux
2695
      ComboBoxMinerals0.Visible := True;
2696
  end;
2697
  ComboBoxOption0Change(nil);
2698
end;
2699
2700
procedure TFormFeedsCharts.ComboBoxTypeChange(Sender: TObject);
2701
begin
2702
  ComboBoxProximal.Visible := False;
2703
  ComboBoxEnergy.Visible := False;
2704
  ComboBoxAA.Visible := False;
2705
  ComboBoxMinerals.Visible := False;
2706
  case ComboBoxType.ItemIndex of
2707
    0: // Analyse proximale
2708
      ComboBoxProximal.Visible := True;
2709
    1: // Valeurs ?nerg?tiques
2710
      ComboBoxEnergy.Visible := True;
2711
    2, 3: // Acides amin?s
2712
      ComboBoxAA.Visible := True;
2713
    4: // Min?raux
2714
      ComboBoxMinerals.Visible := True;
2715
  end;
2716
  ComboBoxOptionChange(nil);
2717
end;
2718
2719
procedure TFormFeedsCharts.FormCreate(Sender: TObject);
2720
begin
2721
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
2722
  then
2723
  begin
2724
    Font.Name := 'Arial Unicode MS';
2725
    SetChartFont(Chart0, 'Arial Unicode MS');
2726
    SeriesBar.Marks.Font.Name := 'Arial Unicode MS';
2727
    SetChartFont(ChartFeed1, 'Arial Unicode MS');
2728
    SetChartFont(ChartFeed2, 'Arial Unicode MS');
2729
    SetChartFont(ChartFeed3, 'Arial Unicode MS');
2730
    SetChartFont(ChartFeed4, 'Arial Unicode MS');
2731
  end;
2732
//  PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
2733
  PanelButtons.Font.Style := [fsBold];
2734
  TranslateComponent(Self);
2735
  // S?lection des ?l?ments par d?faut apr?s traduction des listes
2736
  ComboBoxType0.ItemIndex := 0;
2737
  ComboBoxProximal0.ItemIndex := 0;
2738
  ComboBoxEnergy0.ItemIndex := 0;
2739
  ComboBoxRatios0.ItemIndex := 0;
2740
  ComboBoxAA0.ItemIndex := 0;
2741
  ComboBoxMinerals0.ItemIndex := 0;
2742
  ComboBoxDiet1.Items.Assign(DataModuleDeclaration.FeedList);
2743
  ComboBoxDiet2.Items.Assign(DataModuleDeclaration.FeedList);
2744
  ComboBoxDiet3.Items.Assign(DataModuleDeclaration.FeedList);
2745
  ComboBoxDiet4.Items.Assign(DataModuleDeclaration.FeedList);
2746
  ComboBoxDiet5.Items.Assign(DataModuleDeclaration.FeedList);
2747
  ComboBoxDiet6.Items.Assign(DataModuleDeclaration.FeedList);
2748
  Chart0.Title.Clear;
2749
  Chart0.SubTitle.Clear;
2750
  ComboBoxType.ItemIndex := 0;
2751
  ComboBoxProximal.ItemIndex := 0;
2752
  ComboBoxEnergy.ItemIndex := 0;
2753
  ComboBoxAA.ItemIndex := 0;
2754
  ComboBoxMinerals.ItemIndex := 0;
2755
  ComboBoxFeed1.Items.Assign(DataModuleDeclaration.FeedList);
2756
  ChartFeed1.Title.Clear;
2757
  ChartFeed1.SubTitle.Clear;
2758
  ComboBoxFeed2.Items.Assign(DataModuleDeclaration.FeedList);
2759
  ChartFeed2.Title.Clear;
2760
  ChartFeed2.SubTitle.Clear;
2761
  ComboBoxFeed3.Items.Assign(DataModuleDeclaration.FeedList);
2762
  ChartFeed3.Title.Clear;
2763
  ChartFeed3.SubTitle.Clear;
2764
  ComboBoxFeed4.Items.Assign(DataModuleDeclaration.FeedList);
2765
  ChartFeed4.Title.Clear;
2766
  ChartFeed4.SubTitle.Clear;
2767
end;
2768
2769
procedure TFormFeedsCharts.FormResize(Sender: TObject);
2770
var
2771
  W, H: Integer;
2772
begin
2773
  W := TabSheetChartsComparison.Width div 2;
2774
  H := (TabSheetChartsComparison.Height - GroupBoxChartSelection.Height) div 2;
2775
  GroupBoxFeed1.SetBounds(0, GroupBoxChartSelection.Height, W, H);
2776
  GroupBoxFeed2.SetBounds(W, GroupBoxChartSelection.Height, W, H);
2777
  GroupBoxFeed3.SetBounds(0, GroupBoxChartSelection.Height + H, W, H);
2778
  GroupBoxFeed4.SetBounds(W, GroupBoxChartSelection.Height + H, W, H);
2779
end;
2780
2781
procedure TFormFeedsCharts.SpeedButton2D3D0Click(Sender: TObject);
2782
begin
2783
  Chart0.View3D := not Chart0.View3D;
2784
  if Chart0.View3D
2785
  then
2786
    SeriesBar.Marks.ArrowLength := 8
2787
  else
2788
    SeriesBar.Marks.ArrowLength := 0;
2789
  if Chart0.View3D
2790
  then
2791
    SpeedButton2D3D0.Caption := _('2D')
2792
  else
2793
    SpeedButton2D3D0.Caption := _('3D');
2794
end;
2795
2796
procedure TFormFeedsCharts.SpeedButton2D3D1Click(Sender: TObject);
2797
begin
2798
  ChartFeed1.View3D := not ChartFeed1.View3D;
2799
  if ChartFeed1.View3D
2800
  then
2801
    SpeedButton2D3D1.Caption := _('2D')
2802
  else
2803
    SpeedButton2D3D1.Caption := _('3D');
2804
end;
2805
2806
procedure TFormFeedsCharts.SpeedButton2D3D2Click(Sender: TObject);
2807
begin
2808
  ChartFeed2.View3D := not ChartFeed2.View3D;
2809
  if ChartFeed2.View3D
2810
  then
2811
    SpeedButton2D3D2.Caption := _('2D')
2812
  else
2813
    SpeedButton2D3D2.Caption := _('3D');
2814
end;
2815
2816
procedure TFormFeedsCharts.SpeedButton2D3D3Click(Sender: TObject);
2817
begin
2818
  ChartFeed3.View3D := not ChartFeed3.View3D;
2819
  if ChartFeed3.View3D
2820
  then
2821
    SpeedButton2D3D3.Caption := _('2D')
2822
  else
2823
    SpeedButton2D3D3.Caption := _('3D');
2824
end;
2825
2826
procedure TFormFeedsCharts.SpeedButton2D3D4Click(Sender: TObject);
2827
begin
2828
  ChartFeed4.View3D := not ChartFeed4.View3D;
2829
  if ChartFeed4.View3D
2830
  then
2831
    SpeedButton2D3D4.Caption := _('2D')
2832
  else
2833
    SpeedButton2D3D4.Caption := _('3D');
2834
end;
2835
2836
procedure TFormFeedsCharts.SpeedButtonPrint0Click(Sender: TObject);
2837
begin
2838
  FormChartHReport := TFormChartHReport.Create(nil);
2839
  try
2840
    FormChartHReport.QRChart1.Chart.View3D := Chart0.View3D;
2841
    FormChartHReport.QRChart1.Chart.Title.Assign(Chart0.Title);
2842
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(Chart0.SubTitle);
2843
    FormChartHReport.QRChart1.Chart.Legend.Visible := False;
2844
    CloneChartSeries(SeriesBar).ParentChart := FormChartHReport.QRChart1.Chart;
2845
    FormChartHReport.QuickRepChart.PrinterSetup;
2846
    if FormChartHReport.QuickRepChart.Tag = 0
2847
    then
2848
      FormChartHReport.QuickRepChart.Print;
2849
  finally
2850
    FormChartHReport.Release;
2851
  end;
2852
end;
2853
2854
procedure TFormFeedsCharts.SpeedButtonPrint1Click(Sender: TObject);
2855
var
2856
  i: Integer;
2857
begin
2858
  FormChartHReport := TFormChartHReport.Create(nil);
2859
  try
2860
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed1.View3D;
2861
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed1.Title);
2862
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed1.SubTitle);
2863
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2864
    for i := 0 to ChartFeed1.SeriesCount - 1 do
2865
      CloneChartSeries(ChartFeed1[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2866
    FormChartHReport.QuickRepChart.PrinterSetup;
2867
    if FormChartHReport.QuickRepChart.Tag = 0
2868
    then
2869
      FormChartHReport.QuickRepChart.Print;
2870
  finally
2871
    FormChartHReport.Release;
2872
  end;
2873
end;
2874
2875
procedure TFormFeedsCharts.SpeedButtonPrint2Click(Sender: TObject);
2876
var
2877
  i: Integer;
2878
begin
2879
  FormChartHReport := TFormChartHReport.Create(nil);
2880
  try
2881
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed2.View3D;
2882
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed2.Title);
2883
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed2.SubTitle);
2884
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2885
    for i := 0 to ChartFeed2.SeriesCount - 1 do
2886
      CloneChartSeries(ChartFeed2[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2887
    FormChartHReport.QuickRepChart.PrinterSetup;
2888
    if FormChartHReport.QuickRepChart.Tag = 0
2889
    then
2890
      FormChartHReport.QuickRepChart.Print;
2891
  finally
2892
    FormChartHReport.Release;
2893
    Screen.Cursor := crDefault;
2894
  end;
2895
end;
2896
2897
procedure TFormFeedsCharts.SpeedButtonPrint3Click(Sender: TObject);
2898
var
2899
  i: Integer;
2900
begin
2901
  FormChartHReport := TFormChartHReport.Create(nil);
2902
  try
2903
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed3.View3D;
2904
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed3.Title);
2905
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed3.SubTitle);
2906
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2907
    for i := 0 to ChartFeed3.SeriesCount - 1 do
2908
      CloneChartSeries(ChartFeed3[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2909
    FormChartHReport.QuickRepChart.PrinterSetup;
2910
    if FormChartHReport.QuickRepChart.Tag = 0
2911
    then
2912
      FormChartHReport.QuickRepChart.Print;
2913
  finally
2914
    FormChartHReport.Release;
2915
    Screen.Cursor := crDefault;
2916
  end;
2917
end;
2918
2919
procedure TFormFeedsCharts.SpeedButtonPrint4Click(Sender: TObject);
2920
var
2921
  i: Integer;
2922
begin
2923
  FormChartHReport := TFormChartHReport.Create(nil);
2924
  try
2925
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed4.View3D;
2926
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed4.Title);
2927
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed4.SubTitle);
2928
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2929
    for i := 0 to ChartFeed4.SeriesCount - 1 do
2930
      CloneChartSeries(ChartFeed4[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2931
    FormChartHReport.QuickRepChart.PrinterSetup;
2932
    if FormChartHReport.QuickRepChart.Tag = 0
2933
    then
2934
      FormChartHReport.QuickRepChart.Print;
2935
  finally
2936
    FormChartHReport.Release;
2937
  end;
2938
end;
2939
2940
procedure TFormFeedsCharts.WMSysCommand(var Message: TWMSysCommand);
2941
begin
2942
  if Message.CmdType = SC_MINIMIZE
2943
  then
2944
    Application.Minimize
2945
  else
2946
    inherited;
2947
end;
2948
2949
end.