Skip to content

Commit

Permalink
Fix usage of '_trackDb', closes #44.
Browse files Browse the repository at this point in the history
  • Loading branch information
bctcvai committed Mar 6, 2023
1 parent bfc572f commit ee78ca0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions ui/src/js/annotation/annotation-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ export class AnnotationBrowser extends TatorElement {

// Find the associated track if the given object is a localization
var associatedState = null;
if (objDataType.isLocalization && obj.id in this._data._trackDb)
if (objDataType.isLocalization && this._data._trackDb.has(obj.id))
{
associatedState = this._data._trackDb[obj.id];
associatedState = this._data._trackDb.get(obj.id);
}

// This variable can be changed in the future if there's a project setting to
Expand Down
4 changes: 2 additions & 2 deletions ui/src/js/annotation/entity-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,9 @@ export class EntitySelector extends TatorElement {
const isLocalization = data.type.includes("box") || data.type.includes("line") || data.type.includes("dot");
if (isLocalization)
{
if (data.id in this._globalData._trackDb)
if (this._globalData._trackDb.has(data.id))
{
associatedState = this._globalData._trackDb[data.id];
associatedState = this._globalData._trackDb.get(data.id);
associatedStateType = this._globalData._dataTypes[associatedState.type];
}
}
Expand Down
28 changes: 14 additions & 14 deletions ui/src/js/annotator/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1318,9 +1318,9 @@ export class AnnotationCanvas extends TatorElement
// the active track.
// Handle case when localization is in a track
if (this.activeLocalization) {
if (this.activeLocalization.id in this._data._trackDb)
if (this._data._trackDb.has(this.activeLocalization.id))
{
const track = this._data._trackDb[this.activeLocalization.id];
const track = this._data._trackDb.get(this.activeLocalization.id);
this._activeTrack = track;
this._activeTrackFrame = this.currentFrame();
}
Expand Down Expand Up @@ -1739,7 +1739,7 @@ export class AnnotationCanvas extends TatorElement
});
evt.detail.data.forEach(track => {
track.localizations.forEach(localId => {
this._data._trackDb[localId] = track;
this._data._trackDb.set(localId,track);
});

if (track.color == null) {
Expand Down Expand Up @@ -1773,7 +1773,7 @@ export class AnnotationCanvas extends TatorElement

// Determine if the user right clicked on a state/track or a stand-alone localization/detection
if (this.activeLocalization) {
let localizationInTrack = this.activeLocalization.id in this._data._trackDb;
let localizationInTrack = this._data._trackDb.has(this.activeLocalization.id);
if (localizationInTrack) {
this._contextMenuTrack.displayMenu(clickLocation[0], clickLocation[1]);
}
Expand Down Expand Up @@ -2168,9 +2168,9 @@ export class AnnotationCanvas extends TatorElement
};

let localizationMatchesActiveTrack = this._activeTrack && this._activeTrack.localizations.includes(localization.id);
let localizationInTrack = localization.id in this._data._trackDb;
let localizationInTrack = this._data._trackDb.has(localization.id);

if (localization.id in this._data._trackDb)
if (this._data._trackDb.has(localization.id))
{
if (localizationMatchesActiveTrack)
{
Expand All @@ -2180,7 +2180,7 @@ export class AnnotationCanvas extends TatorElement
}
else
{
trackColor = this._data._trackDb[localization.id].color;
trackColor = this._data._trackDb.get(localization.id).color;
}
if (trackColor)
{
Expand All @@ -2193,7 +2193,7 @@ export class AnnotationCanvas extends TatorElement
{
if (localizationInTrack)
{
colorMap(this._data._trackDb[localization.id].attributes, true);
colorMap(this._data._trackDb.get(localization.id).attributes, true);
}
else
{
Expand Down Expand Up @@ -2983,9 +2983,9 @@ export class AnnotationCanvas extends TatorElement
});
}
// Handle case when localization is in a track
if (localization.id in this._data._trackDb)
if (this._data._trackDb.has(localization.id))
{
const track = this._data._trackDb[localization.id];
const track = this._data._trackDb.get(localization.id);
this._activeTrack = track
this._activeTrackFrame = this.currentFrame();
}
Expand Down Expand Up @@ -3044,8 +3044,8 @@ export class AnnotationCanvas extends TatorElement
this._data._dataByType.forEach((value, key, map) => {
if (key != track.type) {
for (const localization of value) {
if (localization.id in this._data._trackDb) {
const sameId = this._data._trackDb[localization.id].id == track.id;
if (this._data._trackDb.has(localization.id )) {
const sameId = this._data._trackDb.get(localization.id).id == track.id;
const firstFrame = localization.frame == frame;
if (sameId && firstFrame) {
this.selectLocalization(localization, true);
Expand Down Expand Up @@ -3119,9 +3119,9 @@ export class AnnotationCanvas extends TatorElement
this._draw.drawCircle(center, dotWidth/2, drawColor);
}
// Handle case when localization is in a track
if (localization.id in this._data._trackDb)
if (this._data._trackDb.has(localization.id))
{
const track = this._data._trackDb[localization.id];
const track = this._data._trackDb.get(localization.id);
this._activeTrack = track
this._activeTrackFrame = this.currentFrame();
}
Expand Down

0 comments on commit ee78ca0

Please sign in to comment.