source: trunk/gui/apps/driver @ 13

Last change on this file since 13 was 13, checked in by mmc, 16 years ago

Many improvements, including a new energy level viewer
for Huckel-IV. Added support for a new <boolean> type.
Fixed the cloud/field stuff so that when a cloud is 1D,
it reverts to BLT vectors so it will plot correctly.
Fixed the install script to work better on Windows.

File size: 4.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 web startupFile
28option add *MainWin.borderWidth 0 startupFile
29option add *MainWin.anchor nw 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
46
47#
48# Process command line args to get the names of files to load...
49#
50Rappture::getopts argv params {
51    value -tool tool.xml
52}
53
54# open the XML file containing the tool parameters
55if {![file exists $params(-tool)]} {
56    puts stderr "can't find tool \"$params(-tool)\""
57    exit 1
58}
59set xmlobj [Rappture::library $params(-tool)]
60
61set installdir [file dirname $params(-tool)]
62if {"." == $installdir} {
63    set installdir [pwd]
64}
65
66set tool [Rappture::Tool ::#auto $xmlobj $installdir]
67
68# ----------------------------------------------------------------------
69# MAIN WINDOW
70# ----------------------------------------------------------------------
71wm withdraw .
72Rappture::MainWin .main -borderwidth 0
73.main configure -title [$tool xml get tool.title]
74wm withdraw .main
75
76#
77# The main window has a pager that acts as a notebook for the
78# various parts.  This notebook as at least two pages--an input
79# page and an output (analysis) page.  If there are <phase>'s
80# for input, then there are more pages in the notebook.
81#
82set win [.main component app]
83Rappture::Pager $win.pager
84pack $win.pager -expand yes -fill both
85
86set phases [$tool xml children -type phase input]
87if {[llength $phases] > 0} {
88    set plist ""
89    foreach name $phases {
90        lappend plist input.$name
91    }
92    set phases $plist
93} else {
94    set phases input
95}
96
97foreach comp $phases {
98    set title [$tool xml get $comp.about.label]
99    if {$title == ""} {
100        set title "Input #auto"
101    }
102    $win.pager insert end -name $comp -title $title
103
104    #
105    # Build the page of input controls for this phase.
106    #
107    set f [$win.pager page $comp]
108    Rappture::Page $f.cntls $tool $comp
109    pack $f.cntls -expand yes -fill both
110}
111
112# ----------------------------------------------------------------------
113# OUTPUT AREA
114# ----------------------------------------------------------------------
115$win.pager insert end -name analyzer -title "Results"
116set f [$win.pager page analyzer]
117$win.pager page analyzer -command [list $f.analyze simulate -ifneeded]
118
119Rappture::Analyzer $f.analyze $tool -simcontrol auto
120pack $f.analyze -expand yes -fill both
121
122$tool configure -analyzer $f.analyze
123
124# ----------------------------------------------------------------------
125# Finalize the arrangement
126# ----------------------------------------------------------------------
127if {[llength [$win.pager page]] == 2} {
128    set style [$xmlobj get tool.layout]
129    set screenw [winfo screenwidth .]
130
131    update idletasks
132    set w0 [winfo reqwidth [$win.pager page @0]]
133    set w1 [winfo reqwidth [$win.pager page @1]]
134
135    # if only two windows and they're small enough, put them up side-by-side
136    if {$w0+$w1 < $screenw && $style != "wizard"} {
137        $win.pager configure -arrangement side-by-side
138        $f.analyze configure -holdwindow [$win.pager page @0]
139
140        if {[$tool xml get tool.control] == "auto"} {
141            # in "auto" mode, we don't need a simulate button
142            $f.analyze configure -simcontrol off
143        } else {
144            # not in "auto" mode but side-by-side, we always need the button
145            $f.analyze configure -simcontrol on
146        }
147    }
148}
149wm deiconify .main
Note: See TracBrowser for help on using the repository browser.