2 proc CopyOptions { cmd orig new } {
3 set all [eval $orig $cmd]
6 lappend configLine $arg
9 if { [llength $option] != 5 } {
12 set switch [lindex $option 0]
13 set initial [lindex $option 3]
14 set current [lindex $option 4]
15 if { [string compare $initial $current] == 0 } {
18 lappend configLine $switch $current
23 proc CopyBindings { oper orig new args } {
24 set tags [$orig $oper bind]
25 if { [llength $args] > 0 } {
26 lappend tags [lindex $args 0]
29 foreach binding [$orig $oper bind $tag] {
30 set cmd [$orig $oper bind $tag $binding]
31 $new $oper bind $tag $binding $cmd
36 proc CloneGraph { orig new } {
38 CopyOptions "configure" $orig $new
40 foreach axis [$orig axis names] {
41 if { [$new axis name $axis] == "" } {
42 $new axis create $axis
44 CopyOptions [list axis configure $axis] $orig $new
46 foreach axis { x y x2 y2 } {
47 $new ${axis}axis use [$orig ${axis}axis use]
50 foreach pen [$orig pen names] {
51 if { [$new pen name $pen] == "" } {
54 CopyOptions [list pen configure $pen] $orig $new
57 foreach marker [$orig marker names] {
58 $new marker create [$orig marker type $marker] -name $marker
59 CopyBindings marker $orig $new $marker
60 CopyOptions [list marker configure $marker] $orig $new
63 foreach elem [$orig element names] {
64 $new element create $elem
65 CopyBindings element $orig $new $elem
66 CopyOptions [list element configure $elem] $orig $new
68 # Fix element display list
69 $new element show [$orig element show]
71 CopyOptions {legend configure} $orig $new
72 CopyBindings legend $orig $new
73 # Postscript component
74 CopyOptions {postscript configure} $orig $new
76 CopyOptions {grid configure} $orig $new
78 CopyOptions {crosshairs configure} $orig $new
80 foreach binding [bind $orig] {
81 set cmd [bind $orig $binding]
82 bind $new $binding $cmd
88 pack [CloneGraph $graph .top.graph]