<div dir="ltr">Hi David,<br><br>Here is the fixed python version of the example you sent.It displays the cursor properly, but I don't know whether the handle widget is connected properly in the pipeline.<br><br><span style="color: rgb(0, 0, 153);">from vtk import*</span><br style="color: rgb(0, 0, 153);">
<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">sphereSource =vtkSphereSource();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">sphereSource.SetCenter(0.0, 0.0, 0.0);</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">sphereSource.SetRadius(5.0);</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#Create a mapper and actor</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">mapper = vtkPolyDataMapper();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">mapper.SetInputConnection(sphereSource.GetOutputPort());</span><br style="color: rgb(0, 0, 153);">
<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">actor = vtkActor();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">actor.SetMapper(mapper);</span><br style="color: rgb(0, 0, 153);">
<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#Create a renderer, render window, and interactor</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderer =vtkRenderer();</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">renderWindow =vtkRenderWindow();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderWindow.AddRenderer(renderer);</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">renderWindowInteractor =vtkRenderWindowInteractor();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderWindowInteractor.SetRenderWindow(renderWindow);</span><br style="color: rgb(0, 0, 153);">
<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#Add the actor to the scene</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderer.AddActor(actor);</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">renderer.SetBackground(0,0,0); # Background color white</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(255, 0, 0);">cursor =vtkCursor2D();</span><br style="color: rgb(255, 0, 0);">
<span style="color: rgb(255, 0, 0);">cursor.SetModelBounds(-10,10,-10,10,0,0)</span><br style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);">cursor.AllOn()</span><br style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);">cursor.OutlineOff()</span><br style="color: rgb(255, 0, 0);">
<span style="color: rgb(255, 0, 0);">cursor.Update();</span><br style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);">cursormapper=vtkPolyDataMapper()</span><br style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);">cursormapper.SetInputConnection(cursor.GetOutputPort())</span><br style="color: rgb(255, 0, 0);">
<span style="color: rgb(255, 0, 0);">cursoractor=vtkActor()</span><br style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);">cursoractor.GetProperty().SetColor(1,1,0)</span><br style="color: rgb(255, 0, 0);">
<span style="color: rgb(255, 0, 0);">cursoractor.SetMapper(cursormapper)</span><br style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);">renderer.AddActor(cursoractor);</span><br style="color: rgb(255, 0, 0);">
<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">handleRep =vtkPointHandleRepresentation2D();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">handleRep.SetDisplayPosition(cursoractor.GetPosition());</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">handleRep.ActiveRepresentationOn();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">handleRep.SetCursorShape(cursor.GetOutput());</span><br style="color: rgb(0, 0, 153);">
<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">handleWidget =vtkHandleWidget();</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">handleWidget.SetInteractor(renderWindowInteractor);</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">handleWidget.SetRepresentation(handleRep);</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">handleWidget.On();</span><br style="color: rgb(0, 0, 153);">
<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">#Render and interact</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">renderWindow.Render();</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">renderWindowInteractor.Start();</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><br>If you come do any changes, do let me know I will add it to the python examples section.<br>
<br>Thanks<br><br>Jothy<br><br><div class="gmail_quote">On Sat, Mar 27, 2010 at 10:02 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="gmail_quote"><div><div></div><div class="h5">On Thu, Mar 25, 2010 at 8:10 AM, Jothybasu K Selvaraj <span dir="ltr"><<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">Hi all,<br><br>How to set different colours to different axis in vtkCursor3D?<br><br>Thanks<br><br>Jothy<br></div><div dir="ltr"><br></div></blockquote><div><br></div></div></div><div>Jothy,</div><div><br>
</div><div>If you can fix this example: </div>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Widgets/Cursor2D" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Widgets/Cursor2D</a></div><div class="gmail_quote"><br></div><div class="gmail_quote">I can try to look into how to change the color. (It only uses a vtkHandleWidget because I didn't know how else to display the cursor - as always, we are looking for the shortest example that will demonstrate what vtkCursor2D is).</div>
<div class="gmail_quote"><br clear="all">Thanks,<br><font color="#888888"><br><div>David</div></font></div>
</blockquote></div><br></div>