source: trunk/gui/scripts/textresult.tcl @ 13

Last change on this file since 13 was 13, checked in by mmc, 16 years ago

Many improvements, including a new energy level viewer
for Huckel-IV. Added support for a new <boolean> type.
Fixed the cloud/field stuff so that when a cloud is 1D,
it reverts to BLT vectors so it will plot correctly.
Fixed the install script to work better on Windows.

File size: 4.7 KB
Line 
1# ----------------------------------------------------------------------
2#  COMPONENT: TextResult - Log output for ResultSet
3#
4#  This widget is used to show text output in a ResultSet.  The log
5#  output from a tool, for example, is rendered as a TextResult.
6# ======================================================================
7#  AUTHOR:  Michael McLennan, Purdue University
8#  Copyright (c) 2004-2005
9#  Purdue Research Foundation, West Lafayette, IN
10# ======================================================================
11package require Itk
12package require BLT
13
14option add *TextResult.width 4i widgetDefault
15option add *TextResult.height 4i widgetDefault
16option add *TextResult.font \
17    -*-courier-medium-r-normal-*-*-120-* widgetDefault
18
19itcl::class Rappture::TextResult {
20    inherit itk::Widget
21
22    constructor {args} { # defined below }
23
24    public method add {dataobj {settings ""}}
25    public method get {}
26    public method delete {args}
27    public method scale {args}
28
29    set _dataobj ""  ;# data object currently being displayed
30}
31                                                                               
32itk::usual TextResult {
33    keep -background -foreground -cursor -font
34}
35
36# ----------------------------------------------------------------------
37# CONSTRUCTOR
38# ----------------------------------------------------------------------
39itcl::body Rappture::TextResult::constructor {args} {
40    option add hull.width hull.height
41    pack propagate $itk_component(hull) no
42
43    itk_component add scroller {
44        Rappture::Scroller $itk_interior.scroller \
45            -xscrollmode auto -yscrollmode auto
46    }
47    pack $itk_component(scroller) -expand yes -fill both
48
49    itk_component add text {
50        text $itk_component(scroller).text -width 1 -height 1 -wrap none
51    }
52    $itk_component(scroller) contents $itk_component(text)
53    $itk_component(text) configure -state disabled
54
55    eval itk_initialize $args
56}
57
58# ----------------------------------------------------------------------
59# USAGE: add <dataobj> ?<settings>?
60#
61# Clients use this to add a data object to the plot.  If the optional
62# <settings> are specified, then the are applied to the data.  Allowed
63# settings are -color and -brightness, -width, -linestyle and -raise.
64# (Many of these are ignored.)
65# ----------------------------------------------------------------------
66itcl::body Rappture::TextResult::add {dataobj {settings ""}} {
67    array set params {
68        -color ""
69        -brightness ""
70        -width ""
71        -linestyle ""
72        -raise ""
73    }
74    foreach {opt val} $settings {
75        if {![info exists params($opt)]} {
76            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
77        }
78        set params($opt) $val
79    }
80
81    $itk_component(text) configure -state normal
82    $itk_component(text) delete 1.0 end
83
84    if {"" != $dataobj} {
85        set txt [$dataobj get]
86        if {"" != $params(-color)} {
87#
88# ignore color for now -- may use it some day
89#
90#            $itk_component(text) insert end $txt special
91#            $itk_component(text) tag configure special \
92#                -foreground $params(-color)
93            $itk_component(text) insert end $txt
94        } else {
95            $itk_component(text) insert end $txt
96        }
97    }
98
99    $itk_component(text) configure -state disabled
100    set _dataobj $dataobj
101}
102
103# ----------------------------------------------------------------------
104# USAGE: get
105#
106# Clients use this to query the list of objects being plotted, in
107# order from bottom to top of this result.
108# ----------------------------------------------------------------------
109itcl::body Rappture::TextResult::get {} {
110    return $_dataobj
111}
112
113# ----------------------------------------------------------------------
114# USAGE: delete ?<curve1> <curve2> ...?
115#
116# Clients use this to delete a curve from the plot.  If no curves
117# are specified, then all curves are deleted.
118# ----------------------------------------------------------------------
119itcl::body Rappture::TextResult::delete {args} {
120    $itk_component(text) configure -state normal
121    $itk_component(text) delete 1.0 end
122    $itk_component(text) configure -state disabled
123    set _dataobj ""
124}
125
126# ----------------------------------------------------------------------
127# USAGE: scale ?<curve1> <curve2> ...?
128#
129# Sets the default limits for the overall plot according to the
130# limits of the data for all of the given <curve> objects.  This
131# accounts for all curves--even those not showing on the screen.
132# Because of this, the limits are appropriate for all curves as
133# the user scans through data in the ResultSet viewer.
134# ----------------------------------------------------------------------
135itcl::body Rappture::TextResult::scale {args} {
136    # nothing to do for text
137}
Note: See TracBrowser for help on using the repository browser.