source: trunk/gui/apps/driver @ 462

Last change on this file since 462 was 462, checked in by mmc, 15 years ago

Fixed nanovis to take a series of server names as a comma-separated
list, and to try them one after another to make a connection. That
way, if one server is down, you can still reach the rest of the farm.

Added a customized bug handler that looks a little less frightening
than the standard Tcl dialog. Someday, this should log all errors
to a web service, but for now, it just encourages the user to do so.

File size: 6.5 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 Itcl
29package require Rappture
30package require RapptureGUI
31
32# install a better bug handler
33Rappture::bugreport::install
34
35option add *MainWin.mode desktop startupFile
36option add *MainWin.borderWidth 0 startupFile
37option add *MainWin.anchor fill startupFile
38
39# "web site" look
40option add *MainWin.bgScript {
41    rectangle 0 0 200 <h> -outline "" -fill #5880BB
42    rectangle 200 0 300 <h> -outline "" -fill #425F8B
43    rectangle 300 0 <w> <h> -outline "" -fill #324565
44} startupFile
45
46# "clean" look
47option add *MainWin.bgScript "" startupFile
48option add *MainWin.bgColor white startupFile
49option add *Tooltip.background white
50option add *Editor.background white
51option add *Gauge.textBackground white
52option add *TemperatureGauge.textBackground white
53option add *Switch.textBackground white
54option add *Progress.barColor #ffffcc
55option add *Balloon.titleBackground #6666cc
56option add *Balloon.titleForeground white
57option add *ResultSet.controlbarBackground #6666cc
58option add *ResultSet.controlbarForeground white
59option add *ResultSet.activeControlBackground #ccccff
60option add *ResultSet.activeControlForeground black
61option add *Radiodial.length 3i
62
63switch $tcl_platform(platform) {
64    unix - windows {
65        event add <<PopupMenu>> <ButtonPress-3>
66    }
67    macintosh {
68        event add <<PopupMenu>> <Control-ButtonPress-1>
69    }
70}
71
72# fix the "grab" command to support a stack of grab windows
73Rappture::grab::init
74
75#
76# Process command line args to get the names of files to load...
77#
78Rappture::getopts argv params {
79    value -tool tool.xml
80}
81
82# open the XML file containing the tool parameters
83if {![file exists $params(-tool)]} {
84    puts stderr "can't find tool \"$params(-tool)\""
85    exit 1
86}
87set xmlobj [Rappture::library $params(-tool)]
88
89set installdir [file dirname $params(-tool)]
90if {"." == $installdir} {
91    set installdir [pwd]
92}
93
94set tool [Rappture::Tool ::#auto $xmlobj $installdir]
95
96# ----------------------------------------------------------------------
97# LOAD RESOURCE SETTINGS
98#
99# Try to load the $SESSIONDIR/resources file, which contains
100# middleware settings, such as the application name and the
101# filexfer settings.
102# ----------------------------------------------------------------------
103Rappture::resources::load
104
105# ----------------------------------------------------------------------
106# INITIALIZE THE DESKTOP CONNECTION
107#
108# If there's a SESSION ID, then this must be running within the
109# nanoHUB.  Try to initialize the server handling the desktop
110# connection.
111# ----------------------------------------------------------------------
112Rappture::filexfer::init
113
114# ----------------------------------------------------------------------
115# MAIN WINDOW
116# ----------------------------------------------------------------------
117wm withdraw .
118Rappture::MainWin .main -borderwidth 0
119.main configure -title [$tool xml get tool.title]
120wm withdraw .main
121
122# if the FULLSCREEN variable is set, then nanoHUB wants us to go full screen
123if {[info exists env(FULLSCREEN)]} {
124    .main configure -mode web
125}
126
127#
128# The main window has a pager that acts as a notebook for the
129# various parts.  This notebook as at least two pages--an input
130# page and an output (analysis) page.  If there are <phase>'s
131# for input, then there are more pages in the notebook.
132#
133set win [.main component app]
134Rappture::Postern $win.postern
135pack $win.postern -side bottom -fill x
136
137Rappture::Pager $win.pager
138pack $win.pager -expand yes -fill both
139
140set phases [$tool xml children -type phase input]
141if {[llength $phases] > 0} {
142    set plist ""
143    foreach name $phases {
144        lappend plist input.$name
145    }
146    set phases $plist
147} else {
148    set phases input
149}
150
151foreach comp $phases {
152    set title [$tool xml get $comp.about.label]
153    if {$title == ""} {
154        set title "Input #auto"
155    }
156    $win.pager insert end -name $comp -title $title
157
158    #
159    # Build the page of input controls for this phase.
160    #
161    set f [$win.pager page $comp]
162    Rappture::Page $f.cntls $tool $comp
163    pack $f.cntls -expand yes -fill both
164}
165
166# ----------------------------------------------------------------------
167# OUTPUT AREA
168# ----------------------------------------------------------------------
169$win.pager insert end -name analyzer -title "Simulate"
170set f [$win.pager page analyzer]
171$win.pager page analyzer -command [list $f.analyze simulate -ifneeded]
172
173Rappture::Analyzer $f.analyze $tool -simcontrol auto
174pack $f.analyze -expand yes -fill both
175
176$tool notify add analyzer * [list $f.analyze reset]
177
178# ----------------------------------------------------------------------
179# Finalize the arrangement
180# ----------------------------------------------------------------------
181if {[llength [$win.pager page]] == 2} {
182    set style [$xmlobj get tool.layout]
183    set screenw [winfo screenwidth .]
184
185    update idletasks
186    set w0 [winfo reqwidth [$win.pager page @0]]
187    set w1 [winfo reqwidth [$win.pager page @1]]
188
189    # if only two windows and they're small enough, put them up side-by-side
190    if {$w0+$w1 < $screenw && $style != "wizard"} {
191        $win.pager configure -arrangement side-by-side
192        $f.analyze configure -holdwindow [$win.pager page @0]
193
194        set type [$tool xml get tool.control]
195        if {$type == ""} {
196            set type [$tool xml get tool.control.type]
197        }
198
199        if {$type == "auto"} {
200            # in "auto" mode, we don't need a simulate button
201            $f.analyze configure -simcontrol off
202        } else {
203            # not in "auto" mode but side-by-side, we always need the button
204            $f.analyze configure -simcontrol on
205        }
206    }
207}
208wm deiconify .main
Note: See TracBrowser for help on using the repository browser.