<div>Hi,David,<br><br>Before I call SetInteractor() or SetInteractorStyle(), 
do I need to explicitly call some specific functions to release the 
current interactor or interactorStyle? Or just let .NET framework to GC 
it automatically.<br><br>Thanks<br>Liu Peng<br><br></div>
 <span>
 </span>
<br>      在2016-03-02,"David Cole" <DLRdave@aol.com> 写道:
        <blockquote id="isReplyContent" style="padding-left:1ex; margin: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
        -----原始邮件-----<br>
        <b>发件人:</b>"David Cole" <DLRdave@aol.com> <br>
        <b>发送时间:</b>2016年03月2日 星期三<br>
        <b>收件人:</b>"Liu_tj" <tjlp@netease.com><br>
        <b>主题:</b>Re: Re: [vtkusers] vtkRenderWindowInteractor.start() crashes in C# application using Activiz<br>
<br>Sure. If you want to use your own interactor, just instantiate it and<br>call SetInteractor on the render window. And if you want your own<br>style, instantiate it and call SetInteractorStyle.<br><br>ActiViz is really just a thin C# wrapper around VTK, so all the usual<br>VTK stuff applies.<br><br><br>HTH,<br>David C.<br><br><br>On Tue, Mar 1, 2016 at 8:52 PM, Liu_tj <<a href="mailto:tjlp@netease.com">tjlp@netease.com</a>> wrote:<br>> Hi, David,<br>><br>> Thanks. You are right. After I remove the instantiation of the interactor,<br>> the code works.<br>><br>> So, if the render window control contains Interactor and InteractorStyle,<br>> what kind of Interactor and interactorStyle it uses? Can we specify them by<br>> ourself if the default Interactor and InteractorStyle can't meet our<br>> requirement?<br>><br>> Thanks<br>> Liu Peng<br>><br>> 在2016-03-01,"David Cole" <<a href="mailto:DLRdave@aol.com">DLRdave@aol.com</a>> 写道:<br>><br>> -----原始邮件-----<br>> 发件人:"David Cole" <<a href="mailto:DLRdave@aol.com">DLRdave@aol.com</a>><br>> 发送时间:2016年03月1日 星期二<br>> 收件人:"Liu_tj" <<a href="mailto:tjlp@netease.com">tjlp@netease.com</a>><br>> 抄送:"vtkusers" <<a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>><br>> 主题:Re: [vtkusers] vtkRenderWindowInteractor.start() crashes in C#<br>> application using Activiz<br>><br>> When using ActiViz .NET, you typically don't need to create your own<br>> interactor object. The render window control contains a RenderWindow,<br>> an Interactor and an InteractorStyle that are all connected to each<br>> other by default. Interactor.Start starts a windows event loop, and is<br>> used by standalone programs not using a UI framework. When you're<br>> using a UI framework, you don't need to call it.<br>><br>> Just remove your instantiation of the interactor, and do not call<br>> Start. If you are using a Windows Forms application to display your<br>> render window control, just show the form, and let the Windows Forms<br>> framework handle your event loop.<br>><br>><br>> HTH,<br>> David C.<br>><br>><br>> On Tue, Mar 1, 2016 at 10:32 AM, Liu_tj <<a href="mailto:tjlp@netease.com">tjlp@netease.com</a>> wrote:<br>>> Hi, VTK guys,<br>>><br>>> I use Activiz 5.8 Open Source edition to display Axial, Sagittal and<br>>> Coronal<br>>> view for DICOM series in WPF application. In the XAML, I add a button and<br>>> a<br>>> vtkRenderWindowControl component. And a method ShowImagePlaneWidget() is<br>>> defined. I just want to click the button then ShowImagePlaneWidget() is<br>>> called, the DICOM series is loaded and displayed. But it does not work and<br>>> the application crashes at vtkRenderWindowInteractor.start().<br>>><br>>> However, the DICOM can be displayed if ShowImagePlaneWidget() is called in<br>>> the Window_Load event handler.<br>>><br>>> What happens? How to fix it? I am working this issue for some time.<br>>><br>>> Below is my code:<br>>><br>>> private void Window_Loaded(object sender, RoutedEventArgs e)<br>>>         {<br>>>            ShowImagePlaneWidget();<br>>>         }<br>>><br>>>         private void btnLoad_Click(object sender, RoutedEventArgs e)<br>>>         {<br>>>            ShowImagePlaneWidget();<br>>>         }<br>>>         private void ShowImagePlaneWidget()<br>>>         {<br>>>             vtkImagePlaneWidget m_imagePlaneWidgetX =<br>>> vtkImagePlaneWidget.New();<br>>>             vtkImagePlaneWidget m_imagePlaneWidgetY =<br>>> vtkImagePlaneWidget.New();<br>>>             vtkImagePlaneWidget m_imagePlaneWidgetZ =<br>>> vtkImagePlaneWidget.New();<br>>>             vtkRenderWindowInteractor m_interactor =<br>>> vtkRenderWindowInteractor.New();<br>>><br>>>             vtkRenderWindow aRenderWindow = renderctrl.RenderWindow;<br>>><br>>>             vtkDICOMImageReader reader = vtkDICOMImageReader.New();<br>>><br>>><br>>> reader.SetDirectoryName(@"C:\Personal\code\ReadDICOMSeries\build\Debug\IMG\Dental_Lossy_Compressed");<br>>>             reader.Update();<br>>><br>>>             int[] dims = new int[3];<br>>>             dims = reader.GetOutput().GetDimensions();<br>>><br>>>             vtkImageCast readerImageCast = vtkImageCast.New();<br>>>             readerImageCast.SetInput((vtkDataObject)reader.GetOutput());<br>>>             //readerImageCast.SetOutputScalarTypeToUnsignedChar();<br>>>             readerImageCast.ClampOverflowOn();<br>>>             readerImageCast.Update();<br>>><br>>>             m_interactor.SetRenderWindow(aRenderWindow);<br>>>             vtkRenderer renderer =<br>>> aRenderWindow.GetRenderers().GetFirstRenderer();<br>>><br>>>             vtkCellPicker picker = vtkCellPicker.New();<br>>>             picker.SetTolerance(0.005);<br>>>             //m_imagePlaneWidgetX.DebugOn();<br>>>             m_imagePlaneWidgetX.SetDefaultRenderer(renderer);<br>>>             PrepareImagePlaneWidget(m_imagePlaneWidgetX,<br>>> readerImageCast.GetOutput(), m_interactor, picker, dims,<br>>> Direction.CORONAL);<br>>>             vtkRenderWindowInteractor tmpint =<br>>> m_imagePlaneWidgetX.GetInteractor();<br>>>             PrepareImagePlaneWidget(m_imagePlaneWidgetY,<br>>> readerImageCast.GetOutput(), m_interactor, picker, dims,<br>>> Direction.SAGITTAL);<br>>>             PrepareImagePlaneWidget(m_imagePlaneWidgetZ,<br>>> readerImageCast.GetOutput(), m_interactor, picker, dims, Direction.AXIAL);<br>>><br>>>             m_interactor.Initialize();<br>>>             m_interactor.Start();<br>>>             aRenderWindow.Render();<br>>>             return;<br>>>         }<br>>><br>>>         private void PrepareImagePlaneWidget(vtkImagePlaneWidget<br>>> planeWidget, vtkImageData data, vtkRenderWindowInteractor interactor,<br>>> vtkCellPicker picker, int[] dimensions, Direction direction)<br>>>         {<br>>>             planeWidget.SetInteractor(interactor);<br>>><br>>>             planeWidget.SetPicker(picker);<br>>>             planeWidget.RestrictPlaneToVolumeOn();<br>>><br>>>             planeWidget.DisplayTextOn();<br>>>             planeWidget.TextureInterpolateOff();<br>>>             planeWidget.SetResliceInterpolateToLinear();<br>>><br>>>             planeWidget.SetInput(data);<br>>><br>>>             switch (direction)<br>>>             {<br>>>                 case Direction.AXIAL:<br>>>                     planeWidget.SetKeyPressActivationValue((sbyte)'z');<br>>>                     planeWidget.SetPlaneOrientationToZAxes();<br>>>                     planeWidget.GetPlaneProperty().SetColor(0.0, 0.0,<br>>> 1.0);<br>>>                     break;<br>>>                 case Direction.CORONAL:<br>>>                     planeWidget.SetKeyPressActivationValue((sbyte)'x');<br>>>                     planeWidget.SetPlaneOrientationToXAxes();<br>>>                     planeWidget.GetPlaneProperty().SetColor(1.0, 0.0,<br>>> 0.0);<br>>>                     break;<br>>>                 case Direction.SAGITTAL:<br>>>                     planeWidget.SetKeyPressActivationValue((sbyte)'y');<br>>>                     planeWidget.SetPlaneOrientationToYAxes();<br>>>                     planeWidget.GetPlaneProperty().SetColor(0.0, 1.0,<br>>> 0.0);<br>>>                     break;<br>>>             }<br>>>             planeWidget.SetSliceIndex(dimensions[(int)direction] / 2);<br>>>             planeWidget.GetTexturePlaneProperty().SetOpacity(1);<br>>><br>>><br>>>             planeWidget.On();<br>>>             planeWidget.InteractionOn();<br>>>         }<br>>><br>>> Thanks<br>>> Liu Peng<br>>><br>>><br>>><br>>><br>>><br>>> _______________________________________________<br>>> Powered by www.kitware.com<br>>><br>>> Visit other Kitware open-source projects at<br>>> http://www.kitware.com/opensource/opensource.html<br>>><br>>> Please keep messages on-topic and check the VTK FAQ at:<br>>> http://www.vtk.org/Wiki/VTK_FAQ<br>>><br>>> Search the list archives at: http://markmail.org/search/?q=vtkusers<br>>><br>>> Follow this link to subscribe/unsubscribe:<br>>> http://public.kitware.com/mailman/listinfo/vtkusers<br>>><br></blockquote><br><br><span title="neteasefooter"><p> </p></span>