Changeset 2748


Ignore:
Timestamp:
Dec 28, 2011 2:01:15 PM (13 years ago)
Author:
gah
Message:
 
Location:
branches/blt4/gui/scripts
Files:
7 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/gui/scripts/molvisviewer.tcl

    r2745 r2748  
    2727        molvis_server Rappture::MolvisViewer::SetServerList
    2828}
     29
     30itk::usual ComboMenu {
     31}
     32itk::usual ComboEntry {
     33}
     34
    2935
    3036set debug 0
     
    5864    private variable _model
    5965    private variable _mlist
    60     private variable _mrep "ballnstick"
     66    private variable _mrep "ball and stick"
    6167
    6268    private variable _imagecache
     
    144150    private method StickRadius {option {models "all"} }
    145151    private method OrthoProjection {option}
    146     private method Representation { {option ""} }
     152    private method ModelRepresentation { {option ""} }
    147153    private method CartoonTrace {option {model "all"}}
    148154    private method ComputeParallelepipedVertices { dataobj }
     
    231237        $this-stickradius 0.14
    232238        $this-cartoontrace no
    233         $this-model     ballnstick
    234         $this-modelimg  [Rappture::icon ballnstick]
     239        $this-modelrep     "ball and stick"
    235240        $this-opacity   1.0
    236241        $this-ortho     no
     
    320325        [itcl::code $this OrthoProjection toggle]
    321326
     327    if { [catch {
    322328    BuildSettingsTab
    323 
     329    } errs] != 0 } {
     330        global errorInfo
     331        puts stderr "errs=$errs errorInfo=$errorInfo"
     332    }
    324333    # HACK ALERT. Initially force a requested width of the 3dview label.
    325334
     
    795804    $inner configure -borderwidth 4
    796805
    797     label $inner.rep_l -text "Molecule Representation" \
     806    blt::tk::label $inner.rep_l -text "Molecule Representation" \
    798807        -font "Arial 9"
    799 
    800     itk_component add representation {
    801         Rappture::Combobox $inner.rep -width 20 -editable no
    802     }
    803     $inner.rep choices insert end \
    804         "ballnstick"  "ball and stick" \
    805         "spheres"     "spheres"         \
    806         "sticks"      "sticks"          \
    807         "lines"       "lines"           \
    808         "cartoon"     "cartoon"         
    809 
    810     bind $inner.rep <<Value>> [itcl::code $this Representation]
    811     $inner.rep value "ball and stick"
     808    set m $inner.rep.menu
     809    blt::comboentry $inner.rep \
     810        -width 2i \
     811        -textvariable [itcl::scope _settings($this-modelrep)] \
     812        -editable no -menu $m \
     813        -command [itcl::code $this ModelRepresentation]
     814    itk_component add modelrep {
     815        blt::combomenu $m \
     816            -xscrollbar $m.xs \
     817            -yscrollbar $m.ys  \
     818            -textvariable [itcl::scope _settings($this-modelrep)] \
     819            -height { 0 2i }
     820    }
     821    blt::tk::scrollbar $m.xs
     822    blt::tk::scrollbar $m.ys
     823    $m add -text "ball and stick" -value "ballnstick" \
     824        -icon [Rappture::icon ballnstick]
     825    $m add -text "spheres" -value "spheres" \
     826        -icon [Rappture::icon spheres]
     827    $m add -text "sticks" -value "sticks"  \
     828        -icon [Rappture::icon lines]
     829    $m add -text "lines" -value "lines"  \
     830        -icon [Rappture::icon lines]
     831    $m add -text "cartoon" -value "cartoon" \
     832        -icon [Rappture::icon cartoon]
     833    Rappture::Tooltip::for $inner.rep \
     834        "Set the representation of the molecule."
     835    $m select "ball and stick"
    812836
    813837    scale $inner.spherescale -width 10 -font "Arial 9" \
     
    11301154        Cell update
    11311155        OrthoProjection update
    1132         Representation update
     1156        ModelRepresentation update
    11331157    }
    11341158    set tab [$itk_component(main) panel "Settings"]
     
    12101234    set _view(c) $c
    12111235    if { !$_rotatePending } {
    1212         $_dispatcher event -after 100 !rotate
     1236        $_dispatcher event -after 50 !rotate
    12131237        set _rotatePending 1
    12141238    }
     
    15411565
    15421566# ----------------------------------------------------------------------
    1543 # USAGE: Representation spheres|ballnstick|lines|sticks
     1567# USAGE: ModelRepresentation spheres|ballnstick|lines|sticks
    15441568#
    15451569# Used internally to change the molecular representation used to render
    15461570# our scene.
    15471571# ----------------------------------------------------------------------
    1548 itcl::body Rappture::MolvisViewer::Representation { { option "" } } {
     1572itcl::body Rappture::MolvisViewer::ModelRepresentation { { option "" } } {
    15491573    if { $option == "" } {
    1550         set value [$itk_component(representation) value]
    1551         set option [$itk_component(representation) translate $value]
     1574        set rep $_settings($this-modelrep)
     1575        if { [info exists itk_component(modelrep)] } {
     1576            set option [$itk_component(modelrep) item cget $rep -value]
     1577        }
    15521578    }
    15531579    if { $option == $_mrep } {
     
    15581584    }
    15591585    array unset _imagecache
    1560     if { $option == "sticks" } {
    1561         set _settings($this-modelimg) [Rappture::icon lines]
    1562     }  else {
    1563         set _settings($this-modelimg) [Rappture::icon $option]
    1564     }
    15651586    set tab [$itk_component(main) panel "Settings"]
    15661587    set inner $tab.ss.frame
    1567     $inner.pict configure -image $_settings($this-modelimg)
    15681588
    15691589    # Save the current option to set all radiobuttons -- just in case.
     
    15801600            }
    15811601        }
    1582     }
    1583     if { [isconnected] } {
    1584         SendCmd "representation -model $model $option"
    1585         #$_dispatcher event -idle !rebuild
     1602        if { [isconnected] } {
     1603            SendCmd "representation -model $model $option"
     1604        }
    15861605    }
    15871606}
  • branches/blt4/gui/scripts/xyprint.tcl

    r2746 r2748  
    3939    private variable _savedSettings;    # Array of settings.
    4040    private variable _outputFormatType "";
     41    private variable _formatIcon "";
    4142
    4243    private common _oldSettingsFile "~/.rpsettings"
     
    678679    set m $page.format.menu
    679680    blt::comboentry $page.format \
    680         -width 30 \
     681        -width 1i \
    681682        -textvariable [itcl::scope _settings($this-general-format)] \
    682683        -editable no -menu $m \
     684        -iconvariable [itcl::scope _formatIcon] \
    683685        -command [itcl::code $this ApplyGeneralSettings]
    684686    blt::combomenu $m \
     
    686688        -yscrollbar $m.ys  \
    687689        -textvariable [itcl::scope _settings($this-general-format)] \
     690        -iconvariable [itcl::scope _formatIcon] \
    688691        -height { 0 2i }
    689692    blt::tk::scrollbar $m.xs
    690693    blt::tk::scrollbar $m.ys
    691     $m add -value "pdf" -text "PDF Portable Document Format"
    692     $m add -value "ps"  -text "PS PostScript Format" 
    693     $m add -value "eps" -text "EPS Encapsulated PostScript" 
    694     $m add -value "jpg" -text "JPEG Joint Photographic Experts Group Format"
    695     $m add -value "png" -text "PNG Portable Network Graphics Format"
    696     $m add -value "gif" -text "GIF Graphics Interchange Format"
     694    $m add -value "pdf" -text "PDF Portable Document Format"  \
     695        -icon [Rappture::icon pdf]
     696    $m add -value "ps"  -text "PS PostScript Format"  \
     697        -icon [Rappture::icon ps]
     698    $m add -value "eps" -text "EPS Encapsulated PostScript"  \
     699        -icon [Rappture::icon eps]
     700    $m add -value "jpg" -text "JPEG Joint Photographic Experts Group Format"  \
     701        -icon [Rappture::icon jpg]
     702    $m add -value "png" -text "PNG Portable Network Graphics Format"  \
     703        -icon [Rappture::icon png]
     704    $m add -value "gif" -text "GIF Graphics Interchange Format" \
     705        -icon [Rappture::icon gif]
    697706    Rappture::Tooltip::for $page.format_l "Set the format of the image."
    698707
     
    700709    set m $page.style.menu
    701710    blt::comboentry $page.style \
    702         -width 30 \
     711        -width 1i \
    703712        -textvariable [itcl::scope _settings($this-general-style)] \
    704713        -editable no -menu $m \
     
    740749}
    741750   
    742 itcl::body Rappture::XyPrint::ApplyLegendSettings {} {
    743     set page $itk_component(legend_page)
    744     set _settings($this-legend-anchor)    [$page.anchor current]
    745     if { $_clone != "" } {
    746         lappend font $_settings($this-legend-fontfamily)
    747         lappend font $_settings($this-legend-fontsize)
    748         lappend font $_settings($this-legend-fontweight)
    749         lappend font $_settings($this-legend-fontslant)
    750         foreach option { -hide -position -anchor -borderwidth } {
    751             SetComponentOption legend $option
    752         }
    753         $_clone legend configure -font fixed -font $font
    754     }
    755     ApplyElementSettings
    756 }
    757 
    758751itcl::body Rappture::XyPrint::BuildLegendTab {} {
    759752    itk_component add legend_page {
     
    875868        "Set the symbol of the current entry. \"none\" display no symbols."
    876869
    877     label $page.font_l -text "font"
    878     Rappture::Combobox $page.fontfamily -width 10 -editable no
    879     $page.fontfamily choices insert end \
    880         "courier" "courier" \
    881         "helvetica" "helvetica"  \
    882         "new*century*schoolbook"  "new century schoolbook" \
    883         "symbol"  "symbol" \
    884         "times"  "times"         
    885     bind $page.fontfamily <<Value>> [itcl::code $this ApplyLegendSettings]
     870    blt::tk::label $page.font_l -text "font"
     871    set m $page.fontfamily.menu
     872    blt::comboentry $page.fontfamily \
     873        -width 1i \
     874        -textvariable [itcl::scope _settings($this-legend-fontfamily)] \
     875        -editable no -menu $m \
     876        -command [itcl::code $this ApplyLegendSettings]
     877    blt::combomenu $m \
     878        -xscrollbar $m.xs \
     879        -yscrollbar $m.ys  \
     880        -textvariable [itcl::scope _settings($this-legend-fontfamily)] \
     881        -height { 0 2i }
     882    blt::tk::scrollbar $m.xs
     883    blt::tk::scrollbar $m.ys
     884    $m style create "courier" -font "{courier new} 9"
     885    $m style create "helvetica" -font "{arial} 9"
     886    $m style create "newcentury" -font "{new century schoolbook} 9"
     887    $m style create "times" -font "{times new roman} 9"
     888    $m add -text "courier" -value "courier" -style "courier"
     889    $m add -text "helvetica" -value "helvetica"  -style "helvetica"
     890    $m add -text "new century schoolbook" -value "new*century*schoolbook" \
     891        -style "newcentury"
     892    $m add -text "symbol" -value "symbol"
     893    $m add -text "times" -value "times" -style "times"
     894    $m item configure all -icon [Rappture::icon font]
    886895    Rappture::Tooltip::for $page.fontfamily \
    887896        "Set the font of entries in the legend."
    888897
    889     Rappture::Combobox $page.fontsize -width 4 -editable no
    890     $page.fontsize choices insert end \
    891         "8" "8" \
    892         "9" "9" \
    893         "10" "10" \
    894         "11" "11" \
    895         "12" "12" \
    896         "14" "14" \
    897         "17" "17" \
    898         "18" "18" \
    899         "20" "20"
    900     bind  $page.fontsize <<Value>> [itcl::code $this ApplyLegendSettings]
     898    set m $page.fontsize.menu
     899    blt::comboentry $page.fontsize \
     900        -width 0.5i \
     901        -textvariable [itcl::scope _settings($this-legend-fontsize)] \
     902        -editable no -menu $m \
     903        -command [itcl::code $this ApplyLegendSettings]
     904    blt::combomenu $m \
     905        -xscrollbar $m.xs \
     906        -yscrollbar $m.ys  \
     907        -textvariable [itcl::scope _settings($this-legend-fontsize)] \
     908        -height { 0 2i }
     909    blt::tk::scrollbar $m.xs
     910    blt::tk::scrollbar $m.ys
     911    foreach size { "8" "9" "10" "11" "12" "14" "17" "18" "20" } {
     912        $m add -text $size -value $size
     913    }
    901914    Rappture::Tooltip::for $page.fontsize \
    902         "Set the size (points) of the font."
     915        "Set the size (in points) of the legend font."
    903916
    904917    blt::tk::pushbutton $page.fontweight \
     
    10321045    set m $page.tickfontfamily.menu
    10331046    blt::comboentry $page.tickfontfamily \
    1034         -width 10 \
     1047        -width 1i \
    10351048        -textvariable [itcl::scope _settings($this-axis-ticks-fontfamily)] \
    10361049        -editable no -menu $m \
     
    10531066    $m add -text "symbol" -value "symbol"
    10541067    $m add -text "times" -value "times" -style "times"
    1055     $m item configure all \
    1056         -variable [itcl::scope _settings($this-axis-ticks-fontfamily)]
     1068    $m item configure all -icon [Rappture::icon font]
    10571069    Rappture::Tooltip::for $page.tickfontfamily \
    10581070        "Set the font of the ticks for the current axis."
    10591071
    1060     if 0 {
    1061     label $page.tickfont_l -text "tick font"
    1062     Rappture::Combobox $page.tickfontfamily -width 10 -editable no
    1063     $page.tickfontfamily choices insert end \
    1064         "courier" "courier" \
    1065         "helvetica" "helvetica"  \
    1066         "new*century*schoolbook"  "new century schoolbook" \
    1067         "symbol"  "symbol" \
    1068         "times"  "times"         
    1069     bind $page.tickfontfamily <<Value>> [itcl::code $this ApplyAxisSettings]
    1070     Rappture::Tooltip::for $page.tickfontfamily \
    1071         "Set the font of the ticks for the current axis."
    1072     }
    1073     Rappture::Combobox $page.tickfontsize -width 4 -editable no
    1074     $page.tickfontsize choices insert end \
    1075         "8" "8" \
    1076         "9" "9" \
    1077         "10" "10" \
    1078         "11" "11" \
    1079         "12" "12" \
    1080         "14" "14" \
    1081         "17" "17" \
    1082         "18" "18" \
    1083         "20" "20"
    1084     bind $page.tickfontsize <<Value>> [itcl::code $this ApplyAxisSettings]
     1072    set m $page.tickfontsize.menu
     1073    blt::comboentry $page.tickfontsize \
     1074        -width 0.5i \
     1075        -textvariable [itcl::scope _settings($this-axis-ticks-fontsize)] \
     1076        -editable no -menu $m \
     1077        -command [itcl::code $this ApplyLegendSettings]
     1078    blt::combomenu $m \
     1079        -xscrollbar $m.xs \
     1080        -yscrollbar $m.ys  \
     1081        -textvariable [itcl::scope _settings($this-axis-ticks-fontsize)] \
     1082        -height { 0 2i }
     1083    blt::tk::scrollbar $m.xs
     1084    blt::tk::scrollbar $m.ys
     1085    foreach size { "8" "9" "10" "11" "12" "14" "17" "18" "20" } {
     1086        $m add -text $size -value $size
     1087    }
    10851088    Rappture::Tooltip::for $page.tickfontsize \
    1086         "Set the size (points) of the tick font."
     1089        "Set the size (in points) of the tick font."
    10871090
    10881091    blt::tk::pushbutton $page.tickfontweight \
     
    11061109        "Use the italic version of the tick font."
    11071110
    1108     label $page.titlefont_l -text "title font"
    1109     Rappture::Combobox $page.titlefontfamily -width 10 -editable no
    1110     $page.titlefontfamily choices insert end \
    1111         "courier" "courier" \
    1112         "helvetica" "helvetica"  \
    1113         "new*century*schoolbook"  "new century schoolbook" \
    1114         "symbol"  "symbol" \
    1115         "times"  "times"         
    1116     bind $page.titlefontfamily <<Value>> [itcl::code $this ApplyAxisSettings]
     1111    blt::tk::label $page.titlefont_l -text "title font"
     1112    set m $page.titlefontfamily.menu
     1113    blt::comboentry $page.titlefontfamily \
     1114        -width 1i \
     1115        -textvariable [itcl::scope _settings($this-axis-title-fontfamily)] \
     1116        -editable no -menu $m \
     1117        -command [itcl::code $this ApplyAxisSettings]
     1118    blt::combomenu $m \
     1119        -xscrollbar $m.xs \
     1120        -yscrollbar $m.ys  \
     1121        -textvariable [itcl::scope _settings($this-axis-title-fontfamily)] \
     1122        -height { 0 2i }
     1123    blt::tk::scrollbar $m.xs
     1124    blt::tk::scrollbar $m.ys
     1125    $m style create "courier" -font "{courier new} 9"
     1126    $m style create "helvetica" -font "{arial} 9"
     1127    $m style create "newcentury" -font "{new century schoolbook} 9"
     1128    $m style create "times" -font "{times new roman} 9"
     1129    $m add -text "courier" -value "courier" -style "courier"
     1130    $m add -text "helvetica" -value "helvetica"  -style "helvetica"
     1131    $m add -text "new century schoolbook" -value "new*century*schoolbook" \
     1132        -style "newcentury"
     1133    $m add -text "symbol" -value "symbol"
     1134    $m add -text "times" -value "times" -style "times"
     1135    $m item configure all -icon [Rappture::icon font]
    11171136    Rappture::Tooltip::for $page.titlefontfamily \
    11181137        "Set the font of the title for the current axis."
    11191138
    1120     Rappture::Combobox $page.titlefontsize -width 4 -editable no
    1121     $page.titlefontsize choices insert end \
    1122         "8" "8" \
    1123         "9" "9" \
    1124         "10" "10" \
    1125         "11" "11" \
    1126         "12" "12" \
    1127         "14" "14" \
    1128         "17" "17" \
    1129         "18" "18" \
    1130         "20" "20"
    1131     bind $page.titlefontsize <<Value>> [itcl::code $this ApplyAxisSettings]
     1139    set m $page.titlefontsize.menu
     1140    blt::comboentry $page.titlefontsize \
     1141        -width 0.5i \
     1142        -textvariable [itcl::scope _settings($this-axis-title-fontsize)] \
     1143        -editable no -menu $m \
     1144        -command [itcl::code $this ApplyLegendSettings]
     1145    blt::combomenu $m \
     1146        -xscrollbar $m.xs \
     1147        -yscrollbar $m.ys  \
     1148        -textvariable [itcl::scope _settings($this-axis-title-fontsize)] \
     1149        -height { 0 2i }
     1150    blt::tk::scrollbar $m.xs
     1151    blt::tk::scrollbar $m.ys
     1152    foreach size { "8" "9" "10" "11" "12" "14" "17" "18" "20" } {
     1153        $m add -text $size -value $size
     1154    }
    11321155    Rappture::Tooltip::for $page.titlefontsize \
    1133         "Set the size (point) of the title font."
     1156        "Set the size (in points) of the title font."
    11341157
    11351158    blt::tk::pushbutton $page.titlefontweight \
     
    11931216itcl::body Rappture::XyPrint::ApplyLegendSettings {} {
    11941217    set page $itk_component(legend_page)
     1218
    11951219    set _settings($this-legend-position)  [$page.position current]
    11961220    set _settings($this-legend-anchor)    [$page.anchor current]
    1197    
    11981221    foreach option { -hide -position -anchor -borderwidth } {
    11991222        SetComponentOption legend $option
    12001223    }
    1201     set _settings($this-legend-fontfamily)  [$page.fontfamily value]
    1202     set _settings($this-legend-fontsize)    [$page.fontsize value]
    12031224    lappend font $_settings($this-legend-fontfamily)
    12041225    lappend font $_settings($this-legend-fontsize)
     
    12061227    lappend font $_settings($this-legend-fontslant)
    12071228    $_clone legend configure -font fixed -font $font
     1229
     1230    # Set the font of the comboentry to the selected legend font.
     1231    set m $page.fontfamily.menu
     1232    set style [$m item cget $_settings($this-legend-fontfamily) -style]
     1233    set font [$m style cget $style -font]
     1234    $page.fontfamily configure -font $font
    12081235    ApplyElementSettings
    12091236}
     
    12171244        SetNamedComponentOption axis $axis $option
    12181245    }
    1219     #set _settings($this-axis-ticks-fontfamily)  [$page.tickfontfamily value]
    1220     #set _settings($this-axis-ticks-fontfamily) $_settings($this-$axis-ticks-fontfamily) 
    1221     set _settings($this-axis-ticks-fontsize)    [$page.tickfontsize value]
    1222     set _settings($this-axis-title-fontfamily)  [$page.titlefontfamily value]
    1223     set _settings($this-axis-title-fontsize)    [$page.titlefontsize value]
    1224 
    12251246    set tickfont {}
    12261247    set titlefont {}
     
    12361257        lappend titlefont $_settings(${general}-${attr})
    12371258    }
    1238     set style [$page.tickfontfamily.menu item cget \
    1239                $_settings($this-axis-ticks-fontfamily) -style]
    1240     set font [$page.tickfontfamily.menu style cget $style -font]
     1259    # Set the font of the comboentry to the selected tick font.
     1260    set m $page.tickfontfamily.menu
     1261    set style [$m item cget $_settings($this-axis-ticks-fontfamily) -style]
     1262    set font [$m style cget $style -font]
    12411263    $page.tickfontfamily configure -font $font
     1264
     1265    # Set the font of the comboentry to the selected title font.
     1266    set m $page.titlefontfamily.menu
     1267    set style [$m item cget $_settings($this-axis-title-fontfamily) -style]
     1268    set font [$m style cget $style -font]
     1269    $page.titlefontfamily configure -font $font
    12421270
    12431271    $_clone axis configure $axis -tickfont $tickfont -titlefont $titlefont
    12441272    $_clone marker configure ${type}-zero -hide $_settings($this-axis-zero)
    1245     #GetAxis
     1273
    12461274    RegeneratePreview
    12471275}
     
    12911319itcl::body Rappture::XyPrint::InitializeSettings {} {
    12921320    # General settings
     1321    set page $itk_component(graph_page)
    12931322
    12941323    # Always set to "jpg" "ieee"
    12951324    set _settings($this-general-format)   \
    12961325        "JPEG Joint Photographic Experts Group Format"
     1326    $page.format.menu select "JPEG Joint Photographic Experts Group Format"
    12971327    set _settings($this-general-style)    ieee
    12981328    set _settings($this-general-remember) 0
    1299     set page $itk_component(graph_page)
    13001329
    13011330    # Layout settings
     
    13241353    set _settings($this-legend-borderwidth) 0
    13251354
    1326     $page.fontfamily value $_settings($this-legend-fontfamily)
    1327     $page.fontsize value $_settings($this-legend-fontsize)
    13281355    if { $_settings($this-legend-fontweight) == "bold" } {
    13291356        set _settings($this-legend-font-bold) 1
     
    13511378    }
    13521379    set axis [lindex $names 0]
    1353 
    1354     $page.titlefontfamily value $_settings($this-$axis-title-fontfamily)
    1355     $page.titlefontsize value   $_settings($this-$axis-title-fontsize)
    1356     #set _settings($this-axis-ticks-fontfamily) $_settings($this-$axis-ticks-fontfamily)
    1357     $page.tickfontsize value    $_settings($this-$axis-ticks-fontsize)
    13581380
    13591381    # Always hide the zero line.
Note: See TracChangeset for help on using the changeset viewer.