Skip to content

Commit

Permalink
Fixed: invisible text in case when frame fully fitted in player and b…
Browse files Browse the repository at this point in the history
…b is full frame
  • Loading branch information
Boris Sekachev committed Nov 21, 2018
1 parent 9440de2 commit d655d85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cvat/apps/engine/static/engine/js/coordinateTranslator.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ class CoordinateTranslator {
pt.y = clientY;
pt = pt.matrixTransform(targetCanvas.getScreenCTM().inverse());
return pt;
},
canvasToClient: function(sourceCanvas, canvasX, canvasY) {
let pt = sourceCanvas.createSVGPoint();
pt.x = canvasX;
pt.y = canvasY;
pt = pt.matrixTransform(sourceCanvas.getScreenCTM());
return pt;
}
};
}
Expand Down
11 changes: 10 additions & 1 deletion cvat/apps/engine/static/engine/js/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,8 @@ class ShapeView extends Listener {
this._shapeContextMenu = $('#shapeContextMenu');
this._pointContextMenu = $('#pointContextMenu');

this._rightBorderFrame = $('#playerFrame')[0].offsetWidth;

shapeModel.subscribe(this);
}

Expand Down Expand Up @@ -2444,10 +2446,17 @@ class ShapeView extends Listener {
if (this._uis.text && this._uis.text.node.parentElement) {
let revscale = 1 / scale;
let shapeBBox = this._uis.shape.node.getBBox();
let textBBox = this._uis.text.node.getBBox()

let x = shapeBBox.x + shapeBBox.width + TEXT_MARGIN;
let x = shapeBBox.x + shapeBBox.width + TEXT_MARGIN * revscale;
let y = shapeBBox.y;

let transl = window.cvat.translate.point;
let canvas = this._scenes.svg.node;
if (transl.canvasToClient(canvas, x + textBBox.width * revscale, 0).x > this._rightBorderFrame) {
x = shapeBBox.x + TEXT_MARGIN * revscale;
}

this._uis.text.move(x / revscale, y / revscale);
this._uis.text.attr('transform', `scale(${revscale})`);

Expand Down

0 comments on commit d655d85

Please sign in to comment.