MCPcopy Create free account
hub / github.com/Kitware/VTK / WindowLevel

Method WindowLevel

Interaction/Widgets/vtkResliceCursorRepresentation.cxx:680–754  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

678
679//------------------------------------------------------------------------------
680void vtkResliceCursorRepresentation::WindowLevel(double X, double Y)
681{
682 if (!this->Renderer)
683 {
684 return;
685 }
686
687 const int* size = this->Renderer->GetSize();
688 double window = this->InitialWindow;
689 double level = this->InitialLevel;
690
691 // Compute normalized delta
692
693 double dx = 2.0 * (X - this->StartEventPosition[0]) / size[0];
694 double dy = 2.0 * (this->StartEventPosition[1] - Y) / size[1];
695
696 // Scale by current values
697
698 if (fabs(window) > 0.01)
699 {
700 dx = dx * window;
701 }
702 else
703 {
704 dx = dx * (window < 0 ? -0.01 : 0.01);
705 }
706 if (fabs(level) > 0.01)
707 {
708 dy = dy * level;
709 }
710 else
711 {
712 dy = dy * (level < 0 ? -0.01 : 0.01);
713 }
714
715 // Abs so that direction does not flip
716
717 if (window < 0.0)
718 {
719 dx = -1 * dx;
720 }
721 if (level < 0.0)
722 {
723 dy = -1 * dy;
724 }
725
726 // Compute new window level
727
728 double newWindow = dx + window;
729 double newLevel = level - dy;
730
731 if (fabs(newWindow) < 0.01)
732 {
733 newWindow = 0.01 * (newWindow < 0 ? -1 : 1);
734 }
735 if (fabs(newLevel) < 0.01)
736 {
737 newLevel = 0.01 * (newLevel < 0 ? -1 : 1);

Callers

nothing calls this directly

Calls 3

InvertTableMethod · 0.95
GetSizeMethod · 0.45
SetRangeMethod · 0.45

Tested by

no test coverage detected