zoukankan      html  css  js  c++  java
  • 基于Skyline的TerraExplorer6.1.1如何通过二次开发实现圆形对象的手动绘制

    在Skyline的TerraExplorer Pro软件中,用户可以轻松实现几何对象的手动绘制;但在实际的项目中,为了满足不同行业的需求,我们更多情况需要定制开发一些几何对象。这里,通过Skyline提供的开发接口实现圆形对象的绘制,希望能够扩展大家的一些实现思路。

    <!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>
        <title>手绘圆</title>
         <script type = "text/javascript" language = "javascript">
             
    var gPolyObj = null;         
             
    function StartCal() {
                 
    var SGWorld = new CreateSGObj();
                 SGWorld.AttachEvent(
    "OnLButtonDown", DrawPolyLButtonDown);
                 SGWorld.AttachEvent(
    "OnFrame", DrawPolyOnFrame);
                 SGWorld.Window.SetInputMode(
    1);
             }

             
    function EndCal() {
                 
    var SGWorld = new CreateSGObj();
                 SGWorld.DetachEvent(
    "OnLButtonDown", DrawPolyLButtonDown);
                 SGWorld.DetachEvent(
    "OnFrame", DrawPolyOnFrame);
                 SGWorld.Window.SetInputMode(
    0);
                 SGWorld 
    = null;
                 gPolyObj 
    = null;
             }

             
    function CreateTempGroup(groupname) {
                 
    var SGWorld = new CreateSGObj();
                 
    var gid = SGWorld.ProjectTree.FindItem(groupname);             
                 
    if (gid > 0) {
                     
                 }
                 
    else {
                     gid 
    = SGWorld.ProjectTree.CreateLockedGroup(groupname, 0);
                 }
                 
    return gid;
             }

             
    function DelTemp(groupname) {
                 
    var SGWorld = new CreateSGObj();
                 
    var gid = SGWorld.ProjectTree.FindItem(groupname);
                 
    if (gid > 0) {
                     SGWorld.ProjectTree.DeleteItem(gid);
                 }
             }

             
    var gPolyText = "";
             
    //********************************************绘制Circle
             function DrawPolyLButtonDown(Flags, X, Y) {
                 
    try {
                     
    var SGWorld = CreateSGObj();
                     
    var CursorCoord = SGWorld.Window.pixelToWorld(X, Y);
                     
    if (CursorCoord == null)
                         
    return false;

                     
    if (gPolyObj == null) {
                         
    var gid = CreateTempGroup("标绘");
                         
    var pos = SGWorld.Creator.CreatePosition(CursorCoord.Position.X, CursorCoord.Position.Y, 020000);
                         gPolyObj 
    = SGWorld.Creator.CreateCircle(pos, 1, SGWorld.Creator.CreateColor(255001), SGWorld.Creator.CreateColor(255001), gid, gPolyText);
                         gPolyObj.LineStyle.Width 
    = 1;
                     }
                     
    else {
                         EndCal();
                     }
                 }
                 
    catch (e)
                 { }
             }
             
    //-----------
             // 跟随鼠标位置移动,改变圆半径大小
             //-----------
             function DrawPolyOnFrame() {
                 
    try {
                     
    var SGWorld = CreateSGObj();
                     
    if (gPolyObj != null) {

                         
    var mouseInfo = SGWorld.Window.GetMouseInfo();
                         
    var CursorCoord = SGWorld.Window.pixelToWorld(mouseInfo.X, mouseInfo.Y);
                         
    if (CursorCoord == null)
                             
    return false;
                         
    var dr = gPolyObj.Position.DistanceTo(CursorCoord.Position);
                         gPolyObj.Radius 
    = dr;
                     }
                 }
                 
    catch (e) { }
             }

             
    /*  
             功能:   创建sgworld对象
             备注:   赵贺 2011.04.01.
             
    */
             
    function CreateSGObj() {
                 
    var obj = $("sgworld");
                 
    if (obj == null) {
                     obj 
    = document.createElement('object');
                     document.body.appendChild(obj);
                     obj.name 
    = "sgworld";
                     obj.id 
    = "sgworld";
                     obj.classid 
    = "CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1";
                 }
                 
    return obj;
             }
             
    function $(id) {
                 
    return window.document.getElementById(id);
             }        
         
    </script>
    </head>
    <body onunload="DelTemp('标绘')">
        <table style="margin: 0px; border: 0px;">
            <tr>
                <td colspan="4">
                    <input id="Button6" type="button" value="绘制" onclick="StartCal()" />        
                    <input id="Button1" type="button" value="清除" onclick="DelTemp('标绘')" />
                </td>
            </tr>       
        </table>
    </body>
    </html>

     

  • 相关阅读:
    mysql 执行计划 explain
    深度学习论文翻译解析(二十):YOLOv4: Optimal Speed and Accuracy of Object Detection
    卷积神经网络学习笔记——轻量化网络MobileNet系列(V1,V2,V3)
    OpenCV计算机视觉学习(13)——图像特征点检测(Harris角点检测,sift算法)
    人工智能必备数学基础:概率论与数理统计(2)
    人工智能必备数学基础:概率论与数理统计(1)
    深度学习论文翻译解析(十九):Searching for MobileNetV3
    深度学习论文翻译解析(十八):MobileNetV2: Inverted Residuals and Linear Bottlenecks
    深度学习论文翻译解析(十七):MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
    卷积神经网络学*笔记——SENet
  • 原文地址:https://www.cnblogs.com/yitianhe/p/2713296.html
Copyright © 2011-2022 走看看