-
Notifications
You must be signed in to change notification settings - Fork 5
/
viewer.html
631 lines (550 loc) · 24 KB
/
viewer.html
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
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
<!DOCTYPE html>
<script>
/*
* Copyright (c) 2019 University of Utah
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
</script>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ViSUS WebViewer</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js" integrity="sha256-DI6NdAhhFRnO2k51mumYeDShet3I8AKCQf/tf7ARNhI=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/css/bootstrap-select.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js" integrity="sha256-DI6NdAhhFRnO2k51mumYeDShet3I8AKCQf/tf7ARNhI=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/js/bootstrap-select.min.js"></script>
<style type="text/css">
body{
background: black;
}
.slidecontainer {
width: 100%; /* Width of the outside container */
}
.slider {
-webkit-appearance: none;
width: 100%;
height: 15px;
border-radius: 5px;
background: #d3d3d3;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
display: table-cell;
vertical-align: middle;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 25px;
height: 25px;
border-radius: 50%;
background: #4CAF50;
cursor: pointer;
vertical-align: middle;
}
.slider::-moz-range-thumb {
width: 25px;
height: 25px;
border-radius: 50%;
background: #4CAF50;
cursor: pointer;
vertical-align: middle;
}
.nav-item{
padding-right: 5px;
padding-left: 5px;
z-index:50;
}
.myoptnav{
display:none;
}
.myModal {
position: relative;
}
.my-modal-dialog {
position: fixed;
margin: 0;
padding: 50px;
}
.my-modal-dialog>.modal-content{
background-color: rgba(255,255,255,.3) !important;
}
#info{
position:relative;
z-index:30;
padding-top: 50px;
background-color: rgba(255,255,255,.8);
color:rgba(64,64,64,1.0);
}
</style>
</head>
<script>
var selection_box= new Array();
// Selection widget
var selection;
</script>
<body>
<div id='status_bar' style="float:top; display: none"><img src="images/spinner.gif" height="10px" ><label id='status' style="color: blue"></label></div>
<nav id="info" class="panel" role="navigation">
<a href="https://visus.org"><img src="images/site_logo.gif" width="80px"/></a>
</nav>
<div id="downloadModal" class="modal fade modal-fullscreen" role="dialog">
<div class="modal-dialog">
<!-- Download Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Select resolution to download</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="col" style="padding:20px">
<div class="row-md-6 text-center">
<div class="slidecontainer">
<input id='resolution' type='range' step='1' min='0' step='1' max='33' class="slider" oninput='updateDownloadResolution(this.value);'/>
</div>
</div>
<div class="row-md-6 text-center">
<label style="color:green">Resolution: </label><label style="color:green" id='res_lbl'> </label>
</div>
<div class="row-md-6 text-center">
<label>Size: </label><label id="size_est" > ... KB </label>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" id='download_btn' onclick='callDownload()'>Download</button>
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="shareModal" class="modal fade modal-fullscreen" role="dialog">
<div class="modal-dialog">
<!-- Share Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Share link</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="col" style="padding:20px">
<div class="input-group">
<input type="text" id='link_text' class="form-control"
value="/path/to/foo/bar" placeholder="Some path">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="copy-button"
data-toggle="tooltip" data-placement="button"
title="Copy to Clipboard" onclick="copyClick()">
Copy
</button>
</div>
</div>
<!-- <input id='link_text' style='width:100%' /> -->
</div>
<!-- <div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button>
</div> -->
</div>
</div>
</div>
<div id="paletteModal" class="modal fade myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div id="palette-modal-dialog" class="modal-dialog my-modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text form-control-sm">Palette</span>
</div>
<div class="input-group-append input-group-sm">
<select id='palette' onchange='onPaletteChange();' class='custom-select'>
<option value='' selected="selected"></option>
<option value='rich'>rich</option>
<option value='hsl'>hsl</option>
<option value='banded'>banded</option>
<option value='bry'>bry</option>
<option value='bgry'>bgry</option>
<option value='gamma'>gamma</option>
<option value='hot1'>hot1</option>
<option value='hot2'>hot2</option>
<option value='ice'>ice</option>
<option value='lighthues'>lighthues</option>
<option value='smoothrich'>smoothrich</option>
<option value='lut16'>lut16</option>
<option value='BlueGreenDivergent'>BlueGreenDivergent</option>
<option value='AsymmetricBlueGreenDivergent'>AsymmetricBlueGreenDivergent</option>
<option value='GreenGold'>GreenGold</option>
<option value='LinearGreen'>LinearGreen</option>
<option value='LinearTurquois'>LinearTurquois</option>
<option value='MutedBlueGreen'>MutedBlueGreen</option>
<option value='ExtendedCoolWarm'>ExtendedCoolWarm</option>
<option value='AsymmetricBlueOrangeDivergent'>AsymmetricBlueOrangeDivergent</option>
<option value='LinearYellow'>LinearYellow</option>
<option value='LinearGray5'>LinearGray5</option>
<option value='LinearGray4'>LinearGray4</option>
<option value='grayopaque'>grayopaque</option>
<option value='graytransparent'>graytransparent</option>
<option value='scivis_magic_colormap'>magic color map</option>
</select>
</div>
</div>
<div class="input-group input-group-sm" style="padding-top:5px">
<div class="input-group-prepend">
<span class="input-group-text form-control-sm">Range</span>
</div>
<div class="input-group-append">
<input id='palette_min' type="text" size=8 onchange='onPaletteChange();' class="form-control form-control-sm" placeholder="Min">
</div>
<div class="input-group-append">
<input id='palette_max' type="text" size=8 onchange='onPaletteChange();' class="form-control form-control-sm" placeholder="Max">
</div>
<div style="width:13%"></div>
</div>
<div id='resolution_panel' class="input-group input-group-sm" style="padding-top:5px">
<div class="input-group-prepend">
<span class="input-group-text">Resol.</span>
</div>
<div class="input-group-append">
<input id='edit_resolution' type="text" size="2" onchange='onResolutionChange(this.value);'/>
</div>
<div class="input-group-append">
<div class="input-group-text">
<input id='resolutionview' type='range' step='1' min='0' step='1' max='33' class="custom-range" oninput='onResolutionChange(this.value);'/>
</div>
</div>
<!-- <div class="input-group-append">
<label class="input-group-text" id="size_est"> ... KB </label>
</div> -->
<div class="input-group-append">
<button id='view_btn' type='button' class="btn btn-primary btn-sm" onclick='onViewResolution()'>Update</button>
</div>
</div>
</div>
<div class="modal-footer">
<div id="range_panel" style="color:white; padding-bottom:5px">
<span class="form-control-sm">Computed Range <span class="form-control-sm" id="comp_range"> [...] </span></span>
</div>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="serverModal" class="modal fade myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div id="server-modal-dialog" class="modal-dialog my-modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="col">
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Server</span>
</div>
<input id='server' type="text" size=32 onchange='setServer(this.value);' class='form-control'/>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<div class="input-group-text">
<input id='auto_refresh' type='checkbox' size=32 onchange='onRefreshChange(this.value);'></input>
</div>
</div>
<div class="input-group-append">
<span class="input-group-text">AutoRefresh</span>
</div>
</div>
</div>
<div class="col">
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">Close</button>
</div>
</div>
<div class="row">
<div class="col">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<div class="input-group-text">
<input id='auto_spin' type='checkbox' size=32 onchange='onSpinChange(this.value);'></input>
</div>
</div>
<div class="input-group-append">
<span class="input-group-text">AutoSpin</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<nav class="navbar navbar-expand-sm navbar-dark bg-dark rounded fixed-top">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a href="https://visus.org"><img src="images/visus-smallbar.png" width="80px"/></a>
</li>
<li class="nav-item">
<button id="serverbtn" type="button" class="btn btn-primary btn-sm navbar-btn" data-toggle="modal"><span class="fa fa-server"></span></button>
</li>
<li class="nav-item">
<div class="input-group input-group-sm">
<select id='dataset' onchange='setDataset(this.value);' class='custom-select' style="max-width: 200px"></select>
<div class="input-group-append input-group-sm">
<select id='field' onchange='onFieldChange(this.value);' class='custom-select' style="max-width: 100px" ></select>
</div>
</div>
</li>
<li class="nav-item" id="rendercontainer" style="min-width: 55px">
<select id='render_type' onchange='changeVis(this.value)' class='form-control border form-control-sm' data-show-content="true">
<option value="0" data-content="<i class='fa fa-pizza-slice'></i> Slice"></option>
<option value="1" data-content="<i class='fa fa-cube'></i> Volume"></option>
<option value="2" data-content="<i class='fa fa-filter'></i> IsoContour"></option>
</select>
</li>
<li class="nav-item" id="slicenav">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text form-control-sm" id='render_slider_lbl'>Axis</span>
</div>
<div class="input-group-append input-group-sm">
<select id='axis' onchange='onAxisChange(this.value);' class='custom-select'>
<option value='2'>Z</option>
<option value='1'>Y</option>
<option value='0'>X</option>
</select>
</div>
<div class="input-group-append">
<div class="input-group-text form-control-sm">
<input id='slice' type='range' min='0' step='1' max='100' class="custom-range" oninput='onSliceChange(this.value);'/>
</div>
</div>
<div class="input-group-append">
<input id='edit_slice' size="6" onchange='onSliceChange(this.value);' class='form-control form-control-sm'>
</div>
</div>
</li>
<li class="nav-item">
<button id="palettebtn" class="btn btn-warning btn-sm navbar-btn"><span class="fa fa-palette"></span></button>
</li>
<li class="nav-item">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text form-control-sm ">Time</span>
</div>
<div class="input-group-append">
<input id='edit_time' size=4 onchange='onTimeChange(this.value);' class='form-control form-control-sm navbar-btn'/>
</div>
<div class="input-group-append">
<div class="input-group-text form-control-sm">
<input class="custom-range" id='time' type='range' step='1' oninput="onTimeChange(this.value);" onchange="onTimeChange(this.value);"/>
</div>
</div>
</div>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<div class="input-group">
<button type="button" class="btn btn-primary btn-sm navbar-btn" data-toggle="modal" data-target="#downloadModal" onclick="setDefaultResolution()"><span class="fa fa-download"></span></button>
<div class="input-group-append">
<button type="button" class="btn btn-info btn-sm navbar-btn" data-toggle="modal" id='download_btn' data-target="#shareModal" onclick="shareLink()"><span class="fa fa-external-link-alt"></span></button>
</div>
</div>
</li>
<li class="nav-item">
<button id="infobtn" type="button" class="btn btn-primary btn-sm navbar-btn info-link" data-toggle="modal" ><span class="fa fa-info"></span></button>
</li>
</ul>
</div>
</nav>
</nav>
<div id="viewer">
<div class="container">
<div class="row row-centered pos">
<div class="col-lg h-100" id='osdCanvas' style='background: black;'></div>
<script>
document.write('<canvas id="3dCanvas" style="background: black" width="' + $(window).width()*.9 + '" height="' + $(window).height()*.9+ '"/>');
</script>
</div>
</div>
</div>
<script src='https://openseadragon.github.io/openseadragon/openseadragon.min.js'></script>
<script src="src/selection/openseadragonselection.js"></script>
<script src="src/colormaps.js"></script>
<script src="src/dvr.js"></script>
<script src="src/visus.js"></script>
<script src="config.js"></script>
<script src="src/viewer.js"></script>
<script>
$('#infobtn').click(function() {
console.log("infobtn.onclick");
});
$('#palettebtn').click(function() {
// reset modal if it isn't visible
if (!($('.modal.in').length)) {
$('#palette-modal-dialog').css({
top: 0,
left: $('#palettebtn').position().left-50
});
}
$('#paletteModal').modal({
backdrop: false,
show: true
});
$('#palette-modal-dialog').draggable({
handle: ".modal-body"
});
});
$('#serverbtn').click(function() {
// reset modal if it isn't visible
if (!($('.modal.in').length)) {
$('#server-modal-dialog').css({
top: 0,
left: $('#serverbtn').position().left-50
});
}
$('#serverModal').modal({
backdrop: false,
show: true
});
$('#server-modal-dialog').draggable({
handle: ".modal-body"
});
});
function changeVis(value){
console.log("change", value)
if(value=="0" || value=="2")
$("#slicenav").show();
else
$("#slicenav").hide();
onVRChange(value);
}
function rectToSelection(bounds){
rect=visus1.osd.viewport.viewportToImageRectangle(bounds.x, bounds.y, bounds.width, bounds.height)
rect=new OpenSeadragon.Rect(Math.round(rect.x),Math.round(rect.y),Math.round(rect.width),Math.round(rect.height));
selection_box[0]=rect.x;
selection_box[1]=selection_box[0]+rect.width-1;
selection_box[2]=visus1.osd.tileSources.height-(rect.y+rect.height);
selection_box[3]=visus1.osd.tileSources.height-rect.y;
}
function callDownload(){
if(!selection || selection.isSelecting==false){
bounds=visus1.getBounds()
rectToSelection(bounds)
//console.log(selection_box)
download(selection_box)
}
else{
//console.log("rect", selection.rect)
rectToSelection(selection.rect)
download(selection_box)
selection.toggleState()
}
}
function updateDownloadResolution(value){
sel_factor = 1
if(!selection || selection.isSelecting==false){
bounds=visus1.getBounds()
rectToSelection(bounds)
//console.log(selection_box)
sel_size = (selection_box[1]-selection_box[0])*(selection_box[3]-selection_box[2]);
sel_factor=sel_size/(visus1.osd.tileSources.height*visus1.osd.tileSources.width)
}
else{
//console.log("rect", selection.rect)
rectToSelection(selection.rect)
sel_size = (selection_box[1]-selection_box[0])*(selection_box[3]-selection_box[2]);
sel_factor=sel_size/(visus1.osd.tileSources.height*visus1.osd.tileSources.width)
}
//console.log("sel_factor", sel_factor)
onResolutionChange(value, sel_factor)
}
function copyClick() {
var input = document.querySelector('#link_text');
input.setSelectionRange(0, input.value.length + 1);
input.select();
try {
var success = document.execCommand('copy');
if (success) {
document.getElementById('link_text').value = "The URL has been copied to your clipboard"
// Change tooltip message to "Copied!"
console.log("success copy")
} else {
// Handle error. Perhaps change tooltip message to tell user to use Ctrl-c
// instead.
console.log("not success copy")
}
} catch (err) {
// Handle error. Perhaps change tooltip message to tell user to use Ctrl-c
// instead.
console.log("error copy", err)
}
};
$('#downloadModal').onLoad = function (){
updateDownloadResolution($('#edit_resolution').val);
};
setTimeout(function () {
if(visus1){
if(visus1.dataset.dim==3)
$("#rendercontainer").show();
else
$("#rendercontainer").hide();
}
// visualize slider if time varying dataset
// if($("#time")[0].max > $("#time")[0].min){
// $("#time").show()
// $("#time").val($("#time")[0].min)
// $("#time").change()
// $("#edit_time").show()
// }
// else{
// $("#time").hide()
// $("#edit_time").hide()
// }
}, 1000);
$('#render_type').selectpicker();
</script>
<script src="src/bigSlide.js"></script>
<script>
<!-- dataset info panel -->
$(document).ready(function() {
$('.info-link').bigSlide({side:'right', menu:'#info'});
});
</script>
</body>
</html>