diff --git a/api/config_sample.php b/api/config_sample.php index a178d48cd..8ea01cf6f 100644 --- a/api/config_sample.php +++ b/api/config_sample.php @@ -393,4 +393,5 @@ # Dials server values $dials_rest_url = ""; $dials_rest_jwt = ""; + $dials_rest_url_rings = false; ?> diff --git a/api/index.php b/api/index.php index ace25a44c..6a500f99e 100644 --- a/api/index.php +++ b/api/index.php @@ -71,7 +71,8 @@ function setupApplication($mode): Slim $facility_courier_countries, $facility_courier_countries_nde, $facility_courier_countries_link, $dhl_enable, $scale_grid, $scale_grid_end_date, $preset_proposal, $timezone, $valid_components, $enabled_container_types, $ifsummary, $synchweb_version, $redirects, - $shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments; + $shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments, + $dials_rest_url_rings; $app->contentType('application/json'); $options = $app->container['options']; $app->response()->body(json_encode(array( @@ -95,6 +96,7 @@ function setupApplication($mode): Slim 'synchweb_version' => $synchweb_version, 'shipping_service_app_url' => $use_shipping_service_redirect || $use_shipping_service_redirect_incoming_shipments ? $shipping_service_app_url : null, 'shipping_service_app_url_incoming' => $use_shipping_service_redirect_incoming_shipments ? $shipping_service_app_url : null, + 'dials_rest_url_rings' => $dials_rest_url_rings, 'redirects' => $redirects ))); }); diff --git a/api/src/Page/Image.php b/api/src/Page/Image.php index 3f461da22..e75918e1d 100644 --- a/api/src/Page/Image.php +++ b/api/src/Page/Image.php @@ -20,11 +20,13 @@ class Image extends Page 'aid' => '\d+', 'visit' => '\w+\d+-\d+', 'thresh' => '\d', + 'res' => '\d', + 'ice' => '\d', ); public static $dispatch = array(array('/id/:id(/n/:n)', 'get', '_xtal_image'), array('/diff/id/:id(/f/:f)(/n/:n)', 'get', '_diffraction_image'), - array('/di/id/:id(/thresh/:thresh)(/n/:n)', 'get', '_diffraction_viewer'), + array('/di/id/:id(/thresh/:thresh)(/res/:res)(/ice/:ice)(/n/:n)', 'get', '_diffraction_viewer'), array('/cam/bl/:bl(/n/:n)', 'get', '_forward_webcam'), array('/oav/bl/:bl(/n/:n)', 'get', '_forward_oav'), array('/fa/fid/:id', 'get', '_fault_attachment'), @@ -192,7 +194,7 @@ function _diffraction_viewer() { } $im = $info['LOC'] . '/' . $info['FT']; - $out = '/tmp/' . $this->arg('id') . '_' . $n . ($this->has_arg('thresh') ? '_th' : '') . '.jpg'; + $out = '/tmp/' . $this->arg('id') . '_' . $n . ($this->has_arg('thresh') ? '_th' : '') . ($this->has_arg('res') ? '_res' : '') . ($this->has_arg('ice') ? '_ice' : '') . '.jpg'; global $dials_rest_url, $dials_rest_jwt; if (!file_exists($out)) { if (!empty($dials_rest_url) && !empty($dials_rest_jwt)) { @@ -212,6 +214,8 @@ function _diffraction_viewer() { 'colour_scheme' => 'greyscale', 'brightness' => $this->has_arg('thresh') ? 1000 : 10, 'format' => 'png', + 'resolution_rings' => array('show' => $this->has_arg('res')), + 'ice_rings' => array('show' => $this->has_arg('ice')), ) )); } else { diff --git a/client/src/js/modules/dc/views/imageviewer.js b/client/src/js/modules/dc/views/imageviewer.js index 4007366f3..a6152470f 100644 --- a/client/src/js/modules/dc/views/imageviewer.js +++ b/client/src/js/modules/dc/views/imageviewer.js @@ -79,10 +79,10 @@ define(['jquery', 'marionette', 'slidechange @ui.zoom': 'slideChangeZoom', 'keypress @ui.num': 'keyPressNum', - 'click @ui.res': '_dra', - 'click @ui.ice': '_dra', + 'click @ui.res': 'doIceOrRes', + 'click @ui.ice': 'doIceOrRes', 'click @ui.invert': 'doInvert', - 'click @ui.threshold': 'doThreshold', + 'click @ui.threshold': 'reloadImage', 'click button[name=next]': 'next', 'click button[name=prev]': 'prev', @@ -124,7 +124,6 @@ define(['jquery', 'marionette', this.moved = false this.blocks = 0 - this.invert_change = false this.ps = parseFloat(this.model.get('DETECTORPIXELSIZEHORIZONTAL'))/1000 || 0.172 this.diwidth = parseInt(this.model.get('DETECTORNUMBEROFPIXELSX')) || 2527 @@ -285,7 +284,7 @@ define(['jquery', 'marionette', this.n = n this.showProgressBar() this.img.onerror = this._onerror.bind(this,n) - this.img.load(app.apiurl+'/image/'+(this.low ? 'diff' : 'di')+'/id/'+this.model.get('ID')+(this.low ? '/f/1' : '')+(this.ui.threshold.is(':checked') ? '/thresh/1' : '')+('/n/'+n)) + this.img.load(app.apiurl+'/image/'+(this.low ? 'diff' : 'di')+'/id/'+this.model.get('ID')+(this.low ? '/f/1' : '')+(this.ui.threshold.is(':checked') ? '/thresh/1' : '')+(this.ui.res.is(':checked') ? '/res/1' : '')+(this.ui.ice.is(':checked') ? '/ice/1' : '')+('/n/'+n)) }, onImageProgress: function(pc) { @@ -354,6 +353,7 @@ define(['jquery', 'marionette', var self = this this.ui.canvas.fadeOut(100,function() { self.load(n) + self.ui.invert.prop('checked', false) }) }, @@ -366,6 +366,7 @@ define(['jquery', 'marionette', val-- this.change(val) this.ui.num.val(val) + this.ui.invert.prop('checked', false) } }, @@ -375,6 +376,7 @@ define(['jquery', 'marionette', val++ this.change(val) this.ui.num.val(val) + this.ui.invert.prop('checked', false) } }, @@ -407,9 +409,11 @@ define(['jquery', 'marionette', this.ctx.setTransform(this.scalef,0,0,this.scalef,this.offsetx,this.offsety) var r = this.detectVerticalSquash(this.img) this.ctx.drawImage(this.img, 0, 0, this.width, this.height/r) - - if (this.ui.res.is(':checked')) this._draw_res_rings() - if (this.ui.ice.is(':checked')) this._draw_ice_rings() + + if (!app.options.get("dials_rest_url_rings")) { + if (this.ui.res.is(':checked')) this._draw_res_rings() + if (this.ui.ice.is(':checked')) this._draw_ice_rings() + } }, @@ -443,14 +447,13 @@ define(['jquery', 'marionette', // Apply image adjustments adjust: function() { - if (this.brightness == 0 && this.contrast == 0 && !(this.invert_change || this.ui.invert.is(':checked'))) return - + if (this.brightness == 0 && this.contrast == 0 && !(this.ui.invert.is(':checked'))) return + this.c.revert() if (this.ui.invert.is(':checked')) { this.c.invert() //_plot_profiles(lastx, lasty) } - this.invert_change = false var self = this this.c.brightness(this.brightness).contrast(this.contrast).render(function() { @@ -472,13 +475,13 @@ define(['jquery', 'marionette', this.c.reloadCanvasData() this.c.resetOriginalPixelData() }, - - - + + + // Draw ice rings _draw_ice_rings: function() { var rings = [3.897, 3.669,3.441,2.671,2.249,2.07,1.95,1.92,1.88,1.72] - + this.ctx.strokeStyle='blue'; for (var i = 0; i < rings.length; i++) { this.ctx.beginPath(); @@ -487,12 +490,12 @@ define(['jquery', 'marionette', this.ctx.stroke(); } }, - + // Draw resolution rings _draw_res_rings: function() { this.ctx.strokeStyle = 'black'; this.ctx.font = this.imscale < 1 ? '10px Arial' : '30px Arial'; - + for (var i = 0; i < 5; i++) { var rad = (((this.height-10)/2)/5)*(i+1) this.ctx.beginPath(); @@ -501,8 +504,8 @@ define(['jquery', 'marionette', this.ctx.fillText(this._dist_to_res(rad*this.ps/this.imscale).toFixed(2) + 'A',this.model.get('XBEAM')/this.ps*this.imscale-(this.low ? 10 : 40 ),this.model.get('YBEAM')/this.ps*this.imscale-rad+(this.low ? 10 : 40)); } }, - - + + // Plot spot profile _plot_profiles: function(xp, yp) { if (xp < 20) xp = 20 @@ -676,9 +679,6 @@ define(['jquery', 'marionette', //return false }, - - - // Clamp zoom box _clamp_z_box: function(c) { if (c[0]+20 > this.ui.canvas.width()) c[0] = this.ui.canvas.width()-20 @@ -696,13 +696,6 @@ define(['jquery', 'marionette', if (this.offsetx < this.ui.canvas.width() - this.scalef*this.width) this.offsetx = this.ui.canvas.width() - this.scalef*this.width }, - - - - - - - // Convert distance from centre to resolution and back _dist_to_res: function(dist) { return this.model.get('WAVELENGTH') / (2*Math.sin(Math.atan(dist/this.model.get('DET'))/2)) @@ -740,11 +733,8 @@ define(['jquery', 'marionette', this.ui.resc.text(res.toFixed(2)) }, - - - - - + + // Bind load image on return keyPressNum: function(e) { var n = parseInt(this.ui.num.val()) @@ -788,12 +778,19 @@ define(['jquery', 'marionette', }, doInvert: function() { - this.invert_change = true this._dra() }, + doIceOrRes: function() { + if (app.options.get("dials_rest_url_rings")) { + this.reloadImage() + } else { + this._dra() + } + }, - doThreshold: function() { + reloadImage: function() { + this.ui.invert.prop('checked', false) this.load(this.n) } @@ -801,4 +798,4 @@ define(['jquery', 'marionette', })) -}) \ No newline at end of file +})