Points from the point tool

This Python example gets coordinates from the Point tool.

  • Note that VisIt does not really make the point tool available to users but it can be used to set plot and operator attributes. In this case, we make a clear Pseudocolor plot with a ThreeSlice operator. The ThreeSlice operator can have its location set via the Point tool. Once the plot is created, we make it clear and enable the point tool. We install a Python callback on the ThreeSlice operator attributes and record updates made to the coordinates in that object. We then return the coordinates to the user.
import time

class PointToolCoordinates(object):
    def __init__(self, db, var):
        super(PointToolCoordinates, self).__init__()
        self.db = db
        self.var = var
        self.coord = (0,0,0)
        self.waiting = False

    def getCoordinate(self):
        def invoke(atts, obj):
            if obj.waiting:
                a = ThreeSliceAttributes(1)
                obj.coord = (a.x, a.y, a.z)
                obj.waiting = False
        # Make a new clear plot.
        self.waiting = False
        AddPlot("Pseudocolor", self.var)
        pc = PseudocolorAttributes()
        pc.legendFlag = 0
        pc.opacity = 0
        pc.opacityType = pc.Constant
        AddOperator("ThreeSlice", 0)

        # Enable the point tool
        EnableTool(0, 1)
        self.waiting = True
        RegisterCallback("ThreeSliceAttributes", invoke, self)


        # Disable the point tool
        EnableTool(0, 0)

        return self.coord

def printcoord(coord):
    print coord

def main():
    p = PointToolCoordinates("~/Development/data/noise.silo", "hardyglobal")
    for i in xrange(10):
        print "i=",i
        print p.getCoordinate()