Skip to content

Commit

Permalink
Some AAM refactoring #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Sekachev committed Oct 17, 2018
1 parent 0bb168b commit 302526c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 66 deletions.
55 changes: 55 additions & 0 deletions cvat/apps/engine/static/engine/js/attributeAnnotationMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ class AAMModel extends Listener {
return this._activeAAM;
}

get active() {
return this._active;
}

set margin(value) {
this._margin = value;
}
Expand Down Expand Up @@ -344,6 +348,7 @@ class AAMView {
this._aamCounter = $('#aamCounter');
this._aamHelpContainer = $('#aamHelpContainer');
this._zoomMargin = $('#aamZoomMargin');
this._frameContent = SVG.adopt($('#frameContent')[0]);
this._controller = aamController;

this._zoomMargin.on('change', (e) => {
Expand All @@ -353,7 +358,57 @@ class AAMView {
aamModel.subscribe(this);
}


_setupAAMView(active, type, pos) {
let oldRect = $('#outsideRect');
let oldMask = $('#outsideMask');

if (active) {
if (oldRect.length) {
oldRect.remove();
oldMask.remove();
}

let size = {
x: 0,
y: 0,
width: window.cvat.player.geometry.frameWidth,
height: window.cvat.player.geometry.frameHeight
};

let excludeField = this._frameContent.rect(size.width, size.height).move(size.x, size.y).fill('#666');
let includeField = null;

if (type === 'box') {
includeField = this._frameContent.rect(pos.xbr - pos.xtl, pos.ybr - pos.ytl).move(pos.xtl, pos.ytl);
}
else {
includeField = this._frameContent.polygon(pos.points);
}

this._frameContent.mask().add(excludeField).add(includeField).fill('black').attr('id', 'outsideMask');
this._frameContent.rect(size.width, size.height).move(size.x, size.y).attr({
mask: 'url(#outsideMask)',
id: 'outsideRect'
});

let content = $(this._frameContent.node);
let texts = content.find('.shapeText');
for (let text of texts) {
content.append(text);
}
}
else {
oldRect.remove();
oldMask.remove();
}
}

onAAMUpdate(aam) {
this._setupAAMView(aam.active ? true : false,
aam.active ? aam.active.type.split('_')[1] : '',
aam.active ? aam.active.interpolate(window.cvat.player.frames.current).position : 0);

if (aam.activeAAM) {
if (this._aamMenu.hasClass('hidden')) {
this._trackManagement.addClass('hidden');
Expand Down
66 changes: 0 additions & 66 deletions cvat/apps/engine/static/engine/js/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2505,7 +2505,6 @@ class ShapeView extends Listener {
break;
}
case 'activeAttribute':
this._setupAAMView(activeAttribute != null, interpolation.position);
setupHidden.call(this, hiddenShape, hiddenText,
activeAttribute != null, activeAttribute, model.active, interpolation);

Expand Down Expand Up @@ -2753,38 +2752,6 @@ class BoxView extends ShapeView {

ShapeView.prototype._drawShapeUI.call(this);
}


_setupAAMView(active, pos) {
let oldRect = $('#outsideRect');
let oldMask = $('#outsideMask');

if (active) {
if (oldRect.length) {
oldRect.remove();
oldMask.remove();
}

let size = {
x: 0,
y: 0,
width: window.cvat.player.geometry.frameWidth,
height: window.cvat.player.geometry.frameHeight
};

let excludeField = this._scenes.svg.rect(size.width, size.height).move(size.x, size.y).fill('#666');
let includeField = this._scenes.svg.rect(pos.xbr - pos.xtl, pos.ybr - pos.ytl).move(pos.xtl, pos.ytl);
this._scenes.svg.mask().add(excludeField).add(includeField).fill('black').attr('id', 'outsideMask');
this._scenes.svg.rect(size.width, size.height).move(size.x, size.y).attr({
mask: 'url(#outsideMask)',
id: 'outsideRect'
});
}
else {
oldRect.remove();
oldMask.remove();
}
}
}


Expand All @@ -2803,39 +2770,6 @@ class PolyShapeView extends ShapeView {
};
}


_setupAAMView(active, pos) {
let oldRect = $('#outsideRect');
let oldMask = $('#outsideMask');

if (active) {
if (oldRect.length) {
oldRect.remove();
oldMask.remove();
}

let size = {
x: 0,
y: 0,
width: window.cvat.player.geometry.frameWidth,
height: window.cvat.player.geometry.frameHeight
};

let excludeField = this._scenes.svg.rect(size.width, size.height).move(size.x, size.y).fill('#666');
let includeField = this._scenes.svg.polygon(pos.points);
this._scenes.svg.mask().add(excludeField).add(includeField).fill('black').attr('id', 'outsideMask');
this._scenes.svg.rect(size.width, size.height).move(size.x, size.y).attr({
mask: 'url(#outsideMask)',
id: 'outsideRect'
});
}
else {
oldRect.remove();
oldMask.remove();
}
}


_makeEditable() {
ShapeView.prototype._makeEditable.call(this);
if (this._flags.editable) {
Expand Down

0 comments on commit 302526c

Please sign in to comment.