Skip to content

Commit

Permalink
user sets compare-mode base file
Browse files Browse the repository at this point in the history
  • Loading branch information
billyc committed Apr 23, 2024
1 parent b53a954 commit 2946996
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/plugins/matrix/ComparisonSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

b-dropdown-item(aria-role="listitem" @click="addToComparators")
i.fa.fa-exchange-alt
span    Set this file as a base for comparisons
span    Set this file as the base for comparisons

</template>

Expand Down
9 changes: 6 additions & 3 deletions src/plugins/matrix/H5MapViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ const MyComponent = defineComponent({
},
async mounted() {
console.log('MOUNTD')
// Load H5Wasm library and matrix file
this.h5wasm = this.initH5Wasm()
Expand Down Expand Up @@ -395,8 +394,12 @@ const MyComponent = defineComponent({
this.dataArray.forEach(v => {
if (Number.isNaN(v)) pretty.push('NaN')
else if (v == 0) pretty.push('0')
else if (Math.abs(v) >= 0.0001) pretty.push(v)
else pretty.push(v.toExponential(3))
else if (Math.abs(v) >= 0.0001) {
const trimmed = Math.round(10000 * v) / 10000
pretty.push('' + trimmed)
} else {
pretty.push(v.toExponential(3))
}
})
this.prettyDataArray = pretty
},
Expand Down
32 changes: 10 additions & 22 deletions src/plugins/matrix/MatrixViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,15 @@ const MyComponent = defineComponent({
},
addBase() {
this.comparators = [
{
root: this.root,
subfolder: this.subfolder,
filename: this.filename,
},
]
const comparator = {
root: this.root,
subfolder: this.subfolder,
filename: this.filename,
}
this.comparators = [comparator]
localStorage.setItem('h5mapComparators', JSON.stringify(this.comparators))
this.compareToBase(comparator)
},
async compareToBase(base: ComparisonMatrix) {
Expand Down Expand Up @@ -310,7 +311,6 @@ const MyComponent = defineComponent({
this.statusText = 'Loading...'
let oldbuffer = this.h5buffer
let dropbuffer = null
this.h5buffer = null
Expand All @@ -322,26 +322,14 @@ const MyComponent = defineComponent({
this.statusText = ''
if (dropbuffer) {
this.filename = file.name || 'File'
this.$emit('title', this.filename)
}
} catch (e) {
console.error('' + e)
dropbuffer = null
}
// WHAT DID USER wANt??
if (!oldbuffer && !this.h5DiffBuffer) {
// if none are set, this is normal data
this.h5buffer = dropbuffer
} else if (oldbuffer && !this.h5DiffBuffer) {
// if no base set but normal data already set,
// then move normal -> base, and this is new normal
this.h5DiffBuffer = oldbuffer
this.h5buffer = dropbuffer
} else {
// if base is already set, replace normal data and keep base as-is
this.h5buffer = dropbuffer
}
this.h5buffer = dropbuffer
},
async handleDroppedBoundaries(file: File) {
Expand Down

0 comments on commit 2946996

Please sign in to comment.