Newer
Older
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
// // require() is ES5 and allows modifying global variables
// // ES6's `from` does not
// import G = require("./globals");
// import * as $ from 'jquery';
// import Dygraph from 'dygraphs';
// import * as Help from './helper';
// //la funzione drawChart (input: estremi dell'immagine, estremi dell'intervallo)
// //disegna il grafico richiesto relativo alla mappa visualizzata
// export function drawChart(image: G.Image, pixel1: G.coordinates, pixel2: G.coordinates, xMinRange: number, xMaxRange: number)
// {
// //definisco la variabile "grafico", i bottoni relativi al grafico, il tag
// //select e le due spinbox con il relativo botton
// let g: any;
// let box1 = <HTMLElement>document.getElementById("spinBoxMin");
// let box2 = <HTMLElement>document.getElementById("spinBoxMax");
// //disegno il grafico completo
// if (pixel1.x == 0 && pixel1.y == 0 && pixel2.x == image.width - 1 && pixel2.y == image.height - 1) {
// if (!G.Chart.getInstance().calibrated) { //canali
// let chartTitle: string = "Chart from (0, 0) to (" + (image.width - 1) + ", " + (image.height - 1) + ")";
// g = setChart(G.Chart.getInstance().dataCompleteChart, chartTitle);
// } else { //energie
// let chartTitle: string = "Calibrated chart from (0, 0) to (" + (image.width - 1) + ", " + (image.height - 1) + ")";
// g = setChart(G.Chart.getInstance().dataCompleteChartCalibrated, chartTitle);
// }
// //disegno il grafico parzialmente
// } else {
// //determino i conteggi dei pixel da disegnare
// let dataForChart: number[] = new Array(G.Image.getInstance().depth);
// for (let i: number = 0; i < G.Image.getInstance().depth; i++) {
// dataForChart[i] = 0;
// }
// for (let i: number = pixel1.x; i <= pixel2.x; i++) {
// for (let j: number = pixel1.y; j <= pixel2.y; j++) {
// for (let k: number = 0; k < G.Image.getInstance().depth; k++) {
// dataForChart[k] += image.DataMatrix[i][j][k];
// }
// }
// }
// if (!G.Chart.getInstance().calibrated) { //disegno in canali
// let dataChart: string = "Channel,Counts\n";
// for (let i: number = 0; i < G.Image.getInstance().depth; i++) {
// dataChart += i + "," + dataForChart[i] + "\n";
// }
// let chartTitle: string;
// if (pixel1.x == pixel2.x && pixel1.y == pixel2.y) {
// chartTitle = "Chart pixel (" + pixel1.x + ", " + (image.height - pixel1.y - 1) + ")";
// } else {
// chartTitle = "Chart from (" + pixel1.x + "," + pixel2.x + ") to (" +
// (image.height - pixel1.y - 1) + ", " + (image.height - pixel2.y - 1) + ")";
// }
// g = setChart(dataChart, chartTitle);
// } else { //disegno in energie
// let dataChartCalibrated: string = "Energy,Counts\n";
// for (let i: number = 0; i < G.Image.getInstance().depth; i++) {
// dataChartCalibrated += Help.round3(((i + 1) * G.Image.getInstance().calibration.a - G.Image.getInstance().calibration.b) / 1000) + "," + dataForChart[i] + "\n";
// }
// let chartTitle: string;
// if (pixel1.x == pixel2.x && pixel1.y == pixel2.y) {
// chartTitle = "Calibrated chart pixel (" + pixel1.x + ", " + (image.height - pixel1.y - 1) + ")";
// } else {
// chartTitle = "Calibrated chart from (" + pixel1.x + ", " + pixel2.x +
// ") to (" + (image.height - pixel1.y - 1) + ", " + (image.height - pixel2.y - 1) + ")";
// }
// g = setChart(dataChartCalibrated, chartTitle);
// }
// }
// console.log("ci sono");
// $('#setlinearButton').on('click', function ()
// { //selezione scala lineare
// g.updateOptions({ logscale: false });
// });
// $('#setlogButton').on('click', function ()
// { //selezione scala logaritmica
// g.updateOptions({ logscale: true });
// });
// $('#setEnergyButton').on('click', function ()
// { //selezione energie
// G.Chart.getInstance().calibrated = true;
// drawChart(image, pixel1, pixel2, 0, image.channelDepth);
// box1.setAttribute("value", "0");
// box2.setAttribute("value", "image.channelDepth");
// });
// $('#setChannelsButton').on('click', function ()
// { //selezione canali
// G.Chart.getInstance().calibrated = false;
// drawChart(image, pixel1, pixel2, 0, image.channelDepth);
// box1.setAttribute("value", "-");
// box2.setAttribute("value", "-");
// });
// $('#ExportGraph').on('click', function ()
// { //esportazione grafico
// let img = <HTMLImageElement>document.getElementById("chartToImg");
// Dygraph.Export.asPNG(g, img);
// $("#ExportGraph").attr("href", img.src.replace('image/png', 'image/octet-stream'));
// });
// $('#readSpinbox').on('click', function ()
// { //esportazione grafico
// peackSelection(0, 0);
// });
// $('#chart').on('click', function ()
// { //zoom manuale sul grafico
// let r: number[];
// r = g.xAxisRange();
// if (!G.Chart.getInstance().calibrated) {
// r[0] = Math.floor((((r[0] + 1) * G.Image.getInstance().calibration.a) - G.Image.getInstance().calibration.b) / 1000);
// r[1] = Math.floor((((r[1] + 1) * G.Image.getInstance().calibration.a) - G.Image.getInstance().calibration.b) / 1000);
// } else {
// r[0] = Help.round3(r[0]);
// r[1] = Help.round3(r[1]);
// box1.setAttribute("value", r[0].toString());
// box2.setAttribute("value", r[1].toString());
// }
// image.globalxMinRange = r[0];
// image.globalxMaxRange = r[1];
// drawImg(image, pixel1, pixel2, r[0], r[1]);
// });
// $('#elementSelect').on('change', function ()
// { //selezione elemento
// let element: string = (<HTMLInputElement>document.getElementById("elementSelect")).value;
// switch (element) {
// case "1": //Ca
// peackSelection(3.6, 3.8);
// box1.setAttribute("value", "3.60");
// box2.setAttribute("value", "3.80");
// break;
// case "2": //Pb
// peackSelection(10.4, 10.7);
// box1.setAttribute("value", "10.40");
// box2.setAttribute("value", "10.70");
// break;
// case "3": //Hg
// peackSelection(9.8, 10.15);
// box1.setAttribute("value", "9.80");
// box2.setAttribute("value", "10.15");
// break;
// case "4": //Fe
// peackSelection(6.3, 6.5);
// box1.setAttribute("value", "6.30");
// box2.setAttribute("value", "6.50");
// break;
// case "5": //Cu
// peackSelection(7.85, 8.2);
// box1.setAttribute("value", "7.85");
// box2.setAttribute("value", "8.20");
// break;
// case "6": //Zn
// peackSelection(8.5, 8.72);
// box1.setAttribute("value", "8.50");
// box2.setAttribute("value", "8.72");
// break;
// case "7": //Ti
// peackSelection(4.35, 4.65);
// box1.setAttribute("value", "4.35");
// box2.setAttribute("value", "4.65");
// break;
// case "8": //K
// peackSelection(3.2, 3.42);
// box1.setAttribute("value", "3.20");
// box2.setAttribute("value", "3.42");
// break;
// case "9": //Co
// peackSelection(6.8, 7.05);
// box1.setAttribute("value", "6.80");
// box2.setAttribute("value", "7.05");
// break;
// default:
// peackSelection(0, image.channelDepth);
// box1.setAttribute("value", "0");
// box2.setAttribute("value", "image.channelDepth");
// break;
// }
// });
// //la funzione setChart riceve in input i dati e il titolo del grafico da disegnare
// //il quale è restituito il output
// function setChart(dataString: string, charTitle: string)
// {
// let xArrayRange: number[]; //estremi asse x da visualizzare
// let xLab: string;
// if (!G.Chart.getInstance().calibrated) {
// xArrayRange = [0, G.Image.getInstance().depth];
// xLab = "ADC Channel";
// } else {
// xArrayRange = [xMinRange, xMaxRange];
// xLab = "Energy (keV)";
// }
// //dimensioni grafico
// let chartDim: any = document.querySelector('#chart-pannel').getBoundingClientRect();
// let chartWidth = chartDim.right - chartDim.left - 50;
// $('#chart').css('width', chartWidth);
// $('#chart').css('height', "400");
// //disegno il grafico
// let graphs: any = new Dygraph(document.getElementById("chart"), dataString, {
// title: charTitle,
// ylabel: 'Counts',
// xlabel: xLab,
// labelsDivStyles: {
// 'text-align': 'right'
// },
// //legend: 'always',
// dateWindow: xArrayRange,
// showRangeSelector: true,
// logscale: false,
// y: {}
// },);
// return graphs;
// }
// //la funzione, dati gli estremi dell'intervallo da rappresentare, aggiorna mappa e grafico
// function peackSelection(xMinRange: number, xMaxRange: number)
// {
// //let image = G.Image.getInstance();
// //se l'intervallo è [0, 0] devo leggere dalle i valori dalle spinbox
// if (xMinRange == 0 && xMaxRange == 0) {
// xMinRange = parseInt((<HTMLInputElement>box1).value);
// xMaxRange = parseInt((<HTMLInputElement>box2).value);
// }
// image.globalxMinRange = xMinRange;
// image.globalxMaxRange = xMaxRange;
// image.newOrigin = { x: 0, y: 0 };
// image.rePrint = false;
// G.Chart.getInstance().calibrated = true;
// drawImg(image, { x: 0, y: 0 }, { x: image.width - 1, y: image.height - 1 }, image.globalxMinRange, image.globalxMaxRange);
// drawChart(image, { x: 0, y: 0 }, { x: image.width - 1, y: image.height - 1 }, image.globalxMinRange, image.globalxMaxRange);
// }
// }
// //la funzione disegna il rettangolo durante la selezione di un'area della mappa