Package ocempgui :: Package widgets :: Module Graph2D :: Class Graph2D
[show private | hide private]
[frames | no frames]

Type Graph2D

 object --+                
          |                
INotifyable --+            
              |            
     BaseObject --+        
                  |        
     object --+   |        
              |   |        
         Sprite --+        
                  |        
         BaseWidget --+    
                      |    
                Diagram --+
                          |
                         Graph2D


Graph2D (width, height) -> Graph2D

A widget displaying graphs on a cartesian coordinate plane.

The Graph2D widget displays function graphs on a cartesian
coordinate plane using two axes.

The axes, scale units and units attributes must have at least two
values on assignment to fit both, the horizontal and vertical axes.

self.axes = 't', 'v'     # Set velocity related to time.
self.set_axes ('x', 'y') # The default.

# seconds for the time axis, mph for the velocity axis.
self.scale_units = 's', 'mph' 
self.set_scale_units ('-', '-') # The default.

# Each second has a distance of 10px to its neighbours and each mph
# has a distance of 25px to its neighbours.
self.units = 10, 25
self.set_units (10, 10) # The default.

Setting the 'orientation' attribute of the Graph2D widget to
ORIENTATION_VERTICAL will cause it to be rotated clockwise by 90
degrees.

The Graph2D can display the names of the axes and their scale units
next to the related axes. This can be adjusted using the
'show_names' attribute and set_show_names() method:

self.show_names = True # Show the names and scale units.
self.set_show_names (False) # Do not show them.

The axes and graph colors can be set to individual values (e.g. to
outline certain function behaviours) through the 'axis_color' and
'graph_color' attributes and their respective methods
set_axis_color() and set_graph_color().

self.axis_color = (0, 255, 0)
self.set_axiscolor ((255, 255, 0))

self.graph_color = (0, 255, 255)
self.set_graph_color (255, 0, 0)

The 'zoom_factor' attribute and set_zoom_factor() method set the zoom
factor for the graph. Values between 0 and 1 will zoom it out while
values greater than 1 will zoom it out.
Note: The zoom factor directly modifies the 'units' attribute values,
which can lead to rounding errors when using floating point zoom factors.
This usually results in a minor discrepancy, when you try to restore the
original values.

# Zoom the x axis out and the y axis in.
self.zoom_factor = 0.5, 2.0

# Zoom both axis in.
self.set_zoom_factor (3.0, 3.0)

Default action (invoked by activate()):
See the Diagram class.

Mnemonic action (invoked by activate_mnemonic()):
See the Diagram class.

Signals:
SIG_KEYDOWN       - Invoked, when a key is pressed while the Graph2D has
                    the input.
SIG_MOUSEDOWN     - Invoked, when a mouse button is pressed on the
                    Graph2D.
SIG_DOUBLECLICKED - Invoked, when a double-click was emitted on the
                    Graph2D.

Attributes:
show_names  - Indicates, whether the axis names and scale units should
              be shown or not.
axis_color  - The color for both axes.
graph_color - The color for the displayed graph.
zoom_factor - The zoom factor values for both axes.

Method Summary
  __init__(self, width, height)
  draw(self)
W.draw () -> None
  draw_bg(self)
G.draw_bg () -> Surface
  get_axes(self)
G.get_axes (...) -> None
  get_scale_units(self)
G.get_scale_units (...) -> None
  get_units(self)
G.set_units (...) -> None
  notify(self, event)
G.notify (...) -> None
  set_axes(self, axes)
G.set_axes (...) -> None
  set_axis_color(self, var)
G.set_axis_color (...) -> None
  set_data(self, data)
G.set_data (...) -> None
  set_graph_color(self, var)
G.set_graph_color (...) -> None
  set_scale_units(self, units)
G.set_scale_units (...) -> None
  set_show_names(self, var)
G.set_show_names (...) -> None
  set_units(self, units)
G.set_units (...) -> None
  set_zoom_factor(self, x, y)
G.set_zoom_factor (...) -> None
  zoom_in(self)
G.zoom_in () -> None
  zoom_out(self)
G.zoom_out () -> None
    Inherited from Diagram
  evaluate(self)
D.evaluate () -> None
  set_eval_func(self, func)
D.set_eval_func (...) -> None
  set_negative(self, negative)
D.set_negative (...) -> None
  set_orientation(self, orientation)
D.set_orientation (...) -> None
  set_origin(self, x, y)
D.set_origin (...) -> None
  set_values(self, values)
D.set_values (...) -> None
    Inherited from BaseWidget
  activate(self)
W.activate () -> None
  activate_mnemonic(self, mnemonic)
W.activate_mnemonic (...) -> bool
  check_sizes(self, width, height)
W.check_sizes (...) -> int, int
  create_style(self)
W.create_style () -> WidgetStyle
  debug_update(self)
For debugging usage only
  destroy(self)
W.destroy () -> None
  get_style(self)
W.get_style () -> WidgetStyle
  initclass(cls)
B.initclass () -> None (Class method)
  lock(self)
W.lock () -> None
  rect_to_client(self, rect)
W.rect_to_client (...) -> pygame.Rect
  set_depth(self, depth)
W.set_depth (...) -> None
  set_dirty(self, dirty, update)
W.set_dirty (...) -> None
  set_entered(self, entered)
W.set_entered (...) -> None
  set_event_area(self, area)
W.set_event_area (...) -> None
  set_event_manager(self, manager)
W.set_event_manager (...) -> None
  set_focus(self, focus)
W.set_focus (...) -> bool
  set_index(self, index)
W.set_index (...) -> None
  set_indexable(self, indexable)
W.set_indexable (...) -> None
  set_maximum_size(self, width, height)
W.set_maximum_size (...) -> None
  set_minimum_size(self, width, height)
W.set_minimum_size (...) -> None
  set_opacity(self, opacity)
W.set_opacity (...) -> None
  set_position(self, x, y)
W.set_position (...) -> None
  set_sensitive(self, sensitive)
W.set_sensitive (...) -> None
  set_size(self, width, height)
W.set_size (...) -> None
  set_state(self, state)
W.set_state (...) -> None
  set_style(self, style)
W.set_style (...) -> None
  set_tooltip(self, tooltip)
W.set_tooltip (...) -> None
  unlock(self)
W.unlock () -> None
  update(self, **kwargs)
W.update (...) -> None
    Inherited from BaseObject
  connect_signal(self, signal, callback, *data)
B.connect_signal (...) -> EventCallback
  disconnect_signal(self, event)
B.disconnect_signal (...) -> None
  emit(self, signal, data)
B.emit (...) -> bool
  run_signal_handlers(self, signal, *data)
B.run_signal_handlers (...) -> None
    Inherited from Sprite
  __repr__(self)
  add(self, *groups)
add(group or list of of groups, ...) add a sprite to container
  add_internal(self, group)
  alive(self)
alive() -> bool check to see if the sprite is in any groups
  groups(self)
groups() -> list of groups list used sprite containers
  kill(self)
kill() remove this sprite from all groups
  remove(self, *groups)
remove(group or list of groups, ...) remove a sprite from container
  remove_internal(self, group)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Property Summary
  axis_color: The color of the axes.
  graph_color: The color of the graph.
  show_names: Indicates, whether the axis names should be shown.
  zoom_factor: Zoom factor for the axes.
    Inherited from Diagram
  axes: The axes to show.
  data: The data to evaluate.
  eval_func: The evaluation function for calculation.
  negative: Indicates, whether negative values are shown.
  orientation: The orientation of the axes.
  origin: Coordinates of the point of origin on the widget
  scale_units: The scale units of the axes.
  units: The pixels per unit to set.
  values: The calculated values of the set data.
    Inherited from BaseWidget
  bottom
  bottomleft
  bottomright
  center
  centerx
  centery
  controls: Widgets associated with the widget.
  depth: The z-axis layer depth of the widget.
  dirty: Indicates, whether the widget need to be redrawn.
  entered: Indicates, whether the widget is entered.
  eventarea: The area, which gets the events.
  focus: The focus of the widget.
  h
  height
  image: The visible surface of the widget.
  index: The tab index position of the widget.
  indexable: The IIndexable, the widget is attached to.
  left
  locked: Indicates, whether the widget is locked.
  maxsize: The maximum size to occupy by the widget.
  midbottom
  midleft
  midright
  midtop
  minsize: The guaranteed size of the widget.
  opacity: The opacity of the widget.
  position: The position of the topleft corner.
  rect: The area occupied by the widget.
  right
  sensitive: The sensitivity of the widget.
  size
  state: The current state of the widget.
  style: The style of the widget.
  tooltip: The tool tip text to display for the widget.
  top
  topleft
  topright
  w
  width
  x
  y
    Inherited from BaseObject
  manager: The event manager to use by the object.

Instance Method Details

draw(self)

W.draw () -> None

Draws the Graph2D surface.

Creates the visible surface of the Graph2D.
Overrides:
ocempgui.widgets.BaseWidget.BaseWidget.draw

draw_bg(self)

G.draw_bg () -> Surface

Draws the Graph2D background surface and returns it.

Creates the visible background surface of the Graph2D and returns it to the caller.
Overrides:
ocempgui.widgets.BaseWidget.BaseWidget.draw_bg

get_axes(self)

G.get_axes (...) -> None

Gets the amount and names of the axes.
Overrides:
ocempgui.widgets.Diagram.Diagram.get_axes

get_scale_units(self)

G.get_scale_units (...) -> None

Gets the scale units of the axes.
Overrides:
ocempgui.widgets.Diagram.Diagram.get_scale_units

get_units(self)

G.set_units (...) -> None

Gets the pixels per unit for dimensioning.
Overrides:
ocempgui.widgets.Diagram.Diagram.get_units

notify(self, event)

G.notify (...) -> None

Notifies the Graph2D about an event.
Overrides:
ocempgui.widgets.BaseWidget.BaseWidget.notify

set_axes(self, axes)

G.set_axes (...) -> None

Sets the amount and names of the axes.

Raises a TypeError, if the passed argument is not a list or tuple. Raises a ValueError, if the passed argument values are not strings.
Overrides:
ocempgui.widgets.Diagram.Diagram.set_axes

set_axis_color(self, var)

G.set_axis_color (...) -> None

Sets the color of the axes of the coordinate plane.

set_data(self, data)

G.set_data (...) -> None

Sets the data to evaluate.

Raises a TypeError, if the passed argument is not a list or tuple. Raises a ValueError, if the passed argument values are not integers or floats.
Overrides:
ocempgui.widgets.Diagram.Diagram.set_data

set_graph_color(self, var)

G.set_graph_color (...) -> None

Sets the color of the graph to draw.

set_scale_units(self, units)

G.set_scale_units (...) -> None

Sets the scale units of the axes.

Raises a TypeError, if the passed argument is not a list or tuple. Raises a ValueError, if the passed argument values are not strings.
Overrides:
ocempgui.widgets.Diagram.Diagram.set_scale_units

set_show_names(self, var)

G.set_show_names (...) -> None

Sets, whether the axis names and scale units should be shown.

If set to True, the names and scale units of both axes will be displayed besides and beneath the axes in the form 'name / unit'.

set_units(self, units)

G.set_units (...) -> None

Sets the pixels per unit for dimensioning.

Raises a TypeError, if the passed argument is not a list or tuple. Raises a ValueError, if the passed argument values are not integers greater than 0.
Overrides:
ocempgui.widgets.Diagram.Diagram.set_units

set_zoom_factor(self, x, y)

G.set_zoom_factor (...) -> None

Zooms the graph in or out by modifying the pixel per units values.

Zooms the graph in or out by modifying the pixel per units values. Passing 0 as zoom factor will reset the

Raises a TypeError, if the passed arguments are not floats or integers. Raises a ValueError, if the passed arguments are smaller than or equal to 0.

zoom_in(self)

G.zoom_in () -> None

Zooms into the graph by factor 2.

zoom_out(self)

G.zoom_out () -> None

Zoom out of the graph by factor 2.

Property Details

axis_color

The color of the axes.
Get Method:
unknown-696766620(...)
Set Method:
unknown-696766676(...)

graph_color

The color of the graph.
Get Method:
unknown-696766732(...)
Set Method:
unknown-696766788(...)

show_names

Indicates, whether the axis names should be shown.
Get Method:
unknown-696766508(...)
Set Method:
unknown-696766564(...)

zoom_factor

Zoom factor for the axes.
Get Method:
unknown-696766844(...)
Set Method:
unknown-696766900(...)

Generated by Epydoc 2.1 on Thu Jan 10 10:18:44 2008 http://epydoc.sf.net