|
1 | 1 | <template>
|
2 |
| - <v-dialog |
3 |
| - v-model="SimulatorState.dialogBox.saveimage_dialog" |
4 |
| - :persistent="false" |
5 |
| - > |
| 2 | + <v-dialog v-model="dialogState.saveimage_dialog" :persistent="false"> |
6 | 3 | <v-card class="messageBoxContent">
|
7 | 4 | <v-card-text>
|
8 | 5 | <p class="dialogHeader">Render Image</p>
|
9 | 6 | <v-btn
|
10 | 7 | size="x-small"
|
11 | 8 | icon
|
12 | 9 | class="dialogClose"
|
13 |
| - @click="SimulatorState.dialogBox.saveimage_dialog = false" |
| 10 | + @click="dialogState.saveimage_dialog = false" |
14 | 11 | >
|
15 | 12 | <v-icon>mdi-close</v-icon>
|
16 | 13 | </v-btn>
|
|
25 | 22 | type="radio"
|
26 | 23 | name="imgType"
|
27 | 24 | :value="imageType.toLowerCase()"
|
28 |
| - checked="checked" |
29 |
| - @click="checkImgType" |
| 25 | + v-model="selectedImageType" |
| 26 | + @change="checkImgType(imageType)" |
30 | 27 | />
|
31 | 28 | {{ imageType }}
|
32 | 29 | <span></span>
|
33 | 30 | </label>
|
34 | 31 | </div>
|
35 | 32 | <div class="download-dialog-section-2">
|
36 | 33 | <div
|
37 |
| - v-if="toShow == true" |
| 34 | + v-if="toShow" |
38 | 35 | class="option inline btn-group btn-group-toggle"
|
39 | 36 | style="border: none"
|
40 | 37 | data-toggle="buttons"
|
41 | 38 | >
|
42 | 39 | <div
|
43 | 40 | id="radio-full"
|
44 | 41 | class="btn"
|
45 |
| - :class=" |
46 |
| - fullImg == true |
47 |
| - ? 'active-btn' |
48 |
| - : 'inactive-btn' |
49 |
| - " |
| 42 | + :class="fullImg ? 'active-btn' : 'inactive-btn'" |
50 | 43 | role="button"
|
51 |
| - @click="updateView(1)" |
| 44 | + @click="updateView(true)" |
52 | 45 | >
|
53 | 46 | <input type="radio" name="view" value="full" />
|
54 | 47 | Full Circuit View
|
55 | 48 | </div>
|
56 | 49 | <div
|
57 | 50 | id="radio-current"
|
58 | 51 | class="btn"
|
59 |
| - :class=" |
60 |
| - fullImg == false |
61 |
| - ? 'active-btn' |
62 |
| - : 'inactive-btn' |
63 |
| - " |
| 52 | + :class="!fullImg ? 'active-btn' : 'inactive-btn'" |
64 | 53 | role="button"
|
65 |
| - @click="updateView(0)" |
| 54 | + @click="updateView(false)" |
66 | 55 | >
|
67 | 56 | <input
|
68 | 57 | type="radio"
|
69 | 58 | name="view"
|
70 | 59 | value="current"
|
71 |
| - checked="checked" |
72 | 60 | />Current View
|
73 | 61 | </div>
|
74 | 62 | </div>
|
75 |
| - <div |
76 |
| - v-if="toShow1 == true" |
77 |
| - class="download-dialog-section-2_2" |
78 |
| - > |
| 63 | + <div v-if="toShow1" class="download-dialog-section-2_2"> |
79 | 64 | <label class="cb-checkbox">
|
80 | 65 | <input
|
81 | 66 | type="checkbox"
|
82 | 67 | name="transparent"
|
83 | 68 | value="transparent"
|
| 69 | + v-model="transparent" |
84 | 70 | />
|
85 | 71 | Transparent Background
|
86 | 72 | </label>
|
87 | 73 | </div>
|
88 | 74 | </div>
|
89 |
| - <div |
90 |
| - v-if="toShow == true" |
91 |
| - class="download-dialog-section-3" |
92 |
| - > |
| 75 | + <div v-if="toShow" class="download-dialog-section-3"> |
93 | 76 | <span>Resolution:</span>
|
94 | 77 | <label class="option custom-radio inline"
|
95 | 78 | ><input
|
96 | 79 | type="radio"
|
97 | 80 | name="resolution"
|
98 | 81 | value="1"
|
99 |
| - checked="checked" />1x<span></span |
| 82 | + |
| 83 | + v-model="resolution" |
| 84 | + />1x<span></span |
100 | 85 | ></label>
|
101 | 86 | <label class="option custom-radio inline"
|
102 | 87 | ><input
|
103 | 88 | type="radio"
|
104 | 89 | name="resolution"
|
105 |
| - value="2" />2x<span></span |
| 90 | + value="2" |
| 91 | + v-model="resolution" |
| 92 | + />2x<span></span |
106 | 93 | ></label>
|
107 | 94 | <label class="option custom-radio inline"
|
108 | 95 | ><input
|
109 | 96 | type="radio"
|
110 | 97 | name="resolution"
|
111 |
| - value="4" />4x<span></span |
| 98 | + value="4" |
| 99 | + v-model="resolution" |
| 100 | + />4x<span></span |
112 | 101 | ></label>
|
113 | 102 | </div>
|
114 | 103 | </div>
|
115 | 104 | </v-card-text>
|
116 | 105 | <v-card-actions>
|
117 |
| - <v-btn class="messageBtn" block @click="renderCircuit()"> |
| 106 | + <v-btn class="messageBtn" block @click="renderCircuit"> |
118 | 107 | Render Circuit Image
|
119 | 108 | </v-btn>
|
120 | 109 | </v-card-actions>
|
|
125 | 114 | <script lang="ts" setup>
|
126 | 115 | import { generateImage } from '#/simulator/src/data/save'
|
127 | 116 | import { useState } from '#/store/SimulatorStore/state'
|
128 |
| -import { onMounted, ref } from '@vue/runtime-core' |
| 117 | +import { ref, computed, Ref } from '@vue/runtime-core' |
| 118 | +
|
129 | 119 | const SimulatorState = useState()
|
130 | 120 |
|
131 |
| -const imgTypeList = ref(['']) |
132 |
| -imgTypeList.value = ['PNG', 'JPEG', 'SVG', 'BMP', 'GIF', 'TIFF'] |
133 |
| -const toShow = ref(true) |
134 |
| -const toShow1 = ref(true) |
135 |
| -const fullImg = ref(false) |
| 121 | +const dialogState = computed(() => SimulatorState.dialogBox) |
136 | 122 |
|
137 |
| -onMounted(() => { |
138 |
| - SimulatorState.dialogBox.saveimage_dialog = false |
139 |
| -}) |
| 123 | +const imgTypeList: Ref<string[]> = ref(['PNG', 'JPEG', 'SVG', 'BMP', 'GIF', 'TIFF']) |
| 124 | +const toShow: Ref<boolean> = ref(true) |
| 125 | +const toShow1: Ref<boolean> = ref(true) |
| 126 | +const fullImg: Ref<boolean> = ref(false) |
| 127 | +const resolution: Ref<number> = ref(1) |
| 128 | +const transparent: Ref<boolean> = ref(false) |
| 129 | +const selectedImageType: Ref<string> = ref('png') |
140 | 130 |
|
141 |
| -function renderCircuit() { |
142 |
| - SimulatorState.dialogBox.saveimage_dialog = false |
143 |
| - generateImage( |
144 |
| - $('input[name=imgType]:checked').val(), |
145 |
| - $('input[name=view]:checked').val(), |
146 |
| - $('input[name=transparent]:checked').val(), |
147 |
| - $('input[name=resolution]:checked').val() |
148 |
| - ) |
149 |
| -} |
| 131 | +function checkImgType(imageType: string) { |
| 132 | + const isDisabled = imageType.toLowerCase() === 'svg' |
| 133 | + toShow.value = !isDisabled |
| 134 | + toShow1.value = imageType.toLowerCase() === 'png' |
150 | 135 |
|
151 |
| -function checkImgType() { |
152 |
| - $('input[name=resolution]').prop('disabled', false) |
153 |
| - $('input[name=transparent]').prop('disabled', false) |
154 |
| - const imgType = $('input[name=imgType]:checked').val() |
155 |
| - imgType == 'svg' ? (toShow.value = false) : (toShow.value = true) |
156 |
| - if (imgType === 'png') { |
157 |
| - toShow1.value = true |
158 |
| - } else { |
159 |
| - toShow1.value = false |
160 |
| - } |
161 |
| - if (imgType === 'svg') { |
162 |
| - $('input[name=resolution][value=1]').trigger('click') |
163 |
| - $('input[name=view][value="full"]').trigger('click') |
164 |
| - $('input[name=resolution]').prop('disabled', true) |
165 |
| - $('input[name=view]').prop('disabled', true) |
166 |
| - } else if (imgType !== 'png') { |
167 |
| - $('input[name=transparent]').attr('checked', false) |
168 |
| - $('input[name=transparent]').prop('disabled', true) |
169 |
| - $('input[name=view]').prop('disabled', false) |
170 |
| - $('.cb-inner').addClass('disable') |
171 |
| - } else { |
172 |
| - $('input[name=view]').prop('disabled', false) |
173 |
| - $('.cb-inner').removeClass('disable') |
| 136 | + if (isDisabled) { |
| 137 | + resolution.value = 1 |
| 138 | + fullImg.value = true |
| 139 | + } else if (imageType.toLowerCase() !== 'png') { |
| 140 | + transparent.value = false |
174 | 141 | }
|
175 | 142 | }
|
176 | 143 |
|
177 |
| -function updateView(x) { |
178 |
| - if (x == 1) { |
179 |
| - fullImg.value = true |
180 |
| - } else { |
181 |
| - fullImg.value = false |
182 |
| - } |
| 144 | +function updateView(isFullImg: boolean) { |
| 145 | + fullImg.value = isFullImg |
| 146 | +} |
| 147 | +
|
| 148 | +function renderCircuit() { |
| 149 | + SimulatorState.dialogBox.saveimage_dialog = false |
| 150 | + generateImage( |
| 151 | + selectedImageType.value, |
| 152 | + fullImg.value ? 'full' : 'current', |
| 153 | + transparent.value, |
| 154 | + resolution.value |
| 155 | + ) |
183 | 156 | }
|
184 | 157 | </script>
|
0 commit comments