File: template.html

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (190 lines) | stat: -rw-r--r-- 6,375 bytes parent folder | download
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
<!DOCTYPE html>
<html>
<head>
	<meta charset=utf-8>
	<style>
		body { margin: 0; }
		canvas { width: 100%; height: 100% }
	</style>
</head>
<body>
	<script src="three.min.js"></script>
	<script src="dat.gui.min.js"></script>
	<script src="OrbitControls.js"></script>
	<script src="Lut.js"></script>
	<script src="jquery.min.js"></script>
	<script src="_mcdisplay.js"></script>
	<script src="_instr.js"></script>
	<script src="_particles.js"></script>

	<script>
        var campos_x = -26.3, campos_y = 26.3, campos_z = 26.3;
        var box_x1 = 0, box_x2 = 3, box_y1 = -0.3, box_y2 = 0.3, box_z1 = 49, box_z2 = 53;
        var invert_canvas = false;
        // INSERT_CAMPOS_HERE
        // INSERT_BOX_HERE
        // INSERT_INVERT_CANVAS_HERE
        var box_lst = [box_x1, box_x2, box_y1, box_y2, box_z1, box_z2];
        var controller = new Controller(campos_x, campos_y, campos_z, box_lst, invert_canvas);
        var viewmodel = controller.viewmodel;

		// UI event handlers interacting only(!!) with the viewmodel.
		// TODO: implement callbacks
		var handlePlayPause = function()
		{
			if (viewmodel.playBack == PlayBack.RUN)
			{
				viewmodel.setPlayBack(PlayBack.PAUSE);
			}
			else
			{
				viewmodel.setPlayBack(PlayBack.RUN);
			}
		}
		var handleNext = function()
		{
			viewmodel.setPlayBack(PlayBack.PAUSE);
			viewmodel.setRayIdx(viewmodel.getRayIdx() + 1);
		}
		var handlePrev = function()
		{
			viewmodel.setPlayBack(PlayBack.PAUSE);
			viewmodel.setRayIdx(viewmodel.getRayIdx() - 1);
		}
		var handleKeepChanged = function(checked)
		{
			if (checked)
			{
				viewmodel.setDisplayMode(DisplayMode.KEEP);
			}
			else
			{
				viewmodel.setDisplayMode(DisplayMode.SINGLE);
			}
		}
		var handleShowBBChanged = function(checked)
		{
			console.log("bounding box: " + checked);
			viewmodel.setShowBoundingBox(checked);
		}
		var handleShowScatterCubesChanged = function(checked)
		{
			console.log("scatter cubes: " + checked);
			viewmodel.setShowScatterCubes(checked);
		}
		var handleViewTop = function()
		{
			controller.setViewTop();
		}
		var handleViewSide = function()
		{
			controller.setViewSide();
		}
		var handleViewHome = function()
		{
			controller.setViewHome();
		}
	</script>

	<div id="gui" style="width: auto; background-color: black;">
		<label id="lblInstrInfo" style="color: white;">(instr)</label>
	</div>
	<div id="gui" style="width: auto; background-color: black;">
		<button id="btnPrev", onclick="handlePrev();" style="width: 90px;">Previous</button>
		<button id="btnPlayPause", onclick="handlePlayPause();" style="width: 90px;">Play/Pause</button>
		<button id="btnNext", onclick="handleNext();" style="width: 90px;">Next</button>
		<label id="lblRayIdxText" style="color: white;">Ray index</label>
		<label id="lblRayIdx" style="color: white; background-color: black; width: 27px; text-align: right; display: inline-block;">(idx)</label>
		<label id="lblMaxRayIdx" style="color: white; background-color: black; display: inline-block;">(max_idx)</label>
		<label id="lblKeep" style="color: white; background-color: black; display: inline-block; text-align:right; width: 140px;">
			Keep rays<input id="cbxKeep" type="checkbox">
		</label>
		<label id="lblScatterCubes" style="color: white; background-color: black; display: inline-block; text-align:right; width: 140px;">
			Scatter Markers<input id="cbxScattCub" type="checkbox">
		</label>
		<label id="lblView" style="color: white; background-color: black; display: inline-block; text-align:right; width: 120px;">Reset view:</label>
		<button id="btnHome", onclick="handleViewHome();" style="width: 60px;">Home</button>
		<button id="btnSide", onclick="handleViewSide();" style="width: 60px;">Side</button>
		<button id="btnTop", onclick="handleViewTop();" style="width: 60px;">Top</button>
		<label id="lblView" style="color: white; background-color: black; display: inline-block; text-align:right; width: 120px;">Show BB</label>
		<input id="cbxBoundingbox" type="checkbox">
	</div>
	<div id="3dcanvas"></div>

	<script>
		// gui synchronization class
		//
		var UpdateGui = function()
		{
			this.vm_version = -1;
			this.viewmodel = viewmodel;
		}
		UpdateGui.prototype.update = function()
		{
			// return if viewmodel is constant
			if (this.vm_version == this.viewmodel.getUpdateVersion()) { return; }

			this.vm_version = this.viewmodel.getUpdateVersion();

			// update playback mode
			var pb = this.viewmodel.getPlayBack();
			if (pb == PlayBack.RUN)
			{
				btn = document.getElementById("btnPlayPause");
				btn.innerHTML = "Pause";
			}
			if (pb == PlayBack.PAUSE)
			{
				btn = document.getElementById("btnPlayPause");
				btn.innerHTML = "Play";
			}
			// update ray index
			lbl = document.getElementById("lblRayIdx");
			lbl.innerHTML = this.viewmodel.getRayIdx();

			// update keep ckeckbox
			cbxKeep = document.getElementById("cbxKeep");
			var dm = this.viewmodel.getDisplayMode();
			if (dm == DisplayMode.SINGLE)
			{
				cbxKeep.checked = false;
			}
			else
			{
				cbxKeep.checked = true;
			}

			// update show/hide scatter cubes
			cbxScattCub = document.getElementById("cbxScattCub");
			cbxScattCub.checked = this.viewmodel.getShowScatterCubes();

			// update bounding box checkbox
			cbxBoundingbox = document.getElementById("cbxBoundingbox");
			cbxBoundingbox.checked = this.viewmodel.getShowBoundingBox();
		}
		var upd = new UpdateGui();

		// set up static ui
		lblInstrInfo = document.getElementById("lblInstrInfo");
		lblInstrInfo.innerHTML = MCDATA_instrdata["cmd"];
		lblMaxRayIdx = document.getElementById("lblMaxRayIdx");
		lblMaxRayIdx.innerHTML = '/ ' + (MCDATA_particledata["numrays"] - 1);

		// set keep checkbox event handler
		cbxKeep = document.getElementById("cbxKeep");
		cbxKeep.addEventListener("change", function () { handleKeepChanged(cbxKeep.checked) });

		// set show bounding box event handler
		cbxBoundingbox = document.getElementById("cbxBoundingbox");
		cbxBoundingbox.addEventListener("change", function () { handleShowBBChanged(cbxBoundingbox.checked) });

		// set show bounding box event handler
		cbxScattCub = document.getElementById("cbxScattCub");
		cbxScattCub.addEventListener("change", function () { handleShowScatterCubesChanged(cbxScattCub.checked) });

		// call the mcdisplay app!
		controller.setUpdateGuiFunc(upd.update);
		controller.run();
    </script>
</body>
</html>