@@ -132,6 +132,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
132132 __dropHereUI : null ,
133133 __selectionRectInitPos : null ,
134134 __selectionRectRepr : null ,
135+ __rectAnnotationRepr : null ,
135136 __panning : null ,
136137 __isDraggingFile : null ,
137138 __isDraggingLink : null ,
@@ -1448,14 +1449,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
14481449 this . __annotationInitPos = null ;
14491450 }
14501451 if ( this . __annotating ) {
1451- if ( this . __consolidateAnnotation ( annotationInitPos , this . __rectAnnotationRepr ) ) {
1452- if ( this . __rectAnnotationRepr ) {
1453- osparc . wrapper . Svg . removeItem ( this . __rectAnnotationRepr ) ;
1454- this . __rectAnnotationRepr = null ;
1455- }
1456- this . __annotating = null ;
1457- this . __toolHint . setValue ( null ) ;
1458- }
1452+ this . __consolidateAnnotation ( annotationInitPos ) ;
14591453 }
14601454
14611455 if ( this . __panning ) {
@@ -1894,30 +1888,30 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
18941888 const y = Math . min ( initPos . y , currentPos . y ) ;
18951889 const width = Math . abs ( initPos . x - currentPos . x ) ;
18961890 const height = Math . abs ( initPos . y - currentPos . y ) ;
1897- if ( [ null , undefined ] . includes ( this . __rectAnnotationRepr ) ) {
1891+ if ( this . __rectAnnotationRepr ) {
1892+ osparc . wrapper . Svg . updateRect ( this . __rectAnnotationRepr , width , height , x , y ) ;
1893+ } else {
18981894 const color = this . __annotationLastColor ? this . __annotationLastColor : osparc . workbench . Annotation . DEFAULT_COLOR ;
18991895 this . __rectAnnotationRepr = this . __svgLayer . drawAnnotationRect ( width , height , x , y , color ) ;
1900- } else {
1901- osparc . wrapper . Svg . updateRect ( this . __rectAnnotationRepr , width , height , x , y ) ;
19021896 }
19031897 } ,
19041898
1905- __consolidateAnnotation : function ( initPos , annotation ) {
1899+ __consolidateAnnotation : function ( initPos ) {
1900+ const annotationTypes = osparc . workbench . Annotation . TYPES ;
1901+ if ( type === annotationTypes . RECT && ! this . __rectAnnotationRepr ) {
1902+ osparc . FlashMessenger . logAs ( this . tr ( "Draw a rectangle first" ) , "WARNING" ) ;
1903+ return ;
1904+ }
1905+
19061906 const type = this . __annotating ;
19071907 const color = this . __annotationLastColor ? this . __annotationLastColor : osparc . workbench . Annotation . DEFAULT_COLOR ;
19081908 const serializeData = {
19091909 type,
19101910 color,
19111911 attributes : { }
19121912 } ;
1913-
1914- const annotationTypes = osparc . workbench . Annotation . TYPES ;
19151913 if ( type === annotationTypes . RECT ) {
1916- if ( [ null , undefined ] . includes ( annotation ) ) {
1917- osparc . FlashMessenger . logAs ( this . tr ( "Draw a rectangle first" ) , "WARNING" ) ;
1918- return false ;
1919- }
1920- serializeData . attributes = osparc . wrapper . Svg . getRectAttributes ( annotation ) ;
1914+ serializeData . attributes = osparc . wrapper . Svg . getRectAttributes ( this . __rectAnnotationRepr ) ;
19211915 } else {
19221916 serializeData . attributes = initPos ;
19231917 }
@@ -1940,9 +1934,14 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19401934 noteEditor . addListener ( "cancel" , ( ) => win . close ( ) ) ;
19411935 break ;
19421936 }
1943- case annotationTypes . RECT :
1937+ case annotationTypes . RECT : {
19441938 this . __addAnnotation ( serializeData ) ;
1939+ if ( this . __rectAnnotationRepr ) {
1940+ osparc . wrapper . Svg . removeItem ( this . __rectAnnotationRepr ) ;
1941+ this . __rectAnnotationRepr = null ;
1942+ }
19451943 break ;
1944+ }
19461945 case annotationTypes . TEXT : {
19471946 const tempAnnotation = new osparc . workbench . Annotation ( null , {
19481947 type : annotationTypes . TEXT ,
@@ -1976,9 +1975,14 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19761975 win . open ( ) ;
19771976 break ;
19781977 }
1978+ case annotationTypes . CONVERSATION : {
1979+ console . log ( "CONVERSATION" , initPos ) ;
1980+ break ;
1981+ }
19791982 }
19801983
1981- return true ;
1984+ this . __annotating = null ;
1985+ this . __toolHint . setValue ( null ) ;
19821986 } ,
19831987
19841988 __addAnnotation : function ( data , id ) {
0 commit comments