Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
electric.Node Class Reference

List of all members.

Public Member Functions

def __init__
def create
def get_component
def add_wire
def remove_wire
def renumber_wire
def get_wires
def has_wire
def move

Public Attributes

 image
 name
 x
 y
 wires
 item
 component
 rootitem
 center_x
 center_y

Detailed Description

Definition at line 630 of file electric.py.


Constructor & Destructor Documentation

def electric.Node.__init__ (   self,
  image,
  name,
  x,
  y 
)

Definition at line 631 of file electric.py.

00631 
00632     def __init__(self, image, name, x, y):
00633       self.image = image
00634       self.name  = name
00635       self.x     = x
00636       self.y     = y
00637       self.wires = []
00638       self.item  = None


Member Function Documentation

def electric.Node.add_wire (   self,
  wire 
)

Definition at line 661 of file electric.py.

00661 
00662     def add_wire(self, wire):
00663       self.wires.append(wire)

def electric.Node.create (   self,
  component,
  x,
  y 
)

Definition at line 640 of file electric.py.

00640 
00641     def create(self, component, x, y):
00642       self.component = component
00643       self.rootitem = component.get_rootitem()
00644       pixmap = gcompris.utils.load_pixmap(self.image)
00645       self.center_x =  pixmap.get_width()/2
00646       self.center_y =  pixmap.get_height()/2
00647 
00648       self.item = self.rootitem.add(
00649         gnomecanvas.CanvasPixbuf,
00650         pixbuf = pixmap,
00651         x = x + self.center_x,
00652         y = y + self.center_y,
00653         )
00654       self.item.set_data('node', self)
00655       return self.item
00656 

Definition at line 657 of file electric.py.

00657 
00658     def get_component(self):
00659       return self.component

def electric.Node.get_wires (   self)

Definition at line 682 of file electric.py.

00682 
00683     def get_wires(self):
00684       return(self.wires)

def electric.Node.has_wire (   self,
  wire 
)

Definition at line 687 of file electric.py.

00687 
00688     def has_wire(self, wire):
00689       try:
00690         if(self.wires.index(wire)):
00691           return True
00692         else:
00693           return False
00694       except:
00695         pass
00696 

def electric.Node.move (   self,
  x,
  y 
)

Definition at line 697 of file electric.py.

00697 
00698     def move(self, x, y):
00699       if(self.item):
00700         self.item.set(x = x + self.x,
00701                       y = y + self.y)
00702 
00703       for wire in self.wires:
00704         wire.move(self,
00705                   x + self.x + self.center_x,
00706                   y + self.y + self.center_y)
00707 
00708 
00709 #------------------------------------------------------------
00710 # Component
00711 #
# nodes is a list of class Node object

Here is the caller graph for this function:

def electric.Node.remove_wire (   self,
  wire,
  wire_id 
)

Definition at line 666 of file electric.py.

00666 
00667     def remove_wire(self, wire, wire_id):
00668       try:
00669         self.wires.remove(wire)
00670         if(wire_id):
00671           self.renumber_wire(wire, wire_id)
00672       except:
00673         pass
00674 

Here is the call graph for this function:

def electric.Node.renumber_wire (   self,
  wire,
  wire_id 
)

Definition at line 676 of file electric.py.

00676 
00677     def renumber_wire(self, wire, wire_id):
00678       for wire in self.wires:
00679         if(wire.get_wire_id() != wire_id):
00680           wire.set_wire_id(wire_id)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 644 of file electric.py.

Definition at line 645 of file electric.py.

Definition at line 641 of file electric.py.

Definition at line 632 of file electric.py.

Definition at line 637 of file electric.py.

Definition at line 633 of file electric.py.

Definition at line 642 of file electric.py.

Definition at line 636 of file electric.py.

Definition at line 634 of file electric.py.

Definition at line 635 of file electric.py.


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