Skip to content

Commit

Permalink
Merge pull request #525 from Tom-TBT/inherit_annotation
Browse files Browse the repository at this point in the history
Annotation inheritance support
  • Loading branch information
will-moore authored Feb 19, 2024
2 parents 8757082 + d4bbc2e commit e87afd1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/js/models/panel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
else if (property === "h") property = "height";
else if (property === "rot") property = "rotation";


var x_symbol = this.get('pixel_size_x_symbol'),
z_symbol = this.get('pixel_size_z_symbol');
z_symbol = z_symbol ? z_symbol : x_symbol // Using x symbol when z not defined
Expand Down Expand Up @@ -1030,9 +1030,22 @@
var image_ids = this.map(function(s){return s.get('imageId')})
image_ids = "image=" + image_ids.join("&image=");
// TODO: Use /api/ when annotations is supported
var url = WEBINDEX_URL + "api/annotations/?type=tag&limit=1000&" + image_ids;
var url = WEBINDEX_URL + "api/annotations/?type=tag&parents=true&limit=1000&" + image_ids;
$.getJSON(url, function(data){
// Map {iid: {id: 'tag'}, {id: 'names'}}
if (data.hasOwnProperty('parents')){
data.parents.annotations.forEach(function(ann) {
let class_ = ann.link.parent.class;
let id_ = '' + ann.link.parent.id;
let lineage = data.parents.lineage[class_][id_];
for(j = 0; j < lineage.length; j++){
// Unpacking the parent annoations for each image
let clone_ann = JSON.parse(JSON.stringify(ann));
clone_ann.link.parent.id = lineage[j].id;
data.annotations.push(clone_ann);
}
});
}
var imageTags = data.annotations.reduce(function(prev, t){
var iid = t.link.parent.id;
if (!prev[iid]) {
Expand Down
17 changes: 15 additions & 2 deletions src/js/views/labels_from_maps_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,23 @@ var LabelFromMapsModal = Backbone.View.extend({
this.isLoading = true;
$('select', this.el).html("<option>Loading data...</option>");

var url = WEBINDEX_URL + "api/annotations/?type=map&image=";
var url = WEBINDEX_URL + "api/annotations/?type=map&parents=true&image=";
url += imageIds.join("&image=");

$.getJSON(url, function(data) {
if (data.hasOwnProperty('parents')){
data.parents.annotations.forEach(function(ann) {
let class_ = ann.link.parent.class;
let id_ = '' + ann.link.parent.id;
let lineage = data.parents.lineage[class_][id_];
for(j = 0; j < lineage.length; j++){
// Unpacking the parent annoations for each image
let clone_ann = JSON.parse(JSON.stringify(ann));
clone_ann.link.parent.id = lineage[j].id;
data.annotations.push(clone_ann);
}
});
}
this.isLoading = false;
this.annotations = data.annotations;
this.render();
Expand Down Expand Up @@ -155,7 +168,7 @@ var LabelFromMapsModal = Backbone.View.extend({
}
}
keyList.sort(function(a, b) {
return (a.toUpperCase() < b.toUpperCase()) ? -1 : 1;
return (a.toUpperCase() < b.toUpperCase()) ? -1 : 1;
});

var html = keyList.map(function(key) {
Expand Down

0 comments on commit e87afd1

Please sign in to comment.