Skip to content

Commit

Permalink
diplotrans next level of evolution
Browse files Browse the repository at this point in the history
  • Loading branch information
kepper committed May 2, 2024
1 parent 38c92d3 commit 1758b66
Show file tree
Hide file tree
Showing 7 changed files with 381 additions and 49 deletions.
2 changes: 1 addition & 1 deletion 40-create-ghcred.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#/bin/sh

# create nginx config from evironment
# create nginx config from environment
# *prevent envsubst from killing nginx vars with 'tr' and '@'*
cat <<EOT | envsubst | tr '@' '$' >/GH_OAUTH_CLIENT.conf
set @CLIENT_ID $CLIENT_ID;
Expand Down
42 changes: 42 additions & 0 deletions src/components/DiploTabMenu.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<div class="diploTabMenu">
<div class="entry right">
<div class="cancel button" title="Cancel [Esc]">⛌</div>
<label>Next</label>
<div class="value" :title="stateTitle">{{ stateLabel }}</div>
</div>
<div class="entry">
<label>@xml:id</label>
<div class="value string">{{elementId}}</div>
Expand Down Expand Up @@ -49,6 +54,30 @@ export default {
}
},
computed: {
diploTransState () {
return this.$store.getters.diploTransState
},
stateLabel () {
const state = this.diploTransState
console.log('773: ' + state + '' + this.$store.getters.diploTransState)
if (state === 'awaitStart') {
return 'Select Shape in Facsimile'
} else if (state === 'awaitAT') {
return 'Select from Annotated Transcription'
} else {
return 'Modify Diplomatic Transcription'
}
},
stateTitle () {
const state = this.diploTransState
if (state === 'awaitStart') {
return 'Select Shape in Facsimile'
} else if (state === 'awaitAT') {
return 'Select from Annotated Transcription'
} else {
return 'Modify Diplomatic Transcription or select new shape in Facsimile'
}
},
elementId () {
return this.$store.getters.activeDiploTransElementId
},
Expand Down Expand Up @@ -111,6 +140,19 @@ export default {
text-decoration: underline;
}
}
.cancel {
cursor: pointer;
float: right;
font-size: .7rem;
&:hover {
text-decoration: none;
}
}
&.right {
float: right;
}
}
}
</style>
101 changes: 58 additions & 43 deletions src/components/FacsimileComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,66 @@ export default {
click.page = clickedPagePos
// }
// console.log('-------------\n\nCLICK\n\n------------\n', click)
// check for click to svg shape
if (click.target.localName === 'path') {
console.log('clicked on shape ' + click.target.id)
this.$store.dispatch('clickedSvgShape', click.target.id)
// console.log('clicked on shape ' + click.target.id + ' – this.type: ' + this.type)
if (this.type === 'facsimile' && this.explorerTab === 'diplo') {
const selectFunc = () => {
this.$store.dispatch('diploTransToggle', { type: 'shape', id: click.target.id })
}
const func = () => {
console.log('clicked on shape ' + click.target.id)
}
const usedShape = click.target.classList.contains('usedShape')
const addShapeEntry = {
label: 'Add shape to current DiploTrans element',
action: () => {
console.log('TODO: add shape to current DiploTrans element')
},
disabled: this.$store.getters.diploTransSelectedId === null
}
const activateDTEntry = {
label: 'Activate element in DiploTrans',
action: () => {
console.log('TODO: activate element in DiploTrans')
},
disabled: !usedShape
}
const adjustFunctionEntry = {
label: 'Adjust function of shape in DiploTrans',
action: () => {
console.log('TODO: adjust function of shape in DiploTrans')
},
// TODO: only possible for some element types, like notes, but not slurs
disabled: this.$store.getters.diploTransSelectedId === null && !usedShape
}
const contextMenu = {
pos: { x: e.originalEvent.clientX, y: e.originalEvent.clientY },
items: [
{ label: 'Select for automatic transcription', action: selectFunc, disabled: false },
{
label: 'Transcribe shape without AnnotTrans',
disabled: false,
items: [
{ label: 'Deletion', action: func, disabled: false },
{ label: 'Pitch Clarification Letter', action: func, disabled: false },
{ label: 'Navigational Sign', action: func, disabled: false }
]
},
addShapeEntry,
activateDTEntry,
adjustFunctionEntry
]
}
this.$store.dispatch('setContextMenu', contextMenu)
} else {
this.$store.dispatch('clickedSvgShape', click.target.id)
}
}
// check for click to system
Expand All @@ -191,45 +245,6 @@ export default {
console.log('selecting activeDiploTransElementId: ', id)
}
}
/*
const counterRotate = this.viewer.viewport.getRotation()// this.tileSource.degrees * -1
const center = { x: 0, y: 0 }
console.log('counterRotate: ', counterRotate, this.tileSource.degrees * -1)
console.log(e)
const pageOverlay = this.viewer.getOverlayById(document.querySelector('.overlay.pageBorder'))
const pageOverlayViewportBounds = pageOverlay.getBounds(this.viewer.viewport)
console.log('pageOverlayViewportBounds', pageOverlayViewportBounds)
const clientPos = new OpenSeadragon.Point(e.clientX, e.clientY)// { x: e.clientX, y: e.clientY }
// const imagePoint = image.viewerElementToImageCoordinates(clientPos)
// const viewerPoint = this.viewer.viewport.viewportToViewerElementCoordinates(clientPos)
// const viewPoint = this.viewer.viewport.viewerElementToViewportCoordinates(clientPos)
// const pointFromPixel = this.viewer.viewport.pointFromPixel(clientPos)
// const pointFromPixelNoRotate = this.viewer.viewport.pointFromPixelNoRotate(clientPos)
// const windowToImageCoordinates = this.viewer.viewport.windowToImageCoordinates(clientPos)
const windowToViewportCoordinates = this.viewer.viewport.windowToViewportCoordinates(clientPos)
const click = {
x: clientPos.x,
y: clientPos.y,
shift: e.shift
}
console.log('clicked page', click)
// console.log('unrotated imagePoint ', imagePoint, rotatePoint(imagePoint, center, counterRotate))
// console.log('unrotated viewerPoint ', viewerPoint, rotatePoint(viewerPoint, center, counterRotate))
// console.log('unrotated viewPoint ', viewPoint, rotatePoint(viewPoint, center, counterRotate))
// console.log('unrotated pointFromPixel ', pointFromPixel, rotatePoint(pointFromPixel, center, counterRotate))
// console.log('pointFromPixelNoRotate', pointFromPixelNoRotate)
// console.log('windowToImageCoordinates ', windowToImageCoordinates, rotatePoint(windowToImageCoordinates, center, counterRotate))
console.log('windowToViewportCoordinates ', windowToViewportCoordinates, rotatePoint(windowToViewportCoordinates, center, counterRotate), windowToViewportCoordinates.rotate(counterRotate, center))
*/
// console.log(e)
// this.$store.dispatch('facsimileClick', click)
},
/**
Expand Down
196 changes: 196 additions & 0 deletions src/components/shared/ContextMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<template>
<div class="contextMenuBack" v-if="visible" @click="close">
<div class="contextMenu" :style="{ top, left }">
<div class="item level1" :class="{ disabled: item.disabled, activated: this.level1 === n }" v-for="(item, n) in contextMenu.items" :key="n" @click="callback(item)" @mouseenter="setLevel1(n)">
{{ item.label }}
<span class="childMenu" v-if="item.items" style="float: right">❯</span>
</div>
<div class="contextMenu level2" v-if="level2visible" :style="{ top: secondTop, left: secondLeft }">
<div class="item" :class="{ disabled: subItem.disabled, activated: this.level2 === m }" v-for="(subItem, m) in level2items" :key="m" @click="callback(subItem)" @mouseenter="setLevel2(m)">
{{ subItem.label }}
</div>
</div>
</div>
</div>
</template>

<script>
// import { mapGetters } from 'vuex'
export default {
name: 'ContextMenu',
props: {
},
components: {
},
data: () => ({
level1: 0,
level2: -1,
level3: -1,
currentLevel: 1
}),
methods: {
close () {
this.setLevel1(0)
this.setLevel2(-1)
this.setLevel3(-1)
this.$store.dispatch('closeContextMenu')
},
callback (item) {
// console.log('callback: ', item)
if (typeof item.action === 'function' && !item.disabled && !item.items) {
this.$store.dispatch('closeContextMenu')
item.action()
}
},
setLevel1 (n) {
this.level1 = n
this.level2 = -1
this.level3 = -1
},
setLevel2 (n) {
this.level2 = n
this.level3 = -1
},
setLevel3 (n) {
this.level3 = n
},
onKeyDown (e) {
if (!this.visible) {
return
}
e.preventDefault()
e.stopPropagation()
if (e.key === 'Escape') {
this.$store.dispatch('closeContextMenu')
}
if (e.key === 'ArrowDown') {
if (this.currentLevel === 1 && this.level1 + 1 < this.contextMenu.items.length) {
this.level1 = this.level1 + 1
}
}
if (e.key === 'ArrowUp') {
if (this.currentLevel === 1 && this.level1 > 0) {
this.level1 = this.level1 - 1
}
}
}
},
mounted () {
window.addEventListener('keydown', this.onKeyDown)
},
beforeUnmount () {
window.removeEventListener('keydown', this.onKeyDown)
},
computed: {
visible () {
return this.$store.getters.contextMenuVisible
},
contextMenu () {
return this.$store.getters.contextMenu
},
level2visible () {
return this.contextMenu?.items[this.level1]?.items
},
level2items () {
return this.contextMenu?.items[this.level1]?.items
},
left () {
let x = this.contextMenu?.pos?.x
if (!x) {
x = 10
}
x = x + 10
if (x + 300 > window.innerWidth) {
x = x - 320
}
return x + 'px'
},
top () {
return this.contextMenu?.pos?.y + 'px'
},
secondLeft () {
let x = parseInt(this.left)
if (parseInt(x + 300 + 295) > window.innerWidth) {
x = -295
} else {
x = 295
}
return x + 'px'
},
secondTop () {
const cm = document.querySelector('.contextMenu')
const act = document.querySelectorAll('.contextMenu .item.level1')[this.level1]
const yBase = cm.getBoundingClientRect().top
const y = act.getBoundingClientRect().top - yBase - 5
return y + 'px'
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
@import '@/css/_variables.scss';
.contextMenuBack {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 999;
// background-color: rgba(150, 0, 0, 0.5);
}
.contextMenu {
position: absolute;
z-index: 1000;
background-color: transparentize(lighten($mainBackgroundColor, .5%), .2);
border: .5px solid #888888;
border-radius: .4rem;
box-shadow: 0 .3rem .8rem rgba(0, 0, 0, 0.5);
padding: 5px 5px;
width: 300px;
backdrop-filter: blur(10px);
.level2 {
position: absolute;
left: -330px;
top: 0;
}
.item {
padding: 3px 10px;
font-size: .7rem;
font-weight: 500;
cursor: pointer;
text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
&.activated {
background-color: darken($activeHighlightColor, 10%);
border-radius: .2rem;
color: #ffffff;
text-shadow: unset;
}
&.disabled {
color: #999999;
cursor: not-allowed;
&:hover {
background-color: unset;
}
}
.childMenu {
font-weight: 900;
}
}
}
</style>
5 changes: 3 additions & 2 deletions src/store/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1504,12 +1504,13 @@ const dataModule = {
console.log('diploTranscribe_setShapes', annotElem, shapes)

const atDoc = getters.annotatedTranscriptForCurrentWz
// const dtDoc = getters.diplomaticTranscriptForCurrentWz.cloneNode(true)
const dtDoc = getters.diplomaticTranscriptForCurrentWz.cloneNode(true)

const atElem = atDoc.querySelector(annotElem.name + '[*|id="' + annotElem.id + '"]')
const corresp = atElem.getAttribute('corresp')

console.log('searching for corresponding element in diplomatic transcript: ' + corresp)
const dtElem = dtDoc.querySelector('*[*|id="' + corresp.split('#')[1] + '"]')
console.log('searching for corresponding element in diplomatic transcript: ' + corresp + ', found this:\n', dtElem)
},

modifyXml ({ commit, getters, state, dispatch }, { filePath, id, val }) {
Expand Down
Loading

0 comments on commit 1758b66

Please sign in to comment.