Exemplo n.º 1
0
    def boundingVolume(self, mode):
        """Calculate the bounding volume for this node

        The bounding volume for a grouping node is
        the union of it's children's nodes, and is
        dependent on the children of the node's
        bounding nodes, as well as the children field
        of the node.
        """
        current = boundingvolume.getCachedVolume(self)
        if current is not None:
            return current
        # need to create a new volume and make it depend
        # on the appropriate fields...
        volumes = []
        dependencies = [(self, 'choice'), (self, 'whichChoice')]
        unbounded = 0
        for child in self.renderedChildren():
            try:
                if hasattr(child, 'boundingVolume'):
                    volume = child.boundingVolume(mode)
                    volumes.append(volume)
                    dependencies.append((volume, None))
                else:
                    unbounded = 1
                    break
            except boundingvolume.UnboundedObject:
                unbounded = 1
        try:
            volume = boundingvolume.BoundingBox.union(volumes, None)
        except boundingvolume.UnboundedObject:
            unbounded = 1
        if unbounded:
            volume = boundingvolume.UnboundedVolume()
        return boundingvolume.cacheVolume(self, volume, dependencies)
    def boundingVolume(self, mode):
        """Create a bounding-volume object for this node

        This is our geometry's boundingVolume, with the
        addition that any dependent volume must be dependent
        on our geometry field.
        """
        bb = None
        for attrib in self.attributes:
            if attrib.isCoord:
                bv = attrib.boundingVolume(mode)
                if bv and bb:
                    bb = boundingvolume.AABoundingBox.union((bb, bv))
                elif bv:
                    bb = bv
        if not bb:
            # can't determine bounding box, so have to go with the
            # always-visible version...
            return boundingvolume.UnboundedVolume()
        return bb
Exemplo n.º 3
0
    def boundingVolume( self, mode ):
        """Create a bounding-volume object for this node

        This is our geometry's boundingVolume, with the
        addition that any dependent volume must be dependent
        on our geometry field.
        """
        current = boundingvolume.getCachedVolume( self )
        if current:
            return current
        if self.geometry:
            if hasattr( self.geometry, 'boundingVolume'):
                volume = self.geometry.boundingVolume(mode)
            else:
                # is considered always visible
                volume = boundingvolume.UnboundedVolume()
        else:
            # is never visible
            volume = boundingvolume.BoundingVolume()
        return boundingvolume.cacheVolume(
            self, volume, ((self, 'geometry'),(volume,None)),
        )
Exemplo n.º 4
0
 def OnInit(self):
     """Load the image on initial load of the application"""
     print """Each dot is a request (y shows data transferred)"""
     self.log_queue = Queue.Queue(maxsize=self.dataPoints)
     self.coordinate = Coordinate(point=[(0, 0, 0)] * self.dataPoints, )
     # should *not* be necessary, but is, to prevent a cached
     # bounding volume from dropping the graph
     boundingvolume.cacheVolume(
         self.coordinate,
         boundingvolume.UnboundedVolume(),
     )
     # just an arbitrary format/style for the text
     self.fontstyle = FontStyle(
         family='SANS',
         format='bitmap',
         justify='BEGIN',
     )
     #
     self.color = Color(color=[1.0, 0.0, 0.0], )
     self.data_slider = Transform(
         translation=(0, 0, 0),
         scale=(
             1 / 600.,
             1,
             1,
         ),
         children=[
             Shape(
                 appearance=Appearance(
                     texture=ImageTexture(url='_particle.png'),
                     material=Material(diffuseColor=[1, 0, 0], )),
                 geometry=PointSet(
                     coord=self.coordinate,
                     minSize=5.0,
                     maxSize=5.0,
                 ),
             ),
         ],
     )
     self.axes = Transform(children=[
         Transform(
             translation=(.25, coord, 0),
             children=[
                 Shape(geometry=Text(
                     string=[label],
                     fontStyle=self.fontstyle,
                 ))
             ],
         ) for (coord, label) in [
             (0, '0B'),
             (3, '1KB'),
             (6, '1MB'),
             (9, '1GB'),
         ]
     ] + [
         Transform(
             translation=(coord, -.75, 0),
             children=[
                 Shape(geometry=Text(
                     string=[label],
                     fontStyle=self.fontstyle,
                 ))
             ],
         ) for (coord, label) in [
             (0, 'now'),
             (-1200 * self.data_slider.scale[0], '-20m'),
             (-2400 * self.data_slider.scale[0], '-40m'),
             (-3600 * self.data_slider.scale[0], '-60m'),
         ]
     ])
     self.transform = Transform(translation=(3, -2, 0),
                                children=[
                                    self.data_slider,
                                    self.axes,
                                ])
     self.sg = sceneGraph(children=[
         self.transform,
     ], )
     self.time = Timer(duration=1, repeating=1)
     self.time.addEventHandler("fraction", self.OnTimerFraction)
     self.time.register(self)
     self.time.start()
     thread = threading.Thread(target=log_reader,
                               args=('epa-http.txt', self.log_queue))
     thread.setDaemon(True)
     thread.start()