Skyline TEP5.1.3二次开发入门——初级(三)
6.3 IObjectManager51
主要用来实现对象的创建、编辑等操作,结合ITerraExplorerObject5等对象接口,来实现各种类型对象的三维渲染功能;
CreatePolyline |
创建线对象; |
Create2DPolygon |
创建多边形对象; |
CreateRectangle |
创建矩形对象; |
CreateRegularPolygon |
创建正多边形对象; |
CreateCircle |
创建圆对象; |
Create3DPolygon |
创建三维多边形对象; |
CreateBuilding |
创建建筑物对象; |
CreateBox |
创建箱子对象; |
CreatePyramid |
创建金字塔对象; |
CreateCylinder |
创建圆柱体对象; |
CreateCone |
创建圆锥体对象; |
CreateEllipse |
创建椭圆对象; |
CreateArc |
创建弧对象; |
CreateArrow |
创建箭头对象; |
Create3DArrow |
创建三维箭头对象; |
CreateSphere |
创建球体对象; |
CreateModel |
创建模型对象; |
CreateLabel |
创建标签对象; |
CreateLabelEx |
创建扩展的标签对象; |
CreateLocation |
创建位置对象; |
CreateTreeHotlink |
创建树消息连接对象; |
CreateRoute |
创建路径对象; |
CreateMessage |
创建消息对象; |
GetObject |
获得对象; |
CreateImageLabel |
创建影像标签对象; |
CreateImageLabelEx |
创建影像标签对象; |
CreateDynamicObject |
创建动态对象; |
CreateImageryLayer |
创建 影像图层对象; |
CreateElevationLayer |
创建高程层; |
CreateVideoOnTerrain |
创建视频对象; |
CreatePointCloudModel |
创建点云模型对象; |
CreateFromStream |
保留,当前不可用; |
GetFirstObjectPosition |
保留,当前不可用; |
GetNextObject |
保留,当前不可用; |
GetInfoTreeItemID |
获取信息树中对象ItemID值; |
SetObjectParam |
保留,当前不可用; |
GetObjectParam |
保留,当前不可用; |
CreateTerrainModifier |
创建地形修整对象; |
CreateHoleOnTerrain |
创建地形开洞对象; |
代码示例:
【C#】
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TerraExplorerX;
namespace ExCodeIObjMgr
{
public partial class Form1 : Form
{
private TerraExplorer TE;
private ITerraExplorer51 TE51;
private IPlane5 IPlane;
private IObjectManager51 IObjectManager;
public Form1()
{
InitializeComponent();
this.TE = new TerraExplorerClass();
this.TE51 = (ITerraExplorer51)TE;
this.IPlane = (IPlane5)TE;
IObjectManager = (IObjectManager51)TE;
TE51.Load(Application.StartupPath + "\\Default.fly");
}
private void btnCreateLabel_Click(object sender, EventArgs e)
{
LabelStruct myls = new LabelStruct();
myls.Text = "Skyline";
ITerrainLabel5 myLabel = null;
myLabel = IObjectManager.CreateLabel(myls, 120, 38, 10000, HeightStyleCode.HSC_TERRAIN_ABSOLUTE, 0, "Skyline");
myLabel.Text = "Skyline";
myLabel.ScaleFactor = 6000;
myLabel.LimitGrowth = 1;
myLabel.Distance = 1111111;
IPlane.FlyToObject(myLabel.ID, ActionCode.AC_FLYTO);
}
}
}
【javascript】
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="IObjectManager51.aspx.cs" Inherits="ExCode_IObjectManager51" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Skyline二次开发教程【配套示例】</title>
<script type ="text/javascript">
function Init() {
var TE = _$SGCreateTEObj();
var ITerraExplorer = TE.interface("ITerraExplorer51");
ITerraExplorer.Load("D:\\2010售前演示系统\\WPFA-DEMO\\WPFA-DEMO\\bin\\Debug\\FLY\\Default.fly");
}
function AddLabel() {
var myobj = createlabel(120, 38, 10000, "Skyline");
var IPlane = TE.interface("IPlane5");
IPlane.FlyToObject(myobj.ID,0);
}
//------------------------------------------------------------
// 创建标注 赵贺 2009.06.30.
//------------------------------------------------------------
function createlabel(x, y, h, value) {
var TE = _$SGCreateTEObj();
if (tempLabel != null) {
var IInformationTree = TE.interface("IInformationTree5");
IInformationTree.DeleteItem(tempLabel.InfoTreeItemID);
}
var IObjectManager = TE.interface("IObjectManager51");
var LabelInfo = new Object;
LabelInfo.Text = value;
LabelInfo.Scale = 20000;
LabelInfo.FontName = "宋体";
LabelInfo.FontStyle = 1;
LabelInfo.FontSize = 10;
LabelInfo.FgColor = 0x00ffff;
LabelInfo.BgColor = 0x0d0d0d;
LabelInfo.LineToGroundType = 1;
LabelInfo.AlignLabelHorizontal = 2;
LabelInfo.AlignLabelVertical = 1;
var gid = 0;
var tempLabel = IObjectManager.CreateLabel(LabelInfo, x, y, 10, 0, gid, value);
tempLabel.Distance = h;
tempLabel.LimitGrowth = true;
var myMessageID = IObjectManager.CreateMessage(5, 0, 0, 32 + 2, "Skyline", -1, 10, 10, 200, 300, 0);
tempLabel.MessageID = myMessageID.ID;
return tempLabel;
}
//------------------------------------------------------------
// 创建三维对象 赵贺 2009.01.25.
//------------------------------------------------------------
function _$SGCreateTEObj() {
var obj = window.document.getElementById("TE");
if (obj == null) {
obj = document.createElement('object');
document.body.appendChild(obj);
obj.name = "TE";
obj.id = "TE";
obj.classid = "CLSID:3a4f9191-65a8-11d5-85c1-0001023952c1";
}
return obj;
}
//------------------------------------------------------------
// 定义集合参数 赵贺 2009.01.25.
//------------------------------------------------------------
function _$SGWorldParam() {
this.x = 0;
this.y = 0;
this.h = 0;
this.yaw = 0;
this.pitch = 0;
this.roll = 0;
this.OID = 0;
this.OType = 0;
}
</script>
<script type ="text/vbscript">
'------------------------------------------------------------
' IPlane GetPosition 赵贺 2009.01.25.
'------------------------------------------------------------
sub GetPosition(param)
Dim dx,dy,dh,dyaw,dpitch,droll,dcyaw,dcpitch
Dim IPlane
Set IPlane = TE.interface("IPlane5")
IPlane.GetPosition dx,dy,dh,dyaw,dpitch,droll,dcyaw,dcpitch
param.x = dx
param.y = dy
param.h = dh
param.yaw = dyaw+dcyaw
param.pitch = dpitch+dcpitch
param.roll = droll
param = dh
end sub
</script>
</head>
<body onload = "Init()">
<form id="form1" runat="server">
<div id = "Title">
<input id="Button1" type="button" value="添加标注" onclick = "AddLabel()" />
</div>
<div id="Main">
<object id="TerraExplorer3DWindow" classid="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1"
width="521" height="521">
</object>
</div>
</form>
</body>
</html>