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

Method WindowLevel

Interaction/Style/vtkInteractorStyleImage.cxx:446–513  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

444
445//------------------------------------------------------------------------------
446void vtkInteractorStyleImage::WindowLevel()
447{
448 vtkRenderWindowInteractor* rwi = this->Interactor;
449
450 this->WindowLevelCurrentPosition[0] = rwi->GetEventPosition()[0];
451 this->WindowLevelCurrentPosition[1] = rwi->GetEventPosition()[1];
452
453 if (this->HandleObservers && this->HasObserver(vtkCommand::WindowLevelEvent))
454 {
455 this->InvokeEvent(vtkCommand::WindowLevelEvent, this);
456 }
457 else if (this->CurrentImageProperty)
458 {
459 const int* size = this->CurrentRenderer->GetSize();
460
461 double window = this->WindowLevelInitial[0];
462 double level = this->WindowLevelInitial[1];
463
464 // Compute normalized delta
465
466 double dx =
467 (this->WindowLevelCurrentPosition[0] - this->WindowLevelStartPosition[0]) * 4.0 / size[0];
468 double dy =
469 (this->WindowLevelStartPosition[1] - this->WindowLevelCurrentPosition[1]) * 4.0 / size[1];
470
471 // Scale by current values
472
473 if (fabs(window) > 0.01)
474 {
475 dx = dx * window;
476 }
477 else
478 {
479 dx = dx * (window < 0 ? -0.01 : 0.01);
480 }
481 if (fabs(level) > 0.01)
482 {
483 dy = dy * level;
484 }
485 else
486 {
487 dy = dy * (level < 0 ? -0.01 : 0.01);
488 }
489
490 // Abs so that direction does not flip
491
492 if (window < 0.0)
493 {
494 dx = -1 * dx;
495 }
496 if (level < 0.0)
497 {
498 dy = -1 * dy;
499 }
500
501 // Compute new window level
502
503 double newWindow = dx + window;

Callers 1

OnMouseMoveMethod · 0.95

Calls 7

HasObserverMethod · 0.80
InvokeEventMethod · 0.80
RenderMethod · 0.65
maxFunction · 0.50
GetSizeMethod · 0.45
SetColorWindowMethod · 0.45
SetColorLevelMethod · 0.45

Tested by

no test coverage detected