Refactor <dougal-project-settings-binning/>

This commit is contained in:
D. Berge
2023-11-13 21:10:24 +01:00
parent 2f56d377c5
commit 7ab6be5c67

View File

@@ -10,7 +10,7 @@
persistent-hint
suffix="°"
type="number"
v-model.number="theta"
v-model.number="theta_"
>
</v-text-field>
<v-text-field
@@ -20,7 +20,7 @@
type="number"
min="0"
step="1"
v-model.number="I_inc"
v-model.number="I_inc_"
>
</v-text-field>
<v-text-field
@@ -30,7 +30,7 @@
type="number"
min="0"
step="1"
v-model.number="J_inc"
v-model.number="J_inc_"
>
</v-text-field>
<v-text-field
@@ -38,7 +38,7 @@
hint="Inline bin width (can be negative)"
persistent-hint
type="number"
v-model.number="I_width"
v-model.number="I_width_"
>
</v-text-field>
<v-text-field
@@ -46,7 +46,7 @@
hint="Crossline bin width (can be negative)"
persistent-hint
type="number"
v-model.number="J_width"
v-model.number="J_width_"
>
</v-text-field>
<fieldset class="pa-3 mt-3">
@@ -58,7 +58,7 @@
hint="Bin origin easting"
persistent-hint
type="number"
v-model.number="origin.easting"
v-model.number="origin_.easting"
>
</v-text-field>
</v-col>
@@ -68,7 +68,7 @@
hint="Bin origin northing"
persistent-hint
type="number"
v-model.number="origin.northing"
v-model.number="origin_.northing"
>
</v-text-field>
</v-col>
@@ -81,7 +81,7 @@
persistent-hint
type="number"
step="1"
v-model.number="origin.I"
v-model.number="origin_.I"
>
</v-text-field>
</v-col>
@@ -92,7 +92,7 @@
persistent-hint
type="number"
step="1"
v-model.number="origin.J"
v-model.number="origin_.J"
>
</v-text-field>
</v-col>
@@ -124,16 +124,16 @@
export default {
name: "DougalProjectSettingsBinning",
props: [ "value" ],
props: [ "theta", "I_inc", "J_inc", "I_width", "J_width", "origin" ],
data () {
return {
theta: null,
I_inc: 1,
J_inc: 1,
I_width: -12.50,
J_width: 12.50,
origin: {
theta_: null,
I_inc_: 1,
J_inc_: 1,
I_width_: -12.50,
J_width_: 12.50,
origin_: {
easting: null,
northing: null,
I: null,
@@ -143,21 +143,68 @@ export default {
},
watch: {
value (newValue) {
this.reset();
theta () {
if (this.theta != this.theta_) {
this.theta_ = this.theta;
}
},
I_inc () {
if (this.I_inc != this.I_inc_) {
this.I_inc_ = this.I_inc;
}
},
J_inc () {
if (this.J_inc != this.J_inc_) {
this.J_inc_ = this.J_inc;
}
},
I_width () {
if (this.I_width != this.I_width_) {
this.I_width_ = this.I_width;
}
},
J_width () {
if (this.J_width != this.J_width_) {
this.J_width_ = this.J_width;
}
},
origin () {
if (Object.entries(this.origin).some(i => this.origin_[i[0]] != i[1])) {
this.origin_ = {...this.origin};
}
}
},
methods: {
reset () {
for (const key of Object.keys(this.$data)) {
this[key] = this.value[key];
}
this.theta_ = this.theta;
this.I_inc_ = this.I_inc;
this.J_inc_ = this.J_inc;
this.I_width_ = this.I_width;
this.J_width_ = this.J_width;
this.origin_ = {...this.origin};
this.origin_.origin = {...this.origin.origin};
},
save () {
this.$emit('input', {...this.$data});
this.$emit('input', {
binning: {
theta: this.theta_,
I_inc: this.I_inc_,
J_inc: this.J_inc_,
I_width: this.I_width_,
J_width: this.J_width_,
origin: this.origin_
}
});
},
back () {