@@ -67,7 +67,6 @@ export class nrrd_tools {
6767 currentIndex : 0 ,
6868 maxIndex : 0 ,
6969 minIndex : 0 ,
70- z_Index : 0 ,
7170 RSARatio : 0 ,
7271 latestNotEmptyImg : new Image ( ) ,
7372 contrastNum : 0 ,
@@ -88,6 +87,27 @@ export class nrrd_tools {
8887 drawStartPos : new THREE . Vector2 ( 1 , 1 ) ,
8988 } ;
9089
90+ private cursorPage = {
91+ x : {
92+ cursorPageX : 0 ,
93+ cursorPageY : 0 ,
94+ index : 0 ,
95+ updated : false ,
96+ } ,
97+ y : {
98+ cursorPageX : 0 ,
99+ cursorPageY : 0 ,
100+ index : 0 ,
101+ updated : false ,
102+ } ,
103+ z : {
104+ cursorPageX : 0 ,
105+ cursorPageY : 0 ,
106+ index : 0 ,
107+ updated : false ,
108+ } ,
109+ } ;
110+
91111 private gui_states = {
92112 mainAreaSize : 1 ,
93113 dragSensitivity : 75 ,
@@ -209,20 +229,137 @@ export class nrrd_tools {
209229 setSliceOrientation ( axis : "x" | "y" | "z" ) {
210230 if ( this . nrrd_states . enableCursorChoose ) {
211231 if ( this . axis === "z" ) {
212- this . nrrd_states . z_Index = this . nrrd_states . currentIndex ;
232+ this . cursorPage . z . index = this . nrrd_states . currentIndex ;
233+ this . cursorPage . z . cursorPageX = this . nrrd_states . cursorPageX ;
234+ this . cursorPage . z . cursorPageY = this . nrrd_states . cursorPageY ;
235+ } else if ( this . axis === "x" ) {
236+ this . cursorPage . x . index = this . nrrd_states . currentIndex ;
237+ this . cursorPage . x . cursorPageX = this . nrrd_states . cursorPageX ;
238+ this . cursorPage . x . cursorPageY = this . nrrd_states . cursorPageY ;
239+ } else if ( this . axis === "y" ) {
240+ this . cursorPage . y . index = this . nrrd_states . currentIndex ;
241+ this . cursorPage . y . cursorPageX = this . nrrd_states . cursorPageX ;
242+ this . cursorPage . y . cursorPageY = this . nrrd_states . cursorPageY ;
213243 }
214-
215244 if ( axis === "z" ) {
216- this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
217- this . nrrd_states . z_Index ;
245+ if ( this . nrrd_states . isCursorSelect && ! this . cursorPage . z . updated ) {
246+ if ( this . axis === "x" ) {
247+ this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
248+ Math . ceil (
249+ ( this . cursorPage . x . cursorPageX /
250+ this . mainPreSlice . volume . RASDimensions [ 0 ] ) *
251+ this . mainPreSlice . volume . dimensions [ 0 ]
252+ ) ;
253+ this . nrrd_states . cursorPageX = Math . ceil (
254+ ( this . cursorPage . x . index /
255+ this . mainPreSlice . volume . dimensions [ 0 ] ) *
256+ this . mainPreSlice . volume . RASDimensions [ 0 ]
257+ ) ;
258+ }
259+ if ( this . axis === "y" ) {
260+ this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
261+ Math . ceil ( this . cursorPage . y . cursorPageY ) ;
262+ this . nrrd_states . cursorPageY = Math . ceil (
263+ ( 1 -
264+ this . cursorPage . y . index /
265+ this . mainPreSlice . volume . dimensions [ 1 ] ) *
266+ this . mainPreSlice . volume . RASDimensions [ 1 ]
267+ ) ;
268+ }
269+ this . cursorPage . z . updated = true ;
270+ } else {
271+ this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
272+ this . cursorPage . z . index ;
273+ this . nrrd_states . cursorPageX = this . cursorPage . z . cursorPageX ;
274+ this . nrrd_states . cursorPageY = this . cursorPage . z . cursorPageY ;
275+ }
218276 } else if ( axis === "x" ) {
219- this . nrrd_states . oldIndex = this . nrrd_states . currentIndex = Math . ceil (
220- this . nrrd_states . cursorPageX
221- ) ;
277+ if ( this . nrrd_states . isCursorSelect && ! this . cursorPage . x . updated ) {
278+ if ( this . axis === "z" ) {
279+ this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
280+ Math . ceil (
281+ ( this . cursorPage . z . cursorPageX /
282+ this . mainPreSlice . volume . RASDimensions [ 0 ] ) *
283+ this . mainPreSlice . volume . dimensions [ 0 ]
284+ ) ;
285+ this . nrrd_states . cursorPageX = Math . ceil (
286+ ( this . cursorPage . z . index /
287+ this . mainPreSlice . volume . dimensions [ 2 ] ) *
288+ this . mainPreSlice . volume . RASDimensions [ 2 ]
289+ ) ;
290+ }
291+ if ( this . axis === "y" ) {
292+ this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
293+ Math . ceil (
294+ ( this . cursorPage . y . cursorPageX /
295+ this . mainPreSlice . volume . RASDimensions [ 1 ] ) *
296+ this . mainPreSlice . volume . dimensions [ 1 ]
297+ ) ;
298+
299+ this . nrrd_states . cursorPageX = this . cursorPage . y . cursorPageY ;
300+ this . nrrd_states . cursorPageY = Math . ceil (
301+ ( 1 -
302+ this . cursorPage . y . index /
303+ this . mainPreSlice . volume . dimensions [ 1 ] ) *
304+ this . mainPreSlice . volume . RASDimensions [ 1 ]
305+ ) ;
306+ }
307+ this . cursorPage . x . updated = true ;
308+ } else {
309+ this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
310+ this . cursorPage . x . index ;
311+ this . nrrd_states . cursorPageX = this . cursorPage . x . cursorPageX ;
312+ this . nrrd_states . cursorPageY = this . cursorPage . x . cursorPageY ;
313+ }
222314 } else if ( axis === "y" ) {
223- this . nrrd_states . oldIndex = this . nrrd_states . currentIndex = Math . ceil (
224- this . nrrd_states . cursorPageY
225- ) ;
315+ if ( this . nrrd_states . isCursorSelect && ! this . cursorPage . y . updated ) {
316+ if ( this . axis === "z" ) {
317+ this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
318+ this . mainPreSlice . volume . dimensions [ 1 ] -
319+ Math . ceil (
320+ ( this . cursorPage . z . cursorPageY /
321+ this . mainPreSlice . volume . RASDimensions [ 1 ] ) *
322+ this . mainPreSlice . volume . dimensions [ 1 ]
323+ ) ;
324+ this . nrrd_states . cursorPageY = Math . ceil (
325+ ( this . cursorPage . z . index /
326+ this . mainPreSlice . volume . dimensions [ 2 ] ) *
327+ this . mainPreSlice . volume . RASDimensions [ 2 ]
328+ ) ;
329+ }
330+ if ( this . axis === "x" ) {
331+ this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
332+ this . mainPreSlice . volume . dimensions [ 0 ] -
333+ Math . ceil (
334+ ( this . cursorPage . x . cursorPageY /
335+ this . mainPreSlice . volume . RASDimensions [ 0 ] ) *
336+ this . mainPreSlice . volume . dimensions [ 0 ]
337+ ) ;
338+ this . nrrd_states . cursorPageX = Math . ceil (
339+ ( this . cursorPage . x . index /
340+ this . mainPreSlice . volume . dimensions [ 0 ] ) *
341+ this . mainPreSlice . volume . RASDimensions [ 0 ]
342+ ) ;
343+ this . nrrd_states . cursorPageY = Math . ceil (
344+ ( this . cursorPage . x . cursorPageY /
345+ this . mainPreSlice . volume . RASDimensions [ 0 ] ) *
346+ this . mainPreSlice . volume . RASDimensions [ 2 ]
347+ ) ;
348+ }
349+ this . cursorPage . y . updated = true ;
350+ } else {
351+ this . nrrd_states . oldIndex = this . nrrd_states . currentIndex =
352+ this . cursorPage . y . index ;
353+ this . nrrd_states . cursorPageX = this . cursorPage . y . cursorPageX ;
354+ this . nrrd_states . cursorPageY = this . cursorPage . y . cursorPageY ;
355+ }
356+ }
357+ if (
358+ this . cursorPage . x . updated &&
359+ this . cursorPage . y . updated &&
360+ this . cursorPage . z . updated
361+ ) {
362+ this . nrrd_states . isCursorSelect = false ;
226363 }
227364 }
228365
@@ -311,6 +448,12 @@ export class nrrd_tools {
311448 return [ this . nrrd_states . maxIndex ] ;
312449 }
313450 }
451+ getCurrentSlicesNumAndContrastNum ( ) {
452+ return {
453+ currentIndex : this . nrrd_states . currentIndex ,
454+ contrastIndex : this . nrrd_states . contrastNum ,
455+ } ;
456+ }
314457
315458 getCurrentSliceIndex ( ) {
316459 return Math . ceil ( this . mainPreSlice . index / this . nrrd_states . RSARatio ) ;
@@ -378,11 +521,11 @@ export class nrrd_tools {
378521 this . mainPreSlice = this . displaySlices [ 0 ] ;
379522 if ( this . mainPreSlice ) {
380523 this . nrrd_states . RSARatio = this . mainPreSlice . RSARatio ;
381- const initIndex = this . mainPreSlice . index ;
382- this . findLastCanvas ( ) ;
524+ // const initIndex = this.mainPreSlice.index;
383525 // this.findLastCanvas();
384- this . mainPreSlice . index = initIndex ;
385- this . mainPreSlice . repaint . call ( this . mainPreSlice ) ;
526+ // // this.findLastCanvas();
527+ // this.mainPreSlice.index = initIndex;
528+ // this.mainPreSlice.repaint.call(this.mainPreSlice);
386529 }
387530 }
388531
@@ -411,7 +554,8 @@ export class nrrd_tools {
411554 this . nrrd_states . currentIndex = this . mainPreSlice . initIndex ;
412555 } else {
413556 // !need to change
414- this . mainPreSlice . index = this . nrrd_states . oldIndex ;
557+ this . mainPreSlice . index =
558+ this . nrrd_states . oldIndex * this . nrrd_states . RSARatio ;
415559 }
416560
417561 this . originCanvas = this . mainPreSlice . canvas ;
@@ -696,16 +840,17 @@ export class nrrd_tools {
696840 let needToUpdateSlice = this . updateCurrentContrastSlice ( ) ;
697841 needToUpdateSlice . repaint . call ( needToUpdateSlice ) ;
698842
699- let verify = true ;
700- if ( this . nrrd_states . maxIndex - this . nrrd_states . currentIndex <= 30 ) {
701- verify = ! this . verifyCanvasIsEmpty ( needToUpdateSlice . canvas ) ;
702- }
703-
704- if ( verify ) {
705- this . drawDragSlice ( needToUpdateSlice . canvas , newIndex ) ;
706- } else {
707- this . drawDragSlice ( this . nrrd_states . latestNotEmptyImg , newIndex ) ;
708- }
843+ // let verify = true;
844+ // if (this.nrrd_states.maxIndex - this.nrrd_states.currentIndex <= 5) {
845+ // verify = !this.verifyCanvasIsEmpty(needToUpdateSlice.canvas);
846+ // }
847+
848+ // if (verify) {
849+ // this.drawDragSlice(needToUpdateSlice.canvas, newIndex);
850+ // } else {
851+ // this.drawDragSlice(this.nrrd_states.latestNotEmptyImg, newIndex);
852+ // }
853+ this . drawDragSlice ( needToUpdateSlice . canvas , newIndex ) ;
709854 }
710855 // this.nrrd_states.oldIndex = this.mainPreSlice.index;
711856 this . nrrd_states . oldIndex = newIndex ;
@@ -905,6 +1050,24 @@ export class nrrd_tools {
9051050 e . offsetX / this . nrrd_states . sizeFoctor ;
9061051 this . nrrd_states . cursorPageY =
9071052 e . offsetY / this . nrrd_states . sizeFoctor ;
1053+ this . nrrd_states . isCursorSelect = true ;
1054+ switch ( this . axis ) {
1055+ case "x" :
1056+ this . cursorPage . x . updated = true ;
1057+ this . cursorPage . y . updated = false ;
1058+ this . cursorPage . z . updated = false ;
1059+ break ;
1060+ case "y" :
1061+ this . cursorPage . x . updated = false ;
1062+ this . cursorPage . y . updated = true ;
1063+ this . cursorPage . z . updated = false ;
1064+ break ;
1065+ case "z" :
1066+ this . cursorPage . x . updated = false ;
1067+ this . cursorPage . y . updated = false ;
1068+ this . cursorPage . z . updated = true ;
1069+ break ;
1070+ }
9081071 }
9091072 } else if ( e . button === 2 ) {
9101073 rightclicked = true ;
0 commit comments