pointQuery.html 2.71 KB
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="/static/js/jquery-3.4.1.min.js"></script>
    <script src="/static/js/JavaScript.js"></script>
    <script src="/static/js/popupJS.js"></script>
    <link rel="stylesheet" href="/static/css/search.css">

    <script src="/static/js/eventJS/search.js"></script>
</head>

<body marginwidth="0" marginheight="0">
    <div id="mainDiv" class="dialog tiaojian">
        <h1 class="title" onmousedown="MouseDown(event)" onmouseup="MouseUp(event)" onmouseout="MouseUp(event)">
            点击查询<i class="guanbibtn" onclick="Close()">X</i>
        </h1>
        <div class="tool">
            <i title="点击" onclick="selectObject()">点击</i>
        </div>
        <div class="result">
            <h1 class="dialog title">属性展示</h1>
            <ul class="ul">
                <li class="item">
                    <span class="name">属性名</span>
                    <span class="value">属性值</span>
                </li>
            </ul>
            <div class="showdiv">
                <ul class="ul" id="liitems">
                </ul>
            </div>
        </div>
    </div>




    <script>
        function selectObject() {
            var sgworld = CreateSGObj();
            //添加鼠标左键单击事件
            sgworld.AttachEvent("OnLButtonClicked", pointQuery);
            sgworld.Window.SetInputMode(1, "", true);
        }

        // 点击查询功能的鼠标左键点击绑定事件,点击完成后解除绑定
        function pointQuery(Flags, X, Y) {
            var sgworld = CreateSGObj();
            var wpi = sgworld.Window.PixelToWorld(X, Y, -1);
            if (null == wpi) {
                alert("false");
                return false;
            }
            // alert(wpi.ObjectID);
            var pointObj = sgworld.ProjectTree.GetObject(wpi.ObjectID);
            sgworld.DetachEvent("OnLButtonClicked", pointQuery);
            sgworld.Window.SetInputMode(0, "", true);
            //获取点击的对象的属性值
            var msg = getObjectAttributes(pointObj);
            if (!msg.error) {
                $("#liitems").html("");
                //根据获取的属性对象添加相关的组件
                var arr = Object.keys(msg);
                for (var index = 0; index < arr.length; index++) {
                    addItem(arr[index], msg[arr[index]]);
                }
            }

        }

        function addItem(name, value) {
            str = "<li class='item'>" +
                "<span class='name'>" + name + "</span>" +
                "<span class='value'>" + value + "</span></li>";
            $("#liitems").append(str);
        }
    </script>
</body>

</html>