[vtkusers] Different colours to different axes in vtkCursor3D

Jothybasu K Selvaraj jothybasu at gmail.com
Sun Mar 28 14:41:01 EDT 2010


Hi David,

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.

from vtk import*

sphereSource =vtkSphereSource();
sphereSource.SetCenter(0.0, 0.0, 0.0);
sphereSource.SetRadius(5.0);

#Create a mapper and actor
mapper = vtkPolyDataMapper();
mapper.SetInputConnection(sphereSource.GetOutputPort());

actor = vtkActor();
actor.SetMapper(mapper);

#Create a renderer, render window, and interactor
renderer =vtkRenderer();
renderWindow =vtkRenderWindow();
renderWindow.AddRenderer(renderer);
renderWindowInteractor =vtkRenderWindowInteractor();
renderWindowInteractor.SetRenderWindow(renderWindow);

#Add the actor to the scene
renderer.AddActor(actor);
renderer.SetBackground(0,0,0); # Background color white

cursor =vtkCursor2D();
cursor.SetModelBounds(-10,10,-10,10,0,0)
cursor.AllOn()
cursor.OutlineOff()
cursor.Update();
cursormapper=vtkPolyDataMapper()
cursormapper.SetInputConnection(cursor.GetOutputPort())
cursoractor=vtkActor()
cursoractor.GetProperty().SetColor(1,1,0)
cursoractor.SetMapper(cursormapper)
renderer.AddActor(cursoractor);

handleRep =vtkPointHandleRepresentation2D();
handleRep.SetDisplayPosition(cursoractor.GetPosition());
handleRep.ActiveRepresentationOn();
handleRep.SetCursorShape(cursor.GetOutput());

handleWidget =vtkHandleWidget();
handleWidget.SetInteractor(renderWindowInteractor);
handleWidget.SetRepresentation(handleRep);


handleWidget.On();

#Render and interact
renderWindow.Render();
renderWindowInteractor.Start();


If you come do any changes, do let me know I will add it to the python
examples section.

Thanks

Jothy

On Sat, Mar 27, 2010 at 10:02 PM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> On Thu, Mar 25, 2010 at 8:10 AM, Jothybasu K Selvaraj <jothybasu at gmail.com
> > wrote:
>
>> Hi all,
>>
>> How to set different colours to different axis in vtkCursor3D?
>>
>> Thanks
>>
>> Jothy
>>
>>
> Jothy,
>
> If you can fix this example:
> http://www.vtk.org/Wiki/VTK/Examples/Widgets/Cursor2D
>
> 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).
>
> Thanks,
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100328/eec75f11/attachment.htm>


More information about the vtkusers mailing list