source: tol/tolbase/lib/toltk/settable.tcl @ 7b5e14e

1941-docker-image-to-testdevel
Last change on this file since 7b5e14e was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 3.8 KB
Line 
1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : settable.tcl
3# PURPOSE : This file contains a namespace called SetTable with its functions.
4#           It's for managing set tables.
5#           It's a child of BayesTable so inherites all its functionalities.
6#/////////////////////////////////////////////////////////////////////////////
7
8#/////////////////////////////////////////////////////////////////////////////
9  namespace eval ::SetTable {
10#
11# PURPOSE: The purpose of this namespace is organize code and functions and
12#          provides functions to create and manage a set table.
13#          A special namespace is created for each instance of Set table.
14#
15# VARIABLES:
16#
17#/////////////////////////////////////////////////////////////////////////////
18
19}
20
21#/////////////////////////////////////////////////////////////////////////////
22proc ::SetTable::Create {path tableset set {onlywidget no}} {
23#/////////////////////////////////////////////////////////////////////////////
24  set this [::BayesTable::Create $path \
25    -fillproc "::SetTable::Fill [list $tableset]" \
26    -child SetTable -onlywidget $onlywidget]
27  ReadIni   $this
28  Configure $this
29}
30
31proc ::SetTable::Fill {tableset this} {
32
33
34  set numRows [$tableset info datarows]
35  set numCols [llength [$tableset info columns]]
36
37
38  set i_ini 0
39  #insert the set into the table
40  if {[string equal [lindex [$tableset info header] 0] "row"]} {
41    set i_ini 1
42    set j 1
43    set colsF [expr [llength [$tableset info columns]] - [lindex [$tableset info header] 1] -1]
44    foreach lstInfo [lrange [$tableset info columns] 0 $colsF] {
45      ::BayesTable::SetElement $this $i_ini $j [lindex $lstInfo 1]
46      incr j
47    }
48  } elseif {[string equal [$tableset info header] "struct"]} {
49    set j 1
50    foreach lstInfo [$tableset info columns] {
51      ::BayesTable::SetElement $this $i_ini $j [lindex $lstInfo 1]
52      incr j
53    }
54  }
55  set i 1
56  foreach name [$tableset info rowsnames] {
57    ::BayesTable::SetElement $this $i 0 $name
58    incr i
59  }
60  $tableset data apply all [list ::SetTable::FillCell $this [expr $i_ini+1]]
61
62  ::BayesTable::SetMatrixInfo $this [list [expr $numRows+$i_ini+1] [expr $numCols+1]] ""
63}
64
65proc ::SetTable::FillCell {this i_ini i j value} {
66  ::BayesTable::SetElement $this [expr $i_ini+$i] [expr $j+1] $value
67}
68
69
70#/////////////////////////////////////////////////////////////////////////////
71# INIFILE
72#/////////////////////////////////////////////////////////////////////////////
73
74#/////////////////////////////////////////////////////////////////////////////
75  proc ::SetTable::ReadIni {this} {
76#
77# PURPOSE: Reads specific options from .ini file. First of all, reads options
78#          from BayesTable. Actually there isn't specific options.
79#
80# PARAMETERS:
81#   this  -> Instance of BayesTable
82#
83#/////////////////////////////////////////////////////////////////////////////
84  # General options (parent)
85  ::BayesTable::ReadIni $this
86  # Specific options
87}
88
89
90#/////////////////////////////////////////////////////////////////////////////
91  proc ::SetTable::WriteIni {this} {
92#
93# PURPOSE: Writes specific options to .ini file. This procedure is called by
94#          parent BayesGraph. Actually doesn't do anything.
95#
96# PARAMETERS:
97#   this  -> Instance of BayesTable
98#
99#/////////////////////////////////////////////////////////////////////////////
100
101}
102
103
104#/////////////////////////////////////////////////////////////////////////////
105  proc ::SetTable::Configure {this} {
106#
107# PURPOSE: Configures some options of Set Table. First of all, configures
108#          options from BayesTable. Actually there isn't specific options.
109#
110# PARAMETERS:
111#   this  -> Instance of BayesTable
112#
113#/////////////////////////////////////////////////////////////////////////////
114  # General options (parent)
115  ::BayesTable::Configure $this
116  # Specific options
117}
118
Note: See TracBrowser for help on using the repository browser.