2004-07-22 Adrian Dawe <adrian.dawe@multigig.com>
* src/{measure.tcl,nodeDialog.tcl,pkgIndex.tcl.in,
readline.tcl,spicewish,spicewish.tcl,viewer.tcl}:
Update Tcl, plot improved
This commit is contained in:
parent
b0b982c5fc
commit
01724cecd1
|
|
@ -1,3 +1,9 @@
|
|||
2004-07-22 Adrian Dawe <adrian.dawe@multigig.com>
|
||||
|
||||
* src/{measure.tcl,nodeDialog.tcl,pkgIndex.tcl.in,
|
||||
readline.tcl,spicewish,spicewish.tcl,viewer.tcl}:
|
||||
Update Tcl, plot improved
|
||||
|
||||
2004-07-22 Stefan Jones <stefan.jones@multigig.com>
|
||||
|
||||
* src/spicepp.pl.in:
|
||||
|
|
|
|||
|
|
@ -254,7 +254,9 @@ namespace eval meas_markers {
|
|||
proc marker_position { w x y } {
|
||||
|
||||
variable VDD
|
||||
set VDD [spice::get_value vdd [ expr $::spice::steps_completed -1]]
|
||||
|
||||
# get VDD value from spice
|
||||
set VDD [spice::get_value vdd [expr $::spice::steps_completed -1]]
|
||||
|
||||
catch { $w element delete "m_riseTime" }
|
||||
catch { $w marker delete "m_riseTime_t" }
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
|
||||
namespace eval nodeDialog {
|
||||
|
||||
variable w ".nodeSelect"
|
||||
variable plot_title
|
||||
variable selection
|
||||
variable selected "const"
|
||||
variable selectionCnt
|
||||
|
||||
proc create { } {
|
||||
|
|
@ -12,13 +12,18 @@ namespace eval nodeDialog {
|
|||
|
||||
if {[winfo exists $w]} {
|
||||
raise $w
|
||||
Update
|
||||
return
|
||||
}
|
||||
|
||||
toplevel $w
|
||||
|
||||
pack [frame $w.plots] -fill x
|
||||
pack [listbox $w.plots.lst -height 3 \
|
||||
wm title $w "Vectors"
|
||||
|
||||
# Plot names
|
||||
#pack [frame $w.plots] -fill x
|
||||
frame $w.plots
|
||||
pack [listbox $w.plots.lst -height 4 \
|
||||
-width 50 \
|
||||
-yscrollcommand {.nodeSelect.plots.sx set} \
|
||||
] -fill x -expand 1 -side left
|
||||
|
|
@ -28,8 +33,9 @@ namespace eval nodeDialog {
|
|||
-command {.nodeSelect.plots.lst yview}\
|
||||
] -fill y -side right
|
||||
|
||||
|
||||
pack [frame $w.nodes] -fill both -expand 1
|
||||
# vector names
|
||||
#pack [frame $w.nodes] -fill both -expand 1
|
||||
frame $w.nodes
|
||||
pack [blt::hierbox $w.nodes.hb -hideroot 1 \
|
||||
-yscrollcommand {.nodeSelect.nodes.sx set} \
|
||||
-selectbackground "#e6e6e6" \
|
||||
|
|
@ -40,6 +46,27 @@ namespace eval nodeDialog {
|
|||
-command {.nodeSelect.nodes.hb yview} \
|
||||
] -fill y -side right
|
||||
|
||||
# control frame
|
||||
#pack [frame $w.fcont] -fill x
|
||||
frame $w.fcont
|
||||
pack [label $w.fcont.lselected -text "Selected: "] -side left
|
||||
pack [button $w.fcont.bNodeCnt -textvariable spicewish::nodeDialog::selectionCnt \
|
||||
-padx 1m \
|
||||
-command spicewish::nodeDialog::clearSelection \
|
||||
] -side left
|
||||
pack [button $w.fcont.bPlot -text " Plot " \
|
||||
-command spicewish::nodeDialog::plotSelection ]
|
||||
|
||||
|
||||
# blt table
|
||||
blt::table $w \
|
||||
0,0 $w.plots -fill x \
|
||||
1,0 $w.nodes -fill both \
|
||||
2,0 $w.fcont -fill x
|
||||
|
||||
blt::table configure $w r0 r2 -resize none
|
||||
|
||||
# bindings
|
||||
$w.nodes.hb bind all <Button-1> {
|
||||
set hierbox_path %W
|
||||
set index [$hierbox_path index current]
|
||||
|
|
@ -64,19 +91,18 @@ namespace eval nodeDialog {
|
|||
}
|
||||
set spicewish::nodeDialog::selectionCnt [llength $::spicewish::nodeDialog::selection($plotTypeName)]
|
||||
}
|
||||
pack [frame $w.fcont] -fill x
|
||||
pack [button $w.fcont.bNodeCnt -textvariable spicewish::nodeDialog::selectionCnt \
|
||||
-padx 1m \
|
||||
-command spicewish::nodeDialog::clearSelection \
|
||||
] -side left
|
||||
pack [button $w.fcont.bPlot -text "Plot" \
|
||||
-command spicewish::nodeDialog::plotSelection ]
|
||||
|
||||
bind $w.plots.lst <ButtonRelease-1> { spicewish::nodeDialog::selectPlot %W }
|
||||
bind $w.plots.lst <ButtonRelease-1> {
|
||||
spicewish::nodeDialog::selectPlot %W
|
||||
}
|
||||
|
||||
wm protocol $w WM_TAKE_FOCUS { spicewish::nodeDialog::currentPlots }
|
||||
# mouse wheel bindings
|
||||
bind $w.nodes.hb <Button-5> [list %W yview scroll 5 units]
|
||||
bind $w.nodes.hb <Button-4> [list %W yview scroll -5 units]
|
||||
|
||||
wm protocol $w WM_TAKE_FOCUS { spicewish::nodeDialog::Update }
|
||||
|
||||
currentPlots
|
||||
Update
|
||||
}
|
||||
|
||||
proc plotSelection { } {
|
||||
|
|
@ -84,7 +110,10 @@ namespace eval nodeDialog {
|
|||
|
||||
set plotNum [.nodeSelect.plots.lst curselection]
|
||||
set plotTypeName [spice::plot_typename $plotNum]
|
||||
eval "spicewish::viewer::oplot $plotNum $selection($plotTypeName)"
|
||||
|
||||
if {$selection($plotTypeName) == ""} {return}
|
||||
|
||||
eval "spicewish::viewer::oplot $plotTypeName $selection($plotTypeName)"
|
||||
}
|
||||
|
||||
proc loadSelection { } {
|
||||
|
|
@ -117,10 +146,15 @@ namespace eval nodeDialog {
|
|||
populateTree [.nodeSelect.plots.lst curselection]
|
||||
}
|
||||
|
||||
proc currentPlots { } {
|
||||
proc Update { } {
|
||||
variable plot_title
|
||||
variable selection
|
||||
variable selected
|
||||
variable w
|
||||
|
||||
if {![winfo exists $w]} {return}
|
||||
|
||||
# get current plots titles
|
||||
set index 0
|
||||
while { ![catch {set t [spice::plot_name $index]} ] } {
|
||||
|
||||
|
|
@ -136,14 +170,21 @@ namespace eval nodeDialog {
|
|||
incr index
|
||||
}
|
||||
|
||||
# populate current plot window
|
||||
.nodeSelect.plots.lst delete 0 end
|
||||
|
||||
|
||||
for {set i 0} {$i < [array size plot_title]} {incr i} {
|
||||
.nodeSelect.plots.lst insert end $plot_title($i)
|
||||
}
|
||||
|
||||
.nodeSelect.plots.lst selection set 0
|
||||
populateTree 0
|
||||
# list position of selected plot
|
||||
set listPos [spicewish::vectors::get_plotNum $selected]
|
||||
if {$listPos < 0} {set listPos 0}
|
||||
|
||||
.nodeSelect.plots.lst selection set $listPos
|
||||
.nodeSelect.plots.lst see $listPos
|
||||
|
||||
populateTree $listPos
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +207,10 @@ namespace eval nodeDialog {
|
|||
}
|
||||
|
||||
proc selectPlot { w } {
|
||||
variable selected
|
||||
set index [$w curselection]
|
||||
set selected [spicewish::vectors::get_plotTypeName $index]
|
||||
|
||||
populateTree $index
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ proc Loadspice { version dir } {
|
|||
blt::vector create ::spice::Y_Data
|
||||
|
||||
namespace eval spice {
|
||||
namespace export ac help save alias sens alter altermod iplot setcirc asciiplot jobs setplot aspice setscale bg let settype linearize shell bug listing shift show cdump maxstep showmod compose newhelp noise spec cross oldhelp spice dc op spice_data define spice_header deftype plot state delete plot_datapoints status delta plot_date step plot_get_value stop diff plot_name strcmp display plot_nvars tf disto plot_title dowhile plot_variables tran dump print transpose echo pz tutorial edit quit unalias else rehash undefine end repeat unlet reset fourier reshape version spicetoblt resume where get_output rspice get_param run write goto running xgraph hardcopy rusage steps_completed blt_vnum codemodel halt loadsnap savesnap
|
||||
namespace export ac help save alias sens alter altermod iplot setcirc asciiplot jobs setplot aspice setscale bg let settype linearize shell bug listing shift show cdump maxstep showmod compose newhelp noise spec cross oldhelp spice dc op spice_data define spice_header deftype plot state delete plot_datapoints status delta plot_date step plot_get_value stop diff plot_name strcmp display plot_nvars tf disto plot_title dowhile plot_variables tran dump print transpose echo pz tutorial edit quit unalias else rehash undefine end repeat unlet reset fourier reshape version spicetoblt resume where get_output rspice get_param run write goto running xgraph hardcopy rusage steps_completed blt_vnum codemodel halt loadsnap savesnap getplot
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -72,18 +72,11 @@ proc Loadspice { version dir } {
|
|||
puts "DefineLinestyle $linestyleid $mask"
|
||||
}
|
||||
|
||||
# proc spice_init_gui { spicefile } {
|
||||
# if { ! [ winfo exists .controls ] } {
|
||||
# source "/usr/lib/spice/tclspice_source.tcl" ;#- only load procs when gui needed
|
||||
# }
|
||||
# spicewish::init_gui $spicefile
|
||||
# }
|
||||
|
||||
proc spice_init_gui { fileName {gui 0} {batchMode 0}} {
|
||||
|
||||
# source tclcode
|
||||
if {[info procs spicewish::plot] == ""} {
|
||||
source [file join "spice/spicewish.tcl"]
|
||||
source [file join $::spice_library "spice/spicewish.tcl"]
|
||||
}
|
||||
|
||||
if {!$batchMode} { spice::version }
|
||||
|
|
@ -108,9 +101,8 @@ proc Loadspice { version dir } {
|
|||
}
|
||||
}
|
||||
}
|
||||
if {$gui == 0} {
|
||||
wm withdraw .
|
||||
}
|
||||
if {$gui == 1} { spicewish::gui }
|
||||
wm withdraw .
|
||||
}
|
||||
|
||||
set ::spice_version $version
|
||||
|
|
|
|||
|
|
@ -22,6 +22,16 @@ namespace eval readline {
|
|||
"spicewish\:\:iplot" - "iplot" {
|
||||
return [::tclreadline::TryFromList $word [spice::plot_variables 0]]
|
||||
}
|
||||
"spicewish\:\:oplot" - "oplot" {
|
||||
|
||||
if {[lsearch "[spicewish::vectors::avaliable_plotNames]" [lindex $line 1]] != -1} {
|
||||
set plotNum [spicewish::vectors::get_plotNum [lindex $line 1]]
|
||||
return [::tclreadline::TryFromList $word [spice::plot_variables $plotNum]]
|
||||
} else {
|
||||
return [::tclreadline::TryFromList $word [spicewish::vectors::avaliable_plotNames]]
|
||||
}
|
||||
|
||||
}
|
||||
"spicewish\:\:measDialog" - "measDialog" {
|
||||
return [::tclreadline::TryFromList $word [spice::plot_variables 0]]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ proc run_spicepp { fileName } {
|
|||
source [file join $::spice_library "spice/spicepp.tcl"]
|
||||
|
||||
puts ""
|
||||
# check if file contains Hspice statemenst
|
||||
# check if file contains Hspice statements
|
||||
if {[spicepp::checkHSpiceFormat $fileName]} {
|
||||
|
||||
set ppFileName [spicepp::convert $fileName]
|
||||
|
|
@ -58,7 +58,7 @@ proc spicewish_load { argv argc } {
|
|||
}
|
||||
-h - -help { spicewish_usage }
|
||||
-b { set ::mode_batch 1 }
|
||||
-version { spice::version }
|
||||
-version { spice::version; exit }
|
||||
-pp { set mode_spicePP 1 }
|
||||
default { spicewish_usage }
|
||||
}
|
||||
|
|
@ -86,22 +86,45 @@ proc Tclreadline { } {
|
|||
if {$::tcl_interactive} {
|
||||
proc ::tclreadline::prompt1 { } { return "tclspice -> " }
|
||||
|
||||
puts "tclspice ->"
|
||||
puts "tclspice ->"
|
||||
::tclreadline::Loop .tclspice-history
|
||||
puts "tclspice -> "
|
||||
|
||||
if [info exists ::env(HOME)] {
|
||||
set historyfile $::env(HOME)/.tclspice-history
|
||||
} else {
|
||||
set historyfile .tclspice-history
|
||||
}
|
||||
|
||||
::tclreadline::Loop $historyfile
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
proc spicewish_import_namespaces { } {
|
||||
|
||||
|
||||
#----------------
|
||||
# spice::
|
||||
namespace eval spice {
|
||||
namespace export ac help save alias sens alter altermod setcirc asciiplot jobs setplot aspice setscale bg let settype linearize shell bug listing shift show cdump maxstep showmod compose newhelp noise spec cross oldhelp spice dc op spice_data define spice_header deftype state delete plot_datapoints status delta plot_date step plot_get_value stop diff plot_name strcmp display plot_nvars tf disto plot_title dowhile plot_variables tran dump print transpose echo pz tutorial edit quit unalias else rehash undefine end repeat unlet reset fourier reshape version spicetoblt resume where get_output rspice get_param write goto running xgraph hardcopy rusage steps_completed blt_vnum codemodel loadsnap savesnap
|
||||
# get list of spice:: commands
|
||||
set all_spiceCommands [namespace eval spice [list info commands]]
|
||||
set commands ""
|
||||
foreach command $all_spiceCommands {
|
||||
if {[namespace eval spice [list namespace origin $command]] == "::spice::${command}" } {
|
||||
lappend commands $command
|
||||
}
|
||||
}
|
||||
|
||||
namespace import -force spice::*
|
||||
# export
|
||||
namespace eval spice [namespace export $commands]
|
||||
|
||||
# import into current namespace
|
||||
namespace import -force spice::*
|
||||
|
||||
# add command to readline
|
||||
foreach command $commands {
|
||||
::tclreadline::readline add $command
|
||||
}
|
||||
|
||||
#----------------
|
||||
# spicewish::
|
||||
rename ::source ::tclSource
|
||||
rename ::load ::tclLoad
|
||||
|
|
|
|||
|
|
@ -27,9 +27,13 @@ namespace eval spicewish {
|
|||
spicewish::controls::create
|
||||
}
|
||||
|
||||
proc iplot {args} {
|
||||
eval spicewish::viewer::iplot $args
|
||||
}
|
||||
# proc iplot {args} {
|
||||
# eval spicewish::viewer::iplot $args
|
||||
# }
|
||||
|
||||
proc oplot {args} {
|
||||
eval spicewish::viewer::oplot $args
|
||||
}
|
||||
|
||||
proc source { fileName } {
|
||||
if {![file exists $fileName]} {
|
||||
|
|
@ -48,6 +52,7 @@ namespace eval spicewish {
|
|||
proc load { fileName } {
|
||||
if {[string tolower [file extension $fileName]] == ".raw" } {
|
||||
spice::load $fileName
|
||||
spicewish::nodeDialog::Update
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -85,5 +90,35 @@ namespace eval spicewish {
|
|||
|
||||
spice::registerStepCallback spicewish::stepCallBack 1 1
|
||||
|
||||
namespace export plot gui iplot source run halt load measDialog write2gnuplot
|
||||
namespace export plot gui oplot source run halt load measDialog write2gnuplot
|
||||
}
|
||||
|
||||
|
||||
set ::spicewish::viewer::bltplotCnt -1
|
||||
|
||||
proc spice_gr_Plot { args } {
|
||||
|
||||
# time time s a0 voltage V 1
|
||||
set xName [lindex $args 0]
|
||||
set xType [lindex $args 1]
|
||||
set xUnits [lindex $args 2]
|
||||
set yName [lindex $args 3]
|
||||
set yType [lindex $args 4]
|
||||
set yUnits [lindex $args 5]
|
||||
set viewerCnt [lindex $args 6]
|
||||
|
||||
set plotNum [spicewish::vectors::get_plotNum [spice::getplot]]
|
||||
|
||||
if {$spicewish::viewer::vecUpdate_flag} {
|
||||
# update exsisting plots
|
||||
|
||||
} else {
|
||||
# add new plot
|
||||
if {$::spicewish::viewer::bltplotCnt == $viewerCnt } {
|
||||
eval spicewish::viewer::addplot [expr $::spicewish::viewer::viewCnt -1] $plotNum $args
|
||||
} else {
|
||||
eval spicewish::viewer::newplot $plotNum $args
|
||||
set ::spicewish::viewer::bltplotCnt $viewerCnt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
288
src/viewer.tcl
288
src/viewer.tcl
|
|
@ -4,12 +4,16 @@ namespace eval viewer {
|
|||
variable wNames ".tclspice"
|
||||
variable viewCnt 1
|
||||
|
||||
variable vecUpdate_flag 0
|
||||
|
||||
variable viewTraces
|
||||
variable viewTraceScale
|
||||
variable view_w
|
||||
variable view_traces
|
||||
variable view_type
|
||||
variable view_plotName
|
||||
variable view_traceCnt
|
||||
variable view_Xscale
|
||||
|
||||
variable meas_dx
|
||||
variable meas_dy
|
||||
|
|
@ -24,7 +28,7 @@ namespace eval viewer {
|
|||
variable view_w
|
||||
|
||||
set w [toplevel "${wNames}${viewCnt}"]
|
||||
set plotName [spicewish::vectors::plotTypeName $plotNum]
|
||||
set plotName [spicewish::vectors::get_plotTypeName $plotNum]
|
||||
|
||||
wm title $w "\[$w\] - $plotName - [spice::plot_title $plotNum]"
|
||||
|
||||
|
|
@ -135,64 +139,90 @@ namespace eval viewer {
|
|||
return [array names view_w]
|
||||
}
|
||||
|
||||
proc plot { args } {
|
||||
eval "oplot 0 $args"
|
||||
proc plot { args } {
|
||||
|
||||
if {$args == ""} {return}
|
||||
|
||||
spice::bltplot $args
|
||||
}
|
||||
|
||||
proc oplot { plotNum args } {
|
||||
proc oplot { plotTypeName args } {
|
||||
|
||||
if {$args == ""} {return}
|
||||
|
||||
set currentPlotType [spice::getplot]
|
||||
|
||||
spice::setplot $plotTypeName
|
||||
|
||||
spice::bltplot $args
|
||||
|
||||
spice::setplot $currentPlotType
|
||||
}
|
||||
|
||||
proc newplot { plotNum args } {
|
||||
|
||||
variable view_w
|
||||
variable view_traces
|
||||
variable view_type
|
||||
variable view_plotName
|
||||
|
||||
eval "set args \[spicewish::vectors::validVectorList $plotNum $args\]"
|
||||
|
||||
variable view_traceCnt
|
||||
|
||||
if {$args == ""} {return}
|
||||
|
||||
|
||||
# create a new viewer
|
||||
set viewNum [create $plotNum]
|
||||
set w $view_w($viewNum)
|
||||
set view_traces($viewNum) ""
|
||||
set view_type($viewNum) "plot"
|
||||
set view_plotName($viewNum) [spicewish::vectors::plotTypeName $plotNum]
|
||||
set view_traces($viewNum) ""
|
||||
set view_type($viewNum) "plot"
|
||||
set view_plotName($viewNum) [spicewish::vectors::get_plotTypeName $plotNum]
|
||||
set view_traceCnt 0
|
||||
|
||||
# add/update default scale
|
||||
set defBLTvec [spicewish::vectors::create $plotNum [spicewish::vectors::defaultScale $plotNum]]
|
||||
|
||||
if {$defBLTvec == ""} {
|
||||
puts "Error: plotting '[spicewish::vectors::defaultScale $plotNum]'"
|
||||
return
|
||||
}
|
||||
|
||||
set traceCnt 0
|
||||
#loop for all vectors
|
||||
foreach vectorName $args {
|
||||
|
||||
# don't allow duplicate traces
|
||||
|
||||
set BLTvec [spicewish::vectors::create $plotNum "$vectorName"]
|
||||
|
||||
if {$BLTvec == ""} {
|
||||
puts "Error: plotting '$vectorName'"
|
||||
continue
|
||||
}
|
||||
|
||||
lappend view_traces($viewNum) $vectorName
|
||||
|
||||
$w.g element create "$vectorName" \
|
||||
-xdata $defBLTvec \
|
||||
-ydata $BLTvec \
|
||||
-symbol "circle" \
|
||||
-linewidth 2 \
|
||||
-pixels 3 \
|
||||
-color [trace_colour $traceCnt]
|
||||
|
||||
incr traceCnt
|
||||
}
|
||||
return $w
|
||||
eval "addplot $viewNum $plotNum $args"
|
||||
}
|
||||
|
||||
proc addplot { viewNum plotNum args } {
|
||||
|
||||
variable view_w
|
||||
variable view_traces
|
||||
variable view_type
|
||||
variable view_plotName
|
||||
variable view_traceCnt
|
||||
variable view_Xscale
|
||||
|
||||
if {$args == ""} {return}
|
||||
|
||||
set w $view_w($viewNum)
|
||||
|
||||
set xName [lindex $args 0]
|
||||
set xType [lindex $args 1]
|
||||
set xUnits [lindex $args 2]
|
||||
set yName [lindex $args 3]
|
||||
set yType [lindex $args 4]
|
||||
set yUnits [lindex $args 5]
|
||||
|
||||
set xVarName [spicewish::vectors::create_vecName $plotNum $xName]
|
||||
set yVarName [spicewish::vectors::create_vecName $plotNum $yName]
|
||||
|
||||
eval $xVarName set ::spice::X_Data
|
||||
eval $yVarName set ::spice::Y_Data
|
||||
|
||||
lappend view_traces($viewNum) $yName
|
||||
set view_Xscale($viewNum) $xName
|
||||
|
||||
$w.g element create "$yName" \
|
||||
-xdata $xVarName \
|
||||
-ydata $yVarName \
|
||||
-symbol "circle" \
|
||||
-linewidth 2 \
|
||||
-pixels 3 \
|
||||
-color [trace_colour $view_traceCnt]
|
||||
|
||||
$w.g axis configure x -title $xName
|
||||
|
||||
incr view_traceCnt
|
||||
# return $w
|
||||
}
|
||||
|
||||
proc iplot { args } {
|
||||
variable view_type
|
||||
|
||||
|
|
@ -218,16 +248,6 @@ namespace eval viewer {
|
|||
return -1
|
||||
}
|
||||
|
||||
proc get_plotNum { plotTypeName } {
|
||||
|
||||
for {set i 0} {$i < [spicewish::vectors::avaliable_plots]} {incr i} {
|
||||
if {[spicewish::vectors::plotTypeName $i] == $plotTypeName} {
|
||||
return $i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
proc axis_callback { widget value } {
|
||||
|
||||
return [ spicewish::eng::float_eng $value]
|
||||
|
|
@ -250,7 +270,7 @@ namespace eval viewer {
|
|||
|
||||
proc stepCallBack { } {
|
||||
|
||||
set currentPlotName [spicewish::vectors::plotTypeName 0]
|
||||
set currentPlotName [spicewish::vectors::get_plotTypeName 0]
|
||||
|
||||
#puts $::spice::steps_completed
|
||||
# hack !!!
|
||||
|
|
@ -259,22 +279,90 @@ namespace eval viewer {
|
|||
|
||||
}
|
||||
|
||||
proc save_postscript { w } {
|
||||
variable view_plotName
|
||||
|
||||
if {![winfo exists $w]} {
|
||||
puts stderr "Error: '$w' doesn't exist"
|
||||
return
|
||||
}
|
||||
|
||||
set plotNum [spicewish::viewer::get_index $w]
|
||||
if {$plotNum == -1} {
|
||||
puts stderr "Error: invalid viewer"
|
||||
return
|
||||
}
|
||||
|
||||
set fileName "[string range $w 1 end].ps"
|
||||
|
||||
set plotNum [spicewish::vectors::get_plotNum $view_plotName($plotNum)]
|
||||
set w "$w.g"
|
||||
|
||||
# save current backround colours etc
|
||||
set prevSetting(title) [$w cget -title]
|
||||
set prevSetting(plotrelief) [$w cget -plotrelief]
|
||||
set prevSetting(bg) [$w cget -background]
|
||||
set prevSetting(xaxis_bg) [$w xaxis cget -background]
|
||||
set prevSetting(yaxis_bg) [$w xaxis cget -background]
|
||||
set prevSetting(legend_relief) [$w legend cget -relief]
|
||||
set prevSetting(legend_bg) [$w legend cget -background]
|
||||
|
||||
|
||||
# apply white background
|
||||
$w configure -title [spice::plot_title $plotNum]
|
||||
$w configure -plotrelief "flat"
|
||||
$w configure -background "white"
|
||||
$w xaxis configure -background "white"
|
||||
$w yaxis configure -background "white"
|
||||
$w legend configure -relief "flat"
|
||||
$w legend configure -background "white"
|
||||
|
||||
|
||||
# save postscript
|
||||
$w postscript output $fileName -maxpect 1
|
||||
|
||||
# reapply inital colours
|
||||
$w configure -title $prevSetting(title)
|
||||
$w configure -plotrelief $prevSetting(plotrelief)
|
||||
$w configure -background $prevSetting(bg)
|
||||
$w xaxis configure -background $prevSetting(xaxis_bg)
|
||||
$w yaxis configure -background $prevSetting(yaxis_bg)
|
||||
$w legend configure -relief $prevSetting(legend_relief)
|
||||
$w legend configure -background $prevSetting(legend_bg)
|
||||
|
||||
|
||||
puts stdout "created '$fileName'"
|
||||
}
|
||||
|
||||
proc Update { } {
|
||||
variable view_traces
|
||||
variable view_plotName
|
||||
variable vecUpdate_flag
|
||||
variable view_Xscale
|
||||
variable view_plotName
|
||||
|
||||
set vecUpdate_flag 1
|
||||
|
||||
foreach index [names] {
|
||||
|
||||
set plotTypeName $view_plotName($index)
|
||||
set plotNum [get_plotNum $plotTypeName]
|
||||
|
||||
# default scale
|
||||
spicewish::vectors::create $plotNum [spicewish::vectors::defaultScale $plotNum]
|
||||
set plotNum [spicewish::vectors::get_plotNum $plotTypeName]
|
||||
|
||||
foreach trace "$view_traces($index) $view_Xscale($index)" {
|
||||
set currentPlot [spice::getplot]
|
||||
spice::setplot $view_plotName($index)
|
||||
|
||||
foreach trace $view_traces($index) {
|
||||
spicewish::vectors::create $plotNum $trace
|
||||
::spice::X_Data set ""
|
||||
spice::bltplot $trace
|
||||
|
||||
eval $\{::$view_plotName($index):v:$trace\} set \"::spice::Y_Data\"
|
||||
|
||||
spice::setplot $currentPlot
|
||||
}
|
||||
|
||||
}
|
||||
set vecUpdate_flag 0
|
||||
return ""
|
||||
}
|
||||
|
||||
proc Destroy { w } {
|
||||
|
|
@ -307,10 +395,39 @@ namespace eval vectors {
|
|||
if {[lsearch -exact $list $name] != -1} {
|
||||
return $name
|
||||
} else {
|
||||
return ""
|
||||
::spice::Y_Data set ""
|
||||
uplevel #0 ::spice::bltplot $name
|
||||
|
||||
if {[::spice::Y_Data length] != 0} {
|
||||
return $name
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc get_plotNum { plotTypeName } {
|
||||
|
||||
for {set i 0} {$i < [avaliable_plotNums]} {incr i} {
|
||||
if {[get_plotTypeName $i] == $plotTypeName} {
|
||||
return $i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
proc get_plotTypeName { plotNum } {
|
||||
return [spice::plot_typename $plotNum]
|
||||
}
|
||||
|
||||
proc avaliable_plotNames { } {
|
||||
|
||||
for {set plotNum 0} {$plotNum < [avaliable_plotNums]} {incr plotNum} {
|
||||
lappend list [get_plotTypeName $plotNum]
|
||||
}
|
||||
return $list
|
||||
}
|
||||
|
||||
proc validVectorList { plotNum args } {
|
||||
set validList ""
|
||||
|
||||
|
|
@ -324,21 +441,16 @@ namespace eval vectors {
|
|||
|
||||
return $validList
|
||||
}
|
||||
|
||||
proc plotTypeName { plot } {
|
||||
# plot type eg tran1, dc1
|
||||
return [spice::plot_typename $plot]
|
||||
}
|
||||
|
||||
proc type { plot name } {
|
||||
set spice_data [spice::spice_data $plot] ;# "{a0 voltage}{time time}"
|
||||
proc type { plotNum name } {
|
||||
set spice_data [spice::spice_data $plotNum] ;# "{a0 voltage}{time time}"
|
||||
|
||||
set name [string tolower $name]
|
||||
set spice_data [string tolower $spice_data]
|
||||
|
||||
foreach plot $spice_data {
|
||||
set p_name [lindex $plot 0] ;# node name
|
||||
set p_type [lindex $plot 1] ;# voltage/current/time
|
||||
foreach plot_data $spice_data {
|
||||
set p_name [lindex $plot_data 0] ;# node name
|
||||
set p_type [lindex $plot_data 1] ;# voltage/current/time
|
||||
|
||||
if {$p_name == $name} {
|
||||
return $p_type
|
||||
|
|
@ -347,7 +459,7 @@ namespace eval vectors {
|
|||
return ""
|
||||
}
|
||||
|
||||
proc avaliable_plots { } {
|
||||
proc avaliable_plotNums { } {
|
||||
set cnt 0
|
||||
while {![catch { spice::plot_name $cnt }]} {
|
||||
incr cnt
|
||||
|
|
@ -355,25 +467,23 @@ namespace eval vectors {
|
|||
return $cnt
|
||||
}
|
||||
|
||||
proc defaultScale { plot } {
|
||||
proc defaultScale { plotNum } {
|
||||
|
||||
return [spice::plot_defaultscale $plot]
|
||||
return [spice::plot_defaultscale $plotNum]
|
||||
}
|
||||
|
||||
proc create_vecName { plotNum nodeName } {
|
||||
|
||||
proc create { plot name } {
|
||||
|
||||
# valid vector
|
||||
if {[exists $plot $name] == ""} {return ""}
|
||||
|
||||
if { ![info exists "::[plotTypeName $plot]:v:${name}"]} {
|
||||
set ::[plotTypeName $plot]:v:${name} "[blt::vector #auto]"
|
||||
set name "::[get_plotTypeName $plotNum]:v:${nodeName}"
|
||||
|
||||
if {![info exists $name]} {
|
||||
set vecName [blt::vector #auto]
|
||||
eval set $name $vecName
|
||||
} else {
|
||||
eval set vecName \${$name}
|
||||
}
|
||||
|
||||
eval "set tmp \${::[plotTypeName $plot]:v:${name}}"
|
||||
|
||||
eval spice::plot_getvector $plot $name $tmp
|
||||
|
||||
return $tmp
|
||||
return $vecName
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue