~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to components/tachart/taintervalsources.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
 
 
3
 *****************************************************************************
 
4
 *                                                                           *
 
5
 *  See the file COPYING.modifiedLGPL.txt, included in this distribution,    *
 
6
 *  for details about the copyright.                                         *
 
7
 *                                                                           *
 
8
 *  This program is distributed in the hope that it will be useful,          *
 
9
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 
10
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
 
11
 *                                                                           *
 
12
 *****************************************************************************
 
13
 
 
14
 Authors: Alexander Klenin
 
15
 
 
16
}
 
17
 
 
18
unit TAIntervalSources;
 
19
 
 
20
{$H+}
 
21
 
 
22
interface
 
23
 
 
24
uses
 
25
  Classes, TAChartUtils, TACustomSource;
 
26
 
 
27
type
 
28
 
 
29
  { TIntervalChartSource }
 
30
 
 
31
  TIntervalChartSource = class(TCustomChartSource)
 
32
  strict private
 
33
    FParams: TChartAxisIntervalParams;
 
34
    procedure RoundToImage(
 
35
      const AParams: TValuesInRangeParams; var AValues: TChartValueTextArray);
 
36
    procedure SetParams(AValue: TChartAxisIntervalParams);
 
37
  strict protected
 
38
    procedure CalculateIntervals(
 
39
      AParams: TValuesInRangeParams; out ABestStart, ABestStep: Double);
 
40
  protected
 
41
    function GetCount: Integer; override;
 
42
    function GetItem(AIndex: Integer): PChartDataItem; override;
 
43
    procedure SetYCount(AValue: Cardinal); override;
 
44
  public
 
45
    constructor Create(AOwner: TComponent); override;
 
46
    destructor Destroy; override;
 
47
 
 
48
    procedure ValuesInRange(
 
49
      AParams: TValuesInRangeParams; var AValues: TChartValueTextArray); override;
 
50
  published
 
51
    property Params: TChartAxisIntervalParams read FParams write SetParams;
 
52
  end;
 
53
 
 
54
  TDateTimeStep = (
 
55
    dtsYear, dtsQuarter, dtsMonth, dtsWeek, dtsDay,
 
56
    dtsHour, dtsMinute, dtsSecond, dtsMillisecond
 
57
  );
 
58
  TDateTimeSteps = set of TDateTimeStep;
 
59
 
 
60
const
 
61
  DATE_TIME_STEPS_ALL = [Low(TDateTimeStep) .. High(TDateTimeStep)];
 
62
 
 
63
type
 
64
 
 
65
  { TDateTimeIntervalChartSource }
 
66
 
 
67
  TDateTimeIntervalChartSource = class(TIntervalChartSource)
 
68
  strict private
 
69
    FDateTimeFormat: String;
 
70
    FSteps: TDateTimeSteps;
 
71
    procedure SetDateTimeFormat(AValue: String);
 
72
    procedure SetSteps(AValue: TDateTimeSteps);
 
73
  public
 
74
    constructor Create(AOwner: TComponent); override;
 
75
    procedure ValuesInRange(
 
76
      AParams: TValuesInRangeParams; var AValues: TChartValueTextArray); override;
 
77
  published
 
78
    property DateTimeFormat: String read FDateTimeFormat write SetDateTimeFormat;
 
79
    property Steps: TDateTimeSteps
 
80
      read FSteps write SetSteps default DATE_TIME_STEPS_ALL;
 
81
  end;
 
82
 
 
83
 
 
84
procedure Register;
 
85
 
 
86
implementation
 
87
 
 
88
uses
 
89
  DateUtils, Math, StrUtils, SysUtils, TAMath;
 
90
 
 
91
const
 
92
  YEAR = 365.25;
 
93
  DATE_STEP_INTERVALS: array [TDateTimeStep] of Double = (
 
94
    YEAR, YEAR / 4, YEAR / 12, 7, 1,
 
95
    OneHour, OneMinute, OneSecond, OneMillisecond
 
96
  );
 
97
 
 
98
type
 
99
  TSourceIntervalParams = class(TChartAxisIntervalParams)
 
100
  strict protected
 
101
    procedure Changed; override;
 
102
  end;
 
103
 
 
104
  TDateTimeIntervalsHelper = object
 
105
    FBestStep: TDateTimeStep;
 
106
    FBestStepCoeff: Double;
 
107
    FOrigParams: TValuesInRangeParams;
 
108
    FStep: TDateTimeStep;
 
109
    FStepLen: Double;
 
110
 
 
111
    function AxisToGraph(AX: Double): Double;
 
112
    procedure CheckStep(AStepCoeff: Double);
 
113
    function GraphToAxis(AX: Double): Double;
 
114
    function NextValue(AValue: TDateTime): Double;
 
115
    function StartValue(AValue: TDateTime): TDateTime;
 
116
  end;
 
117
 
 
118
procedure Register;
 
119
begin
 
120
  RegisterComponents(
 
121
    CHART_COMPONENT_IDE_PAGE, [
 
122
      TIntervalChartSource, TDateTimeIntervalChartSource
 
123
    ]);
 
124
end;
 
125
 
 
126
function SafeRound(AValue: Double): Double; inline;
 
127
begin
 
128
  Result := Int(AValue * 1e9) / 1e9;
 
129
end;
 
130
 
 
131
{ TDateTimeIntervalsHelper }
 
132
 
 
133
function TDateTimeIntervalsHelper.AxisToGraph(AX: Double): Double;
 
134
begin
 
135
  Result := FOrigParams.FAxisToGraph(AX) * DATE_STEP_INTERVALS[FStep];
 
136
end;
 
137
 
 
138
procedure TDateTimeIntervalsHelper.CheckStep(AStepCoeff: Double);
 
139
begin
 
140
  // Strict inequaltity is importatnt to avoid steps like "ten quarters".
 
141
  if (1.0 <= AStepCoeff) and (AStepCoeff < FBestStepCoeff) then begin
 
142
    FBestStepCoeff := AStepCoeff;
 
143
    FBestStep := FStep;
 
144
    FStepLen := DATE_STEP_INTERVALS[FBestStep] * FBestStepCoeff;
 
145
  end;
 
146
end;
 
147
 
 
148
function TDateTimeIntervalsHelper.GraphToAxis(AX: Double): Double;
 
149
begin
 
150
  Result := FOrigParams.FGraphToAxis(AX / DATE_STEP_INTERVALS[FStep]);
 
151
end;
 
152
 
 
153
function TDateTimeIntervalsHelper.NextValue(AValue: TDateTime): Double;
 
154
begin
 
155
  case FBestStep of
 
156
    dtsYear:
 
157
      if FBestStepCoeff > 10 then
 
158
        // DateTime arithmetics fails on large year numbers.
 
159
        Result := AValue + FStepLen
 
160
      else
 
161
        Result := IncYear(AValue, Round(FBestStepCoeff));
 
162
    dtsMonth: Result := IncMonth(AValue, Round(FBestStepCoeff));
 
163
    otherwise Result := AValue + FStepLen;
 
164
  end;
 
165
end;
 
166
 
 
167
function TDateTimeIntervalsHelper.StartValue(AValue: TDateTime): TDateTime;
 
168
begin
 
169
  Result := Int(AValue / FStepLen - 1) * FStepLen;
 
170
  case FBestStep of
 
171
    dtsYear:
 
172
      // DateTime arithmetics fails on large year numbers.
 
173
      if FBestStepCoeff <= 10 then
 
174
        Result := StartOfTheYear(AValue);
 
175
    dtsMonth: Result := StartOfTheMonth(AValue);
 
176
  end;
 
177
end;
 
178
 
 
179
{ TSourceIntervalParams }
 
180
 
 
181
procedure TSourceIntervalParams.Changed;
 
182
begin
 
183
  with GetOwner as TCustomChartSource do begin
 
184
    BeginUpdate;
 
185
    EndUpdate;
 
186
  end;
 
187
end;
 
188
 
 
189
{ TIntervalChartSource }
 
190
 
 
191
procedure TIntervalChartSource.CalculateIntervals(
 
192
  AParams: TValuesInRangeParams; out ABestStart, ABestStep: Double);
 
193
 
 
194
  procedure CalcMinMaxCount(out AMinCount, AMaxCount: Integer);
 
195
  var
 
196
    imageWidth, len: Integer;
 
197
  begin
 
198
    // If the axis transformation is non-linear, steps may not be equidistant.
 
199
    // However, both minimax and maximin will be achieved on equal steps.
 
200
    with AParams do
 
201
      imageWidth := Abs(ToImage(FMax) - ToImage(FMin));
 
202
    if aipUseMinLength in Params.Options then
 
203
      len := AParams.FScale(Max(Params.MinLength, 2))
 
204
    else
 
205
      len := 2;
 
206
    AMaxCount := Max(imageWidth div len, 2);
 
207
    if aipUseMaxLength in Params.Options then begin
 
208
      len := AParams.FScale(Max(Params.MaxLength, 2));
 
209
      AMinCount := Max((imageWidth + 1) div len, 2);
 
210
    end
 
211
    else
 
212
      AMinCount := 2;
 
213
  end;
 
214
 
 
215
  procedure TryStep(AStep: Double; var ABestCount: Integer);
 
216
  var
 
217
    m, start: Double;
 
218
    mi, prev, cnt: Integer;
 
219
  begin
 
220
    if AStep <= 0 then exit;
 
221
    start := Int(AParams.FMin / AStep) * AStep;
 
222
    m := start;
 
223
    prev := AParams.ToImage(m);
 
224
    cnt := 0;
 
225
    while m <= AParams.FMax do begin
 
226
      mi := AParams.ToImage(m + AStep);
 
227
      if not AParams.IsAcceptableStep(Abs(prev - mi)) then exit;
 
228
      m += AStep;
 
229
      prev := mi;
 
230
      cnt += 1;
 
231
    end;
 
232
    if
 
233
      not (aipUseCount in Params.Options) or (ABestCount <= 0) or
 
234
      (Abs(cnt - Params.Count) < Abs(ABestCount - Params.Count))
 
235
    then begin
 
236
      ABestStart := start - AStep;
 
237
      ABestStep := AStep;
 
238
      ABestCount := cnt;
 
239
    end;
 
240
  end;
 
241
 
 
242
var
 
243
  minCount, maxCount, bestCount: Integer;
 
244
  s, sv: Double;
 
245
begin
 
246
  CalcMinMaxCount(minCount, maxCount);
 
247
  bestCount := 0;
 
248
  if aipUseNiceSteps in Params.Options then begin
 
249
    s := AParams.CountToStep(minCount)  * 10;
 
250
    while s >= Max(AParams.CountToStep(maxCount), AParams.FMinStep) do begin
 
251
      for sv in Params.StepValues do
 
252
        TryStep(s * sv, bestCount);
 
253
      // We are not required to pick the best count, so any one will do.
 
254
      if not (aipUseCount in Params.Options) and (bestCount > 0) then break;
 
255
      s *= 0.1;
 
256
    end;
 
257
  end;
 
258
  if bestCount > 0 then exit;
 
259
  // Either nice steps were not required, or we failed to find one.
 
260
  if aipUseCount in Params.Options then
 
261
    bestCount := EnsureRange(Params.Count, minCount, maxCount)
 
262
  else
 
263
    bestCount := minCount;
 
264
  ABestStep := (AParams.FMax - AParams.FMin) / bestCount;
 
265
  ABestStart := AParams.FMin - ABestStep;
 
266
end;
 
267
 
 
268
constructor TIntervalChartSource.Create(AOwner: TComponent);
 
269
begin
 
270
  inherited Create(AOwner);
 
271
  FParams := TChartAxisIntervalParams.Create(Self);
 
272
end;
 
273
 
 
274
destructor TIntervalChartSource.Destroy;
 
275
begin
 
276
  FreeAndNil(FParams);
 
277
  inherited;
 
278
end;
 
279
 
 
280
function TIntervalChartSource.GetCount: Integer;
 
281
begin
 
282
  Result := 0;
 
283
end;
 
284
 
 
285
function TIntervalChartSource.GetItem(AIndex: Integer): PChartDataItem;
 
286
begin
 
287
  Unused(AIndex);
 
288
  Result := nil;
 
289
end;
 
290
 
 
291
procedure TIntervalChartSource.RoundToImage(
 
292
  const AParams: TValuesInRangeParams; var AValues: TChartValueTextArray);
 
293
 
 
294
  function A2I(AX: Double): Integer; inline;
 
295
  begin
 
296
    Result := AParams.FGraphToImage(AParams.FAxisToGraph(AX));
 
297
  end;
 
298
 
 
299
var
 
300
  i: Integer;
 
301
  v, p, rv: Double;
 
302
  x: Int64;
 
303
begin
 
304
  if AParams.FIntervals.Tolerance = 0 then exit;
 
305
  for i := 0 to High(AValues) do begin
 
306
    v := AValues[i].FValue;
 
307
    if (v = 0) or IsInfinite(v) or IsNan(v) then continue;
 
308
    x := A2I(v);
 
309
    p := Power(10, Floor(Log10(Abs(v)) - Log10(High(Int64)) + 1));
 
310
    while v <> 0 do begin
 
311
      rv := Round(v / p) * p;
 
312
      if Abs(A2I(rv) - x) >= AParams.FIntervals.Tolerance then break;
 
313
      v := rv;
 
314
      p *= 10;
 
315
    end;
 
316
    AValues[i].FValue := v;
 
317
  end;
 
318
end;
 
319
 
 
320
procedure TIntervalChartSource.SetParams(AValue: TChartAxisIntervalParams);
 
321
begin
 
322
  if FParams = AValue then exit;
 
323
  FParams.Assign(AValue);
 
324
  InvalidateCaches;
 
325
  Notify;
 
326
end;
 
327
 
 
328
procedure TIntervalChartSource.SetYCount(AValue: Cardinal);
 
329
begin
 
330
  Unused(AValue);
 
331
  raise EYCountError.Create('Can not set YCount');
 
332
end;
 
333
 
 
334
procedure TIntervalChartSource.ValuesInRange(
 
335
  AParams: TValuesInRangeParams; var AValues: TChartValueTextArray);
 
336
const
 
337
  // Arbitrary limit to prevent hangup/OOM in case of bug in CalculateIntervals.
 
338
  MAX_COUNT = 10000;
 
339
var
 
340
  start, step, m: Double;
 
341
  i: Integer;
 
342
begin
 
343
  if AParams.FMin >= AParams.FMax then exit;
 
344
  AParams.FIntervals := Params;
 
345
 
 
346
  if aipGraphCoords in Params.Options then begin
 
347
    AParams.FMin := AParams.FAxisToGraph(AParams.FMin);
 
348
    AParams.FMax := AParams.FAxisToGraph(AParams.FMax);
 
349
  end;
 
350
  CalculateIntervals(AParams, start, step);
 
351
  if step <= 0 then exit;
 
352
  m := start;
 
353
  SetLength(AValues, Trunc(Min((AParams.FMax - m) / step + 2, MAX_COUNT)));
 
354
  for i := 0 to High(AValues) do begin
 
355
    if IsZero(m) then
 
356
      m := 0;
 
357
    AValues[i].FValue := m;
 
358
    if m > AParams.FMax then begin
 
359
      SetLength(AValues, i + 1);
 
360
      break;
 
361
    end;
 
362
    m += step;
 
363
  end;
 
364
  if aipGraphCoords in Params.Options then
 
365
    for i := 0 to High(AValues) do
 
366
      AValues[i].FValue := AParams.FGraphToAxis(AValues[i].FValue);
 
367
  RoundToImage(AParams, AValues);
 
368
  for i := 0 to High(AValues) do
 
369
    // Extra format arguments for compatibility with FormatItem.
 
370
    AValues[i].FText := Format(
 
371
      AParams.FFormat, [AValues[i].FValue, 0.0, '', 0.0, 0.0]);
 
372
end;
 
373
 
 
374
{ TDateTimeIntervalChartSource }
 
375
 
 
376
constructor TDateTimeIntervalChartSource.Create(AOwner: TComponent);
 
377
begin
 
378
  inherited Create(AOwner);
 
379
  FSteps := DATE_TIME_STEPS_ALL;
 
380
end;
 
381
 
 
382
procedure TDateTimeIntervalChartSource.SetDateTimeFormat(AValue: String);
 
383
begin
 
384
  if FDateTimeFormat = AValue then exit;
 
385
  FDateTimeFormat := AValue;
 
386
  InvalidateCaches;
 
387
  Notify;
 
388
end;
 
389
 
 
390
procedure TDateTimeIntervalChartSource.SetSteps(AValue: TDateTimeSteps);
 
391
begin
 
392
  if FSteps = AValue then exit;
 
393
  FSteps := AValue;
 
394
  InvalidateCaches;
 
395
  Notify;
 
396
end;
 
397
 
 
398
procedure TDateTimeIntervalChartSource.ValuesInRange(
 
399
  AParams: TValuesInRangeParams; var AValues: TChartValueTextArray);
 
400
var
 
401
  helper: TDateTimeIntervalsHelper;
 
402
  prevSt: TSystemTime;
 
403
 
 
404
  function FormatLabel(AValue: TDateTime): String;
 
405
  var
 
406
    st: TSystemTime;
 
407
  begin
 
408
    if DateTimeFormat <> '' then
 
409
      exit(FormatDateTime(DateTimeFormat, AValue));
 
410
    DateTimeToSystemTime(AValue, st);
 
411
    case helper.FBestStep of
 
412
      dtsYear:
 
413
        Result := FormatDateTime('yyyy', AValue);
 
414
      dtsQuarter:
 
415
        Result :=
 
416
          IntToRoman(Floor(AValue / helper.FStepLen) mod 4 + 1) +
 
417
          FormatDateTime('/yyyy', AValue);
 
418
      dtsMonth:
 
419
        Result := FormatDateTime(
 
420
          IfThen(st.Year = prevSt.Year, 'mm', 'mm/yyyy'), AValue);
 
421
      dtsWeek:
 
422
        Result := FormatDateTime('dd/mm', AValue);
 
423
      dtsDay:
 
424
        Result := FormatDateTime(
 
425
          IfThen(st.Month = prevSt.Month, 'dd', 'dd/mm'), AValue);
 
426
      dtsHour:
 
427
        Result := FormatDateTime(
 
428
          IfThen(st.Day = prevSt.Day, 'hh:00', 'dd hh:00'), AValue);
 
429
      dtsMinute:
 
430
        Result := FormatDateTime(
 
431
          IfThen(st.Hour = prevSt.Hour, 'nn', 'hh:nn'), AValue);
 
432
      dtsSecond:
 
433
        Result := FormatDateTime(
 
434
          IfThen(st.Minute = prevSt.Minute, 'ss', 'nn:ss'), AValue);
 
435
      dtsMillisecond:
 
436
        Result :=
 
437
          IfThen(st.Second = prevSt.Second, '', IntToStr(st.Second) + '.') +
 
438
          IntToStr(st.Millisecond) + 'ms';
 
439
    end;
 
440
    if InRange(AValue, helper.FOrigParams.FMin, helper.FOrigParams.FMax) then
 
441
      prevSt := st;
 
442
  end;
 
443
 
 
444
  procedure AddValue(AIndex: Integer; AValue: Double);
 
445
  begin
 
446
    with AValues[AIndex] do begin
 
447
      FValue := AValue;
 
448
      FText := Format(
 
449
        AParams.FFormat, [AValue, 0.0, FormatLabel(AValue), 0.0, 0.0]);
 
450
    end;
 
451
  end;
 
452
 
 
453
const
 
454
  MAX_COUNT = 1000; // Arbitraty limit to prevent OOM in case of a bug.
 
455
var
 
456
  i, cnt: Integer;
 
457
  x, start, stepLen: Double;
 
458
begin
 
459
  if
 
460
    (AParams.FMin >= AParams.FMax) or (aipGraphCoords in Params.options)
 
461
  then
 
462
    exit;
 
463
  AParams.FIntervals := Params;
 
464
 
 
465
  helper.FOrigParams := AParams;
 
466
  AParams.FAxisToGraph := @helper.AxisToGraph;
 
467
  AParams.FGraphToAxis := @helper.GraphToAxis;
 
468
  AParams.FMinStep := 1.0;
 
469
  helper.FBestStepCoeff := SafeInfinity;
 
470
  for helper.FStep in Steps do begin
 
471
    AParams.FMin := helper.FOrigParams.FMin / DATE_STEP_INTERVALS[helper.FStep];
 
472
    AParams.FMax := helper.FOrigParams.FMax / DATE_STEP_INTERVALS[helper.FStep];
 
473
    CalculateIntervals(AParams, start, stepLen);
 
474
    helper.CheckStep(stepLen);
 
475
  end;
 
476
 
 
477
  if IsInfinite(helper.FBestStepCoeff) then exit;
 
478
 
 
479
  start := helper.StartValue(helper.FOrigParams.FMin);
 
480
  cnt := 1;
 
481
  x := start;
 
482
  while (x <= helper.FOrigParams.FMax) and (cnt < MAX_COUNT) do begin
 
483
    cnt += 1;
 
484
    x := helper.NextValue(x);
 
485
  end;
 
486
  i := Length(AValues);
 
487
  SetLength(AValues, i + cnt);
 
488
 
 
489
  FillChar(prevSt, SizeOf(prevSt), $FF);
 
490
  x := start;
 
491
  while (x <= helper.FOrigParams.FMax) and (i < cnt - 1) do begin
 
492
    AddValue(i, x);
 
493
    i += 1;
 
494
    x := helper.NextValue(x);
 
495
  end;
 
496
  AddValue(i, x);
 
497
end;
 
498
 
 
499
end.
 
500