From 53888e3cc6595c966268e060c26d5901e496bdd5 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Wed, 26 Sep 2018 14:32:11 +0300 Subject: [PATCH] Some AAM refactoring #1 --- .../engine/js/attributeAnnotationMode.js | 10 ++------ .../static/engine/js/shapeCollection.js | 14 +++-------- cvat/apps/engine/static/engine/js/shapes.js | 25 +++++++++---------- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/cvat/apps/engine/static/engine/js/attributeAnnotationMode.js b/cvat/apps/engine/static/engine/js/attributeAnnotationMode.js index e0e8d6cc9f5..e425229f149 100644 --- a/cvat/apps/engine/static/engine/js/attributeAnnotationMode.js +++ b/cvat/apps/engine/static/engine/js/attributeAnnotationMode.js @@ -121,10 +121,7 @@ class AAMModel extends Listener { let [xtl, ytl, xbr, ybr] = this._bbRect(this._currentShapes[this._activeIdx].interpolation.position); this._focus(xtl - this._margin, xbr + this._margin, ytl - this._margin, ybr + this._margin); - this._active.activeAAM = { - shape: true, - attribute: attrId, - }; + this._active.activeAttribute = attrId; this.notify(); @@ -139,10 +136,7 @@ class AAMModel extends Listener { _deactivate() { if (this._activeAAM && this._active) { - this._active.activeAAM = { - shape: false, - attribute: null - }; + this._active.activeAttribute = null; } } diff --git a/cvat/apps/engine/static/engine/js/shapeCollection.js b/cvat/apps/engine/static/engine/js/shapeCollection.js index 7f6416f866d..1f1121c0bf8 100644 --- a/cvat/apps/engine/static/engine/js/shapeCollection.js +++ b/cvat/apps/engine/static/engine/js/shapeCollection.js @@ -101,10 +101,7 @@ class ShapeCollectionModel extends Listener { } if (this._activeAAMShape) { - this._activeAAMShape.activeAAM = { - shape: false, - attribute: null - }; + this._activeAAMShape.activeAttribute = null; } this._currentShapes = []; @@ -487,10 +484,7 @@ class ShapeCollectionModel extends Listener { this._activeShape = null; } if (this._activeAAMShape) { - this._activeAAMShape.activeAAM = { - shape: false, - attribute: null, - }; + this._activeAAMShape.activeAttribute = null; } this._frame = frame; this._interpolate(); @@ -503,8 +497,8 @@ class ShapeCollectionModel extends Listener { onShapeUpdate(model) { switch (model.updateReason) { - case 'activeAAM': - if (model.activeAAM.shape) { + case 'activeAttribute': + if (model.activeAttribute != null) { this._activeAAMShape = model; } else if (this._activeAAMShape === model) { diff --git a/cvat/apps/engine/static/engine/js/shapes.js b/cvat/apps/engine/static/engine/js/shapes.js index 667cf97bbbd..587f5223d03 100644 --- a/cvat/apps/engine/static/engine/js/shapes.js +++ b/cvat/apps/engine/static/engine/js/shapes.js @@ -31,8 +31,7 @@ class ShapeModel extends Listener { this._merging = false; this._active = false; this._selected = false; - this._activeAAM = false; - this._activeAAMAttributeId = null; + this._activeAttributeId = null; this._merge = false; this._hiddenShape = false; this._hiddenText = true; @@ -524,17 +523,14 @@ class ShapeModel extends Listener { return this._active; } - set activeAAM(active) { - this._activeAAM = active.shape; - this._activeAAMAttributeId = active.attribute; - this.notify('activeAAM'); + set activeAttribute(value) { + this._activeAttributeId = value; + this._updateReason = 'activeAttribute'; + this.notify(); } - get activeAAM() { - return { - shape: this._activeAAM, - attributeId: this._activeAAMAttributeId - }; + get activeAttribute() { + return this._activeAttributeId; } set merge(value) { @@ -2438,7 +2434,10 @@ class ShapeView extends Listener { let interpolation = model.interpolate(window.cvat.player.frames.current); let hiddenText = model.hiddenText; let hiddenShape = model.hiddenShape; - let activeAAM = model.activeAAM; + let activeAAM = { + attributeId: model.activeAttribute, + shape: model.activeAttribute === null ? false : true, + } this._makeNotEditable(); this._deselect(); @@ -2516,7 +2515,7 @@ class ShapeView extends Listener { this._uis.attributes[attrId].select(); break; } - case 'activeAAM': + case 'activeAttribute': this._setupAAMView(activeAAM.shape, interpolation.position); setupHidden.call(this, hiddenShape, hiddenText, activeAAM, model.active, interpolation);