source: branches/uq/gui/scripts/response.tcl @ 5709

Last change on this file since 5709 was 5709, checked in by mmh, 9 years ago

add response, responseviewer, uqnotebook and uqinfo

File size: 2.7 KB
Line 
1# -*- mode: tcl; indent-tabs-mode: nil -*-
2
3# ----------------------------------------------------------------------
4#  COMPONENT: response - extracts data from an XML description of a
5#  response surface (surrogate model).  Makes it available to the
6#  responseviewer.
7#
8# ======================================================================
9#  AUTHOR:  Martin Hunt, Purdue University
10#  Copyright (c) 2015  HUBzero Foundation, LLC
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 Itcl
16package require BLT
17
18namespace eval Rappture {
19    # forward declaration
20}
21
22itcl::class Rappture::Response {
23    constructor {xmlobj path} {
24        # defined below
25    }
26    destructor {
27        # defined below
28    }
29
30    public method get {}
31    public method variables {}
32    public method label {}
33    public method vlabels {}
34    public method response {}
35    public method rmse {}
36
37    private variable _xmlobj "";      # ref to lib obj
38    private variable _response "";
39}
40
41# ----------------------------------------------------------------------
42# CONSTRUCTOR
43# ----------------------------------------------------------------------
44itcl::body Rappture::Response::constructor {xmlobj path} {
45    if {![Rappture::library isvalid $xmlobj]} {
46        error "bad value \"$xmlobj\": should be LibraryObj"
47    }
48    set _xmlobj $xmlobj
49    set _response [$xmlobj element -as object $path]
50}
51
52# ----------------------------------------------------------------------
53# DESTRUCTOR
54# ----------------------------------------------------------------------
55itcl::body Rappture::Response::destructor {} {
56    # itcl::delete object $_response
57    set _response ""
58}
59
60itcl::body Rappture::Response::variables {} {
61    return [$_response get variables]
62}
63
64itcl::body Rappture::Response::rmse {} {
65    return [$_response get rmse]
66}
67
68itcl::body Rappture::Response::response {} {
69    return [$_response get value]
70}
71
72# Get the response surface label
73itcl::body Rappture::Response::label {} {
74    set lab [$_response get about.label]
75    if {[regexp {([^\(]*)\(([^\)]+)\)} $lab match lab uq_part]} {
76        set lab [string trim $lab]
77    }
78    return $lab
79}
80
81# Get the input variable labels
82itcl::body Rappture::Response::vlabels {} {
83    return [$_response get labels]
84}
85
86# ----------------------------------------------------------------------
87# USAGE: get
88#
89# Clients use this to query the list of xml objects being plotted.
90# Currently limited to one.
91# ----------------------------------------------------------------------
92itcl::body Rappture::Response::get {} {
93    return $_response
94}
Note: See TracBrowser for help on using the repository browser.