Skip to content

Commit bf90148

Browse files
committed
[Editor] Many changes, see desc
- Pre Annotations filtered by algorithm - Marking fixations as invalid - Various fixes
1 parent afed5fd commit bf90148

File tree

7 files changed

+66
-27
lines changed

7 files changed

+66
-27
lines changed

src/editor/data/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export const hoveredFixation = ref( -1 );
2727

2828
export const isSideBarCollapsed = ref( false );
2929

30+
export const algorithmsList: Ref<string[]> = ref( [] );
31+
32+
export const selectedAlgorithm = ref( -1 );
33+
3034
// ┌ ┐
3135
// │ Zoom utilities │
3236
// └ ┘

src/editor/manager/annotations.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const annotationManager = ( renderer: Renderer ): AnnotationManager => {
5656
for ( let i = 1; i < length; i++ ) {
5757
const nextIndex = ( fixationIndex + i ) % length;
5858

59-
if ( fixations.value[nextIndex]!.assigned !== 'assigned' ) {
59+
if ( fixations.value[nextIndex]!.assigned !== 'assigned' && fixations.value[nextIndex]!.assigned !== 'invalid' ) {
6060
selectedFixation.value = nextIndex;
6161
endOfAnnotations = false;
6262
break;
@@ -87,17 +87,19 @@ export const annotationManager = ( renderer: Renderer ): AnnotationManager => {
8787
const deleteByFixID = ( fixationId: number ) => {
8888
let idx = -1;
8989

90-
for ( let i = 0; i < annotations.value.length; i++ ) {
91-
if ( annotations.value[ i ]!.fixationId === fixationId ) {
92-
idx = i;
93-
break;
90+
if ( fixations.value[ fixationId ]!.assigned === 'assigned' ) {
91+
for ( let i = 0; i < annotations.value.length; i++ ) {
92+
if ( annotations.value[ i ]!.fixationId === fixationId ) {
93+
idx = i;
94+
break;
95+
}
9496
}
95-
}
9697

97-
if ( idx > -1 ) {
98-
const d = annotations.value.splice( idx, 1 );
98+
if ( idx > -1 ) {
99+
const d = annotations.value.splice( idx, 1 );
99100

100-
highlightBox( d[ 0 ]!.boxId, 3000 );
101+
highlightBox( d[ 0 ]!.boxId, 3000 );
102+
}
101103
}
102104
};
103105

@@ -116,14 +118,22 @@ export const annotationManager = ( renderer: Renderer ): AnnotationManager => {
116118
}
117119

118120
if ( idx > -1 ) {
119-
const d = annotations.value.splice( idx, 1 );
121+
if ( fixations.value[ annotations.value[ idx ]!.fixationId ]!.assigned === 'assigned' ) {
122+
const d = annotations.value.splice( idx, 1 );
120123

121-
highlightBox( d[ 0 ]!.boxId, 3000 );
124+
highlightBox( d[ 0 ]!.boxId, 3000 );
125+
}
122126
}
123127
};
124128

129+
const markAsInvalid = ( fixationIndex: number ) => {
130+
deleteByFixID( fixationIndex );
131+
fixations.value[ fixationIndex ]!.assigned = 'invalid';
132+
};
133+
125134
const funcs: AnnotationManager = {
126135
create,
136+
markAsInvalid,
127137
deleteByFixID,
128138
deleteByBoxID
129139
};

src/editor/manager/zoom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const setFactor = ( factor: number ) => {
9797

9898
zoomFactor.value = Math.min( Math.max( factor, 1 ), 3 );
9999

100-
// TODO: If you want to do relative to mouse position,
100+
// NOTE: If you want to do relative to mouse position,
101101
// add a mouse position in here and use setViewPortOriginFromCenter
102102
setViewPortOrigin( getViewPortOrigin() );
103103
};

src/editor/render/lines.ts

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import {
44
watch
55
} from 'vue';
66
import {
7+
algorithmsList,
78
annotations,
89
boundingBoxes,
910
canvasSize,
1011
fixations,
12+
selectedAlgorithm,
1113
selectedFixation
1214
} from '../data';
1315
import {
@@ -40,29 +42,20 @@ export const linesRenderer = ( linesCanvas: Ref<HTMLCanvasElement | null> ) => {
4042
// Render
4143
if ( linesDisplay.value === 'all' ) {
4244
annotations.value.forEach( l => {
43-
// TODO: Filter algorithm
44-
drawLine( l );
45+
filterAlgorithms( l, drawLine );
4546
} );
4647
} else if ( linesDisplay.value === 'previous' ) {
4748
if ( selectedFixation.value >= 0 )
4849
annotations.value.forEach( l => {
49-
// TODO: Filter algorithm
50-
if ( l.fixationId === selectedFixation.value )
51-
drawLine( l );
52-
else if ( l.fixationId === selectedFixation.value - 1 )
53-
drawLine( l );
50+
filterAlgorithms( l, previousDrawer );
5451
} );
5552
} else if ( linesDisplay.value === 'surrounding' ) {
5653
if ( selectedFixation.value >= 0 )
5754
annotations.value.forEach( l => {
58-
// TODO: Filter algorithm
59-
if ( l.fixationId > selectedFixation.value - numberOfLinesToRenderInSurroundingMode.value
60-
|| l.fixationId < selectedFixation.value + numberOfLinesToRenderInSurroundingMode.value )
61-
drawLine( l );
55+
filterAlgorithms( l, surroundingDrawer );
6256
} );
63-
64-
// TODO: Do we want more settings here?
6557
} else if ( linesDisplay.value === 'allalgos' ) {
58+
// TODO: Do we want more settings here?
6659
if ( selectedFixation.value >= 0 )
6760
annotations.value.forEach( l => {
6861
if ( l.fixationId === selectedFixation.value )
@@ -71,6 +64,36 @@ export const linesRenderer = ( linesCanvas: Ref<HTMLCanvasElement | null> ) => {
7164
}
7265
};
7366

67+
// TODO: Filter algorithm (also do not display if invalid fixation)
68+
const filterAlgorithms = ( l: EditorAnnotation, drawFunc: ( l: EditorAnnotation ) => void ) => {
69+
const assignType = fixations.value[ l.fixationId ]!.assigned;
70+
71+
if ( assignType === 'invalid' ) return;
72+
73+
if ( assignType === 'assigned' ) drawFunc( l );
74+
75+
if ( !l.algorithm ) {
76+
if ( selectedAlgorithm.value > -1 ) return;
77+
else drawFunc( l );
78+
} else {
79+
if ( l.algorithm === algorithmsList.value[ selectedAlgorithm.value ]! )
80+
drawFunc( l );
81+
}
82+
};
83+
84+
const previousDrawer = ( l: EditorAnnotation ) => {
85+
if ( l.fixationId === selectedFixation.value )
86+
drawLine( l );
87+
else if ( l.fixationId === selectedFixation.value - 1 )
88+
drawLine( l );
89+
};
90+
91+
const surroundingDrawer = ( l: EditorAnnotation ) => {
92+
if ( l.fixationId > selectedFixation.value - numberOfLinesToRenderInSurroundingMode.value
93+
|| l.fixationId < selectedFixation.value + numberOfLinesToRenderInSurroundingMode.value )
94+
drawLine( l );
95+
};
96+
7497
const drawLine = ( line: EditorAnnotation ) => {
7598
const fix = fixations.value[ line.fixationId ]!;
7699
const box = boundingBoxes.value[ line.boxId ]!;

src/editor/types/fixations.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import type {
33
} from '@/types/dtos/FixationDto';
44

55
export interface EditorFixation extends FixationDto {
6-
'assigned': 'assigned' | 'unassigned' | 'machine';
6+
'assigned': 'assigned' | 'unassigned' | 'machine' | 'invalid';
77
}

src/editor/types/history.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export interface HistoryEntry {
1010
export interface AnnotationManager {
1111
'deleteByFixID': ( fixationId: number ) => void;
1212
'deleteByBoxID': ( boxId: number ) => void;
13+
'markAsInvalid': ( fixationId: number ) => void;
1314
'create': ( boundingBoxIndex: number, fixationIndex: number, skipHistory?: boolean, highlight?: boolean ) => void;
1415
}

src/scss/util/_app-setup.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
}
2121

2222
/* Vue intra-page transitions */
23+
// TODO: Update transition config here, maybe add more options
2324
.scale-enter-active,
2425
.scale-leave-active {
2526
transition: all 0.5s ease;
@@ -33,7 +34,7 @@
3334

3435
.fade-enter-active,
3536
.fade-leave-active {
36-
transition: opacity 0.4s ease;
37+
transition: opacity 0.2s ease;
3738
}
3839

3940
.fade-enter-from,

0 commit comments

Comments
 (0)