Skip to content

Commit a332ca1

Browse files
committed
[Editor] Various bug fixes
1 parent 4a9497c commit a332ca1

File tree

11 files changed

+48
-38
lines changed

11 files changed

+48
-38
lines changed

notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@
5555
- [X] survey export -- TODO: Testing
5656
- [X] on index errors open parser settings panel
5757
- [X] How to get reader id for one file per reader import scheme for fixations?
58+
59+
http://localhost:8081/login?magic=JTdCJTIydXNlcm5hbWUlMjIlM0ElMjJCcmlza1NlYWwyMDklMjIlMkMlMjJwYXNzd29yZCUyMiUzQSUyMiUzRE9Ccy03cEIlMjIlN0Q=

src/editor/EditorComponent.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<script setup lang="ts">
22
import '../scss/components/tour.scss';
3+
import {
4+
type Ref,
5+
ref
6+
} from 'vue';
7+
import {
8+
VTour,
9+
type VTourExposedMethods
10+
} from '@globalhive/vuejs-tour';
311
import AnnotationCompletion from './components/AnnotationCompletion.vue';
412
import EditorView from './components/EditorView.vue';
513
import PageTour from './tour/PageTour.vue';
614
import SidePane from './components/SidePane.vue';
7-
import {
8-
VTour
9-
} from '@globalhive/vuejs-tour';
1015
import {
1116
useAnnotationNavigation
1217
} from './composables/useAnnotationNavigation';
@@ -18,11 +23,12 @@
1823
const {
1924
goToNextAnnotation, isAnnotationComplete
2025
} = useAnnotationNavigation();
26+
const tour: Ref<VTourExposedMethods | null> = ref( null );
2127
const {
2228
steps,
2329
showWelcomeTour,
2430
startFullTour
25-
} = useEditorTour();
31+
} = useEditorTour( tour );
2632
2733
</script>
2834

src/editor/io/mouse.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
} from '../data';
1111
import {
1212
canvasToOriginalCoordinates,
13-
scaleInverse
13+
scaleInverse,
14+
scalingFactor
1415
} from '../render/scaling';
1516
import {
1617
isMouseDragging,
@@ -35,8 +36,6 @@ export const mouseHandler = ( target: Ref<HTMLElement | null> ) => {
3536
let rect: DOMRect = new DOMRect( 0, 0, 0, 0 );
3637

3738
const mouseDownHandler = ( ev: MouseEvent ) => {
38-
updateRect();
39-
4039
if ( ev.ctrlKey )
4140
zoomPanStartHandler( ev );
4241
else if ( ev.button === 0 ) {
@@ -49,8 +48,6 @@ export const mouseHandler = ( target: Ref<HTMLElement | null> ) => {
4948
};
5049

5150
const mouseUpHandler = ( ev: MouseEvent ) => {
52-
updateRect();
53-
5451
if ( ev.button === 0 ) {
5552
isMouseDragging.value = false;
5653
isZoomDragging.value = false;
@@ -134,7 +131,10 @@ export const mouseHandler = ( target: Ref<HTMLElement | null> ) => {
134131
} catch { /* empty */ }
135132
} );
136133

137-
watch( canvasSize, updateRect );
134+
watch( [
135+
canvasSize,
136+
scalingFactor
137+
], updateRect );
138138
watch( isSideBarCollapsed, () => {
139139
setTimeout( () => {
140140
updateRect();

src/editor/loaders/backend.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ export const loadEditorDataFromBackend = async ( renderer: Renderer ) => {
4747

4848
fixations.value = [];
4949
fix.forEach( f => {
50-
const isInavlid = sessionData.value.removedFixations?.includes( f.id! ) ?? false;
50+
const isInvalid = sessionData.value.removedFixations?.includes( f.id! ) ?? false;
5151

5252
fixations.value.push( {
5353
'x': f.x!,
5454
'y': f.y!,
5555
'id': f.id!,
56-
'assigned': isInavlid ? 'invalid' : 'unassigned',
56+
'assigned': isInvalid ? 'invalid' : 'unassigned',
5757
'disagreement': f.disagreement
5858
} );
5959
} );
@@ -106,15 +106,18 @@ export const loadEditorDataFromBackend = async ( renderer: Renderer ) => {
106106

107107
algos.forEach( algo => {
108108
const details = additionalAnnotationLoad[ algo ]! as AnnotationDto;
109-
const ann: EditorAnnotation = {
110-
'fixationIdx': getFixIdxFromId( details.fixation!.id! ),
111-
'boxIdx': getBoxIdxFromId( details.characterBoundingBox!.id! ),
112-
'algorithm': algo
113-
};
114109

115-
fixations.value[ ann.fixationIdx ]!.assigned = details.annotationType === 'ANNOTATED' ? 'assigned' : 'machine';
110+
if ( details.fixation && details.characterBoundingBox ) {
111+
const ann: EditorAnnotation = {
112+
'fixationIdx': getFixIdxFromId( details.fixation!.id! ),
113+
'boxIdx': getBoxIdxFromId( details.characterBoundingBox!.id! ),
114+
'algorithm': algo
115+
};
116116

117-
annotations.value.push( ann );
117+
fixations.value[ ann.fixationIdx ]!.assigned = details.annotationType === 'ANNOTATED' ? 'assigned' : 'machine';
118+
119+
annotations.value.push( ann );
120+
}
118121
} );
119122
}
120123

src/editor/manager/annotations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const annotationManager = ( renderer: Renderer ): AnnotationManager => {
3939
'boxIdx': boundingBoxIndex
4040
};
4141

42+
// Try to delete by fix id
4243
deleteByFixID( annotation.fixationIdx );
4344

4445
annotations.value.push( annotation );

src/editor/manager/boxes.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
} from '../render/manager';
2323

2424
let previousIdx = -1;
25+
let previouslyRendered = false;
2526

2627
export const boxHighlightHandler = ( renderer: Renderer ) => {
2728
return ( pos: EditorPoint, highlightCurrent: boolean ) => {
@@ -36,7 +37,7 @@ export const boxHighlightHandler = ( renderer: Renderer ) => {
3637
setHighlightClass( previousIdx, 'none' );
3738
}
3839
} else {
39-
if ( idx !== previousIdx ) {
40+
if ( idx !== previousIdx || ( !previouslyRendered && highlightCurrent ) ) {
4041
needToRedraw = true;
4142

4243
if ( previousIdx > -1 )
@@ -46,8 +47,11 @@ export const boxHighlightHandler = ( renderer: Renderer ) => {
4647
}
4748

4849
if ( highlightCurrent === false ) {
50+
previouslyRendered = false;
4951
setHighlightClass( idx, 'none' );
5052
needToRedraw = true;
53+
} else {
54+
previouslyRendered = true;
5155
}
5256
}
5357

src/editor/manager/click.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import {
1010
isMouseDragging,
1111
lineStart,
12+
mouseDragEnd,
1213
mousePos
1314
} from '../data/io';
1415
import type {
@@ -57,15 +58,14 @@ export const mouseClickHandler = ( renderer: Renderer ) => {
5758

5859
renderer.renderIO.render();
5960
} else {
60-
if ( distanceBetweenPoints( {
61+
const distance = distanceBetweenPoints( {
6162
'x': fixations.value[ selectedFixation.value ]!.x!,
6263
'y': fixations.value[ selectedFixation.value ]!.y!
63-
}, mousePos.value ) > fixationRadius.value ) {
64-
// Get bounding box that was hovered at mouseUp
65-
const bb = getBoxIdFromCoordinate( mousePos.value );
64+
}, mouseDragEnd.value );
6665

67-
// Try to delete the annotation if it was present
68-
annotation.deleteByFixID( selectedFixation.value );
66+
if ( distance > fixationRadius.value ) {
67+
// Get bounding box that was hovered at mouseUp
68+
const bb = getBoxIdFromCoordinate( mousePos.value );
6969

7070
annotation.create( bb, selectedFixation.value );
7171
}

src/editor/render/scaling.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ export const useScaler = ( elementToGetParentFrom: Ref<HTMLElement | null>, rend
9595
canvasPosition
9696
], renderer.renderAll );
9797

98-
const observer = new ResizeObserver( () => {
99-
console.log( 'scaling' );
100-
scaler();
101-
} );
98+
const observer = new ResizeObserver( scaler );
10299

103100
onMounted( () => {
104101
target = elementToGetParentFrom.value!.parentElement!;

src/editor/tour/PageTour.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<script setup lang="ts">
32
import {
43
isSideBarCollapsed
@@ -10,8 +9,6 @@
109
};
1110
1211
const show = defineModel<boolean>();
13-
14-
show.value = true;
1512
const emit = defineEmits<{
1613
( e: 'launch-tour' ): void
1714
}>();

src/editor/tour/editorTour.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {
99
// TODO: To change theme, follow this guide: https://globalhive.github.io/vuejs-tour/guide/css-theme.html
1010

1111

12-
export const useEditorTour = () => {
13-
const tour: Ref<VTourExposedMethods | null> = ref( null );
12+
export const useEditorTour = ( tour: Ref<VTourExposedMethods | null> ) => {
1413
const showWelcomeTour = ref( !localStorage.getItem( 'welcomeTourViewed' ) );
1514
const steps: ITourStep[] = [
1615
{
@@ -72,13 +71,14 @@ export const useEditorTour = () => {
7271
tour.value.startTour();
7372
localStorage.setItem( 'welcomeTourViewed', 'true' );
7473
showWelcomeTour.value = false;
74+
} else {
75+
console.log( 'Tour element missing' );
7576
}
7677
};
7778

7879
return {
79-
tour,
8080
steps,
8181
showWelcomeTour,
8282
startFullTour
8383
};
84-
};
84+
};

0 commit comments

Comments
 (0)