source: trunk/gui/scripts/field3dresult.tcl @ 829

Last change on this file since 829 was 766, checked in by mmc, 17 years ago

Fixed the output viewer for numbers/integers to show a plot of
the value versus input parameters. As you change the ResultSet?
control, the x-axis updates to show the number versus values
in the result set.

Fixed the Rappture::result command to include the user's login
in the metadata, so we know who performed the computation.

File size: 5.9 KB
Line 
1# ----------------------------------------------------------------------
2#  COMPONENT: field3dresult - plot a field in a ResultSet
3#
4#  This widget visualizes scalar/vector fields on 3D meshes.
5#  It is normally used in the ResultViewer to show results from the
6#  run of a Rappture tool.  Use the "add" and "delete" methods to
7#  control the dataobjs showing on the plot.
8# ======================================================================
9#  AUTHOR:  Michael McLennan, Purdue University
10#  Copyright (c) 2004-2005  Purdue Research Foundation
11#
12#  See the file "license.terms" for information on usage and
13#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14# ======================================================================
15package require Itk
16
17option add *Field3DResult.width 4i widgetDefault
18option add *Field3DResult.height 4i widgetDefault
19option add *Field3DResult.foreground black widgetDefault
20option add *Field3DResult.controlBackground gray widgetDefault
21option add *Field3DResult.controlDarkBackground #999999 widgetDefault
22option add *Field3DResult.plotBackground black widgetDefault
23option add *Field3DResult.plotForeground white widgetDefault
24option add *Field3DResult.font \
25    -*-helvetica-medium-r-normal-*-12-* widgetDefault
26
27itcl::class Rappture::Field3DResult {
28    inherit itk::Widget
29
30    itk_option define -mode mode Mode "auto"
31
32    constructor {args} { # defined below }
33    destructor { # defined below }
34
35    public method add {dataobj {settings ""}}
36    public method get {}
37    public method delete {args}
38    public method scale {args}
39    public method parameters {title args} { # do nothing }
40    public method download {option args}
41
42    # resources file tells us the nanovis server
43    public common _nanovisHosts ""
44    public proc setNanovisServer {namelist} {
45        if {[regexp {^[a-zA-Z0-9\.]+:[0-9]+(,[a-zA-Z0-9\.]+:[0-9]+)*$} $namelist match]} {
46            set _nanovisHosts $namelist
47        } else {
48            error "bad nanovis server address \"$namelist\": should be host:port,host:port,..."
49        }
50    }
51}
52
53# must use this name -- plugs into Rappture::resources::load
54proc field3d_init_resources {} {
55    Rappture::resources::register \
56        nanovis_server Rappture::Field3DResult::setNanovisServer
57}
58
59itk::usual Field3DResult {
60    keep -background -foreground -cursor -font
61    keep -plotbackground -plotforeground
62}
63
64# ----------------------------------------------------------------------
65# CONSTRUCTOR
66# ----------------------------------------------------------------------
67itcl::body Rappture::Field3DResult::constructor {args} {
68    array set flags {
69        -mode auto
70    }
71    array set flags $args
72
73    if {"" != $_nanovisHosts && $flags(-mode) != "vtk"} {
74        itk_component add renderer {
75            Rappture::NanovisViewer $itk_interior.ren $_nanovisHosts
76        }
77        pack $itk_component(renderer) -expand yes -fill both
78
79        # can't connect to rendering farm?  then fall back to older viewer
80        if {![$itk_component(renderer) isconnected]} {
81            destroy $itk_component(renderer)
82        }
83    }
84
85    if {![info exists itk_component(renderer)]} {
86        itk_component add renderer {
87            Rappture::ContourResult $itk_interior.ren
88        }
89        pack $itk_component(renderer) -expand yes -fill both
90    }
91
92    eval itk_initialize $args
93}
94
95# ----------------------------------------------------------------------
96# DESTRUCTOR
97# ----------------------------------------------------------------------
98itcl::body Rappture::Field3DResult::destructor {} {
99}
100
101# ----------------------------------------------------------------------
102# USAGE: add <dataobj> ?<settings>?
103#
104# Clients use this to add a data object to the plot.  The optional
105# <settings> are used to configure the plot.  Allowed settings are
106# -color, -brightness, -width, -linestyle, and -raise.
107# ----------------------------------------------------------------------
108itcl::body Rappture::Field3DResult::add {dataobj {settings ""}} {
109    eval $itk_component(renderer) add $dataobj [list $settings]
110}
111
112# ----------------------------------------------------------------------
113# USAGE: get
114#
115# Clients use this to query the list of objects being plotted, in
116# order from bottom to top of this result.
117# ----------------------------------------------------------------------
118itcl::body Rappture::Field3DResult::get {} {
119    return [$itk_component(renderer) get]
120}
121
122# ----------------------------------------------------------------------
123# USAGE: delete ?<dataobj1> <dataobj2> ...?
124#
125# Clients use this to delete a dataobj from the plot.  If no dataobjs
126# are specified, then all dataobjs are deleted.
127# ----------------------------------------------------------------------
128itcl::body Rappture::Field3DResult::delete {args} {
129    eval $itk_component(renderer) delete $args
130}
131
132# ----------------------------------------------------------------------
133# USAGE: scale ?<data1> <data2> ...?
134#
135# Sets the default limits for the overall plot according to the
136# limits of the data for all of the given <data> objects.  This
137# accounts for all objects--even those not showing on the screen.
138# Because of this, the limits are appropriate for all objects as
139# the user scans through data in the ResultSet viewer.
140# ----------------------------------------------------------------------
141itcl::body Rappture::Field3DResult::scale {args} {
142    eval $itk_component(renderer) scale $args
143}
144
145# ----------------------------------------------------------------------
146# USAGE: download coming
147# USAGE: download controls <downloadCommand>
148# USAGE: download now
149#
150# Clients use this method to create a downloadable representation
151# of the plot.  Returns a list of the form {ext string}, where
152# "ext" is the file extension (indicating the type of data) and
153# "string" is the data itself.
154# ----------------------------------------------------------------------
155itcl::body Rappture::Field3DResult::download {option args} {
156    $itk_component(renderer) download $option
157}
Note: See TracBrowser for help on using the repository browser.