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

Last change on this file since 924 was 909, checked in by gah, 16 years ago

VisViewer? base class

File size: 5.4 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
43itk::usual Field3DResult {
44    keep -background -foreground -cursor -font
45    keep -plotbackground -plotforeground
46}
47
48# ----------------------------------------------------------------------
49# CONSTRUCTOR
50# ----------------------------------------------------------------------
51itcl::body Rappture::Field3DResult::constructor {args} {
52    array set flags {
53        -mode auto
54    }
55    array set flags $args
56
57    set servers [Rappture::VisViewer::GetServerList "nanovis"]
58    if {"" != $servers && $flags(-mode) != "vtk"} {
59        itk_component add renderer {
60            Rappture::NanovisViewer $itk_interior.ren $servers
61        }
62        pack $itk_component(renderer) -expand yes -fill both
63
64        # can't connect to rendering farm?  then fall back to older viewer
65        if {![$itk_component(renderer) isconnected]} {
66            destroy $itk_component(renderer)
67        }
68    }
69
70    if {![info exists itk_component(renderer)]} {
71        itk_component add renderer {
72            Rappture::ContourResult $itk_interior.ren
73        }
74        pack $itk_component(renderer) -expand yes -fill both
75    }
76
77    eval itk_initialize $args
78}
79
80# ----------------------------------------------------------------------
81# DESTRUCTOR
82# ----------------------------------------------------------------------
83itcl::body Rappture::Field3DResult::destructor {} {
84}
85
86# ----------------------------------------------------------------------
87# USAGE: add <dataobj> ?<settings>?
88#
89# Clients use this to add a data object to the plot.  The optional
90# <settings> are used to configure the plot.  Allowed settings are
91# -color, -brightness, -width, -linestyle, and -raise.
92# ----------------------------------------------------------------------
93itcl::body Rappture::Field3DResult::add {dataobj {settings ""}} {
94    eval $itk_component(renderer) add $dataobj [list $settings]
95}
96
97# ----------------------------------------------------------------------
98# USAGE: get
99#
100# Clients use this to query the list of objects being plotted, in
101# order from bottom to top of this result.
102# ----------------------------------------------------------------------
103itcl::body Rappture::Field3DResult::get {} {
104    return [$itk_component(renderer) get]
105}
106
107# ----------------------------------------------------------------------
108# USAGE: delete ?<dataobj1> <dataobj2> ...?
109#
110# Clients use this to delete a dataobj from the plot.  If no dataobjs
111# are specified, then all dataobjs are deleted.
112# ----------------------------------------------------------------------
113itcl::body Rappture::Field3DResult::delete {args} {
114    eval $itk_component(renderer) delete $args
115}
116
117# ----------------------------------------------------------------------
118# USAGE: scale ?<data1> <data2> ...?
119#
120# Sets the default limits for the overall plot according to the
121# limits of the data for all of the given <data> objects.  This
122# accounts for all objects--even those not showing on the screen.
123# Because of this, the limits are appropriate for all objects as
124# the user scans through data in the ResultSet viewer.
125# ----------------------------------------------------------------------
126itcl::body Rappture::Field3DResult::scale {args} {
127    eval $itk_component(renderer) scale $args
128}
129
130# ----------------------------------------------------------------------
131# USAGE: download coming
132# USAGE: download controls <downloadCommand>
133# USAGE: download now
134#
135# Clients use this method to create a downloadable representation
136# of the plot.  Returns a list of the form {ext string}, where
137# "ext" is the file extension (indicating the type of data) and
138# "string" is the data itself.
139# ----------------------------------------------------------------------
140itcl::body Rappture::Field3DResult::download {option args} {
141    $itk_component(renderer) download $option
142}
Note: See TracBrowser for help on using the repository browser.