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

Type Diagram

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

Known Subclasses:
Graph2D

Diagram () -> Diagram

An abstract widget class for diagram and graph implementations.

The Diagram class contains the minimum set of attributes and methods
needed to visualize diagrams or graphs from arbitrary data.

Diagrams can have different resolutions, dependant on the value
range, that should be displayed. Inheritors thus have to implement
the 'units' attribute and its related methods get_units() and
set_units(), which define, how many pixels between each full unit
have to be left. Greater values usually result in a higher
resolution, resp. pixel amount between the values.

To allow the user to know about the kind of data, that is evaluated
and displayed, the 'scale_units' attribute and its related methods
get_scale_units() and set_scale_units() must be implemented. Those
define the concrete type of data, that is displayed on each axis of
the diagram (e.g. cm, inch, kg...).

The 'axes' attribute and its related methods get_axes() and
set_axes(), which have to be implemented. denote the axes, which are
used to set the data and its results into relation. A typical
cartesian coordinate plane for example will have two axes (x and y).

The 'orientation' attribute should be respected by inheritors to
allow displaying data in a vertical or horizontal align.

diagram.orientation = ORIENTATION_HORIZONTAL
diagram.set_orientation (ORIENTATION_VERTICAL)

The Diagram contains a 'negative' attribute and set_negative()
method, which indicate, whether negative values should be shown or
not.

diagram.negative = True
diagram.set_negative = False

The 'origin' attribute and set_origin() method set the point of
origin of the diagram on its widget surface and denote a tuple of an
x and y value. Inheritors should use this to set the point of origin
of their diagram type. Most diagram implementors usually would use
this as a relative coordinate to the bottom left corner of the
widget surface.
Note, that this is different from a real relative position on the
widget surface, as those are related to the topleft corner

diagram.origin = 10, 10
diagram.set_origin (20, 20)

The 'data' attribute and set_data() method set the data to be
evaluated by the diagram inheritor using the evaluate() method. It
is up to the inheritor to perform additional sanity checks.

diagram.data = mydata
diagram.set_data (mydata)

An evaluation function, which processes the set data can be set
using the 'eval_func' attribute or set_eval_func() method. If set,
the evaluate() method will process the set data using the eval_func
and store the return values in its 'values' attribute. Otherwise, the
values will be set to the data.

def power_1 (x):
    return x**2 - x

diagram.eval_func = power_1

The evaluate() method of the widget distinguishes between the type
of data and will act differently, dependant on whether it is a
sequence or not. Lists and tuples will be passed to the eval_func
using the python map() function, else the complete data will be
passed to the eval_func:

# Data is list or tuple:
self.values = map (self.eval_func, data)

# Any other type of data:
self.values = self.eval_func (data)

The result values can also be set manually without any processing
using the 'values' attribute and set_values() method. This can be
useful for inheritors like a bar chart for example.

self.values = myvalues
self.set_values (myvalues)

A concrete implementation of the Diagram class can be found as
Graph2D widget within this module.

Default action (invoked by activate()):
None

Mnemonic action (invoked by activate_mnemonic()):
None

Attributes:
scale_units - The scale unit(s) to set for the axes.
units       - Pixels per unit to set.
axes        - The axes to show.
negative    - Indicates, that negative vaues should be taken into
              account.
orientation - The orientation mapping of the axes.
origin      - The position of the point of origin on the widget.
data        - Data to evaluate.
values      - Result values of the set data after evaluation.
eval_func   - Evaluation function to calculate the values.

Method Summary
  __init__(self)
  evaluate(self)
D.evaluate () -> None
  get_axes(self)
D.get_axes (...) -> None
  get_scale_units(self)
D.get_scale_units (...) -> None
  get_units(self)
D.set_units (...) -> None
  set_axes(self, axes)
D.set_axes (...) -> None
  set_data(self, data)
D.set_data (...) -> 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_scale_units(self, units)
D.set_scale_units (...) -> None
  set_units(self, units)
D.set_units (...) -> 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
  draw(self)
W.draw () -> None
  draw_bg(self)
W.draw_bg () -> Surface
  get_style(self)
W.get_style () -> WidgetStyle
  initclass(cls)
B.initclass () -> None (Class method)
  lock(self)
W.lock () -> None
  notify(self, event)
W.notify (...) -> 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
  _get_rect(self)
W._get_rect () -> pygame.Rect
  _get_rect_attr(self, attr)
W._get_rect_attr (...) -> var
  _set_rect_attr(self, attr, value)
W._set_rect_attr (...) -> 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
  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

evaluate(self)

D.evaluate () -> None

Calulates the result values from the set data.

Calculates the result values from the set the data using the set evaluation function.

If the set data is a sequence, eval_func will be applied to each item of it (using map()) to build the return values:

values = map (eval_func, data)

If the set data is not a list or tuple, the data will be passed in it entirety to eval_func in order to calculate the return values:

values = eval_func (data)

The 'negative' attribute neither does affect the data nor the return values.

get_axes(self)

D.get_axes (...) -> None

Gets the amount and names of the axes.

This method has to be implemented by inherited widgets.

get_scale_units(self)

D.get_scale_units (...) -> None

Gets the scale units of the axes.

This method has to be implemented by inherited widgets.

get_units(self)

D.set_units (...) -> None

Gets the pixels per unit for dimensioning.

This method has to be implemented by inherited widgets.

set_axes(self, axes)

D.set_axes (...) -> None

Sets the amount and names of the axes.

This method has to be implemented by inherited widgets.

set_data(self, data)

D.set_data (...) -> None

Sets the data to evaluate.

This method does not perform any consistency checking or whatsoever.

set_eval_func(self, func)

D.set_eval_func (...) -> None

Sets the evaluation function for the data.

Raises a TypeError, if func is not callable.

set_negative(self, negative=True)

D.set_negative (...) -> None

Sets the indicator, whether negative values should be shown.

set_orientation(self, orientation='horizontal')

D.set_orientation (...) -> None

Sets the orientation of the axes.

Raises a ValueError, if the passed argument is not a value of the ORIENTATION_TYPES tuple.

set_origin(self, x, y)

D.set_origin (...) -> None

Sets the coordinates of the point of origin on the widget.

Raises a TypeError, if the passed arguments are not integers.

set_scale_units(self, units)

D.set_scale_units (...) -> None

Sets the scale units of the axes.

This method has to be implemented by inherited widgets.

set_units(self, units)

D.set_units (...) -> None

Sets the pixels per unit for dimensioning.

This method has to be implemented by inherited widgets.

set_values(self, values)

D.set_values (...) -> None

Sets the values without processing the data.

Property Details

axes

The axes to show.
Get Method:
unknown-696727116(...)
Set Method:
unknown-696727172(...)

data

The data to evaluate.
Get Method:
unknown-696727564(...)
Set Method:
unknown-696727620(...)

eval_func

The evaluation function for calculation.
Get Method:
unknown-696727788(...)
Set Method:
unknown-696727844(...)

negative

Indicates, whether negative values are shown.
Get Method:
unknown-696727228(...)
Set Method:
unknown-696727284(...)

orientation

The orientation of the axes.
Get Method:
unknown-696727340(...)
Set Method:
unknown-696727396(...)

origin

Coordinates of the point of origin on the widget
Get Method:
unknown-696727452(...)
Set Method:
unknown-696727508(...)

scale_units

The scale units of the axes.
Get Method:
unknown-696726892(...)
Set Method:
unknown-696726948(...)

units

The pixels per unit to set.
Get Method:
unknown-696727004(...)
Set Method:
unknown-696727060(...)

values

The calculated values of the set data.
Get Method:
unknown-696727676(...)
Set Method:
unknown-696727732(...)

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