source: trunk/gui/apps/driver @ 11

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

Major reorganization of the entire package. The config.xml file
is now irrelevant. All the action is in the tool.xml file. The
main program now organizes all input into 1) side-by-side pages,
2) input/result (wizard-style) pages, or 3) a series of wizard-
style pages. The <input> can have <phase> parts representing
the various pages.

Added a new ContourResult? widget based on Swaroop's vtk plotting
code.

Also, added easymesh and showmesh to the "tools" directory.
We need these for Eric Polizzi's code.

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