Commit 47322b03500a166e31d168abf8ba7692b29f37b6
1 parent
245c4e65
Exists in
master
and in
67 other branches
ENH: Update orientation text slice, if rotated slice
Showing
1 changed file
with
173 additions
and
5 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -428,7 +428,7 @@ class Viewer(wx.Panel): | @@ -428,7 +428,7 @@ class Viewer(wx.Panel): | ||
428 | orig_orien = 1 | 428 | orig_orien = 1 |
429 | mouse_x, mouse_y = self.interactor.GetLastEventPosition() | 429 | mouse_x, mouse_y = self.interactor.GetLastEventPosition() |
430 | ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y) | 430 | ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y) |
431 | - | 431 | + |
432 | if((self.state == const.STATE_SPIN) and (self.spined_image)): | 432 | if((self.state == const.STATE_SPIN) and (self.spined_image)): |
433 | self.cam.SetViewUp(const.SLICE_POSITION[orig_orien][0][self.orientation]) | 433 | self.cam.SetViewUp(const.SLICE_POSITION[orig_orien][0][self.orientation]) |
434 | self.interactor.Render() | 434 | self.interactor.Render() |
@@ -443,10 +443,53 @@ class Viewer(wx.Panel): | @@ -443,10 +443,53 @@ class Viewer(wx.Panel): | ||
443 | ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y) | 443 | ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y) |
444 | cam = ren.GetActiveCamera() | 444 | cam = ren.GetActiveCamera() |
445 | if (self.left_pressed): | 445 | if (self.left_pressed): |
446 | + self.UpdateTextDirection(cam) | ||
446 | self.spined_image = True | 447 | self.spined_image = True |
447 | evt.Spin() | 448 | evt.Spin() |
448 | evt.OnRightButtonDown() | 449 | evt.OnRightButtonDown() |
449 | 450 | ||
451 | + | ||
452 | + def SetLabelImageOrientation(self, cam): | ||
453 | + croll = cam.GetRoll() | ||
454 | + if (self.orientation == 'AXIAL'): | ||
455 | + if (croll >= -2 and croll <= 1): | ||
456 | + print "A, R, P, L" | ||
457 | + | ||
458 | + elif(croll > 1 and croll <= 44): | ||
459 | + print "AL, RA, PR, LP" | ||
460 | + | ||
461 | + elif(croll > 44 and croll <= 88): | ||
462 | + print "LA, AR, RP, PL" | ||
463 | + | ||
464 | + elif(croll > 89 and croll <= 91): | ||
465 | + print "L, A, R, P" | ||
466 | + | ||
467 | + elif(croll > 91 and croll <= 135): | ||
468 | + print "LP, AL, RA, PR" | ||
469 | + | ||
470 | + elif(croll > 135 and croll <= 177): | ||
471 | + print "PL, LA, AR, RP" | ||
472 | + | ||
473 | + elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177): | ||
474 | + print "P, L, A, R" | ||
475 | + | ||
476 | + elif(croll >= -177 and croll <= -133): | ||
477 | + print "PR, LP, AL, RA" | ||
478 | + | ||
479 | + elif(croll >= -132 and croll <= -101): | ||
480 | + print "RP, PL, LA, AR" | ||
481 | + | ||
482 | + elif(croll >= -101 and croll <= -87): | ||
483 | + print "R, P, L, A" | ||
484 | + | ||
485 | + elif(croll >= -86 and croll <= -42): | ||
486 | + print "RA, PR, LP, AL" | ||
487 | + | ||
488 | + elif(croll >= -41 and croll <= -2): | ||
489 | + print "AR, RP, PL, LA" | ||
490 | + | ||
491 | + | ||
492 | + | ||
450 | def OnSpinClick(self, evt, obj): | 493 | def OnSpinClick(self, evt, obj): |
451 | evt.StartSpin() | 494 | evt.StartSpin() |
452 | 495 | ||
@@ -480,14 +523,14 @@ class Viewer(wx.Panel): | @@ -480,14 +523,14 @@ class Viewer(wx.Panel): | ||
480 | else: | 523 | else: |
481 | values = [_('R'), _('L'), _('T'), _('B')] | 524 | values = [_('R'), _('L'), _('T'), _('B')] |
482 | 525 | ||
483 | - left_text = vtku.TextZero() | 526 | + left_text = self.left_text = vtku.TextZero() |
484 | left_text.ShadowOff() | 527 | left_text.ShadowOff() |
485 | left_text.SetColour(colour) | 528 | left_text.SetColour(colour) |
486 | left_text.SetPosition(const.TEXT_POS_VCENTRE_LEFT) | 529 | left_text.SetPosition(const.TEXT_POS_VCENTRE_LEFT) |
487 | left_text.SetVerticalJustificationToCentered() | 530 | left_text.SetVerticalJustificationToCentered() |
488 | left_text.SetValue(values[0]) | 531 | left_text.SetValue(values[0]) |
489 | 532 | ||
490 | - right_text = vtku.TextZero() | 533 | + right_text = self.right_text = vtku.TextZero() |
491 | right_text.ShadowOff() | 534 | right_text.ShadowOff() |
492 | right_text.SetColour(colour) | 535 | right_text.SetColour(colour) |
493 | right_text.SetPosition(const.TEXT_POS_VCENTRE_RIGHT_ZERO) | 536 | right_text.SetPosition(const.TEXT_POS_VCENTRE_RIGHT_ZERO) |
@@ -495,14 +538,14 @@ class Viewer(wx.Panel): | @@ -495,14 +538,14 @@ class Viewer(wx.Panel): | ||
495 | right_text.SetJustificationToRight() | 538 | right_text.SetJustificationToRight() |
496 | right_text.SetValue(values[1]) | 539 | right_text.SetValue(values[1]) |
497 | 540 | ||
498 | - up_text = vtku.TextZero() | 541 | + up_text = self.up_text = vtku.TextZero() |
499 | up_text.ShadowOff() | 542 | up_text.ShadowOff() |
500 | up_text.SetColour(colour) | 543 | up_text.SetColour(colour) |
501 | up_text.SetPosition(const.TEXT_POS_HCENTRE_UP) | 544 | up_text.SetPosition(const.TEXT_POS_HCENTRE_UP) |
502 | up_text.SetJustificationToCentered() | 545 | up_text.SetJustificationToCentered() |
503 | up_text.SetValue(values[2]) | 546 | up_text.SetValue(values[2]) |
504 | 547 | ||
505 | - down_text = vtku.TextZero() | 548 | + down_text = self.down_text = vtku.TextZero() |
506 | down_text.ShadowOff() | 549 | down_text.ShadowOff() |
507 | down_text.SetColour(colour) | 550 | down_text.SetColour(colour) |
508 | down_text.SetPosition(const.TEXT_POS_HCENTRE_DOWN_ZERO) | 551 | down_text.SetPosition(const.TEXT_POS_HCENTRE_DOWN_ZERO) |
@@ -520,6 +563,131 @@ class Viewer(wx.Panel): | @@ -520,6 +563,131 @@ class Viewer(wx.Panel): | ||
520 | self.slice_data.renderer.AddActor(up_text.actor) | 563 | self.slice_data.renderer.AddActor(up_text.actor) |
521 | self.slice_data.renderer.AddActor(down_text.actor) | 564 | self.slice_data.renderer.AddActor(down_text.actor) |
522 | 565 | ||
566 | + def RenderTextDirection(self, directions): | ||
567 | + self.up_text.SetValue(directions[0]) | ||
568 | + self.right_text.SetValue(directions[3]) | ||
569 | + self.down_text.SetValue(directions[2]) | ||
570 | + self.left_text.SetValue(directions[1]) | ||
571 | + self.interactor.Render() | ||
572 | + | ||
573 | + | ||
574 | + def UpdateTextDirection(self, cam): | ||
575 | + croll = cam.GetRoll() | ||
576 | + if (self.orientation == 'AXIAL'): | ||
577 | + | ||
578 | + if (croll >= -2 and croll <= 1): | ||
579 | + self.RenderTextDirection(["A", "R", "P", "L"]) | ||
580 | + | ||
581 | + elif(croll > 1 and croll <= 44): | ||
582 | + self.RenderTextDirection(["AL", "RA", "PR", "LP"]) | ||
583 | + | ||
584 | + elif(croll > 44 and croll <= 88): | ||
585 | + self.RenderTextDirection(["LA", "AR", "RP", "PL"]) | ||
586 | + | ||
587 | + elif(croll > 89 and croll <= 91): | ||
588 | + self.RenderTextDirection(["L", "A", "R", "P"]) | ||
589 | + | ||
590 | + elif(croll > 91 and croll <= 135): | ||
591 | + self.RenderTextDirection(["LP", "AL", "RA", "PR"]) | ||
592 | + | ||
593 | + elif(croll > 135 and croll <= 177): | ||
594 | + self.RenderTextDirection(["PL", "LA", "AR", "RP"]) | ||
595 | + | ||
596 | + elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177): | ||
597 | + self.RenderTextDirection(["P", "L", "A", "R"]) | ||
598 | + | ||
599 | + elif(croll >= -177 and croll <= -133): | ||
600 | + self.RenderTextDirection(["PR", "LP", "AL", "RA"]) | ||
601 | + | ||
602 | + elif(croll >= -132 and croll <= -101): | ||
603 | + self.RenderTextDirection(["RP", "PL", "LA", "AR"]) | ||
604 | + | ||
605 | + elif(croll >= -101 and croll <= -87): | ||
606 | + self.RenderTextDirection(["R", "P", "L", "A"]) | ||
607 | + | ||
608 | + elif(croll >= -86 and croll <= -42): | ||
609 | + self.RenderTextDirection(["RA", "PR", "LP", "AL"]) | ||
610 | + | ||
611 | + elif(croll >= -41 and croll <= -2): | ||
612 | + self.RenderTextDirection(["AR", "RP", "PL", "LA"]) | ||
613 | + | ||
614 | + elif(self.orientation == "CORONAL"): | ||
615 | + | ||
616 | + if (croll >= -2 and croll <= 1): | ||
617 | + self.RenderTextDirection(["S", "R", "I", "L"]) | ||
618 | + | ||
619 | + elif(croll > 1 and croll <= 44): | ||
620 | + self.RenderTextDirection(["SL", "RS", "IR", "LI"]) | ||
621 | + | ||
622 | + elif(croll > 44 and croll <= 88): | ||
623 | + self.RenderTextDirection(["LS", "SR", "RI", "L"]) | ||
624 | + | ||
625 | + elif(croll > 89 and croll <= 91): | ||
626 | + self.RenderTextDirection(["L", "S", "R", "I"]) | ||
627 | + | ||
628 | + elif(croll > 91 and croll <= 135): | ||
629 | + self.RenderTextDirection(["LI", "SL", "RS", "IR"]) | ||
630 | + | ||
631 | + elif(croll > 135 and croll <= 177): | ||
632 | + self.RenderTextDirection(["IL", "LS", "SR", "RI"]) | ||
633 | + | ||
634 | + elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177): | ||
635 | + self.RenderTextDirection(["I", "L", "S", "R"]) | ||
636 | + | ||
637 | + elif(croll >= -177 and croll <= -133): | ||
638 | + self.RenderTextDirection(["IR", "LI", "SL", "RS"]) | ||
639 | + | ||
640 | + elif(croll >= -132 and croll <= -101): | ||
641 | + self.RenderTextDirection(["RI", "IL", "LS", "SR"]) | ||
642 | + | ||
643 | + elif(croll >= -101 and croll <= -87): | ||
644 | + self.RenderTextDirection(["R", "I", "L", "S"]) | ||
645 | + | ||
646 | + elif(croll >= -86 and croll <= -42): | ||
647 | + self.RenderTextDirection(["RS", "IR", "LI", "SL"]) | ||
648 | + | ||
649 | + elif(croll >= -41 and croll <= -2): | ||
650 | + self.RenderTextDirection(["SR", "RI", "IL", "LS"]) | ||
651 | + | ||
652 | + elif(self.orientation == "SAGITAL"): | ||
653 | + | ||
654 | + if (croll >= -2 and croll <= 1): | ||
655 | + self.RenderTextDirection(["A", "S", "P", "I"]) | ||
656 | + | ||
657 | + elif(croll > 1 and croll <= 44): | ||
658 | + self.RenderTextDirection(["AI", "SA", "PS", "IP"]) | ||
659 | + | ||
660 | + elif(croll > 44 and croll <= 88): | ||
661 | + self.RenderTextDirection(["IA", "AS", "SP", "PI"]) | ||
662 | + | ||
663 | + elif(croll > 89 and croll <= 91): | ||
664 | + self.RenderTextDirection(["I", "A", "S", "P"]) | ||
665 | + | ||
666 | + elif(croll > 91 and croll <= 135): | ||
667 | + self.RenderTextDirection(["IP", "AI", "SA", "PS"]) | ||
668 | + | ||
669 | + elif(croll > 135 and croll <= 177): | ||
670 | + self.RenderTextDirection(["PI", "IA", "AS", "SP"]) | ||
671 | + | ||
672 | + elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177): | ||
673 | + self.RenderTextDirection(["P", "I", "A", "S"]) | ||
674 | + | ||
675 | + elif(croll >= -177 and croll <= -133): | ||
676 | + self.RenderTextDirection(["PS", "IP", "AI", "SA"]) | ||
677 | + | ||
678 | + elif(croll >= -132 and croll <= -101): | ||
679 | + self.RenderTextDirection(["SP", "PI", "IA", "AS"]) | ||
680 | + | ||
681 | + elif(croll >= -101 and croll <= -87): | ||
682 | + self.RenderTextDirection(["S", "P", "I", "A"]) | ||
683 | + | ||
684 | + elif(croll >= -86 and croll <= -42): | ||
685 | + self.RenderTextDirection(["SA", "PS", "IP", "AI"]) | ||
686 | + | ||
687 | + elif(croll >= -41 and croll <= -2): | ||
688 | + self.RenderTextDirection(["AS", "SP", "PI", "IA"]) | ||
689 | + | ||
690 | + | ||
523 | def Reposition(self, slice_data): | 691 | def Reposition(self, slice_data): |
524 | """ | 692 | """ |
525 | Based on code of method Zoom in the | 693 | Based on code of method Zoom in the |