Hi.<br><a href="http://devsample.org/index.php">http://devsample.org/index.php</a> here is a sample for Dicom for C++. <span id="result_box" class="short_text"><span style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);" title="">I rewrote it as follows.<br>
<br>public class VtkObserverMouseMove<br>ššššššš {<br>ššššššššššš protected vtkImageViewer2 m_pImageViewer;<br>ššššššššššš protected vtkRenderWindowInteractor m_pIren;<br>ššššššššššš protected vtkPointPicker m_pPicker;<br>
ššššššššššš protected vtkDICOMImageReader m_pDICOMImageReader;<br>ššššššššššš protected Form1 m_pForm;<br>ššššššššššš public VtkObserverMouseMove(vtkImageViewer2 pImageViewer, vtkRenderWindowInteractor pIren, vtkPointPicker pPicker, vtkDICOMImageReader pDICOMImageReader,Form1 pForm)<br>
ššššššššššš {<br>ššššššššššššššš m_pImageViewer = pImageViewer;<br>ššššššššššššššš m_pIren = pIren;<br>ššššššššššššššš m_pPicker = pPicker;<br>ššššššššššššššš m_pDICOMImageReader = pDICOMImageReader;<br>ššššššššššššššš m_pForm = pForm;<br>
<br>ššššššššššš }<br>ššššššššššš public void MouseClick(vtkObject caller, uint eventId, object clientData, IntPtr callData)<br>ššššššššššš {<br>ššššššššššššššš if (m_pPicker.Pick(m_pIren.GetEventPosition()[0],<br>šššššššššššššššššššššššš m_pIren.GetEventPosition()[1],<br>
šššššššššššššššššššššššš 0,š // always zero.<br>šššššššššššššššššššššššš m_pImageViewer.GetRenderer()) == 0)<br>ššššššššššššššš {<br>ššššššššššššššššššš m_pForm.ClickIntensivity = 0;//textbox in winform<br>ššššššššššššššššššš m_pForm.ClickXY[0] = 0;</span></span><span id="result_box" class="short_text"><span style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);" title="">//textbox in winform</span></span><br>
<span id="result_box" class="short_text"><span style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);" title="">ššššššššššššššššššš m_pForm.ClickXY[1] = 0;</span></span><span id="result_box" class="short_text"><span style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);" title="">//textbox in winform</span></span><br>
<span id="result_box" class="short_text"><span style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);" title="">ššššššššššššššššššš m_pForm.UpdateTXT();<br>ššššššššššššššššššš return;<br>ššššššššššššššš }<br>ššššššššššššššš // Get the mapped position of the mouse using the picker.<br>
ššššššššššššššš double[] ptMapped = new double [3];<br>ššššššššššššššš ptMapped = m_pPicker.GetMapperPosition();<br><br>ššššššššššššššš // We have to manually set the physical z-coordinate which requires<br>ššššššššššššššš // us to get the volume spacing.<br>
ššššššššššššššš double[] dSpacing = new double[3];<br>ššššššššššššššš dSpacing = m_pImageViewer.GetInput().GetSpacing();<br>ššššššššššššššš ptMapped[2] = m_pImageViewer.GetSlice() * dSpacing[2];<br><br>ššššššššššššššš // get a shortcut to the pixel data.<br>
ššššššššššššššš vtkImageData pImageData = m_pImageViewer.GetInput();<br><br>ššššššššššššššš // Get the volume index within the entire volume now.<br>ššššššššššššššš int nVolIdx = pImageData.FindPoint(ptMapped);<br>ššššššššššššššš int ScalarSize= pImageData.GetScalarSize();<br>
ššššššššššššššš <br>ššššššššššššššš if(pImageData.GetNumberOfScalarComponents()== 1)<br>ššššššššššššššš {<br>ššššššššššššššššššš // We have to handle different number of scalar components.<br>ššššššššššššššššššš // Get a shortcut to the raw pixel data. This should be further<br>
ššššššššššššššššššš // updated to check if your data is signed or not, but for this<br>ššššššššššššššššššš // example we&#39;ll just assume it&#39;s unsigned. You should also check<br>ššššššššššššššššššš // the type of your data too (unsigned char, unsigned short, etc).<br>
ššššššššššššššššššš IntPtr pPix = pImageData.GetScalarPointer();<br>ššššššššššššššššššš Int16 PixelValue = (Int16)Marshal.ReadInt32(pPix, ScalarSize * nVolIdx);<br>ššššššššššššššššššš m_pForm.ClickIntensivity = Convert.ToDouble(PixelValue);<br>
ššššššššššššššššššš m_pForm.ClickXY[0] = ptMapped[0];<br>ššššššššššššššššššš m_pForm.ClickXY[1] = ptMapped[1];<br>ššššššššššššššššššš m_pForm.UpdateTXT();<br>ššššššššššššššš }<br>ššššššššššš }<br>ššššššššššš public void MouseMove(vtkObject caller, uint eventId, object clientData, IntPtr callData)<br>
ššššššššššš {<br>ššššššššššššššš if (m_pPicker.Pick(m_pIren.GetEventPosition()[0],<br>šššššššššššššššššššššššš m_pIren.GetEventPosition()[1],<br>šššššššššššššššššššššššš 0,š // always zero.<br>šššššššššššššššššššššššš m_pImageViewer.GetRenderer()) == 0)<br>
ššššššššššššššš {<br>ššššššššššššššššššš m_pForm.ClickIntensivity = 0;<br>ššššššššššššššššššš m_pForm.ClickXY[0] = 0;<br>ššššššššššššššššššš m_pForm.ClickXY[1] = 0;<br>ššššššššššššššššššš m_pForm.UpdateTXT();<br>ššššššššššššššššššš return;<br>
ššššššššššššššš }<br>ššššššššššššššš // Get the mapped position of the mouse using the picker.<br>ššššššššššššššš double[] ptMapped = new double [3];<br>ššššššššššššššš ptMapped = m_pPicker.GetMapperPosition();<br><br>ššššššššššššššš // We have to manually set the physical z-coordinate which requires<br>
ššššššššššššššš // us to get the volume spacing.<br>ššššššššššššššš double[] dSpacing = new double[3];<br>ššššššššššššššš dSpacing = m_pImageViewer.GetInput().GetSpacing();<br>ššššššššššššššš ptMapped[2] = m_pImageViewer.GetSlice() * dSpacing[2];<br>
<br>ššššššššššššššš // get a shortcut to the pixel data.<br>ššššššššššššššš vtkImageData pImageData = m_pImageViewer.GetInput();<br><br>ššššššššššššššš // Get the volume index within the entire volume now.<br>ššššššššššššššš int nVolIdx = pImageData.FindPoint(ptMapped);<br>
ššššššššššššššš int ScalarSize= pImageData.GetScalarSize();<br>ššššššššššššššš <br>ššššššššššššššš if(pImageData.GetNumberOfScalarComponents()== 1)<br>ššššššššššššššš {<br>ššššššššššššššššššš // We have to handle different number of scalar components.<br>
ššššššššššššššššššš // Get a shortcut to the raw pixel data. This should be further<br>ššššššššššššššššššš // updated to check if your data is signed or not, but for this<br>ššššššššššššššššššš // example we&#39;ll just assume it&#39;s unsigned. You should also check<br>
ššššššššššššššššššš // the type of your data too (unsigned char, unsigned short, etc).<br>ššššššššššššššššššš IntPtr pPix = pImageData.GetScalarPointer();<br>ššššššššššššššššššš Int16 PixelValue = (Int16)Marshal.ReadInt32(pPix, ScalarSize * nVolIdx);<br>
ššššššššššššššššššš m_pForm.ClickIntensivity = Convert.ToDouble(PixelValue);<br>ššššššššššššššššššš m_pForm.ClickXY[0] = ptMapped[0];<br>ššššššššššššššššššš m_pForm.ClickXY[1] = ptMapped[1];<br>ššššššššššššššššššš m_pForm.UpdateTXT();<br>
ššššššššššššššš }<br>ššššššššššš }<br>ššššššš }<br>ššššššš public Form1()<br>ššššššš {<br>ššššššššššš InitializeComponent();<br>ššššššššššš vtkRenderWindow.GlobalWarningDisplayOff();<br>ššššššššššš m_renWin = reWin.GetRenderWindow();<br>
ššššššššššš m_renWin.AddRenderer(m_renderer);<br>ššššššššššš m_iren.SetRenderWindow(m_renWin);<br><br>ššššššššššš m_imageViewer.SetRenderer(m_renderer);<br>ššššššššššš m_imageViewer.SetRenderWindow(m_renWin);<br>ššššššššššš m_imageViewer.GetImageActor().InterpolateOff();<br>
ššššššššššš m_picker.SetTolerance(0.0);<br>ššššššššššš m_iren.SetPicker(m_picker);<br>ššššššššššš Mouse = new VtkObserverMouseMove(m_imageViewer, m_iren, m_picker, m_DicomReader, this);<br><b>ššššššššššš m_iren.AddObserver((uint)EventIds.LeftButtonPressEvent, new vtkDotNetCallback(Mouse.MouseClick));<br>
ššššššššššš m_iren.AddObserver((uint)EventIds.MouseMoveEvent, new vtkDotNetCallback(Mouse.MouseMove));</b><br><br>ššššššš }<br></span></span><br><div class="gmail_quote">2010/9/12 myaqua1982 <span dir="ltr">&lt;<a href="mailto:myaqua1982@163.com">myaqua1982@163.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



<div style="font-family: verdana; font-size: 10pt;">
<div><font size="2" face="Verdana">Hi all,</font></div>
<div>
<div><font color="#000080">Now I use vtk inšthe dot net entironment . I want 
to select the coordinate of point.šCaculate the distance between two points 
and the angles in the 3D entironment .Some of them suggested me tošuse the 
class called vtkDotNetcallback. But I do not know how to use it. I have search 
in the internet, but there is little information about the class. </font></div>
<div><font color="#000080">Is there anyone who have used it before? Or have 
caculate distance and angle, please give me some advice? 
Thanks!</font></div></div>
<div><font size="2" face="Verdana"></font>š</div>
<div align="left"><font size="2" color="#c0c0c0" face="Verdana">2010-09-12 
</font></div><font size="2" face="Verdana">
<hr style="width: 122px; min-height: 2px;" align="left" size="2">

<div><font size="2" color="#c0c0c0" face="Verdana"><span>myaqua1982</span> 
</font></div></font></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>๓ ๕ืมึลฮษลอ,<br>แฮฤาลส.<br>Best regards, Andrew<br>