source: trunk/gui/scripts/field2dresult.tcl @ 1463

Last change on this file since 1463 was 1463, checked in by gah, 12 years ago
File size: 5.5 KB
Line 
1# ----------------------------------------------------------------------
2#  COMPONENT: field2dresult - 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# ======================================================================
15
16package require Itk
17
18option add *Field2DResult.width 4i widgetDefault
19option add *Field2DResult.height 4i widgetDefault
20option add *Field2DResult.foreground black widgetDefault
21option add *Field2DResult.controlBackground gray widgetDefault
22option add *Field2DResult.controlDarkBackground #999999 widgetDefault
23option add *Field2DResult.plotBackground black widgetDefault
24option add *Field2DResult.plotForeground white widgetDefault
25option add *Field2DResult.font \
26    -*-helvetica-medium-r-normal-*-12-* widgetDefault
27
28itcl::class Rappture::Field2DResult {
29    inherit itk::Widget
30
31    itk_option define -mode mode Mode "auto"
32
33    constructor {args} { # defined below }
34    destructor { # defined below }
35
36    public method add {dataobj {settings ""}}
37    public method get {}
38    public method delete {args}
39    public method scale {args}
40    public method parameters {title args} { # do nothing }
41    public method download {option args}
42}
43
44itk::usual Field2DResult {
45    keep -background -foreground -cursor -font
46    keep -plotbackground -plotforeground
47}
48
49# ----------------------------------------------------------------------
50# CONSTRUCTOR
51# ----------------------------------------------------------------------
52itcl::body Rappture::Field2DResult::constructor {args} {
53    array set flags {
54        -mode auto
55    }
56    array set flags $args
57    set servers [Rappture::VisViewer::GetServerList "nanovis"]
58    if {"" != $servers && $flags(-mode) != "vtk"} {
59        switch -- $flags(-mode) {
60            "auto" - "heightmap" {
61                itk_component add renderer {
62                    Rappture::HeightmapViewer $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        # can't connect to rendering farm?  then fall back to older viewer
76        if {![$itk_component(renderer) isconnected]} {
77            destroy $itk_component(renderer)
78        }
79    }
80
81    if {![info exists itk_component(renderer)]} {
82        itk_component add renderer {
83            Rappture::ContourResult $itk_interior.ren
84        }
85        pack $itk_component(renderer) -expand yes -fill both
86    }
87    eval itk_initialize $args
88}
89
90# ----------------------------------------------------------------------
91# DESTRUCTOR
92# ----------------------------------------------------------------------
93itcl::body Rappture::Field2DResult::destructor {} {
94}
95
96# ----------------------------------------------------------------------
97# USAGE: add <dataobj> ?<settings>?
98#
99# Clients use this to add a data object to the plot.  The optional
100# <settings> are used to configure the plot.  Allowed settings are
101# -color, -brightness, -width, -linestyle, and -raise.
102# ----------------------------------------------------------------------
103itcl::body Rappture::Field2DResult::add {dataobj {settings ""}} {
104    eval $itk_component(renderer) add $dataobj [list $settings]
105}
106
107# ----------------------------------------------------------------------
108# USAGE: get
109#
110# Clients use this to query the list of objects being plotted, in
111# order from bottom to top of this result.
112# ----------------------------------------------------------------------
113itcl::body Rappture::Field2DResult::get {} {
114    return [$itk_component(renderer) get]
115}
116
117# ----------------------------------------------------------------------
118# USAGE: delete ?<dataobj1> <dataobj2> ...?
119#
120# Clients use this to delete a dataobj from the plot.  If no dataobjs
121# are specified, then all dataobjs are deleted.
122# ----------------------------------------------------------------------
123itcl::body Rappture::Field2DResult::delete {args} {
124    eval $itk_component(renderer) delete $args
125}
126
127# ----------------------------------------------------------------------
128# USAGE: scale ?<data1> <data2> ...?
129#
130# Sets the default limits for the overall plot according to the
131# limits of the data for all of the given <data> objects.  This
132# accounts for all objects--even those not showing on the screen.
133# Because of this, the limits are appropriate for all objects as
134# the user scans through data in the ResultSet viewer.
135# ----------------------------------------------------------------------
136itcl::body Rappture::Field2DResult::scale {args} {
137    eval $itk_component(renderer) scale $args
138}
139
140# ----------------------------------------------------------------------
141# USAGE: download coming
142# USAGE: download controls <downloadCommand>
143# USAGE: download now
144#
145# Clients use this method to create a downloadable representation
146# of the plot.  Returns a list of the form {ext string}, where
147# "ext" is the file extension (indicating the type of data) and
148# "string" is the data itself.
149# ----------------------------------------------------------------------
150itcl::body Rappture::Field2DResult::download {option args} {
151    $itk_component(renderer) download $option
152}
Note: See TracBrowser for help on using the repository browser.