source: trunk/gui/apps/driver @ 158

Last change on this file since 158 was 158, checked in by mmc, 19 years ago
  • Fixed installation so that this "gui" part can be installed with standard autoconf techniques: configure, make all, make install The "gui" library is loaded via "package require RapptureGUI"
  • Added C code for Rappture::rlimit, to support limits on CPU time and file sizes. Default limits are 15 mins of CPU and 1MB for each file. These can be overridden in tool.xml by using <tool><limits><cputime> and <tool><limits><filesize>.
  • Added C code for Rappture::rusage, so we can collect resource usage for all child processes. Each Simulation now reports a line of usage to stderr as follows:

MiddlewareTime?: job=# event=simulation start=xxx cputime=xxx ...

  • Fixed Rappture::exec so that it reports proper error messages when rlimits are execeeded.
File size: 5.8 KB
Line 
1#!/bin/sh
2# ----------------------------------------------------------------------
3#  USER INTERFACE DRIVER
4#
5#  This driver program loads a tool description from a tool.xml file,
6#  and produces a user interface automatically to drive an application.
7#  The user can set up input, click and button to launch a tool, and
8#  browse through output.
9#
10#  RUN AS FOLLOWS:
11#    driver ?-tool <toolfile>?
12#
13#  If the <toolfile> is not specified, it defaults to "tool.xml" in
14#  the current working directory.
15#
16# ======================================================================
17#  AUTHOR:  Michael McLennan, Purdue University
18#  Copyright (c) 2004-2005  Purdue Research Foundation
19#
20#  See the file "license.terms" for information on usage and
21#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
22# ======================================================================
23#\
24exec wish "$0" $*
25# ----------------------------------------------------------------------
26# wish executes everything from here on...
27
28package require Rappture
29package require RapptureGUI
30
31option add *MainWin.mode desktop startupFile
32option add *MainWin.borderWidth 0 startupFile
33option add *MainWin.anchor fill startupFile
34
35# "web site" look
36option add *MainWin.bgScript {
37    rectangle 0 0 200 <h> -outline "" -fill #5880BB
38    rectangle 200 0 300 <h> -outline "" -fill #425F8B
39    rectangle 300 0 <w> <h> -outline "" -fill #324565
40} startupFile
41
42# "clean" look
43option add *MainWin.bgScript "" startupFile
44option add *MainWin.bgColor white startupFile
45option add *Tooltip.background white
46option add *Editor.background white
47option add *Gauge.textBackground white
48option add *TemperatureGauge.textBackground white
49option add *Switch.textBackground white
50option add *Progress.barColor #ffffcc
51
52switch $tcl_platform(platform) {
53    unix - windows {
54        event add <<PopupMenu>> <ButtonPress-3>
55    }
56    macintosh {
57        event add <<PopupMenu>> <Control-ButtonPress-1>
58    }
59}
60
61# fix the "grab" command to support a stack of grab windows
62Rappture::grab::init
63
64#
65# Process command line args to get the names of files to load...
66#
67Rappture::getopts argv params {
68    value -tool tool.xml
69}
70
71# open the XML file containing the tool parameters
72if {![file exists $params(-tool)]} {
73    puts stderr "can't find tool \"$params(-tool)\""
74    exit 1
75}
76set xmlobj [Rappture::library $params(-tool)]
77
78set installdir [file dirname $params(-tool)]
79if {"." == $installdir} {
80    set installdir [pwd]
81}
82
83set tool [Rappture::Tool ::#auto $xmlobj $installdir]
84
85# ----------------------------------------------------------------------
86# INITIALIZE THE DESKTOP CONNECTION
87#
88# If there's a SESSION ID, then this must be running within the
89# nanoHUB.  Try to initialize the server handling the desktop
90# connection.
91# ----------------------------------------------------------------------
92Rappture::filexfer::init
93
94# ----------------------------------------------------------------------
95# MAIN WINDOW
96# ----------------------------------------------------------------------
97wm withdraw .
98Rappture::MainWin .main -borderwidth 0
99.main configure -title [$tool xml get tool.title]
100wm withdraw .main
101
102# if the FULLSCREEN variable is set, then nanoHUB wants us to go full screen
103if {[info exists env(FULLSCREEN)]} {
104    .main configure -mode web
105}
106
107#
108# The main window has a pager that acts as a notebook for the
109# various parts.  This notebook as at least two pages--an input
110# page and an output (analysis) page.  If there are <phase>'s
111# for input, then there are more pages in the notebook.
112#
113set win [.main component app]
114Rappture::Postern $win.postern
115pack $win.postern -side bottom -fill x
116
117Rappture::Pager $win.pager
118pack $win.pager -expand yes -fill both
119
120set phases [$tool xml children -type phase input]
121if {[llength $phases] > 0} {
122    set plist ""
123    foreach name $phases {
124        lappend plist input.$name
125    }
126    set phases $plist
127} else {
128    set phases input
129}
130
131foreach comp $phases {
132    set title [$tool xml get $comp.about.label]
133    if {$title == ""} {
134        set title "Input #auto"
135    }
136    $win.pager insert end -name $comp -title $title
137
138    #
139    # Build the page of input controls for this phase.
140    #
141    set f [$win.pager page $comp]
142    Rappture::Page $f.cntls $tool $comp
143    pack $f.cntls -expand yes -fill both
144}
145
146# ----------------------------------------------------------------------
147# OUTPUT AREA
148# ----------------------------------------------------------------------
149$win.pager insert end -name analyzer -title "Simulate"
150set f [$win.pager page analyzer]
151$win.pager page analyzer -command [list $f.analyze simulate -ifneeded]
152
153Rappture::Analyzer $f.analyze $tool -simcontrol auto
154pack $f.analyze -expand yes -fill both
155
156$tool notify add analyzer * [list $f.analyze reset]
157
158# ----------------------------------------------------------------------
159# Finalize the arrangement
160# ----------------------------------------------------------------------
161if {[llength [$win.pager page]] == 2} {
162    set style [$xmlobj get tool.layout]
163    set screenw [winfo screenwidth .]
164
165    update idletasks
166    set w0 [winfo reqwidth [$win.pager page @0]]
167    set w1 [winfo reqwidth [$win.pager page @1]]
168
169    # if only two windows and they're small enough, put them up side-by-side
170    if {$w0+$w1 < $screenw && $style != "wizard"} {
171        $win.pager configure -arrangement side-by-side
172        $f.analyze configure -holdwindow [$win.pager page @0]
173
174        set type [$tool xml get tool.control]
175        if {$type == ""} {
176            set type [$tool xml get tool.control.type]
177        }
178
179        if {$type == "auto"} {
180            # in "auto" mode, we don't need a simulate button
181            $f.analyze configure -simcontrol off
182        } else {
183            # not in "auto" mode but side-by-side, we always need the button
184            $f.analyze configure -simcontrol on
185        }
186    }
187}
188wm deiconify .main
Note: See TracBrowser for help on using the repository browser.