-
Notifications
You must be signed in to change notification settings - Fork 3
/
LayerMenu.js
371 lines (311 loc) · 8.73 KB
/
LayerMenu.js
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
// JavaScript Document
function getLayer(name){
var Layers = h_5_cad.DataBase.Ls;
for(var i=0;i<Layers.length;i++){
if(Layers[i].N == name)
return Layers[i];
}
return null;
}
function setLayer(i)
{
hCad("#layer_menu").hide();
var Layers = h_5_cad.DataBase.Ls;
if(Layers.length<=i||i<0){
h_5_cad.MouseTip.ShowErrTip("无效前图层.");
return ;
}
if(Layers[i].L == 1){
h_5_cad.MouseTip.ShowErrTip("锁定图层不能置为当前图层.");
return ;
}
var index = h_5_cad.DataBase.L;
if(index>-1){
hCad("#layer_menu").find("dd").eq(index).css("background-color","#FFFFFF");
}
h_5_cad.DataBase.L= i;
hCad("#cur_layer").html(Layers[i].N);
};
function getColor(i){
if(i<=h_5_cad.colorList.length&&i>=0){
return h_5_cad.colorList[i];
}
return null;
};
function getColorIndex(v){
for(var i=0;i<h_5_cad.colorList.length;i++)
{
if(v === h_5_cad.colorList[i])
return i;
}
return -1;
};
function getLw(i){
if(i<=h_5_cad.lineWidthList.length&&i>=0){
return h_5_cad.lineWidthList[i];
}
return null;
};
function getLwIndex(v){
for(var i=0;i<h_5_cad.lineWidthList.length;i++)
{
if(v === h_5_cad.lineWidthList[i])
return i;
}
return -1;
};
function getLt(i){
if(i<=h_5_cad.lineTypeList.length&&i>=0){
return h_5_cad.lineTypeList[i];
}
return null;
};
function getLtIndex(v){
for(var i=0;i<h_5_cad.lineTypeList.length;i++)
{
if(v === h_5_cad.lineTypeList[i])
return i;
}
return -1;
};
function setColor(i)
{
var pane_lw = document.getElementById("pane_lw");
pane_lw.style.display = 'none';
var pane_ltype = document.getElementById("pane_ltype");
pane_ltype.style.display = 'none';
var lw_btn = document.getElementById("WEIGHT");
lw_btn.className="weight-box weight";
var ltype_btn = document.getElementById("LINETYPE");
ltype_btn.className="weight-box linetype";
var pane = document.getElementById("pane");
if(pane){
if(pane.style.display == 'none'){
pane.style.display = '';
var pane_color = document.getElementById("pane_color");
if(pane_color){
pane_color.style.display = '';
var v="color"+getColorIndex(h_5_cad.DataBase.C);
var color = document.getElementById(v);
if(color){
color.innerHTML = "<div class='COLOR_SELECT' ></div>";
}
var color_btn = document.getElementById("COLOR");
if(color_btn){
color_btn.className="weight-box color-onmouseup";
}
}
}else
{
var pane_color = document.getElementById("pane_color");
if(pane_color){
if(pane_color.style.display == ''){
pane.style.display = 'none';
pane_color.style.display = 'none';
if(i != -1){
var v="color"+getColorIndex(h_5_cad.DataBase.C);
var color = document.getElementById(v);
if(color){
color.innerHTML = "";
}
h_5_cad.DataBase.C=getColor(i);
hCad(".LAYERCOLOR_LINE").css("background-color",getColor(i));
}
var color_btn = document.getElementById("COLOR");
if(color_btn){
color_btn.className="weight-box color";
}
}
else
{
var pane_color = document.getElementById("pane_color");
pane_color.style.display = '';
var v="color"+getColorIndex(h_5_cad.DataBase.C);
var color = document.getElementById(v);
if(color){
color.innerHTML = "<div class='COLOR_SELECT' ></div>";
}
var color_btn = document.getElementById("COLOR");
if(color_btn){
color_btn.className="weight-box color-onmouseup";
}
}
}
}
}
};
function setLayerLw(i)
{
var pane_color = document.getElementById("pane_color");
pane_color.style.display = 'none';
var pane_ltype = document.getElementById("pane_ltype");
pane_ltype.style.display = 'none';
var color_btn = document.getElementById("COLOR");
color_btn.className="weight-box color";
var ltype_btn = document.getElementById("LINETYPE");
ltype_btn.className="weight-box linetype";
var pane = document.getElementById("pane");
if(pane){
if(pane.style.display == 'none'){
pane.style.display = '';
var pane_lw = document.getElementById("pane_lw");
if(pane_lw){
pane_lw.style.display = '';
var v="lw_"+getLwIndex(h_5_cad.DataBase.Lw);
var color = document.getElementById(v);
if(color){
}
var w_btn = document.getElementById("WEIGHT");
if(w_btn){
w_btn.className="weight-box weight-onmouseup";
}
}
}else
{
var pane_lw = document.getElementById("pane_lw");
if(pane_lw){
if(pane_lw.style.display == ''){
pane.style.display = 'none';
pane_lw.style.display = 'none';
if(i != -1)
h_5_cad.DataBase.Lw=getLw(i);
var w_btn = document.getElementById("WEIGHT");
if(w_btn){
w_btn.className="weight-box weight";
}
}
else
{
var pane_lw = document.getElementById("pane_lw");
pane_lw.style.display = '';
var v="lw_"+getLwIndex(h_5_cad.DataBase.Lw);
var color = document.getElementById(v);
if(color){
}
var w_btn = document.getElementById("WEIGHT");
if(w_btn){
w_btn.className="weight-box weight-onmouseup";
}
}
}
}
}
};
function setLayerLt(i)
{
var pane_color = document.getElementById("pane_color");
pane_color.style.display = 'none';
var pane_lw = document.getElementById("pane_lw");
pane_lw.style.display = 'none';
var color_btn = document.getElementById("COLOR");
color_btn.className="weight-box color";
var w_btn = document.getElementById("WEIGHT");
w_btn.className="weight-box weight";
var pane = document.getElementById("pane");
if(pane){
if(pane.style.display == 'none'){
pane.style.display = '';
var pane_ltype = document.getElementById("pane_ltype");
if(pane_ltype){
pane_ltype.style.display = '';
var v="lt_"+getLtIndex(h_5_cad.DataBase.Lt);
var color = document.getElementById(v);
if(color){
}
var ltype_btn = document.getElementById("LINETYPE");
if(ltype_btn){
ltype_btn.className="weight-box linetype-onmouseup";
}
}
}else
{
var pane_ltype = document.getElementById("pane_ltype");
if(pane_ltype){
if(pane_ltype.style.display == ''){
pane.style.display = 'none';
pane_ltype.style.display = 'none';
if(i != -1)
h_5_cad.DataBase.Lt=getLt(i);
var ltype_btn = document.getElementById("LINETYPE");
if(ltype_btn){
ltype_btn.className="weight-box linetype";
}
}
else
{
var pane_ltype = document.getElementById("pane_ltype");
pane_ltype.style.display = '';
var v="lt_"+getLtIndex(h_5_cad.DataBase.Lt);
var color = document.getElementById(v);
if(color){
}
var ltype_btn = document.getElementById("LINETYPE");
if(ltype_btn){
ltype_btn.className="weight-box linetype-onmouseup";
}
}
}
}
}
};
Layer_Menu=function()
{
this.Create = function(ID)
{
var layerDiv = document.getElementById(ID);
var Layer = h_5_cad.DataBase.Ls[h_5_cad.DataBase.L];
layerDiv.innerHTML = "<dt><span class='curlayer' id = 'cur_layer'>"+Layer.N+"</span><span class='arraw' id = 'layer_arraw'></span></dt>";
layerDiv.innerHTML += "<div id ='layer_menu' class = 'layer_menu' ></div>";
var layer_menu = document.getElementById("layer_menu");
var Layers = h_5_cad.DataBase.Ls;
for(var i=0;i<Layers.length;i++)
{
layer_menu.innerHTML += "<dd onclick='setLayer("+i+");'>"+Layers[i].N+"</dd>";
}
var layer_arraw = document.getElementById("layer_arraw");
if(layer_arraw){
layer_arraw.onclick = function(){
var layer_menu = document.getElementById("layer_menu");
if(layer_menu){
if(layer_menu.style.display == 'none'){
layer_menu.style.display = '';
var index = h_5_cad.DataBase.L;
if(index>-1){
hCad("#layer_menu").find("dd").eq(index).css("background-color","#E2E2E2");
}
}else
{
layer_menu.style.display = 'none';
var index = h_5_cad.DataBase.L;
if(index>-1){
hCad("#layer_menu").find("dd").eq(index).css("background-color","#FFFFFF");
}
}
}
};
}
var cur_layer = document.getElementById("cur_layer");
if(cur_layer){
cur_layer.onclick = function(){
var layer_menu = document.getElementById("layer_menu");
if(layer_menu){
if(layer_menu.style.display == 'none'){
layer_menu.style.display = '';
var index = h_5_cad.DataBase.L;
if(index>-1){
hCad("#layer_menu").find("dd").eq(index).css("background-color","#E2E2E2");
}
}else
{
layer_menu.style.display = 'none';
var index = h_5_cad.DataBase.L;
if(index>-1){
hCad("#layer_menu").find("dd").eq(index).css("background-color","#FFFFFF");
}
}
}
};
}
hCad("#layer_menu").hide();
}
};