PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/components/tools/OmeroWeb/omeroweb/webtest/templates/webtest/demo_viewers/channel_overlay_viewer.html

https://github.com/ximenesuk/openmicroscopy
HTML | 291 lines | 253 code | 37 blank | 1 comment | 0 complexity | 18f4513aaaf2ed504da6741862737a2e MD5 | raw file
  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
  2. <html> <head>
  3. <title>Channel Overlay Viewer</title>
  4. <style type="text/css">
  5. body {
  6. font-family: arial;
  7. }
  8. </style>
  9. {% include "webgateway/base/includes/script_src_jquery.html" %}
  10. <script type="text/javascript" src="{% static 'webadmin/javascript/jquery.imgareaselect-0.9.8/jquery.imgareaselect.js' %}"></script>
  11. <link rel="stylesheet" type="text/css" href="{% static 'webadmin/javascript/jquery.imgareaselect-0.9.8/css/imgareaselect-default.css' %}" />
  12. <script type="text/javascript">
  13. $(document).ready(function() {
  14. var $zoomSelect = $("#zoomSelect");
  15. var $viewer = $('#viewer');
  16. var imgHeight = $viewer.attr('height');
  17. var imgWidth = $viewer.attr('width');
  18. function preview(img, selection) {
  19. if (!selection.width || !selection.height)
  20. return;
  21. var zoomPercent = parseInt($zoomSelect.attr('value'));
  22. var height = {{ image.getSizeY }} * zoomPercent/100;
  23. var width = {{ image.getSizeX }} * zoomPercent/100;
  24. var viewPortWidth = Math.round(selection.width * zoomPercent/100);
  25. var viewPortHeight = Math.round(selection.height * zoomPercent/100);
  26. var marginLeft = -Math.round(selection.x1 * zoomPercent/100);
  27. var marginTop = -Math.round(selection.y1 * zoomPercent/100);
  28. $('#preview').css({
  29. width: viewPortWidth + "px",
  30. height: viewPortHeight + "px",
  31. });
  32. $('#preview img').css({
  33. width: width + "px",
  34. height: height + "px",
  35. marginLeft: -Math.round(selection.x1 * zoomPercent/100) + "px",
  36. marginTop: -Math.round(selection.y1 * zoomPercent/100) + "px"
  37. });
  38. }
  39. $('img#viewer').imgAreaSelect({
  40. handles: true,
  41. onSelectChange: preview
  42. });
  43. $(".cSelect").click(function() {
  44. var $radio = $(this);
  45. var cIndex = $radio.attr('value');
  46. $(".planeRow").css("background", "white")
  47. .each(function() {
  48. var $i = $('input:checked', this);
  49. if ($i.length == 1) {
  50. $(this).css("background", $i.attr('name'));
  51. }
  52. });
  53. refreshImage();
  54. });
  55. // increment X/Y shift values
  56. $(".incShift").click(function() {
  57. var incValue = 0;
  58. var incType = $(this).attr('class').split(" ")[1];
  59. if (incType == "minusBig") incValue = -10;
  60. else if (incType == "minusSmall") incValue = -1;
  61. else if (incType == "plusBig") incValue = 10;
  62. else if (incType == "plusSmall") incValue = 1;
  63. var $input = $(this).parent().children('input');
  64. var oldVal = parseInt($input.attr('value'));
  65. var newVal = oldVal + incValue;
  66. $input.attr('value', newVal);
  67. refreshImage();
  68. });
  69. // increment Z indexes
  70. $(".incZ").click(function() {
  71. var incValue = 0;
  72. var incType = $(this).attr('class').split(" ")[1];
  73. if (incType == "minus") incValue = -1;
  74. else if (incType == "plus") incValue = 1;
  75. // increment all Z indexes
  76. $('.zIndex').each(function() {
  77. var $input = $(this);
  78. var oldVal = parseInt($input.attr('value'));
  79. $input.attr('value', oldVal + incValue);
  80. });
  81. refreshImage();
  82. });
  83. // increment T indexes
  84. $(".incT").click(function() {
  85. var incValue = 0;
  86. var incType = $(this).attr('class').split(" ")[1];
  87. if (incType == "minus") incValue = -1;
  88. else if (incType == "plus") incValue = 1;
  89. // increment all Z indexes
  90. $('.tIndex').each(function() {
  91. var $input = $(this);
  92. var oldVal = parseInt($input.attr('value'));
  93. $input.attr('value', oldVal + incValue);
  94. });
  95. refreshImage();
  96. });
  97. var refreshImage = function() {
  98. // need to construct the query string from the current status of our form and update img src
  99. // E.g. planes=0|2305:7:0:0$x:-50_y:10,1|2305:7:1:0,2|2305:7:2:0&red=2&blue=0&green=1
  100. query = "planes=";
  101. index = 0
  102. $(".planeRow").each(function() {
  103. var $row = $(this);
  104. if (index>0){
  105. query += ",";
  106. }
  107. var imageId = $row.find('[name="imageId"]').attr('value');
  108. var z = $row.find('[name="z"]').attr('value');
  109. var c = $row.find('[name="c"]').attr('value');
  110. var t = $row.find('[name="t"]').attr('value');
  111. query += index + "|" + imageId + ":" + z + ":" + c + ":" + t;
  112. var x = $row.find('[name="x"]').attr('value');
  113. var y = $row.find('[name="y"]').attr('value');
  114. query += "$x:" + x + "_y:" + y;
  115. index +=1;
  116. });
  117. $(".cSelect[name='red']").each(function() {
  118. if ($(this).attr('checked')) {
  119. var i=$(this).attr('value');
  120. query += '&red='+i;
  121. };
  122. });
  123. $(".cSelect[name='green']").each(function() {
  124. if ($(this).attr('checked')) {
  125. var i=$(this).attr('value');
  126. query += '&green='+i;
  127. };
  128. });
  129. $(".cSelect[name='blue']").each(function() {
  130. if ($(this).attr('checked')) {
  131. var i=$(this).attr('value');
  132. query += '&blue='+i;
  133. };
  134. });
  135. var imgSrc = "{% url 'webtest_render_channel_overlay' %}?" + query;
  136. $("#viewer").attr('src', imgSrc);
  137. $("#lens").attr('src', imgSrc);
  138. }
  139. $('#update').click(function() {
  140. refreshImage();
  141. });
  142. refreshImage();
  143. // when the "Save" button is clicked, we want to compile a 'comment' of z, x, y offsets for each channel
  144. // and post it to save it on the image (with particular namespace)
  145. // E.g. comment=0|z:1_x:0_y:0,1|z:0_x:10_y:0,2|z:0_x:0_y:0 &imageIds=1234
  146. $('#save').click(function() {
  147. var query = "ns=omero.web.channel_overlay.offsets&replace=true&comment=";
  148. var zOffsets = [];
  149. var xOffsets = [];
  150. var yOffsets = [];
  151. var imageId = null;
  152. $(".planeRow").each(function() {
  153. var $row = $(this);
  154. imageId = $row.find('[name="imageId"]').attr('value');
  155. var z = $row.find('[name="z"]').attr('value');
  156. zOffsets.push(z);
  157. var x = $row.find('[name="x"]').attr('value');
  158. xOffsets.push(x);
  159. var y = $row.find('[name="y"]').attr('value');
  160. yOffsets.push(y);
  161. });
  162. // normalise z-offsets to 0
  163. var minZ = Math.min.apply( Math, zOffsets );
  164. for (var i=0; i<zOffsets.length; i+=1) {
  165. if (i>0){
  166. query += ",";
  167. }
  168. query += i + "|";
  169. query += "z:" + (zOffsets[i]-minZ) + "_x:" + xOffsets[i] + "_y:" + yOffsets[i];
  170. }
  171. query += "&imageIds="+imageId
  172. // bit of a hack - should really POST properly.
  173. var url = "{% url 'webtest_add_annotations' %}" + "?" + query;
  174. window.location = url;
  175. });
  176. });
  177. </script>
  178. </head>
  179. <body>
  180. <div style="float:left">
  181. <img id='viewer' src="" width="{{ image.width }}" height="{{ image.height }}"/>
  182. </div>
  183. <div id="preview" style="float:left; width: 100px; height: 100px; overflow: hidden;">
  184. <img id="lens" src="" style="width: 100px; height: 100px;" />
  185. </div>
  186. <div style="padding:10px; margin:10px; float:left">
  187. <div style="float:right">
  188. Zoom: <input id='zoomSelect' type="text" size="5" name="zoom" value='200'/> %
  189. </div>
  190. Adjust the x-shift and y-shift of individual planes to align them. <br />
  191. Draw a rectangle on the image to zoom that region.<br />
  192. Also possible to pick the Z, C, T and Image-ID to mix planes from different images.
  193. <hr />
  194. <!-- table of all the channels -->
  195. <table>
  196. <tr>
  197. <td>Red</td><td>Green</td><td>Blue</td>
  198. <td>Image-ID</td>
  199. <td>Z
  200. <img class='incZ minus' src="{% static 'webtest/img/channel_overlay/minus12.png' %}" width='12'/>
  201. <img class='incZ plus' src="{% static 'webtest/img/channel_overlay/plus12.png' %}" width='12'/>
  202. </td>
  203. <td>C</td>
  204. <td>T
  205. <img class='incT minus' src="{% static 'webtest/img/channel_overlay/minus12.png' %}" width='12'/>
  206. <img class='incT plus' src="{% static 'webtest/img/channel_overlay/plus12.png' %}" width='12'/>
  207. </td>
  208. <td>Channel Name</td><td>x-shift</td><td>y-shift</td>
  209. </tr>
  210. {% for c in channels %}
  211. <tr class='planeRow'
  212. {% ifequal blue forloop.counter0 %}bgcolor="blue"{% endifequal %}
  213. {% ifequal green forloop.counter0 %}bgcolor="green"{% endifequal %}
  214. {% ifequal red forloop.counter0 %}bgcolor="red"{% endifequal %}
  215. >
  216. <td><input class='cSelect' type="radio" name="red" value="{{ forloop.counter0 }}"
  217. {% ifequal red forloop.counter0 %} checked="True" {% endifequal %}/></td>
  218. <td><input class='cSelect' type="radio" name="green" value="{{ forloop.counter0 }}"
  219. {% ifequal green forloop.counter0 %} checked="True" {% endifequal %}/></td>
  220. <td><input class='cSelect' type="radio" name="blue" value="{{ forloop.counter0 }}"
  221. {% ifequal blue forloop.counter0 %} checked="True" {% endifequal %}/></td>
  222. <td><input type="text" size="10" name="imageId" value='{{ image.id }}'/></td>
  223. <td><input class='zIndex' type="text" size="2" name="z" value='{% if c.z %}{{c.z}}{% else %}{{ default_z }}{% endif %}'/></td>
  224. <td><input type="text" size="2" name="c" value='{{ forloop.counter0 }}'/></td>
  225. <td><input class='tIndex' type="text" size="2" name="t" value='0'/></td>
  226. <td>{{ c.name }}</td>
  227. <td>
  228. <img class='incShift minusBig' src="{% static 'webtest/img/channel_overlay/minus12.png' %}" width='16' />
  229. <img class='incShift minusSmall' src="{% static 'webtest/img/channel_overlay/minus12.png' %}" width='12' />
  230. <img class='incShift plusSmall' src="{% static 'webtest/img/channel_overlay/plus12.png' %}" width='12'/>
  231. <img class='incShift plusBig' src="{% static 'webtest/img/channel_overlay/plus12.png' %}" width='16'/>
  232. <input type="text" size="5" name="x" value='{% if c.x %}{{c.x}}{% else %}0{% endif %}'/>
  233. </td>
  234. <td>
  235. <img class='incShift minusBig' src="{% static 'webtest/img/channel_overlay/minus12.png' %}" width='16' />
  236. <img class='incShift minusSmall' src="{% static 'webtest/img/channel_overlay/minus12.png' %}" width='12' />
  237. <img class='incShift plusSmall' src="{% static 'webtest/img/channel_overlay/plus12.png' %}" width='12'/>
  238. <img class='incShift plusBig' src="{% static 'webtest/img/channel_overlay/plus12.png' %}" width='16'/>
  239. <input type="text" size="5" name="y" value='{% if c.y %}{{c.y}}{% else %}0{% endif %}'/>
  240. </td>
  241. </tr>
  242. {% endfor %}
  243. <tr>
  244. <td><input class='cSelect' type="radio" name="red" value="off" />off</td>
  245. <td><input class='cSelect' type="radio" name="green" value="off" />off</td>
  246. <td><input class='cSelect' type="radio" name="blue" value="off" />off</td>
  247. <td colspan='5'></td>
  248. <td><input id='update' type="button" value="update" /></td>
  249. <td><input id='save' type="button" value="save" /></td>
  250. </tr>
  251. </table>
  252. <hr />
  253. </div>
  254. </body> </html>