Ignore:
Timestamp:
Jul 12, 2013, 12:06:27 PM (11 years ago)
Author:
gah
Message:

fix multiple barchart results, fix PDB reader, dynamically create tabs for vtkviewer

Location:
branches/1.3/gui/scripts
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3/gui/scripts/drawing.tcl

    r3707 r3785  
    1212package require Itcl
    1313package require BLT
     14
     15set count 0
    1416
    1517namespace eval Rappture {
     
    100102                set pdbdata [$_xmlobj get $path.$elem.pdb]
    101103                if { $pdbdata != "" } {
     104                    if 1 {
     105                        global count
     106                        set f [open /tmp/file$count.pdb "w"]
     107                        incr count
     108                        puts $f $pdbdata
     109                        close $f
     110                    }
    102111                    set contents [Rappture::PdbToVtk $pdbdata]
    103                     if 1 {
     112                    if 0 {
    104113                        set f [open /tmp/convertedpdb.vtk "w"]
    105114                        puts $f $contents
  • branches/1.3/gui/scripts/sidebarframe.tcl

    r3330 r3785  
    4343
    4444    public method insert {pos args}
     45    public method exists {which}
    4546    public method panel {which}
    4647    public method select {which}
     
    6364    private variable _width "auto"   ;# width adjusted by sash or "auto"
    6465    private variable _counter 0      ;# counter for auto-generated names
     66    private variable _title2panel
    6567}
    6668
     
    249251        -command [itcl::code $this _toggleTab $pname]
    250252
     253    set _title2panel($panel(-title)) $pname
    251254    Rappture::Tooltip::text $itk_component(tabs)-$pname \
    252255        "Open/close sidebar for $panel(-title)"
     
    303306        }
    304307    }
     308}
     309
     310# ----------------------------------------------------------------------
     311# USAGE: exists <which>
     312#
     313# Returns the frame representing the requested panel.  The <which>
     314# argument can be a panel index, name, or title, or the keyword
     315# "current" for the selected panel.
     316# ----------------------------------------------------------------------
     317itcl::body Rappture::SidebarFrame::exists { title } {
     318    if { [info exists _title2panel($title)] } {
     319        return 1
     320    }
     321    return 0
    305322}
    306323
  • branches/1.3/gui/scripts/vtkviewer.tcl

    r3709 r3785  
    8686    private method BuildCutawayTab {}
    8787    private method BuildDownloadPopup { widget command }
    88     private method BuildMeshTab {}
    8988    private method BuildMoleculeTab {}
    90     private method ConvertToVtkData { dataobj comp }
     89    private method BuildPolydataTab {}
     90    private method ChangeColormap { dataobj comp color }
    9191    private method DrawLegend {}
    9292    private method EnterLegend { x y }
     93    private method EventuallySetAtomScale { args }
     94    private method EventuallySetBondScale { args }
     95    private method EventuallySetMoleculeOpacity { args }
     96    private method EventuallySetPolydataOpacity { args }
    9397    private method EventuallyResize { w h }
    9498    private method EventuallyRotate { q }
     
    100104    private method PanCamera {}
    101105    private method RequestLegend {}
     106    private method SetAtomScale {}
     107    private method SetBondScale {}
    102108    private method SetColormap { dataobj comp }
    103     private method ChangeColormap { dataobj comp color }
    104109    private method SetLegendTip { x y }
     110    private method SetMoleculeOpacity {}
    105111    private method SetObjectStyle { dataobj comp }
     112    private method SetOpacity { dataset }
     113    private method SetOrientation { side }
     114    private method SetPolydataOpacity {}
    106115    private method Slice {option args}
    107     private method SetOrientation { side }
    108116
    109117    private variable _arcball ""
    110118    private variable _dlist "";         # list of data objects
    111     private variable _allDataObjs
    112119    private variable _obj2datasets
    113120    private variable _obj2ovride;       # maps dataobj => style override
     
    130137    private variable _haveGlyphs 0
    131138    private variable _haveMolecules 0
     139    private variable _havePolydata 0
    132140
    133141    private variable _first ""     ;# This is the topmost dataset.
     
    141149    private variable _resizePending 0
    142150    private variable _rotatePending 0
     151    private variable _atomScalePending 0
     152    private variable _bondScalePending 0
     153    private variable _moleculeOpacityPending 0
     154    private variable _polydataOpacityPending 0
     155    private variable _glyphsOpacityPending 0
    143156    private variable _updatePending 0;
     157    private variable _rotateDelay 150
     158    private variable _scaleDelay 100
     159
    144160    private variable _outline
    145161}
     
    173189    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
    174190
     191    # Atom scale event
     192    $_dispatcher register !atomscale
     193    $_dispatcher dispatch $this !atomscale \
     194        "[itcl::code $this SetAtomScale]; list"
     195
     196    # Bond scale event
     197    $_dispatcher register !bondscale
     198    $_dispatcher dispatch $this !bondscale \
     199        "[itcl::code $this SetBondScale]; list"
     200
     201    # Molecule opacity event
     202    $_dispatcher register !moleculeOpacity
     203    $_dispatcher dispatch $this !moleculeOpacity \
     204        "[itcl::code $this SetMoleculeOpacity]; list"
     205
     206    # Polydata opacity event
     207    $_dispatcher register !polydataOpacity
     208    $_dispatcher dispatch $this !polydataOpacity \
     209        "[itcl::code $this SetPolydataOpacity]; list"
    175210    #
    176211    # Populate parser with commands handle incoming requests
     
    223258    }]
    224259    array set _settings [subst {
    225         legend          1
    226         molecule-representation  "Ball and Stick"
    227         molecule-edges           0
    228         molecule-labels          0
    229         molecule-lighting        1
    230         molecule-opacity         100
    231         molecule-visible         1
    232         molecule-wireframe       0
    233         molecule-palette         elementDefault
    234         mesh-edges           0
    235         mesh-lighting        1
    236         mesh-opacity         40
    237         mesh-visible         1
    238         mesh-wireframe       0
    239         mesh-palette         rainbow
     260        legend                  1
     261        polydata-edges          0
     262        polydata-lighting       1
     263        polydata-opacity        40
     264        polydata-palette        rainbow
     265        polydata-visible        1
     266        polydata-wireframe      0
     267        molecule-atomscale      1.0
     268        molecule-bondscale      1.0
     269        molecule-atoms-visible  1
     270        molecule-bonds-visible  1
     271        molecule-edges          0
     272        molecule-labels         0
     273        molecule-lighting       1
     274        molecule-opacity        100
     275        molecule-palette        elementDefault
     276        molecule-representation "Ball and Stick"
     277        molecule-visible        1
     278        molecule-wireframe      0
    240279    }]
    241 
    242280    itk_component add view {
    243281        canvas $itk_component(plotarea).view \
     
    306344    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
    307345
    308     if { [catch { BuildMeshTab } errs ]  != 0 } {
    309         puts stderr "errs=$errs"
    310     }
    311     if { [catch { BuildMoleculeTab } errs ]  != 0 } {
    312         global errorInfo
    313         puts stderr "errs=$errs\nerrorInfo=$errorInfo"
    314     }
    315346    BuildAxisTab
    316347    #BuildCutawayTab
     
    347378        [itcl::code $this EventuallyResize %w %h]
    348379
    349     if 0 {
    350     bind $itk_component(view) <Configure> \
    351         [itcl::code $this EventuallyResize %w %h]
    352     }
    353380    # Bindings for panning via mouse
    354381    bind $itk_component(view) <ButtonPress-2> \
     
    442469}
    443470
    444 set rotate_delay 150
    445 
    446471itcl::body Rappture::VtkViewer::EventuallyRotate { q } {
    447472    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
    448473    if { !$_rotatePending } {
    449474        set _rotatePending 1
    450         global rotate_delay
    451         $_dispatcher event -after $rotate_delay !rotate
     475        $_dispatcher event -after $_rotateDelay !rotate
     476    }
     477}
     478
     479itcl::body Rappture::VtkViewer::SetAtomScale {} {
     480    SendCmd "molecule ascale $_settings(molecule-atomscale)"
     481    set _atomScalePending 0
     482}
     483
     484itcl::body Rappture::VtkViewer::SetBondScale {} {
     485    SendCmd "molecule bscale $_settings(molecule-bondscale)"
     486    set _bondScalePending 0
     487}
     488
     489itcl::body Rappture::VtkViewer::SetMoleculeOpacity {} {
     490    set _moleculeOpacityPending 0
     491    foreach dataset [CurrentDatasets -visible $_first] {
     492        foreach { dataobj comp } [split $dataset -] break
     493        if { [$dataobj type $comp] == "molecule" } {
     494            SetOpacity $dataset
     495        }
     496    }
     497}
     498
     499itcl::body Rappture::VtkViewer::SetPolydataOpacity {} {
     500    set _polydataOpacityPending 0
     501    foreach dataset [CurrentDatasets -visible $_first] {
     502        foreach { dataobj comp } [split $dataset -] break
     503        if { [$dataobj type $comp] == "polydata" } {
     504            SetOpacity $dataset
     505        }
     506    }
     507}
     508
     509itcl::body Rappture::VtkViewer::EventuallySetAtomScale { args } {
     510    if { !$_atomScalePending } {
     511        set _atomScalePending 1
     512        $_dispatcher event -after $_scaleDelay !atomscale
     513    }
     514}
     515
     516itcl::body Rappture::VtkViewer::EventuallySetBondScale { args } {
     517    if { !$_bondScalePending } {
     518        set _bondScalePending 1
     519        $_dispatcher event -after $_scaleDelay !bondscale
     520    }
     521}
     522
     523itcl::body Rappture::VtkViewer::EventuallySetMoleculeOpacity { args } {
     524    if { !$_moleculeOpacityPending } {
     525        set _moleculeOpacityPending 1
     526        $_dispatcher event -after $_scaleDelay !moleculeOpacity
     527    }
     528}
     529
     530itcl::body Rappture::VtkViewer::EventuallySetPolydataOpacity { args } {
     531    if { !$_polydataOpacityPending } {
     532        set _polydataOpacityPending 1
     533        $_dispatcher event -after $_scaleDelay !polydataOpacity
    452534    }
    453535}
     
    488570        lappend _dlist $dataobj
    489571    }
    490     set _allDataObjs($dataobj) 1
    491572    set _obj2ovride($dataobj-color) $params(-color)
    492573    set _obj2ovride($dataobj-width) $params(-width)
     
    612693itcl::body Rappture::VtkViewer::scale {args} {
    613694    foreach dataobj $args {
     695        foreach comp [$dataobj components] {
     696            set type [$dataobj type $comp]
     697            switch -- $type {
     698                "polydata" {
     699                    set _havePolydata 1
     700                }
     701                "glyphs" {
     702                    set _haveGlyphs 1
     703                }
     704                "molecule" {
     705                    set _haveMolecules 1
     706                }
     707            }
     708        }
    614709        array set bounds [limits $dataobj]
    615710        if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} {
     
    632727        if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} {
    633728            set _limits(zmax) $bounds(zmax)
     729        }
     730    }
     731    if { $_havePolydata } {
     732        if { ![$itk_component(main) exists "Mesh Settings"] } {
     733            if { [catch { BuildPolydataTab } errs ]  != 0 } {
     734                puts stderr "errs=$errs"
     735            }
     736        }
     737    }
     738    if { $_haveMolecules } {
     739        if { ![$itk_component(main) exists "Molecule Settings"]} {
     740            if { [catch { BuildMoleculeTab } errs ]  != 0 } {
     741                global errorInfo
     742                puts stderr "errs=$errs\nerrorInfo=$errorInfo"
     743            }
    634744        }
    635745    }
     
    876986        FixSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
    877987            axis-visible axis-labels \
    878             mesh-edges mesh-lighting mesh-opacity mesh-visible \
    879             mesh-wireframe
     988
     989        if { $_havePolydata } {
     990            FixSettings polydata-edges polydata-lighting polydata-opacity \
     991                polydata-visible polydata-wireframe
     992        }
    880993        SendCmd "imgflush"
    881994    }
     
    9171030            }
    9181031            lappend _obj2datasets($dataobj) $tag
     1032            SendCmd "dataset visible 1 $tag"
    9191033            if { [info exists _obj2ovride($dataobj-raise)] } {
    920                 SendCmd "dataset visible 1 $tag"
    921                 puts stderr "$count: dataset visible 1 $tag"
     1034                SetOpacity $tag
    9221035            }
    9231036        }
     
    9531066        Zoom reset
    9541067    }
    955     FixSettings molecule-representation
    9561068
    9571069    SendCmd "dataset maprange visible"
    958        
     1070
     1071    if { $_haveMolecules } {
     1072        #FixSettings molecule-representation
     1073    }
    9591074    set _reset 0
    9601075    global readyForNextFrame
     
    11971312    }
    11981313    switch -- $what {
    1199         "mesh-opacity" {
    1200             set val $_settings(mesh-opacity)
    1201             set sval [expr { 0.01 * double($val) }]
     1314        "polydata-opacity" {
    12021315            foreach dataset [CurrentDatasets -visible $_first] {
    12031316                foreach { dataobj comp } [split $dataset -] break
    1204                 set type [$dataobj type $comp]
    1205                 if { $type == "polydata" } {
    1206                     SendCmd "$type opacity $sval $dataset"
    1207                 }
    1208             }
    1209         }
    1210         "mesh-wireframe" {
    1211             set bool $_settings(mesh-wireframe)
     1317                if { [$dataobj type $comp] == "polydata" } {
     1318                    SetOpacity $dataset
     1319                }
     1320            }
     1321        }
     1322        "polydata-wireframe" {
     1323            set bool $_settings(polydata-wireframe)
    12121324            foreach dataset [CurrentDatasets -visible $_first] {
    12131325                foreach { dataobj comp } [split $dataset -] break
     
    12181330            }
    12191331        }
    1220         "mesh-visible" {
    1221             set bool $_settings(mesh-visible)
     1332        "polydata-visible" {
     1333            set bool $_settings(polydata-visible)
    12221334            foreach dataset [CurrentDatasets -visible $_first] {
    12231335                foreach { dataobj comp } [split $dataset -] break
     
    12281340            }
    12291341        }
    1230         "mesh-lighting" {
    1231             set bool $_settings(mesh-lighting)
     1342        "polydata-lighting" {
     1343            set bool $_settings(polydata-lighting)
    12321344            foreach dataset [CurrentDatasets -visible $_first] {
    12331345                foreach { dataobj comp } [split $dataset -] break
     
    12381350            }
    12391351        }
    1240         "mesh-edges" {
    1241             set bool $_settings(mesh-edges)
     1352        "polydata-edges" {
     1353            set bool $_settings(polydata-edges)
    12421354            foreach dataset [CurrentDatasets -visible $_first] {
    12431355                foreach { dataobj comp } [split $dataset -] break
     
    12481360            }
    12491361        }
    1250         "mesh-palette" {
     1362        "polydata-palette" {
    12511363            set palette [$itk_component(meshpalette) value]
    1252             set _settings(mesh-palette) $palette
     1364            set _settings(polydata-palette) $palette
    12531365            foreach dataset [CurrentDatasets -visible $_first] {
    12541366                foreach {dataobj comp} [split $dataset -] break
     
    12651377            foreach dataset [CurrentDatasets -visible $_first] {
    12661378                foreach { dataobj comp } [split $dataset -] break
    1267                 set type [$dataobj type $comp]
    1268                 if { $type == "molecule" } {
    1269                     SendCmd "molecule opacity $sval $dataset"
     1379                if { [$dataobj type $comp] == "molecule" } {
     1380                    SetOpacity $dataset
    12701381                }
    12711382            }
     
    13131424        "molecule-palette" {
    13141425            set palette [$itk_component(moleculepalette) value]
    1315             set _settings(molecule-palette) $palette
     1426            set _moelculeSettings(palette) $palette
    13161427            foreach dataset [CurrentDatasets -visible $_first] {
    13171428                foreach {dataobj comp} [split $dataset -] break
     
    13351446                "ballandstick" {
    13361447                    set rscale covalent
    1337                     set ashow 1
    1338                     set bshow 1
     1448                    set _settings(molecule-atoms-visible) 1
     1449                    set _settings(molecule-bonds-visible) 1
    13391450                    set bstyle cylinder
    1340                     set ascale 0.3
    1341                     set bscale 0.075
     1451                    set _settings(molecule-atomscale) 0.3
     1452                    set _settings(molecule-bondscale) 0.075
    13421453                }
    13431454                "balls" - "spheres" {
    13441455                    set rscale covalent
    1345                     set ashow 1
    1346                     set bshow 0
     1456                    set _settings(molecule-atoms-visible) 1
     1457                    set _settings(molecule-bonds-visible) 0
    13471458                    set bstyle cylinder
    1348                     set ascale 0.3
    1349                     set bscale 0.075
     1459                    set _settings(molecule-atomscale) 0.3
     1460                    set _settings(molecule-bondscale) 0.075
    13501461                }
    13511462                "sticks" {
    13521463                    set rscale none
    1353                     set ashow 1
    1354                     set bshow 1
     1464                    set _settings(molecule-atoms-visible) 1
     1465                    set _settings(molecule-bonds-visible) 1
    13551466                    set bstyle cylinder
    1356                     set ascale 0.075
    1357                     set bscale 0.075
     1467                    set _settings(molecule-atomscale) 0.075
     1468                    set _settings(molecule-bondscale) 0.075
    13581469                }
    13591470                "spacefilling" {
    13601471                    set rscale van_der_waals
    1361                     set ashow 1
    1362                     set bshow 0
     1472                    set _settings(molecule-atoms-visible) 1
     1473                    set _settings(molecule-bonds-visible) 0
    13631474                    set bstyle cylinder
    1364                     set ascale 1.0
    1365                     set bscale 0.075
     1475                    set _settings(molecule-atomscale) 1.0
     1476                    set _settings(molecule-bondscale) 0.075
    13661477                }
    13671478                "rods"  {
    13681479                    set rscale none
    1369                     set ashow 1
    1370                     set bshow 1
     1480                    set _settings(molecule-atoms-visible) 1
     1481                    set _settings(molecule-bonds-visible) 1
    13711482                    set bstyle cylinder
    1372                     set ascale 0.1
    1373                     set bscale 0.1
     1483                    set _settings(molecule-atomscale) 0.1
     1484                    set _settings(molecule-bondscale) 0.1
    13741485                }
    13751486                "wireframe" - "lines" {
    13761487                    set rscale none
    1377                     set ashow 0
    1378                     set bshow 1
     1488                    set _settings(molecule-atoms-visible) 0
     1489                    set _settings(molecule-bonds-visible) 1
    13791490                    set bstyle line
    1380                     set ascale 1.0
    1381                     set bscale 1.0
     1491                    set _settings(molecule-atomscale) 1.0
     1492                    set _settings(molecule-bondscale) 1.0
    13821493                }
    13831494                default {
     
    13901501                if { $type == "molecule" } {
    13911502                    SendCmd [subst {molecule rscale $rscale $dataset
    1392 molecule atoms $ashow $dataset
    1393 molecule bonds $bshow $dataset
     1503molecule ascale $_settings(molecule-atomscale) $dataset
     1504molecule bscale $_settings(molecule-bondscale) $dataset
    13941505molecule bstyle $bstyle $dataset
    1395 molecule ascale $ascale $dataset
    1396 molecule bscale $bscale $dataset}]
     1506molecule atoms $_settings(molecule-atoms-visible) $dataset
     1507molecule bonds $_settings(molecule-bonds-visible) $dataset}]
    13971508                }
    13981509            }
     
    15701681        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    15711682    }
    1572     if { ![info exists _settings(mesh-opacity)] } {
    1573         set _settings(mesh-opacity) $style(-opacity)
    1574     }
    1575     set max $_settings(mesh-opacity)
     1683    if { ![info exists _settings(polydata-opacity)] } {
     1684        set _settings(polydata-opacity) $style(-opacity)
     1685    }
     1686    set max $_settings(polydata-opacity)
    15761687
    15771688    set wmap "0.0 1.0 1.0 1.0"
     
    16011712
    16021713itcl::body Rappture::VtkViewer::limits { dataobj } {
    1603     puts stderr components=[$dataobj components]
    16041714    foreach comp [$dataobj components] {
    16051715        set tag $dataobj-$comp
     
    16881798}
    16891799
    1690 itcl::body Rappture::VtkViewer::BuildMeshTab {} {
     1800itcl::body Rappture::VtkViewer::BuildPolydataTab {} {
    16911801
    16921802    set fg [option get $itk_component(hull) font Font]
     
    17001810    checkbutton $inner.mesh \
    17011811        -text "Show Mesh" \
    1702         -variable [itcl::scope _settings(mesh-visible)] \
    1703         -command [itcl::code $this AdjustSetting mesh-visible] \
     1812        -variable [itcl::scope _settings(polydata-visible)] \
     1813        -command [itcl::code $this AdjustSetting polydata-visible] \
    17041814        -font "Arial 9" -anchor w
    17051815
    17061816    checkbutton $inner.wireframe \
    17071817        -text "Show Wireframe" \
    1708         -variable [itcl::scope _settings(mesh-wireframe)] \
    1709         -command [itcl::code $this AdjustSetting mesh-wireframe] \
     1818        -variable [itcl::scope _settings(polydata-wireframe)] \
     1819        -command [itcl::code $this AdjustSetting polydata-wireframe] \
    17101820        -font "Arial 9" -anchor w
    17111821
    17121822    checkbutton $inner.lighting \
    17131823        -text "Enable Lighting" \
    1714         -variable [itcl::scope _settings(mesh-lighting)] \
    1715         -command [itcl::code $this AdjustSetting mesh-lighting] \
     1824        -variable [itcl::scope _settings(polydata-lighting)] \
     1825        -command [itcl::code $this AdjustSetting polydata-lighting] \
    17161826        -font "Arial 9" -anchor w
    17171827
    17181828    checkbutton $inner.edges \
    17191829        -text "Show Edges" \
    1720         -variable [itcl::scope _settings(mesh-edges)] \
    1721         -command [itcl::code $this AdjustSetting mesh-edges] \
     1830        -variable [itcl::scope _settings(polydata-edges)] \
     1831        -command [itcl::code $this AdjustSetting polydata-edges] \
    17221832        -font "Arial 9" -anchor w
    17231833
     
    17461856    $itk_component(meshpalette) value "BCGYR"
    17471857    bind $inner.palette <<Value>> \
    1748         [itcl::code $this AdjustSetting mesh-palette]
     1858        [itcl::code $this AdjustSetting polydata-palette]
    17491859
    17501860    label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
    17511861    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1752         -variable [itcl::scope _settings(mesh-opacity)] \
     1862        -variable [itcl::scope _settings(polydata-opacity)] \
    17531863        -width 10 \
    17541864        -showvalue off \
    1755         -command [itcl::code $this AdjustSetting mesh-opacity]
     1865        -command [itcl::code $this AdjustSetting polydata-opacity]
    17561866
    17571867    blt::table $inner \
     
    21232233    $inner.cell select
    21242234
     2235    label $inner.atomscale_l -text "Atom Scale" -font "Arial 9"
     2236    ::scale $inner.atomscale -width 15 -font "Arial 7" \
     2237        -from 0.0 -to 2.0 -resolution 0.05 -label "" \
     2238        -showvalue true -orient horizontal \
     2239        -command [itcl::code $this EventuallyAtomScale] \
     2240        -variable [itcl::scope _settings(molecule-atomscale)]
     2241    $inner.atomscale set $_settings(molecule-atomscale)
     2242    Rappture::Tooltip::for $inner.atomscale \
     2243        "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."
     2244
     2245    label $inner.bondscale_l -text "Bond Scale" -font "Arial 9"
     2246    ::scale $inner.bondscale -width 15 -font "Arial 7" \
     2247        -from 0.0 -to 1.0 -resolution 0.025 -label "" \
     2248        -showvalue true -orient horizontal \
     2249        -command [itcl::code $this EventuallyBondScale] \
     2250        -variable [itcl::scope _settings(molecule-bondscale)]
     2251    Rappture::Tooltip::for $inner.bondscale \
     2252        "Adjust scale of bonds (sticks)."
     2253    $inner.bondscale set $_settings(molecule-bondscale)
     2254
    21252255    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    21262256    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    21272257        -variable [itcl::scope _settings(molecule-opacity)] \
    2128         -width 10 \
    2129         -showvalue off \
    2130         -command [itcl::code $this AdjustSetting molecule-opacity]
     2258        -width 15 -font "Arial 7" \
     2259        -showvalue on \
     2260        -command [itcl::code $this EventuallyMoleculeOpacity]
    21312261
    21322262    blt::table $inner \
    2133         0,0 $inner.molecule -anchor w -pady {1 0} \
    2134         1,0 $inner.label -anchor w -pady {1 0} \
    2135         2,0 $inner.edges -anchor w -pady {1 0} \
    2136         3,0 $inner.rep_l -anchor w -pady { 2 0 } \
    2137         4,0 $inner.rep -anchor w  \
    2138         5,0 $inner.palette_l -anchor w -pady 2 \
    2139         6,0 $inner.palette   -fill x   -pady 2  \
    2140         7,0 $inner.opacity_l -anchor w -pady 2 \
    2141         8,0 $inner.opacity   -fill x   -pady 2
     2263        0,0 $inner.molecule    -anchor w -pady {1 0} \
     2264        1,0 $inner.label       -anchor w -pady {1 0} \
     2265        2,0 $inner.edges       -anchor w -pady {1 0} \
     2266        3,0 $inner.rep_l       -anchor w -pady { 2 0 } \
     2267        4,0 $inner.rep         -fill x    -pady 2 \
     2268        5,0 $inner.palette_l   -anchor w  -pady 0 \
     2269        6,0 $inner.palette     -fill x    -padx 2 \
     2270        7,0 $inner.atomscale_l -anchor w -pady {3 0} \
     2271        8,0 $inner.atomscale   -fill x    -padx 2 \
     2272        9,0 $inner.bondscale_l -anchor w -pady {3 0} \
     2273        10,0 $inner.bondscale  -fill x   -padx 2 \
     2274        11,0 $inner.opacity_l  -anchor w -pady {3 0} \
     2275        12,0 $inner.opacity    -fill x    -padx 2
    21422276   
    21432277    blt::table configure $inner r* -resize none
    2144     blt::table configure $inner r9 -resize expand
     2278    blt::table configure $inner r13 -resize expand
    21452279}
    21462280
     
    21842318}
    21852319
    2186 itcl::body Rappture::VtkViewer::ConvertToVtkData { dataobj comp } {
    2187     foreach { x1 x2 xN y1 y2 yN } [$dataobj mesh $comp] break
    2188     set values [$dataobj values $comp]
    2189     append out "# vtk DataFile Version 2.0 \n"
    2190     append out "Test data \n"
    2191     append out "ASCII \n"
    2192     append out "DATASET STRUCTURED_POINTS \n"
    2193     append out "DIMENSIONS $xN $yN 1 \n"
    2194     append out "ORIGIN 0 0 0 \n"
    2195     append out "SPACING 1 1 1 \n"
    2196     append out "POINT_DATA [expr $xN * $yN] \n"
    2197     append out "SCALARS field double 1 \n"
    2198     append out "LOOKUP_TABLE default \n"
    2199     append out [join $values "\n"]
    2200     append out "\n"
    2201     return $out
    2202 }
    2203 
    22042320itcl::body Rappture::VtkViewer::GetVtkData { args } {
    22052321    set bytes ""
     
    22092325            set contents [$dataobj data $comp]
    22102326            append bytes "$contents\n"
    2211             append bytes "\# End of VTK file\n\n"
    2212         }
    2213     }
    2214     return [list .txt $bytes]
     2327        }
     2328    }
     2329    return [list .vtk $bytes]
    22152330}
    22162331
     
    22742389        set settings(-wireframe) 1
    22752390    }
    2276     if { $type == "glyphs" } {
    2277         array set settings {
    2278             -color \#808080
    2279             -gscale 1
    2280             -edges 0
    2281             -edgecolor black
    2282             -linewidth 1.0
    2283             -opacity 1.0
    2284             -wireframe 0
    2285             -lighting 1
    2286             -visible 1
    2287         }
    2288         set shape [$dataobj shape $comp]
    2289         array set settings $style
    2290         SendCmd "glyphs add $shape $tag"
    2291         SendCmd "glyphs normscale 0 $tag"
    2292         SendCmd "glyphs gscale $settings(-gscale) $tag"
    2293         SendCmd "glyphs wireframe $settings(-wireframe) $tag"
    2294         #SendCmd "glyphs ccolor [Color2RGB $settings(-color)] $tag"
    2295         #SendCmd "glyphs colormode ccolor {} $tag"
    2296         SendCmd "glyphs gorient 0 {} $tag"
    2297         SendCmd "glyphs smode vcomp {} $tag"
    2298         SendCmd "glyphs opacity $settings(-opacity) $tag"
    2299         SendCmd "glyphs visible $settings(-visible) $tag"
    2300         set _settings(glyphs-wireframe) $settings(-wireframe)
    2301         set _haveGlyphs 1
    2302     } elseif { $type == "molecule" } {
    2303         SendCmd "molecule add $tag"
    2304         SendCmd "molecule rscale van_der_waals $tag"
    2305         set _haveMolecules 1
    2306     } else {
    2307         array set settings {
    2308             -color \#6666FF
    2309             -edges 1
    2310             -edgecolor black
    2311             -linewidth 1.0
    2312             -opacity 1.0
    2313             -wireframe 0
    2314             -lighting 1
    2315             -visible 1
    2316         }
    2317         array set settings $style
    2318         SendCmd "polydata add $tag"
    2319         SendCmd "polydata visible $settings(-visible) $tag"
    2320         set _settings(mesh-visible) $settings(-visible)
    2321         SendCmd "polydata edges $settings(-edges) $tag"
    2322         set _settings(mesh-edges) $settings(-edges)
    2323         SendCmd "polydata color [Color2RGB $settings(-color)] $tag"
    2324         SendCmd "polydata lighting $settings(-lighting) $tag"
    2325         set _settings(mesh-lighting) $settings(-lighting)
    2326         SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag"
    2327         SendCmd "polydata linewidth $settings(-linewidth) $tag"
    2328         SendCmd "polydata opacity $settings(-opacity) $tag"
    2329         set _settings(mesh-opacity) $settings(-opacity)
    2330         SendCmd "polydata wireframe $settings(-wireframe) $tag"
    2331         set _settings(mesh-wireframe) $settings(-wireframe)
     2391    switch -- $type {
     2392        "glyphs" {
     2393            array set settings {
     2394                -color \#808080
     2395                -gscale 1
     2396                -edges 0
     2397                -edgecolor black
     2398                -linewidth 1.0
     2399                -opacity 1.0
     2400                -wireframe 0
     2401                -lighting 1
     2402                -visible 1
     2403            }
     2404            set shape [$dataobj shape $comp]
     2405            array set settings $style
     2406            SendCmd "glyphs add $shape $tag"
     2407            SendCmd "glyphs normscale 0 $tag"
     2408            SendCmd "glyphs gscale $settings(-gscale) $tag"
     2409            SendCmd "glyphs wireframe $settings(-wireframe) $tag"
     2410            #SendCmd "glyphs ccolor [Color2RGB $settings(-color)] $tag"
     2411            #SendCmd "glyphs colormode ccolor {} $tag"
     2412            SendCmd "glyphs gorient 0 {} $tag"
     2413            SendCmd "glyphs smode vcomp {} $tag"
     2414            SendCmd "glyphs opacity $settings(-opacity) $tag"
     2415            SendCmd "glyphs visible $settings(-visible) $tag"
     2416            set _settings(glyphs-wireframe) $settings(-wireframe)
     2417        }
     2418        "molecule" {
     2419            SendCmd "molecule add $tag"
     2420            SendCmd "molecule rscale van_der_waals $tag"
     2421            set _haveMolecules 1
     2422        }
     2423        "polydata" {
     2424            array set settings {
     2425                -color \#6666FF
     2426                -edges 1
     2427                -edgecolor black
     2428                -linewidth 1.0
     2429                -opacity 1.0
     2430                -wireframe 0
     2431                -lighting 1
     2432                -visible 1
     2433            }
     2434            array set settings $style
     2435            SendCmd "polydata add $tag"
     2436            SendCmd "polydata visible $settings(-visible) $tag"
     2437            set _settings(polydata-visible) $settings(-visible)
     2438            SendCmd "polydata edges $settings(-edges) $tag"
     2439            set _settings(polydata-edges) $settings(-edges)
     2440            SendCmd "polydata color [Color2RGB $settings(-color)] $tag"
     2441            SendCmd "polydata lighting $settings(-lighting) $tag"
     2442            set _settings(polydata-lighting) $settings(-lighting)
     2443            SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag"
     2444            SendCmd "polydata linewidth $settings(-linewidth) $tag"
     2445            SendCmd "polydata opacity $settings(-opacity) $tag"
     2446            set _settings(polydata-opacity) $settings(-opacity)
     2447            SendCmd "polydata wireframe $settings(-wireframe) $tag"
     2448            set _settings(polydata-wireframe) $settings(-wireframe)
     2449            set havePolyData 1
     2450        }
    23322451    }
    23332452    SetColormap $dataobj $comp
     
    25172636    set _view(zoom) 1.0
    25182637}
     2638
     2639itcl::body Rappture::VtkViewer::SetOpacity { dataset } {
     2640    foreach {dataobj comp} [split $dataset -] break
     2641    set type [$dataobj type $comp]
     2642    set val $_settings($type-opacity)
     2643    set sval [expr { 0.01 * double($val) }]
     2644    if { !$_obj2ovride($dataobj-raise) } {
     2645        # This is wrong.  Need to figure out why raise isn't set with 1
     2646        #set sval [expr $sval * .6]
     2647    }
     2648    SendCmd "$type opacity $sval $dataset"
     2649}
  • branches/1.3/gui/scripts/xylegend.tcl

    r3765 r3785  
    563563        incr _lastColorIndex -1
    564564        set color [lindex $_autocolors $_lastColorIndex]
    565         $_graph element configure $elem -color $color
     565        if { [$_graph element type $elem] == "bar" } {
     566            $_graph element configure $elem -background $color \
     567                -foreground $color
     568        } else {
     569            $_graph element configure $elem -color $color
     570        }
    566571        set im [$itk_component(legend) entry cget $node -icon]
    567572        $_graph legend icon $elem $im
  • branches/1.3/gui/scripts/xyresult.tcl

    r3765 r3785  
    237237        -brightness 0
    238238        -width 1
    239         -type "line"
    240239        -barwidth 1
    241240        -raise 0
     241        -type "line"
    242242        -linestyle solid
    243243        -description ""
     
    247247    # settings list passed into this routoue.
    248248    array set params [$dataobj hints style]
     249    set type [$dataobj hints type]
     250    if { $type == "" } {
     251        set type "line"
     252    }
    249253    foreach {opt val} $settings {
    250254        if {![info exists params($opt)]} {
     
    255259
    256260    # if type is set to "scatter", then override the width
    257     if {"scatter" == $params(-type)} {
     261    if { $type == "scatter" } {
    258262        set params(-width) 0
    259263    }
     
    296300    }
    297301
    298     set dataobj2raise($dataobj) $params(-raise)
     302    set _dataobj2raise($dataobj) $params(-raise)
    299303
    300304    set g $itk_component(plot)
     
    304308    set raise $params(-raise)
    305309    set desc $params(-description)
    306     set type $params(-type)
    307310    set barwidth $params(-barwidth)
    308311    foreach {mapx mapy} [GetAxes $dataobj] break
     
    311314        if { [info exists _comp2elem($tag)] } {
    312315            set elem $_comp2elem($tag)
    313             switch -- $type {
     316            # Ignore -type, it's already been set
     317            switch -- [$g element type $elem] {
    314318                "line" - "scatter" {
    315                     $g element configure $elem \
     319                    $g line configure $elem \
    316320                        -linewidth $lwidth \
    317321                        -dashes $dashes -hide no
     
    653657        set label [$dataobj hints label]
    654658        lappend label2elem($label) $elem
     659        if { $_dataobj2raise($dataobj) } {
     660            lappend $g element raise $elem
     661        }
    655662    }
    656663    # Then relabel elements with the same label, using the simulation number.
     
    16211628        set label [$dataobj hints label]
    16221629        array set params [$dataobj hints style]
     1630        set type [$dataobj hints type]
    16231631        # Default
    16241632        if {[info exists params(-color)]} {
     
    16271635            set color black
    16281636        }
    1629         if {[info exists parmas(-type)]} {
    1630             set type $params(-type)
    1631         } else {
     1637        if { $type == "" } {
    16321638            set type "line"
    16331639        }
     
    16661672                set pixels 6
    16671673            }
    1668             set elem "elem[incr _nextElement]"
     1674            set elem "$type[incr _nextElement]"
    16691675            set _elem2comp($elem) $tag
    16701676            set _comp2elem($tag) $elem
     
    16731679            switch -- $type {
    16741680                "line" - "scatter" {
    1675                     $g element create $elem \
     1681                    $g line create $elem \
    16761682                        -x $xv -y $yv \
    16771683                        -symbol $sym \
     
    16891695                        -barwidth $barwidth \
    16901696                        -label $label \
    1691                         -color $color \
     1697                        -foreground $color \
     1698                        -background $color \
    16921699                        -mapx $mapx \
    16931700                        -mapy $mapy \
Note: See TracChangeset for help on using the changeset viewer.