Skip to content

Commit

Permalink
Some AAM refactoring #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Sekachev committed Sep 26, 2018
1 parent d485381 commit 2192e18
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions cvat/apps/engine/static/engine/js/shapeCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ShapeCollectionModel extends Listener {
this._groupIdx = 0;
this._frame = null;
this._activeShape = null;
this._activeAAMShape = null;
this._lastPos = {
x: 0,
y: 0,
Expand Down Expand Up @@ -95,11 +94,10 @@ class ShapeCollectionModel extends Listener {
this._z_order.min = 0;

if (this._activeShape) {
this._activeShape.active = false;
}

if (this._activeAAMShape) {
this._activeAAMShape.activeAttribute = null;
if (this._activeShape.activeAttribute != null) {
this._activeShape.activeAttribute = null;
}
this.resetActive();
}

this._currentShapes = [];
Expand Down Expand Up @@ -430,13 +428,14 @@ class ShapeCollectionModel extends Listener {

// If frame was not changed and collection already interpolated (for example after pause() call)
if (frame === this._frame && this._currentShapes.length) return;

if (this._activeShape) {
this._activeShape.active = false;
this._activeShape = null;
}
if (this._activeAAMShape) {
this._activeAAMShape.activeAttribute = null;
if (this._activeShape.activeAttribute != null) {
this._activeShape.activeAttribute = null;
}
this.resetActive();
}

this._frame = frame;
this._interpolate();
}
Expand All @@ -450,10 +449,23 @@ class ShapeCollectionModel extends Listener {
switch (model.updateReason) {
case 'activeAttribute':
if (model.activeAttribute != null) {
this._activeAAMShape = model;
if (this._activeShape && this._activeShape != model) {
if (this._activeShape.activeAttribute != null) {
this._activeShape.activeAttribute = null;
}
this.resetActive();
}
this._activeShape = model;
}
else if (this._activeAAMShape === model) {
this._activeAAMShape = null;
else if (this._activeShape) {
if (this._activeShape != model) {
throw Error('Unexpected behaviour. Variable _activeShape is obsolete');
}

if (this._activeShape.activeAttribute != null) {
this._activeShape.activeAttribute = null;
}
this.resetActive();
}
break;
case 'activation': {
Expand Down Expand Up @@ -589,8 +601,8 @@ class ShapeCollectionModel extends Listener {

switchActiveLock() {
let shape = null;
if (this._activeAAMShape) {
shape = this._activeAAMShape;
if (this._activeShape && this._activeShape.activeAttribute != null) {
shape = this._activeShape;
}
else {
this.selectShape(this._lastPos, false);
Expand Down Expand Up @@ -632,12 +644,12 @@ class ShapeCollectionModel extends Listener {

switchActiveOccluded() {
let shape = null;
if (this._activeAAMShape) {
shape = this._activeAAMShape;
if (this._activeShape && this._activeShape.activeAttribute != null) {
shape = this._activeShape;
}
else {
this.selectShape(this._lastPos, false);
if (this._activeShape && !this._activeShape.lock) {
if (this._activeShape) {
shape = this._activeShape;
}
}
Expand All @@ -648,7 +660,7 @@ class ShapeCollectionModel extends Listener {
}

switchActiveHide() {
if (this._activeAAMShape) {
if (this._activeShape.activeAttribute != null) {
return;
}

Expand Down Expand Up @@ -768,7 +780,7 @@ class ShapeCollectionModel extends Listener {
}

get activeShape() {
return this._activeAAMShape || this._activeShape;
return this._activeShape;
}

get currentShapes() {
Expand Down

0 comments on commit 2192e18

Please sign in to comment.