| |
- __builtin__.object
-
- SimViz
-
- TrackingViz
- Simulation
class SimViz(__builtin__.object) |
|
Abstract interface representing an object which knows how and when
to display itself on a surface inside of a Simulation.
This class is meant to serve as an interface definition to be
subclassed (or at least replicated). |
|
Methods defined here:
- __init__(self, drawingOrder=0)
- Base constructor for a SimViz.
'drawingOrder' is used to specify the order in which this viz
is drawn to the surface relative to others. See 'getDrawingOrder()'.
- drawToSurface(self, surf)
- To be overridden.
Draws this viz on the supplied surface, according to its
internal state.
- getBoundingBox(self)
- To be overridden.
Returns (latmin,latmax,lonmin,lonmax) the lat/lon bounds
of this visualization object.
Note that for Simulation purposes, this does not need to
be implemented if this SimViz is passed in as one of the
scene_viz's (as opposed to an actor_viz).
- getDrawingOrder(self)
- Returns an integer representing the order in which this viz
should be drawn relative to other vizs. Vizs with a higher
drawing order are drawn after those with a lower drawing
order, meaning they will be drawn on top.
- getLabel(self)
- To be overridden (optionally).
Returns string to be displayed as descriptive label for this
viz object. Default behavior is to return None, meaning no
label should ever be displayed.
- getTimeInterval(self)
- To be overridden.
Returns (begin,end) time values for the existence of this
visualization object.
May return ( -Inf,Inf ) to indicate that it is always present.
- mouseIntersect(self, mousex, mousey)
- To be overridden.
Returns True if the given mouse location is inside some
designated region of this visualization.
Note that for Simulation purposes, if getLabel() returns
None then this method does not need to be implemented.
- setState(self, simtime, getXY)
- To be overridden.
Sets the internal state of this viz to the specified time.
This should be stored internally, for subsequent calls to
methods such as drawToSurface or mouseIntersect.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Simulation(__builtin__.object) |
|
A collection of generic SimViz's and a timer, of sorts. This lets the
visualizer say "Give me coordinates of each object at time T". A run()
method is provided which displays the simulation in a pygame window. |
|
Methods defined here:
- __init__(self, actor_vizs, scene_vizs, initTime=0)
- Given two collections of generic SimViz objects, and optionally an
initial time, creates a Simulation object.
Both actor_vizs and scene_vizs should be a collection of SimViz
objects. The difference is that the actor_vizs will determine the
bounds of the animation in space and time, while the location and
time windows of the scene_vizs will be largely ignored.
- getXY(self, lat, lon, bounds, ssize)
- Given coordinates in lon,lat, and a screen size,
returns the corresponding (x,y) pixel coordinates.
- printTime(self)
- run(self, speed=0.0, windowsize=(1280, 800), refresh_rate=1.0, font='/Library/Frameworks/Python.framework/Versions/2....b/python2.5/site-packages/pygame/freesansbold.ttf', fontsize=10, osmzoom=14)
- Pops up a window and displays the simulation on it.
Speed is advancement of sim in seconds/second.
Refresh rate is pause in seconds between frames.
Windowsize is the desired (width,height) of the display window.
Font is either the full path to a pygame-compatible font file
(e.g. a .ttf file), or an actual pygame Font object, or None.
If None, then labels will not be rendered, instead they will be
printed to stdout.
Fontsize is the size of the font, if it exists.
- setTime(self, time)
- Moves all bus tracks to the given time.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class TrackingViz(SimViz) |
|
A generic SimViz which displays a moving image on the map. |
|
- Method resolution order:
- TrackingViz
- SimViz
- __builtin__.object
Methods defined here:
- __init__(self, label, image, getLatLonAtTimeFunc, time_window, bounding_box, drawing_order=0)
- Constructs a TrackingViz.
Arguments:
label - text to display when moused over, or None for no text
image - filename of image to display on map
getLatLonAtTimeFunc - a function that takes one argument (time)
and returns (lat,lon)
time_window - a tuple (begin_time,end_time) representing the times
this object exists
bounding_box - a tuple (min_lat,max_lat,min_lon,max_lon) representing
the farthest bounds that this object will reach
drawing_order - see SimViz.getDrawingOrder()
- drawToSurface(self, surf)
- getBoundingBox(self)
- getLabel(self)
- getTimeInterval(self)
- mouseIntersect(self, mousex, mousey)
- setState(self, simtime, getXY)
Methods inherited from SimViz:
- getDrawingOrder(self)
- Returns an integer representing the order in which this viz
should be drawn relative to other vizs. Vizs with a higher
drawing order are drawn after those with a lower drawing
order, meaning they will be drawn on top.
Data descriptors inherited from SimViz:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |