@@ -110,6 +110,8 @@ export class nrrd_tools {
110110 stepClear : 1 ,
111111 sizeFoctor : 1 ,
112112 clearAllFlag : false ,
113+ previousPanelL : - 99999 ,
114+ previousPanelT : - 99999 ,
113115 getMask : (
114116 mask : ImageData ,
115117 sliceId : number ,
@@ -369,6 +371,11 @@ export class nrrd_tools {
369371 return same ;
370372 }
371373
374+ /**
375+ * init all painted images for store images
376+ * @param dimensions
377+ */
378+
372379 private initPaintImages ( dimensions : Array < number > ) {
373380 // for x slices' marks
374381 for ( let i = 0 ; i < dimensions [ 0 ] ; i ++ ) {
@@ -573,6 +580,10 @@ export class nrrd_tools {
573580
574581 this . clearDictionary ( this . skipSlicesDic ) ;
575582
583+ // this.nrrd_states.previousPanelL = this.nrrd_states.previousPanelT = -99999;
584+ this . displayCanvas . style . left = this . drawingCanvas . style . left = "" ;
585+ this . displayCanvas . style . top = this . drawingCanvas . style . top = "" ;
586+
576587 this . backUpDisplaySlices . length = 0 ;
577588 this . mainPreSlice = undefined ;
578589 this . currentShowingSlice = undefined ;
@@ -795,14 +806,12 @@ export class nrrd_tools {
795806 */
796807 this . drawingCanvas . style . zIndex = "10" ;
797808 this . drawingCanvas . style . position = "absolute" ;
809+
798810 this . drawingCanvas . width = this . nrrd_states . changedWidth ;
799811 this . drawingCanvas . height = this . nrrd_states . changedHeight ;
800812 this . drawingCanvas . style . cursor = this . nrrd_states . defaultPaintCursor ;
801813 this . drawingCanvas . oncontextmenu = ( ) => false ;
802814
803- // this.displayCanvas.style.left = this.drawingCanvas.style.left = "0px";
804- // this.displayCanvas.style.top = this.drawingCanvas.style.top = "0px";
805-
806815 /**
807816 * layer1
808817 * it should be hide, so we don't need to add it to mainAreaContainer
@@ -1163,13 +1172,16 @@ export class nrrd_tools {
11631172 passive : false ,
11641173 } ) ;
11651174
1166- const handleDragPaintPanel = throttle ( ( e : MouseEvent ) => {
1175+ const handleDragPaintPanel = ( e : MouseEvent ) => {
11671176 this . drawingCanvas . style . cursor = "grabbing" ;
1177+ this . nrrd_states . previousPanelL = e . clientX - panelMoveInnerX ;
1178+ this . nrrd_states . previousPanelT = e . clientY - panelMoveInnerY ;
11681179 this . displayCanvas . style . left = this . drawingCanvas . style . left =
1169- e . clientX - panelMoveInnerX + "px" ;
1180+ this . nrrd_states . previousPanelL + "px" ;
11701181 this . displayCanvas . style . top = this . drawingCanvas . style . top =
1171- e . clientY - panelMoveInnerY + "px" ;
1172- } , 80 ) ;
1182+ this . nrrd_states . previousPanelT + "px" ;
1183+ } ;
1184+ // throttle(, 80);
11731185 const handleDisplayMouseMove = ( e : MouseEvent ) => {
11741186 this . nrrd_states . Mouse_Over_x = e . offsetX ;
11751187 this . nrrd_states . Mouse_Over_y = e . offsetY ;
@@ -1268,10 +1280,15 @@ export class nrrd_tools {
12681280 }
12691281 } else if ( e . button === 2 ) {
12701282 rightclicked = true ;
1271- let offsetX = parseInt ( this . drawingCanvas . style . left ) ;
1272- let offsetY = parseInt ( this . drawingCanvas . style . top ) ;
1283+
1284+ // let offsetX = parseInt(this.drawingCanvas.style.left);
1285+ // let offsetY = parseInt(this.drawingCanvas.style.top);
1286+ let offsetX = this . drawingCanvas . offsetLeft ;
1287+ let offsetY = this . drawingCanvas . offsetTop ;
1288+
12731289 panelMoveInnerX = e . clientX - offsetX ;
12741290 panelMoveInnerY = e . clientY - offsetY ;
1291+
12751292 this . drawingCanvas . style . cursor = "grab" ;
12761293 this . drawingCanvas . addEventListener ( "pointerup" , handlePointerUp ) ;
12771294 this . drawingCanvas . addEventListener (
@@ -1875,8 +1892,6 @@ export class nrrd_tools {
18751892 this . displayCanvas . style . left = this . drawingCanvas . style . left = l + "px" ;
18761893 this . displayCanvas . style . top = this . drawingCanvas . style . top = t + "px" ;
18771894 } else {
1878- this . displayCanvas . style . left = this . drawingCanvas . style . left = "" ;
1879- this . displayCanvas . style . top = this . drawingCanvas . style . top = "" ;
18801895 this . mainAreaContainer . style . justifyContent = "center" ;
18811896 this . mainAreaContainer . style . alignItems = "center" ;
18821897 }
0 commit comments