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

« back to all changes in this revision

Viewing changes to components/tachart/demo/chartsource/main.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:
5
5
interface
6
6
 
7
7
uses
8
 
  ExtCtrls, StdCtrls, Forms, TAGraph, TASeries, TASources;
 
8
  ComCtrls, ExtCtrls, Spin, StdCtrls, Forms, TAGraph, TASeries, TASources,
 
9
  Classes;
9
10
 
10
11
type
11
12
 
12
13
  { TForm1 }
13
14
 
14
15
  TForm1 = class(TForm)
 
16
    cbAccDirDerivative: TComboBox;
 
17
    ccsDerivative: TCalculatedChartSource;
 
18
    cbCumulative: TCheckBox;
 
19
    ccsAvg: TCalculatedChartSource;
 
20
    ccsSum: TCalculatedChartSource;
15
21
    Chart1: TChart;
16
22
    Chart1BarSeries1: TBarSeries;
17
23
    Chart1LineSeries1: TLineSeries;
 
24
    chDerivativeLineOrig: TLineSeries;
 
25
    chDerivativeLineDeriv: TLineSeries;
 
26
    Chart1LineSeries4: TLineSeries;
 
27
    Chart1LineSeries5: TLineSeries;
18
28
    Chart2: TChart;
19
29
    Chart2AreaSeries1: TAreaSeries;
20
30
    Chart2LineSeries1: TLineSeries;
 
31
    chDerivative: TChart;
 
32
    chCalc: TChart;
 
33
    chCalcLineSeries1: TLineSeries;
 
34
    chCalcLineSeriesAvg: TLineSeries;
 
35
    chCalcLineSeriesSum: TLineSeries;
 
36
    cbAccDirStatistics: TComboBox;
 
37
    cbSmooth: TCheckBox;
 
38
    seAccumulationRange: TSpinEdit;
 
39
    lblAccumulationRange: TLabel;
21
40
    ListChartSource1: TListChartSource;
 
41
    lcsDerivative: TListChartSource;
22
42
    Memo1: TMemo;
 
43
    PageControl1: TPageControl;
 
44
    Panel1: TPanel;
 
45
    Panel2: TPanel;
 
46
    rgDataShape: TRadioGroup;
23
47
    RandomChartSource1: TRandomChartSource;
 
48
    RandomChartSource2: TRandomChartSource;
24
49
    Splitter1: TSplitter;
 
50
    tsDerivative: TTabSheet;
 
51
    tsStatistics: TTabSheet;
 
52
    tsBasic: TTabSheet;
 
53
    procedure cbAccDirDerivativeChange(Sender: TObject);
 
54
    procedure cbAccDirStatisticsChange(Sender: TObject);
 
55
    procedure cbCumulativeChange(Sender: TObject);
 
56
    procedure cbSmoothChange(Sender: TObject);
 
57
    procedure CreateData;
 
58
    procedure seAccumulationRangeChange(Sender: TObject);
 
59
    procedure FormCreate(Sender: TObject);
 
60
    procedure rgDataShapeClick(Sender: TObject);
25
61
  end;
26
62
 
27
63
var
31
67
 
32
68
{$R *.lfm}
33
69
 
 
70
uses
 
71
  Math;
 
72
 
 
73
{ TForm1 }
 
74
 
 
75
procedure TForm1.cbAccDirDerivativeChange(Sender: TObject);
 
76
begin
 
77
  ccsDerivative.AccumulationDirection :=
 
78
    TChartAccumulationDirection(cbAccDirDerivative.ItemIndex);
 
79
end;
 
80
 
 
81
procedure TForm1.cbAccDirStatisticsChange(Sender: TObject);
 
82
begin
 
83
  ccsAvg.AccumulationDirection :=
 
84
    TChartAccumulationDirection(cbAccDirStatistics.ItemIndex);
 
85
  ccsSum.AccumulationDirection := ccsAvg.AccumulationDirection;
 
86
end;
 
87
 
 
88
procedure TForm1.cbCumulativeChange(Sender: TObject);
 
89
begin
 
90
  chCalcLineSeriesSum.Active := cbCumulative.Checked;
 
91
end;
 
92
 
 
93
procedure TForm1.cbSmoothChange(Sender: TObject);
 
94
begin
 
95
  if cbSmooth.Checked then
 
96
    ccsDerivative.AccumulationMethod := camSmoothDerivative
 
97
  else
 
98
    ccsDerivative.AccumulationMethod := camDerivative;
 
99
end;
 
100
 
 
101
procedure TForm1.CreateData;
 
102
const
 
103
  N = 100;
 
104
  MIN_X = -10;
 
105
  MAX_X = 10;
 
106
  EPS = 1e-6;
 
107
var
 
108
  i: Integer;
 
109
  x, y: Double;
 
110
begin
 
111
  lcsDerivative.Clear;
 
112
  if rgDataShape.ItemIndex = 6 then
 
113
    for i := 0 to 9 do
 
114
      lcsDerivative.Add(i - IfThen(i > 6, 1, 0), i)
 
115
  else
 
116
    for i := 0 to N - 1 do begin
 
117
      x := MIN_X + (MAX_X - MIN_X) / (N - 1) * i;
 
118
      if SameValue(x, 0.0, EPS) then x := 0;
 
119
      case rgDataShape.ItemIndex of
 
120
        0: y := x;
 
121
        1: y := Sin(x);
 
122
        2: if x = 0 then y := 1 else y := Sin(x) / x;
 
123
        3: y := Exp(-x / 3);
 
124
        4: y := Exp(-Sqr((x - 2.5) / 2.5));
 
125
        5: y := Exp(-Sqr((x - 2.5) / 2.5)) + 0.05 * (Random - 0.5);
 
126
      end;
 
127
      lcsDerivative.Add(x, y);
 
128
    end;
 
129
end;
 
130
 
 
131
procedure TForm1.FormCreate(Sender: TObject);
 
132
begin
 
133
  Randomize;
 
134
  CreateData;
 
135
end;
 
136
 
 
137
procedure TForm1.rgDataShapeClick(Sender: TObject);
 
138
begin
 
139
  CreateData;
 
140
end;
 
141
 
 
142
procedure TForm1.seAccumulationRangeChange(Sender: TObject);
 
143
begin
 
144
  ccsDerivative.AccumulationRange := seAccumulationRange.Value;
 
145
end;
 
146
 
34
147
end.
35
148