Commit f2c414d8 authored by Moreau Nicolas's avatar Moreau Nicolas
Browse files

add reset zoom button

parent 9d8d0181
...@@ -224,6 +224,9 @@ ...@@ -224,6 +224,9 @@
<div id="slice" class="map" style="background-color:darkblue"></div> <div id="slice" class="map" style="background-color:darkblue"></div>
</td> </td>
<td> <td>
<button id="zoomout">-</button>
<button id="zoomin">+</button>
<button id="zoomreset">Reset</button>
<div id="spectrum"></div> <div id="spectrum"></div>
</td> </td>
</tr> </tr>
...@@ -329,13 +332,13 @@ ...@@ -329,13 +332,13 @@
var ENTER = function () { console.log(arguments.callee.name + ": entering."); }; var ENTER = function () { console.log(arguments.callee.name + ": entering."); };
var EXIT = function () { console.log(arguments.callee.name + ": exiting."); }; var EXIT = function () { console.log(arguments.callee.name + ": exiting."); };
<%if(useSAMP){%> <%if(useSAMP){%>
var sAMPPublisher = null; var sAMPPublisher = null;
<%}%> <%}%>
var ROI; var ROI;
var summedPixelsSpectrumChart; var summedPixelsSpectrumChart;
var spectrumChart var spectrumChart;
var viewIn3D = function() { var viewIn3D = function() {
window.open("getYtObj?relFITSFilePath="+relFITSFilePath+"&iRA0="+ROI.iRA0+"&iRA1="+ROI.iRA1+"&iDEC0="+ROI.iDEC0+"&iDEC1="+ROI.iDEC1+"&iFREQ0="+ROI.iFREQ0+"&iFREQ1="+ROI.iFREQ1); window.open("getYtObj?relFITSFilePath="+relFITSFilePath+"&iRA0="+ROI.iRA0+"&iRA1="+ROI.iRA1+"&iDEC0="+ROI.iDEC0+"&iDEC1="+ROI.iDEC1+"&iFREQ0="+ROI.iFREQ0+"&iFREQ1="+ROI.iFREQ1);
}; };
...@@ -682,10 +685,10 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -682,10 +685,10 @@ var SAMPPNGPublishControl = (function (Control) {
coordinateFormat: _coordinateFormatType_2 }), coordinateFormat: _coordinateFormatType_2 }),
new ol.control.FullScreen() new ol.control.FullScreen()
]; ];
<%if(useSAMP){%> <%if(useSAMP){%>
let _sAMPPNGPublishControl_1 = new SAMPPNGPublishControl(); let _sAMPPNGPublishControl_1 = new SAMPPNGPublishControl();
_sAMPPNGPublishControl_1.setHandler(sAMPPublisher.sendPNGSlice); _sAMPPNGPublishControl_1.setHandler(sAMPPublisher.sendPNGSlice);
<%}%> <%}%>
_map_1 = new ol.Map({ _map_1 = new ol.Map({
target: _divSlice, target: _divSlice,
view: new ol.View({ view: new ol.View({
...@@ -693,12 +696,12 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -693,12 +696,12 @@ var SAMPPNGPublishControl = (function (Control) {
center: ol.extent.getCenter(_extent), center: ol.extent.getCenter(_extent),
resolution: hidden_canvas_1.width / 512 resolution: hidden_canvas_1.width / 512
}) })
<%if(useSAMP){%> <%if(useSAMP){%>
, ,
controls: ol.control.defaults().extend([ controls: ol.control.defaults().extend([
_sAMPPNGPublishControl_1 _sAMPPNGPublishControl_1
]) ])
<%}%> <%}%>
}); });
_graticule_1 = new ol.Graticule({ _graticule_1 = new ol.Graticule({
...@@ -772,10 +775,10 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -772,10 +775,10 @@ var SAMPPNGPublishControl = (function (Control) {
new ol.control.FullScreen() new ol.control.FullScreen()
]; ];
<%if(useSAMP){%> <%if(useSAMP){%>
let _sAMPPNGPublishControl_2 = new SAMPPNGPublishControl(); let _sAMPPNGPublishControl_2 = new SAMPPNGPublishControl();
_sAMPPNGPublishControl_2.setHandler(sAMPPublisher.sendPNGSummedSlices); _sAMPPNGPublishControl_2.setHandler(sAMPPublisher.sendPNGSummedSlices);
<%}%> <%}%>
_map_2 = new ol.Map({ _map_2 = new ol.Map({
target: _divSummedSlices, target: _divSummedSlices,
...@@ -784,12 +787,12 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -784,12 +787,12 @@ var SAMPPNGPublishControl = (function (Control) {
center: ol.extent.getCenter(_extent), center: ol.extent.getCenter(_extent),
resolution: hidden_canvas_2.width / 512 resolution: hidden_canvas_2.width / 512
}) })
<%if(useSAMP){%> <%if(useSAMP){%>
, ,
controls: ol.control.defaults().extend([ controls: ol.control.defaults().extend([
_sAMPPNGPublishControl_2 _sAMPPNGPublishControl_2
]) ])
<%}%> <%}%>
}); });
document.getElementById("summedslices").addEventListener("mouseenter", function() { document.getElementById("summedslices").addEventListener("mouseenter", function() {
...@@ -905,9 +908,9 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -905,9 +908,9 @@ var SAMPPNGPublishControl = (function (Control) {
}); });
_map_1.addLayer(_im_layer_1); _map_1.addLayer(_im_layer_1);
} }
<% if(useSAMP){%> <% if(useSAMP){%>
sAMPPublisher.setSliceRelPNGPath(path_to_png); sAMPPublisher.setSliceRelPNGPath(path_to_png);
<%}%> <%}%>
document.getElementById('loading').style.display="none"; document.getElementById('loading').style.display="none";
console.log("$.post('/png', {'si': _sliceIndex, 'path': _path}).done(: exiting"); console.log("$.post('/png', {'si': _sliceIndex, 'path': _path}).done(: exiting");
} }
...@@ -955,9 +958,9 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -955,9 +958,9 @@ var SAMPPNGPublishControl = (function (Control) {
_map_2.addLayer(_im_layer_2); _map_2.addLayer(_im_layer_2);
_map_2.addLayer(_box_layer_2); _map_2.addLayer(_box_layer_2);
} }
<%if(useSAMP){%> <%if(useSAMP){%>
sAMPPublisher.setSummedSlicesRelPNGPath(path_to_png); sAMPPublisher.setSummedSlicesRelPNGPath(path_to_png);
<%}%> <%}%>
document.getElementById('loading').style.display="none"; document.getElementById('loading').style.display="none";
console.log("$.post('/sumpng', {'si0': _sliceIndex0, 'si1': _sliceIndex1, 'relFITSFilePath': relFITSFilePath}).done() : exiting"); console.log("$.post('/sumpng', {'si0': _sliceIndex0, 'si1': _sliceIndex1, 'relFITSFilePath': relFITSFilePath}).done() : exiting");
}); });
...@@ -1457,7 +1460,7 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1457,7 +1460,7 @@ var SAMPPNGPublishControl = (function (Control) {
plotData.y = temparr; plotData.y = temparr;
} }
} }
<%if(useSAMP){%> <%if(useSAMP){%>
//Create a FITS file containing the spectrum supposedly to publish it via SAMP. //Create a FITS file containing the spectrum supposedly to publish it via SAMP.
if(_ctype3 === "FREQ" || _ctype3 === "VRAD"){ if(_ctype3 === "FREQ" || _ctype3 === "VRAD"){
$.post("",{"method":"createFits","relFITSFilePath":_relFITSFilePath, "iRA": iRA, "iDEC": iDEC}) $.post("",{"method":"createFits","relFITSFilePath":_relFITSFilePath, "iRA": iRA, "iDEC": iDEC})
...@@ -1476,7 +1479,7 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1476,7 +1479,7 @@ var SAMPPNGPublishControl = (function (Control) {
} }
); );
} }
<%}%> <%}%>
plotData.xaxis = "x"; plotData.xaxis = "x";
...@@ -1565,6 +1568,8 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1565,6 +1568,8 @@ var SAMPPNGPublishControl = (function (Control) {
usePreAllocated: true usePreAllocated: true
}, },
xAxis: { xAxis: {
gridLineColor: '#000000',
lineColor: '#000000',
title: { title: {
text: xtitle text: xtitle
}, },
...@@ -1590,14 +1595,17 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1590,14 +1595,17 @@ var SAMPPNGPublishControl = (function (Control) {
} }
}, },
yAxis: { yAxis: {
gridLineColor: '#000000',
lineColor: '#000000',
title: { title: {
text: ytitle text: ytitle
} }
}, },
tooltip:{ plotOptions: {
/*formatter : function(){ series: {
return '( ' + this.x.toFixed(4) + ', ' + this.y.toFixed(4); + ')'; animation: false,
}*/ lineWidth : 1
}
}, },
series: [ series: [
{ {
...@@ -1623,14 +1631,46 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1623,14 +1631,46 @@ var SAMPPNGPublishControl = (function (Control) {
console.log("SpectrumViewer: exiting"); console.log("SpectrumViewer: exiting");
}; };
$("#zoomin").on('click', function(){
console.log(spectrumChart);
console.log(" min :" + spectrumChart.xAxis[0].min + " max : " + spectrumChart.xAxis[0].max);
let factor = Math.abs((spectrumChart.xAxis[0].min - spectrumChart.xAxis[0].max) * 0.2);
let minVal = spectrumChart.xAxis[0].min + factor;
let maxVal = spectrumChart.xAxis[0].max - factor;
console.log("factor : "+factor);
console.log("min : "+minVal + " , max : "+ maxVal);
spectrumChart.xAxis[0].setExtremes(minVal, maxVal);
});
$("#zoomout").on('click', function(){
let factor = Math.abs((spectrumChart.xAxis[0].min - spectrumChart.xAxis[0].max) * 0.2);
let minVal = spectrumChart.xAxis[0].min - factor;
let maxVal = spectrumChart.xAxis[0].max + factor;
spectrumChart.xAxis[0].setExtremes(minVal, maxVal);
});
$("#zoomreset").on('click', function(){
spectrumChart.xAxis[0].setExtremes(undefined, undefined);
});
function SummedPixelsSpectrumViewer (relFITSFilePath, FITSHeader, itsGD){ function SummedPixelsSpectrumViewer (relFITSFilePath, FITSHeader, itsGD){
console.log("SummedPixelsSpectrumViewer: entering"); console.log("SummedPixelsSpectrumViewer: entering");
var xtitle = "undefined"; var xtitle = "undefined";
var ytitle = "undefined"; var ytitle = "undefined";
let _averageSpectrum = null;
var toptitle = function ( value, unit ) { var toptitle = function ( value, unit ) {
return value.toExponential(4) + " (" + unit + ")"; return value.toExponential(4) + " (" + unit + ")";
}; }
this.setAverageSpectrum = function(averageSpectrum){
console.log("### setAverageSpectrum");
console.log(averageSpectrum);
_averageSpectrum = averageSpectrum;
}
var toptitle_unit = ""; var toptitle_unit = "";
if (_instrume == "SITELLE") { if (_instrume == "SITELLE") {
...@@ -1687,40 +1727,40 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1687,40 +1727,40 @@ var SAMPPNGPublishControl = (function (Control) {
xaxis: 'x' xaxis: 'x'
}; };
var plotData2 = JSON.parse(JSON.stringify(_frequencyPlot)); var plotData2 = JSON.parse(JSON.stringify(_frequencyPlot));
let _companion = null; //let _companion = null;
/* /*
** set the companion ** set the companion
*/ */
this.setCompanion = function(who) { /*this.setCompanion = function(who) {
_companion = who; _companion = who;
} }*/
/* /*
** get the companion ** get the companion
*/ */
this.getCompanion = function() { /*this.getCompanion = function() {
return _companion; return _companion;
} }*/
/* /*
** Who triggered the relayout ? ** Who triggered the relayout ?
*/ */
let _relayoutTriggeredBy = null; //let _relayoutTriggeredBy = null;
/* /*
** Set who triggered the relayout ** Set who triggered the relayout
*/ */
this.setRelayoutTriggeredBy = function(who) { /*this.setRelayoutTriggeredBy = function(who) {
_relayoutTriggeredBy = who; _relayoutTriggeredBy = who;
} }*/
/* /*
** Get who triggered the relayout. ** Get who triggered the relayout.
*/ */
this.getRelayoutTriggeredBy = function() { /*this.getRelayoutTriggeredBy = function() {
return _relayoutTriggeredBy; return _relayoutTriggeredBy;
} }*/
//Plotly.newPlot(_itsGD, _frequencyPlot, _layout); //Plotly.newPlot(_itsGD, _frequencyPlot, _layout);
this.plot = function (iRA0, iRA1, iDEC0, iDEC1, zmin, zmax) { this.plot = function (iRA0, iRA1, iDEC0, iDEC1, zmin, zmax) {
...@@ -1736,7 +1776,7 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1736,7 +1776,7 @@ var SAMPPNGPublishControl = (function (Control) {
events:{ events:{
selection: function(event){ selection: function(event){
this.xAxis[0].update({ this.xAxis[0].update({
plotBands : [{ // visualize the weekend plotBands : [{
from: event.xAxis[0].min, from: event.xAxis[0].min,
to: event.xAxis[0].max, to: event.xAxis[0].max,
color: 'rgba(68, 170, 213, .2)' color: 'rgba(68, 170, 213, .2)'
...@@ -1771,7 +1811,8 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1771,7 +1811,8 @@ var SAMPPNGPublishControl = (function (Control) {
console.log("This should not happen"); console.log("This should not happen");
} }
} }
summedAverageSpectrum = sumArr(averageSpectrum, 0, averageSpectrum.length, cdelt3prim);
this.setTitle({text:toptitle(summedAverageSpectrum/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit)});
return false; return false;
} }
} }
...@@ -1787,12 +1828,22 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1787,12 +1828,22 @@ var SAMPPNGPublishControl = (function (Control) {
}, },
crosshair : true, crosshair : true,
reversed : false, reversed : false,
gridLineColor: '#000000',
lineColor: '#000000'
}, },
yAxis: { yAxis: {
gridLineColor: '#000000',
lineColor: '#000000',
title: { title: {
text: ytitle text: ytitle
} }
}, },
plotOptions: {
series: {
animation: false,
lineWidth : 1
}
},
tooltip:{ tooltip:{
formatter : function(){ formatter : function(){
return '( ' + this.x.toFixed(4) + ', ' + this.y.toFixed(4); + ')'; return '( ' + this.x.toFixed(4) + ', ' + this.y.toFixed(4); + ')';
...@@ -1810,7 +1861,7 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1810,7 +1861,7 @@ var SAMPPNGPublishControl = (function (Control) {
document.getElementById('loading').style.display='none'; document.getElementById('loading').style.display='none';
var x = JSON.parse(resp); var x = JSON.parse(resp);
<%if(useSAMP){%> <%if(useSAMP){%>
// Let's inform the SAMP hub // Let's inform the SAMP hub
if ("absFITSFilePath" in x["result"]) { if ("absFITSFilePath" in x["result"]) {
sAMPPublisher.setAverageSpectrumFile(x["result"]["absFITSFilePath"]); sAMPPublisher.setAverageSpectrumFile(x["result"]["absFITSFilePath"]);
...@@ -1818,11 +1869,11 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1818,11 +1869,11 @@ var SAMPPNGPublishControl = (function (Control) {
else { else {
console.log("Strange we should have found a key 'absFITSFilePath'"); console.log("Strange we should have found a key 'absFITSFilePath'");
} }
<%}%> <%}%>
var averageSpectrum = x["result"]["averageSpectrum"]; averageSpectrum = x["result"]["averageSpectrum"];
var cdelt3prim = 0.; //var cdelt3prim = 0.;
var summedAverageSpectrum = 0; var summedAverageSpectrum = 0;
var start = zmin ? zmin : 0; var start = zmin ? zmin : 0;
var end = zmax ? zmax : averageSpectrum.length; var end = zmax ? zmax : averageSpectrum.length;
...@@ -1935,8 +1986,7 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1935,8 +1986,7 @@ var SAMPPNGPublishControl = (function (Control) {
for(let i=0; i< plotData2.x.length; i++){ for(let i=0; i< plotData2.x.length; i++){
highChartData.push([plotData2.x[i], plotData2.y[i]]); highChartData.push([plotData2.x[i], plotData2.y[i]]);
} }
summedPixelsSpectrumViewer.setAverageSpectrum(averageSpectrum);
summedAverageSpectrum = sumArr(averageSpectrum, start, end, cdelt3prim);
summedPixelsSpectrumChart.setTitle({text:toptitle(summedAverageSpectrum/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit)}); summedPixelsSpectrumChart.setTitle({text:toptitle(summedAverageSpectrum/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit)});
summedPixelsSpectrumChart.series[0].update({ summedPixelsSpectrumChart.series[0].update({
name : '', name : '',
...@@ -1966,11 +2016,13 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -1966,11 +2016,13 @@ var SAMPPNGPublishControl = (function (Control) {
var sliceViewer; var sliceViewer;
var spectrumViewer; var spectrumViewer;
var summedPixelsSpectrumViewer; var summedPixelsSpectrumViewer;
var averageSpectrum;
var relFITSFilePath = '<%=relFITSFilePath%>'; var relFITSFilePath = '<%=relFITSFilePath%>';
var product = '<%=product%>'; var product = '<%=product%>';
var header = {}; var header = {};
var cdelt3prim=0.;
<% for (var i in header) {%> <% for (var i in header) {%>
header["<%=i%>"]="<%=header[i]%>" header["<%=i%>"]="<%=header[i]%>"
...@@ -2056,7 +2108,7 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -2056,7 +2108,7 @@ var SAMPPNGPublishControl = (function (Control) {
console.log("var deleteFeature = function(evt){ : exiting"); console.log("var deleteFeature = function(evt){ : exiting");
}; };
<%if(useSAMP){%> <%if(useSAMP){%>
var SAMPPublisher = function ( FITSHeader, publishSpectrumDiv, publishSummedpixelsspectrumDiv, connector) { var SAMPPublisher = function ( FITSHeader, publishSpectrumDiv, publishSummedpixelsspectrumDiv, connector) {
console.log("SAMPPublisher ctor: entering"); console.log("SAMPPublisher ctor: entering");
var _FITSHeader = FITSHeader; var _FITSHeader = FITSHeader;
...@@ -2145,7 +2197,7 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -2145,7 +2197,7 @@ var SAMPPNGPublishControl = (function (Control) {
console.log("SAMPPublisher ctor: exiting"); console.log("SAMPPublisher ctor: exiting");
} }
<%}%> <%}%>
$( document ).ready(function() { $( document ).ready(function() {
console.log("$( document ).ready(function() {: entering"); console.log("$( document ).ready(function() {: entering");
/* /*
...@@ -2163,7 +2215,7 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -2163,7 +2215,7 @@ var SAMPPNGPublishControl = (function (Control) {
// Conditional code generation for SAMP publisher. // Conditional code generation for SAMP publisher.
<%if(useSAMP){%> <%if(useSAMP){%>
/* /*
** Set up everything required for the SAMP publisher. ** Set up everything required for the SAMP publisher.
*/ */
...@@ -2250,7 +2302,7 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -2250,7 +2302,7 @@ var SAMPPNGPublishControl = (function (Control) {
sAMPPublisher = new SAMPPublisher(header, publishSpectrumDiv, publishSummedpixelsspectrumDiv, connector); sAMPPublisher = new SAMPPublisher(header, publishSpectrumDiv, publishSummedpixelsspectrumDiv, connector);
sAMPPublisher.display(); sAMPPublisher.display();
<%}%> <%}%>
document.getElementById('loading').style.display='block'; document.getElementById('loading').style.display='block';
$.post("", {"method": "RADECRangeInDegrees", "relFITSFilePath": relFITSFilePath, "sessionID": 0}).done(function (resp) { $.post("", {"method": "RADECRangeInDegrees", "relFITSFilePath": relFITSFilePath, "sessionID": 0}).done(function (resp) {
...@@ -2279,8 +2331,8 @@ var SAMPPNGPublishControl = (function (Control) { ...@@ -2279,8 +2331,8 @@ var SAMPPNGPublishControl = (function (Control) {
var gdSummedPixelsPpectrum = document.getElementById('summedpixelsspectrum'); //d3.select('#summedpixelsspectrum').node(); var gdSummedPixelsPpectrum = document.getElementById('summedpixelsspectrum'); //d3.select('#summedpixelsspectrum').node();
summedPixelsSpectrumViewer = new SummedPixelsSpectrumViewer(relFITSFilePath, header, gdSummedPixelsPpectrum); summedPixelsSpectrumViewer = new SummedPixelsSpectrumViewer(relFITSFilePath, header, gdSummedPixelsPpectrum);
summedPixelsSpectrumViewer.setCompanion(spectrumViewer); //summedPixelsSpectrumViewer.setCompanion(spectrumViewer);
spectrumViewer.setCompanion(summedPixelsSpectrumViewer); //spectrumViewer.setCompanion(summedPixelsSpectrumViewer);
spectrumViewer.plot(width/2,height/2); spectrumViewer.plot(width/2,height/2);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment