TAChart: Add "Oscilloscope" page to the line demo

git-svn-id: trunk@33022 -
This commit is contained in:
ask 2011-10-22 17:32:05 +00:00
parent a6962d3529
commit 8b2d7d1c32
3 changed files with 117 additions and 14 deletions

View File

@ -1,32 +1,33 @@
object Form1: TForm1
Left = 647
Left = 605
Height = 479
Top = 364
Width = 645
Width = 691
Caption = 'Form1'
ClientHeight = 479
ClientWidth = 645
ClientWidth = 691
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '0.9.31'
object PageControl2: TPageControl
object PageControl1: TPageControl
Left = 0
Height = 479
Top = 0
Width = 645
Width = 691
ActivePage = tsFast
Align = alClient
TabIndex = 0
TabOrder = 0
OnChange = PageControl1Change
object tsFast: TTabSheet
Caption = 'Fast drawing'
ClientHeight = 453
ClientWidth = 637
ClientWidth = 683
object chFast: TChart
Left = 0
Height = 415
Top = 38
Width = 637
Width = 683
AxisList = <
item
Minors = <>
@ -64,10 +65,10 @@ object Form1: TForm1
Left = 0
Height = 38
Top = 0
Width = 637
Width = 683
Align = alTop
ClientHeight = 38
ClientWidth = 637
ClientWidth = 683
TabOrder = 1
object cbLineType: TComboBox
Left = 8
@ -153,12 +154,12 @@ object Form1: TForm1
object tsPointers: TTabSheet
Caption = 'Pointers'
ClientHeight = 453
ClientWidth = 637
ClientWidth = 683
object chPointers: TChart
Left = 0
Height = 453
Top = 0
Width = 467
Width = 513
AxisList = <
item
Minors = <>
@ -181,7 +182,7 @@ object Form1: TForm1
ParentColor = False
end
object pnlPointers: TPanel
Left = 467
Left = 513
Height = 453
Top = 0
Width = 170
@ -208,6 +209,51 @@ object Form1: TForm1
end
end
end
object tsOscilloscope: TTabSheet
Caption = 'Oscilloscope'
ClientHeight = 453
ClientWidth = 683
object chOscillator: TChart
Left = 0
Height = 453
Top = 0
Width = 683
AxisList = <
item
Grid.Color = clMedGray
Minors = <>
Range.Max = 2
Range.Min = -2
Range.UseMax = True
Range.UseMin = True
Title.LabelFont.Orientation = 900
end
item
Grid.Color = clMedGray
Alignment = calBottom
Minors = <>
Transformations = catOscillator
end>
BackColor = clBlack
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Text.Strings = (
'TAChart'
)
Align = alClient
DoubleBuffered = True
ParentColor = False
object chOscillatorLineSeries1: TLineSeries
AxisIndexX = 1
LinePen.Color = clLime
LinePen.Width = 2
LineType = ltStepXY
Source = lcsOscillator
end
end
end
end
object RandomChartSource1: TRandomChartSource
PointsNumber = 25
@ -254,4 +300,24 @@ object Form1: TForm1
left = 464
top = 160
end
object lcsOscillator: TListChartSource
DataPoints.Strings = (
'0|0|?|'
)
left = 464
top = 316
end
object timOscilloscope: TTimer
Enabled = False
Interval = 150
OnTimer = timOscilloscopeTimer
left = 408
top = 376
end
object catOscillator: TChartAxisTransformations
left = 464
top = 376
object catOscillatorLinearAxisTransform1: TLinearAxisTransform
end
end
end

View File

@ -6,7 +6,8 @@ interface
uses
Classes, ComCtrls, ExtCtrls, Spin, StdCtrls, SysUtils, FileUtil, Forms,
Controls, Graphics, Dialogs, TAGraph, TASeries, TASources, TATools;
Controls, Graphics, Dialogs, TAGraph, TASeries, TASources, TATools,
TATransformations, TACustomSeries;
type
@ -15,6 +16,7 @@ type
TForm1 = class(TForm)
btnAddSeries: TButton;
btnRefresh: TButton;
catOscillatorLinearAxisTransform1: TLinearAxisTransform;
cb3D: TCheckBox;
cbLineType: TComboBox;
cbRotated: TCheckBox;
@ -22,6 +24,9 @@ type
ccsAvg: TCalculatedChartSource;
ccsDerivative: TCalculatedChartSource;
ccsSum: TCalculatedChartSource;
catOscillator: TChartAxisTransformations;
chOscillator: TChart;
chOscillatorLineSeries1: TLineSeries;
chPointers: TChart;
chFast: TChart;
chFastConstantLine1: TConstantLine;
@ -33,11 +38,14 @@ type
edTime: TEdit;
lblPointerSize: TLabel;
lblPointsCount: TLabel;
PageControl2: TPageControl;
lcsOscillator: TListChartSource;
PageControl1: TPageControl;
Panel1: TPanel;
pnlPointers: TPanel;
RandomChartSource1: TRandomChartSource;
sePointerSize: TSpinEdit;
timOscilloscope: TTimer;
tsOscilloscope: TTabSheet;
tsPointers: TTabSheet;
tsFast: TTabSheet;
procedure btnAddSeriesClick(Sender: TObject);
@ -47,7 +55,9 @@ type
procedure cbRotatedChange(Sender: TObject);
procedure cbSortedChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
procedure sePointerSizeChange(Sender: TObject);
procedure timOscilloscopeTimer(Sender: TObject);
end;
var
@ -151,6 +161,11 @@ begin
end;
end;
procedure TForm1.PageControl1Change(Sender: TObject);
begin
timOscilloscope.Enabled := PageControl1.ActivePage = tsOscilloscope;
end;
procedure TForm1.sePointerSizeChange(Sender: TObject);
var
ls: TLineSeries;
@ -162,5 +177,23 @@ begin
end;
end;
procedure TForm1.timOscilloscopeTimer(Sender: TObject);
var
rp: TChartRenderingParams;
begin
rp := chOscillator.RenderingParams;
with chOscillatorLineSeries1 do begin
Add(Sin(GetXMax / 20) + Random - 0.5);
if Count > 20 then
ListSource.Delete(0);
// Allow to zoom into various parts of the chart
// while preserving "oscilloscope" behaviour.
catOscillatorLinearAxisTransform1.Offset := -GetXMin;
end;
// Transformation change resets logical extent.
// We know the old extent is safe to keep, so restore it.
chOscillator.RenderingParams := rp;
end;
end.

View File

@ -68,6 +68,10 @@
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<GenerateDebugInfo Value="True"/>
<DebugInfoType Value="dsAuto"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>