コード例 #1
0
ファイル: image.py プロジェクト: paultcochrane/pyvisi
    def render(self):
        """
        Does JpegImage object specific (pre)rendering stuff
        """
        debugMsg("Called JpegImage.render()")

        return
コード例 #2
0
ファイル: camera.py プロジェクト: paultcochrane/pyvisi
    def getAzimuth(self):
        """
        Get the azimuthal angle (in degrees) of the Camera
        """
        debugMsg("Called Camera.getAzimuth()")

        return self.azimuth
コード例 #3
0
ファイル: camera.py プロジェクト: paultcochrane/pyvisi
    def __init__(self, scene):
        """
        Initialisation of the Camera object

        @param scene: The Scene object to add the Camera object to
        @type scene: Scene object
        """
        debugMsg("Called Camera.__init__()")
        Item.__init__()

        # default x,y,z positions of Camera (specific to vtk)
        self.xPos = 0.0
        self.yPos = 0.0
        self.zPos = 3.0

        # default x,y,z positions of the Camers's focal point (specific to vtk)
        self.xFocalPoint = 0.0
        self.yFocalPoint = 0.0
        self.zFocalPoint = 0.0

        # default elevation and azimuth
        # these should be set to the matlab defaults
        self.elevation = 30
        self.azimuth = 30

        # keep a reference to the renderer so we can send stuff to it
        self.renderer = scene.renderer

        # initialise the position of the Camera
        self.setPosition(self.xPos, self.yPos, self.zPos)
        self.setFocalPoint(self.xFocalPoint, self.yFocalPoint, self.zFocalPoint)
コード例 #4
0
ファイル: image.py プロジェクト: paultcochrane/pyvisi
    def __init__(self, format, scene):
        """
        Initialises the Image class object
        
        @param format: The image format
        @type format: string

        @param scene: The Scene object to add to
        @type scene: Scene object
        """
        debugMsg("Called Image.__init__()")
        Item.__init__()

        #if format == "jpeg":
            #if _debug: print "\t%s: Using jpeg image format" % rendererName
            #return JpegImage(scene)
        #else:
            #print "Unknown image format %s" % format
            #return None

        if format is None:
            raise ValueError, "You must specify an image format"

        if scene is None:
            raise ValueError, "You must specify a scene object"
コード例 #5
0
ファイル: plot.py プロジェクト: paultcochrane/pyvisi
    def render(self):
        """
        Does BallPlot specific rendering tasks
        """
        debugMsg("Called render() in BallPlot")
        self.renderer.runString("// BallPlot.render()")

        # grab the data
        x = self.x
        y = self.y
        z = self.z
        radii = self.radii

        # grab the colours
        red = self.red
        green = self.green
        blue = self.blue

        evalString = ""
        for i in range(len(x)):
            evalString += "sphere {\n"
            evalString += "  <%f, %f, %f> %f\n" % (x[i], y[i], z[i], radii[i])
            evalString += "  pigment {\n"
            evalString += "    rgb <%f, %f, %f>\n" % (red[i], green[i], blue[i])
            evalString += "  }\n"
            evalString += "}\n"

        self.renderer.runString(evalString)

        # set the title if set
        if self.title is not None:
            # not implemented yet
            pass

        return
コード例 #6
0
ファイル: camera.py プロジェクト: paultcochrane/pyvisi
 def getElevation(self):
     """
     Gets the elevation angle (in degrees) of the Camera
     """
     debugMsg("Called Camera.getElevation()")
     
     return self.elevation
コード例 #7
0
ファイル: plane.py プロジェクト: paultcochrane/pyvisi
    def render(self):
        """
        Perform Plane object specific (pre)rendering tasks
        """
        debugMsg("Called Plane.mapImageToPlane()")

        return
コード例 #8
0
ファイル: plot.py プロジェクト: paultcochrane/pyvisi
    def render(self):
        """
        Does ArrowPlot specific rendering tasks
        """
        debugMsg("Called render() in ArrowPlot")
        self.renderer.runString("// ArrowPlot.render()")

        return
コード例 #9
0
ファイル: plane.py プロジェクト: paultcochrane/pyvisi
    def __init__(self, scene):
        """
        Initialisation of the Plane object
        """
        debugMsg("Called Plane.__init__()")
        Item.__init__()

        self.renderer = scene.renderer
コード例 #10
0
ファイル: camera.py プロジェクト: paultcochrane/pyvisi
    def getPosition(self):
        """
        Get the position of Camera within Scene

        Returns the position in a tuple of form (xPos, yPos, zPos)
        """
        debugMsg("Called Camera.getPosition()")

        return (self.xPos, self.yPos, self.zPos)
コード例 #11
0
ファイル: plane.py プロジェクト: paultcochrane/pyvisi
    def mapImageToPlane(self, image):
        """
        Maps an Image object onto a Plane object
        """
        debugMsg("Called Plane.mapImageToPlane()")

        if image is None:
            raise ValueError, "You must specify an image object"

        return
コード例 #12
0
ファイル: image.py プロジェクト: paultcochrane/pyvisi
    def __init__(self, scene):
        """
        Initialises the JpegImage class object

        @param scene: The Scene object to add to
        @type scene: Scene object
        """
        debugMsg("Called JpegImage.__init__()")
        Image.__init__()
        self.renderer = scene.renderer
コード例 #13
0
ファイル: camera.py プロジェクト: paultcochrane/pyvisi
    def getFocalPoint(self):
        """
        Get the position of the focal point of the Camera

        Returns the position of the focal point in a tuple of form 
        (xPos, yPos, zPos)
        """
        debugMsg("Called Camera.getFocalPoint()")

        return (self.xFocalPoint, self.yFocalPoint, self.zFocalPoint)
コード例 #14
0
ファイル: plot.py プロジェクト: paultcochrane/pyvisi
    def __init__(self, scene):
        """
        Initialisation of the ArrowPlot class

        @param scene: the scene with which to associate the arrow plot
        @type scene: Scene object
        """
        debugMsg("Called ArrowPlot.__init__()")
        Plot.__init__()

        self.renderer = scene.renderer
コード例 #15
0
ファイル: image.py プロジェクト: paultcochrane/pyvisi
    def load(self, fname):
        """
        Loads jpeg image data from file.

        @param fname: The filename from which to load jpeg image data
        @type fname: string
        """
        debugMsg("Called JpegImage.load()")

        fileCheck(fname)
        
        return
コード例 #16
0
ファイル: camera.py プロジェクト: paultcochrane/pyvisi
    def setElevation(self, elevation):
        """
        Set the elevation angle (in degrees) of the Camera

        @param elevation: The elevation angle (in degrees) of the Camera
        @type elevation: float
        """
        debugMsg("Called Camera.setElevation()")

        self.elevation = elevation

        return
コード例 #17
0
ファイル: camera.py プロジェクト: paultcochrane/pyvisi
    def setAzimuth(self, azimuth):
        """
        Set the azimuthal angle (in degrees) of the Camera

        @param azimuth: The azimuthal angle (in degrees) of the Camera
        @type azimuth: angle
        """
        debugMsg("Called Camera.setAzimuth()")

        self.azimuth = azimuth

        return
コード例 #18
0
ファイル: plot.py プロジェクト: paultcochrane/pyvisi
    def __init__(self, scene):
        """
        Initialisation of the ContourPlot class
        
        @param scene: the scene with which to associate the line plot
        @type scene: Scene object
        """
        debugMsg("Called LinePlot.__init__()")
        Plot.__init__()

        if scene is None:
            raise ValueError, "You must specify a scene object"
コード例 #19
0
ファイル: scene.py プロジェクト: paultcochrane/pyvisi
    def place(self, obj):
        """
        Place an object within a scene

        @param obj: The object to place within the scene
        @type obj: object
        """
        debugMsg("Called Scene.place()")
        
        if obj is None:
            raise ValueError, "You must specify an object to place" 

        return
コード例 #20
0
ファイル: plot.py プロジェクト: paultcochrane/pyvisi
    def setData(self, *dataList):
        """
        Set data to the plot

        @param dataList: list/tuple of data to set to the plot
        @type dataList: tuple
        """
        debugMsg("Called setData() in LinePlot()")

        if dataList is None:
            raise ValueError, "You must specify a data list"
        
        return
コード例 #21
0
ファイル: text.py プロジェクト: paultcochrane/pyvisi
    def __init__(self, scene):
        """
        Initialisation of the Text clas

        @param scene: the scene with which to associate the text object
        @type scene: scene object
        """
        debugMsg("Called Text.__init__()")
        Item.__init__()

        if scene is None:
            raise ValueError, "You must specify a scene object"
        
        self.font = "Times"
コード例 #22
0
ファイル: plot.py プロジェクト: paultcochrane/pyvisi
    def setData(self, *dataList):
        """
        Set data to the plot

        @param dataList: list/tuple of data objects to set to the plot
        @type dataList: tuple
        """
        debugMsg("Called setData() in ArrowPlot()")
        self.renderer.runString("// ArrowPlot.setData()")

        if dataList is None:
            raise ValueError, "You must specify a data list"
        
        return
コード例 #23
0
ファイル: scene.py プロジェクト: paultcochrane/pyvisi
    def add(self, obj):
        """
        Add a new item to the scene

        @param obj: The object to add to the scene
        @type obj: object
        """
        debugMsg("Called Scene.add()")

        if obj is None:
            raise ValueError, "You must specify an object to add"

        self.objectList.append(obj)

        return
コード例 #24
0
ファイル: scene.py プロジェクト: paultcochrane/pyvisi
    def save(self, fname, format):
        """
        Save the scene to a file

        Possible formats are:
            - PNG
            - TGA (uncompressed targa)
            - CTGA (compressed targa)
            - PPM
            - SYS (e.g. BMP on Windows, PICT on MacOS)

        @param fname: the name of the file to save to
        @type fname: string

        @param format: the image format of the output file
        @type format: Image object or string
        """
        debugMsg("Called Scene.save()")
        self.renderer.runString("// Scene.save()")

        # if the format is passed in as a string or object, react
        # appropriately
        import types
        if type(format) is types.StringType:
            fmt = format.lower()
        else:
            fmt = format.format

        if fmt == "png":
            self.renderer.addToInitStack("Output_File_Type=N")
        elif fmt == "tga":
            self.renderer.addToInitStack("Output_File_Type=T")
        elif fmt == "ppm":
            self.renderer.addToInitStack("Output_File_Type=P")
        elif fmt == "ctga":
            self.renderer.addToInitStack("Output_File_Type=C")
        elif fmt == "sys":
            self.renderer.addToInitStack("Output_File_Type=S")
        else:
            raise ValueError, "Unknown graphics format.  I got %s" % fmt

        self.fname = fname

        # rerender the scene to get the output
        self.render(save=True)

        return
コード例 #25
0
ファイル: scene.py プロジェクト: paultcochrane/pyvisi
    def __init__(self):
        """
        The init function
        """
        debugMsg("Called Scene.__init__()")
        BaseScene.__init__(self)

        self.renderer = Renderer()

        self.xSize = 640
        self.ySize = 480

        # these variables are used to determin the location of the camera
        self.centre = None
        self.bounds = None

        self.objectList = []
コード例 #26
0
ファイル: camera.py プロジェクト: paultcochrane/pyvisi
    def setPosition(self, *pos):
        """
        Set position of camera within scene

        @param pos: Position to set camera in terms of x,y,z coordinates
        @type pos: tuple
        """
        debugMsg("Called Camera.setPosition()")

        # I need to do some mucking around in here with coordinate systems
        # and so on, but at present, we'll just use vtk's coord system
        
        self.xPos = pos[0]
        self.yPos = pos[1]
        self.zPos = pos[2]

        # now to set the position
        self.renderer.runString("# Camera.setPosition()\n")

        return
コード例 #27
0
ファイル: camera.py プロジェクト: paultcochrane/pyvisi
    def setFocalPoint(self, *pos):
        """
        Sets the focal point of the Camera with the Scene

        @param pos: Position to set the focal point
        @type pos: tuple
        """
        debugMsg("Called Camera.setFocalPoint()")

        # I need to do some mucking around in here with coordinate systems
        # and so on, but at present, we'll just use vtk's coord system
        
        self.xFocalPoint = pos[0]
        self.yFocalPoint = pos[1]
        self.zFocalPoint = pos[2]

        # now set the focal point position
        self.renderer.runString("#Camera.setFocalPoint()\n")

        return
コード例 #28
0
ファイル: renderer.py プロジェクト: paultcochrane/pyvisi
    def __init__(self):
        """
        Initialisation of Renderer() class
        """
        debugMsg("Called Renderer.__init__()")
        BaseRenderer.__init__(self)

        # initialise some attributes
        self.renderWindowWidth = 640
        self.renderWindowHeight = 480

        # initialise the evalstack
        self._evalStack = ""

        # initialise the initstack
        ### note that in povray, this is the ini file for the pov scene
        self._initStack = ""

        # initialise the renderer module

        self.runString("// Renderer.__init__\n")
コード例 #29
0
ファイル: plot.py プロジェクト: paultcochrane/pyvisi
    def __init__(self, scene):
        """
        Initialisation of the ArrowPlot3D class

        @param scene: the scene with which to associate the arrow plot
        @type scene: Scene object
        """
        debugMsg("Called ArrowPlot3D.__init__()")
        Plot.__init__(self, scene)

        self.renderer = scene.renderer
        self.renderer.runString("// ArrowPlot3D.__init__()")

        self.scene = scene

        # options
        self.fname = None
        self.format = None

        self.title = None

        # the data to pass between setData() and render()
        self.x = None
        self.y = None
        self.z = None
        self.dx = None
        self.dy = None
        self.dz = None

        self.norm = None
        self.maxNorm = None

        # share the colours around
        self.red = None
        self.green = None
        self.blue = None
 
        # add the plot to the scene
        scene.add(self)
コード例 #30
0
ファイル: scene.py プロジェクト: paultcochrane/pyvisi
    def setBackgroundColor(self, *color):
        """
        Sets the background color of the Scene

        @param color: The color to set the background to.  Can be RGB or CMYK
        @type color: tuple
        """
        debugMsg("Called Scene.setBackgroundColor()")

        # pity this code doesn't work....
        # need to check on the values given in the *color array.
        # if they're greater than 1, scale so that the largest is 1
        #maxColor = None
        #for i in range(len(color)):
            #if color[i] > 1:
                #maxColor = color[i]
                #print maxColor
#
        ## if a maximum colour is found, then scale the colours
        #if maxColor is not None:
            #for i in range(len(color)):
                #color[i] = color[i]/maxColor
        
        # if color is of length 3, then we have rgb
        # if length is 4 then cmyk
        # if length is 1 then greyscale
        # otherwise barf
        if len(color) == 3:
            # ok, using rgb
            # probably should use a Color object or something
            # this will do in the meantime
            pass
        else:
            raise ValueError, "Sorry, only RGB color is supported at present"

        return