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

Method SetCurrentImageNumber

Interaction/Style/vtkInteractorStyleImage.cxx:592–659  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This is a way of dealing with images as if they were layers. It looks through the renderer's list of props and sets the interactor ivars from the Nth image that it finds. You can also use negative numbers, i.e. -1 will return the last image, -2 will return the second-to-last image, etc.

Source from the content-addressed store, hash-verified

590// also use negative numbers, i.e. -1 will return the last image,
591// -2 will return the second-to-last image, etc.
592void vtkInteractorStyleImage::SetCurrentImageNumber(int i)
593{
594 this->CurrentImageNumber = i;
595
596 if (!this->CurrentRenderer)
597 {
598 return;
599 }
600
601 vtkPropCollection* props = this->CurrentRenderer->GetViewProps();
602 vtkProp* prop = nullptr;
603 vtkAssemblyPath* path;
604 vtkImageSlice* imageProp = nullptr;
605 vtkCollectionSimpleIterator pit;
606
607 for (int k = 0; k < 2; k++)
608 {
609 int j = 0;
610 for (props->InitTraversal(pit); (prop = props->GetNextProp(pit));)
611 {
612 bool foundImageProp = false;
613 for (prop->InitPathTraversal(); (path = prop->GetNextPath());)
614 {
615 vtkProp* tryProp = path->GetLastNode()->GetViewProp();
616 imageProp = vtkImageSlice::SafeDownCast(tryProp);
617 if (imageProp)
618 {
619 if (j == i && imageProp->GetPickable())
620 {
621 foundImageProp = true;
622 break;
623 }
624 imageProp = nullptr;
625 j++;
626 }
627 }
628 if (foundImageProp)
629 {
630 break;
631 }
632 }
633 if (i < 0)
634 {
635 i += j;
636 }
637 }
638
639 vtkImageProperty* property = nullptr;
640 if (imageProp)
641 {
642 property = imageProp->GetProperty();
643 }
644
645 if (property != this->CurrentImageProperty)
646 {
647 if (this->CurrentImageProperty)
648 {
649 this->CurrentImageProperty->Delete();

Callers 1

StartWindowLevelMethod · 0.95

Calls 9

GetNextPropMethod · 0.80
GetLastNodeMethod · 0.80
DeleteMethod · 0.65
InitTraversalMethod · 0.45
InitPathTraversalMethod · 0.45
GetNextPathMethod · 0.45
GetViewPropMethod · 0.45
GetPropertyMethod · 0.45
RegisterMethod · 0.45

Tested by

no test coverage detected