GetLayerParameters.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="field">
  3. <div class="field is-horizontal layer">
  4. <div class="field-label is-normal">
  5. <label class="label lnorm">
  6. <div v-if="particle==='bulk'"> bulk </div>
  7. <div v-else-if="particle==='core-shell'">
  8. <div v-if="index == 0"> core </div>
  9. <div v-else> shell </div>
  10. </div>
  11. <div v-else>
  12. layer {{index+1}}
  13. </div>
  14. </label>
  15. </div>
  16. <div class="field-body">
  17. <div class="field is-grouped is-grouped-multiline">
  18. <div v-if="index == 0" class="rh-input">
  19. <input-with-units title="R" v-bind:units="units"
  20. v-bind:value="layer.R"
  21. @newdata="layer.R=$event"/>
  22. <span class="tooltiptext">Core radius</span>
  23. </div>
  24. <div v-else class="rh-input">
  25. <input-with-units title="h" v-bind:units="units"
  26. v-bind:value="layer.R"
  27. @newdata="layer.R=$event"/>
  28. <span class="tooltiptext">Layer thickness</span>
  29. </div>
  30. <b-select v-model="layer.material">
  31. <option v-if="index == 0" value="PEC" disabled> PEC</option>
  32. <option value="nk">nk-constant</option>
  33. <option v-for="material in filteredMaterials" v-bind:key="material.name"
  34. v-bind:value="material.name">
  35. {{material.name}} ({{material.spline_n.xs[0]}} -
  36. {{material.spline_n.xs[material.spline_n.xs.length-1]}} nm)
  37. </option>
  38. </b-select>
  39. <!-- TODO: convert to source units in b-select above-->
  40. </div>
  41. </div>
  42. </div>
  43. <div class="field is-horizontal layer" v-if="!isDisabled">
  44. <div class="field-label is-normal">
  45. <label class="label lnorm">
  46. &nbsp;
  47. </label>
  48. </div>
  49. <div class="field-body nk-input">
  50. <div class="field is-grouped is-grouped-multiline">
  51. <input-with-units title="Re(n)" units=""
  52. v-bind:value="layer.reN"
  53. @newdata="layer.reN=$event"
  54. v-bind:isDisabled="isDisabled"/>
  55. <input-with-units title="Im(n)" units=""
  56. v-bind:value="layer.imN"
  57. @newdata="layer.imN=$event"
  58. v-bind:isDisabled="isDisabled"/>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import InputWithUnits from "./InputWithUnits.vue";
  66. export default {
  67. name: "GetLayerParameters",
  68. components: {
  69. InputWithUnits
  70. },
  71. data () {
  72. return {
  73. isDisabled: false
  74. }
  75. },
  76. computed: {
  77. filteredMaterials: function () {
  78. let tmp = []
  79. for (const mat of this.materials) if (mat.isUsed && mat.isLoaded) tmp.push(mat);
  80. return tmp;
  81. }
  82. },
  83. watch: {
  84. 'layer.material': {
  85. handler: function () {
  86. console.log('update');
  87. if (this.layer.material == 'nk') {
  88. this.isDisabled = false;
  89. } else {
  90. this.isDisabled = true;
  91. }
  92. }
  93. }
  94. },
  95. props: ['layer', 'particle', 'index', 'units', 'materials']
  96. }
  97. </script>
  98. <style scoped>
  99. .binput {
  100. display:flex;
  101. align-items:center;
  102. margin-left: 1rem;
  103. width:5rem;
  104. }
  105. .layer {
  106. margin: 0.5rem;
  107. }
  108. .lnorm {
  109. font-weight: normal;
  110. }
  111. .rh-input {
  112. margin-right: 0px;
  113. position: relative;
  114. display: inline-block;
  115. }
  116. /* Tooltip text */
  117. .rh-input .tooltiptext {
  118. visibility: hidden;
  119. width: 120px;
  120. background-color: #7957d5;
  121. color: white;
  122. text-align: center;
  123. padding: 5px 0;
  124. border-radius: 6px;
  125. /* Position the tooltip text - see examples below! */
  126. position: absolute;
  127. z-index: 1;
  128. bottom: 120%;
  129. left: 0%;
  130. }
  131. /* Show the tooltip text when you mouse over the tooltip container */
  132. .rh-input:hover .tooltiptext {
  133. visibility: visible;
  134. }
  135. .nk-input {
  136. margin-bottom: 12px;
  137. }
  138. </style>