PlotPanel.js
7.92 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
L.supermap.plotting.initPlotPanel = function(div, serverUrl, drawControl,plotEditControl){
var plotPanel = document.getElementById(div);
var treeNodeStyle = document.createElement("div");
treeNodeStyle.style.height = '50%';
treeNodeStyle.style.width = '100%';
treeNodeStyle.style.border = '1px solid #617775';
treeNodeStyle.style.overflow ='scroll';
var treeNode = document.createElement("div");
treeNode.id = "tree";
treeNode.className = "ztree";
var iconNodeStyle = document.createElement("div");
iconNodeStyle.style.height = '50%';
iconNodeStyle.style.width = '100%';
var iconNode = document.createElement("div");
iconNode.id = "icon";
iconNode.style.height = '100%';
iconNode.style.width = '100%';
iconNode.style.border = '1px solid #617775';
iconNode.style.overflow ='scroll';
treeNodeStyle.appendChild(treeNode);
iconNodeStyle.appendChild(iconNode);
plotPanel.appendChild(treeNodeStyle);
plotPanel.appendChild(iconNodeStyle);
function beforeClickTreeNode(treeId, treeNode){
var tree = $.fn.zTree.getZTreeObj(treeId);
if (treeNode.isParent) {
tree.expandNode(treeNode);
return false;
} else {
var iconNode = document.getElementById("icon");
iconNode.innerHTML = "";
createDrawNodes(treeNode, iconNode, drawControl, serverUrl);
}
}
var setting = {
view: {
dblClickExpand: false,
showLine: true,
selectedMulti: false
},
data: {
simpleData: {
enable:true,
idKey: "id",
pIdKey: "pId",
rootPId: 0
}
},
callback: {
beforeClick: beforeClickTreeNode
}
};
var symbolLibManager = L.supermap.plotting.symbolLibManager(serverUrl);
if(symbolLibManager.isInitializeOK()){
var symbolTreeData = analysisSymbolTree(symbolLibManager);
$.fn.zTree.init($("#tree"), setting, symbolTreeData);
} else {
symbolLibManager.on(SuperMap.Plot.Event.initializecompleted, function(result){
if(result.libIDs.length !== 0){
var symbolTreeData = analysisSymbolTree(symbolLibManager);
$.fn.zTree.init($("#tree"), setting, symbolTreeData);
}});
symbolLibManager.initializeAsync();
}
}
function analysisSymbolTree(symbolLibManager) {
var treeData = [];
var idIndex = addBasicCellTreeNodes(treeData);
for(var i = 0; i < symbolLibManager.getSymbolLibNumber(); i++){
var symbolLib = symbolLibManager.getSymbolLibByIndex(i);
var rootSymbolInfo = symbolLib.getRootSymbolInfo();
var rootSymbolIconUrl = symbolLib.getRootSymbolIconUrl();
if(rootSymbolInfo.symbolNodeType === "SYMBOL_GROUP"){
var rootNode = new Object();
rootNode.id = idIndex+i;
rootNode.pId = 0;
rootNode.name = rootSymbolInfo.symbolName;
rootNode.fullName = rootSymbolInfo.symbolName +"/";
treeData.push(rootNode);
idIndex = innerAnalysisSymbolTree(rootSymbolInfo.childNodes, treeData, rootNode, rootSymbolIconUrl);
}
}
return treeData;
}
function createDrawNodes(treeNode, iconNode, drawControl, serverUrl){
var drawNodeClick = function(){
if(drawControl !== null){
drawControl.deactivate();
drawControl.libID = this.libID;
drawControl.code = this.symbolCode;
drawControl.serverUrl = this.serverUrl;
drawControl.activate();
if(undefined !== plotEditControl){
plotEditControl.deactivate();
}
}
}
var me = this;
var drawData = treeNode.drawData;
var table = document.createElement("table");
table.style.height = "100%";
table.style.width = "100%";
var i = 0;
var rowLength = (drawData.length%3 === 0) ? drawData.length/3 : drawData.length/3+1;
for(var j = 0; j < rowLength; j++){
var tr = document.createElement("tr");
for(var k = 0; k < 3; k++){
if(drawData[i]){
//存储菜单信息
var td = document.createElement("td");
var drawNode = document.createElement("div");
drawNode.onclick = drawNodeClick;
drawNode.style.textAlign = "center";
drawNode.id = drawData[i].libID+ ""+ drawData[i].symbolCode;
drawNode.libID = drawData[i].libID;
drawNode.symbolCode = drawData[i].symbolCode;
drawNode.serverUrl = serverUrl;
//图片
var img = document.createElement("img");
img.src = drawData[i].icon;
//文本
var text = document.createElement("div");
text.innerHTML = drawData[i].symbolName;
drawNode.appendChild(img);
drawNode.appendChild(text);
td.appendChild(drawNode);
tr.appendChild(td);
}
i++;
}
table.appendChild(tr);
}
iconNode.appendChild(table);
}
function addBasicCellTreeNodes(treeData){
var cellRootNode = new Object();
cellRootNode.id = 1;
cellRootNode.pId = 0;
cellRootNode.name = "基本标号";
cellRootNode.fullName = "BasicCell" +"/";
cellRootNode.drawData = [];
treeData.push(cellRootNode);
var symbolCode = [24, 28, 29, 31, 34, 410, 32, 590, 360, 390, 400, 350, 26, 370, 380, 44, 48, /*320,*/
1019, 1022, /*1024, 321,*/ 1023, 1025, 1013, 1014, /*1016, 1017, 1026,*/ 1001 /*1003, 1004*/];
var symbolName = ["折线", "平行四边形", "圆", "椭圆", "注记", "正多边形", "多边形", "贝塞尔曲线", "闭合贝塞尔曲线",
"集结地", "大括号", "梯形", "矩形", "弓形", "扇形", "弧线", "平行线", /*"注记指示框",*/ "同心圆", "组合圆",
/*"标注框", "多角标注框",*/ "自由线", "节点链", "跑道形", "八字形", /*"箭头线", "沿线注记", "线型标注",*/ "对象间连线"
/*"多边形区域", "扇形区域"*/];
var cellId = cellRootNode.id + 1;
for(var i = 0; i < symbolCode.length; i++){
var drawCellNode = {
id: cellId++,
pId: 0,
icon:"js/plotPanelControl/" + cellRootNode.fullName + symbolCode[i] + ".png",
symbolCode: symbolCode[i],
libID: 0,
symbolName: symbolName[i]
};
cellRootNode.drawData.push(drawCellNode);
}
return cellId;
}
function innerAnalysisSymbolTree(childSymbolInfos, treeData, parentNode, rootSymbolIconUrl){
var drawData = [];
var treeNodeId = parentNode.id+1;
for(var i = 0; i < childSymbolInfos.length; i++){
if(childSymbolInfos[i].symbolNodeType === "SYMBOL_GROUP"){
var treeNode = new Object();
treeNode.id = treeNodeId++;
treeNode.pId = parentNode.id;
treeNode.name = childSymbolInfos[i].symbolName;
treeNode.fullName = parentNode.fullName + childSymbolInfos[i].symbolName+"/";
treeData.push(treeNode);
treeNodeId = innerAnalysisSymbolTree(childSymbolInfos[i].childNodes, treeData, treeNode, rootSymbolIconUrl);
} else if(childSymbolInfos[i].symbolNodeType === "SYMBOL_NODE"){
var drawNode = new Object();
drawNode.id = treeNodeId++;
drawNode.pId = parentNode.id;
drawNode.icon = rootSymbolIconUrl + parentNode.fullName + childSymbolInfos[i].symbolCode + ".png";
drawNode.symbolCode = childSymbolInfos[i].symbolCode;
drawNode.libID = childSymbolInfos[i].libID;
drawNode.symbolName = childSymbolInfos[i].symbolName + "_" + childSymbolInfos[i].symbolCode;
drawData.push(drawNode);
}
}
if(drawData.length !== 0){
parentNode.drawData = drawData;
}
return treeNodeId;
}