[436] | 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 | # ====================================================================== |
---|
| 15 | package require Itk |
---|
| 16 | |
---|
| 17 | option add *Field3DResult.width 4i widgetDefault |
---|
| 18 | option add *Field3DResult.height 4i widgetDefault |
---|
| 19 | option add *Field3DResult.foreground black widgetDefault |
---|
| 20 | option add *Field3DResult.controlBackground gray widgetDefault |
---|
| 21 | option add *Field3DResult.controlDarkBackground #999999 widgetDefault |
---|
| 22 | option add *Field3DResult.plotBackground black widgetDefault |
---|
| 23 | option add *Field3DResult.plotForeground white widgetDefault |
---|
| 24 | option add *Field3DResult.font \ |
---|
[676] | 25 | -*-helvetica-medium-r-normal-*-12-* widgetDefault |
---|
[436] | 26 | |
---|
| 27 | itcl::class Rappture::Field3DResult { |
---|
| 28 | inherit itk::Widget |
---|
| 29 | |
---|
[460] | 30 | itk_option define -mode mode Mode "auto" |
---|
| 31 | |
---|
[436] | 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} |
---|
[766] | 39 | public method parameters {title args} { # do nothing } |
---|
[468] | 40 | public method download {option args} |
---|
[436] | 41 | } |
---|
| 42 | |
---|
| 43 | itk::usual Field3DResult { |
---|
| 44 | keep -background -foreground -cursor -font |
---|
| 45 | keep -plotbackground -plotforeground |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | # ---------------------------------------------------------------------- |
---|
| 49 | # CONSTRUCTOR |
---|
| 50 | # ---------------------------------------------------------------------- |
---|
| 51 | itcl::body Rappture::Field3DResult::constructor {args} { |
---|
[460] | 52 | array set flags { |
---|
| 53 | -mode auto |
---|
| 54 | } |
---|
| 55 | array set flags $args |
---|
| 56 | |
---|
[909] | 57 | set servers [Rappture::VisViewer::GetServerList "nanovis"] |
---|
[839] | 58 | if {"" != $servers && $flags(-mode) != "vtk"} { |
---|
[436] | 59 | itk_component add renderer { |
---|
[839] | 60 | Rappture::NanovisViewer $itk_interior.ren $servers |
---|
[436] | 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 | # ---------------------------------------------------------------------- |
---|
| 83 | itcl::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 | # ---------------------------------------------------------------------- |
---|
| 93 | itcl::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 | # ---------------------------------------------------------------------- |
---|
| 103 | itcl::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 | # ---------------------------------------------------------------------- |
---|
| 113 | itcl::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 | # ---------------------------------------------------------------------- |
---|
| 126 | itcl::body Rappture::Field3DResult::scale {args} { |
---|
| 127 | eval $itk_component(renderer) scale $args |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | # ---------------------------------------------------------------------- |
---|
| 131 | # USAGE: download coming |
---|
[468] | 132 | # USAGE: download controls <downloadCommand> |
---|
[436] | 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 | # ---------------------------------------------------------------------- |
---|
[468] | 140 | itcl::body Rappture::Field3DResult::download {option args} { |
---|
[436] | 141 | $itk_component(renderer) download $option |
---|
| 142 | } |
---|