这里是说明
(*
Component XYGraph, Version 3.0
April 1999
U.J黵?
57078 Siegen, Germany
e-mail: ujhs@aol.com
Component XYGraph 3.0 is a versatile graph for showing 2D data:
1. + Very flexible property design.
2. + Extended control interface
(control the graph and retrieve all curve data without writing one line
of code by simply assigning TControl磗 to the graph磗 CONTROLS property).
3. + Powerful, flickerfree CENTERZOOM (with or without aspect ratio).
4. + Flickerfree REALPAN (single curves or graph).
5. + Editing of curve controlpoints (move, insert, delete, freeze) by mouse
or numerical input.
6. + Free colored offset-lettering for every controlpoint.
7. + Three markstyles with scaleable size to mark important controlpoints.
8. + Relative cursor reading.
9. + Streamed writing and reading single curves or graph.
10. + DXF output of graph and curves for data exchange with CAD systems.
11. + Moveable hintpanel for additional graph-information.
12. + Example project showing some features.
Properties:
property Controls: TControls
(all properties of type TControl can be TLabel, TStaticText, TStatusLabel
or TPanel. They are used for data output. For example assigning a TLabel
to the property "Mode" will display the graph磗 actual mode.)
property XOut: TControl (output) (normally the TEdit XIn)
property YOut: TControl (output) (normally the TEdit YIn)
property Mode: TControl (output)
property Curve: TControl (output)
property Item: TControl (output)
property Color: TControl (output)
property Angle: TControl (output)
(TEdits are used for numerical inputs. (and outputs of X,Y))
property XIn: TEdit (input)
property YIn: TEdit (input)
(TButtons are used as switches to control graph functions.)
property Clear: TButton (input)
property OpenView: TButton (input)
property OpenPan: TButton (input)
property Reset: TButton (input)
(TRadioButtons are used to control the graph磗 operating mode.)
property ModeNone: TRadioButton (input)
property ModeMove: TRadioButton (input)
property ModeInsert: TRadioButton (input)
property ModeDelete: TRadioButton (input)
property ModeCursor: TRadioButton (input)
(TCheckBoxes are used to control graph options.)
property AspectRatio: TCheckBox (input)
property MainGrid: TCheckBox (input)
property SubGrid: TCheckBox (input)
property HintPanel: TCheckBox (input)
property ViewListBox: TCheckListBox (input)
(ViewListBox is used to control visibility of curves. Click checkmark
of the curve you want to show or hide. To show/hide the ViewListBox
use Button "OpenView".)
property PanListBox: TCheckListBox
(PanListBox is used to select the curve(s) you want to move in the graph.
To show/hide then PanListBox use Button "OpenPan".)
property Colors: TColors
property AxisBkGnd: color of xy-axis background.
property TickColor: color of scaleticks.
property GraphBkGnd: color of graph background.
property MainGridColor: color of maingrid.
property SubGridColor: color of subgrid.
property Fonts: TFonts
property AxisScale: font of axis-scale.
property AxisTitle: font of axis title.
property GraphTitle: font of graph title.
property GraphTitle: Str32 string of graph title.
property Positions: TPositions
property XAxisLeft: left margin of xaxis.
property XAxisRight: right margin of xaxis.
property YAxisTop: top margin of yaxis.
property YAxisBottom: bottom margin of yaxis.
property TitleTop: top margin of graph title.
property TitleLeft: left margin of graph title (centered if 0).
property XAxisTitle: bottom margin of xaxis title.
property YAxisTitle: left margin of yaxis title.
property XAxis: TAxis
property Title: title of axis
property Min: min value of axis
property Max: max value of axis
property MainTicks: how many ticks with texture.
property SubTicks: how many ticks between MainTicks.
property MainTickLen: length of MainTicks.
property SubTickLen: length of SubTicks.
property Decimals: how many digits after comma.
property ShowMainGrid: flag for showing MainGrid (for color look at Colors).
property ShowSubGrid: flag for showing SubGrid (for color look at Colors).
property YAxis: TAxis read FYAxis write FYAxis;
(same as XAxis)
property MaxZoom: defines the zoomlimits (MinZoom is 1 / MaxZoom).
----------------------------------------------------------------------------
Control functions:
LeftButton: does REALPAN if no other function is active. If one or
more curves are selected in the PanListBox, then these curves are moved
instead of panning the graph. You can also set this offset by numerical
input via the X/Y TEdits.
If a curve-controlpoint is active (shown by a marker), then
the actual function (move, insert, delete) is performed.
RightButton: does CENTERZOOM. The point you click will be centered
and then zoomed by mouse movement. If you deselect "Aspect" the X and Y
axis are zoomed independent.
DoubleClick: Resets the graph (pan and zoom).
Shift: if a curve-controlpoint is marked you can freeze this point by
holding down the shift-key.
----------------------------------------------------------------------------
How to do:
Setup the graph to your needs with the properties.
Use the
function MakeCurve(AName: Str32; AColor: TColor; ALineWidth: Byte;
APenStyle: TPenStyle; AEnabled: Boolean);
to create a new curve. The parameters makes the creation very flexible.
Assuming AName = "test". If "test" already exists, it will be renamed to
"test1" (just like Delphi does it with components).
You get a handle to the created curve. With this handle you can add new
points with the
procedure AddPoint(AIndex: Integer; X,Y: TFloat);
Where AIndex is the handle to the curve. After creation of all points you
can add text and/or marks to every point you want with the
procedure AddText(AIndex,APosition,AXOfs,AYOfs: Integer;
const AText: Str32; AColor: TColor);
procedure AddMark(AIndex,APosition: Integer; AMarkType:
TMarkType; AColor: TColor);
AIndex is the handle of the curve. APosition is the pointindex of the curve.
AXOfs,AYOfs defines at witch offsets (relative to the point) where the text
is displayed. Every text can be in different color. For every curve you can
assign a font with the
procedure SetCurveFont(AIndex: Integer; AName: TFontName;
ASize: Integer; AStyle: TFontStyles);
For every curve you can assign the size of marks with the
procedure SetMarkSize(AIndex: Integer; AMarkSize: TMarkSize);
To add text to the HintPanel use Graph.HintPanel.Strings.Add('test');
To clear the text use Graph.HintPanel.Strings.Clear;
To use the edit functions of the graph, set Mode <> None. If moving the
mouse cursor, a marker signs every controlpoint of the curve. Depending on
the editmode you can move, delete or insert a point (only if the marker
is visible). To freeze the actual marker, press (and hold down) the Shift-key.
If EditMode is "Move", you can numerical input new point coordinates via
the X,Y TEdits (if assigned).
----------------------------------------------------------------------------
DXF-output: you can create a DXF file with the
function MakeDXF(const FileName: string; FromX1,FromY1,FromX2,FromY2,
ToX1,ToY1,ToX2,ToY2,TextHeight: TFloat; Decimals: Byte): Boolean;
FromX1..FromY2 are the source coordinates.
ToX1..TY2 are the destination coordinates.
Decimals is the precision after comma.
All entities inside the source coordinates are transfered true to scale
into the destination coordinates. Everything outside (text,scalelines etc.)
are not true to scale. Does not process additional text (created with
AddText) and marks (created with AddMark).
----------------------------------------------------------------------------
Interesting public methods are:
function MakeCurve(const AName: Str32; AColor: TColor; ALineWidth: Byte;
APenStyle: TPenStyle; AEnabled: Boolean): Integer;
procedure AddPoint(AIndex: Integer; X,Y: TFloat);
procedure AddText(AIndex,APosition,AXOfs,AYOfs: Integer; const AText: Str32; AColor: TColor);
procedure SetCurveFont(AIndex: Integer; AName: TFontName; ASize: Integer; AStyle: TFontStyles);
procedure AddMark(AIndex,APosition: Integer; AMarkType: TMarkType; AColor: TColor);
procedure SetMarkSize(AIndex: Integer; AMarkSize: TMarkSize);
procedure ChangePoint(AIndex,APosition: Integer; X,Y: TFloat);
procedure DeleteCurve(AItem: Integer);
function GetCurveHandle(AName: Str32; var H: Integer): Boolean;
function GetCurveName(H: Integer): Str32;
procedure SetCurveEnabled(AIndex: Integer; Value: Boolean);
procedure GetPoint(AIndex,APosition: Integer; var X,Y: TFloat);
procedure InsertPoint(AIndex,APosition: Integer; X,Y: TFloat);
procedure DeletePoint(AIndex,APosition: Integer);
procedure Reset;
procedure ShowHintPanel(Show: Boolean);
procedure SetXOfs(AIndex: Integer; AOfs: TFloat);
function GetXOfs(AIndex: Integer): TFloat;
procedure SetYOfs(AIndex: Integer; AOfs: TFloat);
function GetYOfs(AIndex: Integer): TFloat;
procedure CheckCurvePoints(X,Y: Integer);
procedure ChangeCPx(Fx: TFloat);
procedure ChangeCPy(Fy: TFloat);
procedure ChangeCurveOfs(Ox,Oy: TFloat; Relative: Boolean);
procedure GetCPInfo(var CPMatch: Boolean; var CPCurve,CPIndex: Integer);
procedure SetMode(Value: TMode);
function MakeDXF(const FileName: string; FromX1,FromY1,FromX2,FromY2,
ToX1,ToY1,ToX2,ToY2,TextHeight: TFloat; Decimals: Byte): Boolean;
function SaveCurveToFile(const FileName: string; Item: Integer): Boolean;
function LoadCurveFromFile(const FileName: string): Boolean;
function SaveGraphToFile(const FileName: string): Boolean;
function LoadGraphFromFile(const FileName: string): Boolean;
----------------------------------------------------------------------------
Look at the demo project to see some other features like writing and
reading curves or graph, or creating DXF output.
Excuse my english - I hope you get at least the gist of it.
*)