Hello everyone,
I have a new problem with vtk when i try to get the position of image in the vtkimageviewer2 if i clicked left button.
I set a dicomseries as Input to vtkimageviewer2 ,it works fine
Here is my Code,I only show the input part nothing special
using ITKTOVTKFilterType = itk::ImageToVTKImageFilter;
ITKTOVTKFilterType::Pointer VTKFilter = ITKTOVTKFilterType::New();
VTKFilter->SetInput(reader->GetOutput());
VTKFilter->Update();
vtkSmartPointer imageflip = vtkSmartPointer::New();
imageflip->SetInputData(VTKFilter->GetOutput());
imageflip->SetFilteredAxes(1);//Y
imageflip->Update();
vtkSmartPointer imageViewer = vtkSmartPointer::New();
imageViewer->SetInputConnection(imageflip->GetOutputPort());
And i wrote a interactor and a VtkInteractorStyleImage class to observe my mouse event.also i just show the important part so that You won’t need to read much code.
class myVtkInteractorStyleImage : public vtkInteractorStyleImage
{
public:
static myVtkInteractorStyleImage* New();
vtkTypeMacro(myVtkInteractorStyleImage, vtkInteractorStyleImage);
protected:
vtkImageViewer2* _ImageViewer;
double origin[3];
public:
void SetImageViewer(vtkImageViewer2* imageViewer) {
_ImageViewer = imageViewer;
}
virtual void OnLeftButtonDown() {
//origin[0]= _ImageViewer->GetRenderer()->GetActors()->GetLastActor()->GetOrigin()[0];
origin[1] = _ImageViewer->GetInput()->GetOrigin()[1];
origin[2] = _ImageViewer->GetInput()->GetOrigin()[2];
std::cout << "Renderer Size:" << origin[0] << "," << origin[1] << std::endl;
vtkInteractorStyleImage::OnLeftButtonDown();
}
As i wrote in my code i tried to use like imageViewer->GetInput()->GetOrigin()
but it always return the same value even if i moved the image in render with middle button.
Also i tried to GetActors() because i think the image in render should be a actor.
Then the Programm crash, Here is also a question :
What role does the image play in render? not a Actor?
And How can i get the position of image in the vtkimageviewer2
Any help on this is highly appreciated.
Thanks,