<p style="margin:0;padding:0;" align="left">Hi Ken,<br /><br />Maybe this can help you<br />==&gt;&nbsp; http://devsample.org/index.php?option=com_content&amp;task=view&amp;id=48&amp;Itemid=27<br /><br />Bye<br /></p> <br /> <br /> <br /><br /><blockquote style="border-left: 2px solid #ff0000; padding-left: 5px; margin-left: 5px">&gt; Message du 01/05/08 23:41<br />&gt; De : &quot;Ken Urish&quot; <br />&gt; A : vtkusers@vtk.org<br />&gt; Copie &agrave; : <br />&gt; Objet : [vtkusers] ImageReslice question - Grad student in need of        graduation!<br />&gt; <br />&gt; Help!<br />&gt; <br />&gt; Ive been stuck on this for a while now. I am viewing a 3d dicom image<br />&gt; slice by slice based off teh the &quot;ImageReslice1.cxx&quot; example with teh<br />&gt; imageReslice class.<br />&gt; I am trying to pick 3d points on the image. I can pick x,y points<br />&gt; fine. BUt I have no way to figure out where I am on teh z-axis.<br />&gt; <br />&gt; Ive been having trouble so Ive just been trying to get the program to<br />&gt; output the z-slice I am on when I hit a right mouse click. It give me<br />&gt; a number that does not change and is incorrect.<br />&gt; <br />&gt; I threw an actor into the callback to see if I could call &quot;GetZSlice&quot;<br />&gt; but this always gives me a &quot;0&quot;. Similarly if I try to see my bounds or<br />&gt; set bounds off the actor, nothing works. Ive lost a week on this<br />&gt; really simple step and it driving me up the wall.<br />&gt; <br />&gt; <br />&gt; Thanks<br />&gt; --Ken--<br />&gt; <br />&gt; <br />&gt; The code for the callback is below.<br />&gt; <br />&gt; <br />&gt; // The mouse motion callback, to turn &quot;Slicing&quot; on and off<br />&gt; class vtkImageInteractionCallback : public vtkCommand<br />&gt; {<br />&gt; public:<br />&gt; <br />&gt;   static vtkImageInteractionCallback *New() {<br />&gt;     return new vtkImageInteractionCallback; };<br />&gt; <br />&gt;   vtkImageInteractionCallback() {<br />&gt;     this-&gt;Slicing = 0;<br />&gt;     this-&gt;ImageReslice = 0;<br />&gt;     this-&gt;Interactor = 0; };<br />&gt; <br />&gt;   void SetImageReslice(vtkImageReslice *reslice) {<br />&gt;     this-&gt;ImageReslice = reslice; };<br />&gt; <br />&gt;  void SetACtor(vtkImageActor *actor) {<br />&gt;      this-&gt;Actor = actor; };<br />&gt; <br />&gt;   vtkImageReslice *GetImageReslice() {<br />&gt;     return this-&gt;ImageReslice; };<br />&gt; <br />&gt;   vtkImageActor *GetImageActor() {<br />&gt;     return this-&gt;Actor; };<br />&gt; <br />&gt; <br />&gt;   void SetInteractor(vtkRenderWindowInteractor *interactor) {<br />&gt;     this-&gt;Interactor = interactor; };<br />&gt; <br />&gt;   vtkRenderWindowInteractor *GetInteractor() {<br />&gt;     return this-&gt;Interactor; };<br />&gt; <br />&gt;   virtual void Execute(vtkObject *, unsigned long event, void *)<br />&gt;     {<br />&gt;     vtkRenderWindowInteractor *interactor = this-&gt;GetInteractor();<br />&gt; <br />&gt;     int lastPos[2];<br />&gt;     interactor-&gt;GetLastEventPosition(lastPos);<br />&gt;     int currPos[2];<br />&gt;     interactor-&gt;GetEventPosition(currPos);<br />&gt; <br />&gt;     if (event == vtkCommand::LeftButtonPressEvent)<br />&gt;       {<br />&gt;       this-&gt;Slicing = 1;<br />&gt;       }<br />&gt;     else if (event == vtkCommand::LeftButtonReleaseEvent)<br />&gt;       {<br />&gt;       this-&gt;Slicing = 0;<br />&gt;       }<br />&gt;     else if (event == vtkCommand::MouseMoveEvent)<br />&gt;       {<br />&gt;       if (this-&gt;Slicing)<br />&gt;         {<br />&gt;         vtkImageReslice *reslice = this-&gt;ImageReslice;<br />&gt; <br />&gt;         // Increment slice position by deltaY of mouse<br />&gt;         int deltaY = lastPos[1] - currPos[1];<br />&gt; <br />&gt;         reslice-&gt;GetOutput()-&gt;UpdateInformation();<br />&gt;         double sliceSpacing = reslice-&gt;GetOutput()-&gt;GetSpacing()[2];<br />&gt;         vtkMatrix4x4 *matrix = reslice-&gt;GetResliceAxes();<br />&gt;         // move the center point that we are slicing through<br />&gt;         double point[4];<br />&gt;         double center[4];<br />&gt;         point[0] = 0.0;<br />&gt;         point[1] = 0.0;<br />&gt;         point[2] = sliceSpacing * deltaY;<br />&gt;         point[3] = 1.0;<br />&gt;         matrix-&gt;MultiplyPoint(point, center);<br />&gt;         matrix-&gt;SetElement(0, 3, center[0]);<br />&gt;         matrix-&gt;SetElement(1, 3, center[1]);<br />&gt;         matrix-&gt;SetElement(2, 3, center[2]);<br />&gt;         int z = actor-&gt;GetZSlice();<br />&gt;         interactor-&gt;Render();<br />&gt;         }<br />&gt;       else<br />&gt;         {<br />&gt;         vtkInteractorStyle *style = vtkInteractorStyle::SafeDownCast(<br />&gt;           interactor-&gt;GetInteractorStyle());<br />&gt;         if (style)<br />&gt;           {<br />&gt;           style-&gt;OnMouseMove();<br />&gt;           }<br />&gt;         }<br />&gt;       }<br />&gt;     };<br />&gt; _______________________________________________<br />&gt; This is the private VTK discussion list.<br />&gt; Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<br />&gt; Follow this link to subscribe/unsubscribe:<br />&gt; http://www.vtk.org/mailman/listinfo/vtkusers<br />&gt; <br />&gt; <br /></blockquote>