pointQuery.html
2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!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>