source: trunk/gui/apps/driver @ 64

Last change on this file since 64 was 64, checked in by mmc, 19 years ago

Lots of fixes for app-pntoy and other tools:

  • Fixed plotting to recognize "-color name" in the style section, and to use auto colors for overlayed plots.
  • Fixed x-y plotting to keep axes instead of resetting when flipping back and forth between plots.
  • Fixed 1D fields to support new lin/log limits queries, so it plots properly.
  • Added support for <string> output values.
  • Fixed molecular viewer so that 3D rotation is unconstrained and more intuitive.
  • Fixed Rappture::exec to handle newlines properly. Sometimes output would get all mixed together without newlines. Works better now.
File size: 5.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  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# if the FULLSCREEN variable is set, then nanoHUB wants us to go full screen
99if {[info exists env(FULLSCREEN)]} {
100    .main configure -mode web
101}
102
103#
104# The main window has a pager that acts as a notebook for the
105# various parts.  This notebook as at least two pages--an input
106# page and an output (analysis) page.  If there are <phase>'s
107# for input, then there are more pages in the notebook.
108#
109set win [.main component app]
110Rappture::Postern $win.postern
111pack $win.postern -side bottom -fill x
112
113Rappture::Pager $win.pager
114pack $win.pager -expand yes -fill both
115
116set phases [$tool xml children -type phase input]
117if {[llength $phases] > 0} {
118    set plist ""
119    foreach name $phases {
120        lappend plist input.$name
121    }
122    set phases $plist
123} else {
124    set phases input
125}
126
127foreach comp $phases {
128    set title [$tool xml get $comp.about.label]
129    if {$title == ""} {
130        set title "Input #auto"
131    }
132    $win.pager insert end -name $comp -title $title
133
134    #
135    # Build the page of input controls for this phase.
136    #
137    set f [$win.pager page $comp]
138    Rappture::Page $f.cntls $tool $comp
139    pack $f.cntls -expand yes -fill both
140}
141
142# ----------------------------------------------------------------------
143# OUTPUT AREA
144# ----------------------------------------------------------------------
145$win.pager insert end -name analyzer -title "Simulate"
146set f [$win.pager page analyzer]
147$win.pager page analyzer -command [list $f.analyze simulate -ifneeded]
148
149Rappture::Analyzer $f.analyze $tool -simcontrol auto
150pack $f.analyze -expand yes -fill both
151
152$tool notify add analyzer * [list $f.analyze reset]
153
154# ----------------------------------------------------------------------
155# Finalize the arrangement
156# ----------------------------------------------------------------------
157if {[llength [$win.pager page]] == 2} {
158    set style [$xmlobj get tool.layout]
159    set screenw [winfo screenwidth .]
160
161    update idletasks
162    set w0 [winfo reqwidth [$win.pager page @0]]
163    set w1 [winfo reqwidth [$win.pager page @1]]
164
165    # if only two windows and they're small enough, put them up side-by-side
166    if {$w0+$w1 < $screenw && $style != "wizard"} {
167        $win.pager configure -arrangement side-by-side
168        $f.analyze configure -holdwindow [$win.pager page @0]
169
170        set type [$tool xml get tool.control]
171        if {$type == ""} {
172            set type [$tool xml get tool.control.type]
173        }
174
175        if {$type == "auto"} {
176            # in "auto" mode, we don't need a simulate button
177            $f.analyze configure -simcontrol off
178        } else {
179            # not in "auto" mode but side-by-side, we always need the button
180            $f.analyze configure -simcontrol on
181        }
182    }
183}
184wm deiconify .main
Note: See TracBrowser for help on using the repository browser.