@complat/react-spectra-editor 0.10.13-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE +662 -0
  2. package/README.md +37 -0
  3. package/dist/actions/edit_peak.js +25 -0
  4. package/dist/actions/forecast.js +41 -0
  5. package/dist/actions/integration.js +33 -0
  6. package/dist/actions/jcamp.js +41 -0
  7. package/dist/actions/layout.js +17 -0
  8. package/dist/actions/manager.js +49 -0
  9. package/dist/actions/meta.js +17 -0
  10. package/dist/actions/multiplicity.js +57 -0
  11. package/dist/actions/scan.js +33 -0
  12. package/dist/actions/shift.js +25 -0
  13. package/dist/actions/status.js +33 -0
  14. package/dist/actions/submit.js +41 -0
  15. package/dist/actions/threshold.js +33 -0
  16. package/dist/actions/ui.js +50 -0
  17. package/dist/app.js +125 -0
  18. package/dist/components/cmd_bar/01_viewer.js +133 -0
  19. package/dist/components/cmd_bar/02_zoom.js +119 -0
  20. package/dist/components/cmd_bar/03_peak.js +176 -0
  21. package/dist/components/cmd_bar/04_integration.js +273 -0
  22. package/dist/components/cmd_bar/05_multiplicity.js +228 -0
  23. package/dist/components/cmd_bar/06_undo_redo.js +137 -0
  24. package/dist/components/cmd_bar/common.js +104 -0
  25. package/dist/components/cmd_bar/index.js +113 -0
  26. package/dist/components/cmd_bar/r01_layout.js +351 -0
  27. package/dist/components/cmd_bar/r02_scan.js +226 -0
  28. package/dist/components/cmd_bar/r03_threshold.js +209 -0
  29. package/dist/components/cmd_bar/r04_submit.js +349 -0
  30. package/dist/components/cmd_bar/r05_submit_btn.js +147 -0
  31. package/dist/components/cmd_bar/r06_predict_btn.js +307 -0
  32. package/dist/components/cmd_bar/tri_btn.js +202 -0
  33. package/dist/components/common/chem.js +115 -0
  34. package/dist/components/common/comps.js +29 -0
  35. package/dist/components/common/draw.js +41 -0
  36. package/dist/components/d3_line/index.js +236 -0
  37. package/dist/components/d3_line/line_focus.js +765 -0
  38. package/dist/components/d3_rect/index.js +200 -0
  39. package/dist/components/d3_rect/rect_focus.js +301 -0
  40. package/dist/components/forecast/comps.js +337 -0
  41. package/dist/components/forecast/ir_comps.js +224 -0
  42. package/dist/components/forecast/ir_viewer.js +172 -0
  43. package/dist/components/forecast/nmr_comps.js +253 -0
  44. package/dist/components/forecast/nmr_viewer.js +170 -0
  45. package/dist/components/forecast/section_loading.js +95 -0
  46. package/dist/components/forecast_viewer.js +190 -0
  47. package/dist/components/panel/compare.js +370 -0
  48. package/dist/components/panel/index.js +191 -0
  49. package/dist/components/panel/info.js +335 -0
  50. package/dist/components/panel/multiplicity.js +405 -0
  51. package/dist/components/panel/multiplicity_coupling.js +195 -0
  52. package/dist/components/panel/multiplicity_select.js +114 -0
  53. package/dist/components/panel/peaks.js +296 -0
  54. package/dist/constants/action_type.js +140 -0
  55. package/dist/constants/list_layout.js +23 -0
  56. package/dist/constants/list_shift.js +480 -0
  57. package/dist/constants/list_ui.js +33 -0
  58. package/dist/fn.js +31 -0
  59. package/dist/helpers/brush.js +109 -0
  60. package/dist/helpers/calc.js +10 -0
  61. package/dist/helpers/carbonFeatures.js +47 -0
  62. package/dist/helpers/cfg.js +89 -0
  63. package/dist/helpers/chem.js +594 -0
  64. package/dist/helpers/compass.js +91 -0
  65. package/dist/helpers/converter.js +74 -0
  66. package/dist/helpers/extractParams.js +77 -0
  67. package/dist/helpers/extractPeaksEdit.js +69 -0
  68. package/dist/helpers/focus.js +15 -0
  69. package/dist/helpers/format.js +403 -0
  70. package/dist/helpers/init.js +80 -0
  71. package/dist/helpers/integration.js +30 -0
  72. package/dist/helpers/mount.js +112 -0
  73. package/dist/helpers/multiplicity.js +44 -0
  74. package/dist/helpers/multiplicity_calc.js +117 -0
  75. package/dist/helpers/multiplicity_complat.js +126 -0
  76. package/dist/helpers/multiplicity_manual.js +94 -0
  77. package/dist/helpers/multiplicity_verify_basic.js +196 -0
  78. package/dist/helpers/shift.js +48 -0
  79. package/dist/helpers/zoom.js +32 -0
  80. package/dist/index.js +705 -0
  81. package/dist/layer_content.js +125 -0
  82. package/dist/layer_init.js +231 -0
  83. package/dist/layer_prism.js +186 -0
  84. package/dist/reducers/index.js +89 -0
  85. package/dist/reducers/reducer_edit_peak.js +111 -0
  86. package/dist/reducers/reducer_forecast.js +113 -0
  87. package/dist/reducers/reducer_integration.js +136 -0
  88. package/dist/reducers/reducer_jcamp.js +74 -0
  89. package/dist/reducers/reducer_layout.js +27 -0
  90. package/dist/reducers/reducer_manager.js +20 -0
  91. package/dist/reducers/reducer_meta.js +30 -0
  92. package/dist/reducers/reducer_multiplicity.js +131 -0
  93. package/dist/reducers/reducer_scan.js +55 -0
  94. package/dist/reducers/reducer_shift.js +99 -0
  95. package/dist/reducers/reducer_simulation.js +30 -0
  96. package/dist/reducers/reducer_status.js +41 -0
  97. package/dist/reducers/reducer_submit.js +54 -0
  98. package/dist/reducers/reducer_threshold.js +34 -0
  99. package/dist/reducers/reducer_ui.js +46 -0
  100. package/dist/reducers/undo_redo_config.js +24 -0
  101. package/dist/sagas/index.js +50 -0
  102. package/dist/sagas/saga_edit_peak.js +84 -0
  103. package/dist/sagas/saga_manager.js +116 -0
  104. package/dist/sagas/saga_meta.js +46 -0
  105. package/dist/sagas/saga_multiplicity.js +387 -0
  106. package/dist/sagas/saga_ui.js +392 -0
  107. package/dist/third_party/jAnalyzer.js +596 -0
  108. package/dist/third_party/peakInterval.js +107 -0
  109. package/package.json +77 -0
@@ -0,0 +1,765 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
8
+
9
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10
+
11
+ var _d2 = require('d3');
12
+
13
+ var d3 = _interopRequireWildcard(_d2);
14
+
15
+ var _init = require('../../helpers/init');
16
+
17
+ var _mount = require('../../helpers/mount');
18
+
19
+ var _brush = require('../../helpers/brush');
20
+
21
+ var _brush2 = _interopRequireDefault(_brush);
22
+
23
+ var _compass = require('../../helpers/compass');
24
+
25
+ var _converter = require('../../helpers/converter');
26
+
27
+ var _focus = require('../../helpers/focus');
28
+
29
+ var _integration = require('../../helpers/integration');
30
+
31
+ var _multiplicity_calc = require('../../helpers/multiplicity_calc');
32
+
33
+ var _format = require('../../helpers/format');
34
+
35
+ var _format2 = _interopRequireDefault(_format);
36
+
37
+ var _cfg = require('../../helpers/cfg');
38
+
39
+ var _cfg2 = _interopRequireDefault(_cfg);
40
+
41
+ var _list_layout = require('../../constants/list_layout');
42
+
43
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
44
+
45
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
46
+
47
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
48
+
49
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
50
+
51
+ var LineFocus = function () {
52
+ function LineFocus(props) {
53
+ _classCallCheck(this, LineFocus);
54
+
55
+ var W = props.W,
56
+ H = props.H,
57
+ clickUiTargetAct = props.clickUiTargetAct,
58
+ selectUiSweepAct = props.selectUiSweepAct,
59
+ scrollUiWheelAct = props.scrollUiWheelAct;
60
+
61
+
62
+ this.rootKlass = '.d3Line';
63
+ this.margin = {
64
+ t: 5,
65
+ b: 40,
66
+ l: 60,
67
+ r: 5
68
+ };
69
+ this.w = W - this.margin.l - this.margin.r;
70
+ this.h = H - this.margin.t - this.margin.b;
71
+ this.clickUiTargetAct = clickUiTargetAct;
72
+ this.selectUiSweepAct = selectUiSweepAct;
73
+ this.scrollUiWheelAct = scrollUiWheelAct;
74
+ this.brush = d3.brush();
75
+ this.brushX = d3.brushX();
76
+
77
+ this.axis = null;
78
+ this.path = null;
79
+ this.thresLineUp = null;
80
+ this.thresLineDw = null;
81
+ this.grid = null;
82
+ this.tags = null;
83
+ this.ref = null;
84
+ this.ccPattern = null;
85
+ this.data = [];
86
+ this.dataPks = [];
87
+ this.tTrEndPts = null;
88
+ this.tSfPeaks = null;
89
+ this.root = null;
90
+ this.svg = null;
91
+ this.axisCall = (0, _init.InitAxisCall)(5);
92
+ this.pathCall = null;
93
+ this.tip = null;
94
+ this.factor = 0.125;
95
+ this.currentExtent = null;
96
+ this.shouldUpdate = {};
97
+ this.freq = false;
98
+ this.layout = _list_layout.LIST_LAYOUT.H1;
99
+
100
+ this.getShouldUpdate = this.getShouldUpdate.bind(this);
101
+ this.resetShouldUpdate = this.resetShouldUpdate.bind(this);
102
+ this.setTip = this.setTip.bind(this);
103
+ this.setDataParams = this.setDataParams.bind(this);
104
+ this.create = this.create.bind(this);
105
+ this.update = this.update.bind(this);
106
+ this.setConfig = this.setConfig.bind(this);
107
+ this.drawLine = this.drawLine.bind(this);
108
+ this.drawThres = this.drawThres.bind(this);
109
+ this.drawGrid = this.drawGrid.bind(this);
110
+ this.drawPeaks = this.drawPeaks.bind(this);
111
+ this.drawRef = this.drawRef.bind(this);
112
+ this.drawInteg = this.drawInteg.bind(this);
113
+ this.drawMtply = this.drawMtply.bind(this);
114
+ this.drawComparisons = this.drawComparisons.bind(this);
115
+ this.onClickTarget = this.onClickTarget.bind(this);
116
+ this.mergedPeaks = this.mergedPeaks.bind(this);
117
+ this.isFirefox = typeof InstallTrigger !== 'undefined';
118
+ }
119
+
120
+ _createClass(LineFocus, [{
121
+ key: 'getShouldUpdate',
122
+ value: function getShouldUpdate(nextEpSt, nextItSt, nextMySt) {
123
+ var _shouldUpdate = this.shouldUpdate,
124
+ prevXt = _shouldUpdate.prevXt,
125
+ prevYt = _shouldUpdate.prevYt,
126
+ prevEpSt = _shouldUpdate.prevEpSt,
127
+ prevLySt = _shouldUpdate.prevLySt,
128
+ prevItSt = _shouldUpdate.prevItSt,
129
+ prevMySt = _shouldUpdate.prevMySt,
130
+ prevTePt = _shouldUpdate.prevTePt,
131
+ prevDtPk = _shouldUpdate.prevDtPk,
132
+ prevSfPk = _shouldUpdate.prevSfPk,
133
+ prevData = _shouldUpdate.prevData;
134
+
135
+ var _TfRescale = (0, _compass.TfRescale)(this),
136
+ xt = _TfRescale.xt,
137
+ yt = _TfRescale.yt;
138
+
139
+ var sameXY = xt(1.1) === prevXt && prevYt === yt(1.1);
140
+ var sameEpSt = prevEpSt === nextEpSt;
141
+ var sameLySt = prevLySt === this.layout;
142
+ var sameItSt = prevItSt === nextItSt;
143
+ var sameMySt = prevMySt === nextMySt;
144
+ var sameTePt = prevTePt === this.tTrEndPts.length;
145
+ var sameDtPk = prevDtPk === this.dataPks.length;
146
+ var sameSfPk = prevSfPk === this.tSfPeaks.length;
147
+ var sameData = prevData === this.data.length;
148
+ var sameRef = prevEpSt.prevOffset === nextEpSt.prevOffset;
149
+ this.shouldUpdate = Object.assign({}, this.shouldUpdate, {
150
+ sameXY: sameXY, sameEpSt: sameEpSt, sameLySt: sameLySt, sameItSt: sameItSt, sameMySt: sameMySt, // eslint-disable-line
151
+ sameTePt: sameTePt, sameDtPk: sameDtPk, sameSfPk: sameSfPk, sameData: sameData, sameRef: sameRef // eslint-disable-line
152
+ });
153
+ }
154
+ }, {
155
+ key: 'resetShouldUpdate',
156
+ value: function resetShouldUpdate(prevEpSt, prevItSt, prevMySt) {
157
+ var _TfRescale2 = (0, _compass.TfRescale)(this),
158
+ xt = _TfRescale2.xt,
159
+ yt = _TfRescale2.yt;
160
+
161
+ var prevXt = xt(1.1);
162
+ var prevYt = yt(1.1);
163
+ var prevTePt = this.tTrEndPts.length;
164
+ var prevDtPk = this.dataPks.length;
165
+ var prevSfPk = this.tSfPeaks.length;
166
+ var prevData = this.data.length;
167
+ var prevLySt = this.layout;
168
+ this.shouldUpdate = Object.assign({}, this.shouldUpdate, {
169
+ prevXt: prevXt, prevYt: prevYt, prevEpSt: prevEpSt, prevLySt: prevLySt, prevItSt: prevItSt, prevMySt: prevMySt, // eslint-disable-line
170
+ prevTePt: prevTePt, prevDtPk: prevDtPk, prevSfPk: prevSfPk, prevData: prevData // eslint-disable-line
171
+ });
172
+ }
173
+ }, {
174
+ key: 'setTip',
175
+ value: function setTip() {
176
+ this.tip = (0, _init.InitTip)();
177
+ this.root.call(this.tip);
178
+ }
179
+ }, {
180
+ key: 'setDataParams',
181
+ value: function setDataParams(data, peaks, tTrEndPts, tSfPeaks, freq, layout) {
182
+ this.data = [].concat(_toConsumableArray(data));
183
+ this.dataPks = [].concat(_toConsumableArray(peaks));
184
+ this.tTrEndPts = tTrEndPts;
185
+ this.tSfPeaks = tSfPeaks;
186
+ this.freq = freq;
187
+ this.layout = layout;
188
+ }
189
+ }, {
190
+ key: 'updatePathCall',
191
+ value: function updatePathCall(xt, yt) {
192
+ this.pathCall = d3.line().x(function (d) {
193
+ return xt(d.x);
194
+ }).y(function (d) {
195
+ return yt(d.y);
196
+ });
197
+ }
198
+ }, {
199
+ key: 'setConfig',
200
+ value: function setConfig(sweepExtentSt) {
201
+ // Domain Calculate
202
+ var _ref = sweepExtentSt || { xExtent: false, yExtent: false },
203
+ xExtent = _ref.xExtent,
204
+ yExtent = _ref.yExtent;
205
+
206
+ if (!xExtent || !yExtent) {
207
+ var xes = d3.extent(this.data, function (d) {
208
+ return d.x;
209
+ }).sort(function (a, b) {
210
+ return a - b;
211
+ });
212
+ xExtent = { xL: xes[0], xU: xes[1] };
213
+ var btm = d3.min(this.data, function (d) {
214
+ return d.y;
215
+ });
216
+ var top = d3.max(this.data, function (d) {
217
+ return d.y;
218
+ });
219
+ var height = top - btm;
220
+ yExtent = {
221
+ yL: btm - this.factor * height,
222
+ yU: top + this.factor * height
223
+ };
224
+ }
225
+
226
+ this.scales.x.domain([xExtent.xL, xExtent.xU]);
227
+ this.scales.y.domain([yExtent.yL, yExtent.yU]);
228
+
229
+ // rescale for zoom
230
+
231
+ var _TfRescale3 = (0, _compass.TfRescale)(this),
232
+ xt = _TfRescale3.xt,
233
+ yt = _TfRescale3.yt;
234
+
235
+ // Axis Call
236
+
237
+
238
+ this.axisCall.x.scale(xt);
239
+ this.axisCall.y.scale(yt);
240
+
241
+ this.currentExtent = { xExtent: xExtent, yExtent: yExtent };
242
+ }
243
+ }, {
244
+ key: 'drawLine',
245
+ value: function drawLine() {
246
+ var _shouldUpdate2 = this.shouldUpdate,
247
+ sameXY = _shouldUpdate2.sameXY,
248
+ sameRef = _shouldUpdate2.sameRef;
249
+
250
+ if (sameXY && sameRef) return;
251
+
252
+ var _TfRescale4 = (0, _compass.TfRescale)(this),
253
+ xt = _TfRescale4.xt,
254
+ yt = _TfRescale4.yt;
255
+
256
+ this.updatePathCall(xt, yt);
257
+ this.path.attr('d', this.pathCall(this.data));
258
+ }
259
+ }, {
260
+ key: 'drawThres',
261
+ value: function drawThres() {
262
+ if (this.tTrEndPts.length > 0) {
263
+ this.thresLineUp.attr('d', this.pathCall(this.tTrEndPts));
264
+ this.thresLineUp.attr('visibility', 'visible');
265
+
266
+ var _tTrEndPts = _slicedToArray(this.tTrEndPts, 2),
267
+ left = _tTrEndPts[0],
268
+ right = _tTrEndPts[1];
269
+
270
+ var dwMirrorEndPts = [Object.assign({}, left, { y: -left.y }), Object.assign({}, right, { y: -right.y })];
271
+ this.thresLineDw.attr('d', this.pathCall(dwMirrorEndPts));
272
+ this.thresLineDw.attr('visibility', 'visible');
273
+ } else {
274
+ this.thresLineUp.attr('visibility', 'hidden');
275
+ this.thresLineDw.attr('visibility', 'hidden');
276
+ }
277
+ }
278
+ }, {
279
+ key: 'drawGrid',
280
+ value: function drawGrid() {
281
+ var sameXY = this.shouldUpdate.sameXY;
282
+
283
+ if (sameXY) return;
284
+
285
+ this.grid.x.call(this.axisCall.x.tickSize(-this.h, 0, 0)).selectAll('line').attr('stroke', '#ddd').attr('stroke-opacity', 0.6).attr('fill', 'none');
286
+ this.grid.y.call(this.axisCall.y.tickSize(-this.w, 0, 0)).selectAll('line').attr('stroke', '#ddd').attr('stroke-opacity', 0.6).attr('fill', 'none');
287
+ }
288
+ }, {
289
+ key: 'onClickTarget',
290
+ value: function onClickTarget(data) {
291
+ d3.event.stopPropagation();
292
+ d3.event.preventDefault();
293
+ var onPeak = true;
294
+ this.clickUiTargetAct(data, onPeak);
295
+ }
296
+ }, {
297
+ key: 'mergedPeaks',
298
+ value: function mergedPeaks(editPeakSt) {
299
+ if (!editPeakSt) return this.dataPks;
300
+ this.dataPks = (0, _converter.PksEdit)(this.dataPks, editPeakSt);
301
+ return this.dataPks;
302
+ }
303
+ }, {
304
+ key: 'drawPeaks',
305
+ value: function drawPeaks(editPeakSt) {
306
+ var _this = this;
307
+
308
+ var _shouldUpdate3 = this.shouldUpdate,
309
+ sameXY = _shouldUpdate3.sameXY,
310
+ sameEpSt = _shouldUpdate3.sameEpSt,
311
+ sameDtPk = _shouldUpdate3.sameDtPk,
312
+ sameSfPk = _shouldUpdate3.sameSfPk;
313
+
314
+ if (sameXY && sameEpSt && sameDtPk && sameSfPk) return;
315
+
316
+ // rescale for zoom
317
+
318
+ var _TfRescale5 = (0, _compass.TfRescale)(this),
319
+ xt = _TfRescale5.xt,
320
+ yt = _TfRescale5.yt;
321
+
322
+ var dPks = this.mergedPeaks(editPeakSt);
323
+
324
+ var mpp = this.tags.pPath.selectAll('path').data(dPks);
325
+ mpp.exit().attr('class', 'exit').remove();
326
+
327
+ var linePath = [{ x: -0.5, y: 10 }, { x: -0.5, y: -20 }, { x: 0.5, y: -20 }, { x: 0.5, y: 10 }];
328
+ // const faktor = layoutSt === LIST_LAYOUT.IR ? -1 : 1;
329
+ var lineSymbol = d3.line().x(function (d) {
330
+ return d.x;
331
+ }).y(function (d) {
332
+ return d.y;
333
+ })(linePath);
334
+
335
+ mpp.enter().append('path').attr('d', lineSymbol).attr('class', 'enter-peak').attr('fill', 'red').attr('stroke', 'pink').attr('stroke-width', 3).attr('stroke-opacity', 0.0).merge(mpp).attr('id', function (d) {
336
+ return 'mpp' + Math.round(1000 * d.x);
337
+ }).attr('transform', function (d) {
338
+ return 'translate(' + xt(d.x) + ', ' + yt(d.y) + ')';
339
+ }).on('mouseover', function (d, i, n) {
340
+ d3.select('#mpp' + Math.round(1000 * d.x)).attr('stroke-opacity', '1.0');
341
+ d3.select('#bpt' + Math.round(1000 * d.x)).style('fill', 'blue');
342
+ var tipParams = { d: d, layout: _this.layout };
343
+ _this.tip.show(tipParams, n[i]);
344
+ }).on('mouseout', function (d, i, n) {
345
+ d3.select('#mpp' + Math.round(1000 * d.x)).attr('stroke-opacity', '0.0');
346
+ d3.select('#bpt' + Math.round(1000 * d.x)).style('fill', 'red');
347
+ var tipParams = { d: d, layout: _this.layout };
348
+ _this.tip.hide(tipParams, n[i]);
349
+ }).on('click', function (d) {
350
+ return _this.onClickTarget(d);
351
+ });
352
+ }
353
+ }, {
354
+ key: 'drawInteg',
355
+ value: function drawInteg(integationSt) {
356
+ var _this2 = this;
357
+
358
+ var _shouldUpdate4 = this.shouldUpdate,
359
+ sameXY = _shouldUpdate4.sameXY,
360
+ sameLySt = _shouldUpdate4.sameLySt,
361
+ sameItSt = _shouldUpdate4.sameItSt,
362
+ sameData = _shouldUpdate4.sameData;
363
+
364
+ if (sameXY && sameLySt && sameItSt && sameData) return;
365
+ var stack = integationSt.stack,
366
+ refArea = integationSt.refArea,
367
+ refFactor = integationSt.refFactor,
368
+ shift = integationSt.shift;
369
+
370
+ var isDisable = _cfg2.default.btnCmdIntg(this.layout);
371
+ var itgs = isDisable ? [] : stack;
372
+
373
+ var igbp = this.tags.igbPath.selectAll('path').data(itgs);
374
+ igbp.exit().attr('class', 'exit').remove();
375
+ var igcp = this.tags.igcPath.selectAll('path').data(itgs);
376
+ igcp.exit().attr('class', 'exit').remove();
377
+
378
+ var igtp = this.tags.igtPath.selectAll('text').data(itgs);
379
+ igtp.exit().attr('class', 'exit').remove();
380
+
381
+ if (itgs.length === 0 || isDisable) return;
382
+ // rescale for zoom
383
+
384
+ var _TfRescale6 = (0, _compass.TfRescale)(this),
385
+ xt = _TfRescale6.xt;
386
+
387
+ var dh = 50;
388
+ var integBar = function integBar(data) {
389
+ return d3.line()([[xt(data.xL - shift), dh], [xt(data.xL - shift), dh - 10], [xt(data.xL - shift), dh - 5], [xt(data.xU - shift), dh - 5], [xt(data.xU - shift), dh - 10], [xt(data.xU - shift), dh]]);
390
+ };
391
+
392
+ igbp.enter().append('path').attr('class', 'igbp').attr('fill', 'none').attr('stroke', '#228B22').attr('stroke-width', 2).merge(igbp).attr('id', function (d) {
393
+ return 'igbp' + (0, _focus.itgIdTag)(d);
394
+ }).attr('d', function (d) {
395
+ return integBar(d);
396
+ }).on('mouseover', function (d) {
397
+ d3.select('#igbp' + (0, _focus.itgIdTag)(d)).attr('stroke', 'blue');
398
+ d3.select('#igbc' + (0, _focus.itgIdTag)(d)).attr('stroke', 'blue');
399
+ d3.select('#igtp' + (0, _focus.itgIdTag)(d)).style('fill', 'blue');
400
+ }).on('mouseout', function (d) {
401
+ d3.select('#igbp' + (0, _focus.itgIdTag)(d)).attr('stroke', '#228B22');
402
+ d3.select('#igbc' + (0, _focus.itgIdTag)(d)).attr('stroke', '#228B22');
403
+ d3.select('#igtp' + (0, _focus.itgIdTag)(d)).style('fill', '#228B22');
404
+ }).on('click', function (d) {
405
+ return _this2.onClickTarget(d);
406
+ });
407
+
408
+ var integCurve = function integCurve(border) {
409
+ var xL = border.xL,
410
+ xU = border.xU;
411
+ var nXL = xL - shift,
412
+ nXU = xU - shift;
413
+
414
+ var ps = _this2.data.filter(function (d) {
415
+ return d.x > nXL && d.x < nXU;
416
+ });
417
+ var kMax = _this2.data[_this2.data.length - 1].k;
418
+ if (!ps[0]) return null;
419
+ var kRef = ps[0].k;
420
+ if (!_this2.reverseXAxis(_this2.layout)) {
421
+ return d3.line().x(function (d) {
422
+ return xt(d.x);
423
+ }).y(function (d) {
424
+ return 100 - (kRef - d.k) * 400 / kMax;
425
+ })(ps);
426
+ }
427
+ return d3.line().x(function (d) {
428
+ return xt(d.x);
429
+ }).y(function (d) {
430
+ return 300 - (d.k - kRef) * 400 / kMax;
431
+ })(ps);
432
+ };
433
+
434
+ igcp.enter().append('path').attr('class', 'igcp').attr('fill', 'none').attr('stroke', '#228B22').attr('stroke-width', 2).merge(igcp).attr('id', function (d) {
435
+ return 'igbc' + (0, _focus.itgIdTag)(d);
436
+ }).attr('d', function (d) {
437
+ return integCurve(d);
438
+ }).on('mouseover', function (d) {
439
+ d3.select('#igbp' + (0, _focus.itgIdTag)(d)).attr('stroke', 'blue');
440
+ d3.select('#igbc' + (0, _focus.itgIdTag)(d)).attr('stroke', 'blue');
441
+ d3.select('#igtp' + (0, _focus.itgIdTag)(d)).style('fill', 'blue');
442
+ }).on('mouseout', function (d) {
443
+ d3.select('#igbp' + (0, _focus.itgIdTag)(d)).attr('stroke', '#228B22');
444
+ d3.select('#igbc' + (0, _focus.itgIdTag)(d)).attr('stroke', '#228B22');
445
+ d3.select('#igtp' + (0, _focus.itgIdTag)(d)).style('fill', '#228B22');
446
+ }).on('click', function (d) {
447
+ return _this2.onClickTarget(d);
448
+ });
449
+
450
+ igtp.enter().append('text').attr('class', 'igtp').attr('font-family', 'Helvetica').style('font-size', '12px').attr('fill', '#228B22').style('text-anchor', 'middle').merge(igtp).attr('id', function (d) {
451
+ return 'igtp' + (0, _focus.itgIdTag)(d);
452
+ }).text(function (d) {
453
+ return (0, _integration.calcArea)(d, refArea, refFactor);
454
+ }).attr('transform', function (d) {
455
+ return 'translate(' + xt((d.xL + d.xU) / 2 - shift) + ', ' + (dh - 12) + ')';
456
+ }).on('mouseover', function (d) {
457
+ d3.select('#igbp' + (0, _focus.itgIdTag)(d)).attr('stroke', 'blue');
458
+ d3.select('#igbc' + (0, _focus.itgIdTag)(d)).attr('stroke', 'blue');
459
+ d3.select('#igtp' + (0, _focus.itgIdTag)(d)).style('fill', 'blue');
460
+ }).on('mouseout', function (d) {
461
+ d3.select('#igbp' + (0, _focus.itgIdTag)(d)).attr('stroke', '#228B22');
462
+ d3.select('#igbc' + (0, _focus.itgIdTag)(d)).attr('stroke', '#228B22');
463
+ d3.select('#igtp' + (0, _focus.itgIdTag)(d)).style('fill', '#228B22');
464
+ }).on('click', function (d) {
465
+ return _this2.onClickTarget(d);
466
+ });
467
+ }
468
+ }, {
469
+ key: 'drawMtply',
470
+ value: function drawMtply(mtplySt) {
471
+ var _ref2,
472
+ _this3 = this;
473
+
474
+ var _shouldUpdate5 = this.shouldUpdate,
475
+ sameXY = _shouldUpdate5.sameXY,
476
+ sameLySt = _shouldUpdate5.sameLySt,
477
+ sameMySt = _shouldUpdate5.sameMySt;
478
+
479
+ if (sameXY && sameLySt && sameMySt) return;
480
+
481
+ var stack = mtplySt.stack,
482
+ smExtext = mtplySt.smExtext,
483
+ shift = mtplySt.shift;
484
+
485
+ var mpys = stack;
486
+ var isDisable = _cfg2.default.btnCmdMpy(this.layout);
487
+ if (mpys === 0 || isDisable) return;
488
+ // rescale for zoom
489
+
490
+ var _TfRescale7 = (0, _compass.TfRescale)(this),
491
+ xt = _TfRescale7.xt;
492
+
493
+ var mpyb = this.tags.mpybPath.selectAll('path').data(mpys);
494
+ mpyb.exit().attr('class', 'exit').remove();
495
+ var mpyt1 = this.tags.mpyt1Path.selectAll('text').data(mpys);
496
+ mpyt1.exit().attr('class', 'exit').remove();
497
+ var mpyt2 = this.tags.mpyt2Path.selectAll('text').data(mpys);
498
+ mpyt2.exit().attr('class', 'exit').remove();
499
+ var mPeaks = mpys.map(function (m) {
500
+ var peaks = m.peaks,
501
+ xExtent = m.xExtent;
502
+
503
+ return peaks.map(function (p) {
504
+ return Object.assign({}, p, { xExtent: xExtent });
505
+ });
506
+ });
507
+ mPeaks = (_ref2 = []).concat.apply(_ref2, _toConsumableArray(mPeaks));
508
+ var mpyp = this.tags.mpypPath.selectAll('path').data(mPeaks);
509
+ mpyp.exit().attr('class', 'exit').remove();
510
+
511
+ var height = this.h;
512
+ var dh = Math.abs(0.06 * height);
513
+ var mpyBar = function mpyBar(data) {
514
+ return d3.line()([[xt(data.xExtent.xL - shift), height - dh], [xt(data.xExtent.xL - shift), height - dh - 10], [xt(data.xExtent.xL - shift), height - dh - 5], [xt(data.xExtent.xU - shift), height - dh - 5], [xt(data.xExtent.xU - shift), height - dh - 10], [xt(data.xExtent.xU - shift), height - dh]]);
515
+ };
516
+
517
+ var mpyColor = function mpyColor(d) {
518
+ var _d$xExtent = d.xExtent,
519
+ xL = _d$xExtent.xL,
520
+ xU = _d$xExtent.xU;
521
+
522
+ return smExtext.xL === xL && smExtext.xU === xU ? 'purple' : '#DA70D6';
523
+ };
524
+
525
+ mpyb.enter().append('path').attr('class', 'mpyb').attr('fill', 'none').attr('stroke-width', 2).merge(mpyb).attr('stroke', function (d) {
526
+ return mpyColor(d);
527
+ }).attr('id', function (d) {
528
+ return 'mpyb' + (0, _focus.mpyIdTag)(d);
529
+ }).attr('d', function (d) {
530
+ return mpyBar(d);
531
+ }).on('mouseover', function (d) {
532
+ d3.selectAll('#mpyb' + (0, _focus.mpyIdTag)(d)).attr('stroke', 'blue');
533
+ d3.selectAll('#mpyt1' + (0, _focus.mpyIdTag)(d)).style('fill', 'blue');
534
+ d3.selectAll('#mpyt2' + (0, _focus.mpyIdTag)(d)).style('fill', 'blue');
535
+ d3.selectAll('#mpyp' + (0, _focus.mpyIdTag)(d)).attr('stroke', 'blue');
536
+ }).on('mouseout', function (d) {
537
+ var dColor = mpyColor(d);
538
+ d3.selectAll('#mpyb' + (0, _focus.mpyIdTag)(d)).attr('stroke', dColor);
539
+ d3.selectAll('#mpyt1' + (0, _focus.mpyIdTag)(d)).style('fill', dColor);
540
+ d3.selectAll('#mpyt2' + (0, _focus.mpyIdTag)(d)).style('fill', dColor);
541
+ d3.selectAll('#mpyp' + (0, _focus.mpyIdTag)(d)).attr('stroke', dColor);
542
+ }).on('click', function (d) {
543
+ return _this3.onClickTarget(d);
544
+ });
545
+
546
+ mpyt1.enter().append('text').attr('class', 'mpyt1').attr('font-family', 'Helvetica').style('font-size', '12px').style('text-anchor', 'middle').merge(mpyt1).attr('fill', function (d) {
547
+ return mpyColor(d);
548
+ }).attr('id', function (d) {
549
+ return 'mpyt1' + (0, _focus.mpyIdTag)(d);
550
+ }).text(function (d) {
551
+ return '' + (0, _multiplicity_calc.calcMpyCenter)(d.peaks, shift, d.mpyType).toFixed(3);
552
+ }).attr('transform', function (d) {
553
+ return 'translate(' + xt((d.xExtent.xL + d.xExtent.xU) / 2 - shift) + ', ' + (height - dh + 12) + ')';
554
+ }).on('mouseover', function (d) {
555
+ d3.selectAll('#mpyb' + (0, _focus.mpyIdTag)(d)).attr('stroke', 'blue');
556
+ d3.selectAll('#mpyt1' + (0, _focus.mpyIdTag)(d)).style('fill', 'blue');
557
+ d3.selectAll('#mpyt2' + (0, _focus.mpyIdTag)(d)).style('fill', 'blue');
558
+ d3.selectAll('#mpyp' + (0, _focus.mpyIdTag)(d)).attr('stroke', 'blue');
559
+ }).on('mouseout', function (d) {
560
+ var dColor = mpyColor(d);
561
+ d3.selectAll('#mpyb' + (0, _focus.mpyIdTag)(d)).attr('stroke', dColor);
562
+ d3.selectAll('#mpyt1' + (0, _focus.mpyIdTag)(d)).style('fill', dColor);
563
+ d3.selectAll('#mpyt2' + (0, _focus.mpyIdTag)(d)).style('fill', dColor);
564
+ d3.selectAll('#mpyp' + (0, _focus.mpyIdTag)(d)).attr('stroke', dColor);
565
+ }).on('click', function (d) {
566
+ return _this3.onClickTarget(d);
567
+ });
568
+
569
+ mpyt2.enter().append('text').attr('class', 'mpyt2').attr('font-family', 'Helvetica').style('font-size', '12px').style('text-anchor', 'middle').merge(mpyt2).attr('fill', function (d) {
570
+ return mpyColor(d);
571
+ }).attr('id', function (d) {
572
+ return 'mpyt2' + (0, _focus.mpyIdTag)(d);
573
+ }).text(function (d) {
574
+ return '(' + d.mpyType + ')';
575
+ }).attr('transform', function (d) {
576
+ return 'translate(' + xt((d.xExtent.xL + d.xExtent.xU) / 2 - shift) + ', ' + (height - dh + 24) + ')';
577
+ }).on('mouseover', function (d) {
578
+ d3.selectAll('#mpyb' + (0, _focus.mpyIdTag)(d)).attr('stroke', 'blue');
579
+ d3.selectAll('#mpyt1' + (0, _focus.mpyIdTag)(d)).style('fill', 'blue');
580
+ d3.selectAll('#mpyt2' + (0, _focus.mpyIdTag)(d)).style('fill', 'blue');
581
+ d3.selectAll('#mpyp' + (0, _focus.mpyIdTag)(d)).attr('stroke', 'blue');
582
+ }).on('mouseout', function (d) {
583
+ var dColor = mpyColor(d);
584
+ d3.selectAll('#mpyb' + (0, _focus.mpyIdTag)(d)).attr('stroke', dColor);
585
+ d3.selectAll('#mpyt1' + (0, _focus.mpyIdTag)(d)).style('fill', dColor);
586
+ d3.selectAll('#mpyt2' + (0, _focus.mpyIdTag)(d)).style('fill', dColor);
587
+ d3.selectAll('#mpyp' + (0, _focus.mpyIdTag)(d)).attr('stroke', dColor);
588
+ }).on('click', function (d) {
589
+ return _this3.onClickTarget(d);
590
+ });
591
+
592
+ var mpypH = height - dh;
593
+ var mpypPath = function mpypPath(pk) {
594
+ return [{ x: xt(pk.x - shift) - 0.5, y: mpypH - 5 }, { x: xt(pk.x - shift) - 0.5, y: mpypH - 20 }, { x: xt(pk.x - shift) + 0.5, y: mpypH - 20 }, { x: xt(pk.x - shift) + 0.5, y: mpypH - 5 }];
595
+ };
596
+ // const faktor = layoutSt === LIST_LAYOUT.IR ? -1 : 1;
597
+ var lineSymbol = d3.line().x(function (d) {
598
+ return d.x;
599
+ }).y(function (d) {
600
+ return d.y;
601
+ });
602
+
603
+ mpyp.enter().append('path').attr('class', 'mpyp').attr('fill', 'none').merge(mpyp).attr('stroke', function (d) {
604
+ return mpyColor(d);
605
+ }).attr('d', function (d) {
606
+ return lineSymbol(mpypPath(d));
607
+ }).attr('id', function (d) {
608
+ return 'mpyp' + (0, _focus.mpyIdTag)(d);
609
+ }).on('mouseover', function (d) {
610
+ d3.selectAll('#mpyb' + (0, _focus.mpyIdTag)(d)).attr('stroke', 'blue');
611
+ d3.selectAll('#mpyt1' + (0, _focus.mpyIdTag)(d)).style('fill', 'blue');
612
+ d3.selectAll('#mpyt2' + (0, _focus.mpyIdTag)(d)).style('fill', 'blue');
613
+ d3.selectAll('#mpyp' + (0, _focus.mpyIdTag)(d)).attr('stroke', 'blue');
614
+ }).on('mouseout', function (d) {
615
+ var dColor = mpyColor(d);
616
+ d3.selectAll('#mpyb' + (0, _focus.mpyIdTag)(d)).attr('stroke', dColor);
617
+ d3.selectAll('#mpyt1' + (0, _focus.mpyIdTag)(d)).style('fill', dColor);
618
+ d3.selectAll('#mpyt2' + (0, _focus.mpyIdTag)(d)).style('fill', dColor);
619
+ d3.selectAll('#mpyp' + (0, _focus.mpyIdTag)(d)).attr('stroke', dColor);
620
+ }).on('click', function (d) {
621
+ return _this3.onClickTarget(d);
622
+ });
623
+ }
624
+ }, {
625
+ key: 'drawRef',
626
+ value: function drawRef() {
627
+ // rescale for zoom
628
+ var _TfRescale8 = (0, _compass.TfRescale)(this),
629
+ xt = _TfRescale8.xt,
630
+ yt = _TfRescale8.yt;
631
+
632
+ var ccp = this.ref.selectAll('path').data(this.tSfPeaks);
633
+
634
+ ccp.exit().attr('class', 'exit').remove();
635
+
636
+ var linePath = [{ x: -0.5, y: 10 }, { x: -4, y: -20 }, { x: 4, y: -20 }, { x: 0.5, y: 10 }];
637
+ var faktor = _format2.default.isIrLayout(this.layout) ? -1 : 1;
638
+ var lineSymbol = d3.line().x(function (d) {
639
+ return d.x;
640
+ }).y(function (d) {
641
+ return faktor * d.y;
642
+ })(linePath);
643
+
644
+ ccp.enter().append('path').attr('d', lineSymbol).attr('class', 'enter-ref').attr('fill', 'green').attr('fill-opacity', 0.8).merge(ccp).attr('transform', function (d) {
645
+ return 'translate(' + xt(d.x) + ', ' + yt(d.y) + ')';
646
+ });
647
+ }
648
+ }, {
649
+ key: 'drawComparisons',
650
+ value: function drawComparisons(comparisons) {
651
+ var _this4 = this;
652
+
653
+ d3.selectAll('.line-clip-compare').remove();
654
+ if (!comparisons) return null;
655
+ comparisons.forEach(function (c, idx) {
656
+ if (!c.show) return;
657
+ var path = (0, _mount.MountComparePath)(_this4, _format2.default.compareColors(idx), idx); // #D5D8DC
658
+ path.attr('d', _this4.pathCall(c.data));
659
+ });
660
+ return null;
661
+ }
662
+ }, {
663
+ key: 'reverseXAxis',
664
+ value: function reverseXAxis(layoutSt) {
665
+ return [_list_layout.LIST_LAYOUT.UVVIS, _list_layout.LIST_LAYOUT.HPLC_UVVIS, _list_layout.LIST_LAYOUT.TGA, _list_layout.LIST_LAYOUT.XRD].indexOf(layoutSt) < 0;
666
+ }
667
+ }, {
668
+ key: 'create',
669
+ value: function create(_ref3) {
670
+ var filterSeed = _ref3.filterSeed,
671
+ filterPeak = _ref3.filterPeak,
672
+ tTrEndPts = _ref3.tTrEndPts,
673
+ tSfPeaks = _ref3.tSfPeaks,
674
+ freq = _ref3.freq,
675
+ comparisons = _ref3.comparisons,
676
+ editPeakSt = _ref3.editPeakSt,
677
+ layoutSt = _ref3.layoutSt,
678
+ integationSt = _ref3.integationSt,
679
+ mtplySt = _ref3.mtplySt,
680
+ sweepExtentSt = _ref3.sweepExtentSt,
681
+ isUiAddIntgSt = _ref3.isUiAddIntgSt,
682
+ isUiNoBrushSt = _ref3.isUiNoBrushSt;
683
+
684
+ this.svg = d3.select('.d3Svg');
685
+ (0, _mount.MountMainFrame)(this, 'focus');
686
+ (0, _mount.MountClip)(this);
687
+
688
+ this.root = d3.select(this.rootKlass).selectAll('.focus-main');
689
+ this.scales = (0, _init.InitScale)(this, this.reverseXAxis(layoutSt));
690
+ this.setTip();
691
+ this.setDataParams(filterSeed, filterPeak, tTrEndPts, tSfPeaks, freq, layoutSt);
692
+ (0, _compass.MountCompass)(this);
693
+
694
+ this.axis = (0, _mount.MountAxis)(this);
695
+ this.path = (0, _mount.MountPath)(this, 'steelblue');
696
+
697
+ var _MountThresLine = (0, _mount.MountThresLine)(this, 'green');
698
+
699
+ var _MountThresLine2 = _slicedToArray(_MountThresLine, 2);
700
+
701
+ this.thresLineUp = _MountThresLine2[0];
702
+ this.thresLineDw = _MountThresLine2[1];
703
+
704
+ this.grid = (0, _mount.MountGrid)(this);
705
+ this.tags = (0, _mount.MountTags)(this);
706
+ this.ref = (0, _mount.MountRef)(this);
707
+ (0, _mount.MountAxisLabelX)(this);
708
+ (0, _mount.MountAxisLabelY)(this);
709
+
710
+ if (this.data && this.data.length > 0) {
711
+ this.setConfig(sweepExtentSt);
712
+ this.drawLine();
713
+ this.drawThres();
714
+ this.drawGrid();
715
+ this.drawRef();
716
+ this.drawPeaks(editPeakSt);
717
+ this.drawInteg(integationSt);
718
+ this.drawMtply(mtplySt);
719
+ this.drawComparisons(comparisons);
720
+ }
721
+ (0, _brush2.default)(this, isUiAddIntgSt, isUiNoBrushSt);
722
+ this.resetShouldUpdate(editPeakSt, integationSt, mtplySt);
723
+ }
724
+ }, {
725
+ key: 'update',
726
+ value: function update(_ref4) {
727
+ var filterSeed = _ref4.filterSeed,
728
+ filterPeak = _ref4.filterPeak,
729
+ tTrEndPts = _ref4.tTrEndPts,
730
+ tSfPeaks = _ref4.tSfPeaks,
731
+ freq = _ref4.freq,
732
+ comparisons = _ref4.comparisons,
733
+ editPeakSt = _ref4.editPeakSt,
734
+ layoutSt = _ref4.layoutSt,
735
+ integationSt = _ref4.integationSt,
736
+ mtplySt = _ref4.mtplySt,
737
+ sweepExtentSt = _ref4.sweepExtentSt,
738
+ isUiAddIntgSt = _ref4.isUiAddIntgSt,
739
+ isUiNoBrushSt = _ref4.isUiNoBrushSt;
740
+
741
+ this.root = d3.select(this.rootKlass).selectAll('.focus-main');
742
+ this.scales = (0, _init.InitScale)(this, this.reverseXAxis(layoutSt));
743
+ this.setDataParams(filterSeed, filterPeak, tTrEndPts, tSfPeaks, freq, layoutSt);
744
+
745
+ if (this.data && this.data.length > 0) {
746
+ this.setConfig(sweepExtentSt);
747
+ this.getShouldUpdate(editPeakSt, integationSt, mtplySt);
748
+ this.drawLine();
749
+ this.drawThres();
750
+ this.drawGrid();
751
+ this.drawRef();
752
+ this.drawPeaks(editPeakSt);
753
+ this.drawInteg(integationSt);
754
+ this.drawMtply(mtplySt);
755
+ this.drawComparisons(comparisons);
756
+ }
757
+ (0, _brush2.default)(this, isUiAddIntgSt, isUiNoBrushSt);
758
+ this.resetShouldUpdate(editPeakSt, integationSt, mtplySt);
759
+ }
760
+ }]);
761
+
762
+ return LineFocus;
763
+ }();
764
+
765
+ exports.default = LineFocus;