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 Sep 26, 2018
1 parent 4d295df commit 4196ad3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 34 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 @@ -118,10 +118,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 @@ -136,10 +133,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 @@ -99,10 +99,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 @@ -438,10 +435,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 @@ -454,8 +448,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
38 changes: 22 additions & 16 deletions cvat/apps/engine/static/engine/js/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,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 @@ -522,18 +521,14 @@ class ShapeModel extends Listener {
return this._active;
}

set activeAAM(active) {
this._activeAAM = active.shape;
this._activeAAMAttributeId = active.attribute;
this._updateReason = '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 +2433,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 @@ -2512,7 +2510,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 Expand Up @@ -2862,12 +2860,18 @@ class PolyShapeView extends ShapeView {
this._hideShapeText();
}
this._uis.shape.addClass('hidden');
if (this._uis.points) {
this._uis.points.addClass('hidden');
}

// Run edit mode
PolyShapeView.editor.edit(this._controller.type.split('_')[1],
this._uis.shape.attr('points'), this._color, index, e,
(points) => {
this._uis.shape.removeClass('hidden');
if (this._uis.points) {
this._uis.points.removeClass('hidden');
}
if (points) {
this._uis.shape.attr('points', points);
this._controller.updatePosition(window.cvat.player.frames.current, this._buildPosition());
Expand Down Expand Up @@ -3081,9 +3085,11 @@ class PointsView extends PolyShapeView {

_makeNotEditable() {
PolyShapeView.prototype._makeNotEditable.call(this);
let interpolation = this._controller.interpolate(window.cvat.player.frames.current);
if (interpolation.position.points) {
this._drawPointMarkers(interpolation.position);
if (!this._controller.hiddenShape) {
let interpolation = this._controller.interpolate(window.cvat.player.frames.current);
if (interpolation.position.points) {
this._drawPointMarkers(interpolation.position);
}
}
}

Expand Down

0 comments on commit 4196ad3

Please sign in to comment.