TABLE OF CONTENTS


::pwtk::gp::get_term

SYNOPSIS

proc ::pwtk::gp::get_term {args} {

USAGE

    get_term ?OPTIONS? head.type

 i.e.:

    get_term  ?-o ORIENT?  ?-s SIZE?  ?-fs FONTSIZE?  ?-t TITLE?  ?-spin?  ?-p?  head.type

 where "head" is the rootname of the files (Gnuplot script & output
 file(s)) and "type" is the terminal type and file extension if plot
 is printed to a file (e.g., eps, pdf, svg, png).

REMARK

This routine is used internally by PWTK. A user should use instead the ::pwtk::gp::plot object-oriented interface.

OPTIONS

Options typically do not need to be set (defaults should be OK).

RETURN VALUE

A string containing Gnuplot instructions for setting the appropriate terminal.

SOURCE

    variable gp

    #
    # parse args ...
    #
    
    set narg 1
    set usage "?-p?  ?-o ORIENT?  ?-s SIZE?  ?-fs FONTSIZE?  ?-t TITLE?  ?-spin?  head.type"
    parseOpt_term_

    set head [head_ $args]
    set term [term_ $args]

    # -spin
    # (nothing so far for single-plot)
    
    # -p
    if { $opt(p) } {
        set page 1
    } else {
        set page {}
    }

    # -o ORIENT
    set orient [orient $term $opt(s) $opt(o)]
    
    # -s SIZE
    if { $opt(s) == {} } {
        # TODO: handle -spin option here once gp() is configured for spin-single-plot
        switch -- $term {
            eps { set size $gp(eps.$orient.size) }
            pdf { set size [osize $orient $gp(pdf.size)] }
            png { set size [osize $orient $gp(png.size)] }
            default { set size [osize $orient $gp(size)] }
        }
    } else {
        set size $opt(s)
    }

    # -fs FONTSIZE
    if { $opt(fs) == {} } {
        switch -- $term {
            svg { set fsize $gp(svg.fontSize) }
            png { set fsize $gp(png.fontSize) }
            default { set fsize $gp(fontSize) }
        }
    } else {
        set fsize $opt(fs)
    }

    # -t TITLE
    if { $opt(t) != {} } {
        set title "title [::pwtk::squote $opt(t)]"
    } else {
        set title {}
    }

    set prolog "# Gnuplot script generated by PWTK-$::pwtk::version on [clock format [clock seconds]]

set encoding utf8"

    #
    # set terminal part of the Gnuplot script
    #
    
    switch -- $term {
        eps {
#            return "$prolog
#set minussign
#set term postscript $orient enhanced color font '$gp(font),$fsize' lw $gp(lw)
#set output '$head.eps'
#set size $size\n"
            return "$prolog
set minussign
set term postscript $orient enhanced color font '$gp(font),$fsize' lw $gp(lw) size $size fontscale $gp(eps.fontscale) pointscale $gp(eps.pointscale)
set output '$head.eps'\n"
        }
        
        pdf {
#            return "$prolog
#set minussign
#set term pdfcairo enhanced color font '$gp(font),$fsize' lw $gp(lw) size $size; # size is in inches
#set output '$head.pdf'\n"
            return "$prolog
set minussign
set term pdfcairo enhanced color font '$gp(font),$fsize' lw $gp(lw) size $size fontscale $gp(pdf.fontscale) pointscale $gp(pdf.pointscale)
set output '$head.pdf'\n"
        }
        
        svg {
            return "$prolog
set minussign
set term svg size $size font '$gp(font),$fsize' enhanced lw $gp(lw); #background '#ffffff'
set output '[output svg $head $page]'\n"
        }
        
        png {
            return "$prolog
set minussign
set term pngcairo enhanced color font '$gp(font),$fsize' lw $gp(lw) size $size; #background '#ffffff'
set output '[output png $head $page]'\n"
        }
        
        qt {
            # persist deleted
            return "$prolog
set minussign
set term qt size $size font '$gp(font),$fsize' enhanced  lw $gp(lw) $title\n"
        }
        
        wxt {
            # persist deleted
            return "$prolog
set minussign
set term wxt size $size font '$gp(font),$fsize' enhanced  lw $gp(lw) $title\n"
        }
        
        x11 {
            # persist deleted
            return "$prolog
set term x11 size $size font '$gp(font),$fsize' enhanced  lw $gp(lw) background '#ffffff' $title\n"
        }

        win {
            # use a Gnuplot's default terminal
            return "$prolog\n"
        }

        dumb {
            return "$prolog
set terminal dumb enhanced"
        }
        
        default {
            ::pwtk::error "PWTK does not support the Gnuplot terminal \"$term\", must be one of [join $gp(terminals) {, }]" 1
        }
    }
}