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

add reset zoom button

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