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

Method Execute

Interaction/Image/vtkImageViewer.cxx:88–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 static vtkImageViewerCallback* New() { return new vtkImageViewerCallback; }
87
88 void Execute(vtkObject* caller, unsigned long event, void* vtkNotUsed(callData)) override
89 {
90 if (this->IV->GetInput() == nullptr)
91 {
92 return;
93 }
94
95 // Reset
96
97 if (event == vtkCommand::ResetWindowLevelEvent)
98 {
99 this->IV->GetInputAlgorithm()->UpdateWholeExtent();
100 double* range = this->IV->GetInput()->GetScalarRange();
101 this->IV->SetColorWindow(range[1] - range[0]);
102 this->IV->SetColorLevel(0.5 * (range[1] + range[0]));
103 this->IV->Render();
104 return;
105 }
106
107 // Start
108
109 if (event == vtkCommand::StartWindowLevelEvent)
110 {
111 this->InitialWindow = this->IV->GetColorWindow();
112 this->InitialLevel = this->IV->GetColorLevel();
113 return;
114 }
115
116 // Adjust the window level here
117
118 vtkInteractorStyleImage* isi = static_cast<vtkInteractorStyleImage*>(caller);
119
120 const int* size = this->IV->GetRenderWindow()->GetSize();
121 double window = this->InitialWindow;
122 double level = this->InitialLevel;
123
124 // Compute normalized delta
125
126 double dx = 4.0 *
127 (isi->GetWindowLevelCurrentPosition()[0] - isi->GetWindowLevelStartPosition()[0]) / size[0];
128 double dy = 4.0 *
129 (isi->GetWindowLevelStartPosition()[1] - isi->GetWindowLevelCurrentPosition()[1]) / size[1];
130
131 // Scale by current values
132
133 if (fabs(window) > 0.01)
134 {
135 dx = dx * window;
136 }
137 else
138 {
139 dx = dx * (window < 0 ? -0.01 : 0.01);
140 }
141 if (fabs(level) > 0.01)
142 {
143 dy = dy * level;
144 }
145 else

Callers

nothing calls this directly

Calls 11

GetColorWindowMethod · 0.80
GetColorLevelMethod · 0.80
RenderMethod · 0.65
GetInputMethod · 0.45
UpdateWholeExtentMethod · 0.45
GetInputAlgorithmMethod · 0.45
GetScalarRangeMethod · 0.45
SetColorWindowMethod · 0.45
SetColorLevelMethod · 0.45
GetSizeMethod · 0.45
GetRenderWindowMethod · 0.45

Tested by

no test coverage detected