/usr/share/oce-0.18/src/DrawResources/StandardCommands.tcl is in oce-draw 0.18.2-2build1.
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 366 367 368 369 370 371 | # Copyright (c) 1999-2014 OPEN CASCADE SAS
#
# This file is part of Open CASCADE Technology software library.
#
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License version 2.1 as published
# by the Free Software Foundation, with special exception defined in the file
# OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
# distribution for complete text of the license and disclaimer of any warranty.
#
# Alternatively, this file may be used under the terms of Open CASCADE
# commercial license or contractual agreement.
#
# Draw standard initialisation
#
#################################################
# prompts
#################################################
set Draw_CmdIndex 0
set tcl_prompt1 {
incr Draw_CmdIndex
puts -nonewline "Draw\[$Draw_CmdIndex\]> "
}
set tcl_prompt2 {puts -nonewline "> "}
#################################################
# the help command in TCL
#################################################
proc help {{command ""} {helpstring ""} {group "Procedures"}} {
global Draw_Helps Draw_Groups
if {$command == ""} {
# help general
foreach h [lsort [array names Draw_Groups]] {
puts ""
puts ""
puts $h
set i 0
foreach f [lsort $Draw_Groups($h)] {
if {$i == 0} {
puts ""
puts -nonewline " "
}
puts -nonewline $f
for {set j [string length $f]} {$j < 15} {incr j} {
puts -nonewline " "
}
incr i
if {$i == 4} {set i 0}
}
puts ""
}
} elseif {$helpstring == ""} {
# help function
set isfound 0
foreach f [lsort [array names Draw_Helps]] {
if {[string match $command $f]} {
puts -nonewline $f
for {set j [string length $f]} {$j < 15} {incr j} {
puts -nonewline " "
}
puts " : $Draw_Helps($f)"
set isfound 1
}
}
if {!$isfound} {
if {[string first * $command] != -1} {
puts "No matching commands found!"
} else {
puts "No help found for '$command'! Please try 'help $command*' to find matching commands."
}
}
} else {
# set help
lappend Draw_Groups($group) $command
set Draw_Helps($command) $helpstring
}
flush stdout
}
help help {help pattern, or help command string group, to set help} {DRAW General Commands}
#################################################
# the getsourcefile command in TCL
#################################################
proc getsourcefile {{command ""}} {
global Draw_Helps Draw_Groups Draw_Files
set out {}
if {$command == ""} {
# help general
foreach h [lsort [array names Draw_Groups]] {
lappend out "" "" "$h"
set i 0
foreach f [lsort $Draw_Groups($h)] {
if {$i == 0} {
lappend out ""
}
incr i
#
# check that the command has its source file set
#
foreach command_that_has_file [array names Draw_Files] {
if {($command_that_has_file == $f)} {
lappend out [format {%-20s %s} $f $Draw_Files($f)]
}
}
}
}
} else {
# getsourcefile fonction
append command "*"
foreach f [lsort [array names Draw_Files]] {
if {[string match $command $f]} {
lappend out [format {%-20s %s} $f $Draw_Files($f)]
}
}
}
return [join $out "\n"]
}
help getsourcefile {getsourcefile, or getsourcefile command } {DRAW General Commands}
#################################################
# whatis
#################################################
#proc gwhatis {aVarName} {
# global $aVarName
# puts -nonewline $aVarName; puts -nonewline " is a "; puts [dtyp ${aVarName}]
#}
proc whatis args {
set __out_string ""
foreach i $args {
if {$i == "."} {set i [dname $i]}
#gwhatis $i
global $i
set __tmp_string "$i is a [dtyp $i]\n"
set __out_string "${__out_string}${__tmp_string}"
}
return ${__out_string}
}
help whatis "whatis object1 object2 ..."
#################################################
# library, lsource
#################################################
proc library lib {
global auto_path
set auto_path [linsert $auto_path 0 $lib]
if [file readable $lib/LibraryInit] {
puts "Loading $lib/LibraryInit"
uplevel "source $lib/LibraryInit"
}
}
proc lsource file {
if [file readable $file] {source $file} else {
global auto_path
foreach dir $auto_path {
if [file readable $dir/$file] {
uplevel #0 "source $dir/$file"
break
}
}
}
}
#################################################
# directory
#################################################
proc isgdraw {var} {
global $var
return [isdraw $var]
}
proc directory {{joker *}} {
set res ""
foreach var [info globals $joker] {
if [isgdraw $var] {lappend res $var}
}
return $res
}
help directory {directory [pattern], list draw variables} {DRAW Variables management}
proc lsd {} { exec ls [datadir] }
proc dall {} {
set schmurtz ""
foreach var [info globals] {
global $var
if [isdraw $var] {
if ![isprot $var] {
lappend schmurtz $var; unset $var
}
}
}
return $schmurtz
}
#################################################
# repeat, do
#################################################
proc repeat {val script} {
for {set i 1} {$i <= $val} {incr i} {uplevel $script}
}
proc do {var start end args} {
global errorInfo errorCode
if {[llength args] == 1} {
set incr 1
set body args
} else {
set incr [lindex 1 args]
set body [lindex 2 args]
}
upvar $var v
if {[dval $incr] < 0} {set rel >=} else {set rel <=}
for {dset v $start} {[dval v] $rel [dval end]} {dset v [dval v+($incr)]} {
set code [catch {uplevel $body} string]
if {$code == 1} {
return -code error -errorInfo $errorInfo -errorcode $errorCode $string
} elseif {$code == 2} {
return -code return $string
}elseif {$code == 3} {
return
} elseif {$code > 4} {
return -code $code $string
}
}
}
#################################################
# datadir, save, restore
#################################################
set Draw_DataDir "."
proc datadir {{dir ""}} {
global Draw_DataDir
if {$dir != ""} {
if {![file isdirectory $dir]} {
error "datadir : $dir is not a directory"
} else {
set Draw_DataDir $dir
}
}
return $Draw_DataDir
}
help datadir {datadir [directory]} "DRAW Variables management"
proc save {name {file ""}} {
if {$file == ""} {set file $name}
upvar $name n
if {![isdraw n]} {error "save : $name is not a Draw variable"}
global Draw_DataDir
bsave n [file join $Draw_DataDir $file]
return [file join $Draw_DataDir $file]
}
help save {save variable [filename]} "DRAW Variables management"
proc restore {file {name ""}} {
if {$name == ""} {
# if name is not given explicitly, use name of the file w/o extension
set name [file rootname [file tail $file]]
}
global Draw_DataDir
upvar $name n
brestore [file join $Draw_DataDir $file ] n
return $name
}
help restore {restore filename [variablename]} "DRAW Variables management"
#################################################
# misc...
#################################################
proc ppcurve {a} {
2dclear;
uplevel pcurve $a;
2dfit;
}
#################################################
# display and donly with jokers
#################################################
proc disp { args } {
set res ""
foreach joker $args {
if { $joker == "." } {
dtyp .
set joker [lastrep id x y b]
}
foreach var [info globals $joker] {
if { $var == "." } {
dtyp .
set var [lastrep id x y b]
}
if [isgdraw $var] {lappend res $var}
}
}
uplevel #0 eval display $res
return $res
}
proc donl { args } {
set res ""
foreach joker $args {
if { $joker == "." } {
dtyp .
set joker [lastrep id x y b]
}
foreach var [info globals $joker] {
if { $var == "." } {
dtyp .
set var [lastrep id x y b]
}
if [isgdraw $var] {lappend res $var}
}
}
uplevel #0 eval donly $res
return $res
}
proc don { args } {
set res ""
foreach joker $args {
if { $joker == "." } {
dtyp .
set joker [lastrep id x y b]
}
foreach var [info globals $joker] {
if { $var == "." } {
dtyp .
set var [lastrep id x y b]
}
if [isgdraw $var] {lappend res $var}
}
}
uplevel #0 eval donly $res
return $res
}
|