#!/usr/bin/wish
#############################################################################
# Visual Tcl v1.10 Project
#

#################################
# GLOBAL VARIABLES
#
global MARCAS_X; 
global MARCAS_Y; 
global MARCAS_Z; 
global ROT_X; 
global ROT_Z; 
global SIN_BORDE; 
global colorL; 
global dime; 
global eX; 
global eY; 
global etiq; 
global exp; 
global llabel; 
global malla_var; 
global orienta; 
global widget; 
    set widget(GNUTK) {.top17.fra18.can17}
    set widget(RANGES) {.top19}
    set widget(SAVE) {.top28}
    set widget(SOBRE) {.top21}
    set widget(TRAMA) {.top30}
    set widget(WARNING_POLAR) {.top18.but21}
    set widget(ejesL) {.top18}
    set widget(importacion) {.top20}
    set widget(rev,.top17.fra18.can17) {GNUTK}
    set widget(rev,.top17.fra18.men20.m.men17) {ejesL}
    set widget(rev,.top18) {ejesL}
    set widget(rev,.top18.but21) {WARNING_POLAR}
    set widget(rev,.top19) {RANGES}
    set widget(rev,.top20) {importacion}
    set widget(rev,.top21) {SOBRE}
    set widget(rev,.top28) {SAVE}
    set widget(rev,.top30) {TRAMA}
    set widget(rev,.top30.fra31.but36) {TRAMA}

#################################
# USER DEFINED PROCEDURES
#
proc init {argc argv} {

}

init $argc $argv


proc replot {x} {
set viewz $x
}

proc main {argc argv} {

}

proc Window {args} {
global vTcl
    set cmd [lindex $args 0]
    set name [lindex $args 1]
    set newname [lindex $args 2]
    set rest [lrange $args 3 end]
    if {$name == "" || $cmd == ""} {return}
    if {$newname == ""} {
        set newname $name
    }
    set exists [winfo exists $newname]
    switch $cmd {
        show {
            if {$exists == "1" && $name != "."} {wm deiconify $name; return}
            if {[info procs vTclWindow(pre)$name] != ""} {
                eval "vTclWindow(pre)$name $newname $rest"
            }
            if {[info procs vTclWindow$name] != ""} {
                eval "vTclWindow$name $newname $rest"
            }
            if {[info procs vTclWindow(post)$name] != ""} {
                eval "vTclWindow(post)$name $newname $rest"
            }
        }
        hide    { if $exists {wm withdraw $newname; return} }
        iconify { if $exists {wm iconify $newname; return} }
        destroy { if $exists {destroy $newname; return} }
    }
}

#################################
# VTCL GENERATED GUI PROCEDURES
#

proc vTclWindow. {base} {
    if {$base == ""} {
        set base .
    }
    ###################
    # CREATING WIDGETS
    ###################
    wm focusmodel $base passive
    wm geometry $base 1x1+0+0
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 0 0
    wm withdraw $base
    wm title $base "vt.tcl"
    ###################
    # SETTING GEOMETRY
    ###################
}

proc vTclWindow.top17 {base} {
    if {$base == ""} {
        set base .top17
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel \
        -background #ccbebe -highlightbackground #ccbebe \
        -highlightcolor #d4eeca 
    wm focusmodel $base passive
    wm geometry $base 444x504+482+136
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm deiconify $base
    wm title $base "UniGNUPlot 1.0.1 Beta"
    frame $base.fra18 \
        -background #beccbe -borderwidth 2 -height 75 -relief groove \
        -width 125 
    button $base.fra18.but19 \
        \
        -command {if { $malla_var == 1} {
set grid "set grid"
} else {
set grid ""
}

if { $SIN_BORDE == 1 } {
set border "set noborder" 
} else { 
set border "set border"
}

if { $MARCAS_X == 1 } {
set MX "set noxtics" 
} else { 
set MX "set xtics"
}

if { $MARCAS_Y == 1 } {
set MY "set noytics" 
} else { 
set MY "set ytics"
}

if { $MARCAS_Z == 1 } {
set MZ "set noztics" 
} else { 
set MZ "set ztics"
}


if { $eX == 1 } {
 set ejeX "set xzeroaxis"
} else {
set ejeX ""
}


if { $eY == 1 } {
 set ejeY "set yzeroaxis"
} else {
 set ejeY ""
}


set fp [open "| gnuplot" r+]

fconfigure $fp -buffering line

#puts $fp "set term postscript $orienta $color"
#puts $fp "set output 'tmp.ps'"

puts $fp "set view $ROT_X, $ROT_Z"

puts $fp $MX
puts $fp $MY
puts $fp $MZ

puts $fp "set term tk"
puts $fp "set output 'f1.tk'"

puts $fp $border
puts $fp $tipo

puts $fp $label

puts $fp "set title \"$titulo\" "

puts $fp $xlabel
puts $fp $ylabel
puts $fp $zlabel
puts $fp $ejeX
puts $fp $ejeY

puts $fp $xrange
puts $fp $yrange
puts $fp $zrange

puts $fp $grid

puts $fp "set isosamples $TRAMA_X,$TRAMA_Y"


puts $fp "$plot $exp $line"
close $fp
source f1.tk
gnuplot $widget(GNUTK)} \
        -font {Helvetica -10 normal} -padx 9 -pady 3 -text Graficar 
    frame $base.fra18.cpd23 \
        -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra18.cpd23.01 \
        -anchor w -relief groove -text expresión 
    entry $base.fra18.cpd23.02 \
        -cursor {} -textvariable exp 
    bind $base.fra18.cpd23.02 <Key><Key-Return> {
        if { $malla_var == 1} {
set grid "set grid"
} else {
set grid ""
}

if { $SIN_BORDE == 1 } {
set border "set noborder" 
} else { 
set border "set border"
}

if { $MARCAS_X == 1 } {
set MX "set noxtics" 
} else { 
set MX "set xtics"
}

if { $MARCAS_Y == 1 } {
set MY "set noytics" 
} else { 
set MY "set ytics"
}

if { $MARCAS_Z == 1 } {
set MZ "set noztics" 
} else { 
set MZ "set ztics"
}


if { $eX == 1 } {
 set ejeX "set xzeroaxis"
} else {
set ejeX ""
}


if { $eY == 1 } {
 set ejeY "set yzeroaxis"
} else {
 set ejeY ""
}


set fp [open "| gnuplot" r+]

fconfigure $fp -buffering line

#puts $fp "set term postscript $orienta $color"
#puts $fp "set output 'tmp.ps'"

puts $fp "set view $ROT_X, $ROT_Z"

puts $fp $MX
puts $fp $MY
puts $fp $MZ

puts $fp "set term tk"
puts $fp "set output 'f1.tk'"

puts $fp $border
puts $fp $tipo

puts $fp $label

puts $fp "set title \"$titulo\" "

puts $fp $xlabel
puts $fp $ylabel
puts $fp $zlabel
puts $fp $ejeX
puts $fp $ejeY

puts $fp $xrange
puts $fp $yrange
puts $fp $zrange

puts $fp $grid

puts $fp "set isosamples $TRAMA_X,$TRAMA_Y"


puts $fp "$plot $exp $line"
close $fp
source f1.tk
gnuplot $widget(GNUTK)
    }
    checkbutton $base.fra18.che27 \
        -background #bed0be -command {set malla 1} \
        -font {Helvetica -10 normal} -foreground #000000 -indicatoron 0 \
        -text Malla -variable malla_var 
    menubutton $base.fra18.men17 \
        -font {Helvetica -10 normal} -menu .top17.fra18.men17.m -padx 4 \
        -pady 3 -relief raised -text Lineas -textvariable llabel 
    menu $base.fra18.men17.m \
        -cursor {} -tearoff 0 
    $base.fra18.men17.m add command \
        -command {set line "w dots"
set llabel "Puntos"} -label Puntos 
    $base.fra18.men17.m add command \
        -command {set line "w lines"
set llabel "Linea"} -label Lineas 
    $base.fra18.men17.m add command \
        -command {set line "w boxes"
set llabel "Cajas"} -label Cajas 
    $base.fra18.men17.m add command \
        -command {set line "w steps"
set llabel "Escalonado"} \
        -label Escalones 
    $base.fra18.men17.m add command \
        -command {set line "w impulses"
set llabel "impulsos"} \
        -label Implusos 
    $base.fra18.men17.m add command \
        -command {set line "w linespoints"
set llabel "Linea y puntos"} \
        -label {lineas y puntos} 
    $base.fra18.men17.m add command \
        -command {set line "w yerrorbars"
set llabel "Barras de error Y"} \
        -label {Barras de error "y"} 
    $base.fra18.men17.m add command \
        -command {set line "w xerrorbars"
set llabel "Barras de error X"} \
        -label {Barras de error "x"} 
    $base.fra18.men17.m add command \
        -command {set line "w fsteps"
set llabel "Escalonado Desfazado"} \
        -label {Escalonado desfazado} 
    $base.fra18.men17.m add command \
        -command {set line "w boxerrorbars"
set llabel "Cajas de error"} \
        -label {Cajas de error} 
    $base.fra18.men17.m add command \
        -command {set line "w histeps"
set llabel "Escalonado elevado"} \
        -label {Escalonado elevado} 
    $base.fra18.men17.m add command \
        -command {set line "w boxxyerrorbars"
set llabel "Cajas de error XY"} \
        -label {Cajas de error en "xy"} 
    $base.fra18.men17.m add command \
        -command {set line "w vector"
set llabel "vectores"} -label vectores 
    $base.fra18.men17.m add command \
        -command {set line "w financebars"
set llabel "Barras financieras"} \
        -label {Barras financieras} 
    $base.fra18.men17.m add command \
        -command {set line "w candlesticks"
set llabel "Barras separadas"} \
        -label {Barras separadas} 
    menubutton $base.fra18.men19 \
        -font {Helvetica -10 normal} -menu .top17.fra18.men19.m -padx 4 \
        -pady 3 -relief raised -text 2D -textvariable dime 
    menu $base.fra18.men19.m \
        -cursor {} -tearoff 0 
    $base.fra18.men19.m add command \
        \
        -command {set plot "plot"
set dime "2D"
set tipo "set nopolar; set noparametric"} \
        -label 2D 
    $base.fra18.men19.m add command \
        \
        -command {set plot "splot"
set dime "3D"
set tipo "set nopolar; set noparametric"} \
        -label 3D 
    $base.fra18.men19.m add command \
        -command {set tipo "set polar"
set dime "Polar"
set plot "plot"} \
        -label Polar 
    label $base.fra18.lab20 \
        -borderwidth 1 -font {Helvetica -10 normal} -relief raised \
        -text {Tipo de Linea} 
    label $base.fra18.lab22 \
        -borderwidth 1 -font {Helvetica -10 normal} -relief raised \
        -text {Tipo de gráfica} 
    checkbutton $base.fra18.che17 \
        -background #bed0be -command {set ejeX 1} \
        -font {Helvetica -10 normal} -indicatoron 0 -text {Mostrar Eje X} \
        -variable eX 
    checkbutton $base.fra18.che18 \
        -background #bed0be -command {set ejeY 1} \
        -font {Helvetica -10 normal} -indicatoron 0 -text {Mostrar Eje Y} \
        -variable eY 
    menubutton $base.fra18.men20 \
        -font {Helvetica -10 normal} -menu .top17.fra18.men20.m -padx 4 \
        -pady 3 -relief raised -text {Sin Etiqueta} -textvariable etiq 
    menu $base.fra18.men20.m \
        -cursor {} -tearoff 0 
    $base.fra18.men20.m add command \
        \
        -command {set label ""
set label "$label set nokey;"
set etiq "Sin Etiqueta"} \
        -label {sin Etiquetas} 
    $base.fra18.men20.m add command \
        -command {set label "set key;"
set etiq "Identificada"} \
        -label {Con identificadores} 
    $base.fra18.men20.m add command \
        -command {Window show $widget(ejesL)} -label {De los ejes} 
    menu $base.fra18.men20.m.men17 \
        -tearoff 0 
    menubutton $base.fra18.men24 \
        -font {Helvetica -10 normal} -menu .top17.fra18.men24.m -padx 4 \
        -pady 3 -relief raised -text Archivo 
    menu $base.fra18.men24.m \
        -cursor {} -tearoff 0 
    $base.fra18.men24.m add command \
        -command {Window show $widget(SAVE)} -label Salvar 
    $base.fra18.men24.m add command \
        -command {Window show $widget(importacion)} -label Importar 
    $base.fra18.men24.m add cascade \
        -label Imprimir -menu .top17.fra18.men24.m.men27 -state active 
    $base.fra18.men24.m add command \
        -command exit -label Salir 
    menu $base.fra18.men24.m.men25 \
        -tearoff 0 
    menu $base.fra18.men24.m.men26 \
        -tearoff 0 
    menu $base.fra18.men24.m.men27 \
        -tearoff 0 
    $base.fra18.men24.m.men27 add command \
        \
        -command {set fp [open "| gnuplot" r+]

fconfigure $fp -buffering line

puts $fp "set term postscript $orienta $color"
puts $fp "set output 'tmp.ps'"

puts $fp $MX
puts $fp $MY
puts $fp $MZ

puts $fp "set view $ROT_X, $ROT_Z"

puts $fp $tipo

puts $fp $label

puts $fp "set title \"$titulo\" "

puts $fp $xlabel
puts $fp $ylabel
puts $fp $zlabel
puts $fp $ejeX
puts $fp $ejeY

puts $fp $xrange
puts $fp $yrange
puts $fp $zrange

puts $fp $grid

puts $fp "set isosamples $TRAMA_X,$TRAMA_Y"

puts $fp $border

puts $fp "$plot $exp $line"

close $fp

exec lpr tmp.ps} \
        -label Imprimir 
    $base.fra18.men24.m.men27 add command \
        -label {Imprimir en impresora remota} 
    checkbutton $base.fra18.che33 \
        -background #bed0be \
        -command {if { $colorL == 1 } {
set color "color"
}

if { $colorL != 1 } {
set color ""
}} \
        -font {Helvetica -10 normal} -indicatoron 0 -text {En Color} \
        -variable colorL 
    menubutton $base.fra18.men34 \
        -font {Helvetica -10 normal} -menu .top17.fra18.men34.m -padx 4 \
        -pady 3 -relief raised -text eps -textvariable orienta 
    menu $base.fra18.men34.m \
        -cursor {} -tearoff 0 
    $base.fra18.men34.m add command \
        -command {set orienta "landscape"} -label Apaisado 
    $base.fra18.men34.m add command \
        -command {set orienta "portrait"} -label Vertical 
    $base.fra18.men34.m add command \
        -command {set orienta "eps"} -label Encapsulado 
    label $base.fra18.lab35 \
        -borderwidth 1 -font {Helvetica -10 normal} -relief raised \
        -text Orientación 
    label $base.fra18.lab36 \
        -borderwidth 1 -font {Helvetica -10 normal} -relief raised \
        -text etiquetas 
    button $base.fra18.but17 \
        \
        -command {set colorL 1
set color "color"
set plot "plot"
set dime "2D"
set label "set nokey"
set line "w lines"
set llabel "Lineas"
set titulo "Generado con UniGNUPlot"
set tipo "set nopolar; set noparametric"
set ejeZ ""
set xlabel ""
set ylabel ""
set zlabel ""
set TRAMA_X 10
set TRAMA_Y 10
set xrange "set xrange\[*:*\]"
set yrange "set yrange\[*:*\]"
set zrange "set zrange\[*:*\]"
set ROT_X 60
set ROT_Z 30
set viewx 60
set viewz 30} \
        -font {Helvetica -10 normal} -padx 9 -pady 3 -text Inicializar 
    label $base.fra18.lab17 \
        -borderwidth 1 -relief groove -text torvalds@linuxave.net 
    button $base.fra18.but18 \
        -command {Window show $widget(RANGES)} -font {Helvetica -10 normal} \
        -padx 9 -pady 3 -text Rangos 
    button $base.fra18.but29 \
        -command {Window show $widget(TRAMA)} -font {Helvetica -10 normal} \
        -padx 9 -pady 3 -text Trama 
    canvas $base.fra18.can17 \
        -background #f7fada -borderwidth 2 -height 207 -relief ridge \
        -width 296 
    scale $base.fra18.sca17 \
        -borderwidth 1 -command replot -orient vert -showvalue 0 -to 180.0 \
        -variable ROT_X 
    scale $base.fra18.sca18 \
        -borderwidth 1 -command {set viewx} -orient horiz -showvalue 0 \
        -to 180.0 -variable ROT_Z 
    frame $base.fra18.fra19 \
        -background #bed0be -borderwidth 2 -height 75 -relief groove \
        -width 125 
    label $base.fra18.fra19.lab20 \
        -borderwidth 1 -font {Helvetica -8 normal} -relief raised -text 30 \
        -textvariable ROT_Z 
    label $base.fra18.fra19.lab22 \
        -borderwidth 1 -font {Helvetica -8 normal} -relief raised -text 60 \
        -textvariable ROT_X 
    label $base.fra18.fra19.lab23 \
        -borderwidth 1 -font {Helvetica -8 normal} -relief raised -text Z= 
    label $base.fra18.fra19.lab24 \
        -borderwidth 1 -font {Helvetica -8 normal} -relief raised -text X= 
    label $base.fra18.lab25 \
        -background #bed0be -borderwidth 1 -font {Helvetica -10 normal} \
        -relief raised -text Rotación 
    frame $base.fra17 \
        -borderwidth 2 -height 75 -relief groove -width 125 
    checkbutton $base.fra17.che18 \
        -font {Helvetica -10 normal} -indicatoron 0 -text {Sin Borde} \
        -variable SIN_BORDE 
    checkbutton $base.fra17.che19 \
        -font {Helvetica -10 normal} -indicatoron 0 -text {Sin Marcas x} \
        -variable MARCAS_X 
    checkbutton $base.fra17.che20 \
        -font {Helvetica -10 normal} -indicatoron 0 -text {Sin Marcas y} \
        -variable MARCAS_Y 
    checkbutton $base.fra17.che17 \
        -font {Helvetica -10 normal} -indicatoron 0 -text {Sin Marcas z} \
        -variable MARCAS_Z 
    button $base.but17 \
        -command {Window show $widget(SOBRE)} -font {Helvetica -10 normal} \
        -padx 9 -pady 3 -text Sobre... 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.fra18 \
        -x 5 -y 5 -width 360 -height 495 -anchor nw -bordermode ignore 
    place $base.fra18.but19 \
        -x 175 -y 5 -width 56 -height 19 -anchor nw -bordermode ignore 
    place $base.fra18.cpd23 \
        -x 5 -y 120 -width 330 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra18.cpd23.01 \
        -in .top17.fra18.cpd23 -anchor center -expand 0 -fill none -padx 2 \
        -pady 2 -side left 
    pack $base.fra18.cpd23.02 \
        -in .top17.fra18.cpd23 -anchor center -expand 1 -fill x -padx 2 \
        -pady 2 -side right 
    place $base.fra18.che27 \
        -x 265 -y 40 -width 48 -height 18 -anchor nw -bordermode ignore 
    place $base.fra18.men17 \
        -x 5 -y 40 -width 123 -height 17 -anchor nw -bordermode ignore 
    place $base.fra18.men19 \
        -x 245 -y 20 -width 68 -height 17 -anchor nw -bordermode ignore 
    place $base.fra18.lab20 \
        -x 5 -y 25 -width 66 -height 13 -anchor nw -bordermode ignore 
    place $base.fra18.lab22 \
        -x 245 -y 5 -width 93 -height 13 -anchor nw -bordermode ignore 
    place $base.fra18.che17 \
        -x 265 -y 60 -anchor nw -bordermode ignore 
    place $base.fra18.che18 \
        -x 265 -y 80 -anchor nw -bordermode ignore 
    place $base.fra18.men20 \
        -x 5 -y 100 -width 85 -height 17 -anchor nw -bordermode ignore 
    place $base.fra18.men24 \
        -x 5 -y 60 -width 95 -height 17 -anchor nw -bordermode ignore 
    place $base.fra18.che33 \
        -x 265 -y 100 -width 67 -height 18 -anchor nw -bordermode ignore 
    place $base.fra18.men34 \
        -x 175 -y 85 -width 80 -height 17 -anchor nw -bordermode ignore 
    place $base.fra18.lab35 \
        -x 175 -y 65 -width 57 -height 16 -anchor nw -bordermode ignore 
    place $base.fra18.lab36 \
        -x 5 -y 80 -width 60 -height 16 -anchor nw -bordermode ignore 
    place $base.fra18.but17 \
        -x 5 -y 5 -width 78 -height 17 -anchor nw -bordermode ignore 
    place $base.fra18.lab17 \
        -x 10 -y 470 -width 146 -height 18 -anchor nw -bordermode ignore 
    place $base.fra18.but18 \
        -x 175 -y 25 -width 56 -height 19 -anchor nw -bordermode ignore 
    place $base.fra18.but29 \
        -x 175 -y 45 -width 54 -height 17 -anchor nw -bordermode ignore 
    place $base.fra18.can17 \
        -x 5 -y 150 -width 325 -height 276 -anchor nw -bordermode ignore 
    place $base.fra18.sca17 \
        -x 330 -y 150 -width 18 -height 272 -anchor nw -bordermode ignore 
    place $base.fra18.sca18 \
        -x 5 -y 425 -width 322 -height 18 -anchor nw -bordermode ignore 
    place $base.fra18.fra19 \
        -x 250 -y 465 -width 105 -height 25 -anchor nw -bordermode ignore 
    place $base.fra18.fra19.lab20 \
        -x 80 -y 5 -anchor nw -bordermode ignore 
    place $base.fra18.fra19.lab22 \
        -x 25 -y 5 -anchor nw -bordermode ignore 
    place $base.fra18.fra19.lab23 \
        -x 10 -y 5 -anchor nw -bordermode ignore 
    place $base.fra18.fra19.lab24 \
        -x 65 -y 5 -anchor nw -bordermode ignore 
    place $base.fra18.lab25 \
        -x 275 -y 445 -width 55 -height 21 -anchor nw -bordermode ignore 
    place $base.fra17 \
        -x 365 -y 5 -width 80 -height 85 -anchor nw -bordermode ignore 
    place $base.fra17.che18 \
        -x 5 -y 5 -anchor nw -bordermode ignore 
    place $base.fra17.che19 \
        -x 5 -y 25 -width 64 -height 16 -anchor nw -bordermode ignore 
    place $base.fra17.che20 \
        -x 5 -y 45 -width 68 -height 16 -anchor nw -bordermode ignore 
    place $base.fra17.che17 \
        -x 5 -y 65 -width 68 -height 16 -anchor nw -bordermode ignore 
    place $base.but17 \
        -x 380 -y 485 -width 51 -height 14 -anchor nw -bordermode ignore 
}

proc vTclWindow.top18 {base} {
    if {$base == ""} {
        set base .top18
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel
    wm focusmodel $base passive
    wm geometry $base 380x156+48+300
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm title $base "Etiquetas"
    frame $base.cpd19  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.cpd19.01  -anchor w -relief groove -text {Eje X} 
    entry $base.cpd19.02  -cursor {} -textvariable labelX 
    frame $base.fra20  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra20.01  -anchor w -relief groove -text {Eje Y} 
    entry $base.fra20.02  -cursor {} -textvariable labelY 
    frame $base.fra21  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra21.01  -anchor w -relief groove -text {Eje Z} 
    entry $base.fra21.02  -cursor {} -textvariable labelZ 
    button $base.but22   -command {set xlabel "set xlabel \"$labelX\""
set ylabel "set ylabel \"$labelY\""
set zlabel "set zlabel \"$labelZ\""
set titulo $titulo}  -padx 9 -pady 3 -text {Poner Etiquetas} 
    frame $base.fra23  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra23.01  -anchor w -relief groove -text Título 
    entry $base.fra23.02  -cursor {} -textvariable titulo 
    button $base.but24  -command {Window hide $widget(ejesL)} -padx 9 -pady 3 -text Cerrar 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.cpd19  -x 10 -y 10 -width 370 -height 25 -anchor nw -bordermode ignore 
    pack $base.cpd19.01  -in .top18.cpd19 -anchor center -expand 0 -fill none -padx 2 -pady 2  -side left 
    pack $base.cpd19.02  -in .top18.cpd19 -anchor center -expand 1 -fill x -padx 2 -pady 2  -side right 
    place $base.fra20  -x 10 -y 35 -width 370 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra20.01  -in .top18.fra20 -anchor center -expand 0 -fill none -padx 2 -pady 2  -side left 
    pack $base.fra20.02  -in .top18.fra20 -anchor center -expand 1 -fill x -padx 2 -pady 2  -side right 
    place $base.fra21  -x 10 -y 60 -width 370 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra21.01  -in .top18.fra21 -anchor center -expand 0 -fill none -padx 2 -pady 2  -side left 
    pack $base.fra21.02  -in .top18.fra21 -anchor center -expand 1 -fill x -padx 2 -pady 2  -side right 
    place $base.but22  -x 15 -y 120 -width 121 -height 24 -anchor nw -bordermode ignore 
    place $base.fra23  -x 10 -y 85 -width 370 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra23.01  -in .top18.fra23 -anchor center -expand 0 -fill none -padx 2 -pady 2  -side left 
    pack $base.fra23.02  -in .top18.fra23 -anchor center -expand 1 -fill x -padx 2 -pady 2  -side right 
    place $base.but24  -x 300 -y 120 -width 71 -height 24 -anchor nw -bordermode ignore
}

proc vTclWindow.top19 {base} {
    if {$base == ""} {
        set base .top19
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel  -menu .top19.m30 
    wm focusmodel $base passive
    wm geometry $base 206x161+200+308
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm title $base "Rangos"
    frame $base.fra20  -borderwidth 2 -height 75 -relief groove -width 125 
    frame $base.fra20.cpd21  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra20.cpd21.01  -anchor w -relief groove -text X 
    entry $base.fra20.cpd21.02  -cursor {} -textvariable XI 
    frame $base.fra20.fra22  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra20.fra22.01  -anchor w -relief groove -text X 
    entry $base.fra20.fra22.02  -cursor {} -textvariable XF 
    label $base.fra20.lab23  -borderwidth 1 -relief raised -text Desde: 
    label $base.fra20.lab24  -borderwidth 1 -relief raised -text Hasta: 
    frame $base.fra20.fra25  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra20.fra25.01  -anchor w -relief groove -text Y 
    entry $base.fra20.fra25.02  -cursor {} -textvariable YI 
    frame $base.fra20.fra26  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra20.fra26.01  -anchor w -relief groove -text Y 
    entry $base.fra20.fra26.02  -cursor {} -textvariable YF 
    frame $base.fra20.fra27  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra20.fra27.01  -anchor w -relief groove -text Z 
    entry $base.fra20.fra27.02  -cursor {} -textvariable ZI 
    frame $base.fra20.fra28  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra20.fra28.01  -anchor w -relief groove -text Z 
    entry $base.fra20.fra28.02  -cursor {} -textvariable ZF 
    button $base.fra20.but29   -command {set xrange "set xrange\[$XI:$XF\]"
set yrange "set yrange\[$YI:$YF\]"
set zrange "set zrange\[$ZI:$ZF\]"}  -indicatoron 1 -padx 9 -pady 3 -text Listo! 
    button $base.fra20.but38  -command {Window hide $widget(RANGES)} -padx 9 -pady 3 -text Cerrar 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.fra20  -x 5 -y 5 -width 200 -height 150 -anchor nw -bordermode ignore 
    place $base.fra20.cpd21  -x 10 -y 25 -width 70 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra20.cpd21.01  -in .top19.fra20.cpd21 -anchor center -expand 0 -fill none -padx 2  -pady 2 -side left 
    pack $base.fra20.cpd21.02  -in .top19.fra20.cpd21 -anchor center -expand 1 -fill x -padx 2  -pady 2 -side right 
    place $base.fra20.fra22  -x 100 -y 25 -width 70 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra20.fra22.01  -in .top19.fra20.fra22 -anchor center -expand 0 -fill none -padx 2  -pady 2 -side left 
    pack $base.fra20.fra22.02  -in .top19.fra20.fra22 -anchor center -expand 1 -fill x -padx 2  -pady 2 -side right 
    place $base.fra20.lab23  -x 10 -y 5 -anchor nw -bordermode ignore 
    place $base.fra20.lab24  -x 100 -y 5 -anchor nw -bordermode ignore 
    place $base.fra20.fra25  -x 10 -y 50 -width 70 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra20.fra25.01  -in .top19.fra20.fra25 -anchor center -expand 0 -fill none -padx 2  -pady 2 -side left 
    pack $base.fra20.fra25.02  -in .top19.fra20.fra25 -anchor center -expand 1 -fill x -padx 2  -pady 2 -side right 
    place $base.fra20.fra26  -x 100 -y 50 -width 70 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra20.fra26.01  -in .top19.fra20.fra26 -anchor center -expand 0 -fill none -padx 2  -pady 2 -side left 
    pack $base.fra20.fra26.02  -in .top19.fra20.fra26 -anchor center -expand 1 -fill x -padx 2  -pady 2 -side right 
    place $base.fra20.fra27  -x 10 -y 75 -width 70 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra20.fra27.01  -in .top19.fra20.fra27 -anchor center -expand 0 -fill none -padx 2  -pady 2 -side left 
    pack $base.fra20.fra27.02  -in .top19.fra20.fra27 -anchor center -expand 1 -fill x -padx 2  -pady 2 -side right 
    place $base.fra20.fra28  -x 100 -y 75 -width 70 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra20.fra28.01  -in .top19.fra20.fra28 -anchor center -expand 0 -fill none -padx 2  -pady 2 -side left 
    pack $base.fra20.fra28.02  -in .top19.fra20.fra28 -anchor center -expand 1 -fill x -padx 2  -pady 2 -side right 
    place $base.fra20.but29  -x 10 -y 105 -anchor nw -bordermode ignore 
    place $base.fra20.but38  -x 105 -y 105 -anchor nw -bordermode ignore
}

proc vTclWindow.top20 {base} {
    if {$base == ""} {
        set base .top20
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel  -menu .top20.m21 
    wm focusmodel $base passive
    wm geometry $base 480x78+170+564
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm title $base "Importación"
    frame $base.cpd22  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.cpd22.01  -anchor w -relief groove -text {Nombre del Archivo} 
    entry $base.cpd22.02  -cursor {} -textvariable ifile 
    button $base.but23  -command {set exp "\"$ifile\""
Window hide $widget(importacion)}  -padx 9 -pady 3 -text Listo 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.cpd22  -x 10 -y 10 -width 460 -height 25 -anchor nw -bordermode ignore 
    pack $base.cpd22.01  -in .top20.cpd22 -anchor center -expand 0 -fill none -padx 2 -pady 2  -side left 
    pack $base.cpd22.02  -in .top20.cpd22 -anchor center -expand 1 -fill x -padx 2 -pady 2  -side right 
    place $base.but23  -x 10 -y 40 -width 66 -height 24 -anchor nw -bordermode ignore
}

proc vTclWindow.top21 {base} {
    if {$base == ""} {
        set base .top21
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel
    wm focusmodel $base passive
    wm geometry $base 207x156+540+540
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm title $base "Sobre..."
    message $base.mes22  -aspect 180 -justify center -padx 5 -pady 2 -relief raised  -text {UniGNUPlot, Front-End para GNUPlot desarrollado por Cederik L. De León A. junio 2000. torvalds@linuxave.net http://unicalculus.sourceforge.net Versión 1.0.1 BETA  Bajo licencia pública GNU. Para el proyecto UniCalculus} 
    button $base.but23  -command {Window hide $widget(SOBRE)} -padx 9 -pady 3 -text Cerrar 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.mes22  -x 5 -y 5 -width 194 -height 116 -anchor nw -bordermode ignore 
    place $base.but23  -x 70 -y 125 -anchor nw -bordermode ignore
}

proc vTclWindow.top28 {base} {
    if {$base == ""} {
        set base .top28
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel
    wm focusmodel $base passive
    wm geometry $base 398x100+67+306
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm title $base "Guardar..."
    frame $base.fra29  -borderwidth 2 -height 75 -relief groove -width 125 
    frame $base.fra29.cpd30  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra29.cpd30.01  -anchor w -relief groove -text {Nombre del Archivo} 
    entry $base.fra29.cpd30.02  -cursor {} -textvariable filename 
    menubutton $base.fra29.men31  -menu .top28.fra29.men31.m -padx 4 -pady 3 -relief raised  -text Formatos 
    menu $base.fra29.men31.m  -cursor {} -tearoff 0 
    $base.fra29.men31.m add command  -command {set format "postscript"
set filename "$filename.$format"}  -label postscript 
    $base.fra29.men31.m add command  -command {set format "dumb"
set filename "$filename.$format"}  -label Texto 
    $base.fra29.men31.m add command  -command {set format "xfig"
set filename "$filename.$format"}  -label xfig 
    $base.fra29.men31.m add command  -command {set format "dxf"
set filename "$filename.$format"}  -label {AutoCAD (dxf)} 
    $base.fra29.men31.m add command  -command {set format "eps"
set filename "$filename.$format"}  -label {Postscript Encapsulado (eps)} 
    button $base.fra29.but32   -command {Window hide $widget(SAVE)

if { $format == "dumb" } {
 set color ""
 set orient ""

}
set fp [open "| gnuplot" r+]

fconfigure $fp -buffering line

puts $fp "set term $format $orienta $color"
puts $fp "set output '$filename'"

puts $fp $tipo
puts $fp $border

puts $fp $label

puts $fp "set title \"$titulo\" "

puts $fp "set view $ROT_X, $ROT_Z"

puts $fp $MX
puts $fp $MY
puts $fp $MZ

puts $fp $xlabel
puts $fp $ylabel
puts $fp $zlabel

puts $fp $ejeX
puts $fp $ejeY

puts $fp $xrange
puts $fp $yrange
puts $fp $zrange

puts $fp "set isosamples $TRAMA_X,$TRAMA_Y"

puts $fp $grid

puts $fp "$plot $exp $line"
close $fp}  -padx 9 -pady 3 -text guardar 
    button $base.fra29.but17  -command {Window hide $widget(SAVE)} -font {Helvetica -10 normal}  -padx 9 -pady 3 -text Cancelar 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.fra29  -x 5 -y 5 -width 390 -height 85 -anchor nw -bordermode ignore 
    place $base.fra29.cpd30  -x 10 -y 10 -width 370 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra29.cpd30.01  -in .top28.fra29.cpd30 -anchor center -expand 0 -fill none -padx 2  -pady 2 -side left 
    pack $base.fra29.cpd30.02  -in .top28.fra29.cpd30 -anchor center -expand 1 -fill x -padx 2  -pady 2 -side right 
    place $base.fra29.men31  -x 10 -y 45 -anchor nw -bordermode ignore 
    place $base.fra29.but32  -x 315 -y 40 -anchor nw -bordermode ignore 
    place $base.fra29.but17  -x 170 -y 50 -width 62 -height 17 -anchor nw -bordermode ignore
}

proc vTclWindow.top30 {base} {
    if {$base == ""} {
        set base .top30
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel
    wm focusmodel $base passive
    wm geometry $base 345x109+75+272
    wm maxsize $base 1265 994
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm title $base "trama de la gráfica"
    frame $base.fra31  -background #bed0be -borderwidth 2 -height 75 -relief groove  -width 125 
    scale $base.fra31.sca32  -borderwidth 1 -from 2.0 -orient horiz -showvalue 0 -variable TRAMA_X 
    frame $base.fra31.cpd33  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra31.cpd33.01  -anchor w -relief groove -text {Trama X} 
    entry $base.fra31.cpd33.02  -cursor {} -textvariable TRAMA_X 
    frame $base.fra31.fra34  -borderwidth 1 -height 30 -relief raised -width 30 
    label $base.fra31.fra34.01  -anchor w -relief groove -text {Trama Y} 
    entry $base.fra31.fra34.02  -cursor {} -textvariable TRAMA_Y 
    scale $base.fra31.sca35  -borderwidth 1 -from 2.0 -orient horiz -showvalue 0 -variable TRAMA_Y 
    button $base.fra31.but36  -command {Window hide $widget(TRAMA)} -padx 9 -pady 3 -text Cerrar 
    button $base.fra31.but37  -command {set TRAMA_X 10
set TRAMA_Y 10} -padx 9 -pady 3  -text {Valores Por defecto} 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.fra31  -x 5 -y 5 -width 340 -height 100 -anchor nw -bordermode ignore 
    place $base.fra31.sca32  -x 105 -y 15 -width 222 -height 18 -anchor nw -bordermode ignore 
    place $base.fra31.cpd33  -x 10 -y 10 -width 90 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra31.cpd33.01  -in .top30.fra31.cpd33 -anchor center -expand 0 -fill none -padx 2  -pady 2 -side left 
    pack $base.fra31.cpd33.02  -in .top30.fra31.cpd33 -anchor center -expand 1 -fill x -padx 2  -pady 2 -side right 
    place $base.fra31.fra34  -x 10 -y 35 -width 90 -height 25 -anchor nw -bordermode ignore 
    pack $base.fra31.fra34.01  -in .top30.fra31.fra34 -anchor center -expand 0 -fill none -padx 2  -pady 2 -side left 
    pack $base.fra31.fra34.02  -in .top30.fra31.fra34 -anchor center -expand 1 -fill x -padx 2  -pady 2 -side right 
    place $base.fra31.sca35  -x 105 -y 40 -width 222 -height 18 -anchor nw -bordermode ignore 
    place $base.fra31.but36  -x 10 -y 65 -anchor nw -bordermode ignore 
    place $base.fra31.but37  -x 190 -y 65 -anchor nw -bordermode ignore
}

Window show .
Window show .top17

main $argc $argv
