?? main.pas
字號(hào):
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, ADODB;
const
startx = 40;
startY = 40;
type
TForm1 = class(TForm)
Image1: TImage;
Button3: TButton;
shuangdinglen: TEdit;
Label1: TLabel;
fulen: TEdit;
Label2: TLabel;
gugulen: TEdit;
Label3: TLabel;
Button5: TButton;
Label4: TLabel;
cbleixing: TComboBox;
Label5: TLabel;
yunzhou: TEdit;
Label6: TLabel;
Image2: TImage;
ADOdata: TADOConnection;
adoqry: TADOQuery;
Image3: TImage;
Image4: TImage;
Image5: TImage;
Label7: TLabel;
gonggulen: TEdit;
cbnetgrid: TCheckBox;
cbstandline: TCheckBox;
Button1: TButton;
Label8: TLabel;
toutunlen: TEdit;
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
//參數(shù)說(shuō)明: 1.繪圖的母體 2.曲線類型名3.橫坐標(biāo)4.縱坐標(biāo)5.行數(shù)6.列數(shù)7.橫寬8.列寬9.橫坐標(biāo)初始值
Function drawbackimage(tempbmp:Timage;itemname,itemXvalue,itemYvalue:string;rowsnumber,colsnumber,rowwidth,colwidth,tempvalue:integer):boolean; //網(wǎng)格
Function drawstandline(tempbmp:Timage;itemname:string;maxheight,maxwidth:integer):boolean; //曲線
Function drawcurrentpostion(tempbmp:Timage;maxheight,maxwidth,currentXpostion,currentYpostion:integer):boolean;
Function drawCRLline(tempbmp:timage;itemname:string;maxheight,maxwidth:integer):boolean;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Function Tform1.drawbackimage(tempbmp:Timage;itemname,itemXvalue,itemYvalue:string;rowsnumber,colsnumber,rowwidth,colwidth,tempvalue:integer):boolean;
var rows,cols,itemheight,itemwidth,tempwidth:integer;
textrow,textcol:string;
i : integer;
begin
rows := rowsnumber;
cols := colsnumber;
itemheight := colwidth; //橫間距
itemwidth := rowwidth; //列間距
textcol := itemXvalue;
textrow := itemYvalue;
tempwidth := tempvalue;
with tempbmp.Canvas do
begin
pen.Color := clwhite;
brush.Color := clwhite;
Rectangle(0,0,tempbmp.Width,tempbmp.Height);
pen.Width := 2;
pen.Color := clblack;
moveto(startx,starty);
lineto(startx,tempbmp.Height-starty);
lineto(tempbmp.width-startx,tempbmp.Height-starty);
pen.Width := 1;
lineto(tempbmp.width-startx,starty);
lineto(startx,starty);
pen.Color := $00E1E1E1;
for i :=0 to rows do
begin
moveto(startx,tempbmp.Height-startx-((tempbmp.height-4-startx*2)* i div rows) );
if cbnetgrid.Checked then
lineto(tempbmp.Width-startx,tempbmp.Height-starty-((tempbmp.Height-4-starty*2)* i div rows) );
textout(startx div 2-5,tempbmp.Height-starty-((tempbmp.Height-4-startx*2)* i div rows) -5,inttoSTR(i * itemheight));
end;
for i:= 0 to cols do
begin
moveto(startx+((tempbmp.Width-6-startx*2)* i div cols),starty+1);
if cbnetgrid.Checked then
lineto(startx+((tempbmp.Width-6-startx*2)* i div cols),tempbmp.Height-starty-1);
textout(startx+((tempbmp.Width-6-startx*2)* i div cols)-5,tempbmp.Height-starty + 5,inttostr((tempwidth+i)*itemwidth));
end;
//畫(huà)文字
pen.Color := clblack;
Font.Size := 9;
TextOut((tempbmp.Width - 40) div 2 ,tempbmp.Height-starty div 2,textrow);
//Font.Name := '隸書(shū)';
TextOut(startx div 2,starty -20,textcol);
end;
result := true;
end;
//繪圖母體,曲線名,高度最大值 ,寬度最大值
Function Tform1.drawstandline(tempbmp:Timage;itemname:string;maxheight,maxwidth:integer):boolean;
var currentXvalue,currentYvalue,topx,topy:integer;
rowmaxvalue,colmaxvalue,colsmaxcount:integer;
currentitemname:string;
i : integer;
tempvalue : array[1..30,1..2] of integer;
begin
tempbmp.Canvas.Pen.Width := 1;
currentitemname := itemname; //曲線名,也是字段值
rowmaxvalue := maxheight;
colmaxvalue := maxwidth;
with adoqry do
begin
active := false;
sql.Clear;
sql.Add('select * from itemvalue where itemname='+''''+currentitemname+''''+' and itemvalue='+''''+'tou_5'+'''');
active := true;
first;
if eof then
begin
application.MessageBox('沒(méi)找到相關(guān)曲線參數(shù),請(qǐng)?jiān)O(shè)置曲線參數(shù)','提示');
exit;
end;
//rowsmaxcount := fields.Count-4;
colsmaxcount := fields.Count-4;
for i:= 1 to 30 do
begin
tempvalue[i,1] := 999;
tempvalue[i,2] := 999;
end;
for i:= 3 to fields.Count-3 do
begin
tempvalue[i-2,1] := startx+((tempbmp.Width-6-startx*2) * (i-3) div colsmaxcount); //strtoint(copy(fields[i].FieldName,5,length(fields[i].FieldName)-4));
tempvalue[i-2,2] := tempbmp.Height-starty- (tempbmp.Height-4-starty*2)* fields[i].AsInteger div rowmaxvalue ;
end;
tempvalue[fields.Count-4,1] := startx+((tempbmp.Width-6-startx*2) * colsmaxcount div colsmaxcount);
tempvalue[fields.Count-4,2] := tempbmp.Height-starty-(tempbmp.Height-4-starty*2) * fields[fields.Count-2].AsInteger div rowmaxvalue;
end;
for i:= 1 to 30 do
begin
if (tempvalue[i,1]=999) or (tempvalue[i,2]=999) then
begin
tempvalue[i,1] := tempvalue[i-1,1];
tempvalue[i,2] := tempvalue[i-1,2];
end;
end;
with tempbmp.Canvas do
begin
pen.Color := clgreen;
polyline([point(tempvalue[1,1], tempvalue[1,2]), point(tempvalue[2,1], tempvalue[2,2]), point(tempvalue[3,1], tempvalue[3,2]), point(tempvalue[4,1], tempvalue[4,2]), point(tempvalue[5,1], tempvalue[5,2]), point(tempvalue[6,1], tempvalue[6,2]), point(tempvalue[7,1], tempvalue[7,2]), point(tempvalue[8,1], tempvalue[8,2]),
point(tempvalue[9,1], tempvalue[9,2]), point(tempvalue[10,1], tempvalue[10,2]), point(tempvalue[11,1], tempvalue[11,2]), point(tempvalue[12,1], tempvalue[12,2]), point(tempvalue[13,1], tempvalue[13,2]), point(tempvalue[14,1], tempvalue[14,2]), point(tempvalue[15,1], tempvalue[15,2]), point(tempvalue[16,1], tempvalue[16,2]),
point(tempvalue[17,1], tempvalue[17,2]), point(tempvalue[18,1], tempvalue[18,2]), point(tempvalue[19,1], tempvalue[19,2]), point(tempvalue[20,1], tempvalue[20,2]), point(tempvalue[21,1], tempvalue[21,2]), point(tempvalue[22,1], tempvalue[22,2]), point(tempvalue[23,1], tempvalue[23,2]), point(tempvalue[24,1], tempvalue[24,2]),
point(tempvalue[24+1,1],tempvalue[24+1,2]),point(tempvalue[24+2,1], tempvalue[24+2,2]), point(tempvalue[24+3,1], tempvalue[24+3,2]), point(tempvalue[24+4,1], tempvalue[24+4,2]), point(tempvalue[24+5,1], tempvalue[24+5,2]), point(tempvalue[24+6,1], tempvalue[24+6,2]) ]);
end;
with adoqry do
begin
active := false;
sql.Clear;
sql.Add('select * from itemvalue where itemname='+''''+currentitemname+''''+' and itemvalue='+''''+'tou_50'+'''');
active := true;
first;
if eof then
begin
application.MessageBox('沒(méi)找到相關(guān)曲線參數(shù),請(qǐng)?jiān)O(shè)置曲線參數(shù)','提示');
exit;
end;
//rowsmaxcount := fields.Count-4;
colsmaxcount := fields.Count-4;
for i:= 1 to 30 do
begin
tempvalue[i,1] := 999;
tempvalue[i,2] := 999;
end;
for i:= 3 to fields.Count-3 do
begin
tempvalue[i-2,1] := startx+((tempbmp.Width-6-startx*2)* (i-3) div colsmaxcount); //strtoint(copy(fields[i].FieldName,5,length(fields[i].FieldName)-4));
tempvalue[i-2,2] := tempbmp.Height-starty- (tempbmp.Height-4-starty*2) * fields[i].AsInteger div rowmaxvalue;
end;
tempvalue[fields.Count-4,1] := startx+((tempbmp.Width-6-startx*2) * colsmaxcount div colsmaxcount);
tempvalue[fields.Count-4,2] := tempbmp.Height-starty-(tempbmp.Height-4-starty*2) * fields[fields.Count-2].AsInteger div rowmaxvalue;
end;
for i:= 1 to 30 do
begin
if (tempvalue[i,1]=999) or (tempvalue[i,2]=999) then
begin
tempvalue[i,1] := tempvalue[i-1,1];
tempvalue[i,2] := tempvalue[i-1,2];
end;
end;
with tempbmp.Canvas do
begin
pen.Color := clred;
polyline([point(tempvalue[1,1], tempvalue[1,2]), point(tempvalue[2,1], tempvalue[2,2]), point(tempvalue[3,1], tempvalue[3,2]), point(tempvalue[4,1], tempvalue[4,2]), point(tempvalue[5,1], tempvalue[5,2]), point(tempvalue[6,1], tempvalue[6,2]), point(tempvalue[7,1], tempvalue[7,2]), point(tempvalue[8,1], tempvalue[8,2]),
point(tempvalue[9,1], tempvalue[9,2]), point(tempvalue[10,1], tempvalue[10,2]), point(tempvalue[11,1], tempvalue[11,2]), point(tempvalue[12,1], tempvalue[12,2]), point(tempvalue[13,1], tempvalue[13,2]), point(tempvalue[14,1], tempvalue[14,2]), point(tempvalue[15,1], tempvalue[15,2]), point(tempvalue[16,1], tempvalue[16,2]),
point(tempvalue[17,1], tempvalue[17,2]), point(tempvalue[18,1], tempvalue[18,2]), point(tempvalue[19,1], tempvalue[19,2]), point(tempvalue[20,1], tempvalue[20,2]), point(tempvalue[21,1], tempvalue[21,2]), point(tempvalue[22,1], tempvalue[22,2]), point(tempvalue[23,1], tempvalue[23,2]), point(tempvalue[24,1], tempvalue[24,2]),
point(tempvalue[24+1,1],tempvalue[24+1,2]),point(tempvalue[24+2,1], tempvalue[24+2,2]), point(tempvalue[24+3,1], tempvalue[24+3,2]), point(tempvalue[24+4,1], tempvalue[24+4,2]), point(tempvalue[24+5,1], tempvalue[24+5,2]), point(tempvalue[24+6,1], tempvalue[24+6,2]) ]);
end;
with adoqry do
begin
active := false;
sql.Clear;
sql.Add('select * from itemvalue where itemname='+''''+currentitemname+''''+' and itemvalue='+''''+'tou_95'+'''');
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -