source: branches/1.4/gui/scripts/tool.tcl @ 4941

Last change on this file since 4941 was 4531, checked in by gah, 10 years ago

test nanovisviewer against old 1.2 server

File size: 2.4 KB
Line 
1# -*- mode: tcl; indent-tabs-mode: nil -*-
2# ----------------------------------------------------------------------
3#  COMPONENT: tool - represents an entire tool
4#
5#  This object represents an entire tool defined by Rappture.
6#  Each tool resides in an installation directory with other tool
7#  resources (libraries, examples, etc.).  Each tool is defined by
8#  its inputs and outputs, which are tied to various widgets in the
9#  GUI.  Each tool tracks the inputs, knows when they're changed,
10#  and knows how to run itself to produce new results.
11# ======================================================================
12#  AUTHOR:  Michael McLennan, Purdue University
13#  Copyright (c) 2004-2014  HUBzero Foundation, LLC
14#
15#  See the file "license.terms" for information on usage and
16#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
17# ======================================================================
18
19itcl::class Rappture::Tool {
20    inherit Rappture::ControlOwner
21
22    constructor {xmlobj installdir} {
23        Rappture::ControlOwner::constructor ""
24    } { # defined below }
25
26    destructor { # defined below }
27
28    public method installdir {} {
29        return [$_task installdir]
30    }
31    public method run {args} {
32        sync  ;# sync all widget values to XML
33        eval $_task run $args
34    }
35    public method abort {} {
36        $_task abort
37    }
38    public method reset {} {
39        $_task reset
40    }
41
42    private variable _task ""  ;# underlying task for the tool
43
44    # global resources for this tool session (from task)
45    public proc resources {{option ""}} {
46        eval ::Rappture::Task::resources $option
47    }
48}
49
50# ----------------------------------------------------------------------
51# CONSTRUCTOR
52# ----------------------------------------------------------------------
53itcl::body Rappture::Tool::constructor {xmlobj installdir} {
54    if {![Rappture::library isvalid $xmlobj]} {
55        error "bad value \"$xmlobj\": should be Rappture::Library"
56    }
57
58    set _task [Rappture::Task ::#auto $xmlobj $installdir \
59        -logger ::Rappture::Logger::log]
60
61    # save a reference to the tool XML in the ControlOwner
62    set _xmlobj $xmlobj
63}
64
65# ----------------------------------------------------------------------
66# DESTRUCTOR
67# ----------------------------------------------------------------------
68itcl::body Rappture::Tool::destructor {} {
69    itcl::delete object $_task
70}
Note: See TracBrowser for help on using the repository browser.