Quellcode durchsuchen

add plot label input to GetPlotSettings.vue

Konstantin Ladutenko vor 3 Jahren
Ursprung
Commit
e19737a615

+ 72 - 3
guiapp/src/components/GetPlotSettings.vue

@@ -6,9 +6,11 @@
       </div>
     </div>
     <div class="col-xs-grow col-sm q-px-xs">
-      <div class="row justify-xs-center justify-sm-start items-baseline">
+      <div class="row justify-xs-center justify-sm-start items-center">
 
         <div class="col-auto">
+          <!--          TODO move to config.ts -> min max
+           -->
               <q-input
                   v-model.number="numberOfModesToPlot"
                   outlined
@@ -20,6 +22,25 @@
                   style="width: 6em"
               />
         </div>
+        <div class="col-auto">
+<!--          TODO move to config.ts ->                     style="width: 17.7em"
+ -->
+          <q-input  v-model="plotLabel"
+                    label="plot label"
+                    :shadow-text="plotLabel=='' ? shadowText+' (Tab to complete)' : ''"
+                    outlined
+                    dense
+                    class="q-pa-sm"
+                    style="width: 17.7em"
+                    @keydown="processInputFill"
+                    @focus="processInputFill"
+          />
+        </div>
+        <div class="col-auto">
+          <q-checkbox v-model="isAppendPlots">
+            append new spectra to the plot
+          </q-checkbox>
+        </div>
 
       </div>
     </div>
@@ -30,8 +51,12 @@
 import {
   defineComponent,
   computed,
-  watch
+  watch,
+  ref
   } from 'vue'
+import { event } from 'quasar'
+const { stopAndPrevent } = event
+
 import { useStore } from 'src/store'
 import { flexRowTitleStyle } from 'components/utils'
 
@@ -48,10 +73,30 @@ export default defineComponent({
         if (intVal<1) intVal = 1
         if (intVal>10) intVal = 10
         $store.commit('simulationSetup/setNumberOfModesToPlot', intVal)
-        $store.commit('plotRuntime/resizeIsPlotMode',intVal)
+        $store.commit('plotRuntime/resizeSelectorIsPlotMode',intVal)
       }
     })
 
+    const plotLabel = computed({
+      get: ()=> $store.state.simulationSetup.gui.plotLabel,
+      set: val => $store.commit('simulationSetup/setPlotLabel', val)
+    })
+
+    const isAppendPlots = computed({
+      get: ()=> $store.state.plotRuntime.isAppendPlots,
+      set: val => $store.commit('plotRuntime/setIsAppendPlots', val)
+    })
+
+    const shadowText = computed(()=>{
+      const numberOfLayers = $store.state.simulationSetup.gui.layers.length
+      let particleType = 'bulk'
+      if (numberOfLayers == 2) return 'core-shell'
+      if (numberOfLayers > 2) return 'multilayer'
+      const R = $store.state.simulationSetup.gui.layers[0].layerWidth.toString()
+      const units = $store.state.guiRuntime.units
+      return particleType+' R='+R+units
+    })
+
     watch(numberOfModesToPlot, ()=>{
       const intVal = parseInt(numberOfModesToPlot.value.toString())
       if (isNaN(intVal)) return
@@ -59,8 +104,32 @@ export default defineComponent({
       if (intVal>10) numberOfModesToPlot.value = 10
     })
 
+    const inputFillCancelled = ref(false)
+
     return { flexRowTitleStyle,
       numberOfModesToPlot,
+      plotLabel, isAppendPlots,
+      shadowText,
+      processInputFill (e:any) {
+        if (e === void 0) {
+          return
+        }
+
+        if (e.keyCode === 27) {
+          if (inputFillCancelled.value !== true) {
+            inputFillCancelled.value = true
+          }
+        }
+        else if (e.keyCode === 9) {
+          if (inputFillCancelled.value !== true && shadowText.value.length > 0) {
+            stopAndPrevent(e)
+            if (plotLabel.value == '') plotLabel.value = shadowText.value
+          }
+        }
+        else if (inputFillCancelled.value === true) {
+          inputFillCancelled.value = false
+        }
+      },
       }
   },
 })

+ 1 - 1
guiapp/src/components/PlotSelector.vue

@@ -88,7 +88,7 @@ export default defineComponent({
       return columns
     })
 
-    $store.commit('plotRuntime/resizeIsPlotMode', guiNumberOfModes.value)
+    $store.commit('plotRuntime/resizeSelectorIsPlotMode', guiNumberOfModes.value)
 
     const rows_store = computed({
       get: ()=> {

+ 3 - 0
guiapp/src/pages/Spectrum.vue

@@ -12,6 +12,9 @@
     <GetPlotSettings/>
     <div class="q-ma-xs"/>
     <RunSimulationSpectrum/>
+    <div class="col-auto q-pa-md">
+      Input result: {{$store.state.simulationSetup.gui.plotLabel}}
+    </div>
     <div class="q-ma-sm"/>
     <PlotSelector/>
     <div class="q-ma-xs"/>

+ 3 - 1
guiapp/src/store/plot-runtime/mutations.ts

@@ -28,7 +28,7 @@ const mutation: MutationTree<prsi> = {
   setQabsPlotToggle (state: prsi, val: boolean) {state.isPlotQabs = val},
   setQextPlotToggle (state: prsi, val: boolean) {state.isPlotQext = val},
 
-  resizeIsPlotMode (state:prsi, val:number) {
+  resizeSelectorIsPlotMode (state:prsi, val:number) {
     while (state.isPlotModeE.length > val) state.isPlotModeE.pop();
     while (state.isPlotModeH.length > val) state.isPlotModeH.pop();
     while (state.isPlotModeE.length < val) state.isPlotModeE.push(false);
@@ -42,6 +42,8 @@ const mutation: MutationTree<prsi> = {
     for (let i = 0; i< val.length; ++i) state.isPlotModeH[i] = val[i]
   },
 
+  setIsAppendPlots (state:prsi, val:boolean) {state.isAppendPlots = val},
+
 }
 
 export default mutation

+ 4 - 1
guiapp/src/store/plot-runtime/state.ts

@@ -30,6 +30,7 @@ export interface plotRuntimeStateInterface {
   isPlotQext: boolean
   isPlotModeE: boolean[]
   isPlotModeH: boolean[]
+  isAppendPlots: boolean
 }
 
 function state(): plotRuntimeStateInterface {
@@ -74,11 +75,13 @@ function state(): plotRuntimeStateInterface {
       // showEditInChartStudio: true,
       displaylogo: false}
   }
+  const isAppendPlots = false
 
   return { WLs,
     Qsca, Qabs, Qext, Qsca_n, Qabs_n, Qext_n,
     spectraPlot, isPlotQsca, isPlotQabs, isPlotQext,
-    isPlotModeE, isPlotModeH
+    isPlotModeE, isPlotModeH,
+    isAppendPlots
   }
 }
 

+ 1 - 0
guiapp/src/store/simulation-setup/mutations.ts

@@ -41,6 +41,7 @@ const mutation: MutationTree<sssi> = {
   setPointsWL  (state: sssi, val: number) {state.gui.pointsWL  = val},
   setCurrentWL (state: sssi, val: number) {state.gui.currentWL = val},
   setNumberOfModesToPlot  (state: sssi, val: number) {state.gui.numberOfModesToPlot  = val},
+  setPlotLabel (state: sssi, val: string) {state.gui.plotLabel = val},
 
 };
 

+ 4 - 1
guiapp/src/store/simulation-setup/state.ts

@@ -15,6 +15,7 @@ export interface simulationSetup {
   fromWL: number; toWL:number; pointsWL:number; currentWL:number
   layers: layer[]
   numberOfModesToPlot: number
+  plotLabel: string
 }
 
 export interface simulationSetupStateInterface {
@@ -35,13 +36,15 @@ function setupFactory(hostIndex = 1,
                           nSpline:undefined, kSpline:undefined
                         },
                       ],
-                      numberOfModesToPlot = 4
+                      numberOfModesToPlot = 4,
+                      plotLabel = ''
                      ):simulationSetup {
   return {hostIndex:hostIndex,
     fromWL:fromWL, toWL:toWL, pointsWL:pointsWL,
     currentWL:currentWL,
     layers: cloneDeep(layers),
     numberOfModesToPlot: numberOfModesToPlot,
+    plotLabel: plotLabel,
   }
 }