|
292 | 292 | } |
293 | 293 |
|
294 | 294 |
|
| 295 | + function ShowHotSpot(evt,hotspotid) |
| 296 | + { |
| 297 | + var svgDocument = evt.target.ownerDocument; |
| 298 | + var strId = "hotspot."+hotspotid; |
| 299 | + var hotspot = svgDocument.getElementById(strId); |
| 300 | + if(hotspot) |
| 301 | + hotspot.setAttribute("opacity",".5"); |
| 302 | + } |
| 303 | + function HideHotSpot(evt,hotspotid) |
| 304 | + { |
| 305 | + var svgDocument = evt.target.ownerDocument; |
| 306 | + var strId = "hotspot."+hotspotid; |
| 307 | + var hotspot = svgDocument.getElementById(strId); |
| 308 | + if(hotspot) |
| 309 | + hotspot.setAttribute("opacity","0"); |
| 310 | + |
| 311 | + var toolTip = svgDocument.getElementById('ToolTip'); |
| 312 | + if(toolTip) |
| 313 | + toolTip.setAttribute("visibility","hidden"); |
| 314 | + } |
| 315 | + function ShowToolTip(evt,hotspotid,strTooltip) |
| 316 | + { |
| 317 | + if(strTooltip=="") |
| 318 | + return; |
| 319 | + |
| 320 | + // change text |
| 321 | + var svgDocument = evt.target.ownerDocument; |
| 322 | + var tiptext = svgDocument.getElementById('ToolTipText'); |
| 323 | + if( !tiptext ) |
| 324 | + return; |
| 325 | + tiptext.firstChild.nodeValue = " " + strTooltip + " " ; |
| 326 | + |
| 327 | + // show tooltip before, else some refresh issue |
| 328 | + |
| 329 | + var toolTip = svgDocument.getElementById('ToolTip'); |
| 330 | + if(!toolTip) |
| 331 | + return; |
| 332 | + |
| 333 | + toolTip.setAttribute("visibility","visible"); |
| 334 | + toolTip.setAttribute("opacity",".95"); |
| 335 | + |
| 336 | + // move tooltip |
| 337 | + // get viewbox |
| 338 | + |
| 339 | + var root = svgDocument.documentElement; |
| 340 | + var vbox = (root.getAttribute("viewBox")).split(' '); |
| 341 | + var x0 = parseFloat(vbox[0]); |
| 342 | + var y0 = parseFloat(vbox[1]); |
| 343 | + var vboxW = parseFloat(vbox[2]); |
| 344 | + var vboxH = parseFloat(vbox[3]); |
| 345 | + |
| 346 | + // get default width of svg |
| 347 | + |
| 348 | + var strW = root.getAttribute("width"); |
| 349 | + var svgW = parseFloat(strW); |
| 350 | + if(strW.indexOf('mm') != -1) |
| 351 | + svgW *= 3.779; |
| 352 | + |
| 353 | + var strH = root.getAttribute("height"); |
| 354 | + var svgH = parseFloat(strH); |
| 355 | + if(strH.indexOf('mm') != -1) |
| 356 | + svgH *= 3.779; // 96 dpi -> 96/25.4 = 3.779 |
| 357 | + |
| 358 | + // update the viewbox / width / height if svg is embedded in html with zoom fit all |
| 359 | + var realx0 = x0; |
| 360 | + var realy0 = y0; |
| 361 | + var realvboxW = vboxW; |
| 362 | + var realvboxH = vboxH; |
| 363 | + var realsvgW = svgW; |
| 364 | + var realsvgH = svgH; |
| 365 | + |
| 366 | + if ((typeof(top) == "undefined") || (typeof(top.svgctl1) != "undefined")) // embedded in html |
| 367 | + { |
| 368 | + // get window size in pxl |
| 369 | + |
| 370 | + svgW = window.innerWidth; |
| 371 | + svgH = window.innerHeight; |
| 372 | + |
| 373 | + // calculate real viewbox |
| 374 | + |
| 375 | + realsvgW = svgW; |
| 376 | + realsvgH = svgH; |
| 377 | + if((svgW / svgH) > (vboxW / vboxH)) |
| 378 | + { |
| 379 | + realvboxW = (vboxH * svgW) / svgH; |
| 380 | + realvboxH = vboxH; |
| 381 | + realx0 = x0 - (realvboxW - vboxW)/2 ; |
| 382 | + } |
| 383 | + else |
| 384 | + { |
| 385 | + realvboxH = (vboxW * svgH) / svgW; |
| 386 | + realvboxW = vboxW; |
| 387 | + realy0 = y0 - (realvboxH - vboxH)/2 ; |
| 388 | + } |
| 389 | + } |
| 390 | + |
| 391 | + // get user zoom/pan |
| 392 | + |
| 393 | + var newScale = root.currentScale; |
| 394 | + var translation = root.currentTranslate; |
| 395 | + |
| 396 | + // transform pxl to user unit |
| 397 | + |
| 398 | + var xPos = (((evt.clientX+10- translation.x)/newScale) * realvboxW)/realsvgW + realx0 ; |
| 399 | + var yPos = (((evt.clientY+5- translation.y)/newScale) * realvboxH)/ realsvgH + realy0 ; |
| 400 | + var scaleForWidth = ( (1 / newScale) * realvboxH) / realsvgH; |
| 401 | + |
| 402 | + // move tooltip |
| 403 | + |
| 404 | + toolTip.setAttribute("transform", "translate(" + xPos + "," + yPos + ")" ); |
| 405 | + |
| 406 | + // resize tooltip |
| 407 | + |
| 408 | + var fontsize = 12; |
| 409 | + tiptext.setAttribute("font-size",fontsize*scaleForWidth); |
| 410 | + tiptext.setAttribute("y", fontsize*scaleForWidth); |
| 411 | + var tipBG = svgDocument.getElementById('ToolTipBG'); |
| 412 | + var outline = tiptext.getBBox(); |
| 413 | + if(tipBG) |
| 414 | + { |
| 415 | + tipBG.setAttribute("stroke-width", 1*scaleForWidth); |
| 416 | + tipBG.setAttribute("width", Number(outline.width) ); |
| 417 | + tipBG.setAttribute("height", Number(outline.height) + fontsize*.5*scaleForWidth ); |
| 418 | + } |
| 419 | + var ToolTipShadow = svgDocument.getElementById('ToolTipShadow'); |
| 420 | + if(ToolTipShadow) |
| 421 | + { |
| 422 | + ToolTipShadow.setAttribute("width", Number(outline.width) ); |
| 423 | + ToolTipShadow.setAttribute("height", Number(outline.height) + fontsize*.5*scaleForWidth ); |
| 424 | + ToolTipShadow.setAttribute("x", 3*scaleForWidth); |
| 425 | + ToolTipShadow.setAttribute("y", 3*scaleForWidth); |
| 426 | + } |
| 427 | + } |
| 428 | + function ShowPaper() |
| 429 | + { |
| 430 | + var svgDocument = getDocument(); |
| 431 | + var paper = svgDocument.getElementById("paperID"); |
| 432 | + if(paper) |
| 433 | + { |
| 434 | + paper.setAttribute("transform","scale(1)"); |
| 435 | + paper.setAttribute("opacity","1"); |
| 436 | + paper.setAttribute("visibility","visible"); |
| 437 | + } |
| 438 | + var svg = svgDocument.getRootElement(); |
| 439 | + if(svg) |
| 440 | + { |
| 441 | + svg.setAttribute("width","1510.000mm"); |
| 442 | + svg.setAttribute("height","1010.000mm"); |
| 443 | + svg.setAttribute("viewBox","-5.000000 -5.000000 1510.000000 1010.000000"); |
| 444 | + } |
| 445 | + } |
| 446 | + |
| 447 | + |
295 | 448 | // Merges any number of options objects into a new object |
296 | 449 | function mergeOptions() { |
297 | 450 | var mergedOptions = {}; |
|
0 commit comments