Logo Search packages:      
Sourcecode: ocempgui version File versions  Download package

ocempgui::widgets::Graph2D::Graph2D Class Reference

Inherits Diagram::Diagram.

List of all members.

Detailed Description

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

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.

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
SIG_DOUBLECLICKED - Invoked, when a double-click was emitted on the

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.

Definition at line 35 of file Graph2D.py.

Public Member Functions

def __init__
def draw
def draw_bg
def get_axes
def get_scale_units
def get_units
def notify
def set_axes
def set_axis_color
def set_data
def set_graph_color
def set_scale_units
def set_show_names
def set_units
def set_zoom_factor
def zoom_in
def zoom_out

Public Attributes


Static Public Attributes

tuple axis_color
tuple graph_color
tuple show_names
tuple zoom_factor

Private Member Functions

def _draw_axes

Private Attributes


The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index