delphi, Mapobjects(mo)开发一些技巧,图形对象类型转换
2007-12-06 21:37
603 查看
function CircleToPline(MEllipse: IMoEllipse): IMoLine;
var
i : Integer;
pt : IMoPoint;
pts : IMoPoints;
a, b : Double; //分别长半轴与短半轴
x, y : Double; //圆心
Mline : IMoLine;
begin
pt := CoPoint.Create;
pts := CoPoints.Create;
a := MEllipse.Width / 2;
b := MEllipse.Height / 2;
x := MEllipse.Center.X;
Y := MEllipse.Center.y;
for i := 0 to Resolution do
begin
pt.X := x + a * Cos(2 * Pi * i / Resolution);
pt.y := Y + b * Sin(2 * Pi * i / Resolution);
pts.Add(pt);
end;
Mline := CoLine.Create;
Mline.Parts.Add(pts);
result := Mline;
end;
//by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2001.03.03编写
//矩形转化为区域
{******************************************* yl Write *******************************************}
function RectToRegion(MRectangle: IMoRectangle): IMoPolygon;
var
Obj : IMoPolygon;
i : Integer;
pts : array[0..3] of IMoPoint;
Ptss : IMoPoints;
begin
Obj := CoPolygon.Create;
for i := 0 to 3 do
begin
pts[i] := CoPoint.Create;
end;
with MRectangle do
begin
pts[0].X := Left;
pts[0].Y := top;
pts[1].X := Left;
pts[1].Y := Bottom;
pts[2].X := Right;
pts[2].Y := Bottom;
pts[3].X := Right;
pts[3].Y := top;
end;
Ptss := CoPoints.Create;
for i := 0 to 3 do
ptss.Add(pts[i]);
ptss.Add(pts[0]);
obj.Parts.Add(ptss);
result := obj;
end;
//矩形转化为线
{******************************************* yl Write *******************************************}
function RectToPline(MRectangle: IMoRectangle): IMoLine;
var
Mline : IMoLine;
i : Integer;
pts : array[0..3] of IMoPoint;
Ptss : IMoPoints;
begin
Mline := CoLine.Create;
for i := 0 to 3 do
begin
pts[i] := CoPoint.Create;
end;
with MRectangle do
begin
pts[0].X := Left;
pts[0].Y := top;
pts[1].X := Left;
pts[1].Y := Bottom;
pts[2].X := Right;
pts[2].Y := Bottom;
pts[3].X := Right;
pts[3].Y := top;
end;
Ptss := CoPoints.Create;
for i := 0 to 3 do
ptss.Add(pts[i]);
ptss.Add(pts[0]);
Mline.Parts.Add(ptss);
result := Mline;
end;
var
i : Integer;
pt : IMoPoint;
pts : IMoPoints;
a, b : Double; //分别长半轴与短半轴
x, y : Double; //圆心
Mline : IMoLine;
begin
pt := CoPoint.Create;
pts := CoPoints.Create;
a := MEllipse.Width / 2;
b := MEllipse.Height / 2;
x := MEllipse.Center.X;
Y := MEllipse.Center.y;
for i := 0 to Resolution do
begin
pt.X := x + a * Cos(2 * Pi * i / Resolution);
pt.y := Y + b * Sin(2 * Pi * i / Resolution);
pts.Add(pt);
end;
Mline := CoLine.Create;
Mline.Parts.Add(pts);
result := Mline;
end;
//by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2001.03.03编写
//矩形转化为区域
{******************************************* yl Write *******************************************}
function RectToRegion(MRectangle: IMoRectangle): IMoPolygon;
var
Obj : IMoPolygon;
i : Integer;
pts : array[0..3] of IMoPoint;
Ptss : IMoPoints;
begin
Obj := CoPolygon.Create;
for i := 0 to 3 do
begin
pts[i] := CoPoint.Create;
end;
with MRectangle do
begin
pts[0].X := Left;
pts[0].Y := top;
pts[1].X := Left;
pts[1].Y := Bottom;
pts[2].X := Right;
pts[2].Y := Bottom;
pts[3].X := Right;
pts[3].Y := top;
end;
Ptss := CoPoints.Create;
for i := 0 to 3 do
ptss.Add(pts[i]);
ptss.Add(pts[0]);
obj.Parts.Add(ptss);
result := obj;
end;
//矩形转化为线
{******************************************* yl Write *******************************************}
function RectToPline(MRectangle: IMoRectangle): IMoLine;
var
Mline : IMoLine;
i : Integer;
pts : array[0..3] of IMoPoint;
Ptss : IMoPoints;
begin
Mline := CoLine.Create;
for i := 0 to 3 do
begin
pts[i] := CoPoint.Create;
end;
with MRectangle do
begin
pts[0].X := Left;
pts[0].Y := top;
pts[1].X := Left;
pts[1].Y := Bottom;
pts[2].X := Right;
pts[2].Y := Bottom;
pts[3].X := Right;
pts[3].Y := top;
end;
Ptss := CoPoints.Create;
for i := 0 to 3 do
ptss.Add(pts[i]);
ptss.Add(pts[0]);
Mline.Parts.Add(ptss);
result := Mline;
end;
相关文章推荐
- java fastjson如何自定义转换含枚举类型对象(编程技巧)
- 记录开发Nodejs c++ addon的一些经验(二、数据类型的转换)
- Pandas实现数据类型转换的一些小技巧汇总
- 如何在.net开发的代码中遍历所有的图形对象,并判断是什么类型的对象!
- [Delphi]Delphi开发的一些技巧
- C#.NET开发Winform使用MySQL数据库 无法将“System.Byte[]”的对象强制转换为类型“System.IConvertible”
- IOS开发第二讲 基本数据类型 类的新建 一些常用技巧
- Delphi开发的一些技巧
- java中(一些技巧)contains 方法的作用 字符串转换int 类型
- Delphi开发的一些技巧
- DELPHI的一些开发技巧和方法(一)
- delphi中转换office word文件为HTML文件,或者其它类型的文件的一些总结
- DELPHI的一些开发技巧和方法(二)
- 通讯转换工具开发_webservice储值卡项目总结之webservice复杂对象类型
- java fastjson如何自定义转换含枚举类型对象(编程技巧)
- delphi 对应 c# 的一些函数及类型的转换方法【原】
- 解析PHP将对象转换成数组的方法(兼容多维数组类型)
- day_03_引用、类型转换、类和对象
- iOS开发的一些技巧
- List中存放不同类型对象之间的转换