------------------------------------------------------------------------------ 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.
| 590 | // also use negative numbers, i.e. -1 will return the last image, |
| 591 | // -2 will return the second-to-last image, etc. |
| 592 | void 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(); |
no test coverage detected