彭
彭真
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么我一调用那个xyscreen2world过程,就会出错,显示无效的float数据,帮我看一下,这几个过程
主要是xyworld2screen ,xyscreen2world和pan
type
TForm1 = class(TForm)
.......................
...........
procedure drawmap;
procedure drawgrid;
end;
type
Tgeodrv =class(Tobject)
private
sScale:single;
screenleft,screentop,screenright,screenbottom:integer;
public
xworldmin,yworldmin,xworldmax,yworldmax:single;
canvas:Tcanvas;
constructor create(Acanvas:Tcanvas);
procedure xyworld2screen(x,y:single;var xx,yy:integer);
virtual;
procedure xyscreen2world(x,y:integer;var xx,yy:single);
virtual;
.........
end;
var
Form1: TForm1;
Gdrv:TGeodrv;
implementation
......
//着两个坐标转换过程怎么总是有错啊???
procedure Tgeodrv.xyworld2screen(x,y:single;var xx,yy:integer);
begin
xx:=trunc((x-xworldmin)*sscale)+screenleft;
yy:=trunc((yworldmax-y)*sscale)+screentop;
end;
procedure Tgeodrv.xyscreen2world(x,y:integer;var xx,yy:single);
begin
xx:=(x-screenleft/sscale+xworldmin);
yy:=yworldmax-(y-screentop)/sscale;
end;
procedure Tform1.drawmap;
begin
Gdrv.clear;
form1.drawgrid;
end;
..........
procedure TForm1.FormCreate(Sender: TObject);
begin
....
gdrv:=tgeodrv.create(form1.PaintBox1.Canvas);
end;
procedure TForm1.PaintBox1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
var xt,yt:single;
begin
//每次调用都显示出错,真搞不懂。本来是很简单,却不知道错在哪里?
Gdrv.xyscreen2world(x,y,xt,yt);
statusbar1.simpletext:=format('(%d,%d)-(%f,%f)',[x,y,xt,yt]);
end;
end.
主要是xyworld2screen ,xyscreen2world和pan
type
TForm1 = class(TForm)
.......................
...........
procedure drawmap;
procedure drawgrid;
end;
type
Tgeodrv =class(Tobject)
private
sScale:single;
screenleft,screentop,screenright,screenbottom:integer;
public
xworldmin,yworldmin,xworldmax,yworldmax:single;
canvas:Tcanvas;
constructor create(Acanvas:Tcanvas);
procedure xyworld2screen(x,y:single;var xx,yy:integer);
virtual;
procedure xyscreen2world(x,y:integer;var xx,yy:single);
virtual;
.........
end;
var
Form1: TForm1;
Gdrv:TGeodrv;
implementation
......
//着两个坐标转换过程怎么总是有错啊???
procedure Tgeodrv.xyworld2screen(x,y:single;var xx,yy:integer);
begin
xx:=trunc((x-xworldmin)*sscale)+screenleft;
yy:=trunc((yworldmax-y)*sscale)+screentop;
end;
procedure Tgeodrv.xyscreen2world(x,y:integer;var xx,yy:single);
begin
xx:=(x-screenleft/sscale+xworldmin);
yy:=yworldmax-(y-screentop)/sscale;
end;
procedure Tform1.drawmap;
begin
Gdrv.clear;
form1.drawgrid;
end;
..........
procedure TForm1.FormCreate(Sender: TObject);
begin
....
gdrv:=tgeodrv.create(form1.PaintBox1.Canvas);
end;
procedure TForm1.PaintBox1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
var xt,yt:single;
begin
//每次调用都显示出错,真搞不懂。本来是很简单,却不知道错在哪里?
Gdrv.xyscreen2world(x,y,xt,yt);
statusbar1.simpletext:=format('(%d,%d)-(%f,%f)',[x,y,xt,yt]);
end;
end.