[vtkusers] Digital Graticule

Jothybasu K Selvaraj jothybasu at gmail.com
Sun Apr 18 12:54:10 EDT 2010


Hi Guys,

I have managed to create a digital graticule, but the distance of the ticks
doesn't match properly.Basically its stitching together a cursor2D & small
line from vtkLineSource.

If anyone can figure it out, I request them to create a c++ class and sub,it
that to the developer list as a convenience class.

Thanks,

Jothy





import vtk
import numpy as np
color=[1,1,0]
Bounds=[-110,110,-110,110,0,0]
Cursor=vtk.vtkCursor2D()
Cursor.SetModelBounds(Bounds)
Cursor.SetFocalPoint(0,0,0)
Cursor.AllOn()
Cursor.AxesOn()
Cursor.OutlineOff()
Cursor.SetRadius(1)
mapper=vtk.vtkPolyDataMapper()
mapper.SetInputConnection(Cursor.GetOutputPort())
actor=vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(color)


def CreateTicks(Cursorolor,CursorursorBounds,TickInterval):
    XTicks=list()
    YTicks=list()
    XBoundsRight=CursorursorBounds[0]
    XBoundsLeft=CursorursorBounds[1]
    YBoundsRight=CursorursorBounds[2]
    YBoundsLeft=CursorursorBounds[3]

    for x in range(XBoundsRight+TickInterval,XBoundsLeft,TickInterval):
        print x
        XTick=vtk.vtkLineSource()
        XTick.SetPoint1(x,5,0)
        XTick.SetPoint2(x,-5,0)
        XTick.Update()
        XTickMapper=vtk.vtkPolyDataMapper()
        XTickMapper.SetInputConnection(XTick.GetOutputPort())
        XTickActor=vtk.vtkActor()
        XTickActor.SetMapper(XTickMapper)
        XTickActor.GetProperty().SetColor(color)
        XTicks.append(XTickActor)

    for y in range(YBoundsRight+TickInterval,YBoundsLeft,TickInterval):
        #print y
        YTick=vtk.vtkLineSource()
        YTick.SetPoint1(5,y,0)
        YTick.SetPoint2(-5,y,0)
        YTick.Update()
        YTickMapper=vtk.vtkPolyDataMapper()
        YTickMapper.SetInputConnection(YTick.GetOutputPort())
        YTickActor=vtk.vtkActor()
        YTickActor.SetMapper(YTickMapper)
        YTickActor.GetProperty().SetColor(color)
        YTicks.append(YTickActor)
    return XTicks,YTicks


XTicks,YTicks=CreateTicks((1,1,0),Bounds,10)
NumOfXTicks= np.size(XTicks)
NumOfYTicks= np.size(YTicks)


Ren=vtk.vtkRenderer()
Ren.AddActor(actor)
for x in range(0,NumOfXTicks,1):
    Ren.AddActor(XTicks[x])

for y in range(0,NumOfYTicks,1):
    Ren.AddActor(YTicks[y])


RenWin=vtk.vtkRenderWindow()
RenWin.AddRenderer(Ren)
RenWin.Render()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100418/ba47b0be/attachment.htm>


More information about the vtkusers mailing list