source: trunk/gui/apps/driver @ 942

Last change on this file since 942 was 942, checked in by gah, 16 years ago

Makefile fixups

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