|
@@ -1,7 +1,9 @@
|
|
|
import { MutationTree } from 'vuex'
|
|
|
-import { plotRuntimeStateInterface as prsi, spectraData } from './state'
|
|
|
-import {cloneDeep} from 'lodash'
|
|
|
+import { cloneDeep } from 'lodash'
|
|
|
import { Data } from 'plotly.js-dist-min'
|
|
|
+import { plotRuntimeStateInterface as prsi, spectraData } from './state'
|
|
|
+import { getModeName, toUnits } from 'components/utils'
|
|
|
+
|
|
|
|
|
|
const mutation: MutationTree<prsi> = {
|
|
|
setQ (state: prsi, val: spectraData) {
|
|
@@ -14,6 +16,11 @@ const mutation: MutationTree<prsi> = {
|
|
|
state.Qext_n = cloneDeep(val.Qext_n)
|
|
|
},
|
|
|
|
|
|
+ setWLsInUnits (state:prsi, sourceUnits:string) {
|
|
|
+ state.WLsInUnits.length = 0
|
|
|
+ for (const WL of state.WLs) state.WLsInUnits.push(toUnits(WL, sourceUnits))
|
|
|
+ },
|
|
|
+
|
|
|
setQscaPlotToggle (state: prsi, val: boolean) {state.isPlotQsca = val},
|
|
|
setQabsPlotToggle (state: prsi, val: boolean) {state.isPlotQabs = val},
|
|
|
setQextPlotToggle (state: prsi, val: boolean) {state.isPlotQext = val},
|
|
@@ -36,6 +43,10 @@ const mutation: MutationTree<prsi> = {
|
|
|
for (let i = 0; i< val.length; ++i) state.isPlotModeH[i] = val[i]
|
|
|
},
|
|
|
|
|
|
+ updateXAxisTitle (state:prsi, val:string) {
|
|
|
+ if (state.spectraPlot.layout.xaxis) state.spectraPlot.layout.xaxis.title = val
|
|
|
+ },
|
|
|
+
|
|
|
updateNumberOfPlotsFromPreviousSimulations(state: prsi) {
|
|
|
state.numberOfPlotsFromPreviousSimulations = state.spectraPlot.data.length
|
|
|
},
|
|
@@ -46,7 +57,7 @@ const mutation: MutationTree<prsi> = {
|
|
|
const label:string = state.commonLabel
|
|
|
if (state.isPlotQscaTotal) {
|
|
|
const traceQsca: Partial<Data> = {
|
|
|
- x: state.WLs,
|
|
|
+ x: state.WLsInUnits,
|
|
|
y: state.Qsca,
|
|
|
type: 'scatter',
|
|
|
name: 'Qsca '+label
|
|
@@ -56,7 +67,7 @@ const mutation: MutationTree<prsi> = {
|
|
|
|
|
|
if (state.isPlotQabsTotal) {
|
|
|
const traceQabs: Partial<Data> = {
|
|
|
- x: state.WLs,
|
|
|
+ x: state.WLsInUnits,
|
|
|
y: state.Qabs,
|
|
|
type: 'scatter',
|
|
|
name: 'Qabs '+label
|
|
@@ -66,7 +77,7 @@ const mutation: MutationTree<prsi> = {
|
|
|
|
|
|
if (state.isPlotQextTotal) {
|
|
|
const traceQext: Partial<Data> = {
|
|
|
- x: state.WLs,
|
|
|
+ x: state.WLsInUnits,
|
|
|
y: state.Qext,
|
|
|
type: 'scatter',
|
|
|
name: 'Qext '+label
|
|
@@ -74,6 +85,42 @@ const mutation: MutationTree<prsi> = {
|
|
|
state.spectraPlot.data.push(traceQext)
|
|
|
}
|
|
|
|
|
|
+ const typeNames = ['E', 'H']
|
|
|
+ const totalEvaluatedModes = state.Qsca_n[0].length
|
|
|
+
|
|
|
+ for (let modeType = 0; modeType < 2; ++modeType) {
|
|
|
+ for (let mode_n = 0; mode_n < totalEvaluatedModes; ++mode_n) {
|
|
|
+ const isPlotMode = modeType === 0 ? state.isPlotModeE : state.isPlotModeH;
|
|
|
+ if (!isPlotMode[mode_n]) continue;
|
|
|
+ if (state.isPlotQsca) {
|
|
|
+ const traceQsca: Partial<Data> = {
|
|
|
+ x: state.WLsInUnits,
|
|
|
+ y: state.Qsca_n[modeType][mode_n],
|
|
|
+ type: 'scatter',
|
|
|
+ name: 'Qsca ' + typeNames[modeType] + ' ' + getModeName(mode_n + 1)+' '+label
|
|
|
+ };
|
|
|
+ state.spectraPlot.data.push(traceQsca);
|
|
|
+ }
|
|
|
+ if (state.isPlotQabs) {
|
|
|
+ const traceQabs: Partial<Data> = {
|
|
|
+ x: state.WLsInUnits,
|
|
|
+ y: state.Qabs_n[modeType][mode_n],
|
|
|
+ type: 'scatter',
|
|
|
+ name: 'Qabs ' + typeNames[modeType] + ' ' + getModeName(mode_n + 1)+' '+label
|
|
|
+ };
|
|
|
+ state.spectraPlot.data.push(traceQabs);
|
|
|
+ }
|
|
|
+ if (state.isPlotQext) {
|
|
|
+ const traceQext: Partial<Data> = {
|
|
|
+ x: state.WLsInUnits,
|
|
|
+ y: state.Qext_n[modeType][mode_n],
|
|
|
+ type: 'scatter',
|
|
|
+ name: 'Qext ' + typeNames[modeType] + ' ' + getModeName(mode_n + 1)+' '+label
|
|
|
+ };
|
|
|
+ state.spectraPlot.data.push(traceQext);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
},
|