@ -21,8 +21,11 @@ import consts from './consts';
import {
import {
translateToSVG ,
translateToSVG ,
translateFromSVG ,
translateFromSVG ,
pointsToArray ,
pointsToNumberArray ,
parsePoints ,
displayShapeSize ,
displayShapeSize ,
scalarProduct ,
vectorLength ,
ShapeSizeElement ,
ShapeSizeElement ,
DrawnState ,
DrawnState ,
} from './shared' ;
} from './shared' ;
@ -71,6 +74,9 @@ export class CanvasViewImpl implements CanvasView, Listener {
private autoborderHandler : AutoborderHandler ;
private autoborderHandler : AutoborderHandler ;
private activeElement : ActiveElement ;
private activeElement : ActiveElement ;
private configuration : Configuration ;
private configuration : Configuration ;
private serviceFlags : {
drawHidden : Record < number , boolean > ;
} ;
private set mode ( value : Mode ) {
private set mode ( value : Mode ) {
this . controller . mode = value ;
this . controller . mode = value ;
@ -80,8 +86,75 @@ export class CanvasViewImpl implements CanvasView, Listener {
return this . controller . mode ;
return this . controller . mode ;
}
}
private isServiceHidden ( clientID : number ) : boolean {
return this . serviceFlags . drawHidden [ clientID ] || false ;
}
private setupServiceHidden ( clientID : number , value : boolean ) : void {
this . serviceFlags . drawHidden [ clientID ] = value ;
const shape = this . svgShapes [ clientID ] ;
const text = this . svgTexts [ clientID ] ;
const state = this . drawnStates [ clientID ] ;
if ( value ) {
if ( shape ) {
( state . shapeType === 'points' ? shape . remember ( '_selectHandler' ) . nested : shape )
. style ( 'display' , 'none' ) ;
}
if ( text ) {
text . addClass ( 'cvat_canvas_hidden' ) ;
}
} else {
delete this . serviceFlags . drawHidden [ clientID ] ;
if ( state ) {
if ( ! state . outside && ! state . hidden ) {
if ( shape ) {
( state . shapeType === 'points' ? shape . remember ( '_selectHandler' ) . nested : shape )
. style ( 'display' , '' ) ;
}
if ( text ) {
text . removeClass ( 'cvat_canvas_hidden' ) ;
this . updateTextPosition (
text ,
shape ,
) ;
}
}
}
}
}
private onDrawDone ( data : object | null , duration : number , continueDraw? : boolean ) : void {
private onDrawDone ( data : object | null , duration : number , continueDraw? : boolean ) : void {
const hiddenBecauseOfDraw = Object . keys ( this . serviceFlags . drawHidden )
. map ( ( _clientID ) : number = > + _clientID ) ;
if ( hiddenBecauseOfDraw . length ) {
for ( const hidden of hiddenBecauseOfDraw ) {
this . setupServiceHidden ( hidden , false ) ;
}
}
if ( data ) {
if ( data ) {
const { clientID , points } = data as any ;
if ( typeof ( clientID ) === 'number' ) {
const event : CustomEvent = new CustomEvent ( 'canvas.canceled' , {
bubbles : false ,
cancelable : true ,
} ) ;
this . canvas . dispatchEvent ( event ) ;
const [ state ] = this . controller . objects
. filter ( ( _state : any ) : boolean = > (
_state . clientID === clientID
) ) ;
this . onEditDone ( state , points ) ;
return ;
}
const { zLayer } = this . controller ;
const { zLayer } = this . controller ;
const event : CustomEvent = new CustomEvent ( 'canvas.drawn' , {
const event : CustomEvent = new CustomEvent ( 'canvas.drawn' , {
bubbles : false ,
bubbles : false ,
@ -323,6 +396,15 @@ export class CanvasViewImpl implements CanvasView, Listener {
) ;
) ;
}
}
for ( const element of
window . document . getElementsByClassName ( 'cvat_canvas_poly_direction' ) ) {
const angle = ( element as any ) . instance . data ( 'angle' ) ;
( element as any ) . instance . style ( {
transform : ` scale( ${ 1 / this . geometry . scale } ) rotate( ${ angle } deg) ` ,
} ) ;
}
for ( const element of
for ( const element of
window . document . getElementsByClassName ( 'cvat_canvas_selected_point' ) ) {
window . document . getElementsByClassName ( 'cvat_canvas_selected_point' ) ) {
const previousWidth = element . getAttribute ( 'stroke-width' ) as string ;
const previousWidth = element . getAttribute ( 'stroke-width' ) as string ;
@ -425,13 +507,88 @@ export class CanvasViewImpl implements CanvasView, Listener {
}
}
}
}
private hideDirection ( shape : SVG.Polygon | SVG . PolyLine ) : void {
/* eslint class-methods-use-this: 0 */
const handler = shape . remember ( '_selectHandler' ) ;
if ( ! handler || ! handler . nested ) return ;
const nested = handler . nested as SVG . Parent ;
if ( nested . children ( ) . length ) {
nested . children ( ) [ 0 ] . removeClass ( 'cvat_canvas_first_poly_point' ) ;
}
const node = nested . node as SVG . LinkedHTMLElement ;
const directions = node . getElementsByClassName ( 'cvat_canvas_poly_direction' ) ;
for ( const direction of directions ) {
const { instance } = ( direction as any ) ;
instance . off ( 'click' ) ;
instance . remove ( ) ;
}
}
private showDirection ( state : any , shape : SVG.Polygon | SVG . PolyLine ) : void {
const path = consts . ARROW_PATH ;
const points = parsePoints ( state . points ) ;
const handler = shape . remember ( '_selectHandler' ) ;
if ( ! handler || ! handler . nested ) return ;
const firstCircle = handler . nested . children ( ) [ 0 ] ;
const secondCircle = handler . nested . children ( ) [ 1 ] ;
firstCircle . addClass ( 'cvat_canvas_first_poly_point' ) ;
const [ cx , cy ] = [
( secondCircle . cx ( ) + firstCircle . cx ( ) ) / 2 ,
( secondCircle . cy ( ) + firstCircle . cy ( ) ) / 2 ,
] ;
const [ firstPoint , secondPoint ] = points . slice ( 0 , 2 ) ;
const xAxis = { i : 1 , j : 0 } ;
const baseVector = { i : secondPoint.x - firstPoint . x , j : secondPoint.y - firstPoint . y } ;
const baseVectorLength = vectorLength ( baseVector ) ;
let cosinus = 0 ;
if ( baseVectorLength !== 0 ) {
// two points have the same coordinates
cosinus = scalarProduct ( xAxis , baseVector )
/ ( v e c t o r L e n g t h ( x A x i s ) * b a s e V e c t o r L e n g t h ) ;
}
const angle = Math . acos ( cosinus ) * ( Math . sign ( baseVector . j ) || 1 ) * 180 / Math . PI ;
const pathElement = handler . nested . path ( path ) . fill ( 'white' )
. stroke ( {
width : 1 ,
color : 'black' ,
} ) . addClass ( 'cvat_canvas_poly_direction' ) . style ( {
'transform-origin' : ` ${ cx } px ${ cy } px ` ,
transform : ` scale( ${ 1 / this . geometry . scale } ) rotate( ${ angle } deg) ` ,
} ) . move ( cx , cy ) ;
pathElement . on ( 'click' , ( e : MouseEvent ) : void = > {
if ( e . button === 0 ) {
e . stopPropagation ( ) ;
if ( state . shapeType === 'polygon' ) {
const reversedPoints = [ points [ 0 ] , . . . points . slice ( 1 ) . reverse ( ) ] ;
this . onEditDone ( state , pointsToNumberArray ( reversedPoints ) ) ;
} else {
const reversedPoints = points . reverse ( ) ;
this . onEditDone ( state , pointsToNumberArray ( reversedPoints ) ) ;
}
}
} ) ;
pathElement . data ( 'angle' , angle ) ;
pathElement . dmove ( - pathElement . width ( ) / 2 , - pathElement . height ( ) / 2 ) ;
}
private selectize ( value : boolean , shape : SVG.Element ) : void {
private selectize ( value : boolean , shape : SVG.Element ) : void {
const self = this ;
const self = this ;
const { offset } = this . controller . geometry ;
const { offset } = this . controller . geometry ;
const translate = ( points : number [ ] ) : number [ ] = > points
const translate = ( points : number [ ] ) : number [ ] = > points
. map ( ( coord : number ) : number = > coord - offset ) ;
. map ( ( coord : number ) : number = > coord - offset ) ;
function dblClickHandler ( e : MouseEvent ) : void {
function mousedownHandler ( e : MouseEvent ) : void {
if ( e . button !== 0 ) return ;
e . preventDefault ( ) ;
const pointID = Array . prototype . indexOf
const pointID = Array . prototype . indexOf
. call ( ( ( e . target as HTMLElement ) . parentElement as HTMLElement ) . children , e . target ) ;
. call ( ( ( e . target as HTMLElement ) . parentElement as HTMLElement ) . children , e . target ) ;
@ -440,45 +597,52 @@ export class CanvasViewImpl implements CanvasView, Listener {
. filter ( ( _state : any ) : boolean = > (
. filter ( ( _state : any ) : boolean = > (
_state . clientID === self . activeElement . clientID
_state . clientID === self . activeElement . clientID
) ) ;
) ) ;
if ( state . shapeType === 'rectangle' ) {
e . preventDefault ( ) ;
if ( [ 'polygon' , 'polyline' , 'points' ] . includes ( state . shapeType ) ) {
return ;
if ( e . ctrlKey ) {
const { points } = state ;
self . onEditDone (
state ,
points . slice ( 0 , pointID * 2 ) . concat ( points . slice ( pointID * 2 + 2 ) ) ,
) ;
} else if ( e . shiftKey ) {
self . canvas . dispatchEvent ( new CustomEvent ( 'canvas.editstart' , {
bubbles : false ,
cancelable : true ,
} ) ) ;
self . mode = Mode . EDIT ;
self . deactivate ( ) ;
self . editHandler . edit ( {
enabled : true ,
state ,
pointID ,
} ) ;
}
}
}
}
}
function dblClickHandler ( e : MouseEvent ) : void {
e . preventDefault ( ) ;
if ( self . activeElement . clientID !== null ) {
const [ state ] = self . controller . objects
. filter ( ( _state : any ) : boolean = > (
_state . clientID === self . activeElement . clientID
) ) ;
if ( state . shapeType === 'cuboid' ) {
if ( state . shapeType === 'cuboid' ) {
if ( e . shiftKey ) {
if ( e . shiftKey ) {
const points = translate ( pointsToArray ( ( e . target as any )
const points = translate ( pointsTo Number Array( ( e . target as any )
. parentElement . parentElement . instance . attr ( 'points' ) ) ) ;
. parentElement . parentElement . instance . attr ( 'points' ) ) ) ;
self . onEditDone (
self . onEditDone (
state ,
state ,
points ,
points ,
) ;
) ;
e . preventDefault ( ) ;
return ;
}
}
}
}
if ( e . ctrlKey ) {
const { points } = state ;
self . onEditDone (
state ,
points . slice ( 0 , pointID * 2 ) . concat ( points . slice ( pointID * 2 + 2 ) ) ,
) ;
} else if ( e . shiftKey ) {
self . canvas . dispatchEvent ( new CustomEvent ( 'canvas.editstart' , {
bubbles : false ,
cancelable : true ,
} ) ) ;
self . mode = Mode . EDIT ;
self . deactivate ( ) ;
self . editHandler . edit ( {
enabled : true ,
state ,
pointID ,
} ) ;
}
}
}
e . preventDefault ( ) ;
}
}
function contextMenuHandler ( e : MouseEvent ) : void {
function contextMenuHandler ( e : MouseEvent ) : void {
@ -524,6 +688,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
} ) ;
} ) ;
circle . on ( 'dblclick' , dblClickHandler ) ;
circle . on ( 'dblclick' , dblClickHandler ) ;
circle . on ( 'mousedown' , mousedownHandler ) ;
circle . on ( 'contextmenu' , contextMenuHandler ) ;
circle . on ( 'contextmenu' , contextMenuHandler ) ;
circle . addClass ( 'cvat_canvas_selected_point' ) ;
circle . addClass ( 'cvat_canvas_selected_point' ) ;
} ) ;
} ) ;
@ -534,6 +699,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
} ) ;
} ) ;
circle . off ( 'dblclick' , dblClickHandler ) ;
circle . off ( 'dblclick' , dblClickHandler ) ;
circle . off ( 'mousedown' , mousedownHandler ) ;
circle . off ( 'contextmenu' , contextMenuHandler ) ;
circle . off ( 'contextmenu' , contextMenuHandler ) ;
circle . removeClass ( 'cvat_canvas_selected_point' ) ;
circle . removeClass ( 'cvat_canvas_selected_point' ) ;
} ) ;
} ) ;
@ -565,6 +731,9 @@ export class CanvasViewImpl implements CanvasView, Listener {
} ;
} ;
this . configuration = model . configuration ;
this . configuration = model . configuration ;
this . mode = Mode . IDLE ;
this . mode = Mode . IDLE ;
this . serviceFlags = {
drawHidden : { } ,
} ;
// Create HTML elements
// Create HTML elements
this . loadingAnimation = window . document
this . loadingAnimation = window . document
@ -864,6 +1033,9 @@ export class CanvasViewImpl implements CanvasView, Listener {
if ( data . enabled && this . mode === Mode . IDLE ) {
if ( data . enabled && this . mode === Mode . IDLE ) {
this . canvas . style . cursor = 'crosshair' ;
this . canvas . style . cursor = 'crosshair' ;
this . mode = Mode . DRAW ;
this . mode = Mode . DRAW ;
if ( typeof ( data . redraw ) === 'number' ) {
this . setupServiceHidden ( data . redraw , true ) ;
}
this . drawHandler . draw ( data , this . geometry ) ;
this . drawHandler . draw ( data , this . geometry ) ;
} else {
} else {
this . canvas . style . cursor = '' ;
this . canvas . style . cursor = '' ;
@ -1045,7 +1217,8 @@ export class CanvasViewImpl implements CanvasView, Listener {
const drawnState = this . drawnStates [ clientID ] ;
const drawnState = this . drawnStates [ clientID ] ;
const shape = this . svgShapes [ state . clientID ] ;
const shape = this . svgShapes [ state . clientID ] ;
const text = this . svgTexts [ state . clientID ] ;
const text = this . svgTexts [ state . clientID ] ;
const isInvisible = state . hidden || state . outside ;
const isInvisible = state . hidden || state . outside
|| this . isServiceHidden ( state . clientID ) ;
if ( drawnState . hidden !== state . hidden || drawnState . outside !== state . outside ) {
if ( drawnState . hidden !== state . hidden || drawnState . outside !== state . outside ) {
if ( isInvisible ) {
if ( isInvisible ) {
@ -1147,59 +1320,57 @@ export class CanvasViewImpl implements CanvasView, Listener {
const { displayAllText } = this . configuration ;
const { displayAllText } = this . configuration ;
for ( const state of states ) {
for ( const state of states ) {
if ( state . objectType === 'tag' ) {
const points : number [ ] = ( state . points as number [ ] ) ;
this . addTag ( state ) ;
const translatedPoints : number [ ] = translate ( points ) ;
// TODO: Use enums after typification cvat-core
if ( state . shapeType === 'rectangle' ) {
this . svgShapes [ state . clientID ] = this
. addRect ( translatedPoints , state ) ;
} else {
} else {
const points : number [ ] = ( state . points as number [ ] ) ;
const stringified = translatedPoints . reduce (
const translatedPoints : number [ ] = translate ( points ) ;
( acc : string , val : number , idx : number ) : string = > {
if ( idx % 2 ) {
return ` ${ acc } ${ val } ` ;
}
// TODO: Use enums after typification cvat-core
return ` ${ acc } ${ val } , ` ;
if ( state . shapeType === 'rectangle' ) {
} , '' ,
) ;
if ( state . shapeType === 'polygon' ) {
this . svgShapes [ state . clientID ] = this
. addPolygon ( stringified , state ) ;
} else if ( state . shapeType === 'polyline' ) {
this . svgShapes [ state . clientID ] = this
this . svgShapes [ state . clientID ] = this
. addRect ( translatedPoints , state ) ;
. addPolyline ( stringified , state ) ;
} else if ( state . shapeType === 'points' ) {
this . svgShapes [ state . clientID ] = this
. addPoints ( stringified , state ) ;
} else if ( state . shapeType === 'cuboid' ) {
this . svgShapes [ state . clientID ] = this
. addCuboid ( stringified , state ) ;
} else {
} else {
const stringified = translatedPoints . reduce (
continue ;
( acc : string , val : number , idx : number ) : string = > {
if ( idx % 2 ) {
return ` ${ acc } ${ val } ` ;
}
return ` ${ acc } ${ val } , ` ;
} , '' ,
) ;
if ( state . shapeType === 'polygon' ) {
this . svgShapes [ state . clientID ] = this
. addPolygon ( stringified , state ) ;
} else if ( state . shapeType === 'polyline' ) {
this . svgShapes [ state . clientID ] = this
. addPolyline ( stringified , state ) ;
} else if ( state . shapeType === 'points' ) {
this . svgShapes [ state . clientID ] = this
. addPoints ( stringified , state ) ;
} else if ( state . shapeType === 'cuboid' ) {
this . svgShapes [ state . clientID ] = this
. addCuboid ( stringified , state ) ;
}
}
}
}
this . svgShapes [ state . clientID ] . on ( 'click.canvas' , ( ) : void = > {
this . svgShapes [ state . clientID ] . on ( 'click.canvas' , ( ) : void = > {
this . canvas . dispatchEvent ( new CustomEvent ( 'canvas.clicked' , {
this . canvas . dispatchEvent ( new CustomEvent ( 'canvas.clicked' , {
bubbles : false ,
bubbles : false ,
cancelable : true ,
cancelable : true ,
detail : {
detail : {
state ,
state ,
} ,
} ,
} ) ) ;
} ) ) ;
} ) ;
} ) ;
if ( displayAllText ) {
if ( displayAllText ) {
this . svgTexts [ state . clientID ] = this . addText ( state ) ;
this . svgTexts [ state . clientID ] = this . addText ( state ) ;
this . updateTextPosition (
this . updateTextPosition (
this . svgTexts [ state . clientID ] ,
this . svgTexts [ state . clientID ] ,
this . svgShapes [ state . clientID ] ,
this . svgShapes [ state . clientID ] ,
) ;
) ;
}
}
}
this . saveState ( state ) ;
this . saveState ( state ) ;
@ -1327,16 +1498,6 @@ export class CanvasViewImpl implements CanvasView, Listener {
const shape = this . svgShapes [ clientID ] ;
const shape = this . svgShapes [ clientID ] ;
let text = this . svgTexts [ clientID ] ;
if ( ! text ) {
text = this . addText ( state ) ;
this . svgTexts [ state . clientID ] = text ;
this . updateTextPosition (
text ,
shape ,
) ;
}
if ( state . lock ) {
if ( state . lock ) {
return ;
return ;
}
}
@ -1354,29 +1515,39 @@ export class CanvasViewImpl implements CanvasView, Listener {
( shape as any ) . attr ( 'projections' , true ) ;
( shape as any ) . attr ( 'projections' , true ) ;
}
}
let text = this . svgTexts [ clientID ] ;
if ( ! text ) {
text = this . addText ( state ) ;
this . svgTexts [ state . clientID ] = text ;
}
const hideText = ( ) : void = > {
if ( text ) {
text . addClass ( 'cvat_canvas_hidden' ) ;
}
} ;
const showText = ( ) : void = > {
if ( text ) {
text . removeClass ( 'cvat_canvas_hidden' ) ;
this . updateTextPosition ( text , shape ) ;
}
} ;
if ( ! state . pinned ) {
if ( ! state . pinned ) {
shape . addClass ( 'cvat_canvas_shape_draggable' ) ;
shape . addClass ( 'cvat_canvas_shape_draggable' ) ;
( shape as any ) . draggable ( ) . on ( 'dragstart' , ( ) : void = > {
( shape as any ) . draggable ( ) . on ( 'dragstart' , ( ) : void = > {
this . mode = Mode . DRAG ;
this . mode = Mode . DRAG ;
if ( text ) {
hideText ( ) ;
text . addClass ( 'cvat_canvas_hidden' ) ;
}
} ) . on ( 'dragend' , ( e : CustomEvent ) : void = > {
} ) . on ( 'dragend' , ( e : CustomEvent ) : void = > {
if ( text ) {
showText ( ) ;
text . removeClass ( 'cvat_canvas_hidden' ) ;
this . updateTextPosition (
text ,
shape ,
) ;
}
this . mode = Mode . IDLE ;
this . mode = Mode . IDLE ;
const p1 = e . detail . handler . startPoints . point ;
const p1 = e . detail . handler . startPoints . point ;
const p2 = e . detail . p ;
const p2 = e . detail . p ;
const delta = 1 ;
const delta = 1 ;
const { offset } = this . controller . geometry ;
const { offset } = this . controller . geometry ;
if ( Math . sqrt ( ( ( p1 . x - p2 . x ) * * 2 ) + ( ( p1 . y - p2 . y ) * * 2 ) ) >= delta ) {
if ( Math . sqrt ( ( ( p1 . x - p2 . x ) * * 2 ) + ( ( p1 . y - p2 . y ) * * 2 ) ) >= delta ) {
const points = pointsTo Array(
const points = pointsToNumberArray (
shape . attr ( 'points' ) || ` ${ shape . attr ( 'x' ) } , ${ shape . attr ( 'y' ) } `
shape . attr ( 'points' ) || ` ${ shape . attr ( 'x' ) } , ${ shape . attr ( 'y' ) } `
+ ` ${ shape . attr ( 'x' ) + shape . attr ( 'width' ) } , `
+ ` ${ shape . attr ( 'x' ) + shape . attr ( 'width' ) } , `
+ ` ${ shape . attr ( 'y' ) + shape . attr ( 'height' ) } ` ,
+ ` ${ shape . attr ( 'y' ) + shape . attr ( 'height' ) } ` ,
@ -1399,19 +1570,32 @@ export class CanvasViewImpl implements CanvasView, Listener {
this . selectize ( true , shape ) ;
this . selectize ( true , shape ) ;
}
}
const showDirection = ( ) : void = > {
if ( [ 'polygon' , 'polyline' ] . includes ( state . shapeType ) ) {
this . showDirection ( state , shape as SVG . Polygon | SVG . PolyLine ) ;
}
} ;
const hideDirection = ( ) : void = > {
if ( [ 'polygon' , 'polyline' ] . includes ( state . shapeType ) ) {
this . hideDirection ( shape as SVG . Polygon | SVG . PolyLine ) ;
}
} ;
showDirection ( ) ;
let shapeSizeElement : ShapeSizeElement | null = null ;
let shapeSizeElement : ShapeSizeElement | null = null ;
let resized = false ;
let resized = false ;
( shape as any ) . resize ( {
( shape as any ) . resize ( {
snapToGrid : 0.1 ,
snapToGrid : 0.1 ,
} ) . on ( 'resizestart' , ( ) : void = > {
} ) . on ( 'resizestart' , ( ) : void = > {
this . mode = Mode . RESIZE ;
this . mode = Mode . RESIZE ;
resized = false ;
hideDirection ( ) ;
hideText ( ) ;
if ( state . shapeType === 'rectangle' ) {
if ( state . shapeType === 'rectangle' ) {
shapeSizeElement = displayShapeSize ( this . adoptedContent , this . adoptedText ) ;
shapeSizeElement = displayShapeSize ( this . adoptedContent , this . adoptedText ) ;
}
}
resized = false ;
if ( text ) {
text . addClass ( 'cvat_canvas_hidden' ) ;
}
} ) . on ( 'resizing' , ( ) : void = > {
} ) . on ( 'resizing' , ( ) : void = > {
resized = true ;
resized = true ;
if ( shapeSizeElement ) {
if ( shapeSizeElement ) {
@ -1422,20 +1606,15 @@ export class CanvasViewImpl implements CanvasView, Listener {
shapeSizeElement . rm ( ) ;
shapeSizeElement . rm ( ) ;
}
}
if ( text ) {
showDirection ( ) ;
text . removeClass ( 'cvat_canvas_hidden' ) ;
showText ( ) ;
this . updateTextPosition (
text ,
shape ,
) ;
}
this . mode = Mode . IDLE ;
this . mode = Mode . IDLE ;
if ( resized ) {
if ( resized ) {
const { offset } = this . controller . geometry ;
const { offset } = this . controller . geometry ;
const points = pointsTo Array(
const points = pointsTo Number Array(
shape . attr ( 'points' ) || ` ${ shape . attr ( 'x' ) } , ${ shape . attr ( 'y' ) } `
shape . attr ( 'points' ) || ` ${ shape . attr ( 'x' ) } , ${ shape . attr ( 'y' ) } `
+ ` ${ shape . attr ( 'x' ) + shape . attr ( 'width' ) } , `
+ ` ${ shape . attr ( 'x' ) + shape . attr ( 'width' ) } , `
+ ` ${ shape . attr ( 'y' ) + shape . attr ( 'height' ) } ` ,
+ ` ${ shape . attr ( 'y' ) + shape . attr ( 'height' ) } ` ,
@ -1453,6 +1632,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
}
}
} ) ;
} ) ;
this . updateTextPosition ( text , shape ) ;
this . canvas . dispatchEvent ( new CustomEvent ( 'canvas.activated' , {
this . canvas . dispatchEvent ( new CustomEvent ( 'canvas.activated' , {
bubbles : false ,
bubbles : false ,
cancelable : true ,
cancelable : true ,
@ -1570,8 +1750,8 @@ export class CanvasViewImpl implements CanvasView, Listener {
rect . addClass ( 'cvat_canvas_shape_occluded' ) ;
rect . addClass ( 'cvat_canvas_shape_occluded' ) ;
}
}
if ( state . hidden || state . outside ) {
if ( state . hidden || state . outside || this . isServiceHidden ( state . clientID ) ) {
rect . style( 'display' , 'none ') ;
rect . addClass( 'cvat_canvas_hidden ') ;
}
}
return rect ;
return rect ;
@ -1593,8 +1773,8 @@ export class CanvasViewImpl implements CanvasView, Listener {
polygon . addClass ( 'cvat_canvas_shape_occluded' ) ;
polygon . addClass ( 'cvat_canvas_shape_occluded' ) ;
}
}
if ( state . hidden || state . outside ) {
if ( state . hidden || state . outside || this . isServiceHidden ( state . clientID ) ) {
polygon . style( 'display' , 'none ') ;
polygon . addClass( 'cvat_canvas_hidden ') ;
}
}
return polygon ;
return polygon ;
@ -1616,8 +1796,8 @@ export class CanvasViewImpl implements CanvasView, Listener {
polyline . addClass ( 'cvat_canvas_shape_occluded' ) ;
polyline . addClass ( 'cvat_canvas_shape_occluded' ) ;
}
}
if ( state . hidden || state . outside ) {
if ( state . hidden || state . outside || this . isServiceHidden ( state . clientID ) ) {
polyline . style( 'display' , 'none ') ;
polyline . addClass( 'cvat_canvas_hidden ') ;
}
}
return polyline ;
return polyline ;
@ -1640,8 +1820,8 @@ export class CanvasViewImpl implements CanvasView, Listener {
cube . addClass ( 'cvat_canvas_shape_occluded' ) ;
cube . addClass ( 'cvat_canvas_shape_occluded' ) ;
}
}
if ( state . hidden || state . outside ) {
if ( state . hidden || state . outside || this . isServiceHidden ( state . clientID ) ) {
cube . style( 'display' , 'none ') ;
cube . addClass( 'cvat_canvas_hidden ') ;
}
}
return cube ;
return cube ;
@ -1684,8 +1864,8 @@ export class CanvasViewImpl implements CanvasView, Listener {
const group = this . setupPoints ( shape , state ) ;
const group = this . setupPoints ( shape , state ) ;
if ( state . hidden || state . outside ) {
if ( state . hidden || state . outside || this . isServiceHidden ( state . clientID ) ) {
group . style( 'display' , 'none ') ;
group . addClass( 'cvat_canvas_hidden ') ;
}
}
shape . remove = ( ) : SVG . PolyLine = > {
shape . remove = ( ) : SVG . PolyLine = > {
@ -1696,9 +1876,4 @@ export class CanvasViewImpl implements CanvasView, Listener {
return shape ;
return shape ;
}
}
/* eslint-disable-next-line */
private addTag ( state : any ) : void {
console . log ( state ) ;
}
}
}