Statistiques
| Révision:

root / UnitFeedsCharts.pas @ 1

Historique | Voir | Annoter | Télécharger (125,771 ko)

1
unit UnitFeedsCharts;
2

    
3
interface
4

    
5
uses
6
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
  gnugettext, StdCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, Series, Buttons,
8
  Math, ComCtrls, ImgList, ActnList, JvExStdCtrls, JvButton, JvCtrls;
9

    
10
type
11
  TFormFeedsCharts = class(TForm)
12
    GroupBoxFeed1: TGroupBox;
13
    PanelFeed1: TPanel;
14
    ChartFeed1: TChart;
15
    GroupBoxChartSelection: TGroupBox;
16
    GroupBoxFeed2: TGroupBox;
17
    PanelFeed2: TPanel;
18
    ChartFeed2: TChart;
19
    GroupBoxFeed3: TGroupBox;
20
    PanelFeed3: TPanel;
21
    ChartFeed3: TChart;
22
    GroupBoxFeed4: TGroupBox;
23
    PanelFeed4: TPanel;
24
    ChartFeed4: TChart;
25
    SpeedButton2D3D1: TSpeedButton;
26
    SpeedButton2D3D2: TSpeedButton;
27
    SpeedButton2D3D3: TSpeedButton;
28
    SpeedButton2D3D4: TSpeedButton;
29
    SpeedButtonPrint1: TSpeedButton;
30
    SpeedButtonPrint2: TSpeedButton;
31
    SpeedButtonPrint3: TSpeedButton;
32
    SpeedButtonPrint4: TSpeedButton;
33
    PanelButtons: TPanel;
34
    PageControlFeedsChats: TPageControl;
35
    TabSheetSingleChart: TTabSheet;
36
    TabSheetChartsComparison: TTabSheet;
37
    GroupBoxChart0: TGroupBox;
38
    Chart0: TChart;
39
    SpeedButton2D3D0: TSpeedButton;
40
    SpeedButtonPrint0: TSpeedButton;
41
    LabelDiet1: TLabel;
42
    LabelDiet2: TLabel;
43
    LabelDiet3: TLabel;
44
    LabelDiet4: TLabel;
45
    LabelDiet5: TLabel;
46
    LabelDiet6: TLabel;
47
    ComboBoxRatios0: TComboBox;
48
    ComboBoxAA0: TComboBox;
49
    ComboBoxEnergy0: TComboBox;
50
    ComboBoxMinerals0: TComboBox;
51
    ComboBoxProximal0: TComboBox;
52
    ComboBoxType0: TComboBox;
53
    ComboBoxDiet1: TComboBox;
54
    ComboBoxDiet2: TComboBox;
55
    ComboBoxDiet3: TComboBox;
56
    ComboBoxDiet4: TComboBox;
57
    ComboBoxDiet5: TComboBox;
58
    ComboBoxDiet6: TComboBox;
59
    ComboBoxAA: TComboBox;
60
    ComboBoxEnergy: TComboBox;
61
    ComboBoxMinerals: TComboBox;
62
    ComboBoxProximal: TComboBox;
63
    ComboBoxType: TComboBox;
64
    ComboBoxFeed1: TComboBox;
65
    ComboBoxFeed2: TComboBox;
66
    ComboBoxFeed3: TComboBox;
67
    ComboBoxFeed4: TComboBox;
68
    JvImgBtnClose: TJvImgBtn;
69
    JvImgBtnHelp: TJvImgBtn;
70
    ActionListButtons: TActionList;
71
    ActionHelp: TAction;
72
    ActionClose: TAction;
73
    ImageListIcons: TImageList;
74
    SeriesBar: TBarSeries;
75
    procedure FormCreate(Sender: TObject);
76
    procedure ComboBoxTypeChange(Sender: TObject);
77
    procedure ComboBoxOptionChange(Sender: TObject);
78
    procedure ComboBoxFeed1Change(Sender: TObject);
79
    procedure ComboBoxFeed2Change(Sender: TObject);
80
    procedure ComboBoxFeed3Change(Sender: TObject);
81
    procedure ComboBoxFeed4Change(Sender: TObject);
82
    procedure FormResize(Sender: TObject);
83
    procedure SpeedButton2D3D1Click(Sender: TObject);
84
    procedure SpeedButton2D3D2Click(Sender: TObject);
85
    procedure SpeedButton2D3D3Click(Sender: TObject);
86
    procedure SpeedButton2D3D4Click(Sender: TObject);
87
    procedure SpeedButtonPrint1Click(Sender: TObject);
88
    procedure SpeedButtonPrint2Click(Sender: TObject);
89
    procedure SpeedButtonPrint3Click(Sender: TObject);
90
    procedure SpeedButtonPrint4Click(Sender: TObject);
91
    procedure ComboBoxType0Change(Sender: TObject);
92
    procedure ComboBoxOption0Change(Sender: TObject);
93
    procedure ComboBoxDietChange(Sender: TObject);
94
    procedure SpeedButton2D3D0Click(Sender: TObject);
95
    procedure SpeedButtonPrint0Click(Sender: TObject);
96
    procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
97
    procedure ActionHelpExecute(Sender: TObject);
98
    procedure ActionCloseExecute(Sender: TObject);
99
  private
100
    { D?clarations priv?es }
101
  public
102
    { D?clarations publiques }
103
  end;
104

    
105
var
106
  FormFeedsCharts: TFormFeedsCharts;
107

    
108
implementation
109

    
110
uses
111
  UnitDeclaration, UnitOptions, UnitChartHReport;
112

    
113
{$R *.dfm}
114

    
115
procedure TFormFeedsCharts.ActionCloseExecute(Sender: TObject);
116
begin
117
  ModalResult := mrClose;
118
end;
119

    
120
procedure TFormFeedsCharts.ActionHelpExecute(Sender: TObject);
121
begin
122
  Application.HelpContext(HelpContext);
123
end;
124

    
125
procedure TFormFeedsCharts.ComboBoxDietChange(Sender: TObject);
126
var
127
//  FeedBar: TBarSeries;
128
  s: string;
129

    
130
  procedure AddBarValue;
131
  begin
132
    with DataModuleDeclaration do
133
      case ComboBoxType0.ItemIndex of
134
        0: // Analyse proximale
135
          case ComboBoxProximal0.ItemIndex of
136
            0: // MS
137
              if not ClientDataSetFeedsMS.IsNull
138
              then SeriesBar.AddBar(ClientDataSetFeedsMS.Value, s, clTeeColor)
139
              else SeriesBar.AddNull(s);
140
            1: // MM
141
              if not ClientDataSetFeedsMM.IsNull
142
              then SeriesBar.AddBar(ClientDataSetFeedsMM.Value, s, clTeeColor)
143
              else SeriesBar.AddNull(s);
144
            2: // MAT
145
              if not ClientDataSetFeedsMAT.IsNull
146
              then SeriesBar.AddBar(ClientDataSetFeedsMAT.Value, s, clTeeColor)
147
              else SeriesBar.AddNull(s);
148
            3: // MG
149
              if not ClientDataSetFeedsMG.IsNull
150
              then SeriesBar.AddBar(ClientDataSetFeedsMG.Value, s, clTeeColor)
151
              else SeriesBar.AddNull(s);
152
            4: // CB
153
              if not ClientDataSetFeedsCB.IsNull
154
              then SeriesBar.AddBar(ClientDataSetFeedsCB.Value, s, clTeeColor)
155
              else SeriesBar.AddNull(s);
156
            5: // NDF
157
              if not ClientDataSetFeedsNDF.IsNull
158
              then SeriesBar.AddBar(ClientDataSetFeedsNDF.Value, s, clTeeColor)
159
              else SeriesBar.AddNull(s);
160
            6: // ADF
161
              if not ClientDataSetFeedsADF.IsNull
162
              then SeriesBar.AddBar(ClientDataSetFeedsADF.Value, s, clTeeColor)
163
              else SeriesBar.AddNull(s);
164
            7: // ADL
165
              if not ClientDataSetFeedsADL.IsNull
166
              then SeriesBar.AddBar(ClientDataSetFeedsADL.Value, s, clTeeColor)
167
              else SeriesBar.AddNull(s);
168
            8: // Amidon
169
              if not ClientDataSetFeedsAmidon.IsNull
170
              then SeriesBar.AddBar(ClientDataSetFeedsAmidon.Value, s, clTeeColor)
171
              else SeriesBar.AddNull(s);
172
            9: // Sucres
173
              if not ClientDataSetFeedsSucres.IsNull
174
              then SeriesBar.AddBar(ClientDataSetFeedsSucres.Value, s, clTeeColor)
175
              else SeriesBar.AddNull(s);
176
          end;
177
        1: // Valeurs ?nerg?tiques
178
          case ComboBoxEnergy0.ItemIndex of
179
            0: // Energie brute
180
              if not ClientDataSetFeedsEB.IsNull
181
              then SeriesBar.AddBar(ClientDataSetFeedsEB.Value, s, clTeeColor)
182
              else SeriesBar.AddNull(s);
183
            1: // Energie digestible (porc croissance)
184
              if not ClientDataSetFeedsEDc.IsNull
185
              then SeriesBar.AddBar(ClientDataSetFeedsEDc.Value, s, clTeeColor)
186
              else SeriesBar.AddNull(s);
187
            2: // Energie digestible (porc adulte)
188
              if not ClientDataSetFeedsEDt.IsNull
189
              then SeriesBar.AddBar(ClientDataSetFeedsEDt.Value, s, clTeeColor)
190
              else SeriesBar.AddNull(s);
191
            3: // Energie m?tabolisable (porc croissance)
192
              if not ClientDataSetFeedsEMc.IsNull
193
              then SeriesBar.AddBar(ClientDataSetFeedsEMc.Value, s, clTeeColor)
194
              else SeriesBar.AddNull(s);
195
            4: // Energie m?tabolisable (porc adulte)
196
              if not ClientDataSetFeedsEMt.IsNull
197
              then SeriesBar.AddBar(ClientDataSetFeedsEMt.Value, s, clTeeColor)
198
              else SeriesBar.AddNull(s);
199
            5: // Energie nette (porc croissance)
200
              if not ClientDataSetFeedsENc.IsNull
201
              then SeriesBar.AddBar(ClientDataSetFeedsENc.Value, s, clTeeColor)
202
              else SeriesBar.AddNull(s);
203
            6: // Energie nette (porc adulte)
204
              if not ClientDataSetFeedsENt.IsNull
205
              then SeriesBar.AddBar(ClientDataSetFeedsENt.Value, s, clTeeColor)
206
              else SeriesBar.AddNull(s);
207
          end;
208
        2: // Rapports ?nerg?tiques
209
          case ComboBoxRatios0.ItemIndex of
210
            0: // Phosphore digestible / Energie nette (porc croissance)
211
              if not ClientDataSetFeedsPd_ENc.IsNull
212
              then SeriesBar.AddBar(ClientDataSetFeedsPd_ENc.Value, s, clTeeColor)
213
              else SeriesBar.AddNull(s);
214
            1: // Phosphore digestible / Energie nette (porc adulte)
215
              if not ClientDataSetFeedsPd_ENt.IsNull
216
              then SeriesBar.AddBar(ClientDataSetFeedsPd_ENt.Value, s, clTeeColor)
217
              else SeriesBar.AddNull(s);
218
            2: // Lysine digestible / Energie nette (porc croissance)
219
              if not ClientDataSetFeedsLysd_ENc.IsNull
220
              then SeriesBar.AddBar(ClientDataSetFeedsLysd_ENc.Value, s, clTeeColor)
221
              else SeriesBar.AddNull(s);
222
            3: // Lysine digestible / Energie nette (porc adulte)
223
              if not ClientDataSetFeedsLysd_ENt.IsNull
224
              then SeriesBar.AddBar(ClientDataSetFeedsLysd_ENt.Value, s, clTeeColor)
225
              else SeriesBar.AddNull(s);
226
          end;
227
        3: // Acides amin?s totaux
228
          case ComboBoxAA0.ItemIndex of
229
            0: // Lysine
230
              if not ClientDataSetFeedsLys.IsNull
231
              then SeriesBar.AddBar(ClientDataSetFeedsLys.Value, s, clTeeColor)
232
              else SeriesBar.AddNull(s);
233
            1: // Thr?onine
234
              if not ClientDataSetFeedsThr.IsNull
235
              then SeriesBar.AddBar(ClientDataSetFeedsThr.Value, s, clTeeColor)
236
              else SeriesBar.AddNull(s);
237
            2: // M?thionine
238
              if not ClientDataSetFeedsMet.IsNull
239
              then SeriesBar.AddBar(ClientDataSetFeedsMet.Value, s, clTeeColor)
240
              else SeriesBar.AddNull(s);
241
            3: // Cyst?ine
242
              if not ClientDataSetFeedsCys.IsNull
243
              then SeriesBar.AddBar(ClientDataSetFeedsCys.Value, s, clTeeColor)
244
              else SeriesBar.AddNull(s);
245
            4: // M?thionine + Cyst?ine
246
              if not ClientDataSetFeedsMetCys.IsNull
247
              then SeriesBar.AddBar(ClientDataSetFeedsMetCys.Value, s, clTeeColor)
248
              else SeriesBar.AddNull(s);
249
            5: // Tryptophane
250
              if not ClientDataSetFeedsTrp.IsNull
251
              then SeriesBar.AddBar(ClientDataSetFeedsTrp.Value, s, clTeeColor)
252
              else SeriesBar.AddNull(s);
253
            6: // Isoleucine
254
              if not ClientDataSetFeedsIle.IsNull
255
              then SeriesBar.AddBar(ClientDataSetFeedsIle.Value, s, clTeeColor)
256
              else SeriesBar.AddNull(s);
257
            7: // Valine
258
              if not ClientDataSetFeedsVal.IsNull
259
              then SeriesBar.AddBar(ClientDataSetFeedsVal.Value, s, clTeeColor)
260
              else SeriesBar.AddNull(s);
261
            8: // Leucine
262
              if not ClientDataSetFeedsLeu.IsNull
263
              then SeriesBar.AddBar(ClientDataSetFeedsLeu.Value, s, clTeeColor)
264
              else SeriesBar.AddNull(s);
265
            9: // Ph?nylalanine
266
              if not ClientDataSetFeedsPhe.IsNull
267
              then SeriesBar.AddBar(ClientDataSetFeedsPhe.Value, s, clTeeColor)
268
              else SeriesBar.AddNull(s);
269
            10: // Tyrosine
270
              if not ClientDataSetFeedsTyr.IsNull
271
              then SeriesBar.AddBar(ClientDataSetFeedsTyr.Value, s, clTeeColor)
272
              else SeriesBar.AddNull(s);
273
            11: // Ph?nylalanine + Tyrosine
274
              if not ClientDataSetFeedsPheTyr.IsNull
275
              then SeriesBar.AddBar(ClientDataSetFeedsPheTyr.Value, s, clTeeColor)
276
              else SeriesBar.AddNull(s);
277
            12: // Histidine
278
              if not ClientDataSetFeedsHis.IsNull
279
              then SeriesBar.AddBar(ClientDataSetFeedsHis.Value, s, clTeeColor)
280
              else SeriesBar.AddNull(s);
281
            13: // Arginine
282
              if not ClientDataSetFeedsArg.IsNull
283
              then SeriesBar.AddBar(ClientDataSetFeedsArg.Value, s, clTeeColor)
284
              else SeriesBar.AddNull(s);
285
            14: // Alanine
286
              if not ClientDataSetFeedsAla.IsNull
287
              then SeriesBar.AddBar(ClientDataSetFeedsAla.Value, s, clTeeColor)
288
              else SeriesBar.AddNull(s);
289
            15: // Aspartate
290
              if not ClientDataSetFeedsAsp.IsNull
291
              then SeriesBar.AddBar(ClientDataSetFeedsAsp.Value, s, clTeeColor)
292
              else SeriesBar.AddNull(s);
293
            16: // Glutamate
294
              if not ClientDataSetFeedsGlu.IsNull
295
              then SeriesBar.AddBar(ClientDataSetFeedsGlu.Value, s, clTeeColor)
296
              else SeriesBar.AddNull(s);
297
            17: // Glycine
298
              if not ClientDataSetFeedsGly.IsNull
299
              then SeriesBar.AddBar(ClientDataSetFeedsGly.Value, s, clTeeColor)
300
              else SeriesBar.AddNull(s);
301
            18: // S?rine
302
              if not ClientDataSetFeedsSer.IsNull
303
              then SeriesBar.AddBar(ClientDataSetFeedsSer.Value, s, clTeeColor)
304
              else SeriesBar.AddNull(s);
305
            19: // Proline
306
              if not ClientDataSetFeedsPro.IsNull
307
              then SeriesBar.AddBar(ClientDataSetFeedsPro.Value, s, clTeeColor)
308
              else SeriesBar.AddNull(s);
309
          end;
310
        4: // Acides amin?s digestibles
311
          case ComboBoxAA0.ItemIndex of
312
            0: // Lysine
313
              if not ClientDataSetFeedsLysd.IsNull
314
              then SeriesBar.AddBar(ClientDataSetFeedsLysd.Value, s, clTeeColor)
315
              else SeriesBar.AddNull(s);
316
            1: // Thr?onine
317
              if not ClientDataSetFeedsThrd.IsNull
318
              then SeriesBar.AddBar(ClientDataSetFeedsThrd.Value, s, clTeeColor)
319
              else SeriesBar.AddNull(s);
320
            2: // M?thionine
321
              if not ClientDataSetFeedsMetd.IsNull
322
              then SeriesBar.AddBar(ClientDataSetFeedsMetd.Value, s, clTeeColor)
323
              else SeriesBar.AddNull(s);
324
            3: // Cyst?ine
325
              if not ClientDataSetFeedsCysd.IsNull
326
              then SeriesBar.AddBar(ClientDataSetFeedsCysd.Value, s, clTeeColor)
327
              else SeriesBar.AddNull(s);
328
            4: // M?thionine + Cyst?ine
329
              if not ClientDataSetFeedsMetCysd.IsNull
330
              then SeriesBar.AddBar(ClientDataSetFeedsMetCysd.Value, s, clTeeColor)
331
              else SeriesBar.AddNull(s);
332
            5: // Tryptophane
333
              if not ClientDataSetFeedsTrpd.IsNull
334
              then SeriesBar.AddBar(ClientDataSetFeedsTrpd.Value, s, clTeeColor)
335
              else SeriesBar.AddNull(s);
336
            6: // Isoleucine
337
              if not ClientDataSetFeedsIled.IsNull
338
              then SeriesBar.AddBar(ClientDataSetFeedsIled.Value, s, clTeeColor)
339
              else SeriesBar.AddNull(s);
340
            7: // Valine
341
              if not ClientDataSetFeedsVald.IsNull
342
              then SeriesBar.AddBar(ClientDataSetFeedsVald.Value, s, clTeeColor)
343
              else SeriesBar.AddNull(s);
344
            8: // Leucine
345
              if not ClientDataSetFeedsLeud.IsNull
346
              then SeriesBar.AddBar(ClientDataSetFeedsLeud.Value, s, clTeeColor)
347
              else SeriesBar.AddNull(s);
348
            9: // Ph?nylalanine
349
              if not ClientDataSetFeedsPhed.IsNull
350
              then SeriesBar.AddBar(ClientDataSetFeedsPhed.Value, s, clTeeColor)
351
              else SeriesBar.AddNull(s);
352
            10: // Tyrosine
353
              if not ClientDataSetFeedsTyrd.IsNull
354
              then SeriesBar.AddBar(ClientDataSetFeedsTyrd.Value, s, clTeeColor)
355
              else SeriesBar.AddNull(s);
356
            11: // Ph?nylalanine + Tyrosine
357
              if not ClientDataSetFeedsPheTyrd.IsNull
358
              then SeriesBar.AddBar(ClientDataSetFeedsPheTyrd.Value, s, clTeeColor)
359
              else SeriesBar.AddNull(s);
360
            12: // Histidine
361
              if not ClientDataSetFeedsHisd.IsNull
362
              then SeriesBar.AddBar(ClientDataSetFeedsHisd.Value, s, clTeeColor)
363
              else SeriesBar.AddNull(s);
364
            13: // Arginine
365
              if not ClientDataSetFeedsArgd.IsNull
366
              then SeriesBar.AddBar(ClientDataSetFeedsArgd.Value, s, clTeeColor)
367
              else SeriesBar.AddNull(s);
368
            14: // Alanine
369
              if not ClientDataSetFeedsAlad.IsNull
370
              then SeriesBar.AddBar(ClientDataSetFeedsAlad.Value, s, clTeeColor)
371
              else SeriesBar.AddNull(s);
372
            15: // Aspartate
373
              if not ClientDataSetFeedsAspd.IsNull
374
              then SeriesBar.AddBar(ClientDataSetFeedsAspd.Value, s, clTeeColor)
375
              else SeriesBar.AddNull(s);
376
            16: // Glutamate
377
              if not ClientDataSetFeedsGlud.IsNull
378
              then SeriesBar.AddBar(ClientDataSetFeedsGlud.Value, s, clTeeColor)
379
              else SeriesBar.AddNull(s);
380
            17: // Glycine
381
              if not ClientDataSetFeedsGlyd.IsNull
382
              then SeriesBar.AddBar(ClientDataSetFeedsGlyd.Value, s, clTeeColor)
383
              else SeriesBar.AddNull(s);
384
            18: // S?rine
385
              if not ClientDataSetFeedsSerd.IsNull
386
              then SeriesBar.AddBar(ClientDataSetFeedsSerd.Value, s, clTeeColor)
387
              else SeriesBar.AddNull(s);
388
            19: // Proline
389
              if not ClientDataSetFeedsProd.IsNull
390
              then SeriesBar.AddBar(ClientDataSetFeedsProd.Value, s, clTeeColor)
391
              else SeriesBar.AddNull(s);
392
          end;
393
        5: // Profils acides amin?s
394
          case ComboBoxAA0.ItemIndex of
395
            0: // Lysine
396
              if not ClientDataSetFeedsLysd.IsNull and (ClientDataSetFeedsLysd.Value <> 0)
397
              then SeriesBar.AddBar(100, s, clTeeColor)
398
              else SeriesBar.AddNull(s);
399
            1: // Thr?onine
400
              if not ClientDataSetFeedsThrd_Lysd.IsNull
401
              then SeriesBar.AddBar(ClientDataSetFeedsThrd_Lysd.Value, s, clTeeColor)
402
              else SeriesBar.AddNull(s);
403
            2: // M?thionine
404
              if not ClientDataSetFeedsMetd_Lysd.IsNull
405
              then SeriesBar.AddBar(ClientDataSetFeedsMetd_Lysd.Value, s, clTeeColor)
406
              else SeriesBar.AddNull(s);
407
            3: // Cyst?ine
408
              if not ClientDataSetFeedsCysd_Lysd.IsNull
409
              then SeriesBar.AddBar(ClientDataSetFeedsCysd_Lysd.Value, s, clTeeColor)
410
              else SeriesBar.AddNull(s);
411
            4: // M?thionine + Cyst?ine
412
              if not ClientDataSetFeedsMetCysd_Lysd.IsNull
413
              then SeriesBar.AddBar(ClientDataSetFeedsMetCysd_Lysd.Value, s, clTeeColor)
414
              else SeriesBar.AddNull(s);
415
            5: // Tryptophane
416
              if not ClientDataSetFeedsTrpd_Lysd.IsNull
417
              then SeriesBar.AddBar(ClientDataSetFeedsTrpd_Lysd.Value, s, clTeeColor)
418
              else SeriesBar.AddNull(s);
419
            6: // Isoleucine
420
              if not ClientDataSetFeedsIled_Lysd.IsNull
421
              then SeriesBar.AddBar(ClientDataSetFeedsIled_Lysd.Value, s, clTeeColor)
422
              else SeriesBar.AddNull(s);
423
            7: // Valine
424
              if not ClientDataSetFeedsVald_Lysd.IsNull
425
              then SeriesBar.AddBar(ClientDataSetFeedsVald_Lysd.Value, s, clTeeColor)
426
              else SeriesBar.AddNull(s);
427
            8: // Leucine
428
              if not ClientDataSetFeedsLeud_Lysd.IsNull
429
              then SeriesBar.AddBar(ClientDataSetFeedsLeud_Lysd.Value, s, clTeeColor)
430
              else SeriesBar.AddNull(s);
431
            9: // Ph?nylalanine
432
              if not ClientDataSetFeedsPhed_Lysd.IsNull
433
              then SeriesBar.AddBar(ClientDataSetFeedsPhed_Lysd.Value, s, clTeeColor)
434
              else SeriesBar.AddNull(s);
435
            10: // Tyrosine
436
              if not ClientDataSetFeedsTyrd_Lysd.IsNull
437
              then SeriesBar.AddBar(ClientDataSetFeedsTyrd_Lysd.Value, s, clTeeColor)
438
              else SeriesBar.AddNull(s);
439
            11: // Ph?nylalanine + Tyrosine
440
              if not ClientDataSetFeedsPheTyrd_Lysd.IsNull
441
              then SeriesBar.AddBar(ClientDataSetFeedsPheTyrd_Lysd.Value, s, clTeeColor)
442
              else SeriesBar.AddNull(s);
443
            12: // Histidine
444
              if not ClientDataSetFeedsHisd_Lysd.IsNull
445
              then SeriesBar.AddBar(ClientDataSetFeedsHisd_Lysd.Value, s, clTeeColor)
446
              else SeriesBar.AddNull(s);
447
            13: // Arginine
448
              if not ClientDataSetFeedsArgd_Lysd.IsNull
449
              then SeriesBar.AddBar(ClientDataSetFeedsArgd_Lysd.Value, s, clTeeColor)
450
              else SeriesBar.AddNull(s);
451
            14: // Alanine
452
              if not ClientDataSetFeedsAlad_Lysd.IsNull
453
              then SeriesBar.AddBar(ClientDataSetFeedsAlad_Lysd.Value, s, clTeeColor)
454
              else SeriesBar.AddNull(s);
455
            15: // Aspartate
456
              if not ClientDataSetFeedsAspd_Lysd.IsNull
457
              then SeriesBar.AddBar(ClientDataSetFeedsAspd_Lysd.Value, s, clTeeColor)
458
              else SeriesBar.AddNull(s);
459
            16: // Glutamate
460
              if not ClientDataSetFeedsGlud_Lysd.IsNull
461
              then SeriesBar.AddBar(ClientDataSetFeedsGlud_Lysd.Value, s, clTeeColor)
462
              else SeriesBar.AddNull(s);
463
            17: // Glycine
464
              if not ClientDataSetFeedsGlyd_Lysd.IsNull
465
              then SeriesBar.AddBar(ClientDataSetFeedsGlyd_Lysd.Value, s, clTeeColor)
466
              else SeriesBar.AddNull(s);
467
            18: // S?rine
468
              if not ClientDataSetFeedsSerd_Lysd.IsNull
469
              then SeriesBar.AddBar(ClientDataSetFeedsSerd_Lysd.Value, s, clTeeColor)
470
              else SeriesBar.AddNull(s);
471
            19: // Proline
472
              if not ClientDataSetFeedsProd_Lysd.IsNull
473
              then SeriesBar.AddBar(ClientDataSetFeedsProd_Lysd.Value, s, clTeeColor)
474
              else SeriesBar.AddNull(s);
475
          end;
476
        6: // Min?raux
477
          case ComboBoxMinerals0.ItemIndex of
478
            0: // Calcium
479
              if not ClientDataSetFeedsCa.IsNull
480
              then SeriesBar.AddBar(ClientDataSetFeedsCa.Value, s, clTeeColor)
481
              else SeriesBar.AddNull(s);
482
            1: // Phosphore
483
              if not ClientDataSetFeedsP.IsNull
484
              then SeriesBar.AddBar(ClientDataSetFeedsP.Value, s, clTeeColor)
485
              else SeriesBar.AddNull(s);
486
            2: // Phosphore digestible
487
              if not ClientDataSetFeedsPd.IsNull
488
              then SeriesBar.AddBar(ClientDataSetFeedsPd.Value, s, clTeeColor)
489
              else SeriesBar.AddNull(s);
490
          end;
491
      end;
492
  end;
493

    
494
begin
495
  Chart0.Title.Clear;
496
  Chart0.Title.Text.Add(ComboBoxType0.Text);
497
  case ComboBoxType0.ItemIndex of
498
    0: // Analyse proximale
499
      Chart0.Title.Text.Add(ComboBoxProximal0.Text);
500
    1: // Valeurs ?nerg?tiques
501
      Chart0.Title.Text.Add(ComboBoxEnergy0.Text);
502
    2: // Rapports ?nerg?tiques
503
      Chart0.Title.Text.Add(ComboBoxRatios0.Text);
504
    3, 4, 5: // Acides amin?s
505
      Chart0.Title.Text.Add(ComboBoxAA0.Text);
506
    6: // Min?raux
507
      Chart0.Title.Text.Add(ComboBoxMinerals0.Text);
508
  end;
509
  Chart0.SubTitle.Clear;
510
  case ComboBoxType0.ItemIndex of
511
    0: // Analyse proximale
512
      with FormOptions do
513
        if Expression = 0
514
        then // sur frais
515
          Chart0.SubTitle.Text.Add(ComboBoxProximal.Items[Proximal])
516
        else // sur mati?re s?che
517
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxProximal.Items[Proximal], _('DM')]));
518
    1: // Valeurs ?nerg?tiques
519
      with FormOptions do
520
        if Expression = 0
521
        then // sur frais
522
          Chart0.SubTitle.Text.Add(ComboBoxEnergy.Items[Energy])
523
        else // sur mati?re s?che
524
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxEnergy.Items[Energy], _('DM')]));
525
    2: // Rapports ?nerg?tiques
526
      with FormOptions do
527
        if Energy = 0
528
        then // MJ
529
          Chart0.SubTitle.Text.Add(_('g/MJ'))
530
        else // kcal
531
          Chart0.SubTitle.Text.Add(_('g/1000kcal'));
532
    3, 4: // Acides amin?s totaux et digestibles
533
      with FormOptions do
534
        if Expression = 0
535
        then // sur frais
536
          Chart0.SubTitle.Text.Add(ComboBoxAA.Items[AA])
537
        else // sur mati?re s?che
538
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxAA.Items[AA], _('DM')]));
539
    5: // Profils acides amin?s
540
      Chart0.SubTitle.Text.Add('%');
541
    6: // Min?raux
542
      with FormOptions do
543
        if Expression = 0
544
        then // sur frais
545
          Chart0.SubTitle.Text.Add(ComboBoxMinerals.Items[Minerals])
546
        else // sur mati?re s?che
547
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxMinerals.Items[Minerals], _('DM')]));
548
  end;
549
  case ComboBoxType0.ItemIndex of
550
    0: // Analyse proximale
551
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.ProximalFormat;
552
    1: // Valeurs ?nerg?tiques
553
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.EnergyFormat;
554
    2: // Rapports ?nerg?tiques
555
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.DecimalFormat(2);
556
    3, 4: // Acides amin?s totaux et digestibles
557
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.AAFormat;
558
    5: // Profils acides amin?s
559
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.DecimalFormat(0);
560
    6: // Min?raux
561
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.MineralsFormat;
562
  end;
563
  SeriesBar.Clear;
564
  SeriesBar.ValueFormat := Chart0.LeftAxis.AxisValuesFormat;
565
  if ComboBoxDiet1.ItemIndex <> -1
566
  then
567
    with DataModuleDeclaration do
568
    begin
569
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet1.Text, []);
570
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet1.Text) + 1;
571
      s := StrTrunc(ComboBoxDiet1.Text, 30);
572
      AddBarValue;
573
    end;
574
  if ComboBoxDiet2.ItemIndex <> -1
575
  then
576
    with DataModuleDeclaration do
577
    begin
578
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet2.Text, []);
579
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet2.Text) + 1;
580
      s := StrTrunc(ComboBoxDiet2.Text, 30);
581
      AddBarValue;
582
    end;
583
  if ComboBoxDiet3.ItemIndex <> -1
584
  then
585
    with DataModuleDeclaration do
586
    begin
587
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet3.Text, []);
588
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet3.Text) + 1;
589
      s := StrTrunc(ComboBoxDiet3.Text, 30);
590
      AddBarValue;
591
    end;
592
  if ComboBoxDiet4.ItemIndex <> -1
593
  then
594
    with DataModuleDeclaration do
595
    begin
596
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet4.Text, []);
597
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet4.Text) + 1;
598
      s := StrTrunc(ComboBoxDiet4.Text, 30);
599
      AddBarValue;
600
    end;
601
  if ComboBoxDiet5.ItemIndex <> -1
602
  then
603
    with DataModuleDeclaration do
604
    begin
605
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet5.Text, []);
606
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet5.Text) + 1;
607
      s := StrTrunc(ComboBoxDiet5.Text, 30);
608
      AddBarValue;
609
    end;
610
  if ComboBoxDiet6.ItemIndex <> -1
611
  then
612
    with DataModuleDeclaration do
613
    begin
614
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet6.Text, []);
615
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet6.Text) + 1;
616
      s := StrTrunc(ComboBoxDiet6.Text, 30);
617
      AddBarValue;
618
    end;
619
end;
620

    
621
procedure TFormFeedsCharts.ComboBoxFeed1Change(Sender: TObject);
622
var
623
  IngredientName: String;
624
  Cumul, Ratio, Total, Value: Double;
625
  FeedBar: TBarSeries;
626
begin
627
//  while ChartFeed1.SeriesCount > 0 do
628
//    ChartFeed1.Series[0].Free;
629
  ChartFeed1.FreeAllSeries(nil);
630
  ChartFeed1.Title.Clear;
631
  ChartFeed1.SubTitle.Clear;
632
  if ComboBoxFeed1.ItemIndex <> -1
633
  then
634
    with DataModuleDeclaration do
635
    begin
636
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed1.Text, []);
637
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed1.Text) + 1;
638
      ChartFeed1.AxisVisible := True;
639
      ChartFeed1.Title.Text.Add(ClientDataSetFeedsName.Value);
640
      ChartFeed1.SubTitle.Text.Add(ComboBoxType.Text);
641
      case ComboBoxType.ItemIndex of
642
        0: // Analyse proximale
643
          ChartFeed1.SubTitle.Text.Add(ComboBoxProximal.Text);
644
        1: // Valeurs ?nerg?tiques
645
          ChartFeed1.SubTitle.Text.Add(ComboBoxEnergy.Text);
646
        2, 3: // Acides amin?s
647
          ChartFeed1.SubTitle.Text.Add(ComboBoxAA.Text);
648
        4: // Min?raux
649
          ChartFeed1.SubTitle.Text.Add(ComboBoxMinerals.Text);
650
      end;
651
      case ComboBoxType.ItemIndex of
652
        0: // Analyse proximale
653
          case ComboBoxProximal.ItemIndex of
654
            0: // Composition
655
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
656
            1: // MS
657
              Cumul := ClientDataSetFeedsMS.Value;
658
            2: // MM
659
              Cumul := ClientDataSetFeedsMM.Value;
660
            3: // MAT
661
              Cumul := ClientDataSetFeedsMAT.Value;
662
            4: // MG
663
              Cumul := ClientDataSetFeedsMG.Value;
664
            5: // CB
665
              Cumul := ClientDataSetFeedsCB.Value;
666
            6: // NDF
667
              Cumul := ClientDataSetFeedsNDF.Value;
668
            7: // ADF
669
              Cumul := ClientDataSetFeedsADF.Value;
670
            8: // ADL
671
              Cumul := ClientDataSetFeedsADL.Value;
672
            9: // Amidon
673
              Cumul := ClientDataSetFeedsAmidon.Value;
674
            10: // Sucres
675
              Cumul := ClientDataSetFeedsSucres.Value;
676
            else
677
              Cumul := 0;
678
          end;
679
        1: // Valeurs ?nerg?tiques
680
          case ComboBoxEnergy.ItemIndex of
681
            0: // Energie brute
682
              Cumul := ClientDataSetFeedsEB.Value;
683
            1: // Energie digestible (porc croissance)
684
              Cumul := ClientDataSetFeedsEDc.Value;
685
            2: // Energie digestible (porc adulte)
686
              Cumul := ClientDataSetFeedsEDt.Value;
687
            3: // Energie m?tabolisable (porc croissance)
688
              Cumul := ClientDataSetFeedsEMc.Value;
689
            4: // Energie m?tabolisable (porc adulte)
690
              Cumul := ClientDataSetFeedsEMt.Value;
691
            5: // Energie nette (porc croissance)
692
              Cumul := ClientDataSetFeedsENc.Value;
693
            6: // Energie nette (porc adulte)
694
              Cumul := ClientDataSetFeedsENt.Value;
695
            else
696
              Cumul := 0;
697
          end;
698
        2: // Acides amin?s totaux
699
          case ComboBoxAA.ItemIndex of
700
            0: // Lysine
701
              Cumul := ClientDataSetFeedsLys.Value;
702
            1: // Thr?onine
703
              Cumul := ClientDataSetFeedsThr.Value;
704
            2: // M?thionine
705
              Cumul := ClientDataSetFeedsMet.Value;
706
            3: // Cyst?ine
707
              Cumul := ClientDataSetFeedsCys.Value;
708
            4: // M?thionine + Cyst?ine
709
              Cumul := ClientDataSetFeedsMetCys.Value;
710
            5: // Tryptophane
711
              Cumul := ClientDataSetFeedsTrp.Value;
712
            6: // Isoleucine
713
              Cumul := ClientDataSetFeedsIle.Value;
714
            7: // Valine
715
              Cumul := ClientDataSetFeedsVal.Value;
716
            8: // Leucine
717
              Cumul := ClientDataSetFeedsLeu.Value;
718
            9: // Ph?nylalanine
719
              Cumul := ClientDataSetFeedsPhe.Value;
720
            10: // Tyrosine
721
              Cumul := ClientDataSetFeedsTyr.Value;
722
            11: // Ph?nylalanine + Tyrosine
723
              Cumul := ClientDataSetFeedsPheTyr.Value;
724
            12: // Histidine
725
              Cumul := ClientDataSetFeedsHis.Value;
726
            13: // Arginine
727
              Cumul := ClientDataSetFeedsArg.Value;
728
            14: // Alanine
729
              Cumul := ClientDataSetFeedsAla.Value;
730
            15: // Aspartate
731
              Cumul := ClientDataSetFeedsAsp.Value;
732
            16: // Glutamate
733
              Cumul := ClientDataSetFeedsGlu.Value;
734
            17: // Glycine
735
              Cumul := ClientDataSetFeedsGly.Value;
736
            18: // S?rine
737
              Cumul := ClientDataSetFeedsSer.Value;
738
            19: // Proline
739
              Cumul := ClientDataSetFeedsPro.Value;
740
            else
741
              Cumul := 0;
742
          end;
743
        3: // Acides amin?s digestibles
744
          case ComboBoxAA.ItemIndex of
745
            0: // Lysine
746
              Cumul := ClientDataSetFeedsLysd.Value;
747
            1: // Thr?onine
748
              Cumul := ClientDataSetFeedsThrd.Value;
749
            2: // M?thionine
750
              Cumul := ClientDataSetFeedsMetd.Value;
751
            3: // Cyst?ine
752
              Cumul := ClientDataSetFeedsCysd.Value;
753
            4: // M?thionine + Cyst?ine
754
              Cumul := ClientDataSetFeedsMetCysd.Value;
755
            5: // Tryptophane
756
              Cumul := ClientDataSetFeedsTrpd.Value;
757
            6: // Isoleucine
758
              Cumul := ClientDataSetFeedsIled.Value;
759
            7: // Valine
760
              Cumul := ClientDataSetFeedsVald.Value;
761
            8: // Leucine
762
              Cumul := ClientDataSetFeedsLeud.Value;
763
            9: // Ph?nylalanine
764
              Cumul := ClientDataSetFeedsPhed.Value;
765
            10: // Tyrosine
766
              Cumul := ClientDataSetFeedsTyrd.Value;
767
            11: // Ph?nylalanine + Tyrosine
768
              Cumul := ClientDataSetFeedsPheTyrd.Value;
769
            12: // Histidine
770
              Cumul := ClientDataSetFeedsHisd.Value;
771
            13: // Arginine
772
              Cumul := ClientDataSetFeedsArgd.Value;
773
            14: // Alanine
774
              Cumul := ClientDataSetFeedsAlad.Value;
775
            15: // Aspartate
776
              Cumul := ClientDataSetFeedsAspd.Value;
777
            16: // Glutamate
778
              Cumul := ClientDataSetFeedsGlud.Value;
779
            17: // Glycine
780
              Cumul := ClientDataSetFeedsGlyd.Value;
781
            18: // S?rine
782
              Cumul := ClientDataSetFeedsSerd.Value;
783
            19: // Proline
784
              Cumul := ClientDataSetFeedsProd.Value;
785
            else
786
              Cumul := 0;
787
          end;
788
        4: // Min?raux
789
          case ComboBoxMinerals.ItemIndex of
790
            0: // Calcium
791
              Cumul := ClientDataSetFeedsCa.Value;
792
            1: // Phosphore
793
              Cumul := ClientDataSetFeedsP.Value;
794
            2: // Phosphore digestible
795
              Cumul := ClientDataSetFeedsPd.Value;
796
            else
797
              Cumul := 0;
798
          end;
799
        else
800
          Cumul := 0;
801
      end;
802
      if Cumul = 0
803
      then // Division par z?ro
804
        Cumul := 1;
805
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
806
      ClientDataSetComposition.Filtered := True;
807
      ClientDataSetComposition.First;
808
      Total := 0;
809
      while not ClientDataSetComposition.Eof do
810
      begin
811
        if ClientDataSetCompositionUser.Value
812
        then
813
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
814
        else
815
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
816
        ClientDataSetIngredients.Filtered := True;
817
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
818
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
819
        if (FormOptions.Expression = 0)
820
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
821
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
822
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
823
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
824
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
825
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
826
          Ratio := Ratio * RapMS;
827
        case ComboBoxType.ItemIndex of
828
          0: // Analyse proximale
829
            case ComboBoxProximal.ItemIndex of
830
              0: // Composition
831
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
832
              1: // MS
833
                Value := ClientDataSetCompositionMS.Value * Ratio;
834
              2: // MM
835
                Value := ClientDataSetIngredientsMM.Value * Ratio;
836
              3: // MAT
837
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
838
              4: // MG
839
                Value := ClientDataSetIngredientsMG.Value * Ratio;
840
              5: // CB
841
                Value := ClientDataSetIngredientsCB.Value * Ratio;
842
              6: // NDF
843
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
844
              7: // ADF
845
                Value := ClientDataSetIngredientsADF.Value * Ratio;
846
              8: // ADL
847
                Value := ClientDataSetIngredientsADL.Value * Ratio;
848
              9: // Amidon
849
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
850
              10: // Sucres
851
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
852
              else
853
                Value := 0;
854
            end;
855
          1: // Valeurs ?nerg?tiques
856
            case ComboBoxEnergy.ItemIndex of
857
              0: // Energie brute
858
                Value := ClientDataSetIngredientsEB.Value * Ratio;
859
              1: // Energie digestible (porc croissance)
860
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
861
              2: // Energie digestible (porc adulte)
862
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
863
              3: // Energie m?tabolisable (porc croissance)
864
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
865
              4: // Energie m?tabolisable (porc adulte)
866
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
867
              5: // Energie nette (porc croissance)
868
                Value := ClientDataSetIngredientsENc.Value * Ratio;
869
              6: // Energie nette (porc adulte)
870
                Value := ClientDataSetIngredientsENt.Value * Ratio;
871
              else
872
                Value := 0;
873
            end;
874
          2: // Acides amin?s totaux
875
            case ComboBoxAA.ItemIndex of
876
              0: // Lysine
877
                Value := ClientDataSetIngredientsLys.Value * Ratio;
878
              1: // Thr?onine
879
                Value := ClientDataSetIngredientsThr.Value * Ratio;
880
              2: // M?thionine
881
                Value := ClientDataSetIngredientsMet.Value * Ratio;
882
              3: // Cyst?ine
883
                Value := ClientDataSetIngredientsCys.Value * Ratio;
884
              4: // M?thionine + Cyst?ine
885
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
886
              5: // Tryptophane
887
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
888
              6: // Isoleucine
889
                Value := ClientDataSetIngredientsIle.Value * Ratio;
890
              7: // Valine
891
                Value := ClientDataSetIngredientsVal.Value * Ratio;
892
              8: // Leucine
893
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
894
              9: // Ph?nylalanine
895
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
896
              10: // Tyrosine
897
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
898
              11: // Ph?nylalanine + Tyrosine
899
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
900
              12: // Histidine
901
                Value := ClientDataSetIngredientsHis.Value * Ratio;
902
              13: // Arginine
903
                Value := ClientDataSetIngredientsArg.Value * Ratio;
904
              14: // Alanine
905
                Value := ClientDataSetIngredientsAla.Value * Ratio;
906
              15: // Aspartate
907
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
908
              16: // Glutamate
909
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
910
              17: // Glycine
911
                Value := ClientDataSetIngredientsGly.Value * Ratio;
912
              18: // S?rine
913
                Value := ClientDataSetIngredientsSer.Value * Ratio;
914
              19: // Proline
915
                Value := ClientDataSetIngredientsPro.Value * Ratio;
916
              else
917
                Value := 0;
918
            end;
919
          3: // Acides amin?s digestibles
920
            case ComboBoxAA.ItemIndex of
921
              0: // Lysine
922
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
923
              1: // Thr?onine
924
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
925
              2: // M?thionine
926
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
927
              3: // Cyst?ine
928
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
929
              4: // M?thionine + Cyst?ine
930
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
931
              5: // Tryptophane
932
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
933
              6: // Isoleucine
934
                Value := ClientDataSetIngredientsIled.Value * Ratio;
935
              7: // Valine
936
                Value := ClientDataSetIngredientsVald.Value * Ratio;
937
              8: // Leucine
938
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
939
              9: // Ph?nylalanine
940
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
941
              10: // Tyrosine
942
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
943
              11: // Ph?nylalanine + Tyrosine
944
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
945
              12: // Histidine
946
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
947
              13: // Arginine
948
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
949
              14: // Alanine
950
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
951
              15: // Aspartate
952
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
953
              16: // Glutamate
954
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
955
              17: // Glycine
956
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
957
              18: // S?rine
958
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
959
              19: // Proline
960
                Value := ClientDataSetIngredientsProd.Value * Ratio;
961
              else
962
                Value := 0;
963
            end;
964
          4: // Min?raux
965
            case ComboBoxMinerals.ItemIndex of
966
              0: // Calcium
967
                Value := ClientDataSetIngredientsCa.Value * Ratio;
968
              1: // Phosphore
969
                Value := ClientDataSetIngredientsP.Value * Ratio;
970
              2: // Phosphore digestible
971
                if ClientDataSetFeedsPresentation.Value = 0
972
                then // Farine (dPphy)
973
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
974
                else // Granul?s (dP)
975
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
976
              else
977
                Value := 0;
978
            end;
979
          else
980
            Value := 0;
981
        end;
982
        if (FormOptions.Expression = 1)
983
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
984
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
985
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
986
        if Value > 0
987
        then // Prendre en compte la valeur
988
        begin
989
          FeedBar := TBarSeries.Create(ChartFeed1);
990
          FeedBar.ParentChart := ChartFeed1;
991
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
992
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
993
          FeedBar.MultiBar := mbStacked100;
994
          FeedBar.Marks.Visible := False;
995
          ChartFeed1.AddSeries(FeedBar);
996
          FeedBar.AddBar(Value, '', clTeeColor);
997
          Total := Total + Value;
998
        end;
999
        ClientDataSetComposition.Next;
1000
      end;
1001
      ClientDataSetIngredients.Filtered := False;
1002
      ClientDataSetIngredients.Filter := '';
1003
      // Cas particuliers
1004
      if (ComboBoxType.ItemIndex = 1)
1005
      and ((ComboBoxEnergy.ItemIndex = 1)
1006
        or (ComboBoxEnergy.ItemIndex = 3)
1007
        or (ComboBoxEnergy.ItemIndex = 5))
1008
      and (ClientDataSetFeedsBonusC.Value > 0)
1009
      then // Bonus ?nergie (porc croissance)
1010
      begin
1011
        case ComboBoxEnergy.ItemIndex of
1012
          1: Value := ClientDataSetFeedsEDc.Value - Total;
1013
          3: Value := ClientDataSetFeedsEMc.Value - Total;
1014
          5: Value := ClientDataSetFeedsENc.Value - Total;
1015
          else Value := 0;
1016
        end;
1017
        FeedBar := TBarSeries.Create(ChartFeed1);
1018
        FeedBar.ParentChart := ChartFeed1;
1019
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1020
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1021
        FeedBar.MultiBar := mbStacked100;
1022
        FeedBar.Marks.Visible := False;
1023
        ChartFeed1.AddSeries(FeedBar);
1024
        FeedBar.AddBar(Value, '', clTeeColor);
1025
        Total := Total + Value;
1026
      end;
1027
      if (ComboBoxType.ItemIndex = 1)
1028
      and ((ComboBoxEnergy.ItemIndex = 2)
1029
        or (ComboBoxEnergy.ItemIndex = 4)
1030
        or (ComboBoxEnergy.ItemIndex = 6))
1031
      and (ClientDataSetFeedsBonusT.Value > 0)
1032
      then // Bonus ?nergie (porc adulte)
1033
      begin
1034
        case ComboBoxEnergy.ItemIndex of
1035
          2: Value := ClientDataSetFeedsEDt.Value - Total;
1036
          4: Value := ClientDataSetFeedsEMt.Value - Total;
1037
          6: Value := ClientDataSetFeedsENt.Value - Total;
1038
          else Value := 0;
1039
        end;
1040
        FeedBar := TBarSeries.Create(ChartFeed1);
1041
        FeedBar.ParentChart := ChartFeed1;
1042
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1043
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1044
        FeedBar.MultiBar := mbStacked100;
1045
        FeedBar.Marks.Visible := False;
1046
        ChartFeed1.AddSeries(FeedBar);
1047
        FeedBar.AddBar(Value, '', clTeeColor);
1048
        Total := Total + Value;
1049
      end;
1050
      if (ComboBoxType.ItemIndex = 0)
1051
      and (ComboBoxProximal.ItemIndex = 0)
1052
      and not ClientDataSetFeedsPhytaseId.IsNull
1053
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
1054
      then // Phytase (taux d'incorporation)
1055
      begin
1056
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
1057
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1058
        FeedBar := TBarSeries.Create(ChartFeed1);
1059
        FeedBar.ParentChart := ChartFeed1;
1060
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1061
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1062
        FeedBar.MultiBar := mbStacked100;
1063
        FeedBar.Marks.Visible := False;
1064
        ChartFeed1.AddSeries(FeedBar);
1065
        FeedBar.AddBar(Value, '', clTeeColor);
1066
        Total := Total + Value;
1067
      end;
1068
      if (ComboBoxType.ItemIndex = 4)
1069
      and (ComboBoxMinerals.ItemIndex = 2)
1070
      and not ClientDataSetFeedsPhytaseId.IsNull
1071
      and (ClientDataSetFeedsPd.Value > Total)
1072
      then // Phytase (Phosphore digestible)
1073
      begin
1074
        Value := ClientDataSetFeedsPd.Value - Total;
1075
        FeedBar := TBarSeries.Create(ChartFeed1);
1076
        FeedBar.ParentChart := ChartFeed1;
1077
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1078
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1079
        FeedBar.MultiBar := mbStacked100;
1080
        FeedBar.Marks.Visible := False;
1081
        ChartFeed1.AddSeries(FeedBar);
1082
        FeedBar.AddBar(Value, '', clTeeColor);
1083
        Total := Total + Value;
1084
      end;
1085
      // Total
1086
      case ComboBoxType.ItemIndex of
1087
        0: // Analyse proximale
1088
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
1089
          then // sur frais
1090
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
1091
          else // sur mati?re s?che - except? pour Composition et MS
1092
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
1093
        1: // Valeurs ?nerg?tiques
1094
          if FormOptions.Expression = 0
1095
          then // sur frais
1096
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
1097
          else // sur mati?re s?che
1098
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
1099
        2, 3: // Acides amin?s
1100
          if FormOptions.Expression = 0
1101
          then // sur frais
1102
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
1103
          else // sur mati?re s?che
1104
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
1105
        4: // Min?raux
1106
          if FormOptions.Expression = 0
1107
          then // sur frais
1108
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
1109
          else // sur mati?re s?che
1110
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
1111
      end;
1112
      ClientDataSetComposition.Filtered := False;
1113
      ClientDataSetComposition.Filter := '';
1114
    end;
1115
end;
1116

    
1117
procedure TFormFeedsCharts.ComboBoxFeed2Change(Sender: TObject);
1118
var
1119
  IngredientName: String;
1120
  Cumul, Ratio, Total, Value: Double;
1121
  FeedBar: TBarSeries;
1122
begin
1123
//  while ChartFeed2.SeriesCount > 0 do
1124
//    ChartFeed2.Series[0].Free;
1125
  ChartFeed2.FreeAllSeries(nil);
1126
  ChartFeed2.Title.Clear;
1127
  ChartFeed2.SubTitle.Clear;
1128
  if ComboBoxFeed2.ItemIndex <> -1
1129
  then
1130
    with DataModuleDeclaration do
1131
    begin
1132
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed2.Text, []);
1133
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed2.Text) + 1;
1134
      ChartFeed2.AxisVisible := True;
1135
      ChartFeed2.Title.Text.Add(ClientDataSetFeedsName.Value);
1136
      ChartFeed2.SubTitle.Text.Add(ComboBoxType.Text);
1137
      case ComboBoxType.ItemIndex of
1138
        0: // Analyse proximale
1139
          ChartFeed2.SubTitle.Text.Add(ComboBoxProximal.Text);
1140
        1: // Valeurs ?nerg?tiques
1141
          ChartFeed2.SubTitle.Text.Add(ComboBoxEnergy.Text);
1142
        2, 3: // Acides amin?s
1143
          ChartFeed2.SubTitle.Text.Add(ComboBoxAA.Text);
1144
        4: // Min?raux
1145
          ChartFeed2.SubTitle.Text.Add(ComboBoxMinerals.Text);
1146
      end;
1147
      case ComboBoxType.ItemIndex of
1148
        0: // Analyse proximale
1149
          case ComboBoxProximal.ItemIndex of
1150
            0: // Composition
1151
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
1152
            1: // MS
1153
              Cumul := ClientDataSetFeedsMS.Value;
1154
            2: // MM
1155
              Cumul := ClientDataSetFeedsMM.Value;
1156
            3: // MAT
1157
              Cumul := ClientDataSetFeedsMAT.Value;
1158
            4: // MG
1159
              Cumul := ClientDataSetFeedsMG.Value;
1160
            5: // CB
1161
              Cumul := ClientDataSetFeedsCB.Value;
1162
            6: // NDF
1163
              Cumul := ClientDataSetFeedsNDF.Value;
1164
            7: // ADF
1165
              Cumul := ClientDataSetFeedsADF.Value;
1166
            8: // ADL
1167
              Cumul := ClientDataSetFeedsADL.Value;
1168
            9: // Amidon
1169
              Cumul := ClientDataSetFeedsAmidon.Value;
1170
            10: // Sucres
1171
              Cumul := ClientDataSetFeedsSucres.Value;
1172
            else
1173
              Cumul := 0;
1174
          end;
1175
        1: // Valeurs ?nerg?tiques
1176
          case ComboBoxEnergy.ItemIndex of
1177
            0: // Energie brute
1178
              Cumul := ClientDataSetFeedsEB.Value;
1179
            1: // Energie digestible (porc croissance)
1180
              Cumul := ClientDataSetFeedsEDc.Value;
1181
            2: // Energie digestible (porc adulte)
1182
              Cumul := ClientDataSetFeedsEDt.Value;
1183
            3: // Energie m?tabolisable (porc croissance)
1184
              Cumul := ClientDataSetFeedsEMc.Value;
1185
            4: // Energie m?tabolisable (porc adulte)
1186
              Cumul := ClientDataSetFeedsEMt.Value;
1187
            5: // Energie nette (porc croissance)
1188
              Cumul := ClientDataSetFeedsENc.Value;
1189
            6: // Energie nette (porc adulte)
1190
              Cumul := ClientDataSetFeedsENt.Value;
1191
            else
1192
              Cumul := 0;
1193
          end;
1194
        2: // Acides amin?s totaux
1195
          case ComboBoxAA.ItemIndex of
1196
            0: // Lysine
1197
              Cumul := ClientDataSetFeedsLys.Value;
1198
            1: // Thr?onine
1199
              Cumul := ClientDataSetFeedsThr.Value;
1200
            2: // M?thionine
1201
              Cumul := ClientDataSetFeedsMet.Value;
1202
            3: // Cyst?ine
1203
              Cumul := ClientDataSetFeedsCys.Value;
1204
            4: // M?thionine + Cyst?ine
1205
              Cumul := ClientDataSetFeedsMetCys.Value;
1206
            5: // Tryptophane
1207
              Cumul := ClientDataSetFeedsTrp.Value;
1208
            6: // Isoleucine
1209
              Cumul := ClientDataSetFeedsIle.Value;
1210
            7: // Valine
1211
              Cumul := ClientDataSetFeedsVal.Value;
1212
            8: // Leucine
1213
              Cumul := ClientDataSetFeedsLeu.Value;
1214
            9: // Ph?nylalanine
1215
              Cumul := ClientDataSetFeedsPhe.Value;
1216
            10: // Tyrosine
1217
              Cumul := ClientDataSetFeedsTyr.Value;
1218
            11: // Ph?nylalanine + Tyrosine
1219
              Cumul := ClientDataSetFeedsPheTyr.Value;
1220
            12: // Histidine
1221
              Cumul := ClientDataSetFeedsHis.Value;
1222
            13: // Arginine
1223
              Cumul := ClientDataSetFeedsArg.Value;
1224
            14: // Alanine
1225
              Cumul := ClientDataSetFeedsAla.Value;
1226
            15: // Aspartate
1227
              Cumul := ClientDataSetFeedsAsp.Value;
1228
            16: // Glutamate
1229
              Cumul := ClientDataSetFeedsGlu.Value;
1230
            17: // Glycine
1231
              Cumul := ClientDataSetFeedsGly.Value;
1232
            18: // S?rine
1233
              Cumul := ClientDataSetFeedsSer.Value;
1234
            19: // Proline
1235
              Cumul := ClientDataSetFeedsPro.Value;
1236
            else
1237
              Cumul := 0;
1238
          end;
1239
        3: // Acides amin?s digestibles
1240
          case ComboBoxAA.ItemIndex of
1241
            0: // Lysine
1242
              Cumul := ClientDataSetFeedsLysd.Value;
1243
            1: // Thr?onine
1244
              Cumul := ClientDataSetFeedsThrd.Value;
1245
            2: // M?thionine
1246
              Cumul := ClientDataSetFeedsMetd.Value;
1247
            3: // Cyst?ine
1248
              Cumul := ClientDataSetFeedsCysd.Value;
1249
            4: // M?thionine + Cyst?ine
1250
              Cumul := ClientDataSetFeedsMetCysd.Value;
1251
            5: // Tryptophane
1252
              Cumul := ClientDataSetFeedsTrpd.Value;
1253
            6: // Isoleucine
1254
              Cumul := ClientDataSetFeedsIled.Value;
1255
            7: // Valine
1256
              Cumul := ClientDataSetFeedsVald.Value;
1257
            8: // Leucine
1258
              Cumul := ClientDataSetFeedsLeud.Value;
1259
            9: // Ph?nylalanine
1260
              Cumul := ClientDataSetFeedsPhed.Value;
1261
            10: // Tyrosine
1262
              Cumul := ClientDataSetFeedsTyrd.Value;
1263
            11: // Ph?nylalanine + Tyrosine
1264
              Cumul := ClientDataSetFeedsPheTyrd.Value;
1265
            12: // Histidine
1266
              Cumul := ClientDataSetFeedsHisd.Value;
1267
            13: // Arginine
1268
              Cumul := ClientDataSetFeedsArgd.Value;
1269
            14: // Alanine
1270
              Cumul := ClientDataSetFeedsAlad.Value;
1271
            15: // Aspartate
1272
              Cumul := ClientDataSetFeedsAspd.Value;
1273
            16: // Glutamate
1274
              Cumul := ClientDataSetFeedsGlud.Value;
1275
            17: // Glycine
1276
              Cumul := ClientDataSetFeedsGlyd.Value;
1277
            18: // S?rine
1278
              Cumul := ClientDataSetFeedsSerd.Value;
1279
            19: // Proline
1280
              Cumul := ClientDataSetFeedsProd.Value;
1281
            else
1282
              Cumul := 0;
1283
          end;
1284
        4: // Min?raux
1285
          case ComboBoxMinerals.ItemIndex of
1286
            0: // Calcium
1287
              Cumul := ClientDataSetFeedsCa.Value;
1288
            1: // Phosphore
1289
              Cumul := ClientDataSetFeedsP.Value;
1290
            2: // Phosphore digestible
1291
              Cumul := ClientDataSetFeedsPd.Value;
1292
            else
1293
              Cumul := 0;
1294
          end;
1295
        else
1296
          Cumul := 0;
1297
      end;
1298
      if Cumul = 0
1299
      then // Division par z?ro
1300
        Cumul := 1;
1301
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
1302
      ClientDataSetComposition.Filtered := True;
1303
      ClientDataSetComposition.First;
1304
      Total := 0;
1305
      while not ClientDataSetComposition.Eof do
1306
      begin
1307
        if ClientDataSetCompositionUser.Value
1308
        then
1309
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
1310
        else
1311
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
1312
        ClientDataSetIngredients.Filtered := True;
1313
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
1314
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
1315
        if (FormOptions.Expression = 0)
1316
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1317
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
1318
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
1319
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
1320
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1321
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
1322
          Ratio := Ratio * RapMS;
1323
        case ComboBoxType.ItemIndex of
1324
          0: // Analyse proximale
1325
            case ComboBoxProximal.ItemIndex of
1326
              0: // Composition
1327
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1328
              1: // MS
1329
                Value := ClientDataSetCompositionMS.Value * Ratio;
1330
              2: // MM
1331
                Value := ClientDataSetIngredientsMM.Value * Ratio;
1332
              3: // MAT
1333
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
1334
              4: // MG
1335
                Value := ClientDataSetIngredientsMG.Value * Ratio;
1336
              5: // CB
1337
                Value := ClientDataSetIngredientsCB.Value * Ratio;
1338
              6: // NDF
1339
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
1340
              7: // ADF
1341
                Value := ClientDataSetIngredientsADF.Value * Ratio;
1342
              8: // ADL
1343
                Value := ClientDataSetIngredientsADL.Value * Ratio;
1344
              9: // Amidon
1345
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
1346
              10: // Sucres
1347
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
1348
              else
1349
                Value := 0;
1350
            end;
1351
          1: // Valeurs ?nerg?tiques
1352
            case ComboBoxEnergy.ItemIndex of
1353
              0: // Energie brute
1354
                Value := ClientDataSetIngredientsEB.Value * Ratio;
1355
              1: // Energie digestible (porc croissance)
1356
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
1357
              2: // Energie digestible (porc adulte)
1358
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
1359
              3: // Energie m?tabolisable (porc croissance)
1360
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
1361
              4: // Energie m?tabolisable (porc adulte)
1362
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
1363
              5: // Energie nette (porc croissance)
1364
                Value := ClientDataSetIngredientsENc.Value * Ratio;
1365
              6: // Energie nette (porc adulte)
1366
                Value := ClientDataSetIngredientsENt.Value * Ratio;
1367
              else
1368
                Value := 0;
1369
            end;
1370
          2: // Acides amin?s totaux
1371
            case ComboBoxAA.ItemIndex of
1372
              0: // Lysine
1373
                Value := ClientDataSetIngredientsLys.Value * Ratio;
1374
              1: // Thr?onine
1375
                Value := ClientDataSetIngredientsThr.Value * Ratio;
1376
              2: // M?thionine
1377
                Value := ClientDataSetIngredientsMet.Value * Ratio;
1378
              3: // Cyst?ine
1379
                Value := ClientDataSetIngredientsCys.Value * Ratio;
1380
              4: // M?thionine + Cyst?ine
1381
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
1382
              5: // Tryptophane
1383
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
1384
              6: // Isoleucine
1385
                Value := ClientDataSetIngredientsIle.Value * Ratio;
1386
              7: // Valine
1387
                Value := ClientDataSetIngredientsVal.Value * Ratio;
1388
              8: // Leucine
1389
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
1390
              9: // Ph?nylalanine
1391
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
1392
              10: // Tyrosine
1393
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
1394
              11: // Ph?nylalanine + Tyrosine
1395
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
1396
              12: // Histidine
1397
                Value := ClientDataSetIngredientsHis.Value * Ratio;
1398
              13: // Arginine
1399
                Value := ClientDataSetIngredientsArg.Value * Ratio;
1400
              14: // Alanine
1401
                Value := ClientDataSetIngredientsAla.Value * Ratio;
1402
              15: // Aspartate
1403
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
1404
              16: // Glutamate
1405
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
1406
              17: // Glycine
1407
                Value := ClientDataSetIngredientsGly.Value * Ratio;
1408
              18: // S?rine
1409
                Value := ClientDataSetIngredientsSer.Value * Ratio;
1410
              19: // Proline
1411
                Value := ClientDataSetIngredientsPro.Value * Ratio;
1412
              else
1413
                Value := 0;
1414
            end;
1415
          3: // Acides amin?s digestibles
1416
            case ComboBoxAA.ItemIndex of
1417
              0: // Lysine
1418
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
1419
              1: // Thr?onine
1420
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
1421
              2: // M?thionine
1422
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
1423
              3: // Cyst?ine
1424
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
1425
              4: // M?thionine + Cyst?ine
1426
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
1427
              5: // Tryptophane
1428
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
1429
              6: // Isoleucine
1430
                Value := ClientDataSetIngredientsIled.Value * Ratio;
1431
              7: // Valine
1432
                Value := ClientDataSetIngredientsVald.Value * Ratio;
1433
              8: // Leucine
1434
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
1435
              9: // Ph?nylalanine
1436
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
1437
              10: // Tyrosine
1438
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
1439
              11: // Ph?nylalanine + Tyrosine
1440
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
1441
              12: // Histidine
1442
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
1443
              13: // Arginine
1444
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
1445
              14: // Alanine
1446
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
1447
              15: // Aspartate
1448
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
1449
              16: // Glutamate
1450
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
1451
              17: // Glycine
1452
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
1453
              18: // S?rine
1454
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
1455
              19: // Proline
1456
                Value := ClientDataSetIngredientsProd.Value * Ratio;
1457
              else
1458
                Value := 0;
1459
            end;
1460
          4: // Min?raux
1461
            case ComboBoxMinerals.ItemIndex of
1462
              0: // Calcium
1463
                Value := ClientDataSetIngredientsCa.Value * Ratio;
1464
              1: // Phosphore
1465
                Value := ClientDataSetIngredientsP.Value * Ratio;
1466
              2: // Phosphore digestible
1467
                if ClientDataSetFeedsPresentation.Value = 0
1468
                then // Farine (dPphy)
1469
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
1470
                else // Granul?s (dP)
1471
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
1472
              else
1473
                Value := 0;
1474
            end;
1475
          else
1476
            Value := 0;
1477
        end;
1478
        if (FormOptions.Expression = 1)
1479
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1480
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
1481
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
1482
        if Value > 0
1483
        then // Prendre en compte la valeur
1484
        begin
1485
          FeedBar := TBarSeries.Create(ChartFeed2);
1486
          FeedBar.ParentChart := ChartFeed2;
1487
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
1488
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
1489
          FeedBar.MultiBar := mbStacked100;
1490
          FeedBar.Marks.Visible := False;
1491
          ChartFeed2.AddSeries(FeedBar);
1492
          FeedBar.AddBar(Value, '', clTeeColor);
1493
          Total := Total + Value;
1494
        end;
1495
        ClientDataSetComposition.Next;
1496
      end;
1497
      ClientDataSetIngredients.Filtered := False;
1498
      ClientDataSetIngredients.Filter := '';
1499
      // Cas particuliers
1500
      if (ComboBoxType.ItemIndex = 1)
1501
      and ((ComboBoxEnergy.ItemIndex = 1)
1502
        or (ComboBoxEnergy.ItemIndex = 3)
1503
        or (ComboBoxEnergy.ItemIndex = 5))
1504
      and (ClientDataSetFeedsBonusC.Value > 0)
1505
      then // Bonus ?nergie (porc croissance)
1506
      begin
1507
        case ComboBoxEnergy.ItemIndex of
1508
          1: Value := ClientDataSetFeedsEDc.Value - Total;
1509
          3: Value := ClientDataSetFeedsEMc.Value - Total;
1510
          5: Value := ClientDataSetFeedsENc.Value - Total;
1511
          else Value := 0;
1512
        end;
1513
        FeedBar := TBarSeries.Create(ChartFeed2);
1514
        FeedBar.ParentChart := ChartFeed2;
1515
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1516
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1517
        FeedBar.MultiBar := mbStacked100;
1518
        FeedBar.Marks.Visible := False;
1519
        ChartFeed2.AddSeries(FeedBar);
1520
        FeedBar.AddBar(Value, '', clTeeColor);
1521
        Total := Total + Value;
1522
      end;
1523
      if (ComboBoxType.ItemIndex = 1)
1524
      and ((ComboBoxEnergy.ItemIndex = 2)
1525
        or (ComboBoxEnergy.ItemIndex = 4)
1526
        or (ComboBoxEnergy.ItemIndex = 6))
1527
      and (ClientDataSetFeedsBonusT.Value > 0)
1528
      then // Bonus ?nergie (porc adulte)
1529
      begin
1530
        case ComboBoxEnergy.ItemIndex of
1531
          2: Value := ClientDataSetFeedsEDt.Value - Total;
1532
          4: Value := ClientDataSetFeedsEMt.Value - Total;
1533
          6: Value := ClientDataSetFeedsENt.Value - Total;
1534
          else Value := 0;
1535
        end;
1536
        FeedBar := TBarSeries.Create(ChartFeed2);
1537
        FeedBar.ParentChart := ChartFeed2;
1538
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1539
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1540
        FeedBar.MultiBar := mbStacked100;
1541
        FeedBar.Marks.Visible := False;
1542
        ChartFeed2.AddSeries(FeedBar);
1543
        FeedBar.AddBar(Value, '', clTeeColor);
1544
        Total := Total + Value;
1545
      end;
1546
      if (ComboBoxType.ItemIndex = 0)
1547
      and (ComboBoxProximal.ItemIndex = 0)
1548
      and not ClientDataSetFeedsPhytaseId.IsNull
1549
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
1550
      then // Phytase (taux d'incorporation)
1551
      begin
1552
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
1553
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1554
        FeedBar := TBarSeries.Create(ChartFeed2);
1555
        FeedBar.ParentChart := ChartFeed2;
1556
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1557
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1558
        FeedBar.MultiBar := mbStacked100;
1559
        FeedBar.Marks.Visible := False;
1560
        ChartFeed2.AddSeries(FeedBar);
1561
        FeedBar.AddBar(Value, '', clTeeColor);
1562
        Total := Total + Value;
1563
      end;
1564
      if (ComboBoxType.ItemIndex = 4)
1565
      and (ComboBoxMinerals.ItemIndex = 2)
1566
      and not ClientDataSetFeedsPhytaseId.IsNull
1567
      and (ClientDataSetFeedsPd.Value > Total)
1568
      then // Phytase (Phosphore digestible)
1569
      begin
1570
        Value := ClientDataSetFeedsPd.Value - Total;
1571
        FeedBar := TBarSeries.Create(ChartFeed2);
1572
        FeedBar.ParentChart := ChartFeed2;
1573
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1574
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1575
        FeedBar.MultiBar := mbStacked100;
1576
        FeedBar.Marks.Visible := False;
1577
        ChartFeed2.AddSeries(FeedBar);
1578
        FeedBar.AddBar(Value, '', clTeeColor);
1579
        Total := Total + Value;
1580
      end;
1581
      // Total
1582
      case ComboBoxType.ItemIndex of
1583
        0: // Analyse proximale
1584
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
1585
          then // sur frais
1586
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
1587
          else // sur mati?re s?che - except? pour Composition et MS
1588
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
1589
        1: // Valeurs ?nerg?tiques
1590
          if FormOptions.Expression = 0
1591
          then // sur frais
1592
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
1593
          else // sur mati?re s?che
1594
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
1595
        2, 3: // Acides amin?s
1596
          if FormOptions.Expression = 0
1597
          then // sur frais
1598
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
1599
          else // sur mati?re s?che
1600
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
1601
        4: // Min?raux
1602
          if FormOptions.Expression = 0
1603
          then // sur frais
1604
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
1605
          else // sur mati?re s?che
1606
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
1607
      end;
1608
      ClientDataSetComposition.Filtered := False;
1609
      ClientDataSetComposition.Filter := '';
1610
    end;
1611
end;
1612

    
1613
procedure TFormFeedsCharts.ComboBoxFeed3Change(Sender: TObject);
1614
var
1615
  IngredientName: String;
1616
  Cumul, Ratio, Total, Value: Double;
1617
  FeedBar: TBarSeries;
1618
begin
1619
//  while ChartFeed3.SeriesCount > 0 do
1620
//    ChartFeed3.Series[0].Free;
1621
  ChartFeed3.FreeAllSeries(nil);
1622
  ChartFeed3.Title.Clear;
1623
  ChartFeed3.SubTitle.Clear;
1624
  if ComboBoxFeed3.ItemIndex <> -1
1625
  then
1626
    with DataModuleDeclaration do
1627
    begin
1628
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed3.Text, []);
1629
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed3.Text) + 1;
1630
      ChartFeed3.AxisVisible := True;
1631
      ChartFeed3.Title.Text.Add(ClientDataSetFeedsName.Value);
1632
      ChartFeed3.SubTitle.Text.Add(ComboBoxType.Text);
1633
      case ComboBoxType.ItemIndex of
1634
        0: // Analyse proximale
1635
          ChartFeed3.SubTitle.Text.Add(ComboBoxProximal.Text);
1636
        1: // Valeurs ?nerg?tiques
1637
          ChartFeed3.SubTitle.Text.Add(ComboBoxEnergy.Text);
1638
        2, 3: // Acides amin?s
1639
          ChartFeed3.SubTitle.Text.Add(ComboBoxAA.Text);
1640
        4: // Min?raux
1641
          ChartFeed3.SubTitle.Text.Add(ComboBoxMinerals.Text);
1642
      end;
1643
      case ComboBoxType.ItemIndex of
1644
        0: // Analyse proximale
1645
          case ComboBoxProximal.ItemIndex of
1646
            0: // Composition
1647
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
1648
            1: // MS
1649
              Cumul := ClientDataSetFeedsMS.Value;
1650
            2: // MM
1651
              Cumul := ClientDataSetFeedsMM.Value;
1652
            3: // MAT
1653
              Cumul := ClientDataSetFeedsMAT.Value;
1654
            4: // MG
1655
              Cumul := ClientDataSetFeedsMG.Value;
1656
            5: // CB
1657
              Cumul := ClientDataSetFeedsCB.Value;
1658
            6: // NDF
1659
              Cumul := ClientDataSetFeedsNDF.Value;
1660
            7: // ADF
1661
              Cumul := ClientDataSetFeedsADF.Value;
1662
            8: // ADL
1663
              Cumul := ClientDataSetFeedsADL.Value;
1664
            9: // Amidon
1665
              Cumul := ClientDataSetFeedsAmidon.Value;
1666
            10: // Sucres
1667
              Cumul := ClientDataSetFeedsSucres.Value;
1668
            else
1669
              Cumul := 0;
1670
          end;
1671
        1: // Valeurs ?nerg?tiques
1672
          case ComboBoxEnergy.ItemIndex of
1673
            0: // Energie brute
1674
              Cumul := ClientDataSetFeedsEB.Value;
1675
            1: // Energie digestible (porc croissance)
1676
              Cumul := ClientDataSetFeedsEDc.Value;
1677
            2: // Energie digestible (porc adulte)
1678
              Cumul := ClientDataSetFeedsEDt.Value;
1679
            3: // Energie m?tabolisable (porc croissance)
1680
              Cumul := ClientDataSetFeedsEMc.Value;
1681
            4: // Energie m?tabolisable (porc adulte)
1682
              Cumul := ClientDataSetFeedsEMt.Value;
1683
            5: // Energie nette (porc croissance)
1684
              Cumul := ClientDataSetFeedsENc.Value;
1685
            6: // Energie nette (porc adulte)
1686
              Cumul := ClientDataSetFeedsENt.Value;
1687
            else
1688
              Cumul := 0;
1689
          end;
1690
        2: // Acides amin?s totaux
1691
          case ComboBoxAA.ItemIndex of
1692
            0: // Lysine
1693
              Cumul := ClientDataSetFeedsLys.Value;
1694
            1: // Thr?onine
1695
              Cumul := ClientDataSetFeedsThr.Value;
1696
            2: // M?thionine
1697
              Cumul := ClientDataSetFeedsMet.Value;
1698
            3: // Cyst?ine
1699
              Cumul := ClientDataSetFeedsCys.Value;
1700
            4: // M?thionine + Cyst?ine
1701
              Cumul := ClientDataSetFeedsMetCys.Value;
1702
            5: // Tryptophane
1703
              Cumul := ClientDataSetFeedsTrp.Value;
1704
            6: // Isoleucine
1705
              Cumul := ClientDataSetFeedsIle.Value;
1706
            7: // Valine
1707
              Cumul := ClientDataSetFeedsVal.Value;
1708
            8: // Leucine
1709
              Cumul := ClientDataSetFeedsLeu.Value;
1710
            9: // Ph?nylalanine
1711
              Cumul := ClientDataSetFeedsPhe.Value;
1712
            10: // Tyrosine
1713
              Cumul := ClientDataSetFeedsTyr.Value;
1714
            11: // Ph?nylalanine + Tyrosine
1715
              Cumul := ClientDataSetFeedsPheTyr.Value;
1716
            12: // Histidine
1717
              Cumul := ClientDataSetFeedsHis.Value;
1718
            13: // Arginine
1719
              Cumul := ClientDataSetFeedsArg.Value;
1720
            14: // Alanine
1721
              Cumul := ClientDataSetFeedsAla.Value;
1722
            15: // Aspartate
1723
              Cumul := ClientDataSetFeedsAsp.Value;
1724
            16: // Glutamate
1725
              Cumul := ClientDataSetFeedsGlu.Value;
1726
            17: // Glycine
1727
              Cumul := ClientDataSetFeedsGly.Value;
1728
            18: // S?rine
1729
              Cumul := ClientDataSetFeedsSer.Value;
1730
            19: // Proline
1731
              Cumul := ClientDataSetFeedsPro.Value;
1732
            else
1733
              Cumul := 0;
1734
          end;
1735
        3: // Acides amin?s digestibles
1736
          case ComboBoxAA.ItemIndex of
1737
            0: // Lysine
1738
              Cumul := ClientDataSetFeedsLysd.Value;
1739
            1: // Thr?onine
1740
              Cumul := ClientDataSetFeedsThrd.Value;
1741
            2: // M?thionine
1742
              Cumul := ClientDataSetFeedsMetd.Value;
1743
            3: // Cyst?ine
1744
              Cumul := ClientDataSetFeedsCysd.Value;
1745
            4: // M?thionine + Cyst?ine
1746
              Cumul := ClientDataSetFeedsMetCysd.Value;
1747
            5: // Tryptophane
1748
              Cumul := ClientDataSetFeedsTrpd.Value;
1749
            6: // Isoleucine
1750
              Cumul := ClientDataSetFeedsIled.Value;
1751
            7: // Valine
1752
              Cumul := ClientDataSetFeedsVald.Value;
1753
            8: // Leucine
1754
              Cumul := ClientDataSetFeedsLeud.Value;
1755
            9: // Ph?nylalanine
1756
              Cumul := ClientDataSetFeedsPhed.Value;
1757
            10: // Tyrosine
1758
              Cumul := ClientDataSetFeedsTyrd.Value;
1759
            11: // Ph?nylalanine + Tyrosine
1760
              Cumul := ClientDataSetFeedsPheTyrd.Value;
1761
            12: // Histidine
1762
              Cumul := ClientDataSetFeedsHisd.Value;
1763
            13: // Arginine
1764
              Cumul := ClientDataSetFeedsArgd.Value;
1765
            14: // Alanine
1766
              Cumul := ClientDataSetFeedsAlad.Value;
1767
            15: // Aspartate
1768
              Cumul := ClientDataSetFeedsAspd.Value;
1769
            16: // Glutamate
1770
              Cumul := ClientDataSetFeedsGlud.Value;
1771
            17: // Glycine
1772
              Cumul := ClientDataSetFeedsGlyd.Value;
1773
            18: // S?rine
1774
              Cumul := ClientDataSetFeedsSerd.Value;
1775
            19: // Proline
1776
              Cumul := ClientDataSetFeedsProd.Value;
1777
            else
1778
              Cumul := 0;
1779
          end;
1780
        4: // Min?raux
1781
          case ComboBoxMinerals.ItemIndex of
1782
            0: // Calcium
1783
              Cumul := ClientDataSetFeedsCa.Value;
1784
            1: // Phosphore
1785
              Cumul := ClientDataSetFeedsP.Value;
1786
            2: // Phosphore digestible
1787
              Cumul := ClientDataSetFeedsPd.Value;
1788
            else
1789
              Cumul := 0;
1790
          end;
1791
        else
1792
          Cumul := 0;
1793
      end;
1794
      if Cumul = 0
1795
      then // Division par z?ro
1796
        Cumul := 1;
1797
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
1798
      ClientDataSetComposition.Filtered := True;
1799
      ClientDataSetComposition.First;
1800
      Total := 0;
1801
      while not ClientDataSetComposition.Eof do
1802
      begin
1803
        if ClientDataSetCompositionUser.Value
1804
        then
1805
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
1806
        else
1807
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
1808
        ClientDataSetIngredients.Filtered := True;
1809
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
1810
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
1811
        if (FormOptions.Expression = 0)
1812
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1813
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
1814
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
1815
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
1816
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1817
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
1818
          Ratio := Ratio * RapMS;
1819
        case ComboBoxType.ItemIndex of
1820
          0: // Analyse proximale
1821
            case ComboBoxProximal.ItemIndex of
1822
              0: // Composition
1823
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1824
              1: // MS
1825
                Value := ClientDataSetCompositionMS.Value * Ratio;
1826
              2: // MM
1827
                Value := ClientDataSetIngredientsMM.Value * Ratio;
1828
              3: // MAT
1829
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
1830
              4: // MG
1831
                Value := ClientDataSetIngredientsMG.Value * Ratio;
1832
              5: // CB
1833
                Value := ClientDataSetIngredientsCB.Value * Ratio;
1834
              6: // NDF
1835
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
1836
              7: // ADF
1837
                Value := ClientDataSetIngredientsADF.Value * Ratio;
1838
              8: // ADL
1839
                Value := ClientDataSetIngredientsADL.Value * Ratio;
1840
              9: // Amidon
1841
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
1842
              10: // Sucres
1843
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
1844
              else
1845
                Value := 0;
1846
            end;
1847
          1: // Valeurs ?nerg?tiques
1848
            case ComboBoxEnergy.ItemIndex of
1849
              0: // Energie brute
1850
                Value := ClientDataSetIngredientsEB.Value * Ratio;
1851
              1: // Energie digestible (porc croissance)
1852
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
1853
              2: // Energie digestible (porc adulte)
1854
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
1855
              3: // Energie m?tabolisable (porc croissance)
1856
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
1857
              4: // Energie m?tabolisable (porc adulte)
1858
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
1859
              5: // Energie nette (porc croissance)
1860
                Value := ClientDataSetIngredientsENc.Value * Ratio;
1861
              6: // Energie nette (porc adulte)
1862
                Value := ClientDataSetIngredientsENt.Value * Ratio;
1863
              else
1864
                Value := 0;
1865
            end;
1866
          2: // Acides amin?s totaux
1867
            case ComboBoxAA.ItemIndex of
1868
              0: // Lysine
1869
                Value := ClientDataSetIngredientsLys.Value * Ratio;
1870
              1: // Thr?onine
1871
                Value := ClientDataSetIngredientsThr.Value * Ratio;
1872
              2: // M?thionine
1873
                Value := ClientDataSetIngredientsMet.Value * Ratio;
1874
              3: // Cyst?ine
1875
                Value := ClientDataSetIngredientsCys.Value * Ratio;
1876
              4: // M?thionine + Cyst?ine
1877
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
1878
              5: // Tryptophane
1879
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
1880
              6: // Isoleucine
1881
                Value := ClientDataSetIngredientsIle.Value * Ratio;
1882
              7: // Valine
1883
                Value := ClientDataSetIngredientsVal.Value * Ratio;
1884
              8: // Leucine
1885
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
1886
              9: // Ph?nylalanine
1887
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
1888
              10: // Tyrosine
1889
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
1890
              11: // Ph?nylalanine + Tyrosine
1891
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
1892
              12: // Histidine
1893
                Value := ClientDataSetIngredientsHis.Value * Ratio;
1894
              13: // Arginine
1895
                Value := ClientDataSetIngredientsArg.Value * Ratio;
1896
              14: // Alanine
1897
                Value := ClientDataSetIngredientsAla.Value * Ratio;
1898
              15: // Aspartate
1899
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
1900
              16: // Glutamate
1901
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
1902
              17: // Glycine
1903
                Value := ClientDataSetIngredientsGly.Value * Ratio;
1904
              18: // S?rine
1905
                Value := ClientDataSetIngredientsSer.Value * Ratio;
1906
              19: // Proline
1907
                Value := ClientDataSetIngredientsPro.Value * Ratio;
1908
              else
1909
                Value := 0;
1910
            end;
1911
          3: // Acides amin?s digestibles
1912
            case ComboBoxAA.ItemIndex of
1913
              0: // Lysine
1914
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
1915
              1: // Thr?onine
1916
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
1917
              2: // M?thionine
1918
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
1919
              3: // Cyst?ine
1920
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
1921
              4: // M?thionine + Cyst?ine
1922
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
1923
              5: // Tryptophane
1924
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
1925
              6: // Isoleucine
1926
                Value := ClientDataSetIngredientsIled.Value * Ratio;
1927
              7: // Valine
1928
                Value := ClientDataSetIngredientsVald.Value * Ratio;
1929
              8: // Leucine
1930
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
1931
              9: // Ph?nylalanine
1932
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
1933
              10: // Tyrosine
1934
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
1935
              11: // Ph?nylalanine + Tyrosine
1936
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
1937
              12: // Histidine
1938
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
1939
              13: // Arginine
1940
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
1941
              14: // Alanine
1942
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
1943
              15: // Aspartate
1944
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
1945
              16: // Glutamate
1946
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
1947
              17: // Glycine
1948
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
1949
              18: // S?rine
1950
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
1951
              19: // Proline
1952
                Value := ClientDataSetIngredientsProd.Value * Ratio;
1953
              else
1954
                Value := 0;
1955
            end;
1956
          4: // Min?raux
1957
            case ComboBoxMinerals.ItemIndex of
1958
              0: // Calcium
1959
                Value := ClientDataSetIngredientsCa.Value * Ratio;
1960
              1: // Phosphore
1961
                Value := ClientDataSetIngredientsP.Value * Ratio;
1962
              2: // Phosphore digestible
1963
                if ClientDataSetFeedsPresentation.Value = 0
1964
                then // Farine (dPphy)
1965
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
1966
                else // Granul?s (dP)
1967
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
1968
              else
1969
                Value := 0;
1970
            end;
1971
          else
1972
            Value := 0;
1973
        end;
1974
        if (FormOptions.Expression = 1)
1975
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1976
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
1977
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
1978
        if Value > 0
1979
        then // Prendre en compte la valeur
1980
        begin
1981
          FeedBar := TBarSeries.Create(ChartFeed3);
1982
          FeedBar.ParentChart := ChartFeed3;
1983
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
1984
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
1985
          FeedBar.MultiBar := mbStacked100;
1986
          FeedBar.Marks.Visible := False;
1987
          ChartFeed3.AddSeries(FeedBar);
1988
          FeedBar.AddBar(Value, '', clTeeColor);
1989
          Total := Total + Value;
1990
        end;
1991
        ClientDataSetComposition.Next;
1992
      end;
1993
      ClientDataSetIngredients.Filtered := False;
1994
      ClientDataSetIngredients.Filter := '';
1995
      // Cas particuliers
1996
      if (ComboBoxType.ItemIndex = 1)
1997
      and ((ComboBoxEnergy.ItemIndex = 1)
1998
        or (ComboBoxEnergy.ItemIndex = 3)
1999
        or (ComboBoxEnergy.ItemIndex = 5))
2000
      and (ClientDataSetFeedsBonusC.Value > 0)
2001
      then // Bonus ?nergie (porc croissance)
2002
      begin
2003
        case ComboBoxEnergy.ItemIndex of
2004
          1: Value := ClientDataSetFeedsEDc.Value - Total;
2005
          3: Value := ClientDataSetFeedsEMc.Value - Total;
2006
          5: Value := ClientDataSetFeedsENc.Value - Total;
2007
          else Value := 0;
2008
        end;
2009
        FeedBar := TBarSeries.Create(ChartFeed3);
2010
        FeedBar.ParentChart := ChartFeed3;
2011
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2012
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2013
        FeedBar.MultiBar := mbStacked100;
2014
        FeedBar.Marks.Visible := False;
2015
        ChartFeed3.AddSeries(FeedBar);
2016
        FeedBar.AddBar(Value, '', clTeeColor);
2017
        Total := Total + Value;
2018
      end;
2019
      if (ComboBoxType.ItemIndex = 1)
2020
      and ((ComboBoxEnergy.ItemIndex = 2)
2021
        or (ComboBoxEnergy.ItemIndex = 4)
2022
        or (ComboBoxEnergy.ItemIndex = 6))
2023
      and (ClientDataSetFeedsBonusT.Value > 0)
2024
      then // Bonus ?nergie (porc adulte)
2025
      begin
2026
        case ComboBoxEnergy.ItemIndex of
2027
          2: Value := ClientDataSetFeedsEDt.Value - Total;
2028
          4: Value := ClientDataSetFeedsEMt.Value - Total;
2029
          6: Value := ClientDataSetFeedsENt.Value - Total;
2030
          else Value := 0;
2031
        end;
2032
        FeedBar := TBarSeries.Create(ChartFeed3);
2033
        FeedBar.ParentChart := ChartFeed3;
2034
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2035
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2036
        FeedBar.MultiBar := mbStacked100;
2037
        FeedBar.Marks.Visible := False;
2038
        ChartFeed3.AddSeries(FeedBar);
2039
        FeedBar.AddBar(Value, '', clTeeColor);
2040
        Total := Total + Value;
2041
      end;
2042
      if (ComboBoxType.ItemIndex = 0)
2043
      and (ComboBoxProximal.ItemIndex = 0)
2044
      and not ClientDataSetFeedsPhytaseId.IsNull
2045
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
2046
      then // Phytase (taux d'incorporation)
2047
      begin
2048
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
2049
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
2050
        FeedBar := TBarSeries.Create(ChartFeed3);
2051
        FeedBar.ParentChart := ChartFeed3;
2052
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2053
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2054
        FeedBar.MultiBar := mbStacked100;
2055
        FeedBar.Marks.Visible := False;
2056
        ChartFeed3.AddSeries(FeedBar);
2057
        FeedBar.AddBar(Value, '', clTeeColor);
2058
        Total := Total + Value;
2059
      end;
2060
      if (ComboBoxType.ItemIndex = 4)
2061
      and (ComboBoxMinerals.ItemIndex = 2)
2062
      and not ClientDataSetFeedsPhytaseId.IsNull
2063
      and (ClientDataSetFeedsPd.Value > Total)
2064
      then // Phytase (Phosphore digestible)
2065
      begin
2066
        Value := ClientDataSetFeedsPd.Value - Total;
2067
        FeedBar := TBarSeries.Create(ChartFeed3);
2068
        FeedBar.ParentChart := ChartFeed3;
2069
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2070
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2071
        FeedBar.MultiBar := mbStacked100;
2072
        FeedBar.Marks.Visible := False;
2073
        ChartFeed3.AddSeries(FeedBar);
2074
        FeedBar.AddBar(Value, '', clTeeColor);
2075
        Total := Total + Value;
2076
      end;
2077
      // Total
2078
      case ComboBoxType.ItemIndex of
2079
        0: // Analyse proximale
2080
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
2081
          then // sur frais
2082
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
2083
          else // sur mati?re s?che - except? pour Composition et MS
2084
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
2085
        1: // Valeurs ?nerg?tiques
2086
          if FormOptions.Expression = 0
2087
          then // sur frais
2088
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
2089
          else // sur mati?re s?che
2090
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
2091
        2, 3: // Acides amin?s
2092
          if FormOptions.Expression = 0
2093
          then // sur frais
2094
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
2095
          else // sur mati?re s?che
2096
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
2097
        4: // Min?raux
2098
          if FormOptions.Expression = 0
2099
          then // sur frais
2100
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
2101
          else // sur mati?re s?che
2102
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
2103
      end;
2104
      ClientDataSetComposition.Filtered := False;
2105
      ClientDataSetComposition.Filter := '';
2106
    end;
2107
end;
2108

    
2109
procedure TFormFeedsCharts.ComboBoxFeed4Change(Sender: TObject);
2110
var
2111
  IngredientName: String;
2112
  Cumul, Ratio, Total, Value: Double;
2113
  FeedBar: TBarSeries;
2114
begin
2115
//  while ChartFeed4.SeriesCount > 0 do
2116
//    ChartFeed4.Series[0].Free;
2117
  ChartFeed4.FreeAllSeries(nil);
2118
  ChartFeed4.Title.Clear;
2119
  ChartFeed4.SubTitle.Clear;
2120
  if ComboBoxFeed4.ItemIndex <> -1
2121
  then
2122
    with DataModuleDeclaration do
2123
    begin
2124
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed4.Text, []);
2125
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed4.Text) + 1;
2126
      ChartFeed4.AxisVisible := True;
2127
      ChartFeed4.Title.Text.Add(ClientDataSetFeedsName.Value);
2128
      ChartFeed4.SubTitle.Text.Add(ComboBoxType.Text);
2129
      case ComboBoxType.ItemIndex of
2130
        0: // Analyse proximale
2131
          ChartFeed4.SubTitle.Text.Add(ComboBoxProximal.Text);
2132
        1: // Valeurs ?nerg?tiques
2133
          ChartFeed4.SubTitle.Text.Add(ComboBoxEnergy.Text);
2134
        2, 3: // Acides amin?s
2135
          ChartFeed4.SubTitle.Text.Add(ComboBoxAA.Text);
2136
        4: // Min?raux
2137
          ChartFeed4.SubTitle.Text.Add(ComboBoxMinerals.Text);
2138
      end;
2139
      case ComboBoxType.ItemIndex of
2140
        0: // Analyse proximale
2141
          case ComboBoxProximal.ItemIndex of
2142
            0: // Composition
2143
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
2144
            1: // MS
2145
              Cumul := ClientDataSetFeedsMS.Value;
2146
            2: // MM
2147
              Cumul := ClientDataSetFeedsMM.Value;
2148
            3: // MAT
2149
              Cumul := ClientDataSetFeedsMAT.Value;
2150
            4: // MG
2151
              Cumul := ClientDataSetFeedsMG.Value;
2152
            5: // CB
2153
              Cumul := ClientDataSetFeedsCB.Value;
2154
            6: // NDF
2155
              Cumul := ClientDataSetFeedsNDF.Value;
2156
            7: // ADF
2157
              Cumul := ClientDataSetFeedsADF.Value;
2158
            8: // ADL
2159
              Cumul := ClientDataSetFeedsADL.Value;
2160
            9: // Amidon
2161
              Cumul := ClientDataSetFeedsAmidon.Value;
2162
            10: // Sucres
2163
              Cumul := ClientDataSetFeedsSucres.Value;
2164
            else
2165
              Cumul := 0;
2166
          end;
2167
        1: // Valeurs ?nerg?tiques
2168
          case ComboBoxEnergy.ItemIndex of
2169
            0: // Energie brute
2170
              Cumul := ClientDataSetFeedsEB.Value;
2171
            1: // Energie digestible (porc croissance)
2172
              Cumul := ClientDataSetFeedsEDc.Value;
2173
            2: // Energie digestible (porc adulte)
2174
              Cumul := ClientDataSetFeedsEDt.Value;
2175
            3: // Energie m?tabolisable (porc croissance)
2176
              Cumul := ClientDataSetFeedsEMc.Value;
2177
            4: // Energie m?tabolisable (porc adulte)
2178
              Cumul := ClientDataSetFeedsEMt.Value;
2179
            5: // Energie nette (porc croissance)
2180
              Cumul := ClientDataSetFeedsENc.Value;
2181
            6: // Energie nette (porc adulte)
2182
              Cumul := ClientDataSetFeedsENt.Value;
2183
            else
2184
              Cumul := 0;
2185
          end;
2186
        2: // Acides amin?s totaux
2187
          case ComboBoxAA.ItemIndex of
2188
            0: // Lysine
2189
              Cumul := ClientDataSetFeedsLys.Value;
2190
            1: // Thr?onine
2191
              Cumul := ClientDataSetFeedsThr.Value;
2192
            2: // M?thionine
2193
              Cumul := ClientDataSetFeedsMet.Value;
2194
            3: // Cyst?ine
2195
              Cumul := ClientDataSetFeedsCys.Value;
2196
            4: // M?thionine + Cyst?ine
2197
              Cumul := ClientDataSetFeedsMetCys.Value;
2198
            5: // Tryptophane
2199
              Cumul := ClientDataSetFeedsTrp.Value;
2200
            6: // Isoleucine
2201
              Cumul := ClientDataSetFeedsIle.Value;
2202
            7: // Valine
2203
              Cumul := ClientDataSetFeedsVal.Value;
2204
            8: // Leucine
2205
              Cumul := ClientDataSetFeedsLeu.Value;
2206
            9: // Ph?nylalanine
2207
              Cumul := ClientDataSetFeedsPhe.Value;
2208
            10: // Tyrosine
2209
              Cumul := ClientDataSetFeedsTyr.Value;
2210
            11: // Ph?nylalanine + Tyrosine
2211
              Cumul := ClientDataSetFeedsPheTyr.Value;
2212
            12: // Histidine
2213
              Cumul := ClientDataSetFeedsHis.Value;
2214
            13: // Arginine
2215
              Cumul := ClientDataSetFeedsArg.Value;
2216
            14: // Alanine
2217
              Cumul := ClientDataSetFeedsAla.Value;
2218
            15: // Aspartate
2219
              Cumul := ClientDataSetFeedsAsp.Value;
2220
            16: // Glutamate
2221
              Cumul := ClientDataSetFeedsGlu.Value;
2222
            17: // Glycine
2223
              Cumul := ClientDataSetFeedsGly.Value;
2224
            18: // S?rine
2225
              Cumul := ClientDataSetFeedsSer.Value;
2226
            19: // Proline
2227
              Cumul := ClientDataSetFeedsPro.Value;
2228
            else
2229
              Cumul := 0;
2230
          end;
2231
        3: // Acides amin?s digestibles
2232
          case ComboBoxAA.ItemIndex of
2233
            0: // Lysine
2234
              Cumul := ClientDataSetFeedsLysd.Value;
2235
            1: // Thr?onine
2236
              Cumul := ClientDataSetFeedsThrd.Value;
2237
            2: // M?thionine
2238
              Cumul := ClientDataSetFeedsMetd.Value;
2239
            3: // Cyst?ine
2240
              Cumul := ClientDataSetFeedsCysd.Value;
2241
            4: // M?thionine + Cyst?ine
2242
              Cumul := ClientDataSetFeedsMetCysd.Value;
2243
            5: // Tryptophane
2244
              Cumul := ClientDataSetFeedsTrpd.Value;
2245
            6: // Isoleucine
2246
              Cumul := ClientDataSetFeedsIled.Value;
2247
            7: // Valine
2248
              Cumul := ClientDataSetFeedsVald.Value;
2249
            8: // Leucine
2250
              Cumul := ClientDataSetFeedsLeud.Value;
2251
            9: // Ph?nylalanine
2252
              Cumul := ClientDataSetFeedsPhed.Value;
2253
            10: // Tyrosine
2254
              Cumul := ClientDataSetFeedsTyrd.Value;
2255
            11: // Ph?nylalanine + Tyrosine
2256
              Cumul := ClientDataSetFeedsPheTyrd.Value;
2257
            12: // Histidine
2258
              Cumul := ClientDataSetFeedsHisd.Value;
2259
            13: // Arginine
2260
              Cumul := ClientDataSetFeedsArgd.Value;
2261
            14: // Alanine
2262
              Cumul := ClientDataSetFeedsAlad.Value;
2263
            15: // Aspartate
2264
              Cumul := ClientDataSetFeedsAspd.Value;
2265
            16: // Glutamate
2266
              Cumul := ClientDataSetFeedsGlud.Value;
2267
            17: // Glycine
2268
              Cumul := ClientDataSetFeedsGlyd.Value;
2269
            18: // S?rine
2270
              Cumul := ClientDataSetFeedsSerd.Value;
2271
            19: // Proline
2272
              Cumul := ClientDataSetFeedsProd.Value;
2273
            else
2274
              Cumul := 0;
2275
          end;
2276
        4: // Min?raux
2277
          case ComboBoxMinerals.ItemIndex of
2278
            0: // Calcium
2279
              Cumul := ClientDataSetFeedsCa.Value;
2280
            1: // Phosphore
2281
              Cumul := ClientDataSetFeedsP.Value;
2282
            2: // Phosphore digestible
2283
              Cumul := ClientDataSetFeedsPd.Value;
2284
            else
2285
              Cumul := 0;
2286
          end;
2287
        else
2288
          Cumul := 0;
2289
      end;
2290
      if Cumul = 0
2291
      then // Division par z?ro
2292
        Cumul := 1;
2293
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
2294
      ClientDataSetComposition.Filtered := True;
2295
      ClientDataSetComposition.First;
2296
      Total := 0;
2297
      while not ClientDataSetComposition.Eof do
2298
      begin
2299
        if ClientDataSetCompositionUser.Value
2300
        then
2301
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
2302
        else
2303
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
2304
        ClientDataSetIngredients.Filtered := True;
2305
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
2306
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
2307
        if (FormOptions.Expression = 0)
2308
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2309
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
2310
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
2311
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
2312
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2313
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
2314
          Ratio := Ratio * RapMS;
2315
        case ComboBoxType.ItemIndex of
2316
          0: // Analyse proximale
2317
            case ComboBoxProximal.ItemIndex of
2318
              0: // Composition
2319
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
2320
              1: // MS
2321
                Value := ClientDataSetCompositionMS.Value * Ratio;
2322
              2: // MM
2323
                Value := ClientDataSetIngredientsMM.Value * Ratio;
2324
              3: // MAT
2325
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
2326
              4: // MG
2327
                Value := ClientDataSetIngredientsMG.Value * Ratio;
2328
              5: // CB
2329
                Value := ClientDataSetIngredientsCB.Value * Ratio;
2330
              6: // NDF
2331
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
2332
              7: // ADF
2333
                Value := ClientDataSetIngredientsADF.Value * Ratio;
2334
              8: // ADL
2335
                Value := ClientDataSetIngredientsADL.Value * Ratio;
2336
              9: // Amidon
2337
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
2338
              10: // Sucres
2339
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
2340
              else
2341
                Value := 0;
2342
            end;
2343
          1: // Valeurs ?nerg?tiques
2344
            case ComboBoxEnergy.ItemIndex of
2345
              0: // Energie brute
2346
                Value := ClientDataSetIngredientsEB.Value * Ratio;
2347
              1: // Energie digestible (porc croissance)
2348
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
2349
              2: // Energie digestible (porc adulte)
2350
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
2351
              3: // Energie m?tabolisable (porc croissance)
2352
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
2353
              4: // Energie m?tabolisable (porc adulte)
2354
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
2355
              5: // Energie nette (porc croissance)
2356
                Value := ClientDataSetIngredientsENc.Value * Ratio;
2357
              6: // Energie nette (porc adulte)
2358
                Value := ClientDataSetIngredientsENt.Value * Ratio;
2359
              else
2360
                Value := 0;
2361
            end;
2362
          2: // Acides amin?s totaux
2363
            case ComboBoxAA.ItemIndex of
2364
              0: // Lysine
2365
                Value := ClientDataSetIngredientsLys.Value * Ratio;
2366
              1: // Thr?onine
2367
                Value := ClientDataSetIngredientsThr.Value * Ratio;
2368
              2: // M?thionine
2369
                Value := ClientDataSetIngredientsMet.Value * Ratio;
2370
              3: // Cyst?ine
2371
                Value := ClientDataSetIngredientsCys.Value * Ratio;
2372
              4: // M?thionine + Cyst?ine
2373
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
2374
              5: // Tryptophane
2375
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
2376
              6: // Isoleucine
2377
                Value := ClientDataSetIngredientsIle.Value * Ratio;
2378
              7: // Valine
2379
                Value := ClientDataSetIngredientsVal.Value * Ratio;
2380
              8: // Leucine
2381
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
2382
              9: // Ph?nylalanine
2383
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
2384
              10: // Tyrosine
2385
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
2386
              11: // Ph?nylalanine + Tyrosine
2387
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
2388
              12: // Histidine
2389
                Value := ClientDataSetIngredientsHis.Value * Ratio;
2390
              13: // Arginine
2391
                Value := ClientDataSetIngredientsArg.Value * Ratio;
2392
              14: // Alanine
2393
                Value := ClientDataSetIngredientsAla.Value * Ratio;
2394
              15: // Aspartate
2395
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
2396
              16: // Glutamate
2397
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
2398
              17: // Glycine
2399
                Value := ClientDataSetIngredientsGly.Value * Ratio;
2400
              18: // S?rine
2401
                Value := ClientDataSetIngredientsSer.Value * Ratio;
2402
              19: // Proline
2403
                Value := ClientDataSetIngredientsPro.Value * Ratio;
2404
              else
2405
                Value := 0;
2406
            end;
2407
          3: // Acides amin?s digestibles
2408
            case ComboBoxAA.ItemIndex of
2409
              0: // Lysine
2410
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
2411
              1: // Thr?onine
2412
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
2413
              2: // M?thionine
2414
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
2415
              3: // Cyst?ine
2416
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
2417
              4: // M?thionine + Cyst?ine
2418
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
2419
              5: // Tryptophane
2420
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
2421
              6: // Isoleucine
2422
                Value := ClientDataSetIngredientsIled.Value * Ratio;
2423
              7: // Valine
2424
                Value := ClientDataSetIngredientsVald.Value * Ratio;
2425
              8: // Leucine
2426
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
2427
              9: // Ph?nylalanine
2428
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
2429
              10: // Tyrosine
2430
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
2431
              11: // Ph?nylalanine + Tyrosine
2432
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
2433
              12: // Histidine
2434
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
2435
              13: // Arginine
2436
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
2437
              14: // Alanine
2438
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
2439
              15: // Aspartate
2440
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
2441
              16: // Glutamate
2442
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
2443
              17: // Glycine
2444
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
2445
              18: // S?rine
2446
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
2447
              19: // Proline
2448
                Value := ClientDataSetIngredientsProd.Value * Ratio;
2449
              else
2450
                Value := 0;
2451
            end;
2452
          4: // Min?raux
2453
            case ComboBoxMinerals.ItemIndex of
2454
              0: // Calcium
2455
                Value := ClientDataSetIngredientsCa.Value * Ratio;
2456
              1: // Phosphore
2457
                Value := ClientDataSetIngredientsP.Value * Ratio;
2458
              2: // Phosphore digestible
2459
                if ClientDataSetFeedsPresentation.Value = 0
2460
                then // Farine (dPphy)
2461
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
2462
                else // Granul?s (dP)
2463
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
2464
              else
2465
                Value := 0;
2466
            end;
2467
          else
2468
            Value := 0;
2469
        end;
2470
        if (FormOptions.Expression = 1)
2471
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2472
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
2473
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
2474
        if Value > 0
2475
        then // Prendre en compte la valeur
2476
        begin
2477
          FeedBar := TBarSeries.Create(ChartFeed4);
2478
          FeedBar.ParentChart := ChartFeed4;
2479
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
2480
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
2481
          FeedBar.MultiBar := mbStacked100;
2482
          FeedBar.Marks.Visible := False;
2483
          ChartFeed4.AddSeries(FeedBar);
2484
          FeedBar.AddBar(Value, '', clTeeColor);
2485
          Total := Total + Value;
2486
        end;
2487
        ClientDataSetComposition.Next;
2488
      end;
2489
      ClientDataSetIngredients.Filtered := False;
2490
      ClientDataSetIngredients.Filter := '';
2491
      // Cas particuliers
2492
      if (ComboBoxType.ItemIndex = 1)
2493
      and ((ComboBoxEnergy.ItemIndex = 1)
2494
        or (ComboBoxEnergy.ItemIndex = 3)
2495
        or (ComboBoxEnergy.ItemIndex = 5))
2496
      and (ClientDataSetFeedsBonusC.Value > 0)
2497
      then // Bonus ?nergie (porc croissance)
2498
      begin
2499
        case ComboBoxEnergy.ItemIndex of
2500
          1: Value := ClientDataSetFeedsEDc.Value - Total;
2501
          3: Value := ClientDataSetFeedsEMc.Value - Total;
2502
          5: Value := ClientDataSetFeedsENc.Value - Total;
2503
          else Value := 0;
2504
        end;
2505
        FeedBar := TBarSeries.Create(ChartFeed4);
2506
        FeedBar.ParentChart := ChartFeed4;
2507
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2508
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2509
        FeedBar.MultiBar := mbStacked100;
2510
        FeedBar.Marks.Visible := False;
2511
        ChartFeed4.AddSeries(FeedBar);
2512
        FeedBar.AddBar(Value, '', clTeeColor);
2513
        Total := Total + Value;
2514
      end;
2515
      if (ComboBoxType.ItemIndex = 1)
2516
      and ((ComboBoxEnergy.ItemIndex = 2)
2517
        or (ComboBoxEnergy.ItemIndex = 4)
2518
        or (ComboBoxEnergy.ItemIndex = 6))
2519
      and (ClientDataSetFeedsBonusT.Value > 0)
2520
      then // Bonus ?nergie (porc adulte)
2521
      begin
2522
        case ComboBoxEnergy.ItemIndex of
2523
          2: Value := ClientDataSetFeedsEDt.Value - Total;
2524
          4: Value := ClientDataSetFeedsEMt.Value - Total;
2525
          6: Value := ClientDataSetFeedsENt.Value - Total;
2526
          else Value := 0;
2527
        end;
2528
        FeedBar := TBarSeries.Create(ChartFeed4);
2529
        FeedBar.ParentChart := ChartFeed4;
2530
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2531
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2532
        FeedBar.MultiBar := mbStacked100;
2533
        FeedBar.Marks.Visible := False;
2534
        ChartFeed4.AddSeries(FeedBar);
2535
        FeedBar.AddBar(Value, '', clTeeColor);
2536
        Total := Total + Value;
2537
      end;
2538
      if (ComboBoxType.ItemIndex = 0)
2539
      and (ComboBoxProximal.ItemIndex = 0)
2540
      and not ClientDataSetFeedsPhytaseId.IsNull
2541
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
2542
      then // Phytase (taux d'incorporation)
2543
      begin
2544
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
2545
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
2546
        FeedBar := TBarSeries.Create(ChartFeed4);
2547
        FeedBar.ParentChart := ChartFeed4;
2548
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2549
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2550
        FeedBar.MultiBar := mbStacked100;
2551
        FeedBar.Marks.Visible := False;
2552
        ChartFeed4.AddSeries(FeedBar);
2553
        FeedBar.AddBar(Value, '', clTeeColor);
2554
        Total := Total + Value;
2555
      end;
2556
      if (ComboBoxType.ItemIndex = 4)
2557
      and (ComboBoxMinerals.ItemIndex = 2)
2558
      and not ClientDataSetFeedsPhytaseId.IsNull
2559
      and (ClientDataSetFeedsPd.Value > Total)
2560
      then // Phytase (Phosphore digestible)
2561
      begin
2562
        Value := ClientDataSetFeedsPd.Value - Total;
2563
        FeedBar := TBarSeries.Create(ChartFeed4);
2564
        FeedBar.ParentChart := ChartFeed4;
2565
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2566
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2567
        FeedBar.MultiBar := mbStacked100;
2568
        FeedBar.Marks.Visible := False;
2569
        ChartFeed4.AddSeries(FeedBar);
2570
        FeedBar.AddBar(Value, '', clTeeColor);
2571
        Total := Total + Value;
2572
      end;
2573
      // Total
2574
      case ComboBoxType.ItemIndex of
2575
        0: // Analyse proximale
2576
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
2577
          then // sur frais
2578
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
2579
          else // sur mati?re s?che - except? pour Composition et MS
2580
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
2581
        1: // Valeurs ?nerg?tiques
2582
          if FormOptions.Expression = 0
2583
          then // sur frais
2584
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
2585
          else // sur mati?re s?che
2586
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
2587
        2, 3: // Acides amin?s
2588
          if FormOptions.Expression = 0
2589
          then // sur frais
2590
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
2591
          else // sur mati?re s?che
2592
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
2593
        4: // Min?raux
2594
          if FormOptions.Expression = 0
2595
          then // sur frais
2596
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
2597
          else // sur mati?re s?che
2598
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
2599
      end;
2600
      ClientDataSetComposition.Filtered := False;
2601
      ClientDataSetComposition.Filter := '';
2602
    end;
2603
end;
2604

    
2605
procedure TFormFeedsCharts.ComboBoxOption0Change(Sender: TObject);
2606
begin
2607
  ComboBoxDietChange(nil);
2608
end;
2609

    
2610
procedure TFormFeedsCharts.ComboBoxOptionChange(Sender: TObject);
2611
begin
2612
  ComboBoxFeed1Change(nil);
2613
  ComboBoxFeed2Change(nil);
2614
  ComboBoxFeed3Change(nil);
2615
  ComboBoxFeed4Change(nil);
2616
end;
2617

    
2618
procedure TFormFeedsCharts.ComboBoxType0Change(Sender: TObject);
2619
begin
2620
  ComboBoxProximal0.Visible := False;
2621
  ComboBoxEnergy0.Visible := False;
2622
  ComboBoxRatios0.Visible := False;
2623
  ComboBoxAA0.Visible := False;
2624
  ComboBoxMinerals0.Visible := False;
2625
  case ComboBoxType0.ItemIndex of
2626
    0: // Analyse proximale
2627
      ComboBoxProximal0.Visible := True;
2628
    1: // Valeurs ?nerg?tiques
2629
      ComboBoxEnergy0.Visible := True;
2630
    2: // Rapports ?nerg?tiques
2631
      ComboBoxRatios0.Visible := True;
2632
    3, 4, 5: // Acides amin?s
2633
      ComboBoxAA0.Visible := True;
2634
    6: // Min?raux
2635
      ComboBoxMinerals0.Visible := True;
2636
  end;
2637
  ComboBoxOption0Change(nil);
2638
end;
2639

    
2640
procedure TFormFeedsCharts.ComboBoxTypeChange(Sender: TObject);
2641
begin
2642
  ComboBoxProximal.Visible := False;
2643
  ComboBoxEnergy.Visible := False;
2644
  ComboBoxAA.Visible := False;
2645
  ComboBoxMinerals.Visible := False;
2646
  case ComboBoxType.ItemIndex of
2647
    0: // Analyse proximale
2648
      ComboBoxProximal.Visible := True;
2649
    1: // Valeurs ?nerg?tiques
2650
      ComboBoxEnergy.Visible := True;
2651
    2, 3: // Acides amin?s
2652
      ComboBoxAA.Visible := True;
2653
    4: // Min?raux
2654
      ComboBoxMinerals.Visible := True;
2655
  end;
2656
  ComboBoxOptionChange(nil);
2657
end;
2658

    
2659
procedure TFormFeedsCharts.FormCreate(Sender: TObject);
2660
begin
2661
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
2662
  then
2663
  begin
2664
    Font.Name := 'Arial Unicode MS';
2665
    SetChartFont(Chart0, 'Arial Unicode MS');
2666
    SeriesBar.Marks.Font.Name := 'Arial Unicode MS';
2667
    SetChartFont(ChartFeed1, 'Arial Unicode MS');
2668
    SetChartFont(ChartFeed2, 'Arial Unicode MS');
2669
    SetChartFont(ChartFeed3, 'Arial Unicode MS');
2670
    SetChartFont(ChartFeed4, 'Arial Unicode MS');
2671
  end;
2672
//  PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
2673
  PanelButtons.Font.Style := [fsBold];
2674
  TranslateComponent(Self);
2675
  // S?lection des ?l?ments par d?faut apr?s traduction des listes
2676
  ComboBoxType0.ItemIndex := 0;
2677
  ComboBoxProximal0.ItemIndex := 0;
2678
  ComboBoxEnergy0.ItemIndex := 0;
2679
  ComboBoxRatios0.ItemIndex := 0;
2680
  ComboBoxAA0.ItemIndex := 0;
2681
  ComboBoxMinerals0.ItemIndex := 0;
2682
  ComboBoxDiet1.Items.Assign(DataModuleDeclaration.FeedList);
2683
  ComboBoxDiet2.Items.Assign(DataModuleDeclaration.FeedList);
2684
  ComboBoxDiet3.Items.Assign(DataModuleDeclaration.FeedList);
2685
  ComboBoxDiet4.Items.Assign(DataModuleDeclaration.FeedList);
2686
  ComboBoxDiet5.Items.Assign(DataModuleDeclaration.FeedList);
2687
  ComboBoxDiet6.Items.Assign(DataModuleDeclaration.FeedList);
2688
  Chart0.Title.Clear;
2689
  Chart0.SubTitle.Clear;
2690
  ComboBoxType.ItemIndex := 0;
2691
  ComboBoxProximal.ItemIndex := 0;
2692
  ComboBoxEnergy.ItemIndex := 0;
2693
  ComboBoxAA.ItemIndex := 0;
2694
  ComboBoxMinerals.ItemIndex := 0;
2695
  ComboBoxFeed1.Items.Assign(DataModuleDeclaration.FeedList);
2696
  ChartFeed1.Title.Clear;
2697
  ChartFeed1.SubTitle.Clear;
2698
  ComboBoxFeed2.Items.Assign(DataModuleDeclaration.FeedList);
2699
  ChartFeed2.Title.Clear;
2700
  ChartFeed2.SubTitle.Clear;
2701
  ComboBoxFeed3.Items.Assign(DataModuleDeclaration.FeedList);
2702
  ChartFeed3.Title.Clear;
2703
  ChartFeed3.SubTitle.Clear;
2704
  ComboBoxFeed4.Items.Assign(DataModuleDeclaration.FeedList);
2705
  ChartFeed4.Title.Clear;
2706
  ChartFeed4.SubTitle.Clear;
2707
end;
2708

    
2709
procedure TFormFeedsCharts.FormResize(Sender: TObject);
2710
var
2711
  W, H: Integer;
2712
begin
2713
  W := TabSheetChartsComparison.Width div 2;
2714
  H := (TabSheetChartsComparison.Height - GroupBoxChartSelection.Height) div 2;
2715
  GroupBoxFeed1.SetBounds(0, GroupBoxChartSelection.Height, W, H);
2716
  GroupBoxFeed2.SetBounds(W, GroupBoxChartSelection.Height, W, H);
2717
  GroupBoxFeed3.SetBounds(0, GroupBoxChartSelection.Height + H, W, H);
2718
  GroupBoxFeed4.SetBounds(W, GroupBoxChartSelection.Height + H, W, H);
2719
end;
2720

    
2721
procedure TFormFeedsCharts.SpeedButton2D3D0Click(Sender: TObject);
2722
begin
2723
  Chart0.View3D := not Chart0.View3D;
2724
  if Chart0.View3D
2725
  then
2726
    SeriesBar.Marks.ArrowLength := 8
2727
  else
2728
    SeriesBar.Marks.ArrowLength := 0;
2729
  if Chart0.View3D
2730
  then
2731
    SpeedButton2D3D0.Caption := _('2D')
2732
  else
2733
    SpeedButton2D3D0.Caption := _('3D');
2734
end;
2735

    
2736
procedure TFormFeedsCharts.SpeedButton2D3D1Click(Sender: TObject);
2737
begin
2738
  ChartFeed1.View3D := not ChartFeed1.View3D;
2739
  if ChartFeed1.View3D
2740
  then
2741
    SpeedButton2D3D1.Caption := _('2D')
2742
  else
2743
    SpeedButton2D3D1.Caption := _('3D');
2744
end;
2745

    
2746
procedure TFormFeedsCharts.SpeedButton2D3D2Click(Sender: TObject);
2747
begin
2748
  ChartFeed2.View3D := not ChartFeed2.View3D;
2749
  if ChartFeed2.View3D
2750
  then
2751
    SpeedButton2D3D2.Caption := _('2D')
2752
  else
2753
    SpeedButton2D3D2.Caption := _('3D');
2754
end;
2755

    
2756
procedure TFormFeedsCharts.SpeedButton2D3D3Click(Sender: TObject);
2757
begin
2758
  ChartFeed3.View3D := not ChartFeed3.View3D;
2759
  if ChartFeed3.View3D
2760
  then
2761
    SpeedButton2D3D3.Caption := _('2D')
2762
  else
2763
    SpeedButton2D3D3.Caption := _('3D');
2764
end;
2765

    
2766
procedure TFormFeedsCharts.SpeedButton2D3D4Click(Sender: TObject);
2767
begin
2768
  ChartFeed4.View3D := not ChartFeed4.View3D;
2769
  if ChartFeed4.View3D
2770
  then
2771
    SpeedButton2D3D4.Caption := _('2D')
2772
  else
2773
    SpeedButton2D3D4.Caption := _('3D');
2774
end;
2775

    
2776
procedure TFormFeedsCharts.SpeedButtonPrint0Click(Sender: TObject);
2777
begin
2778
  FormChartHReport := TFormChartHReport.Create(nil);
2779
  try
2780
    FormChartHReport.QRChart1.Chart.View3D := Chart0.View3D;
2781
    FormChartHReport.QRChart1.Chart.Title.Assign(Chart0.Title);
2782
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(Chart0.SubTitle);
2783
    FormChartHReport.QRChart1.Chart.Legend.Visible := False;
2784
    CloneChartSeries(SeriesBar).ParentChart := FormChartHReport.QRChart1.Chart;
2785
    FormChartHReport.QuickRepChart.PrinterSetup;
2786
    if FormChartHReport.QuickRepChart.Tag = 0
2787
    then
2788
      FormChartHReport.QuickRepChart.Print;
2789
  finally
2790
    FormChartHReport.Release;
2791
  end;
2792
end;
2793

    
2794
procedure TFormFeedsCharts.SpeedButtonPrint1Click(Sender: TObject);
2795
var
2796
  i: Integer;
2797
begin
2798
  FormChartHReport := TFormChartHReport.Create(nil);
2799
  try
2800
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed1.View3D;
2801
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed1.Title);
2802
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed1.SubTitle);
2803
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2804
    for i := 0 to ChartFeed1.SeriesCount - 1 do
2805
      CloneChartSeries(ChartFeed1[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2806
    FormChartHReport.QuickRepChart.PrinterSetup;
2807
    if FormChartHReport.QuickRepChart.Tag = 0
2808
    then
2809
      FormChartHReport.QuickRepChart.Print;
2810
  finally
2811
    FormChartHReport.Release;
2812
  end;
2813
end;
2814

    
2815
procedure TFormFeedsCharts.SpeedButtonPrint2Click(Sender: TObject);
2816
var
2817
  i: Integer;
2818
begin
2819
  FormChartHReport := TFormChartHReport.Create(nil);
2820
  try
2821
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed2.View3D;
2822
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed2.Title);
2823
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed2.SubTitle);
2824
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2825
    for i := 0 to ChartFeed2.SeriesCount - 1 do
2826
      CloneChartSeries(ChartFeed2[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2827
    FormChartHReport.QuickRepChart.PrinterSetup;
2828
    if FormChartHReport.QuickRepChart.Tag = 0
2829
    then
2830
      FormChartHReport.QuickRepChart.Print;
2831
  finally
2832
    FormChartHReport.Release;
2833
    Screen.Cursor := crDefault;
2834
  end;
2835
end;
2836

    
2837
procedure TFormFeedsCharts.SpeedButtonPrint3Click(Sender: TObject);
2838
var
2839
  i: Integer;
2840
begin
2841
  FormChartHReport := TFormChartHReport.Create(nil);
2842
  try
2843
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed3.View3D;
2844
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed3.Title);
2845
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed3.SubTitle);
2846
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2847
    for i := 0 to ChartFeed3.SeriesCount - 1 do
2848
      CloneChartSeries(ChartFeed3[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2849
    FormChartHReport.QuickRepChart.PrinterSetup;
2850
    if FormChartHReport.QuickRepChart.Tag = 0
2851
    then
2852
      FormChartHReport.QuickRepChart.Print;
2853
  finally
2854
    FormChartHReport.Release;
2855
    Screen.Cursor := crDefault;
2856
  end;
2857
end;
2858

    
2859
procedure TFormFeedsCharts.SpeedButtonPrint4Click(Sender: TObject);
2860
var
2861
  i: Integer;
2862
begin
2863
  FormChartHReport := TFormChartHReport.Create(nil);
2864
  try
2865
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed4.View3D;
2866
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed4.Title);
2867
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed4.SubTitle);
2868
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2869
    for i := 0 to ChartFeed4.SeriesCount - 1 do
2870
      CloneChartSeries(ChartFeed4[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2871
    FormChartHReport.QuickRepChart.PrinterSetup;
2872
    if FormChartHReport.QuickRepChart.Tag = 0
2873
    then
2874
      FormChartHReport.QuickRepChart.Print;
2875
  finally
2876
    FormChartHReport.Release;
2877
  end;
2878
end;
2879

    
2880
procedure TFormFeedsCharts.WMSysCommand(var Message: TWMSysCommand);
2881
begin
2882
  if Message.CmdType = SC_MINIMIZE
2883
  then
2884
    Application.Minimize
2885
  else
2886
    inherited;
2887
end;
2888

    
2889
end.