source: trunk/gui/apps/driver @ 413

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