mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 05:58:06 +02:00
TAChart: Add "distance" demo. Based on patch by Werner Pamler.
git-svn-id: trunk@38451 -
This commit is contained in:
parent
d485227dea
commit
82f17f1252
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -2865,6 +2865,10 @@ components/tachart/demo/db/dbdemo.lpi svneol=native#text/plain
|
||||
components/tachart/demo/db/dbdemo.lpr svneol=native#text/pascal
|
||||
components/tachart/demo/db/main.lfm svneol=native#text/plain
|
||||
components/tachart/demo/db/main.pas svneol=native#text/pascal
|
||||
components/tachart/demo/distance/Main.lfm svneol=native#text/plain
|
||||
components/tachart/demo/distance/Main.pas svneol=native#text/pascal
|
||||
components/tachart/demo/distance/distancedemo.lpi svneol=native#text/plain
|
||||
components/tachart/demo/distance/distancedemo.lpr svneol=native#text/pascal
|
||||
components/tachart/demo/dragdrop/dragdropdemo.lpi svneol=native#text/plain
|
||||
components/tachart/demo/dragdrop/dragdropdemo.lpr svneol=native#text/plain
|
||||
components/tachart/demo/dragdrop/main.lfm svneol=native#text/plain
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -162,6 +162,9 @@ components/tachart/demo/clone/lib
|
||||
components/tachart/demo/db/*.exe
|
||||
components/tachart/demo/db/*.lps
|
||||
components/tachart/demo/db/lib
|
||||
components/tachart/demo/distance/*.exe
|
||||
components/tachart/demo/distance/*.lps
|
||||
components/tachart/demo/distance/lib
|
||||
components/tachart/demo/dragdrop/*.exe
|
||||
components/tachart/demo/dragdrop/*.lps
|
||||
components/tachart/demo/dragdrop/lib
|
||||
|
404
components/tachart/demo/distance/Main.lfm
Normal file
404
components/tachart/demo/distance/Main.lfm
Normal file
@ -0,0 +1,404 @@
|
||||
object Form1: TForm1
|
||||
Left = 495
|
||||
Height = 531
|
||||
Top = 225
|
||||
Width = 800
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 531
|
||||
ClientWidth = 800
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '1.1'
|
||||
object Chart1: TChart
|
||||
Left = 0
|
||||
Height = 367
|
||||
Top = 0
|
||||
Width = 800
|
||||
AxisList = <
|
||||
item
|
||||
TickColor = clBlue
|
||||
AxisPen.Color = clBlue
|
||||
AxisPen.Visible = True
|
||||
Marks.LabelFont.Color = clBlue
|
||||
Minors = <>
|
||||
Title.LabelFont.Orientation = 900
|
||||
Transformations = ChartAxisTransformations1
|
||||
end
|
||||
item
|
||||
Alignment = calBottom
|
||||
Minors = <>
|
||||
end
|
||||
item
|
||||
Grid.Visible = False
|
||||
TickColor = clTeal
|
||||
Alignment = calRight
|
||||
AxisPen.Color = clTeal
|
||||
AxisPen.Visible = True
|
||||
Marks.LabelFont.Color = clTeal
|
||||
Minors = <>
|
||||
Transformations = ChartAxisTransformations3
|
||||
end>
|
||||
BackColor = clCream
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
MarginsExternal.Left = 8
|
||||
MarginsExternal.Top = 8
|
||||
MarginsExternal.Right = 8
|
||||
MarginsExternal.Bottom = 8
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Font.Color = clBlue
|
||||
Title.Text.Strings = (
|
||||
'TAChart'
|
||||
)
|
||||
Toolset = ctDist
|
||||
Align = alClient
|
||||
DoubleBuffered = True
|
||||
ParentColor = False
|
||||
object Chart1LineSeries1: TLineSeries
|
||||
AxisIndexX = 1
|
||||
AxisIndexY = 0
|
||||
LinePen.Color = clBlue
|
||||
Source = RandomChartSource1
|
||||
end
|
||||
object Chart1LineSeries2: TLineSeries
|
||||
AxisIndexX = 1
|
||||
AxisIndexY = 0
|
||||
LinePen.Color = clBlue
|
||||
LinePen.Style = psDash
|
||||
Source = RandomChartSource2
|
||||
end
|
||||
object Chart1LineSeries3: TLineSeries
|
||||
AxisIndexX = 1
|
||||
AxisIndexY = 2
|
||||
LinePen.Color = clTeal
|
||||
LinePen.Width = 3
|
||||
Pointer.Brush.Color = clMoneyGreen
|
||||
Pointer.Style = psCircle
|
||||
ShowPoints = True
|
||||
Source = RandomChartSource3
|
||||
end
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 108
|
||||
Top = 367
|
||||
Width = 800
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 108
|
||||
ClientWidth = 800
|
||||
TabOrder = 1
|
||||
object rgSnapMode: TRadioGroup
|
||||
Left = 8
|
||||
Height = 101
|
||||
Top = 5
|
||||
Width = 96
|
||||
AutoFill = True
|
||||
Caption = 'Snapping mode'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 83
|
||||
ClientWidth = 92
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'cdmXY'
|
||||
'cdmOnlyX'
|
||||
'cdmOnlyY'
|
||||
)
|
||||
OnClick = rgSnapModeClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object rgDrawingMode: TRadioGroup
|
||||
Left = 208
|
||||
Height = 101
|
||||
Top = 5
|
||||
Width = 97
|
||||
AutoFill = True
|
||||
Caption = 'Drawing mode'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 83
|
||||
ClientWidth = 93
|
||||
ItemIndex = 1
|
||||
Items.Strings = (
|
||||
'tdmDefault'
|
||||
'tdmNormal'
|
||||
'tdmXor'
|
||||
)
|
||||
OnClick = rgDrawingModeClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object cbRotateLabel: TCheckBox
|
||||
Left = 428
|
||||
Height = 17
|
||||
Top = 29
|
||||
Width = 78
|
||||
Caption = 'Rotate label'
|
||||
Checked = True
|
||||
OnClick = cbRotateLabelClick
|
||||
State = cbChecked
|
||||
TabOrder = 2
|
||||
end
|
||||
object cbShowLabel: TCheckBox
|
||||
Left = 428
|
||||
Height = 17
|
||||
Top = 5
|
||||
Width = 71
|
||||
Caption = 'Show label'
|
||||
Checked = True
|
||||
OnClick = cbShowLabelClick
|
||||
State = cbChecked
|
||||
TabOrder = 3
|
||||
end
|
||||
object clrPenColor: TColorButton
|
||||
Left = 708
|
||||
Height = 25
|
||||
Top = 41
|
||||
Width = 78
|
||||
BorderWidth = 2
|
||||
ButtonColorAutoSize = False
|
||||
ButtonColorSize = 16
|
||||
ButtonColor = clBlack
|
||||
Caption = 'Pen'
|
||||
Margin = 4
|
||||
OnColorChanged = clrPenColorColorChanged
|
||||
end
|
||||
object clrFontColor: TColorButton
|
||||
Left = 708
|
||||
Height = 25
|
||||
Top = 70
|
||||
Width = 78
|
||||
BorderWidth = 2
|
||||
ButtonColorAutoSize = False
|
||||
ButtonColorSize = 16
|
||||
ButtonColor = clBlack
|
||||
Caption = 'Font'
|
||||
Margin = 4
|
||||
OnColorChanged = clrFontColorColorChanged
|
||||
end
|
||||
object clrBackgroundColor: TColorButton
|
||||
Left = 708
|
||||
Height = 25
|
||||
Top = 8
|
||||
Width = 78
|
||||
BorderWidth = 2
|
||||
ButtonColorAutoSize = False
|
||||
ButtonColorSize = 16
|
||||
ButtonColor = clBtnFace
|
||||
Caption = 'Backgr'
|
||||
Margin = 4
|
||||
OnColorChanged = clrBackgroundColorColorChanged
|
||||
end
|
||||
object edEndbarLength: TSpinEdit
|
||||
Left = 628
|
||||
Height = 21
|
||||
Top = 5
|
||||
Width = 50
|
||||
MaxValue = 1000
|
||||
OnChange = edEndbarLengthChange
|
||||
TabOrder = 4
|
||||
Value = 1000
|
||||
end
|
||||
object lblEndBarLength: TLabel
|
||||
Left = 548
|
||||
Height = 13
|
||||
Top = 8
|
||||
Width = 67
|
||||
Caption = 'Endbar length'
|
||||
ParentColor = False
|
||||
end
|
||||
object cbHide: TCheckBox
|
||||
Left = 428
|
||||
Height = 17
|
||||
Top = 81
|
||||
Width = 103
|
||||
Caption = 'Hide at mouse up'
|
||||
OnClick = cbHideClick
|
||||
TabOrder = 5
|
||||
end
|
||||
object rgMeasureMode: TRadioGroup
|
||||
Left = 108
|
||||
Height = 101
|
||||
Top = 5
|
||||
Width = 97
|
||||
AutoFill = True
|
||||
Caption = 'Measure mode'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 83
|
||||
ClientWidth = 93
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'cdmXY'
|
||||
'cdmOnlyX'
|
||||
'cdmOnlyY'
|
||||
)
|
||||
OnClick = rgMeasureModeClick
|
||||
TabOrder = 6
|
||||
end
|
||||
object mDistanceText: TMemo
|
||||
Left = 536
|
||||
Height = 53
|
||||
Top = 42
|
||||
Width = 138
|
||||
Lines.Strings = (
|
||||
'axis dist = %0:.4g'
|
||||
'graph dist = %1:.4g'
|
||||
)
|
||||
OnChange = mDistanceTextChange
|
||||
TabOrder = 7
|
||||
end
|
||||
object rgDataPointMode: TRadioGroup
|
||||
Left = 308
|
||||
Height = 101
|
||||
Top = 5
|
||||
Width = 97
|
||||
AutoFill = True
|
||||
Caption = 'Data point mode'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 83
|
||||
ClientWidth = 93
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'Free'
|
||||
'Snap'
|
||||
'Lock'
|
||||
)
|
||||
OnClick = rgDataPointModeClick
|
||||
TabOrder = 8
|
||||
end
|
||||
object cbFlipLabel: TCheckBox
|
||||
Left = 428
|
||||
Height = 17
|
||||
Top = 53
|
||||
Width = 61
|
||||
Caption = 'Flip label'
|
||||
OnClick = cbFlipLabelClick
|
||||
TabOrder = 9
|
||||
end
|
||||
end
|
||||
object StatusBar1: TStatusBar
|
||||
Left = 0
|
||||
Height = 20
|
||||
Top = 511
|
||||
Width = 800
|
||||
Panels = <>
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 0
|
||||
Height = 36
|
||||
Top = 475
|
||||
Width = 800
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
Caption = 'Left-drag --> measure 1st distance Ctrl+left-drag --> measure 2nd distance Right-drag --> show values'
|
||||
Color = clGray
|
||||
Font.Color = clWhite
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object RandomChartSource1: TRandomChartSource
|
||||
PointsNumber = 10
|
||||
RandSeed = 2143215771
|
||||
XMax = 10
|
||||
XMin = 0
|
||||
YMax = 10
|
||||
YMin = 4
|
||||
left = 73
|
||||
top = 28
|
||||
end
|
||||
object RandomChartSource2: TRandomChartSource
|
||||
PointsNumber = 15
|
||||
RandSeed = 2143294090
|
||||
XMax = 10
|
||||
XMin = 0
|
||||
YMax = 5
|
||||
YMin = 0
|
||||
left = 73
|
||||
top = 97
|
||||
end
|
||||
object ctDist: TChartToolset
|
||||
left = 72
|
||||
top = 232
|
||||
object ctDistDataPointCrosshairTool1: TDataPointCrosshairTool
|
||||
Shift = [ssRight]
|
||||
OnDraw = ctDistDataPointCrosshairTool1Draw
|
||||
Size = 16
|
||||
end
|
||||
object ctDistDataPointDistanceTool1: TDataPointDistanceTool
|
||||
Shift = [ssLeft]
|
||||
LinePen.Width = 2
|
||||
Marks.Distance = 30
|
||||
Marks.Format = 'dist='#13#10'%0:.9g / %1:.9g'
|
||||
Marks.LinkPen.Color = clBlue
|
||||
PointerEnd.Brush.Style = bsClear
|
||||
PointerEnd.VertSize = 1000
|
||||
PointerStart.Brush.Style = bsClear
|
||||
PointerStart.Pen.Color = clRed
|
||||
PointerStart.VertSize = 1000
|
||||
OnMeasure = ctDistDataPointDistanceTool1Measure
|
||||
end
|
||||
object ctDistDataPointDistanceTool2: TDataPointDistanceTool
|
||||
Shift = [ssCtrl, ssLeft]
|
||||
Marks.Format = '%0:.9g'
|
||||
PointerEnd.HorizSize = 8
|
||||
PointerEnd.Style = psRightTriangle
|
||||
PointerEnd.VertSize = 8
|
||||
PointerStart.Brush.Style = bsClear
|
||||
PointerStart.Style = psLeftBracket
|
||||
PointerStart.VertSize = 8
|
||||
OnMeasure = ctDistDataPointDistanceTool1Measure
|
||||
end
|
||||
end
|
||||
object ChartAxisTransformations1: TChartAxisTransformations
|
||||
left = 260
|
||||
top = 128
|
||||
object ChartAxisTransformations1LogarithmAxisTransform1: TLogarithmAxisTransform
|
||||
Enabled = False
|
||||
Base = 10
|
||||
end
|
||||
end
|
||||
object RandomChartSource3: TRandomChartSource
|
||||
PointsNumber = 16
|
||||
RandSeed = 1603408474
|
||||
XMax = 10
|
||||
XMin = 0
|
||||
YMax = 1000
|
||||
YMin = 900
|
||||
left = 72
|
||||
top = 169
|
||||
end
|
||||
object ChartAxisTransformations3: TChartAxisTransformations
|
||||
left = 440
|
||||
top = 128
|
||||
object ChartAxisTransformations3AutoScaleAxisTransform1: TAutoScaleAxisTransform
|
||||
MaxValue = 20
|
||||
MinValue = 10
|
||||
end
|
||||
end
|
||||
end
|
231
components/tachart/demo/distance/Main.pas
Normal file
231
components/tachart/demo/distance/Main.pas
Normal file
@ -0,0 +1,231 @@
|
||||
unit Main;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
StdCtrls, Spin, ComCtrls,
|
||||
TAChartUtils, TATransformations, TAGraph, TASources, TASeries,
|
||||
TATools, TADataTools;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
cbFlipLabel: TCheckBox;
|
||||
cbHide: TCheckBox;
|
||||
cbRotateLabel: TCheckBox;
|
||||
cbShowLabel: TCheckBox;
|
||||
Chart1: TChart;
|
||||
Chart1LineSeries1: TLineSeries;
|
||||
Chart1LineSeries2: TLineSeries;
|
||||
Chart1LineSeries3: TLineSeries;
|
||||
ChartAxisTransformations1: TChartAxisTransformations;
|
||||
ChartAxisTransformations1LogarithmAxisTransform1: TLogarithmAxisTransform;
|
||||
ChartAxisTransformations3: TChartAxisTransformations;
|
||||
ChartAxisTransformations3AutoScaleAxisTransform1: TAutoScaleAxisTransform;
|
||||
clrBackgroundColor: TColorButton;
|
||||
clrFontColor: TColorButton;
|
||||
clrPenColor: TColorButton;
|
||||
ctDist: TChartToolset;
|
||||
ctDistDataPointCrosshairTool1: TDataPointCrosshairTool;
|
||||
ctDistDataPointDistanceTool1: TDataPointDistanceTool;
|
||||
ctDistDataPointDistanceTool2: TDataPointDistanceTool;
|
||||
edEndbarLength: TSpinEdit;
|
||||
lblEndBarLength: TLabel;
|
||||
mDistanceText: TMemo;
|
||||
Panel1: TPanel;
|
||||
Panel2: TPanel;
|
||||
RandomChartSource1: TRandomChartSource;
|
||||
RandomChartSource2: TRandomChartSource;
|
||||
RandomChartSource3: TRandomChartSource;
|
||||
rgDataPointMode: TRadioGroup;
|
||||
rgDrawingMode: TRadioGroup;
|
||||
rgMeasureMode: TRadioGroup;
|
||||
rgSnapMode: TRadioGroup;
|
||||
StatusBar1: TStatusBar;
|
||||
procedure cbFlipLabelClick(Sender: TObject);
|
||||
procedure cbHideClick(Sender: TObject);
|
||||
procedure cbRotateLabelClick(Sender: TObject);
|
||||
procedure cbShowLabelClick(Sender: TObject);
|
||||
procedure clrBackgroundColorColorChanged(Sender: TObject);
|
||||
procedure clrFontColorColorChanged(Sender: TObject);
|
||||
procedure clrPenColorColorChanged(Sender: TObject);
|
||||
procedure ctDistDataPointCrosshairTool1Draw(ASender: TDataPointCrosshairTool);
|
||||
procedure ctDistDataPointDistanceTool1Measure(
|
||||
ASender: TDataPointDistanceTool);
|
||||
procedure edEndbarLengthChange(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure mDistanceTextChange(Sender: TObject);
|
||||
procedure rgDataPointModeClick(Sender: TObject);
|
||||
procedure rgDrawingModeClick(Sender: TObject);
|
||||
procedure rgMeasureModeClick(Sender: TObject);
|
||||
procedure rgSnapModeClick(Sender: TObject);
|
||||
private
|
||||
procedure SwitchOptions(AOptions: TDataPointDistanceTool.TOptions; AOn: Boolean);
|
||||
procedure UpdateButtons;
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
TACustomSeries;
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.cbFlipLabelClick(Sender: TObject);
|
||||
begin
|
||||
SwitchOptions([dpdoFlipLabel], cbFlipLabel.Checked);
|
||||
end;
|
||||
|
||||
procedure TForm1.cbHideClick(Sender: TObject);
|
||||
begin
|
||||
SwitchOptions([dpdoPermanent], not cbHide.Checked);
|
||||
end;
|
||||
|
||||
procedure TForm1.cbRotateLabelClick(Sender: TObject);
|
||||
begin
|
||||
SwitchOptions([dpdoRotateLabel], cbRotateLabel.Checked);
|
||||
end;
|
||||
|
||||
procedure TForm1.cbShowLabelClick(Sender: TObject);
|
||||
begin
|
||||
ctDistDataPointDistanceTool1.Marks.Visible := cbShowLabel.Checked;
|
||||
ctDistDataPointDistanceTool2.Marks.Visible := cbShowLabel.Checked;
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TForm1.clrBackgroundColorColorChanged(Sender: TObject);
|
||||
begin
|
||||
Chart1.BackColor := clrBackgroundColor.ButtonColor;
|
||||
end;
|
||||
|
||||
procedure TForm1.clrFontColorColorChanged(Sender: TObject);
|
||||
begin
|
||||
ctDistDataPointDistanceTool1.Marks.LabelFont.Color := clrFontColor.ButtonColor;
|
||||
ctDistDataPointDistanceTool2.Marks.LabelFont.Color := clrFontColor.ButtonColor;
|
||||
end;
|
||||
|
||||
procedure TForm1.clrPenColorColorChanged(Sender: TObject);
|
||||
begin
|
||||
ctDistDataPointDistanceTool1.LinePen.Color := clrPenColor.ButtonColor;
|
||||
ctDistDataPointDistanceTool2.LinePen.Color := clrPenColor.ButtonColor;
|
||||
ctDistDataPointCrosshairTool1.CrosshairPen.Color := clrPenColor.ButtonColor;
|
||||
end;
|
||||
|
||||
procedure TForm1.ctDistDataPointCrosshairTool1Draw(
|
||||
ASender: TDataPointCrosshairTool);
|
||||
var
|
||||
ser: TChartSeries;
|
||||
begin
|
||||
ser := TChartSeries(ASender.Series);
|
||||
if ser <> nil then begin
|
||||
with ser.Source.Item[ASender.PointIndex]^ do
|
||||
Statusbar1.SimpleText := Format('Cursor at (%f; %f)', [X, Y]);
|
||||
end else
|
||||
Statusbar1.SimpleText := '';
|
||||
end;
|
||||
|
||||
procedure TForm1.ctDistDataPointDistanceTool1Measure(
|
||||
ASender: TDataPointDistanceTool);
|
||||
const
|
||||
DIST_TEXT: array [TChartDistanceMode] of String = ('', 'x ', 'y ');
|
||||
begin
|
||||
with ASender do
|
||||
Statusbar1.SimpleText := Format(
|
||||
'Measured %sdistance between (%f; %f) and (%f; %f): %f', [
|
||||
DIST_TEXT[MeasureMode],
|
||||
PointStart.GraphPos.X, PointStart.GraphPos.Y,
|
||||
PointEnd.GraphPos.X, PointEnd.GraphPos.Y,
|
||||
Distance(cuPixel)
|
||||
]);
|
||||
end;
|
||||
|
||||
procedure TForm1.edEndbarLengthChange(Sender: TObject);
|
||||
begin
|
||||
ctDistDataPointDistanceTool1.PointerStart.VertSize := edEndbarLength.Value;
|
||||
ctDistDataPointDistanceTool1.PointerEnd.VertSize := edEndbarLength.Value;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
cbHideClick(nil);
|
||||
cbRotateLabelClick(nil);
|
||||
mDistanceTextChange(nil);
|
||||
rgDataPointModeClick(nil);
|
||||
rgDrawingModeClick(nil);
|
||||
end;
|
||||
|
||||
procedure TForm1.mDistanceTextChange(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
s := mDistanceText.Lines.Text;
|
||||
try
|
||||
Format(s, [1.0, 1.0]);
|
||||
ctDistDataPointDistanceTool1.Marks.Format := s;
|
||||
ctDistDataPointDistanceTool2.Marks.Format := s;
|
||||
except
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.rgDataPointModeClick(Sender: TObject);
|
||||
begin
|
||||
with ctDistDataPointDistanceTool1 do begin
|
||||
DataPointMode := TDataPointDistanceTool.TDataPointMode(rgDataPointMode.ItemIndex);
|
||||
ctDistDataPointDistanceTool2.DataPointMode := DataPointMode;
|
||||
end;
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TForm1.rgDrawingModeClick(Sender: TObject);
|
||||
begin
|
||||
ctDistDataPointDistanceTool1.DrawingMode := TChartToolDrawingMode(rgDrawingMode.ItemIndex);
|
||||
ctDistDataPointDistanceTool2.DrawingMode := TChartToolDrawingMode(rgDrawingMode.ItemIndex);
|
||||
ctDistDataPointCrosshairTool1.DrawingMode := TChartToolDrawingMode(rgDrawingMode.ItemIndex);
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TForm1.rgMeasureModeClick(Sender: TObject);
|
||||
begin
|
||||
ctDistDataPointDistanceTool1.MeasureMode := TChartDistanceMode(rgMeasureMode.ItemIndex);
|
||||
ctDistDataPointDistanceTool2.MeasureMode := TChartDistanceMode(rgMeasureMode.ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TForm1.rgSnapModeClick(Sender: TObject);
|
||||
begin
|
||||
ctDistDataPointDistanceTool1.DistanceMode := TChartDistanceMode(rgSnapMode.ItemIndex);
|
||||
ctDistDataPointDistanceTool2.DistanceMode := TChartDistanceMode(rgSnapMode.ItemIndex);
|
||||
ctDistDataPointCrosshairTool1.DistanceMode := TChartDistanceMode(rgSnapMode.ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TForm1.SwitchOptions(
|
||||
AOptions: TDataPointDistanceTool.TOptions; AOn: Boolean);
|
||||
begin
|
||||
with ctDistDataPointDistanceTool1 do begin
|
||||
if AOn then
|
||||
Options := Options + AOptions
|
||||
else
|
||||
Options := Options - AOptions;
|
||||
ctDistDataPointDistanceTool2.Options := Options;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdateButtons;
|
||||
begin
|
||||
clrPenColor.Enabled := ctDistDataPointDistanceTool1.DrawingMode=tdmNormal;
|
||||
clrFontColor.Enabled := (ctDistDataPointDistanceTool1.DrawingMode=tdmNormal)
|
||||
and ctDistDataPointDistanceTool1.Marks.Visible;
|
||||
rgSnapMode.Enabled := ctDistDataPointDistanceTool1.DataPointMode <> dpmFree;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
102
components/tachart/demo/distance/distancedemo.lpi
Normal file
102
components/tachart/demo/distance/distancedemo.lpi
Normal file
@ -0,0 +1,102 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="distancedemo"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="TAChartLazarusPkg"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="3">
|
||||
<Unit0>
|
||||
<Filename Value="distancedemo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="distancedemo"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="Main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Main"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="tadistancetool.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TADistanceTool"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="distancedemo"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<StripSymbols Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
20
components/tachart/demo/distance/distancedemo.lpr
Normal file
20
components/tachart/demo/distance/distancedemo.lpr
Normal file
@ -0,0 +1,20 @@
|
||||
program distancedemo;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, tachartlazaruspkg, Main, TADistanceTool;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user