Statistiques
| Révision:

root / UnitFeedCharts.pas @ 4

Historique | Voir | Annoter | Télécharger (113,815 ko)

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