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

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