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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
<?xml version="1.0" standalone="no" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<head>
<script type="text/ecmascript"> <![CDATA[
//section to contain script code
var myMapApp = new mapApp();
var myMainMap;
var myRefMapDragger;
function init() {
myMapApp.resetFactors();
myMainMap = new map("mainMap",3000,100,1000,0.6);
//set constraints to draggable rect in reference map
myRefMapDragger = new dragObj("dragRectForRefMap",0,200,510,610,"ul");
//colorRegion();
}
function showData1(evt) {}
function showData(evt) {
var xlinkns = "http://www.w3.org/1999/xlink";
var myPoly = evt.currentTarget;
var myDynamicTrackerText = document.getElementById("TrackerText");
var myDynamicTrackerText1 = document.getElementById("TrackerText1");
var myDynamicTrackerMessage = document.getElementById("TrackerMessage");
var myTrackerPlot = document.getElementById("plot");
if (evt.type == "mouseover") {
var myTracker = myPoly.getAttribute("POS");
var myTracker1 = " value="+myPoly.getAttribute("value");
var myMessage = myPoly.getAttribute("MESSAGE");
myTracker1 = myTracker1+" count="+myPoly.getAttribute("count");
// alert (myTracker+" "+myTracker1);
myDynamicTrackerText.firstChild.nodeValue=myTracker;
myDynamicTrackerText1.firstChild.nodeValue=myTracker1;
myDynamicTrackerMessage.firstChild.nodeValue=myMessage;
}
if (evt.type == "mouseout") {
myDynamicTrackerText.firstChild.nodeValue="-";
}
if (evt.type == "click") {
myDynamicTrackerText.firstChild.nodeValue="-";
var moduleId = myPoly.getAttribute("detid");
var url_serv = "http://cmstkmon.cern.ch:1972/urn:xdaq-application:lid=15/Request?";
var queryString = "RequestID=PlotTkMapHistogram";
queryString+= "&ModId=" + moduleId;
var url1 = url_serv + queryString;
// var filename=moduleId+".jpg";
// myTrackerPlot.setAttributeNS( xlinkns, "xlink:href", filename )
myTrackerPlot.setAttributeNS( xlinkns, "xlink:href", url1);
pausecomp(5000);
queryString = "RequestID=UpdatePlot&t="+moduleId;
var url2 = url_serv + queryString;
myTrackerPlot.setAttributeNS( xlinkns, "xlink:href", url2);
var myTracker = myPoly.getAttribute("POS");
myTracker = myTracker+" value="+myPoly.getAttribute("value");
myTracker = myTracker+" count="+myPoly.getAttribute("count");
myDynamicTrackerText.firstChild.nodeValue=myTracker;
}
}
function colorRegion() {
var myGroup = document.getElementById("tracker");
var children = myGroup.childNodes;
var myModule;
//loop over all children
//for (var i = 0; i < children.length;i++) {
for (var i = 0; i < 10000;i++) {
//check if it is a path-element
if (children.item(i).nodeName == "polygon") {
myModule = children.item(i).getAttribute("MODULE");
switch (myModule) {
case "stereo":
myColor = "blue";
break;
case "nostereo":
myColor = "rgb(255,255,0)";
break;
default:
myColor = "red";
}
children.item(i).setAttribute("fill",myColor);
}
}
}
//holds data on map
function map(mapName,origWidth,minZoom,maxZoom,zoomFact) {
var mapSVG = document.getElementById(mapName);
this.mapName = mapName;
this.origWidth = origWidth;
this.minZoom = minZoom;
this.maxZoom = maxZoom;
this.zoomFact = zoomFact;
this.pixXOffset = parseFloat(mapSVG.getAttributeNS(null,"x"));
this.pixYOffset = parseFloat(mapSVG.getAttributeNS(null,"y"));
viewBoxArray = mapSVG.getAttributeNS(null,"viewBox").split(" ");
this.curxOrig = parseFloat(viewBoxArray[0]);
this.curyOrig = parseFloat(viewBoxArray[1]);
this.curWidth = parseFloat(viewBoxArray[2]);
this.curHeight = parseFloat(viewBoxArray[3]);
this.pixWidth = parseFloat(mapSVG.getAttributeNS(null,"width"));
this.pixHeight = parseFloat(mapSVG.getAttributeNS(null,"height"));
this.pixXOrig = parseFloat(mapSVG.getAttributeNS(null,"x"));
this.pixYOrig = parseFloat(mapSVG.getAttributeNS(null,"y"));
this.pixSize = this.curWidth / this.pixWidth;
this.zoomVal = this.origWidth / this.curWidth * 100;
}
map.prototype.newViewBox = function(refRectId,refMapId) {
var myRefRect = document.getElementById(refRectId);
var myRefMapSVG = document.getElementById(refMapId);
var viewBoxArray = myRefMapSVG.getAttributeNS(null,"viewBox").split(" ");
var refPixSize = viewBoxArray[2] / myRefMapSVG.getAttributeNS(null,"width");
this.curxOrig = parseFloat(viewBoxArray[0]) + (myRefRect.getAttributeNS(null,"x") - myRefMapSVG.getAttributeNS(null,"x")) * refPixSize;
this.curyOrig = parseFloat(viewBoxArray[1]) + (myRefRect.getAttributeNS(null,"y") - myRefMapSVG.getAttributeNS(null,"y")) * refPixSize;
this.curWidth = myRefRect.getAttributeNS(null,"width") * refPixSize;
this.curHeight = myRefRect.getAttributeNS(null,"height") * refPixSize;
var myViewBoxString = this.curxOrig + " " + this.curyOrig + " " + this.curWidth + " " + this.curHeight;
this.pixSize = this.curWidth / this.pixWidth;
this.zoomVal = this.origWidth / this.curWidth * 100;
document.getElementById(this.mapName).setAttributeNS(null,"viewBox",myViewBoxString);
}
//holds data on window size
function mapApp() {
}
//calculate ratio and offset values of app window
mapApp.prototype.resetFactors = function() {
var svgroot = document.documentElement;
if (!svgroot.getScreenCTM) {
//case for ASV3 and Corel
var viewBoxArray = svgroot.getAttributeNS(null,"viewBox").split(" ");
var myRatio = viewBoxArray[2]/viewBoxArray[3];
if ((window.innerWidth/window.innerHeight) > myRatio) { //case window is more wide than myRatio
this.scaleFactor = viewBoxArray[3] / window.innerHeight;
}
else { //case window is more tall than myRatio
this.scaleFactor = viewBoxArray[2] / window.innerWidth;
}
this.offsetX = (window.innerWidth - viewBoxArray[2] * 1 / this.scaleFactor) / 2;
this.offsetY = (window.innerHeight - viewBoxArray[3] * 1 / this.scaleFactor) / 2;
}
}
mapApp.prototype.calcCoord = function(coordx,coordy) {
var svgroot = document.documentElement;
var coords = new Array();
if (!svgroot.getScreenCTM) {
//case ASV3 a. Corel
coords["x"] = (coordx - this.offsetX) * this.scaleFactor;
coords["y"] = (coordy - this.offsetY) * this.scaleFactor;
}
else {
matrix=svgroot.getScreenCTM();
coords["x"]= matrix.inverse().a*coordx+matrix.inverse().c*coordy+matrix.inverse().e;
coords["y"]= matrix.inverse().b*coordx+matrix.inverse().d*coordy+matrix.inverse().f;
}
return coords;
}
//make an element draggable with constraints
function dragObj(dragId,constrXmin,constrXmax,constrYmin,constrYmax,refPoint) {
this.dragId = dragId;
this.constrXmin = constrXmin;
this.constrXmax = constrXmax;
this.constrYmin = constrYmin;
this.constrYmax = constrYmax;
this.refPoint = refPoint;
this.status = "false";
}
dragObj.prototype.drag = function(evt) {
//works only for rect and use-elements
var myDragElement = evt.target;
if (evt.type == "mousedown") {
var coords = myMapApp.calcCoord(evt.clientX,evt.clientY);
this.curX = coords["x"];
this.curY = coords["y"];
this.status = "true";
}
if (evt.type == "mousemove" && this.status == "true") {
var coords = myMapApp.calcCoord(evt.clientX,evt.clientY);
var newEvtX = coords["x"];
var newEvtY = coords["y"];
var bBox = myDragElement.getBBox();
if (this.refPoint == "ul") {
var toMoveX = bBox.x + newEvtX - this.curX;
var toMoveY = bBox.y + newEvtY - this.curY;
}
else {
//refPoint = center
var toMoveX = bBox.x + bBox.width / 2 + newEvtX - this.curX;
var toMoveY = bBox.y + bBox.height / 2 + newEvtY - this.curY;
}
if ((bBox.x + newEvtX - this.curX) < this.constrXmin) {
if(this.refPoint == "ul") {
toMoveX = this.constrXmin;
}
else {
toMoveX = this.constrXmin + bBox.width / 2;
}
}
if ((bBox.x + newEvtX - this.curX + bBox.width) > this.constrXmax) {
if(this.refPoint == "ul") {
toMoveX = this.constrXmax - bBox.width;
}
else {
toMoveX = this.constrXmax - bBox.width / 2;
}
}
if ((bBox.y + newEvtY - this.curY) < this.constrYmin) {
if(this.refPoint == "ul") {
toMoveY = this.constrYmin;
}
else {
toMoveY = this.constrYmin + bBox.height / 2;
}
}
if ((bBox.y + bBox.height + newEvtY - this.curY) > this.constrYmax) {
if(this.refPoint == "ul") {
toMoveY = this.constrYmax - bBox.height;
}
else {
toMoveY = this.constrYmax - bBox.height / 2;
}
}
myDragElement.setAttributeNS(null,"x",toMoveX);
myDragElement.setAttributeNS(null,"y",toMoveY);
this.curX = newEvtX;
this.curY = newEvtY;
}
if (evt.type == "mouseup" || evt.type == "mouseout") {
this.status = "false";
}
}
dragObj.prototype.zoom = function(inOrOut) {
var myDragElement = document.getElementById(this.dragId);
var myOldX = myDragElement.getAttributeNS(null,"x");
var myOldY = myDragElement.getAttributeNS(null,"y");
var myOldWidth = myDragElement.getAttributeNS(null,"width");
var myOldHeight = myDragElement.getAttributeNS(null,"height");
switch (inOrOut) {
case "in":
var myNewX = parseFloat(myOldX) + myOldWidth / 2 - (myOldWidth * myMainMap.zoomFact * 0.5);
var myNewY = parseFloat(myOldY) + myOldHeight / 2 - (myOldHeight * myMainMap.zoomFact * 0.5);
var myNewWidth = myOldWidth * myMainMap.zoomFact;
var myNewHeight = myOldHeight * myMainMap.zoomFact;
break;
case "out":
var myNewX = parseFloat(myOldX) + myOldWidth / 2 - (myOldWidth * (1 + myMainMap.zoomFact) * 0.5);
var myNewY = parseFloat(myOldY) + myOldHeight / 2 - (myOldHeight * (1 + myMainMap.zoomFact) * 0.5);
var myNewWidth = myOldWidth * (1 + myMainMap.zoomFact);
var myNewHeight = myOldHeight * (1 + myMainMap.zoomFact);
break;
case "down":
var myNewX = parseFloat(myOldX);
var myNewY = parseFloat(myOldY) +1.3* 6.*myMainMap.zoomFact;
var myNewWidth = myOldWidth ;
var myNewHeight = myOldHeight ;
break;
case "up":
var myNewX = parseFloat(myOldX);
var myNewY = parseFloat(myOldY) -1.3*6.* myMainMap.zoomFact;
var myNewWidth = myOldWidth ;
var myNewHeight = myOldHeight ;
break;
case "left":
var myNewX = parseFloat(myOldX) - 3.*6.* myMainMap.zoomFact;
var myNewY = parseFloat(myOldY);
var myNewWidth = myOldWidth ;
var myNewHeight = myOldHeight ;
break;
case "right":
var myNewX = parseFloat(myOldX)+3.*6.* myMainMap.zoomFact;
var myNewY = parseFloat(myOldY);
var myNewWidth = myOldWidth ;
var myNewHeight = myOldHeight ;
break;
case "PIXB":
var myNewX = 0.;
var myNewY = 540.;
var myNewWidth = 62. ;
var myNewHeight = 36. ;
break;
case "FPIX-z":
var myNewX = 0.;
var myNewY = 581.;
var myNewWidth = 35.83 ;
var myNewHeight = 21.01 ;
break;
case "FPIX+z":
var myNewX = 0.;
var myNewY = 516.;
var myNewWidth = 35.83 ;
var myNewHeight = 21.01 ;
break;
case "TID-z":
var myNewX = 40.0;
var myNewY = 585.;
var myNewWidth = 34. ;
var myNewHeight = 15. ;
break;
case "TID+z":
var myNewX = 40.0;
var myNewY = 520.;
var myNewWidth = 34. ;
var myNewHeight = 15. ;
break;
case "TOB":
var myNewX = 97.;
var myNewY = 542.;
var myNewWidth = 72. ;
var myNewHeight = 36. ;
break;
case "TIB":
var myNewX = 46.8;
var myNewY = 540.;
var myNewWidth = 64.8 ;
var myNewHeight = 38. ;
break;
case "TEC-z":
var myNewX = 73.8;
var myNewY = 568.;
var myNewWidth = 115.2 ;
var myNewHeight = 57.6 ;
break;
case "TEC+z":
var myNewX = 73.8;
var myNewY = 500.;
var myNewWidth = 115.2 ;
var myNewHeight = 57.6 ;
break;
default:
var myNewX = this.constrXmin;
var myNewY = this.constrYmin;
var myNewWidth = this.constrXmax - this.constrXmin;
var myNewHeight = this.constrYmax - this.constrYmin;
break;
}
if(inOrOut=="in" || inOrOut=="out" || inOrOut=="full"){
if (myNewWidth > (this.constrXmax - this.constrXmin)) {
myNewWidth = this.constrXmax - this.constrXmin;
}
if (myNewHeight > (this.constrYmax - this.constrYmin)) {
myNewHeight = this.constrYmax - this.constrYmin;
}
if (myNewX < this.constrXmin) {
myNewX = this.constrXmin;
}
if (myNewY < this.constrYmin) {
myNewY = this.constrYmin;
}
if ((myNewX + myNewWidth) > this.constrXmax) {
myNewX = this.constrXmax - myNewWidth;
}
if ((myNewY + myNewHeight) > this.constrYmax) {
myNewY = this.constrYmax - myNewHeight;
}
}
myDragElement.setAttributeNS(null,"x",myNewX);
myDragElement.setAttributeNS(null,"y",myNewY);
myDragElement.setAttributeNS(null,"width",myNewWidth);
myDragElement.setAttributeNS(null,"height",myNewHeight);
myMainMap.newViewBox(this.dragId,"referenceMap");
}
//magnifier glass mouse-over effects
function magnify(evt,scaleFact,inOrOut) {
if (inOrOut == "in") {
if (myMainMap.zoomVal < myMainMap.maxZoom) {
scaleObject(evt,scaleFact);
}
else {
}
}
if (inOrOut == "out") {
if (myMainMap.zoomVal > myMainMap.minZoom) {
scaleObject(evt,scaleFact);
}
else {
}
}
if (inOrOut == "full") {
if (myMainMap.zoomVal > myMainMap.minZoom) {
scaleObject(evt,scaleFact);
}
else {
}
}
if (scaleFact == 1) {
scaleObject(evt,scaleFact);
}
}
//scale an object
function scaleObject(evt,factor) {
//reference to the currently selected object
var element = evt.currentTarget;
var myX = element.getAttributeNS(null,"x");
var myY = element.getAttributeNS(null,"y");
var newtransform = "scale(" + factor + ") translate(" + (myX * 1 / factor - myX) + " " + (myY * 1 / factor - myY) +")";
element.setAttributeNS(null,'transform', newtransform);
}
function zoomIt(inOrOut) {
if (inOrOut == "in") {
if (myMainMap.zoomVal < myMainMap.maxZoom) {
myRefMapDragger.zoom("in");
}
else {
}
}
if (inOrOut == "out") {
if (myMainMap.zoomVal > myMainMap.minZoom) {
myRefMapDragger.zoom("out");
}
else {
}
}
if (inOrOut == "full") {
if (myMainMap.zoomVal > myMainMap.minZoom) {
myRefMapDragger.zoom("full");
}
else {
}
}
if(inOrOut!="in" && inOrOut!="out" && inOrOut!="full") myRefMapDragger.zoom(inOrOut);
}
function pausecomp(millis)
{
var inizio = new Date();
var inizioint=inizio.getTime();
var intervallo = 0;
while(intervallo<millis){
var fine = new Date();
var fineint=fine.getTime();
intervallo = fineint-inizioint;
}
return;
}
]]> </script>
<!-- section for CSS stylesheet definitions -->
<style type="text/css"><![CDATA[
.normalText {font-size:20;fill:black;font-weight:bold;}
.dragRect {fill:darkcyan;stroke:none;opacity:0.4;}
]]></style>
</head>
<body onload="init()" onresize="myMapApp.resetFactors();" style=" background-color:lightyellow; ">
<div id="controlbuttons">
<button onclick="zoomIt('in');">Zoom in</button>
<button onclick="zoomIt('out');">Zoom out</button>
<button onclick="zoomIt('full');">Home</button>
<button onclick="zoomIt('up');">Up</button>
<button onclick="zoomIt('down');">Down</button>
<button onclick="zoomIt('left');">Left</button>
<button onclick="zoomIt('right');">Right</button>
<button onclick="zoomIt('TIB');">TIB</button>
<button onclick="zoomIt('TOB');">TOB</button>
<button onclick="zoomIt('TID+z');">TID+z</button>
<button onclick="zoomIt('TID-z');">TID-z</button>
<button onclick="zoomIt('TEC+z');">TEC+z</button>
<button onclick="zoomIt('TEC-z');">TEC-z</button>
<button onclick="zoomIt('PIXB');">PIXB</button>
<button onclick="zoomIt('FPIX+z');">FPIX+z</button>
<button onclick="zoomIt('FPIX-z');">FPIX-z</button>
</div>
<br />
<svg:svg width="100%" height="100%" viewBox="0 0 1400 700" >
<svg:rect x = "-500"
y = "-500"
width = "6000"
overflow = "hidden"
height = "8000"
style = "fill:#d5e6fc;stroke:red;stroke-width:1px;" />
<svg:defs>
<svg:symbol id="magnifyer" overflow="visible" style="fill:white;stroke:darkcyan;stroke-width:2;" >
<svg:circle r="12" />
</svg:symbol>
<svg:symbol id="magnifyerZoomOut" overflow="visible" style="fill:white;stroke:darkcyan;stroke-width:2;" >
<svg:use xlink:href="#magnifyer"/>
<svg:line x1="-6" y1="0" x2="6" y2="0" style="stroke:darkcyan;stroke-width:2;"/>
</svg:symbol>
<svg:symbol id="magnifyerZoomIn" overflow="visible">
<svg:use xlink:href="#magnifyer"/>
<svg:line x1="-6" y1="0" x2="6" y2="0" style="stroke:darkcyan;stroke-width:2;"/>
<svg:line x1="0" y1="-6" x2="0" y2="6" style="stroke:darkcyan;stroke-width:2;"/>
</svg:symbol>
<svg:symbol id="magnifyerFull" overflow="visible">
<svg:use xlink:href="#magnifyer"/>
<svg:line x1="-2" y1="0" x2="4" y2="0" style="stroke:darkcyan;stroke-width:2;"/>
<svg:line x1="-2" y1="-6" x2="-4" y2="6" style="stroke:darkcyan;stroke-width:2;"/>
<svg:line x1="-2" y1="-6" x2="5" y2="-6" style="stroke:darkcyan;stroke-width:2;"/>
</svg:symbol>
</svg:defs>
<svg:rect fill="white" stroke="none" x="0" y="0" width="100%" height="100%" onclick="showData1(evt);"/>
<svg:svg id="referenceMap" x="0" y="510" viewBox="0 0 3000 1600" width="180"
height="100" >
<svg:use xlink:href="#tracker" />
</svg:svg>
<svg:rect id="dragRectForRefMap" class="dragRect" x="0" y="510" width="180"
height="100" />
<svg:g id="navigatorElements" class="normalText">
<svg:text id="TrackerText" x="350" y="530"> - </svg:text>
<svg:text id="TrackerText1" x="350" y="565"> - </svg:text>
<svg:text id="TrackerMessage" x="350" y="600"> - </svg:text>
</svg:g>
<svg:image id="plot" xlink:href="plot.jpg" x="900" y="10" width="420" height="400" />
<svg:svg id="mainMap" x="0" y="0" viewBox="0 0 3000 1600" width="900" height="500">
<svg:rect fill="lightblue" stroke="none" x="0" y="0" width="3000" height="1600" />
<svg:g id="tracker" transform="translate(10,1500) rotate(270)" style="fill:none;stroke:black;stroke-width:0;">
|