<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hi David,<br><br>&gt; Here is the working code:<br>&gt; 
http://www.vtk.org/Wiki/VTK/Examples/Widgets/Cursor2D<br>&gt; <br>Not if you make the following two changes:<br><br>&nbsp; sphereSource-&gt;SetRadius(1.0);<br><br>&nbsp; cursor-&gt;SetModelBounds(-1,1,-1,1,0,0);<br><br>Then the cursor and the sphere will not have the same center.<br><br>Regards,<br>Xiaofeng<br>
<a href="http://www.xzing.org"></a><br><br><br><br>&gt; Date: Fri, 9 Apr 2010 08:42:09 -0400<br>&gt; Subject: Re: [vtkusers] Why doesn't the intersection of the lines of a         vtkCursor2D not set at the focal point?<br>&gt; From: daviddoria+vtk@gmail.com<br>&gt; To: xf10036@hotmail.com<br>&gt; CC: vtkusers@vtk.org<br>&gt; <br>&gt; On Thu, Apr 8, 2010 at 9:52 PM, Xiaofeng Z &lt;xf10036@hotmail.com&gt; wrote:<br>&gt; &gt; Hi vtkUsers,<br>&gt; &gt;<br>&gt; &gt; The following is a program that place a vtkSphere and a vtkCursor2D in a<br>&gt; &gt; rendering window.&nbsp; My question is why the cursor 2d does not pass the center<br>&gt; &gt; of the sphere, see attached image.<br>&gt; &gt;<br>&gt; &gt; int _tmain(int argc, _TCHAR* argv[])<br>&gt; &gt; {<br>&gt; &gt; &nbsp;&nbsp;&nbsp; // create sphere geometry<br>&gt; &gt; &nbsp;&nbsp;&nbsp; vtkSphereSource *sphere = vtkSphereSource::New();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; sphere-&gt;SetCenter(0.0, 0.0, 0.0);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; sphere-&gt;SetRadius(1.0);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; sphere-&gt;SetThetaResolution(18);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; sphere-&gt;SetPhiResolution(18);<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; // map to graphics library<br>&gt; &gt; &nbsp;&nbsp;&nbsp; vtkPolyDataMapper *map = vtkPolyDataMapper::New();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; map-&gt;SetInput(sphere-&gt;GetOutput());<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; // actor coordinates geometry, properties, transformation<br>&gt; &gt; &nbsp;&nbsp;&nbsp; vtkActor *actor = vtkActor::New();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; actor-&gt;SetMapper(map);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; actor-&gt;GetProperty()-&gt;SetColor(0,0,1); // sphere color blue<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; // renderers and render window<br>&gt; &gt; &nbsp;&nbsp;&nbsp; vtkRenderer *renA = vtkRenderer::New();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; renA-&gt;SetViewport(0.0, 0.0, 1.0, 1.0);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; vtkRenderWindow* win = vtkRenderWindow::New();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; win-&gt;SetSize(300,300);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; win-&gt;AddRenderer(renA);<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; // an interactor<br>&gt; &gt; &nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; iren-&gt;SetRenderWindow(win);<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; renA-&gt;SetBackground(1,1,1); // Background color white<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; renA-&gt;AddActor(actor);<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; // add a 2D cursor to each Renderer<br>&gt; &gt; &nbsp;&nbsp;&nbsp; vtkCursor2D* cursor = vtkCursor2D::New();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; cursor-&gt;SetTranslationMode(1);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; cursor-&gt;SetWrap(1);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; cursor-&gt;SetModelBounds(-0.5, 0.5, -0.5, 0.5, 0.0, 0.0);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; cursor-&gt;SetFocalPoint(0.0, 0.0, 0.0);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; cursor-&gt;AllOff();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; cursor-&gt;AxesOn();<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; mapper-&gt;SetInput(cursor-&gt;GetOutput());<br>&gt; &gt; &nbsp;&nbsp;&nbsp; actor = vtkActor::New();<br>&gt; &gt; &nbsp;&nbsp;&nbsp; actor-&gt;SetMapper(mapper);<br>&gt; &gt; &nbsp;&nbsp;&nbsp; actor-&gt;GetProperty()-&gt;SetColor(1.0, 0.0, 0.0);<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; renA-&gt;AddActor(actor);<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; // render an image (lights and cameras are created automatically)<br>&gt; &gt; &nbsp;&nbsp;&nbsp; win-&gt;Render();<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; iren-&gt;Start();<br>&gt; &gt;<br>&gt; &gt; &nbsp;&nbsp;&nbsp; return 0;<br>&gt; &gt; }<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Xiaofeng Z<br>&gt; <br>&gt; Hi Xiaofeng,<br>&gt; <br>&gt; You need to create a new actor for the cursor:<br>&gt; <br>&gt; i.e. replace this:<br>&gt; <br>&gt; vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>&gt; mapper-&gt;SetInput(cursor-&gt;GetOutput());<br>&gt; actor = vtkActor::New();<br>&gt; actor-&gt;SetMapper(mapper);<br>&gt; <br>&gt; with this:<br>&gt; <br>&gt; vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>&gt; mapper-&gt;SetInput(cursor-&gt;GetOutput());<br>&gt; vtkActor* cursorActor = vtkActor::New();<br>&gt; cursorActor-&gt;SetMapper(mapper);<br>&gt; <br>&gt; and then it works.<br>&gt; <br>&gt; Here is the working code:<br>&gt; http://www.vtk.org/Wiki/VTK/Examples/Widgets/Cursor2D<br>&gt; <br>&gt; Thanks,<br>&gt; <br>&gt; David<br>                                               <br /><hr />Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. <a href='http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2' target='_new'>See how.</a></body>
</html>