@@ -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' ) )
@@ -147,7 +150,7 @@ function calculateImageScale() {
147
150
if ( state ) {
148
151
strState = 'accept' ;
149
152
}
150
- let annotation = gAnnotationList . filter ( function ( e ) {
153
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
151
154
return e . id === id ;
152
155
} ) [ 0 ] ;
153
156
annotation . verified_by_user = true ;
@@ -341,11 +344,9 @@ function calculateImageScale() {
341
344
annotationIndex += offset ;
342
345
if ( annotationIndex < 0 ) {
343
346
displayFeedback ( $ ( '#feedback_last_annotation' ) ) ;
344
- drawAnnotation ( gAnnotationList [ 0 ] ) ;
345
347
return ;
346
348
} else if ( annotationIndex >= annotationIndexList . length ) {
347
349
displayFeedback ( $ ( '#feedback_last_annotation' ) ) ;
348
- drawAnnotation ( gAnnotationList [ gAnnotationList . length - 1 ] ) ;
349
350
return ;
350
351
}
351
352
@@ -360,19 +361,22 @@ function calculateImageScale() {
360
361
*/
361
362
function loadAnnotationView ( annotationId , fromHistory ) {
362
363
gAnnotationId = annotationId ;
363
- let annotationNotInList = gAnnotationList . filter ( function ( e ) {
364
+ let annotation = gAnnotationList . filter ( function ( e ) {
364
365
return e . id === annotationId ;
365
- } ) . length === 0 ;
366
- if ( annotationNotInList ) {
366
+ } ) [ 0 ] ;
367
+ if ( ! annotation ) {
367
368
console . log (
368
369
'skipping request to load annotation ' + annotationId +
369
370
' as it is not in current annotation list.' ) ;
370
371
return ;
371
372
}
372
- loadSingleAnnotation ( annotationId , fromHistory ) ;
373
+ loadImageAnnotations ( annotation , fromHistory ) ;
373
374
}
374
375
375
- function continueLoadAnnotationView ( annotation , fromHistory ) {
376
+ function continueLoadAnnotationView ( annotation_id , fromHistory ) {
377
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
378
+ return e . id === annotation_id ;
379
+ } ) [ 0 ] ;
376
380
if ( annotation . verified_by_user ) {
377
381
displayFeedback ( $ ( '#feedback_already_verified' ) ) ;
378
382
}
@@ -413,18 +417,20 @@ function calculateImageScale() {
413
417
$ ( '#blurred_label' ) . hide ( )
414
418
}
415
419
$ ( '#blurred' ) . prop ( 'checked' , annotation . blurred ) ;
416
- drawAnnotation ( annotation ) ;
420
+ drawAnnotations ( gCurrentAnnotations , annotation . id ) ;
417
421
}
418
422
419
423
/**
420
- * Draw the annotation that should be verified
424
+ * Draw the annotations that should be verified
421
425
*
422
- * @param annotation
426
+ * @param annotations list of all annotation to draw
427
+ * @param current id of the current annotation
423
428
*/
424
- function drawAnnotation ( annotation ) {
429
+ function drawAnnotations ( annotations , current ) {
425
430
if ( tool ) {
426
431
tool . clear ( ) ;
427
432
}
433
+ let annotation = annotations [ 0 ] ;
428
434
if ( ! tool || tool . annotationTypeId !== annotation . annotation_type . id ||
429
435
( tool . vector_type === 5 && tool . node_count !== annotation . annotation_type . node_count ) ) {
430
436
switch ( annotation . annotation_type . vector_type ) {
@@ -442,18 +448,25 @@ function calculateImageScale() {
442
448
break ;
443
449
}
444
450
}
445
- let color = '#FF0000' ;
446
- if ( annotation . concealed ) {
447
- if ( annotation . blurred ) {
448
- color = '#5CB85C' ;
449
- } else {
450
- color = '#F0AD4E' ;
451
+ colors = [ ] ;
452
+ for ( let annotation of annotations ) {
453
+ let color = '#FF0000' ;
454
+ if ( annotation . concealed ) {
455
+ if ( annotation . blurred ) {
456
+ color = '#5CB85C' ;
457
+ } else {
458
+ color = '#F0AD4E' ;
459
+ }
451
460
}
461
+ else if ( annotation . blurred ) {
462
+ color = '#5BC0DE'
463
+ }
464
+ if ( annotation . id !== current ) {
465
+ color += '60' ; // some transparency
466
+ }
467
+ colors . push ( color ) ;
452
468
}
453
- else if ( annotation . blurred ) {
454
- color = '#5BC0DE'
455
- }
456
- tool . drawExistingAnnotations ( [ annotation ] , color ) ;
469
+ tool . drawExistingAnnotations ( annotations , colors ) ;
457
470
}
458
471
459
472
/**
@@ -532,7 +545,7 @@ function calculateImageScale() {
532
545
}
533
546
534
547
function handleConcealedChange ( ) {
535
- let annotation = gAnnotationList . filter ( function ( e ) {
548
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
536
549
return e . id === gAnnotationId ;
537
550
} ) [ 0 ] ;
538
551
annotation . concealed = $ ( '#concealed' ) . is ( ':checked' ) ;
@@ -541,12 +554,12 @@ function calculateImageScale() {
541
554
} else {
542
555
$ ( '#concealed_label' ) . hide ( )
543
556
}
544
- drawAnnotation ( annotation ) ;
557
+ drawAnnotations ( gCurrentAnnotations , annotation . id ) ;
545
558
apiBlurredConcealed ( ) ;
546
559
}
547
560
548
561
function handleBlurredChange ( ) {
549
- let annotation = gAnnotationList . filter ( function ( e ) {
562
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
550
563
return e . id === gAnnotationId ;
551
564
} ) [ 0 ] ;
552
565
annotation . blurred = $ ( '#blurred' ) . is ( ':checked' ) ;
@@ -555,12 +568,12 @@ function calculateImageScale() {
555
568
} else {
556
569
$ ( '#blurred_label' ) . hide ( )
557
570
}
558
- drawAnnotation ( annotation ) ;
571
+ drawAnnotations ( gCurrentAnnotations , annotation . id ) ;
559
572
apiBlurredConcealed ( ) ;
560
573
}
561
574
562
575
function apiBlurredConcealed ( ) {
563
- let annotation = gAnnotationList . filter ( function ( e ) {
576
+ let annotation = gCurrentAnnotations . filter ( function ( e ) {
564
577
return e . id === gAnnotationId ;
565
578
} ) [ 0 ] ;
566
579
let data = {
0 commit comments