root / UFGraph3D.pas @ 3
Historique | Voir | Annoter | Télécharger (20,928 ko)
1 |
unit UFGraph3D;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Forms, Classes, Controls, Messages, ComCtrls, StdCtrls, ExtCtrls, |
7 |
Grids, Chart, Series, TeeProcs, TeEngine, TeePoin3, TeeSurfa, PBNumEdit, |
8 |
PBSuperSpin, JvExControls, JvxSlider, UVariables; |
9 |
|
10 |
type
|
11 |
TFGraph3D = class(TForm)
|
12 |
Chart3D: TChart; |
13 |
SeriesAdLib: TPoint3DSeries; |
14 |
PanelData: TPanel; |
15 |
GroupBoxX: TGroupBox; |
16 |
GroupBoxY: TGroupBox; |
17 |
GroupBoxZ: TGroupBox; |
18 |
ComboBoxX: TComboBox; |
19 |
ComboBoxY: TComboBox; |
20 |
ComboBoxZ: TComboBox; |
21 |
SliderRotation: TJvxSlider; |
22 |
Panel3D: TPanel; |
23 |
SliderElevation: TJvxSlider; |
24 |
SliderPerspective: TJvxSlider; |
25 |
SliderZoom: TJvxSlider; |
26 |
GroupBoxAdLib: TGroupBox; |
27 |
LabelA: TLabel; |
28 |
LabelUnite: TLabel; |
29 |
LabelEquation: TLabel; |
30 |
LabelB: TLabel; |
31 |
SuperSpinA: TPBSuperSpin; |
32 |
SuperSpinB: TPBSuperSpin; |
33 |
GroupBoxPotential: TGroupBox; |
34 |
LabelEntretien: TLabel; |
35 |
LabelPrecocite: TLabel; |
36 |
LabelPDMoy: TLabel; |
37 |
SuperSpinPDMoy: TPBSuperSpin; |
38 |
SuperSpinPrecocite: TPBSuperSpin; |
39 |
SuperSpinEntretien: TPBSuperSpin; |
40 |
LabelPVPDmax: TLabel; |
41 |
SuperSpinPVPDmax: TPBSuperSpin; |
42 |
GroupBoxType: TGroupBox; |
43 |
RadioButton2D: TRadioButton; |
44 |
RadioButton3D: TRadioButton; |
45 |
GroupBoxResult: TGroupBox; |
46 |
StringGridResult: TStringGrid; |
47 |
Panel2D: TPanel; |
48 |
TrackBarJour: TTrackBar; |
49 |
Chart2D: TChart; |
50 |
SeriesCourbePD: TLineSeries; |
51 |
SeriesLimitePD: TLineSeries; |
52 |
SeriesPointPD: TLineSeries; |
53 |
SeriesDroitePD: TLineSeries; |
54 |
SeriesCourbeLD: TLineSeries; |
55 |
SeriesPointLD: TLineSeries; |
56 |
SeriesDroiteLD: TLineSeries; |
57 |
LabelLimitPD2D: TLabel; |
58 |
SeriesSurface: TSurfaceSeries; |
59 |
SeriesRation: TPoint3DSeries; |
60 |
EditUnit: TEdit; |
61 |
EditEquation: TEdit; |
62 |
LabelLimitPD3D: TLabel; |
63 |
SeriesPointPDAdLib: TLineSeries; |
64 |
SeriesPointLDAdLib: TLineSeries; |
65 |
procedure FormShow(Sender: TObject);
|
66 |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
67 |
procedure ComboBoxXChange(Sender: TObject);
|
68 |
procedure ComboBoxYChange(Sender: TObject);
|
69 |
procedure ComboBoxZChange(Sender: TObject);
|
70 |
procedure SliderRotationChange(Sender: TObject);
|
71 |
procedure SliderElevationChange(Sender: TObject);
|
72 |
procedure SliderPerspectiveChange(Sender: TObject);
|
73 |
procedure SliderZoomChange(Sender: TObject);
|
74 |
procedure RadioButton2DClick(Sender: TObject);
|
75 |
procedure RadioButton3DClick(Sender: TObject);
|
76 |
procedure SuperSpinAChange(Sender: TObject);
|
77 |
procedure SuperSpinBChange(Sender: TObject);
|
78 |
procedure SuperSpinPDMoyChange(Sender: TObject);
|
79 |
procedure SuperSpinPrecociteChange(Sender: TObject);
|
80 |
procedure SuperSpinEntretienChange(Sender: TObject);
|
81 |
procedure SuperSpinPVPDmaxChange(Sender: TObject);
|
82 |
procedure StringGridResultDrawCell(Sender: TObject; ACol,
|
83 |
ARow: Integer; Rect: TRect; State: TGridDrawState); |
84 |
procedure StringGridResultMouseMove(Sender: TObject;
|
85 |
Shift: TShiftState; X, Y: Integer); |
86 |
procedure TrackBarJourChange(Sender: TObject);
|
87 |
procedure FormCreate(Sender: TObject);
|
88 |
procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND; |
89 |
private
|
90 |
{ D?clarations priv?es }
|
91 |
Update : boolean ; |
92 |
PResSimulP: PTabResSimulP; |
93 |
procedure AfficheSimulation;
|
94 |
procedure AfficheResult;
|
95 |
procedure AfficheGraph2D;
|
96 |
procedure AfficheGraph3D;
|
97 |
public
|
98 |
{ D?clarations publiques }
|
99 |
end;
|
100 |
|
101 |
var
|
102 |
FGraph3D: TFGraph3D; |
103 |
|
104 |
implementation
|
105 |
|
106 |
uses
|
107 |
Graphics, Math, SysUtils, gnugettext, UCalcSimulP, UStrings, UFProfilP; |
108 |
|
109 |
{$R *.dfm}
|
110 |
|
111 |
procedure TFGraph3D.FormCreate(Sender: TObject);
|
112 |
begin
|
113 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
114 |
then
|
115 |
Font.Name := 'Arial Unicode MS';
|
116 |
TranslateComponent(Self); |
117 |
Constraints.MinWidth := 184 + (Width - ClientWidth);
|
118 |
Width := 800;
|
119 |
Constraints.MinHeight := 528 + (Height - ClientHeight);
|
120 |
Height := 600;
|
121 |
ComboBoxX.ItemIndex := 0;
|
122 |
ComboBoxY.ItemIndex := 0;
|
123 |
ComboBoxZ.ItemIndex := 0;
|
124 |
end;
|
125 |
|
126 |
procedure TFGraph3D.FormShow(Sender: TObject);
|
127 |
begin
|
128 |
Update := True; |
129 |
EditUnit.Text := FProfilP.CBUnite.Text; |
130 |
EditEquation.Text := FProfilP.CBEquation.Text; |
131 |
SuperSpinA.Decimals := FProfilP.PBCoefA.Decimals; |
132 |
SuperSpinA.Increment := FProfilP.PBCoefA.Increment; |
133 |
SuperSpinA.AsFloat := FProfilP.PBCoefA.AsFloat; |
134 |
SuperSpinB.Decimals := FProfilP.PBCoefB.Decimals; |
135 |
SuperSpinB.Increment := FProfilP.PBCoefB.Increment; |
136 |
SuperSpinB.AsFloat := FProfilP.PBCoefB.AsFloat; |
137 |
SuperSpinPDMoy.AsFloat := FProfilP.PBPDMoy.AsFloat; |
138 |
SuperSpinPrecocite.AsFloat := FProfilP.PBComport.AsFloat; |
139 |
SuperSpinEntretien.AsFloat := FProfilP.PBEntretien.AsFloat; |
140 |
SuperSpinPVPDmax.AsFloat := FProfilP.PBPVmr2.AsFloat; |
141 |
Update := False; |
142 |
SliderRotation.Value := Chart3D.View3DOptions.Rotation; |
143 |
SliderElevation.Value := Chart3D.View3DOptions.Elevation; |
144 |
SliderPerspective.Value := Chart3D.View3DOptions.Perspective; |
145 |
SliderZoom.Value := Chart3D.View3DOptions.Zoom; |
146 |
New(PResSimulP); |
147 |
AfficheSimulation; |
148 |
end;
|
149 |
|
150 |
procedure TFGraph3D.FormClose(Sender: TObject; var Action: TCloseAction); |
151 |
begin
|
152 |
Dispose(PResSimulP); |
153 |
end;
|
154 |
|
155 |
procedure TFGraph3D.SuperSpinAChange(Sender: TObject);
|
156 |
begin
|
157 |
if not Update |
158 |
then
|
159 |
begin
|
160 |
PProfilP.a := SuperSpinA.AsFloat; |
161 |
AfficheSimulation; |
162 |
end;
|
163 |
end;
|
164 |
|
165 |
procedure TFGraph3D.SuperSpinBChange(Sender: TObject);
|
166 |
begin
|
167 |
if not Update |
168 |
then
|
169 |
begin
|
170 |
PProfilP.b := SuperSpinB.AsFloat; |
171 |
AfficheSimulation; |
172 |
end;
|
173 |
end;
|
174 |
|
175 |
procedure TFGraph3D.SuperSpinPDMoyChange(Sender: TObject);
|
176 |
begin
|
177 |
if not Update and (SuperSpinPDMoy.AsInteger >= SuperSpinPDMoy.MinValue) |
178 |
then
|
179 |
begin
|
180 |
PProfilP.PDMoy := SuperSpinPDMoy.AsFloat; |
181 |
AfficheSimulation; |
182 |
end;
|
183 |
end;
|
184 |
|
185 |
procedure TFGraph3D.SuperSpinPrecociteChange(Sender: TObject);
|
186 |
begin
|
187 |
if not Update and (SuperSpinPrecocite.AsFloat >= SuperSpinPrecocite.MinValue) |
188 |
then
|
189 |
begin
|
190 |
PProfilP.BGompertz := SuperSpinPrecocite.AsFloat; |
191 |
AfficheSimulation; |
192 |
end;
|
193 |
end;
|
194 |
|
195 |
procedure TFGraph3D.SuperSpinEntretienChange(Sender: TObject);
|
196 |
begin
|
197 |
if not Update and (SuperSpinEntretien.AsFloat >= SuperSpinEntretien.MinValue) |
198 |
then
|
199 |
begin
|
200 |
PProfilP.Entretien := SuperSpinEntretien.AsFloat; |
201 |
AfficheSimulation; |
202 |
end;
|
203 |
end;
|
204 |
|
205 |
procedure TFGraph3D.SuperSpinPVPDmaxChange(Sender: TObject);
|
206 |
begin
|
207 |
if not Update and (SuperSpinPVPDmax.AsFloat >= SuperSpinPVPDmax.MinValue) |
208 |
then
|
209 |
begin
|
210 |
PProfilP.PVmr2 := SuperSpinPVPDmax.AsFloat; |
211 |
AfficheSimulation; |
212 |
end;
|
213 |
end;
|
214 |
|
215 |
procedure TFGraph3D.RadioButton2DClick(Sender: TObject);
|
216 |
begin
|
217 |
GroupBoxX.Visible := False; |
218 |
GroupBoxY.Visible := False; |
219 |
GroupBoxZ.Visible := False; |
220 |
Panel3D.Visible := False; |
221 |
GroupBoxResult.Visible := True; |
222 |
Panel2D.Visible := True; |
223 |
AfficheResult; |
224 |
AfficheGraph2D; |
225 |
end;
|
226 |
|
227 |
procedure TFGraph3D.RadioButton3DClick(Sender: TObject);
|
228 |
begin
|
229 |
GroupBoxResult.Visible := False; |
230 |
Panel2D.Visible := False; |
231 |
GroupBoxX.Visible := True; |
232 |
GroupBoxY.Visible := True; |
233 |
GroupBoxZ.Visible := True; |
234 |
Panel3D.Visible := True; |
235 |
AfficheGraph3D; |
236 |
end;
|
237 |
|
238 |
procedure TFGraph3D.StringGridResultDrawCell(Sender: TObject; ACol,
|
239 |
ARow: Integer; Rect: TRect; State: TGridDrawState); |
240 |
begin
|
241 |
with (Sender as TStringGrid).Canvas do |
242 |
begin
|
243 |
if ACol = 0 |
244 |
then // Titre |
245 |
Brush.Color := clBtnFace |
246 |
else // Donn?es |
247 |
Brush.Color := clWhite; |
248 |
// Fond
|
249 |
FillRect(Rect); |
250 |
// Texte
|
251 |
Font.Color := clDefault; |
252 |
SetTextAlign(Handle, TA_CENTER); |
253 |
TextRect(Rect, Rect.Left + (Rect.Right - Rect.Left) div 2, Rect.Top + 2, (Sender as TStringGrid).Cells[ACol, ARow]); |
254 |
end;
|
255 |
end;
|
256 |
|
257 |
procedure TFGraph3D.StringGridResultMouseMove(Sender: TObject;
|
258 |
Shift: TShiftState; X, Y: Integer); |
259 |
var
|
260 |
Col, Lig: integer; |
261 |
Unite, s: String;
|
262 |
begin
|
263 |
(Sender as TStringGrid).MouseToCell(X, Y, Col, Lig);
|
264 |
// Unit?
|
265 |
case Lig of |
266 |
0: Unite := _('d'); |
267 |
1: Unite := _('kg'); |
268 |
3: Unite := Format('%s/%s', [_('kg'), _('d')]); |
269 |
4, 6, 8: Unite := Format('%s/%s', [_('g'), _('d')]); |
270 |
5, 7: Unite := Format('%s/%s %s', [_('g'), _('kg'), _('feed')]); |
271 |
2, 9: Unite := Format('x %s', [_('maintenance')]); |
272 |
else
|
273 |
Unite := '';
|
274 |
end;
|
275 |
// Hint
|
276 |
case Lig of |
277 |
0: s := Format('%s (%s)', [_('Age'), Unite]); |
278 |
1: s := Format('%s (%s)', [_('Body weight'), Unite]); |
279 |
2: s := Format('%s (%s)', [_('Net energy intake'), Unite]); |
280 |
3: s := Format('%s (%s)', [_('Feed intake'), Unite]); |
281 |
4: s := Format('%s (%s)', [_('Protein deposition'), Unite]); |
282 |
5: s := Format('%s (%s)', [_('Marginal protein deposition'), Unite]); |
283 |
6: s := Format('%s (%s)', [_('Lipid deposition'), Unite]); |
284 |
7: s := Format('%s (%s)', [_('Marginal lipid deposition'), Unite]); |
285 |
8: s := Format('%s (%s)', [_('Protein deposition at the plateau'), Unite]); |
286 |
9: s := Format('%s (%s)', [_('Feeding level required to attain the plateau'), Unite]); |
287 |
10: s := _('Fraction of net energy deposited as protein'); |
288 |
else
|
289 |
s := '';
|
290 |
end ;
|
291 |
if (Sender as TStringGrid).Hint <> s |
292 |
then // Changement de cellule |
293 |
begin
|
294 |
(Sender as TStringGrid).Hint := s;
|
295 |
Application.ActivateHint(Mouse.CursorPos); |
296 |
end ;
|
297 |
end;
|
298 |
|
299 |
procedure TFGraph3D.TrackBarJourChange(Sender: TObject);
|
300 |
begin
|
301 |
TrackBarJour.SelEnd := TrackBarJour.Position; |
302 |
AfficheResult; |
303 |
AfficheGraph2D; |
304 |
end;
|
305 |
|
306 |
procedure TFGraph3D.ComboBoxXChange(Sender: TObject);
|
307 |
begin
|
308 |
AfficheGraph3D; |
309 |
end;
|
310 |
|
311 |
procedure TFGraph3D.ComboBoxYChange(Sender: TObject);
|
312 |
begin
|
313 |
AfficheGraph3D; |
314 |
end;
|
315 |
|
316 |
procedure TFGraph3D.ComboBoxZChange(Sender: TObject);
|
317 |
begin
|
318 |
AfficheGraph3D; |
319 |
end;
|
320 |
|
321 |
procedure TFGraph3D.AfficheSimulation;
|
322 |
begin
|
323 |
// CalcSimulP(-1, -1, -1, -1, -1, 1, {1,} PResSimulP);
|
324 |
CalcSimulP(-1, PProfilP.Num, PProfilP.SeqAli, PProfilP.Ration, -1, 1, PResSimulP); |
325 |
TrackBarJour.Max := PResSimulP.NbJSim; |
326 |
if RadioButton2D.Checked
|
327 |
then
|
328 |
begin
|
329 |
AfficheResult; |
330 |
AfficheGraph2D; |
331 |
end
|
332 |
else
|
333 |
AfficheGraph3D; |
334 |
end;
|
335 |
|
336 |
procedure TFGraph3D.AfficheResult;
|
337 |
var
|
338 |
j: Integer; |
339 |
F, PDmaxE, a, b, px1, py1, PD, LD, NEmAL, NEcrois, PDLimit, PentePD, PenteLD, Correction: Double; |
340 |
begin
|
341 |
j := TrackBarJour.Position; |
342 |
F := PResSimulP.TabResult[52, j];
|
343 |
PDmaxE := PResSimulP.TabResult[69, j];
|
344 |
a := PResSimulP.TabResult[74, j];
|
345 |
b := PResSimulP.TabResult[75, j];
|
346 |
px1 := PResSimulP.TabResult[76, j];
|
347 |
py1 := PResSimulP.TabResult[77, j];
|
348 |
PD := PResSimulP.TabResult[79, j];
|
349 |
LD := PResSimulP.TabResult[80, j];
|
350 |
NEmAL := PResSimulP.TabResult[71, j];
|
351 |
NEcrois := PResSimulP.TabResult[90, j] * 1000; |
352 |
PDLimit := PResSimulP.TabResult[47, j];
|
353 |
if (px1 < F) and (PD < PDLimit) |
354 |
then
|
355 |
PentePD := (a + 2 * b * (px1 - 1)) / GEProtJaap |
356 |
else
|
357 |
PentePD := 0;
|
358 |
if px1 < F
|
359 |
then
|
360 |
Correction := LD / ((NEmAL * (px1 - 1) - (a * (px1 - 1) + b * Power (px1 - 1, 2)) * (1 + NEPD)) / ValEnergie[2, 2]) |
361 |
else
|
362 |
Correction := LD / ((NEmAL * (px1 - 1) - PDmaxE * (1 + NEPD)) / ValEnergie[2, 2]); |
363 |
if px1 < F
|
364 |
then
|
365 |
PenteLD := Correction * ((NEmAL - (a + 2 * b * (px1 - 1)) * (1 + NEPD)) / ValEnergie[2, 2]) |
366 |
else
|
367 |
PenteLD := Correction * (NEmAL / ValEnergie[2, 2]); |
368 |
// Titre
|
369 |
StringGridResult.Cells[0, 0] := StrAge; |
370 |
StringGridResult.Cells[0, 1] := StrPV; |
371 |
StringGridResult.Cells[0, 2] := StrEN; |
372 |
StringGridResult.Cells[0, 3] := StrIngere; |
373 |
StringGridResult.Cells[0, 4] := StrPD; |
374 |
StringGridResult.Cells[0, 5] := StrPDMarginal; |
375 |
StringGridResult.Cells[0, 6] := StrLD; |
376 |
StringGridResult.Cells[0, 7] := StrLDMarginal; |
377 |
StringGridResult.Cells[0, 8] := StrPDmax; |
378 |
StringGridResult.Cells[0, 9] := StrF; |
379 |
StringGridResult.Cells[0, 10] := StrX; |
380 |
// Valeurs
|
381 |
StringGridResult.Cells[1, 0] := FloatToStrF(PResSimulP.TabResult[1, j], ffFixed, 15, 0); |
382 |
StringGridResult.Cells[1, 1] := FloatToStrF(PResSimulP.TabResult[2, j], ffFixed, 15, 1); |
383 |
StringGridResult.Cells[1, 2] := FloatToStrF(px1, ffFixed, 15, 2); |
384 |
StringGridResult.Cells[1, 3] := FloatToStrF(px1 * (NEmAL / NEcrois), ffFixed, 15, 2); |
385 |
StringGridResult.Cells[1, 4] := FloatToStrF(PD, ffFixed, 15, 1); |
386 |
StringGridResult.Cells[1, 5] := FloatToStrF(PentePD / (NEmAL / NEcrois), ffFixed, 15, 1); |
387 |
StringGridResult.Cells[1, 6] := FloatToStrF(LD, ffFixed, 15, 1); |
388 |
StringGridResult.Cells[1, 7] := FloatToStrF(PenteLD / (NEmAL / NEcrois), ffFixed, 15, 1); |
389 |
StringGridResult.Cells[1, 8] := FloatToStrF(PDmaxE / GEProtJaap, ffFixed, 15, 1); |
390 |
StringGridResult.Cells[1, 9] := FloatToStrF(F, ffFixed, 15, 2); |
391 |
StringGridResult.Cells[1, 10] := FloatToStrF((1 + NEPD) * py1 / ((px1 - 1) * NEmAL), ffFixed, 15, 2); |
392 |
end;
|
393 |
|
394 |
procedure TFGraph3D.AfficheGraph2D;
|
395 |
const
|
396 |
pas = 100;
|
397 |
var
|
398 |
i, j: Integer; |
399 |
F, PDmaxE, a, b, px1, PD, LD, NEmAL, NEcrois, PDLimit, x, y, PentePD, PenteLD, Correction, px1AL: Double; |
400 |
begin
|
401 |
j := TrackBarJour.Position; |
402 |
F := PResSimulP.TabResult[52, j];
|
403 |
PDmaxE := PResSimulP.TabResult[69, j];
|
404 |
a := PResSimulP.TabResult[74, j];
|
405 |
b := PResSimulP.TabResult[75, j];
|
406 |
px1 := PResSimulP.TabResult[76, j];
|
407 |
PD := PResSimulP.TabResult[79, j];
|
408 |
LD := PResSimulP.TabResult[80, j];
|
409 |
NEmAL := PResSimulP.TabResult[71, j];
|
410 |
NEcrois := PResSimulP.TabResult[90, j] * 1000; |
411 |
PDLimit := PResSimulP.TabResult[47, j];
|
412 |
px1AL := PResSimulP.TabResult[110, j];
|
413 |
//
|
414 |
// PD
|
415 |
//
|
416 |
// Courbe
|
417 |
SeriesCourbePD.Clear; |
418 |
SeriesLimitePD.Clear; |
419 |
for i := 1 * pas to 6 * pas do |
420 |
begin
|
421 |
x := i / pas; |
422 |
if x < F
|
423 |
then // curvilin?aire |
424 |
y := (a * (x - 1) + b * Power(x - 1, 2)) / GEProtJaap |
425 |
else // plateau |
426 |
y := PDmaxE / GEProtJaap; |
427 |
SeriesCourbePD.AddXY(x, y, '', clTeeColor);
|
428 |
if (PD = PDLimit) and (y > PD) |
429 |
then // pointill?s |
430 |
if i mod pas div 5 = 0 then SeriesLimitePD.AddXY(x, PD, '', clTeeColor); |
431 |
end;
|
432 |
// Point
|
433 |
SeriesPointPD.Clear; |
434 |
SeriesPointPD.AddXY(px1, PD, '', clTeeColor);
|
435 |
// Droite
|
436 |
SeriesDroitePD.Clear; |
437 |
if (px1 < F) and (PD < PDLimit) |
438 |
then
|
439 |
PentePD := (a + 2 * b * (px1 - 1)) / GEProtJaap |
440 |
else
|
441 |
PentePD := 0;
|
442 |
SeriesDroitePD.AddXY(px1 - 1, PD - PentePD, '', clTeeColor); |
443 |
SeriesDroitePD.AddXY(px1 + 1, PD + PentePD, '', clTeeColor); |
444 |
// AdLib
|
445 |
SeriesPointPDAdLib.Clear; |
446 |
if px1AL <> px1 then |
447 |
begin
|
448 |
if px1AL < F
|
449 |
then // curvilin?aire |
450 |
y := (a * (px1AL - 1) + b * Power(px1AL - 1, 2)) / GEProtJaap |
451 |
else // plateau |
452 |
y := PDmaxE / GEProtJaap; |
453 |
SeriesPointPDAdLib.AddXY(px1AL, y, '', clTeeColor);
|
454 |
end;
|
455 |
//
|
456 |
// LD
|
457 |
//
|
458 |
if px1 < F
|
459 |
then
|
460 |
Correction := LD / ((NEmAL * (px1 - 1) - (a * (px1 - 1) + b * Power(px1 - 1, 2)) * (1 + NEPD)) / ValEnergie[2, 2]) |
461 |
else
|
462 |
Correction := LD / ((NEmAL * (px1 - 1) - PDmaxE * (1 + NEPD)) / ValEnergie[2, 2]); |
463 |
// Courbe
|
464 |
SeriesCourbeLD.Clear; |
465 |
for i := 1 * pas to 6 * pas do |
466 |
begin
|
467 |
x := i / pas; |
468 |
if x < F
|
469 |
then
|
470 |
y := Correction * ((NEmAL * (x - 1) - (a * (x - 1) + b * Power(x - 1, 2)) * (1 + NEPD)) / ValEnergie[2, 2]) |
471 |
else
|
472 |
y := Correction * ((NEmAL * (x - 1) - PDmaxE * (1 + NEPD)) / ValEnergie[2, 2]); |
473 |
SeriesCourbeLD.AddXY(x, y, '', clTeeColor);
|
474 |
end ;
|
475 |
// Point
|
476 |
SeriesPointLD.Clear; |
477 |
SeriesPointLD.AddXY(px1, LD, '', clTeeColor);
|
478 |
// Droite
|
479 |
SeriesDroiteLD.Clear; |
480 |
if px1 < F
|
481 |
then
|
482 |
PenteLD := Correction * ((NEmAL - (a + 2 * b * (px1 - 1)) * (1 + NEPD)) / ValEnergie[2, 2]) |
483 |
else
|
484 |
PenteLD := Correction * (NEmAL / ValEnergie[2, 2]); |
485 |
SeriesDroiteLD.AddXY(px1 - 1, LD - PenteLD, '', clTeeColor); |
486 |
SeriesDroiteLD.AddXY(px1 + 1, LD + PenteLD, '', clTeeColor); |
487 |
// AdLib
|
488 |
SeriesPointLDAdLib.Clear; |
489 |
if px1AL <> px1 then |
490 |
begin
|
491 |
if px1AL < F
|
492 |
then
|
493 |
y := Correction * ((NEmAL * (px1AL - 1) - (a * (px1AL - 1) + b * Power(px1AL - 1, 2)) * (1 + NEPD)) / ValEnergie[2, 2]) |
494 |
else
|
495 |
y := Correction * ((NEmAL * (px1AL - 1) - PDmaxE * (1 + NEPD)) / ValEnergie[2, 2]); |
496 |
SeriesPointLDAdLib.AddXY(px1AL, y, '', clTeeColor);
|
497 |
end;
|
498 |
// Ajustement de la taille des axes
|
499 |
Chart2D.TopAxis.Minimum := 0;
|
500 |
Chart2D.TopAxis.Maximum := Chart2D.BottomAxis.Maximum * (NEmAL / NEcrois); |
501 |
Chart2D.TopAxis.Minimum := Chart2D.BottomAxis.Minimum * (NEmAL / NEcrois); |
502 |
LabelLimitPD2D.Visible := (PD = PDLimit); |
503 |
end;
|
504 |
|
505 |
procedure TFGraph3D.AfficheGraph3D;
|
506 |
const
|
507 |
pas = 10;
|
508 |
var
|
509 |
i, j, debut, fin: Integer; |
510 |
x, y, z, entretien, F, PDmaxE, a, b, px1, LD, NEmAL, NEcrois, Correction: Double; |
511 |
begin
|
512 |
SeriesSurface.Clear; |
513 |
SeriesAdLib.Clear; |
514 |
SeriesRation.Clear; |
515 |
Chart3D.BottomAxis.Title.Caption := ComboBoxX.Text; |
516 |
Chart3D.LeftAxis.Title.Caption := ComboBoxY.Text; |
517 |
Chart3D.DepthAxis.Title.Caption := ComboBoxZ.Text; |
518 |
if ComboBoxZ.ItemIndex = 1 |
519 |
then // x Entretien |
520 |
begin
|
521 |
debut := 1 * pas;
|
522 |
fin := 4 * pas;
|
523 |
end
|
524 |
else // kg aliment |
525 |
begin
|
526 |
debut := 0 * pas;
|
527 |
fin := 4 * pas;
|
528 |
end;
|
529 |
Chart3D.DepthAxis.Minimum := debut / pas; |
530 |
Chart3D.DepthAxis.Maximum := fin / pas; |
531 |
for j := 1 to PResSimulP.NbJSim do |
532 |
begin
|
533 |
case ComboBoxX.ItemIndex of |
534 |
1: // Age |
535 |
x := PResSimulP.TabResult[1, j];
|
536 |
2: // Poids vif |
537 |
x := PResSimulP.TabResult[2, j];
|
538 |
else // Dur?e |
539 |
x := j; |
540 |
end;
|
541 |
F := PResSimulP.TabResult[52, j];
|
542 |
PDmaxE := PResSimulP.TabResult[69, j];
|
543 |
a := PResSimulP.TabResult[74, j];
|
544 |
b := PResSimulP.TabResult[75, j];
|
545 |
px1 := PResSimulP.TabResult[76, j] ;
|
546 |
LD := PResSimulP.TabResult[80, j];
|
547 |
NEmAL := PResSimulP.TabResult[71, j];
|
548 |
NEcrois := PResSimulP.TabResult[90, j] * 1000; |
549 |
if px1 < F
|
550 |
then
|
551 |
Correction := LD / ((NEmAL * (px1 - 1) - (a * (px1 - 1) + b * Power(px1 - 1, 2)) * (1 + NEPD)) / ValEnergie[2, 2]) |
552 |
else
|
553 |
Correction := LD / ((NEmAL * (px1 - 1) - PDmaxE * (1 + NEPD)) / ValEnergie[2, 2]) ; |
554 |
// Surface
|
555 |
entretien := 1;
|
556 |
if ComboBoxZ.ItemIndex = 1 |
557 |
then // x Entretien |
558 |
z := entretien |
559 |
else // kg aliment |
560 |
z := Trunc(pas * (NEmAL / NEcrois)) / pas; |
561 |
SeriesSurface.AddXYZ(x, 0, z);
|
562 |
for i := debut to fin do |
563 |
begin
|
564 |
if ComboBoxZ.ItemIndex = 1 |
565 |
then // x Entretien |
566 |
entretien := i / pas |
567 |
else // kg aliment |
568 |
entretien := i / pas / (NEmAL / NEcrois); |
569 |
if ComboBoxY.ItemIndex = 0 |
570 |
then // PD |
571 |
if entretien < F
|
572 |
then // curvilin?aire |
573 |
y := (a * (entretien - 1) + b * Power(entretien - 1, 2)) / GEProtJaap |
574 |
else // plateau |
575 |
y := PDmaxE / GEProtJaap |
576 |
else // LD |
577 |
if entretien < F
|
578 |
then
|
579 |
y := Correction * ((NEmAL * (entretien - 1) - (a * (entretien - 1) + b * Power(entretien - 1, 2)) * (1 + NEPD)) / ValEnergie[2, 2]) |
580 |
else
|
581 |
y := Correction * ((NEmAL * (entretien - 1) - PDmaxE * (1 + NEPD)) / ValEnergie[2, 2]); |
582 |
z := i / pas; |
583 |
if entretien > 1 |
584 |
then
|
585 |
SeriesSurface.AddXYZ(x, y, z); |
586 |
end ;
|
587 |
// Ligne (ad libitum)
|
588 |
entretien := PResSimulP.TabResult[110, j]; // px1AL |
589 |
if ComboBoxY.ItemIndex = 0 |
590 |
then // PD |
591 |
if entretien < F
|
592 |
then // curvilin?aire |
593 |
y := (a * (entretien - 1) + b * Power(entretien - 1, 2)) / GEProtJaap |
594 |
else // plateau |
595 |
y := PDmaxE / GEProtJaap |
596 |
else // LD |
597 |
if entretien < F
|
598 |
then
|
599 |
y := Correction * ((NEmAL * (entretien - 1) - (a * (entretien - 1) + b * Power(entretien - 1, 2)) * (1 + NEPD)) / ValEnergie[2, 2]) |
600 |
else
|
601 |
y := Correction * ((NEmAL * (entretien - 1) - PDmaxE * (1 + NEPD)) / ValEnergie[2, 2]); |
602 |
if ComboBoxZ.ItemIndex = 1 |
603 |
then // x Entretien |
604 |
z := entretien |
605 |
else // kg aliment |
606 |
z := entretien * (NEmAL / NEcrois); |
607 |
SeriesAdLib.AddXYZ (x, y, z); |
608 |
// Ligne (plan de rationnement)
|
609 |
entretien := px1; |
610 |
if ComboBoxY.ItemIndex = 0 |
611 |
then // PD |
612 |
if entretien < F
|
613 |
then // curvilin?aire |
614 |
y := (a * (entretien - 1) + b * Power(entretien - 1, 2)) / GEProtJaap |
615 |
else // plateau |
616 |
y := PDmaxE / GEProtJaap |
617 |
else // LD |
618 |
if entretien < F
|
619 |
then
|
620 |
y := Correction * ((NEmAL * (entretien - 1) - (a * (entretien - 1) + b * Power(entretien - 1, 2)) * (1 + NEPD)) / ValEnergie[2, 2]) |
621 |
else
|
622 |
y := Correction * ((NEmAL * (entretien - 1) - PDmaxE * (1 + NEPD)) / ValEnergie[2, 2]); |
623 |
if ComboBoxZ.ItemIndex = 1 |
624 |
then // x Entretien |
625 |
z := entretien |
626 |
else // kg aliment |
627 |
z := entretien * (NEmAL / NEcrois); |
628 |
SeriesRation.AddXYZ (x, y, z); |
629 |
end;
|
630 |
i := 0;
|
631 |
for j := 1 to PResSimulP.NbJSim do |
632 |
if PResSimulP.TabResult[79, j] = PResSimulP.TabResult[47, j] |
633 |
then // PD = PDFirstLimit |
634 |
Inc(i); |
635 |
LabelLimitPD3D.Visible := (i > 0);
|
636 |
end;
|
637 |
|
638 |
procedure TFGraph3D.SliderRotationChange(Sender: TObject);
|
639 |
begin
|
640 |
Chart3D.View3DOptions.Rotation := SliderRotation.Value; |
641 |
end;
|
642 |
|
643 |
procedure TFGraph3D.SliderElevationChange(Sender: TObject);
|
644 |
begin
|
645 |
Chart3D.View3DOptions.Elevation := SliderElevation.Value; |
646 |
end;
|
647 |
|
648 |
procedure TFGraph3D.SliderPerspectiveChange(Sender: TObject);
|
649 |
begin
|
650 |
Chart3D.View3DOptions.Perspective := SliderPerspective.Value; |
651 |
end;
|
652 |
|
653 |
procedure TFGraph3D.SliderZoomChange(Sender: TObject);
|
654 |
begin
|
655 |
Chart3D.View3DOptions.Zoom := SliderZoom.Value; |
656 |
end;
|
657 |
|
658 |
procedure TFGraph3D.WMSysCommand(var Message: TWMSysCommand); |
659 |
begin
|
660 |
if Message.CmdType = SC_MINIMIZE
|
661 |
then
|
662 |
Application.Minimize |
663 |
else
|
664 |
inherited;
|
665 |
end;
|
666 |
|
667 |
end.
|