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

Method Execute

Interaction/Image/vtkImageViewer2.cxx:456–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454 static vtkImageViewer2Callback* New() { return new vtkImageViewer2Callback; }
455
456 void Execute(vtkObject* caller, unsigned long event, void* vtkNotUsed(callData)) override
457 {
458 if (this->IV->GetInput() == nullptr)
459 {
460 return;
461 }
462
463 // Reset
464
465 if (event == vtkCommand::ResetWindowLevelEvent)
466 {
467 this->IV->GetInputAlgorithm()->UpdateWholeExtent();
468 double* range = this->IV->GetInput()->GetScalarRange();
469 this->IV->SetColorWindow(range[1] - range[0]);
470 this->IV->SetColorLevel(0.5 * (range[1] + range[0]));
471 this->IV->Render();
472 return;
473 }
474
475 // Start
476
477 if (event == vtkCommand::StartWindowLevelEvent)
478 {
479 this->InitialWindow = this->IV->GetColorWindow();
480 this->InitialLevel = this->IV->GetColorLevel();
481 return;
482 }
483
484 // Adjust the window level here
485
486 vtkInteractorStyleImage* isi = static_cast<vtkInteractorStyleImage*>(caller);
487
488 const int* size = this->IV->GetRenderWindow()->GetSize();
489 double window = this->InitialWindow;
490 double level = this->InitialLevel;
491
492 // Compute normalized delta
493
494 double dx = 4.0 *
495 (isi->GetWindowLevelCurrentPosition()[0] - isi->GetWindowLevelStartPosition()[0]) / size[0];
496 double dy = 4.0 *
497 (isi->GetWindowLevelStartPosition()[1] - isi->GetWindowLevelCurrentPosition()[1]) / size[1];
498
499 // Scale by current values
500
501 if (fabs(window) > 0.01)
502 {
503 dx = dx * window;
504 }
505 else
506 {
507 dx = dx * (window < 0 ? -0.01 : 0.01);
508 }
509 if (fabs(level) > 0.01)
510 {
511 dy = dy * level;
512 }
513 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