Skip to content

Commit

Permalink
Some AAM refactoring #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Sekachev committed Oct 15, 2018
1 parent 1458d40 commit 53888e3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
10 changes: 2 additions & 8 deletions cvat/apps/engine/static/engine/js/attributeAnnotationMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
}
}

Expand Down
14 changes: 4 additions & 10 deletions cvat/apps/engine/static/engine/js/shapeCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ class ShapeCollectionModel extends Listener {
}

if (this._activeAAMShape) {
this._activeAAMShape.activeAAM = {
shape: false,
attribute: null
};
this._activeAAMShape.activeAttribute = null;
}

this._currentShapes = [];
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down
25 changes: 12 additions & 13 deletions cvat/apps/engine/static/engine/js/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 53888e3

Please sign in to comment.