/usr/share/elmerfront/tcl/ecif_tk_procsListBox.tcl is in elmer-common 6.1.0.svn.5396.dfsg2-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | #/*****************************************************************************/
# *
# * Elmer, A Finite Element Software for Multiphysical Problems
# *
# * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
# *
# * This program is free software; you can redistribute it and/or
# * modify it under the terms of the GNU General Public License
# * as published by the Free Software Foundation; either version 2
# * of the License, or (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program (in file fem/GPL-2); if not, write to the
# * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# * Boston, MA 02110-1301, USA.
# *
# *****************************************************************************/
#***********************************************************************
#Program: ELMER Front
#Module: ecif_tk_procsListBox.tcl
#Language: Tcl
#Date: 05.10.98
#Version: 1.00
#Author(s): Martti Verho
#Revisions:
#
#Abstract: Listbox handling procedures
#
#************************************************************************
###########################
### List-Box procedures ###
###########################
#-Fill list-box widget with dataList-elements.
proc ListBox::fill {lbox dataList} {
set start_pos [lindex [$lbox yview] 0]
eval {$lbox delete 0 end}
eval {$lbox insert end} $dataList
$lbox yview moveto $start_pos
}
# Set the problem type indicator at the beginning of a parameter row
#
proc ListBox::markParameterLBByMask { globArray } {
global Common Info ObjectTable
upvar #0 $globArray theArray
set index 0
set new_list ""
set tmask $theArray(targetMask)
foreach id $theArray(ids) {
# Get paramter mask via parameter's object
#set mask [StdPanelExec::getTargetMask $globArray $theArray($id,oid)]
set mask $theArray($id,mask)
set accept_target 1
if { [info exists theArray(hasParameterTargetCheckProc)] &&
$theArray(hasParameterTargetCheckProc)
} {
set pn $globArray
append pn "::parameterTargetCheckProc"
set accept_target [eval $pn $id]
}
if { $accept_target && $mask == $tmask } {
set mark $Info(paramMarked)
} else {
set mark $Info(paramUnmarked)
}
set row [lindex $theArray(parameterLBList) $index]
set row [string replace $row 0 0 $mark]
lappend new_list $row
incr index
}
set theArray(parameterLBList) $new_list
set selections [$theArray(parameterLB) curselection]
ListBox::fill $theArray(parameterLB) $new_list
foreach idx $selections {
$theArray(parameterLB) selection set $idx
}
}
proc ListBox::markSelectedBoundaries { {source_list "" } {current_array ""} } {
global Info ObjectTable Common ModelFlags
if { $current_array == "" } {
set current_array $Common(currentArray)
}
# If no active panel specified
if {$current_array == ""} {
return
}
upvar #0 $current_array theArray
if { ![info exists theArray(boundaryLB)] ||
![winfo exists $theArray(boundaryLB)]
} {
return
}
if { $source_list == "" } {
set source_list [ $theArray(boundaryLB) get 0 end]
}
set lbr 0
set mark $Info(selectedMark)
set current_selections [$theArray(boundaryLB) curselection]
foreach old_row $source_list {
if { $mark == [string index $old_row 0] } {
set has_mark 1
} else {
set has_mark 0
}
#-The row without the selection mark
set clean_row [string trimleft $old_row $mark]
#-Check if row should be selected
set bndr_id [lindex $theArray(boundaryIds) $lbr]
set selected $ObjectTable($bndr_id,slctd)
#-Insert selection mark in the beginning
if { $selected } {
set new_row $mark
append new_row $clean_row
#-No selection mark
} else {
set new_row $clean_row
}
if { $selected && !$has_mark ||
!$selected && $has_mark
} {
ListBox::updateRow $theArray(boundaryLB) $lbr $new_row $selected
}
incr lbr
}
# Restore current selections
foreach lbr $current_selections {
$theArray(boundaryLB) selection set $lbr
}
}
# Make a body selected in the objects list-box (from cpp)
# NOTE mode-variable not currently in use!!!
#
proc ListBox::selectBody { bd1_id lr1_id bd2_id lr2_id {mode ""} } {
global Common Info ObjectTable
set glob_array $Common(currentArray)
# If currently no active panel
if { $glob_array == "" } {
return
}
upvar #0 $glob_array theArray
if { ![info exists theArray(objectLB)] ||
![winfo exists $theArray(objectLB)]
} {
return
}
# Bodypair
if { $bd1_id != $Info(NO_INDEX) &&
$bd2_id != $Info(NO_INDEX) &&
$bd1_id != $bd2_id
} {
set obj_id [Object::findIdByParentIds "BP" $bd1_id $bd2_id]
set lr_id $lr1_id
# First body
} elseif { $bd1_id != $Info(NO_INDEX) } {
set obj_id $bd1_id
set lr_id $lr1_id
# Second body
} else {
set obj_id $bd2_id
set lr_id $lr2_id
}
# Try the body first
set obj_index [lsearch $theArray(objectIds) $obj_id]
# Ok, perhaps objects are layers (like GridParameter)
if { $obj_index == -1 } {
set obj_index [lsearch $theArray(objectIds) $lr_id]
# Nothing found
if { $obj_index == -1 } {
return
}
}
$theArray(objectLB) selection clear 0 end
$theArray(objectLB) selection set $obj_index
$theArray(objectLB) see $obj_index
# Exec array object selected proc
execNsProc $glob_array objectSelected $obj_index
}
# Selection in the elements list box (from cpp)
#
# NOTE: Work only with arries which have the following array variables defined:
#
# boundaryLb, boundaryIds, boundaryIndex
#
#
proc ListBox::selectBoundary {bndr_id bd1_id lr1_id bd2_id lr2_id {extend 0} } {
global Common ModelFlags ObjectTable
set glob_array $Common(currentArray)
set trg_id $bndr_id
# If currently no active panel
if { $glob_array == "" } {
return
}
upvar #0 $glob_array theArray
if { ![info exists theArray(boundaryLB)] ||
![winfo exists $theArray(boundaryLB)]
} {
return
}
if { $glob_array == $Common(panelArray,BC) } {
if { [info exists ObjectTable($bndr_id,grpId)] } {
set trg_id $ObjectTable($bndr_id,grpId)
}
}
# Select first correct body, if not
# yet current
if { $theArray(body1Id) != $bd1_id ||
$theArray(body2Id) != $bd2_id
} {
ListBox::selectBody $bd1_id $lr1_id $bd2_id $lr2_id
}
# Clear old selections, if not extended selection mode
if { !($extend && $theArray(canMultiSelectBoundaries)) } {
$theArray(boundaryLB) selection clear 0 end
}
#-Boundary listbox row to select
set bndr_lb_row [lsearch $theArray(boundaryIds) $trg_id]
$theArray(boundaryLB) selection set $bndr_lb_row
# If not currently marked selected
# ================================
if { !$ObjectTable($trg_id,slctd) } {
set $ObjectTable($trg_id,slctd) 1
# Currently marked selected
# =========================
} else {
set $ObjectTable($trg_id,slctd) 0
#$theArray(boundaryLB) selection clear $bndr_lb_row
}
# Is focus has changed
if { $theArray(boundaryIndex) != $bndr_lb_row } {
# Exec proper array boundary selected proc
execNsProc $glob_array boundarySelected $bndr_lb_row
}
}
#-Adds or removes (toggles) a selection mark (like #)
# at the end of of a listbox entry.
# Return new status (0 = doesn't have a mark, 1 = has a mark)
#
proc ListBox::toggleSelectionMark {source row {select 1} } {
global Info
set mark $Info(selectedMark)
set data [join [$source get $row $row]]
set data [string trimright $data]
set mark_index [string first $mark $data]
if {$mark_index == -1} {
append data $mark
set hasMark 1
} else {
set data [string trimright $data $mark]
set hasMark 0
}
$source delete $row
$source insert $row $data
if { $select } {
$source selection set $row
}
return $hasMark
}
# Updates one listbox row
proc ListBox::updateRow {lbox index row {set_selected 1} } {
set start_pos [lindex [$lbox yview] 0]
$lbox delete $index $index
$lbox insert $index $row
$lbox yview moveto $start_pos
if { $set_selected } {
$lbox selection set $index
}
}
# end ecif_tk_procsListBox.tcl
# ********************
|