~ubuntu-branches/ubuntu/natty/mgltools-vision/natty

« back to all changes in this revision

Viewing changes to Vision/doc/Tutorial/cartoon/cartoon5_net.py

  • Committer: Bazaar Package Importer
  • Author(s): Steffen Moeller
  • Date: 2008-07-31 22:00:08 UTC
  • Revision ID: james.westby@ubuntu.com-20080731220008-broax3qn6pq9ygnb
Tags: upstream-1.5.2.cvs.20080731
ImportĀ upstreamĀ versionĀ 1.5.2.cvs.20080731

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/ksh ~/.mgltools/pythonsh
 
2
########################################################################
 
3
#
 
4
#    Vision Network - Python source code - file generated by vision
 
5
#    Tuesday 13 November 2007 14:49:16 
 
6
#    
 
7
#       The Scripps Research Institute (TSRI)
 
8
#       Molecular Graphics Lab
 
9
#       La Jolla, CA 92037, USA
 
10
#
 
11
# Copyright: Daniel Stoffler, Michel Sanner and TSRI
 
12
#   
 
13
# revision: Guillaume Vareille
 
14
#  
 
15
#########################################################################
 
16
#
 
17
# $Header: /opt/cvs/python/packages/share1.5/Vision/doc/Tutorial/cartoon/cartoon5_net.py,v 1.9 2007/11/13 23:23:43 vareille Exp $
 
18
#
 
19
# $Id: cartoon5_net.py,v 1.9 2007/11/13 23:23:43 vareille Exp $
 
20
#
 
21
 
 
22
 
 
23
if __name__=='__main__':
 
24
    from Vision import launchVisionToRunNetworkAsApplication, mainLoopVisionToRunNetworkAsApplication
 
25
    masterNet = launchVisionToRunNetworkAsApplication()
 
26
    import os
 
27
    masterNet.filename = os.path.abspath(__file__)
 
28
from traceback import print_exc
 
29
masterNet.createUserPanel('MyApp' ,width=178, height=245)
 
30
## loading libraries ##
 
31
from Vision.PILNodes import imagelib
 
32
masterNet.getEditor().addLibraryInstance(imagelib,"Vision.PILNodes", "imagelib")
 
33
 
 
34
from Vision.StandardNodes import stdlib
 
35
masterNet.getEditor().addLibraryInstance(stdlib,"Vision.StandardNodes", "stdlib")
 
36
 
 
37
try:
 
38
    ## saving node Filelist ##
 
39
    from Vision.StandardNodes import Filelist
 
40
    Filelist_0 = Filelist(constrkw = {}, name='Filelist', library=stdlib)
 
41
    masterNet.addNode(Filelist_0,14,6)
 
42
    apply(Filelist_0.inputPortByName['match_str'].widget.configure, (), {'master': 'MyApp', 'widgetPlacerCfg': {'rely': '0.8816', 'relx': '0.5787'}})
 
43
    Filelist_0.inputPortByName['match_str'].widget.set("cartoonMovie/*.png", run=False)
 
44
except:
 
45
    print "WARNING: failed to restore Filelist named Filelist in network masterNet"
 
46
    print_exc()
 
47
    Filelist_0=None
 
48
 
 
49
try:
 
50
    ## saving node Read Image ##
 
51
    from Vision.PILNodes import ReadImage
 
52
    Read_Image_1 = ReadImage(constrkw = {}, name='Read Image', library=imagelib)
 
53
    masterNet.addNode(Read_Image_1,20,264)
 
54
    apply(Read_Image_1.inputPortByName['filename'].configure, (), {'datatype': 'string', 'originalDatatype': 'str'})
 
55
    Read_Image_1.inputPortByName['filename'].widget.set("", run=False)
 
56
    Read_Image_1.inputPortByName['filename'].unbindWidget()
 
57
except:
 
58
    print "WARNING: failed to restore ReadImage named Read Image in network masterNet"
 
59
    print_exc()
 
60
    Read_Image_1=None
 
61
 
 
62
try:
 
63
    ## saving node Scale ##
 
64
    from Vision.PILNodes import ResizeImage
 
65
    Scale_2 = ResizeImage(constrkw = {}, name='Scale', library=imagelib)
 
66
    masterNet.addNode(Scale_2,22,317)
 
67
    apply(Scale_2.inputPortByName['scale'].widget.configure, (), {'widgetGridCfg': {'labelSide': 'left'}, 'master': 'MyApp', 'widgetPlacerCfg': {'rely': '0.5143', 'relx': '0.5112'}, 'widgetGridCfgMyApp': {'labelSide': 'left'}})
 
68
    Scale_2.inputPortByName['scale'].widget.set(0.376964776024, run=False)
 
69
except:
 
70
    print "WARNING: failed to restore ResizeImage named Scale in network masterNet"
 
71
    print_exc()
 
72
    Scale_2=None
 
73
 
 
74
try:
 
75
    ## saving node Show Image ##
 
76
    from Vision.PILNodes import ShowImage
 
77
    Show_Image_3 = ShowImage(constrkw = {}, name='Show Image', library=imagelib)
 
78
    masterNet.addNode(Show_Image_3,21,374)
 
79
except:
 
80
    print "WARNING: failed to restore ShowImage named Show Image in network masterNet"
 
81
    print_exc()
 
82
    Show_Image_3=None
 
83
 
 
84
try:
 
85
    ## saving node call method ##
 
86
    from Vision.StandardNodes import CallMethod
 
87
    call_method_4 = CallMethod(constrkw = {}, name='call method', library=stdlib)
 
88
    masterNet.addNode(call_method_4,3,85)
 
89
    call_method_4.inputPortByName['signature'].widget.set("sort", run=False)
 
90
    apply(call_method_4.configure, (), {'expanded': True})
 
91
except:
 
92
    print "WARNING: failed to restore CallMethod named call method in network masterNet"
 
93
    print_exc()
 
94
    call_method_4=None
 
95
 
 
96
try:
 
97
    ## saving node Index ##
 
98
    from Vision.StandardNodes import Index
 
99
    Index_5 = Index(constrkw = {}, name='Index', library=stdlib)
 
100
    masterNet.addNode(Index_5,41,182)
 
101
    apply(Index_5.inputPortByName['index'].widget.configure, (), {'max': 100, 'master': 'MyApp', 'widgetPlacerCfg': {'rely': '0.1429', 'relx': '0.5225'}})
 
102
except:
 
103
    print "WARNING: failed to restore Index named Index in network masterNet"
 
104
    print_exc()
 
105
    Index_5=None
 
106
 
 
107
masterNet.run()
 
108
masterNet.freeze()
 
109
 
 
110
## saving connections for network cartoon5 ##
 
111
if Read_Image_1 is not None and Scale_2 is not None:
 
112
    try:
 
113
        masterNet.connectNodes(
 
114
            Read_Image_1, Scale_2, "image", "image", blocking=True)
 
115
    except:
 
116
        print "WARNING: failed to restore connection between Read_Image_1 and Scale_2 in network masterNet"
 
117
if Scale_2 is not None and Show_Image_3 is not None:
 
118
    try:
 
119
        masterNet.connectNodes(
 
120
            Scale_2, Show_Image_3, "scaledImage", "image", blocking=True)
 
121
    except:
 
122
        print "WARNING: failed to restore connection between Scale_2 and Show_Image_3 in network masterNet"
 
123
if Filelist_0 is not None and call_method_4 is not None:
 
124
    try:
 
125
        masterNet.connectNodes(
 
126
            Filelist_0, call_method_4, "filelist", "objects", blocking=True)
 
127
    except:
 
128
        print "WARNING: failed to restore connection between Filelist_0 and call_method_4 in network masterNet"
 
129
if call_method_4 is not None and Index_5 is not None:
 
130
    try:
 
131
        masterNet.connectNodes(
 
132
            call_method_4, Index_5, "objects", "data", blocking=True)
 
133
    except:
 
134
        print "WARNING: failed to restore connection between call_method_4 and Index_5 in network masterNet"
 
135
if Index_5 is not None and Read_Image_1 is not None:
 
136
    try:
 
137
        masterNet.connectNodes(
 
138
            Index_5, Read_Image_1, "data", "filename", blocking=True)
 
139
    except:
 
140
        print "WARNING: failed to restore connection between Index_5 and Read_Image_1 in network masterNet"
 
141
masterNet.unfreeze()
 
142
 
 
143
#masterNet.run()
 
144
 
 
145
if __name__=='__main__':
 
146
    mainLoopVisionToRunNetworkAsApplication(masterNet.editor)