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'll just assume it'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'll just assume it'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"><<a href="mailto:myaqua1982@163.com">myaqua1982@163.com</a>></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 inthe 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 touse 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>