@@ -28,6 +28,7 @@ function calculateImageScale() {
28
28
let gImageId ;
29
29
let gImageSet ;
30
30
let gImageSetId ;
31
+ let gCurrentAnnotations ;
31
32
let gImageCache = { } ;
32
33
let gAnnotationId ; // the selected annotation
33
34
let tool ;
@@ -92,16 +93,18 @@ function calculateImageScale() {
92
93
} )
93
94
}
94
95
95
- function loadSingleAnnotation ( id , fromHistory ) {
96
+ function loadImageAnnotations ( annotation , fromHistory ) {
96
97
let params = {
97
- annotation_id : id ,
98
+ image_id : annotation . image . id ,
99
+ annotation_type_id : annotation . annotation_type ,
98
100
} ;
99
- $ . ajax ( API_ANNOTATIONS_BASE_URL + 'annotation/loadone /?' + $ . param ( params ) , {
101
+ $ . ajax ( API_ANNOTATIONS_BASE_URL + 'annotation/loadmultiple /?' + $ . param ( params ) , {
100
102
type : 'GET' ,
101
103
headers : gHeaders ,
102
104
dataType : 'json' ,
103
105
success : function ( data ) {
104
- continueLoadAnnotationView ( data . annotation , fromHistory ) ;
106
+ gCurrentAnnotations = data . annotation ;
107
+ continueLoadAnnotationView ( annotation . id , fromHistory ) ;
105
108
} ,
106
109
error : function ( ) {
107
110
displayFeedback ( $ ( '#feedback_connection_error' ) )
@@ -130,7 +133,7 @@ function calculateImageScale() {
130
133
if ( state ) {
131
134
strState = 'accept' ;
132
135
}
133
- let annotation = gAnnotationList . filter ( function ( e ) {
136
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
134
137
return e . id === id ;
135
138
} ) [ 0 ] ;
136
139
annotation . verified_by_user = true ;
@@ -324,11 +327,9 @@ function calculateImageScale() {
324
327
annotationIndex += offset ;
325
328
if ( annotationIndex < 0 ) {
326
329
displayFeedback ( $ ( '#feedback_last_annotation' ) ) ;
327
- drawAnnotation ( gAnnotationList [ 0 ] ) ;
328
330
return ;
329
331
} else if ( annotationIndex >= annotationIndexList . length ) {
330
332
displayFeedback ( $ ( '#feedback_last_annotation' ) ) ;
331
- drawAnnotation ( gAnnotationList [ gAnnotationList . length - 1 ] ) ;
332
333
return ;
333
334
}
334
335
@@ -343,19 +344,22 @@ function calculateImageScale() {
343
344
*/
344
345
function loadAnnotationView ( annotationId , fromHistory ) {
345
346
gAnnotationId = annotationId ;
346
- let annotationNotInList = gAnnotationList . filter ( function ( e ) {
347
+ let annotation = gAnnotationList . filter ( function ( e ) {
347
348
return e . id === annotationId ;
348
- } ) . length === 0 ;
349
- if ( annotationNotInList ) {
349
+ } ) [ 0 ] ;
350
+ if ( ! annotation ) {
350
351
console . log (
351
352
'skipping request to load annotation ' + annotationId +
352
353
' as it is not in current annotation list.' ) ;
353
354
return ;
354
355
}
355
- loadSingleAnnotation ( annotationId , fromHistory ) ;
356
+ loadImageAnnotations ( annotation , fromHistory ) ;
356
357
}
357
358
358
- function continueLoadAnnotationView ( annotation , fromHistory ) {
359
+ function continueLoadAnnotationView ( annotation_id , fromHistory ) {
360
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
361
+ return e . id === annotation_id ;
362
+ } ) [ 0 ] ;
359
363
if ( annotation . verified_by_user ) {
360
364
displayFeedback ( $ ( '#feedback_already_verified' ) ) ;
361
365
}
@@ -396,18 +400,20 @@ function calculateImageScale() {
396
400
$ ( '#blurred_label' ) . hide ( )
397
401
}
398
402
$ ( '#blurred' ) . prop ( 'checked' , annotation . blurred ) ;
399
- drawAnnotation ( annotation ) ;
403
+ drawAnnotations ( gCurrentAnnotations , annotation . id ) ;
400
404
}
401
405
402
406
/**
403
- * Draw the annotation that should be verified
407
+ * Draw the annotations that should be verified
404
408
*
405
- * @param annotation
409
+ * @param annotations list of all annotation to draw
410
+ * @param current id of the current annotation
406
411
*/
407
- function drawAnnotation ( annotation ) {
412
+ function drawAnnotations ( annotations , current ) {
408
413
if ( tool ) {
409
414
tool . clear ( ) ;
410
415
}
416
+ let annotation = annotations [ 0 ] ;
411
417
if ( ! tool || tool . annotationTypeId !== annotation . annotation_type . id ||
412
418
( tool . vector_type === 5 && tool . node_count !== annotation . annotation_type . node_count ) ) {
413
419
switch ( annotation . annotation_type . vector_type ) {
@@ -425,18 +431,25 @@ function calculateImageScale() {
425
431
break ;
426
432
}
427
433
}
428
- let color = '#FF0000' ;
429
- if ( annotation . concealed ) {
430
- if ( annotation . blurred ) {
431
- color = '#5CB85C' ;
432
- } else {
433
- color = '#F0AD4E' ;
434
+ colors = [ ] ;
435
+ for ( let annotation of annotations ) {
436
+ let color = '#FF0000' ;
437
+ if ( annotation . concealed ) {
438
+ if ( annotation . blurred ) {
439
+ color = '#5CB85C' ;
440
+ } else {
441
+ color = '#F0AD4E' ;
442
+ }
434
443
}
444
+ else if ( annotation . blurred ) {
445
+ color = '#5BC0DE'
446
+ }
447
+ if ( annotation . id !== current ) {
448
+ color += '60' ; // some transparency
449
+ }
450
+ colors . push ( color ) ;
435
451
}
436
- else if ( annotation . blurred ) {
437
- color = '#5BC0DE'
438
- }
439
- tool . drawExistingAnnotations ( [ annotation ] , color ) ;
452
+ tool . drawExistingAnnotations ( annotations , colors ) ;
440
453
}
441
454
442
455
/**
@@ -515,7 +528,7 @@ function calculateImageScale() {
515
528
}
516
529
517
530
function handleConcealedChange ( ) {
518
- let annotation = gAnnotationList . filter ( function ( e ) {
531
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
519
532
return e . id === gAnnotationId ;
520
533
} ) [ 0 ] ;
521
534
annotation . concealed = $ ( '#concealed' ) . is ( ':checked' ) ;
@@ -524,12 +537,12 @@ function calculateImageScale() {
524
537
} else {
525
538
$ ( '#concealed_label' ) . hide ( )
526
539
}
527
- drawAnnotation ( annotation ) ;
540
+ drawAnnotations ( gCurrentAnnotations , annotation . id ) ;
528
541
apiBlurredConcealed ( ) ;
529
542
}
530
543
531
544
function handleBlurredChange ( ) {
532
- let annotation = gAnnotationList . filter ( function ( e ) {
545
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
533
546
return e . id === gAnnotationId ;
534
547
} ) [ 0 ] ;
535
548
annotation . blurred = $ ( '#blurred' ) . is ( ':checked' ) ;
@@ -538,12 +551,12 @@ function calculateImageScale() {
538
551
} else {
539
552
$ ( '#blurred_label' ) . hide ( )
540
553
}
541
- drawAnnotation ( annotation ) ;
554
+ drawAnnotations ( gCurrentAnnotations , annotation . id ) ;
542
555
apiBlurredConcealed ( ) ;
543
556
}
544
557
545
558
function apiBlurredConcealed ( ) {
546
- let annotation = gAnnotationList . filter ( function ( e ) {
559
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
547
560
return e . id === gAnnotationId ;
548
561
} ) [ 0 ] ;
549
562
let data = {
0 commit comments