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
RevLine 
[1]1#!/bin/sh
2# ----------------------------------------------------------------------
3#  USER INTERFACE DRIVER
4#
5#  This driver program loads a tool description from a tool.xml file,
[11]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.
[1]9#
10#  RUN AS FOLLOWS:
[11]11#    driver ?-tool <toolfile>?
[1]12#
[11]13#  If the <toolfile> is not specified, it defaults to "tool.xml" in
14#  the current working directory.
[1]15#
16# ======================================================================
17#  AUTHOR:  Michael McLennan, Purdue University
[115]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.
[1]22# ======================================================================
23#\
24exec wish "$0" $*
25# ----------------------------------------------------------------------
26# wish executes everything from here on...
27
[365]28package require Itcl
[1]29package require Rappture
[158]30package require RapptureGUI
[1]31
[22]32option add *MainWin.mode desktop startupFile
[1]33option add *MainWin.borderWidth 0 startupFile
[44]34option add *MainWin.anchor fill startupFile
[1]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
[9]46option add *Tooltip.background white
[11]47option add *Editor.background white
48option add *Gauge.textBackground white
49option add *TemperatureGauge.textBackground white
[13]50option add *Switch.textBackground white
[23]51option add *Progress.barColor #ffffcc
[413]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
[1]59
[17]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
[52]69# fix the "grab" command to support a stack of grab windows
70Rappture::grab::init
71
[1]72#
73# Process command line args to get the names of files to load...
74#
[11]75Rappture::getopts argv params {
76    value -tool tool.xml
[1]77}
78
79# open the XML file containing the tool parameters
[11]80if {![file exists $params(-tool)]} {
81    puts stderr "can't find tool \"$params(-tool)\""
[1]82    exit 1
83}
[11]84set xmlobj [Rappture::library $params(-tool)]
85
86set installdir [file dirname $params(-tool)]
87if {"." == $installdir} {
88    set installdir [pwd]
[1]89}
90
[11]91set tool [Rappture::Tool ::#auto $xmlobj $installdir]
[1]92
93# ----------------------------------------------------------------------
[413]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# ----------------------------------------------------------------------
[50]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# ----------------------------------------------------------------------
[1]112# MAIN WINDOW
113# ----------------------------------------------------------------------
114wm withdraw .
115Rappture::MainWin .main -borderwidth 0
[11]116.main configure -title [$tool xml get tool.title]
117wm withdraw .main
[1]118
[56]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
[11]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#
[1]130set win [.main component app]
[52]131Rappture::Postern $win.postern
132pack $win.postern -side bottom -fill x
133
[11]134Rappture::Pager $win.pager
135pack $win.pager -expand yes -fill both
[1]136
[11]137set phases [$tool xml children -type phase input]
138if {[llength $phases] > 0} {
139    set plist ""
140    foreach name $phases {
141        lappend plist input.$name
[1]142    }
[11]143    set phases $plist
144} else {
145    set phases input
146}
[1]147
[11]148foreach comp $phases {
149    set title [$tool xml get $comp.about.label]
150    if {$title == ""} {
151        set title "Input #auto"
[1]152    }
[11]153    $win.pager insert end -name $comp -title $title
[1]154
[11]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
[1]161}
162
163# ----------------------------------------------------------------------
164# OUTPUT AREA
165# ----------------------------------------------------------------------
[64]166$win.pager insert end -name analyzer -title "Simulate"
[11]167set f [$win.pager page analyzer]
168$win.pager page analyzer -command [list $f.analyze simulate -ifneeded]
[1]169
[11]170Rappture::Analyzer $f.analyze $tool -simcontrol auto
171pack $f.analyze -expand yes -fill both
172
[22]173$tool notify add analyzer * [list $f.analyze reset]
[11]174
[1]175# ----------------------------------------------------------------------
[11]176# Finalize the arrangement
[1]177# ----------------------------------------------------------------------
[11]178if {[llength [$win.pager page]] == 2} {
179    set style [$xmlobj get tool.layout]
180    set screenw [winfo screenwidth .]
[9]181
[11]182    update idletasks
183    set w0 [winfo reqwidth [$win.pager page @0]]
184    set w1 [winfo reqwidth [$win.pager page @1]]
[9]185
[11]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
[12]189        $f.analyze configure -holdwindow [$win.pager page @0]
190
[22]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"} {
[12]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        }
[9]203    }
[1]204}
[11]205wm deiconify .main
Note: See TracBrowser for help on using the repository browser.