source: trunk/gui/apps/driver @ 52

Last change on this file since 52 was 52, checked in by mmc, 19 years ago
  • Added a back door so we can debug Rappture applications running in the nanoHUB environment.
  • Added format and label controls to the axes of an XY plot.
  • Added a <molecule><about><emblems> directive, a boolean control indicating whether or not the molecule viewer should show the atom labels by default. If missing or "off", the labels are turned off. To turn labels on by default, this must be set to a boolean true value.
  • Fixed the packing bug that was causing tabbed notebooks to be the wrong size (size of last page, rather than max overall size).
  • Added -state option to comboboxes, so they can be disabled.
  • Added a grab stack, so that when a balloon dialog has the grab and a combobox steals it away, the balloon gets it back.
File size: 5.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  Purdue Research Foundation, West Lafayette, IN
19# ======================================================================
20#\
21exec wish "$0" $*
22# ----------------------------------------------------------------------
23# wish executes everything from here on...
24
25package require Rappture
26
27option add *MainWin.mode desktop startupFile
28option add *MainWin.borderWidth 0 startupFile
29option add *MainWin.anchor fill startupFile
30
31# "web site" look
32option add *MainWin.bgScript {
33    rectangle 0 0 200 <h> -outline "" -fill #5880BB
34    rectangle 200 0 300 <h> -outline "" -fill #425F8B
35    rectangle 300 0 <w> <h> -outline "" -fill #324565
36} startupFile
37
38# "clean" look
39option add *MainWin.bgScript "" startupFile
40option add *MainWin.bgColor white startupFile
41option add *Tooltip.background white
42option add *Editor.background white
43option add *Gauge.textBackground white
44option add *TemperatureGauge.textBackground white
45option add *Switch.textBackground white
46option add *Progress.barColor #ffffcc
47
48switch $tcl_platform(platform) {
49    unix - windows {
50        event add <<PopupMenu>> <ButtonPress-3>
51    }
52    macintosh {
53        event add <<PopupMenu>> <Control-ButtonPress-1>
54    }
55}
56
57# fix the "grab" command to support a stack of grab windows
58Rappture::grab::init
59
60#
61# Process command line args to get the names of files to load...
62#
63Rappture::getopts argv params {
64    value -tool tool.xml
65}
66
67# open the XML file containing the tool parameters
68if {![file exists $params(-tool)]} {
69    puts stderr "can't find tool \"$params(-tool)\""
70    exit 1
71}
72set xmlobj [Rappture::library $params(-tool)]
73
74set installdir [file dirname $params(-tool)]
75if {"." == $installdir} {
76    set installdir [pwd]
77}
78
79set tool [Rappture::Tool ::#auto $xmlobj $installdir]
80
81# ----------------------------------------------------------------------
82# INITIALIZE THE DESKTOP CONNECTION
83#
84# If there's a SESSION ID, then this must be running within the
85# nanoHUB.  Try to initialize the server handling the desktop
86# connection.
87# ----------------------------------------------------------------------
88Rappture::filexfer::init
89
90# ----------------------------------------------------------------------
91# MAIN WINDOW
92# ----------------------------------------------------------------------
93wm withdraw .
94Rappture::MainWin .main -borderwidth 0
95.main configure -title [$tool xml get tool.title]
96wm withdraw .main
97
98#
99# The main window has a pager that acts as a notebook for the
100# various parts.  This notebook as at least two pages--an input
101# page and an output (analysis) page.  If there are <phase>'s
102# for input, then there are more pages in the notebook.
103#
104set win [.main component app]
105Rappture::Postern $win.postern
106pack $win.postern -side bottom -fill x
107
108Rappture::Pager $win.pager
109pack $win.pager -expand yes -fill both
110
111set phases [$tool xml children -type phase input]
112if {[llength $phases] > 0} {
113    set plist ""
114    foreach name $phases {
115        lappend plist input.$name
116    }
117    set phases $plist
118} else {
119    set phases input
120}
121
122foreach comp $phases {
123    set title [$tool xml get $comp.about.label]
124    if {$title == ""} {
125        set title "Input #auto"
126    }
127    $win.pager insert end -name $comp -title $title
128
129    #
130    # Build the page of input controls for this phase.
131    #
132    set f [$win.pager page $comp]
133    Rappture::Page $f.cntls $tool $comp
134    pack $f.cntls -expand yes -fill both
135}
136
137# ----------------------------------------------------------------------
138# OUTPUT AREA
139# ----------------------------------------------------------------------
140$win.pager insert end -name analyzer -title "Run"
141set f [$win.pager page analyzer]
142$win.pager page analyzer -command [list $f.analyze simulate -ifneeded]
143
144Rappture::Analyzer $f.analyze $tool -simcontrol auto
145pack $f.analyze -expand yes -fill both
146
147$tool notify add analyzer * [list $f.analyze reset]
148
149# ----------------------------------------------------------------------
150# Finalize the arrangement
151# ----------------------------------------------------------------------
152if {[llength [$win.pager page]] == 2} {
153    set style [$xmlobj get tool.layout]
154    set screenw [winfo screenwidth .]
155
156    update idletasks
157    set w0 [winfo reqwidth [$win.pager page @0]]
158    set w1 [winfo reqwidth [$win.pager page @1]]
159
160    # if only two windows and they're small enough, put them up side-by-side
161    if {$w0+$w1 < $screenw && $style != "wizard"} {
162        $win.pager configure -arrangement side-by-side
163        $f.analyze configure -holdwindow [$win.pager page @0]
164
165        set type [$tool xml get tool.control]
166        if {$type == ""} {
167            set type [$tool xml get tool.control.type]
168        }
169
170        if {$type == "auto"} {
171            # in "auto" mode, we don't need a simulate button
172            $f.analyze configure -simcontrol off
173        } else {
174            # not in "auto" mode but side-by-side, we always need the button
175            $f.analyze configure -simcontrol on
176        }
177    }
178}
179wm deiconify .main
Note: See TracBrowser for help on using the repository browser.