/[ascend]/trunk/pygtk/canvas/blocktype.py
ViewVC logotype

Contents of /trunk/pygtk/canvas/blocktype.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1954 - (show annotations) (download) (as text)
Tue Nov 11 10:01:18 2008 UTC (14 years ago) by jpye
File MIME type: text/x-python
File size: 1555 byte(s)
Some changes to facilitate pickling.
1 import pygtk
2 pygtk.require('2.0')
3 import gtk
4 import ascpy
5
6 class BlockType:
7 """
8 All data associated with the MODEL type that is represented by a block.
9 This includes the actual ASCEND TypeDescription as well as the NOTES that
10 are found to represent the inputs and outputs for this block, as well as
11 some kind of graphical representation(s) for the block. In the canvas-
12 based GUI, there will need to be a Cairo-based represention, for drawing
13 on the canvas, as well as some other form, for creating the icon in the
14 block palette.
15 """
16 # FIXME there is no definition here of the canvas graphical representation,
17 # but there should be.
18
19 def __init__(self, typedesc, notesdb):
20 self.type = typedesc
21 self.notesdb = notesdb
22
23 # FIXME BlockType should know what .a4c file to load in order to access
24 # its type definition, for use in unpickling.
25 self.sourcefile = None
26
27 nn = notesdb.getTypeRefinedNotesLang(self.type,ascpy.SymChar("inline"))
28
29 self.inputs = []
30 self.outputs = []
31 for n in nn:
32 t = n.getText()
33 if t[0:min(len(t),3)]=="in:":
34 self.inputs += [n]
35 elif t[0:min(len(t),4)]=="out:":
36 self.outputs += [n]
37
38 def get_icon(self, width, height):
39 return gtk.gdk.pixbuf_new_from_file_at_size("defaultblock.svg",width,height)
40
41 def __getstate__(self):
42 print "GET STATE ON BLOCKTYPE %s" % self.type.getName()
43 return (str(self.type.getName()),)
44
45 def __setstate__(self, state):
46 print "SET STATE ON BLOCKTYPE"
47 (typename,) = state
48 print "Recreating type '%s'" % typename
49 self.type = None
50 self.notesdb = None

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22