[vtkusers] ActiViz | Changing Window Level and Window Width in a RenderWindowControl

Matias Montroull matimontg at gmail.com
Mon Feb 10 19:51:50 EST 2014


I made it work!

     interactor.Initialize() is the key..

Code:

                    vtkImageViewer2 _ImageViewer = vtkImageViewer2.New();
                    vtkDICOMImageReader reader = vtkDICOMImageReader.New();
                    reader.SetFileName(ofdmulti.FileNames[0]);
                    reader.Update();
                    _ImageViewer.SetInputConnection(reader.GetOutputPort());
                    vtkRenderWindow renderWindow =
renderWindowControl1.RenderWindow;

                    vtkRenderWindowInteractor interactor = new
vtkRenderWindowInteractor();

interactor.SetInteractorStyle(vtkInteractorStyleImage.New());
                    _ImageViewer.SetupInteractor(interactor);
                    interactor.Initialize(); //This is ke, if not added
then WW and WL functionality won't work.

                    _ImageViewer.SetRenderWindow(renderWindow);
                    _ImageViewer.Render();


On Mon, Feb 10, 2014 at 9:01 PM, Matias Montroull <matimontg at gmail.com>wrote:

> still no luck..
>
>            vtkDICOMImageReader reader = vtkDICOMImageReader.New();
>                     reader.SetFileName(ofdmulti.FileNames[0]);
>                     reader.Update();
>
>
> _ImageViewer.SetInputConnection(reader.GetOutputPort());
>                     vtkRenderWindow renderWindow =
> renderWindowControl1.RenderWindow;
>                     vtkRenderer ren =
> renderWindow.GetRenderers().GetFirstRenderer();
>                     vtkRenderWindowInteractor interactor =
> renderWindow.GetInteractor();
>                     vtkInteractorStyleImage iteractor_image =
> vtkInteractorStyleImage.New();
>                     interactor.SetInteractorStyle(iteractor_image);
>
> renderWindow.GetInteractor().SetInteractorStyle(iteractor_image);
>                     renderWindow.SetInteractor(interactor);
>
>                     _ImageViewer.SetRenderWindow(renderWindow);
>                     _ImageViewer.SetSlice(0);
>                     _ImageViewer.Render();
>
>
> On Sat, Feb 8, 2014 at 4:17 PM, David Cole <dlrdave at aol.com> wrote:
>
>> Don't do this:
>>
>>     vtkRenderWindowInteractor interactor = vtkRenderWindowInteractor.New(
>> );
>>
>> Do this:
>>
>>    vtkRenderWindowInteractor interactor = renderWindow.GetInteractor();
>>
>> You don't need a new interactor, you just need a new interaction style
>> that you push into the existing interactor.
>>
>>
>> Good luck.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140210/07eb6cec/attachment.html>


More information about the vtkusers mailing list