Changeset 2653 for trunk


Ignore:
Timestamp:
Nov 3, 2011, 12:50:14 PM (13 years ago)
Author:
gah
Message:
 
Location:
trunk/gui/scripts
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/field.tcl

    r2616 r2653  
    503503itcl::body Rappture::Field::hints {{keyword ""}} {
    504504    foreach {key path} {
    505         group   about.group
    506         label   about.label
    507         color   about.color
    508         style   about.style
    509         scale   about.scale
    510         seeds   about.seeds
    511         scalars about.scalars
    512         vectors about.vectors
    513         default about.default
    514         units   units
    515         updir   updir
    516         camera  camera.position
    517         type    about.type
     505        camera          camera.position
     506        color           about.color
     507        default         about.default
     508        group           about.group
     509        label           about.label
     510        scalars         about.scalars
     511        scale           about.scale
     512        seeds           about.seeds
     513        style           about.style
     514        toolId          tool.id
     515        toolName        tool.name
     516        toolRevision    tool.version.application.revision
     517        type            about.type
     518        units           units
     519        updir           updir
     520        vectors         about.vectors
    518521    } {
    519522        set str [$_field get $path]
  • trunk/gui/scripts/vtkstreamlinesviewer.tcl

    r2652 r2653  
    10471047        }
    10481048
     1049        if 0 {
     1050            # Tell the server the name of the tool, the version, and dataset
     1051            # that we are rendering.  Have to do it here because we don't know
     1052            # what data objects are using the renderer until be get here.
     1053            set args ""
     1054            lappend args tool [$_first hints toolId]
     1055            lappend args version [$_first hints toolRevision]
     1056            lappend args dataset [$_first hints label]
     1057            SendCmd "clientinfo $args"
     1058        }
     1059
    10491060        foreach axis { x y z } {
    10501061            set label [$_first hints ${axis}label]
  • trunk/gui/scripts/xyprint.tcl

    r2006 r2653  
    7474    private method GetAxisType { axis }
    7575    private method restore { toolName plotName data }
     76
     77    # Same dialog may be used for different graphs
    7678    private common _settings
    77     private common _fonts
    7879    private common _wait
    7980}
     
    99100        ignore -highlightthickness -borderwidth -background
    100101    }
     102    set inner [frame $itk_interior.frame -bg grey]
    101103    itk_component add preview {
    102         label $itk_interior.preview \
     104        label $inner.preview \
    103105            -highlightthickness 0 -bd 0 -image $_preview -width 2.5i \
    104                 -height 2.25i -background grey -padx 10 -pady 10
     106                -height 2.5i -background grey
    105107    } {
    106108        ignore -background
     
    121123    }
    122124    blt::table $itk_interior \
    123         0,0 $itk_component(preview) -cspan 2 -fill both \
    124         1,0 $itk_component(tabs) -fill both -cspan 2 \
    125         2,1 $itk_component(cancel) -padx 2 -pady 2 -width .9i -fill y \
    126         2,0 $itk_component(ok) -padx 2 -pady 2 -width .9i -fill y
    127     blt::table configure $itk_interior r1 -resize none
    128     blt::table configure $itk_interior r1 -resize both
    129 
     125        0,0 $inner -fill both \
     126        0,1 $itk_component(tabs) -fill both -cspan 2 \
     127        1,2 $itk_component(cancel) -padx 2 -pady 2 -width .9i -fill y \
     128        1,1 $itk_component(ok) -padx 2 -pady 2 -width .9i -fill y
     129    blt::table $inner \
     130        0,0 $itk_component(preview) -fill both -padx 10 -pady 10
     131
     132    #blt::table configure $itk_interior c1 c2 -resize none
     133    blt::table configure $itk_interior c0 -resize both
    130134    BuildGeneralTab
    131135    BuildAxisTab
     
    148152    set _clone ""
    149153    set _graph ""
    150     foreach font [array names _fonts] {
    151         font delete $font
    152     }
    153     array unset _fonts
    154154}
    155155
     
    358358    set _settings($this-layout-width) [Pixels2Inches [$_clone cget -width]]
    359359    set _settings($this-layout-height) [Pixels2Inches [$_clone cget -height]]
    360     set _fonts(legend) [font create legend \
    361                             -family helvetica -size 10 -weight normal]
    362     update
     360
     361    set _settings($this-legend-fontfamily) helvetica
     362    set _settings($this-legend-fontsize)   10
     363    set _settings($this-legend-fontweight) normal
     364    set _settings($this-legend-fontslant)  roman
     365    set font "helvetica 10 normal roman"
    363366    $_clone legend configure \
    364367        -position right \
    365         -font $_fonts(legend) \
     368        -font $font \
    366369        -hide yes -borderwidth 0 -background white -relief solid \
    367370        -anchor nw -activeborderwidth 0
    368371    #
     372    set _settings($this-axis-ticks-fontfamily) helvetica
     373    set _settings($this-axis-ticks-fontsize)   10
     374    set _settings($this-axis-ticks-fontweight) normal
     375    set _settings($this-axis-ticks-fontslant)  roman
     376    set _settings($this-axis-title-fontfamily) helvetica
     377    set _settings($this-axis-title-fontsize)   10
     378    set _settings($this-axis-title-fontweight) normal
     379    set _settings($this-axis-title-fontslant)  roman
    369380    foreach axis [$_clone axis names] {
    370381        if { [$_clone axis cget $axis -hide] } {
    371382            continue
    372383        }
    373         set _fonts($axis-ticks) [font create $axis-ticks \
    374                                      -family helvetica -size 10 \
    375                                      -weight normal -slant roman]
    376         set _fonts($axis-title) [font create $axis-title \
    377                                      -family helvetica -size 10 \
    378                                      -weight normal -slant roman]
    379         update
     384        set _settings($this-$axis-ticks-fontfamily) helvetica
     385        set _settings($this-$axis-ticks-fontsize)   10
     386        set _settings($this-$axis-ticks-fontweight) normal
     387        set _settings($this-$axis-ticks-fontslant)  roman
     388        set _settings($this-$axis-title-fontfamily) helvetica
     389        set _settings($this-$axis-title-fontsize)   10
     390        set _settings($this-$axis-title-fontweight) normal
     391        set _settings($this-$axis-title-fontslant)  roman
     392        set tickfont "helvetica 10 normal roman"
     393        set titlefont "helvetica 10 normal roman"
    380394        $_clone axis configure $axis -ticklength 5  \
    381395            -majorticks {} -minorticks {}
    382396        $_clone axis configure $axis \
    383             -tickfont $_fonts($axis-ticks) \
    384             -titlefont $_fonts($axis-title)
     397            -tickfont $tickfont \
     398            -titlefont $titlefont
    385399    }
    386400    foreach elem [$_clone element names] {
     
    395409
    396410itcl::body Rappture::XyPrint::SetOption { opt } {
    397     set new $_settings($this-graph$opt)
     411    set new $_settings($this$opt)
    398412    set old [$_clone cget $opt]
    399413    set code [catch [list $_clone configure $opt $new] err]
     
    402416        global errorInfo
    403417        puts stderr "$err: $errorInfo"
    404         set _settings($this-graph$opt) $old
     418        set _settings($this$opt) $old
    405419        $_clone configure $opt $old
    406420    }
     
    438452    set w [Inches2Pixels $_settings($this-layout-width) 3.4]
    439453    set h [Inches2Pixels $_settings($this-layout-height) 3.4]
     454    $_clone snap $img -width $w -height $h
     455
    440456    set pixelsPerInch [winfo pixels . 1i]
    441     set sx [expr 2.5*$pixelsPerInch/$w]
    442     set sy [expr 2.0*$pixelsPerInch/$h]
     457    set cw [winfo width $itk_component(preview)]
     458    set ch [winfo height $itk_component(preview)]
     459    set rw [expr 2.5*$pixelsPerInch]
     460    set rh [expr 2.5*$pixelsPerInch]
     461    set maxwidth $rw
     462    set maxheight $rh
     463    if { $maxwidth > $cw } {
     464        set maxwidth $cw
     465    }
     466    if { $maxheight > $ch } {
     467        set maxheight $ch
     468    }
     469    set sx [expr double($maxwidth)/$w]
     470    set sy [expr double($maxheight)/$h]
    443471    set s [expr min($sx,$sy)]
    444     $_clone snap $img -width $w -height $h
    445 
    446     if 0 {
    447         if { ![winfo exists .labeltest] } {
    448             toplevel .labeltest -bg red
    449             label .labeltest.label -image $img
    450             pack .labeltest.label -fill both
    451         }
    452     }
     472
    453473    set pw [expr int(round($s * $w))]
    454474    set ph [expr int(round($s * $h))]
    455     $_preview configure -width $pw -height $ph
    456     if 0 {
    457         .labeltest.label configure -image $img
    458     }
     475    $_preview configure -width $pw -height $ph
    459476    blt::winop resample $img $_preview box
    460477    image delete $img
     
    501518    foreach option { -min -max -loose -title -stepsize -subdivisions } {
    502519        set _settings($this-axis$option) [$_clone axis cget $axis $option]
     520    }
     521    foreach attr { fontfamily fontsize fontweight fontslant } {
     522        set specific $this-$axis-ticks
     523        set general $this-axis-ticks
     524        set _settings(${general}-${attr}) $_settings(${specific}-${attr})
     525        set specific $this-$axis-title
     526        set general $this-axis-title
     527        set _settings(${general}-${attr}) $_settings(${specific}-${attr})
    503528    }
    504529    set type [GetAxisType $axis]
     
    676701    set _settings($this-legend-anchor)    [$page.anchor current]
    677702    if { $_clone != "" } {
    678         font configure $_fonts(legend) \
    679             -family $_settings($this-legend-font-family) \
    680             -size $_settings($this-legend-font-size) \
    681             -weight $_settings($this-legend-font-weight) \
    682             -slant $_settings($this-legend-font-slant)
     703        lappend font $_settings($this-legend-fontfamily)
     704        lappend font $_settings($this-legend-fontsize)
     705        lappend font $_settings($this-legend-fontweight)
     706        lappend font $_settings($this-legend-fontslant)
    683707        foreach option { -hide -position -anchor -borderwidth } {
    684708            SetComponentOption legend $option
    685709        }
    686         $_clone legend configure -font fixed -font $_fonts(legend)
     710        $_clone legend configure -font fixed -font $font
    687711    }
    688712    ApplyElementSettings
     
    836860
    837861    Rappture::PushButton $page.fontweight \
    838         -width 18 -height 18 \
    839862        -onimage [Rappture::icon font-bold] \
    840863        -offimage [Rappture::icon font-bold] \
    841864        -onvalue "bold" -offvalue "normal" \
    842865        -command [itcl::code $this ApplyLegendSettings] \
    843         -variable [itcl::scope _settings($this-legend-font-weight)]
     866        -variable [itcl::scope _settings($this-legend-fontweight)]
    844867    Rappture::Tooltip::for $page.fontweight \
    845868        "Use the bold version of the font."
    846869
    847870    Rappture::PushButton $page.fontslant \
    848         -width 18 -height 18 \
    849871        -onimage [Rappture::icon font-italic] \
    850872        -offimage [Rappture::icon font-italic] \
    851873        -onvalue "italic" -offvalue "roman" \
    852874        -command [itcl::code $this ApplyLegendSettings] \
    853         -variable [itcl::scope _settings($this-legend-font-slant)]
     875        -variable [itcl::scope _settings($this-legend-fontslant)]
    854876    Rappture::Tooltip::for $page.fontslant \
    855877        "Use the italic version of the font."
     
    878900
    879901    blt::table configure $page r* -resize none -pady { 0 2 }
     902    blt::table configure $page c3 c4 -resize none
    880903    blt::table configure $page r8 -resize both
    881904
     
    9891012
    9901013    Rappture::PushButton $page.tickfontweight \
    991         -width 18 -height 18 \
    9921014        -onimage [Rappture::icon font-bold] \
    9931015        -offimage [Rappture::icon font-bold] \
    9941016        -onvalue "bold" -offvalue "normal" \
    9951017        -command [itcl::code $this ApplyAxisSettings] \
    996         -variable [itcl::scope _settings($this-axis-tickfont-weight)]
     1018        -variable [itcl::scope _settings($this-axis-ticks-fontweight)]
    9971019    Rappture::Tooltip::for $page.tickfontweight \
    9981020        "Use the bold version of the tick font."
    9991021
    10001022    Rappture::PushButton $page.tickfontslant \
    1001         -width 18 -height 18 \
    10021023        -onimage [Rappture::icon font-italic] \
    10031024        -offimage [Rappture::icon font-italic] \
    10041025        -onvalue "italic" -offvalue "roman" \
    10051026        -command [itcl::code $this ApplyAxisSettings] \
    1006         -variable [itcl::scope _settings($this-axis-tickfont-slant)]
     1027        -variable [itcl::scope _settings($this-axis-ticks-fontslant)]
    10071028    Rappture::Tooltip::for $page.tickfontslant \
    10081029        "Use the italic version of the tick font."
     
    10361057
    10371058    Rappture::PushButton $page.titlefontweight \
    1038         -width 18 -height 18 \
    10391059        -onimage [Rappture::icon font-bold] \
    10401060        -offimage [Rappture::icon font-bold] \
    10411061        -onvalue "bold" -offvalue "normal" \
    10421062        -command [itcl::code $this ApplyAxisSettings] \
    1043         -variable [itcl::scope _settings($this-axis-titlefont-weight)]
     1063        -variable [itcl::scope _settings($this-axis-title-fontweight)]
    10441064    Rappture::Tooltip::for $page.titlefontweight \
    10451065        "Use the bold version of the title font."
    10461066
    10471067    Rappture::PushButton $page.titlefontslant \
    1048         -width 18 -height 18 \
    10491068        -onimage [Rappture::icon font-italic] \
    10501069        -offimage [Rappture::icon font-italic] \
    10511070        -onvalue "italic" -offvalue "roman" \
    10521071        -command [itcl::code $this ApplyAxisSettings] \
    1053         -variable [itcl::scope _settings($this-axis-titlefont-slant)]
     1072        -variable [itcl::scope _settings($this-axis-title-fontslant)]
    10541073    Rappture::Tooltip::for $page.titlefontslant \
    10551074        "Use the italic version of the title font."
     
    10841103        8,4 $page.plotpad -fill both -cspan 3
    10851104
    1086     blt::table configure $page  c0 c7 c8 -resize none
     1105    blt::table configure $page  c0 c4 c5 c6 c7 c8 -resize none
    10871106}
    10881107
     
    10951114    set _settings($this-legend-position)  [$page.position current]
    10961115    set _settings($this-legend-anchor)    [$page.anchor current]
    1097 
     1116   
    10981117    foreach option { -hide -position -anchor -borderwidth } {
    10991118        SetComponentOption legend $option
    11001119    }
    1101     font configure $_fonts(legend) \
    1102         -family [$page.fontfamily current] \
    1103         -size [$page.fontsize current] \
    1104         -weight $_settings($this-legend-font-weight) \
    1105         -slant $_settings($this-legend-font-slant)
    1106     $_clone legend configure -font fixed -font $_fonts(legend)
     1120    lappend font $_settings($this-legend-fontfamily)
     1121    lappend font $_settings($this-legend-fontsize)
     1122    lappend font $_settings($this-legend-fontweight)
     1123    lappend font $_settings($this-legend-fontslant)
     1124    $_clone legend configure -font fixed -font $font
    11071125    ApplyElementSettings
    11081126}
     
    11211139        SetNamedComponentOption axis $axis $option
    11221140    }
     1141    set tickfont {}
     1142    set titlefont {}
     1143    foreach attr { fontfamily fontsize fontweight fontslant } {
     1144        set specific $this-$axis-ticks
     1145        set general  $this-axis-ticks
     1146        set _settings(${specific}-${attr}) $_settings(${general}-${attr})
     1147        lappend tickfont $_settings(${general}-${attr})
     1148        set specific $this-$axis-title
     1149        set general  $this-axis-title
     1150        set _settings(${specific}-${attr}) $_settings(${general}-${attr})
     1151        lappend titlefont $_settings(${general}-${attr})
     1152    }
     1153    $_clone axis configure $axis -tickfont $tickfont -titlefont $titlefont
    11231154    $_clone marker configure ${type}-zero -hide $_settings($this-axis-zero)
    1124     font configure $axis-title \
    1125         -family [$page.titlefontfamily current] \
    1126         -size   [$page.titlefontsize current] \
    1127         -weight $_settings($this-axis-titlefont-weight) \
    1128         -slant  $_settings($this-axis-titlefont-slant)
    1129     font configure $axis-ticks \
    1130         -family [$page.tickfontfamily current] \
    1131         -size   [$page.tickfontsize current] \
    1132         -weight $_settings($this-axis-tickfont-weight) \
    1133         -slant  $_settings($this-axis-tickfont-slant)
    1134     $_clone axis configure $axis -tickfont $axis-ticks -titlefont $axis-title
    11351155    GetAxis
    11361156    RegeneratePreview
     
    12151235    set _settings($this-legend-borderwidth) 0
    12161236
    1217     array unset info
    1218     array set info [font configure legend]
    1219     $page.fontfamily value $info(-family)
    1220     $page.fontsize value $info(-size)
    1221     set _settings($this-legend-font-weight) $info(-weight)
    1222     set _settings($this-legend-font-slant) $info(-slant)
    1223     if { $info(-weight) == "bold" } {
     1237    $page.fontfamily value $_settings($this-legend-fontfamily)
     1238    $page.fontsize value $_settings($this-legend-fontsize)
     1239    if { $_settings($this-legend-fontweight) == "bold" } {
    12241240        set _settings($this-legend-font-bold) 1
    12251241    }
     
    12441260    set axis [lindex $names 0]
    12451261
    1246     array set info [font configure $axis-title]
    1247     $page.titlefontfamily value $info(-family)
    1248     $page.titlefontsize value $info(-size)
    1249     set _settings($this-axis-titlefont-weight) $info(-weight)
    1250     set _settings($this-axis-titlefont-slant) $info(-slant)
    1251 
    1252     array set info [font configure $axis-ticks]
    1253     $page.tickfontfamily value $info(-family)
    1254     $page.tickfontsize value $info(-size)
    1255     set _settings($this-axis-tickfont-weight) $info(-weight)
    1256     set _settings($this-axis-tickfont-slant) $info(-slant)
     1262    $page.titlefontfamily value $_settings($this-$axis-title-fontfamily)
     1263    $page.titlefontsize value   $_settings($this-axis-title-fontsize)
     1264    $page.tickfontfamily value  $_settings($this-$axis-ticks-fontfamily)
     1265    $page.tickfontsize value    $_settings($this-axis-ticks-fontsize)
    12571266
    12581267    # Always hide the zero line.
     
    12841293    set parser [interp create -safe]
    12851294    $parser alias xyprint [itcl::code $this restore]
    1286     $parser alias font font
    12871295    set f [open $_settingsFile "r"]
    12881296    set code [read $f]
     
    12971305        $parser eval $_savedSettings($key)
    12981306    }
    1299     foreach {name value} [$parser eval "array get general"] {
    1300         set _settings($this-graph-$name) $value
     1307    # Restore settings to this instance
     1308    foreach {name value} [$parser eval "array get settings"] {
     1309        set _settings($this-$name) $value
    13011310    }
    13021311    interp delete $parser
     
    13381347    # Create stanza associated with tool and plot title.
    13391348    # General settings
    1340     append out "    set general(format) $_settings($this-general-format)\n"
    1341     append out "    set general(style) $_settings($this-general-style)\n"
    1342 
    1343     foreach font [array names _fonts] {
    1344         append out "    font configure $font"
    1345         array unset info
    1346         array set info [font configure $font]
    1347         foreach opt { -family -size -weight -slant } {
    1348             set value [list $info($opt)]
    1349             append out " $opt $value"
    1350         }
    1351         append out "\n"
    1352     }
     1349    set length [string length "${this}-"]
     1350    append out "    array set settings {\n"
     1351    foreach item [array names _settings ${this}-*] {
     1352        set field [string range $item $length end]
     1353        if { [regexp {^element-[0-9]+$} $field] } {
     1354            continue
     1355        }
     1356        set value $_settings($item)
     1357        append out "        [list $field] [list $value]\n"
     1358    }
     1359    append out "    }\n"
     1360    # Legend font
     1361    lappend legendfont $_settings($this-legend-fontfamily)
     1362    lappend legendfont $_settings($this-legend-fontsize)
     1363    lappend legendfont $_settings($this-legend-fontweight)
     1364    lappend legendfont $_settings($this-legend-fontslant)
     1365    # Axis tick font
     1366    lappend axistickfont $_settings($this-axis-ticks-fontfamily)
     1367    lappend axistickfont $_settings($this-axis-ticks-fontsize)
     1368    lappend axistickfont $_settings($this-axis-ticks-fontweight)
     1369    lappend axistickfont $_settings($this-axis-ticks-fontslant)
     1370    # Axis title font
     1371    lappend axistitlefont $_settings($this-axis-title-fontfamily)
     1372    lappend axistitlefont $_settings($this-axis-title-fontsize)
     1373    lappend axistitlefont $_settings($this-axis-title-fontweight)
     1374    lappend axistitlefont $_settings($this-axis-title-fontslant)
    13531375    append out "\n"
    13541376
     
    13681390        append out " $opt $value"
    13691391    }
    1370     append out " -font legend\n"
     1392    append out " -font \"$legendfont\"\n"
    13711393
    13721394    # Element settings
     
    14011423            append out " $opt $value"
    14021424        }
    1403         append out " -tickfont \"$axis-ticks\""
    1404         append out " -titlefont \"$axis-title\"\n"
     1425        append out " -tickfont \"$axistickfont\""
     1426        append out " -titlefont \"$axistitlefont\"\n"
    14051427        set hide [$_clone marker cget ${axis}-zero -hide]
    14061428        append out "        preview marker configure \"${axis}-zero\" -hide $hide\n"
Note: See TracChangeset for help on using the changeset viewer.