📄 showdrawunit.pas
字号:
procedure TShowDrawForm.SpeedButton8Click(Sender: TObject);
begin
HorizScroll(-10,Chart2);
end;
procedure TShowDrawForm.SpinEdit2Change(Sender: TObject);
begin
Chart2.MaxPointsPerPage:=SpinEdit2.Value;
Chart2.UndoZoom
end;
procedure TShowDrawForm.Chart2M(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
{ This procedure draws the crosshair lines }
Procedure DrawCross(AX,AY:Integer);
begin
With Chart2,Canvas do
begin
Pen.Color:=CrossHairColor;
Pen.Style:=CrossHairStyle;
Pen.Mode:=pmXor;
Pen.Width:=1;
MoveTo(ax,ChartRect.Top-Height3D);
LineTo(ax,ChartRect.Bottom-Height3D);
MoveTo(ChartRect.Left+Width3D,ay);
LineTo(ChartRect.Right+Width3D,ay);
end;
end;
Var tmpX,tmpY:Double;
begin
if (OldX2<>-1) then
begin
DrawCross(OldX2,OldY2); { draw old crosshair }
OldX2:=-1;
end;
{ check if mouse is inside Chart rectangle }
if PtInRect( Chart2.ChartRect, Point(X-Chart2.Width3D,Y+Chart2.Height3D) ) then
begin
DrawCross(x,y); { draw crosshair at current position }
{ store old position }
OldX2:=x;
OldY2:=y;
{ set label text }
With LineSeries1 do
begin
GetCursorValues(tmpX,tmpY); { <-- get values under mouse cursor }
MainForm.RzStatusPane2.Caption:='X:'+GetVertAxis.LabelValue(Round(tmpX))+
'米 '+
'Y:'+GetHorizAxis.LabelValue(tmpY)+'伏';
end;
end;
end;
procedure TShowDrawForm.Chart2AfterDraw(Sender: TObject);
begin
OldX2:=-1; { Reset old mouse position }
end;
procedure TShowDrawForm.Series1AfterDrawValues(Sender: TObject);
begin
OldX:=-1; { Reset old mouse position }
end;
procedure TShowDrawForm.FormResize(Sender: TObject);
begin
Panel1.Height:= (Panel2.Height) div 2;
end;
procedure TShowDrawForm.Chart1Click(Sender: TObject);
Var
tmpX,tmpY,tempZ:Double;
i:Integer;
p:TPoint;
begin
Series1.GetCursorValues(tmpX,tmpY); { <-- get values under mouse cursor }
for i:=0 to rDDSInfo.Num-1 do
begin
tempZ:=Sqrt(Sqr(tmpX-rDDSInfo.PointX[i])+Sqr(tmpY-rDDSInfo.PointY[i]));
if tempZ <3 then
begin
p.Y := Chart1.LeftAxis.CalcYPosValue(Round(Series1.YValue[i]));
p.x := Chart1.BottomAxis.CalcXPosValue(Round(Series1.XValue[i]));
p := Chart1.ClientToScreen(p);
SetCursorPos(p.X, p.y);
Exit;
end;
end;
end;
procedure TShowDrawForm.Chart2Click(Sender: TObject);
Var
tmpX,tmpY,tempZ:Double;
i:Integer;
p:TPoint;
begin
LineSeries1.GetCursorValues(tmpX,tmpY); { <-- get values under mouse cursor }
for i:=0 to rNew_Infor.Num-1 do
begin
tempZ:=Sqrt(Sqr(tmpX-rNew_Infor.EndX[i])+Sqr(tmpY-rNew_Infor.DDS_E[i]));
if tempZ <5 then
begin
p.Y := Chart2.LeftAxis.CalcYPosValue(Round(LineSeries1.YValue[i+1]));
p.x := Chart2.BottomAxis.CalcXPosValue(Round(LineSeries1.XValue[i+1]));
p := Chart2.ClientToScreen(p);
SetCursorPos(p.X, p.y);
Exit;
end;
end;
end;
procedure TShowDrawForm.btn1Click(Sender: TObject);
begin
Chart1.Refresh;
Chart2.Refresh;
cht1.Refresh;
cht2.Refresh;
end;
procedure TShowDrawForm.FormShow(Sender: TObject);
begin
Label1.Caption:='铁路里程'+StrXUnite+'(米)';
Label2.Caption:='铁路里程'+StrXUnite+'(米)';
lbl1.Caption:='铁路里程'+StrXUnite+'(米)';
lbl2.Caption:='铁路里程'+StrXUnite+'(米)';
end;
procedure TShowDrawForm.RzPageControl1Change(Sender: TObject);
begin
if RzPageControl1.ActivePage.TabIndex=0 then
begin
Panel1.Height := (Panel2.Height) div 2;
Panel4.Enabled := True;
end;
if RzPageControl1.ActivePage.TabIndex=1 then
begin
Panel1.Height := (Panel2.Height) div 3;
cht2.Height := TabSheet2.Height div 2;
Panel4.Enabled:= False;
end;
end;
procedure TShowDrawForm.cht2MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
Procedure DrawCross(AX,AY:Integer);
begin
With cht2,Canvas do
begin
Pen.Color:=CrossHairColor;
Pen.Style:=CrossHairStyle;
Pen.Mode:=pmXor;
Pen.Width:=1;
MoveTo(ax,ChartRect.Top-Height3D);
LineTo(ax,ChartRect.Bottom-Height3D);
MoveTo(ChartRect.Left+Width3D,ay);
LineTo(ChartRect.Right+Width3D,ay);
end;
end;
Var tmpX,tmpY:Double;
begin
if (OldX3<>-1) then
begin
DrawCross(OldX3,OldY3); { draw old crosshair }
OldX3:=-1;
end;
{ check if mouse is inside Chart rectangle }
if PtInRect( cht2.ChartRect, Point(X-cht2.Width3D,Y+cht2.Height3D) ) then
begin
DrawCross(x,y); { draw crosshair at current position }
{ store old position }
OldX3:=x;
OldY3:=y;
{ set label text }
With LineSeries5 do
begin
GetCursorValues(tmpX,tmpY); { <-- get values under mouse cursor }
MainForm.RzStatusPane2.Caption:='X:'+GetVertAxis.LabelValue(Round(tmpX))+
'米 '+
'Y:'+GetHorizAxis.LabelValue(tmpY)+'伏';
end;
end;
end;
procedure TShowDrawForm.cht2AfterDraw(Sender: TObject);
begin
OldX3:=-1; { Reset old mouse position }
end;
procedure TShowDrawForm.LineSeries5AfterDrawValues(Sender: TObject);
begin
OldX3:=-1; { Reset old mouse position }
end;
procedure TShowDrawForm.cht1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
Procedure DrawCross(AX,AY:Integer);
begin
With cht1,Canvas do
begin
Pen.Color:=CrossHairColor;
Pen.Style:=CrossHairStyle;
Pen.Mode:=pmXor;
Pen.Width:=1;
MoveTo(ax,ChartRect.Top-Height3D);
LineTo(ax,ChartRect.Bottom-Height3D);
MoveTo(ChartRect.Left+Width3D,ay);
LineTo(ChartRect.Right+Width3D,ay);
end;
end;
Var tmpX,tmpY:Double;
begin
if (OldX4<>-1) then
begin
DrawCross(OldX4,OldY4); { draw old crosshair }
OldX4:=-1;
end;
{ check if mouse is inside Chart rectangle }
if PtInRect( cht1.ChartRect, Point(X-cht1.Width3D,Y+cht1.Height3D) ) then
begin
DrawCross(x,y); { draw crosshair at current position }
{ store old position }
OldX4:=x;
OldY4:=y;
{ set label text }
With LineSeries3 do
begin
GetCursorValues(tmpX,tmpY); { <-- get values under mouse cursor }
MainForm.RzStatusPane2.Caption:='X:'+GetVertAxis.LabelValue(Round(tmpX))+
'米 '+
'Y:'+GetHorizAxis.LabelValue(tmpY)+'伏';
end;
end;
end;
procedure TShowDrawForm.cht1AfterDraw(Sender: TObject);
begin
OldX4:=-1; { Reset old mouse position }
end;
procedure TShowDrawForm.LineSeries3AfterDrawValues(Sender: TObject);
begin
OldX4:=-1; { Reset old mouse position }
end;
procedure TShowDrawForm.ToolButton2Click(Sender: TObject);
var tmpH,tmpW:Longint;
begin
{ This code creates and stores a new BITMAP file
which contains the FOUR charts.
Asks previously the user the BMP filename.
}
with dlgSave1 do
begin
if Execute then
With TBitmap.Create do
try
tmpW:=Chart1.Width;
tmpH:=Chart1.Height;
Width := tmpW;
if RzPageControl1.ActivePageIndex=0 then
begin
{ calculate bitmap size (2x2) }
Height:= 2*tmpH;
{ draw chart 1 }
Chart1.BufferedDisplay:=False;
Chart1.Draw(Canvas,Rect(0,0,tmpW,tmpH));
Chart1.BufferedDisplay:=True;
{ draw chart 2 }
Chart2.BufferedDisplay:=False;
Chart2.Draw(Canvas,Rect(0,tmpH+1,tmpW,2*tmpH));
Chart2.BufferedDisplay:=True;
SaveToFile(FileName+'.BMP');
end;
if RzPageControl1.ActivePageIndex=1 then
begin
Height:= 3*tmpH;
{ draw chart 1 }
Chart1.BufferedDisplay:=False;
Chart1.Draw(Canvas,Rect(0,0,tmpW,tmpH));
Chart1.BufferedDisplay:=True;
{ draw chart 3 }
cht2.BufferedDisplay:=False;
cht2.Draw(Canvas,Rect(0,tmpH+1,tmpW,2*tmpH));
cht2.BufferedDisplay:=True;
{ draw chart 4 }
cht1.BufferedDisplay:=False;
cht1.Draw(Canvas,Rect(0,tmpH*2+1,tmpW,3*tmpH));
cht1.BufferedDisplay:=True;
SaveToFile(FileName+'.BMP');
end;
finally
Free;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -