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 |
|