source: branches/blt4/gui/scripts/field3dresult.tcl @ 1681

Last change on this file since 1681 was 1506, checked in by gah, 15 years ago
File size: 5.5 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        switch -- $flags(-mode) {
60            "auto" - "nanovis" {
61                itk_component add renderer {
62                    Rappture::NanovisViewer $itk_interior.ren $servers
63                }
64            }
65            "flowvis" {
66                itk_component add renderer {
67                    Rappture::FlowvisViewer $itk_interior.ren $servers
68                }
69            }
70            default {
71                puts stderr "unknown render mode \"$flags(-mode)\""
72            }
73        }               
74        pack $itk_component(renderer) -expand yes -fill both
75
76        # can't connect to rendering farm?  then fall back to older viewer
77        if {![$itk_component(renderer) isconnected]} {
78            destroy $itk_component(renderer)
79        }
80    }
81
82    if {![info exists itk_component(renderer)]} {
83        itk_component add renderer {
84            Rappture::ContourResult $itk_interior.ren
85        }
86        pack $itk_component(renderer) -expand yes -fill both
87    }
88
89    eval itk_initialize $args
90}
91
92# ----------------------------------------------------------------------
93# DESTRUCTOR
94# ----------------------------------------------------------------------
95itcl::body Rappture::Field3DResult::destructor {} {
96}
97
98# ----------------------------------------------------------------------
99# USAGE: add <dataobj> ?<settings>?
100#
101# Clients use this to add a data object to the plot.  The optional
102# <settings> are used to configure the plot.  Allowed settings are
103# -color, -brightness, -width, -linestyle, and -raise.
104# ----------------------------------------------------------------------
105itcl::body Rappture::Field3DResult::add {dataobj {settings ""}} {
106    eval $itk_component(renderer) add $dataobj [list $settings]
107}
108
109# ----------------------------------------------------------------------
110# USAGE: get
111#
112# Clients use this to query the list of objects being plotted, in
113# order from bottom to top of this result.
114# ----------------------------------------------------------------------
115itcl::body Rappture::Field3DResult::get {} {
116    return [$itk_component(renderer) get]
117}
118
119# ----------------------------------------------------------------------
120# USAGE: delete ?<dataobj1> <dataobj2> ...?
121#
122# Clients use this to delete a dataobj from the plot.  If no dataobjs
123# are specified, then all dataobjs are deleted.
124# ----------------------------------------------------------------------
125itcl::body Rappture::Field3DResult::delete {args} {
126    eval $itk_component(renderer) delete $args
127}
128
129# ----------------------------------------------------------------------
130# USAGE: scale ?<data1> <data2> ...?
131#
132# Sets the default limits for the overall plot according to the
133# limits of the data for all of the given <data> objects.  This
134# accounts for all objects--even those not showing on the screen.
135# Because of this, the limits are appropriate for all objects as
136# the user scans through data in the ResultSet viewer.
137# ----------------------------------------------------------------------
138itcl::body Rappture::Field3DResult::scale {args} {
139    eval $itk_component(renderer) scale $args
140}
141
142# ----------------------------------------------------------------------
143# USAGE: download coming
144# USAGE: download controls <downloadCommand>
145# USAGE: download now
146#
147# Clients use this method to create a downloadable representation
148# of the plot.  Returns a list of the form {ext string}, where
149# "ext" is the file extension (indicating the type of data) and
150# "string" is the data itself.
151# ----------------------------------------------------------------------
152itcl::body Rappture::Field3DResult::download {option args} {
153    $itk_component(renderer) download $option $args
154}
Note: See TracBrowser for help on using the repository browser.