Changeset 2989


Ignore:
Timestamp:
May 1, 2012, 11:02:22 PM (12 years ago)
Author:
gah
Message:

additions for drawing entry

Location:
branches/blt4
Files:
2 edited

Legend:

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

    r2988 r2989  
    2323    private variable _cname2id
    2424    private variable _cname2image
     25    private variable _name2path
    2526    private variable _drawingHeight 0
    2627    private variable _drawingWidth 0
    2728    private variable _owner
     29    private variable _parser ""
    2830    private variable _path
    2931    private variable _showing ""
     
    4345    public method tooltip {}
    4446
     47    private method Activate { tag }
    4548    private method AdjustDrawingArea { xAspect yAspect }
     49    private method Deactivate { tag }
    4650    private method Highlight { tag }
     51    private method InitSubstitutions {}
     52    private method Invoke { name x y }
     53    private method ParseBackground {}
    4754    private method ParseDescription {}
    4855    private method ParseGrid { cpath cname }
     
    5461    private method ParseRectangle { cpath cname }
    5562    private method ParseScreenCoordinates { values }
    56     private method ParseBackground {}
    5763    private method ParseSubstitutions {}
    5864    private method ParseText { cpath cname }
     
    6167    private method ScreenX { x }
    6268    private method ScreenY { y }
    63     private method Activate { tag }
    64     private method Deactivate { tag }
    65     private method Invoke { name x y }
     69    private method XmlGet { path }
     70    private method Withdraw {}
    6671}
    6772
     
    142147        image delete $_cname2image($name)
    143148    }
     149    array unset _name2path
     150    array unset _cname2id
     151    array unset _cnames2controls
     152    array unset _cname2image
     153   
    144154    # Recompute the size of the canvas/drawing area
    145155    set _canvasWidth [winfo width $itk_component(drawing)]
     
    214224    }
    215225    # Coords
    216     set xcoords [$_owner xml get $cpath.xcoords]
     226    set xcoords [XmlGet $cpath.xcoords]
    217227    set xcoords [string trim $xcoords]
    218     set ycoords [$_owner xml get $cpath.ycoords]
     228    set ycoords [XmlGet $cpath.ycoords]
    219229    set ycoords [string trim $ycoords]
    220230    if { $ycoords == "" } {
     
    263273        if { [info exists attr2option($attr)] } {
    264274            set option $attr2option($attr)
    265             set value [$_owner xml get $cpath.$attr]
     275            set value [XmlGet $cpath.$attr]
    266276            set options($option) $value
    267277        }
     
    299309        if { [info exists attr2option($attr)] } {
    300310            set option $attr2option($attr)
    301             set value [$_owner xml get $cpath.$attr]
     311            set value [XmlGet $cpath.$attr]
    302312            set options($option) $value
    303313        } elseif { [string match "controls*" $attr] } {
    304             set value [$_owner xml get $cpath.$attr]
     314            set value [XmlGet $cpath.$attr]
    305315            lappend _cname2controls($cname) $value
    306316        }
    307317    }
    308318    # Coordinates
    309     set coords [$_owner xml get $cpath.coords]
     319    set coords [XmlGet $cpath.coords]
    310320    set coords [ScreenCoords $coords]
    311321    if { $coords == "" } {
     
    347357    # Coords
    348358    set coords {}
    349     set coords [$_owner xml get $cpath.coords]
     359    set coords [XmlGet $cpath.coords]
    350360    set coords [string trim $coords]
    351361    if { $coords == "" } {
     
    359369        if { [info exists attr2option($attr)] } {
    360370            set option $attr2option($attr)
    361             set value [$_owner xml get $cpath.$attr]
     371            set value [XmlGet $cpath.$attr]
    362372            set options($option) $value
    363373        }
     
    389399        if { [info exists attr2option($attr)] } {
    390400            set option $attr2option($attr)
    391             set value [$_owner xml get $cpath.$attr]
     401            set value [XmlGet $cpath.$attr]
    392402            set options($option) $value
    393403        }
     
    395405    # Coordinates
    396406    set coords {}
    397     set coords [$_owner xml get $cpath.coords]
     407    set coords [XmlGet $cpath.coords]
    398408    set coords [string trim $coords]
    399409    if { $coords == "" } {
     
    420430        if { [info exists attr2option($attr)] } {
    421431            set option $attr2option($attr)
    422             set value [$_owner xml get $cpath.$attr]
     432            set value [XmlGet $cpath.$attr]
    423433            set options($option) $value
    424434        }
     
    426436    # Coordinates
    427437    set coords {}
    428     set coords [$_owner xml get $cpath.coords]
     438    set coords [XmlGet $cpath.coords]
    429439    set coords [ScreenCoords $coords]
    430440    if { [llength $coords] == 2 } {
    431441        foreach { x1 y1 } $coords break
    432         set w [$_owner xml get $cpath.width]
     442        set w [XmlGet $cpath.width]
    433443        if { $w == "" || ![string is number $w] || $w <= 0.0 } {
    434444            set width [expr [image width $img] / 4]
     
    436446            set width [expr [ScreenX $w] - [ScreenX 0]]
    437447        }
    438         set h [$_owner xml get $cpath.height]
     448        set h [XmlGet $cpath.height]
    439449        if { $h == "" || ![string is number $h] || $h <= 0.0 } {
    440450            set height [expr [image height $img] / 4]
     
    478488        set y1 0
    479489    }
    480     set contents [$_owner xml get $cpath.contents]
     490    set contents [$XmlGet $cpath.contents]
    481491    if { [string compare -length 5 $contents "file:"] } {
    482492        set fileName [string range $contents 5 end]
     
    509519    }
    510520    # Coords
    511     set coords {}
    512     set coords [$_owner xml get $cpath.coords]
     521    set coords [$XmlGet $cpath.coords]
    513522    set coords [string trim $coords]
    514523    if { $coords == "" } {
     
    525534        if { [info exists attr2option($attr)] } {
    526535            set option $attr2option($attr)
    527             set value [$_owner xml get $cpath.$attr]
     536            set value [XmlGet $cpath.$attr]
    528537            set options($option) $value
    529538        }
     
    555564        if { [info exists attr2option($attr)] } {
    556565            set option $attr2option($attr)
    557             set value [$_owner xml get $cpath.$attr]
     566            set value [XmlGet $cpath.$attr]
    558567            set options($option) $value
    559568        }
    560569    }
    561570    # Coordinates
    562     set coords {}
    563     set coords [$_owner xml get $cpath.coords]
     571    set coords [XmlGet $cpath.coords]
    564572    set coords [string trim $coords]
    565573    if { $coords == "" } {
     
    593601        if { [info exists attr2option($attr)] } {
    594602            set option $attr2option($attr)
    595             set value [$_owner xml get $cpath.$attr]
     603            set value [XmlGet $cpath.$attr]
    596604            set options($option) $value
    597605        }
    598606    }
    599607    # Coords
    600     set coords {}
    601     set coords [$_owner xml get $cpath.coords]
     608    set coords [XmlGet $cpath.coords]
    602609    set coords [string trim $coords]
    603610    if { $coords == "" } {
     
    726733            "color*" {
    727734                #  Background color of the drawing canvas (default white)
    728                 set value [$_owner xml get $_path.background.$elem]
     735                set value [XmlGet $_path.background.$elem]
    729736                $itk_component(drawing) configure -background $value
    730737            }
    731738            "aspect*" {
    732                 set value [$_owner xml get $_path.background.$elem]
     739                set value [XmlGet $_path.background.$elem]
    733740                foreach { xAspect yAspect } $value break
    734741                AdjustDrawingArea $xAspect $yAspect
    735742            }
    736743            "coordinates*" {
    737                 set value [$_owner xml get $_path.background.$elem]
     744                set value [XmlGet $_path.background.$elem]
    738745                ParseScreenCoordinates $value
    739746            }
     
    748755        }
    749756        set varPath $_path.substitutions.$var
     757        set map ""
     758        set name ""
     759        set path ""
    750760        foreach elem [$_owner xml children $varPath] {
    751             set map ""
    752             set name ""
    753             set path ""
    754761            switch -glob -- $elem {
    755                 #  Background color of the drawing canvas (default white)
    756762                "name*" {
    757                     set name [$_owner xml get $varPath.$elem]
     763                    set name [XmlGet $varPath.$elem]
    758764                }
    759765                "path*" {
    760                     set path [$_owner xml get $varPath.$elem]
     766                    set path [XmlGet $varPath.$elem]
    761767                }
    762768                "map*" {
    763                     set from [$_owner xml get $varPath.$elem.from]
    764                     set to [$_owner xml get $varPath.$elem.to]
     769                    set from [XmlGet $varPath.$elem.from]
     770                    set to [Xmlget $varPath.$elem.to]
    765771                    if { $from == "" || $to == "" } {
    766772                        puts stderr "empty translation in map table \"$varPath\""
     
    769775                }
    770776            }
    771             if { $name == "" } {
    772                 puts stderr \
    773                     "no name defined for substituion variable \"$varPath\""
    774                 continue
    775             }
    776             if { [info exists _name2path($name)] } {
    777                 puts stderr \
    778                     "substitution variable \"$name\" already defined"
    779                 continue
    780             }           
    781             set _name2path($name) $path
    782             if { $path == "" } {
    783                 puts stderr \
    784                     "no path defined for substituion variable \"$varPath\""
    785                 continue
    786             }
    787             set _name2map($name) $map
    788         }
    789     }
     777        }
     778        if { $name == "" } {
     779            puts stderr \
     780                "no name defined for substituion variable \"$varPath\""
     781            continue
     782        }
     783        if { [info exists _name2path($name)] } {
     784            puts stderr \
     785                "substitution variable \"$name\" already defined"
     786            continue
     787        }               
     788        set _name2path($name) $path
     789        if { $path == "" } {
     790            puts stderr \
     791                "no path defined for substituion variable \"$varPath\""
     792            continue
     793        }
     794        set _name2map($name) $map
     795    }
     796    InitSubstitutions
    790797}
    791798
     
    803810    if { ![winfo exists $popup] } {
    804811        # Create a popup for the print dialog
    805         Rappture::Balloon $popup -title "Change values..."
     812        Rappture::Balloon $popup -title "Change values..." \
     813            -deactivatecommand [itcl::code $this Withdraw]
    806814        set inner [$popup component inner]
    807815        Rappture::DrawingControls $inner.controls $_owner \
     
    823831}
    824832
     833#
     834# Invoke --
     835#
     836itcl::body Rappture::DrawingEntry::Withdraw {} {
     837    Redraw
     838}
    825839
    826840# ----------------------------------------------------------------------
     
    837851    return ""
    838852}
     853
     854
     855#
     856# InitSubstitutions --
     857#
     858itcl::body Rappture::DrawingEntry::InitSubstitutions {} {
     859    # Load a new parser with the variables representing the substitution
     860    set _parser [interp create -safe]
     861    foreach name [array names _name2path] {
     862        set path $_name2path($name)
     863        set w [$_owner widgetfor $path]
     864        if { $w != "" } {
     865            set value [$w value]
     866        } else {
     867            set value ""
     868        }
     869        $_parser eval [list set $name $value]
     870    }
     871}
     872
     873itcl::body Rappture::DrawingEntry::XmlGet { path } {
     874    set value [$_owner xml get $path]
     875    if { $_parser == "" } {
     876        return $value
     877    }
     878    return [$_parser eval [list subst -nocommands $value]]
     879}
     880
  • branches/blt4/packages/vizservers/nanoscale/server2.c

    r2674 r2989  
    461461                /* Set the screen number in the DISPLAY variable. */
    462462                display[3] = screenNum + '0';
    463                 setenv("DISPLAY", display, 0);
     463                setenv("DISPLAY", display, 1);
    464464                /* Set the enviroment, if necessary. */
    465465                for (i = 0; i < serverPtr->numEnvArgs; i += 2) {
    466                     setenv(serverPtr->envArgs[i], serverPtr->envArgs[i+1], 0);
     466                    setenv(serverPtr->envArgs[i], serverPtr->envArgs[i+1], 1);
    467467                }
    468468                INFO("Executing %s: client %s, %s on DISPLAY=%s",
Note: See TracChangeset for help on using the changeset viewer.