Changeset 1742


Ignore:
Timestamp:
May 26, 2010 7:21:24 PM (14 years ago)
Author:
mmc
Message:

Added preview of outputs to the irappture builder. Fixed a problem
with the file chooser for the "save as" dialog. Added a distinction
between errors and warnings when looking for problems in the tool
definition.

Fixed a few problems in RapptureGUI affecting the scroller and the
way it refreshes itself when the frame within it suddenly shrinks.
Fixed the histogram to avoid errors when the histogram data is
empty. Fixed the analyzer so you can create it without setting
the -notebookpage option. All of these errors showed up in the
irappture builder.

Location:
trunk
Files:
3 added
8 edited

Legend:

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

    r1663 r1742  
    2424option add *Analyzer.simControlActiveBackground #ffffcc widgetDefault
    2525option add *Analyzer.simControlActiveOutline black widgetDefault
    26 option add *Analyzer.notebookpage "about" widgetDefault
    2726
    2827option add *Analyzer.font \
     
    4746    itk_option define -simcontrolactivebackground simControlActiveBackground Background ""
    4847    itk_option define -holdwindow holdWindow HoldWindow ""
    49     itk_option define -notebookpage notebookPage NotebookPage ""
     48    itk_option define -notebookpage notebookPage NotebookPage "about"
    5049
    5150    constructor {tool args} { # defined below }
  • trunk/gui/scripts/histogram.tcl

    r1550 r1742  
    6767    itcl::delete object $_hist
    6868    # don't destroy the _xmlobj! we don't own it!
    69     blt::vector destroy $_widths $_heights $_locations
     69    if {"" != $_widths} {
     70        blt::vector destroy $_widths
     71    }
     72    if {"" != $_heights} {
     73        blt::vector destroy $_heights
     74    }
     75    if {"" != $_locations} {
     76        blt::vector destroy $_locations
     77    }
    7078}
    7179
     
    155163            error "bad option \"$which\": should be x, xlin, xlog, y, ylin, ylog"
    156164        }
     165    }
     166
     167    if {"" == $vname} {
     168        return {0 1}
    157169    }
    158170    $vname dup tmp
  • trunk/gui/scripts/historesult.tcl

    r1402 r1742  
    626626        set yv [$xydata heights]
    627627        set zv [$xydata widths]
     628
     629        if {"" == $xv} {
     630            continue
     631        }
    628632       
    629633        if {[info exists _histo2color($xydata)]} {
  • trunk/gui/scripts/scroller.tcl

    r1728 r1742  
    307307            set h [winfo reqheight $_frame.f]
    308308            $_frame configure -scrollregion [list 0 0 $w $h]
     309            _fixframe outer
    309310            _lock reset x
    310311            _lock reset y
  • trunk/instant/Makefile.in

    r1730 r1742  
    3030                $(srcdir)/main.tcl \
    3131                $(srcdir)/objects.tcl \
     32                $(srcdir)/objpath.tcl \
    3233                $(srcdir)/slideframes.tcl \
    3334                $(srcdir)/tweener.tcl
     
    3738                $(srcdir)/images/dragm.xbm \
    3839                $(srcdir)/images/treemn.png \
    39                 $(srcdir)/images/treepl.png
     40                $(srcdir)/images/treepl.png \
     41                $(srcdir)/images/warn24.png \
     42                $(srcdir)/images/err24.png
    4043
    4144OBJECTFILES     = \
  • trunk/instant/filmstrip.tcl

    r1728 r1742  
    137137            -background $itk_option(-titlebackground) \
    138138            -text $params(-title) -tags [list $name:all $name:title]
    139 puts "created placard for $params(-title)"
    140139        foreach {x0 y0 x1 y1} [$itk_component(strip) bbox $name:title] break
    141140        set wd [expr {$x1-$x0}]
  • trunk/instant/hierlist.tcl

    r1739 r1742  
    2929    itk_option define -icon icon Icon ""
    3030    itk_option define -font font Font ""
    31     itk_option define -title title Title "%type: ~%id"
     31    itk_option define -title title Title "%type: %id"
    3232    itk_option define -selectbackground selectBackground Foreground ""
    3333    itk_option define -droplinecolor dropLineColor Foreground ""
     
    9292    # this widget exports nodes via drag-n-drop
    9393    dragdrop source $itk_component(area)
    94 
    95     itk_component add editor {
    96         Rappture::Editor $itk_interior.editor
    97     }
    9894
    9995    set _imh(open) [image create photo]
     
    158154        }
    159155        set {
     156            # changed an option -- may be %type or %id -- update display
     157            $_dispatcher event -idle !redraw
     158
    160159            return [eval $_tree set $args]
    161160        }
     
    339338        catch {unset data}
    340339        array set data [$_tree get $n]
    341         set str $itk_option(-title)
    342340        set xpos $xtxt
    343         while {[regexp -indices {~?%(lc:|uc:)?([a-z]+)} $str match how field]} {
    344             foreach {s0 s1} $match break
    345             foreach {h0 h1} $how break
    346             foreach {f0 f1} $field break
    347 
    348             set pre [string range $str 0 [expr {$s0-1}]]
    349             if {[string length $pre] > 0} {
    350                 $c create text $xpos $ypos -anchor w -text $pre -font $itk_option(-font) -tags [list text item:$n item:$n-text]
    351                 set xwd [font measure $itk_option(-font) $pre]
    352                 set xpos [expr {$xpos+$xwd}]
    353             }
    354 
    355             set editable 0
    356             set fname [string range $str $f0 $f1]
    357             if {[string index $str $s0] == "~"} {
    358                 set editable 1
    359             }
    360             if {[info exists data($fname)]} {
    361                 set how [string range $str $h0 $h1]
    362                 switch -- $how {
    363                     lc: { set label [string tolower $data($fname)] }
    364                     uc: { set label [string toupper $data($fname)] }
    365                     default { set label $data($fname) }
    366                 }
    367 
    368                 # draw the editable part of the title string
    369                 set id [$c create text $xpos $ypos -anchor w -text $label -font $itk_option(-font) -tags [list text item:$n item:$n-text item:$n-$fname]]
    370                 if {$editable} {
    371                     $c bind $id <ButtonPress-1> [itcl::code $this _edit start $n $fname]
    372                 }
    373                 set xwd [font measure $itk_option(-font) $label]
    374                 set xpos [expr {$xpos+$xwd}]
    375             }
    376             set str [string range $str [expr {$s1+1}] end]
    377         }
    378 
    379         # draw the last little bit on title string, if there is any
    380         if {[string length $str] > 0} {
    381             $c create text $xpos $ypos -anchor w -text $str -font $itk_option(-font) -tags [list text item:$n item:$n-text]
    382             set xwd [font measure $itk_option(-font) $str]
    383             set xpos [expr {$xpos+$xwd}]
    384         }
     341
     342        set subs(%type) ""
     343        set subs(%id) ""
     344        foreach {name val} [$_tree get $n] {
     345            set subs(%$name) $val
     346            set subs(%lc:$name) [string tolower $val]
     347            set subs(%uc:$name) [string toupper $val]
     348        }
     349
     350        set str [string map [array get subs] $itk_option(-title)]
     351        $c create text $xpos $ypos -anchor w -text $str -font $itk_option(-font) -tags [list text item:$n item:$n-text]
    385352
    386353        set ypos [expr {$ypos+$lineht+$itk_option(-padding)}]
     
    390357            # if this node has children, draw them here
    391358            _redrawChildren $n $xtxt ypos
    392         }
    393     }
    394 }
    395 
    396 # ----------------------------------------------------------------------
    397 # USAGE: _edit start <node> <field>
    398 # USAGE: _edit activate <node> <field>
    399 # USAGE: _edit validate <node> <field> <value>
    400 # USAGE: _edit apply <node> <field> <value>
    401 #
    402 # Used internally to handle the pop-up editor that edits part of
    403 # the title string for a node.  The "start" operation is called when
    404 # the user clicks on the title to edit it.  If the node is already
    405 # selected, this brings up an editor for the field value, allowing the
    406 # user to change the field.  The "activate" operation is called by
    407 # the editor to figure out where it should pop up.  The "validate"
    408 # operation is called to check the new value and make sure that it
    409 # is okay.  The "apply" operation applies the value to the node.
    410 # ----------------------------------------------------------------------
    411 itcl::body Rappture::Hierlist::_edit {option n f args} {
    412     switch -- $option {
    413         start {
    414             if {[string equal $n $_current]} {
    415                 $itk_component(editor) configure \
    416                     -activatecommand [itcl::code $this _edit activate $n $f] \
    417                     -validatecommand [itcl::code $this _edit validate $n $f] \
    418                     -applycommand [itcl::code $this _edit apply $n $f]
    419                 $itk_component(editor) activate
    420             }
    421         }
    422         activate {
    423             set str [$_tree get $n $f]
    424             foreach {x0 y0 x1 y1} [$itk_component(area) bbox item:$n-$f] break
    425             set w [expr {$x1-$x0}]
    426             set h [expr {$y1-$y0}]
    427             set x0 [expr {[winfo rootx $itk_component(area)]+$x0}]
    428             set y0 [expr {[winfo rooty $itk_component(area)]+$y0}]
    429 
    430             return [list text $str x [expr {$x0-2}] y [expr {$y0-2}] w $w h $h]
    431         }
    432         validate {
    433             set val [lindex $args 0]
    434             if {![regexp {^[a-zA-Z0-9_]+$} $val]} {
    435                 bell
    436                 return 0
    437             }
    438             return 1
    439         }
    440         apply {
    441             set val [lindex $args 0]
    442             $_tree set $n $f $val
    443             $itk_component(area) itemconfigure item:$n-$f -text $val
    444         }
    445         default {
    446             error "bad option \"$option\": should be start, activate, validate, apply"
    447359        }
    448360    }
     
    569481                    regexp {node:([0-9]+)} $params(-data) match node
    570482                    eval $_tree move $node $_droppos
     483                    event generate $itk_component(hull) <<SelectionPath>>
    571484                } else {
    572485                    set dlist [list open yes terminal yes dragdrop yes]
  • trunk/instant/main.tcl

    r1728 r1742  
    4747option add *build*cntls*highlightBackground #cccccc
    4848option add *build*cntls*font {helvetica -12}
    49 option add *build*cntls.Button.borderWidth 1
    50 option add *build*cntls.Button.relief flat
    51 option add *build*cntls.Button.overRelief raised
    52 option add *build*cntls.Button.padX 2
     49option add *build*cntls*Button.borderWidth 1
     50option add *build*cntls*Button.relief flat
     51option add *build*cntls*Button.overRelief raised
     52option add *build*cntls*Button.padX 2
     53option add *build*cntls*Editor.background white
    5354option add *options*Entry.background white
    5455option add *options*Text.background white
     
    8788
    8889wm protocol . WM_DELETE_WINDOW main_exit
     90wm title . "Instant Rappture"
    8991
    9092# install a better bug handler
     
    119121Rappture::icon foo  ;# force loading of this module
    120122lappend Rappture::icon::iconpath [file join $dir images]
     123
     124# ----------------------------------------------------------------------
     125#  HACK ALERT!  Make it so the Analyzer can't possibly enable its
     126#    simulate button in "preview" mode, or else the user might
     127#    actually launch a simulation.
     128# ----------------------------------------------------------------------
     129itcl::body Rappture::Analyzer::_simState {state args} {
     130    if {"" != $itk_option(-simcontrolbackground)} {
     131        set simcbg $itk_option(-simcontrolbackground)
     132    } else {
     133        set simcbg $itk_option(-background)
     134    }
     135    $itk_interior.simol configure \
     136        -background $itk_option(-simcontroloutline)
     137    configure -simcontrolcolor $simcbg
     138
     139    $itk_component(simulate) configure -state disabled
     140}
    121141
    122142# ----------------------------------------------------------------------
     
    340360        set ErrList [lsort -decreasing -command main_errors_cmp $ErrList]
    341361
    342         if {[llength $ErrList] == 1} {
    343             set isproblem "is 1 problem"
     362        # count the errors and warnings
     363        set nerrs 0
     364        set nwarn 0
     365        set nother 0
     366        foreach rec $ErrList {
     367            switch -- [lindex $rec 0] {
     368                error   { incr nerrs }
     369                warning { incr nwarn }
     370                default { incr nother }
     371            }
     372        }
     373
     374        set phrases ""
     375        if {$nerrs == 1} {
     376            lappend phrases "1 error"
     377        } elseif {$nerrs > 1} {
     378            lappend phrases "$nerrs errors"
     379        }
     380        if {$nwarn == 1} {
     381            lappend phrases "1 warning"
     382        } elseif {$nwarn > 1} {
     383            lappend phrases "$nwarn warnings"
     384        }
     385        if {$nother == 1} {
     386            lappend phrases "1 other suggestion"
     387        } elseif {$nother > 1} {
     388            lappend phrases "$nother suggestions"
     389        }
     390        switch -- [llength $phrases] {
     391            1 { set phrases [lindex $phrases 0] }
     392            2 { set phrases [join $phrases " and "] }
     393            3 { set phrases [join $phrases "%"]
     394                regsub "%" $phrases ", " phrases
     395                regsub "%" $phrases ", and " phrases
     396            }
     397        }
     398
     399        if {$nerrs+$nwarn+$nother == 1} {
     400            set thereis "There is"
    344401            set problem "this problem"
    345402        } else {
    346             set isproblem "are [llength $ErrList] problems"
     403            set thereis "There are"
    347404            set problem "these problems"
    348405        }
    349         set choice [tk_messageBox -icon error -type yesno -title "iRappture: Problems with your tool definition" -message "There $isproblem with your current tool definition.  Examine and resolve $problem?"]
     406
     407        set choice [tk_messageBox -icon error -type yesno -title "iRappture: Problems with your tool definition" -message "$thereis $phrases for your current tool definition.  Examine and resolve $problem?"]
    350408        if {$choice == "yes"} {
    351409            return 1
     
    392450
    393451    .func.build.options.errs.info configure -text "$class: $mesg"
     452
     453    if {$class == "Error"} {
     454        .func.build.options.errs.exclaim config -image [Rappture::icon err24]
     455    } else {
     456        .func.build.options.errs.exclaim config -image [Rappture::icon warn24]
     457    }
    394458
    395459    set win [.func.build.options.panes pane 0]
     
    613677
    614678        gettoolfile {
    615             set fname [tk_getSaveFile -title "iRappture: Save Tool" -initialfile "tool.xml" -defaultextension .xml -filetypes { {{XML files} .xml} {{All files} *} }]
     679            set fname [tk_getSaveFile -title "iRappture: Save Tool" -parent .saveas -initialfile "tool.xml" -defaultextension .xml -filetypes { {{XML files} .xml} {{All files} *} }]
    616680
    617681            if {"" != $fname} {
     
    624688        getprogfile {
    625689            set ext .tcl
    626             set fname [tk_getSaveFile -title "iRappture: Save Program Skeleton" -initialfile "wrapper$ext" -defaultextension $ext -filetypes {
     690            set fname [tk_getSaveFile -title "iRappture: Save Program Skeleton" -parent .saveas -initialfile "wrapper$ext" -defaultextension $ext -filetypes {
    627691    {{C programs} .c}
    628692    {{C++ programs} .cpp}
     
    684748    global ToolXml ToolPreview
    685749
     750    # while we're checking for errors, put up a striped pattern over
     751    # the preview area
     752    set w [winfo width .func.preview]
     753    set h [winfo height .func.preview]
     754    place .func.preview.stripes -x 0 -y 0 -width $w -height $h
     755    raise .func.preview.stripes
     756
    686757    # freshen up the ToolXml
    687758    if {![main_generate_xml]} {
     
    701772
    702773    # clear all current widgets in the preview window
     774    place forget .func.preview.stripes
    703775    set win .func.preview
    704776    $win.pager delete 0 end
     
    746818        pack $f.cntls -expand yes -fill both
    747819    }
     820
     821    # add an analyzer for output widgets
     822    set simtxt [$ToolXml get tool.action.label]
     823    if {"" == $simtxt} {
     824        set simtxt "Simulate"
     825    }
     826    $win.pager insert end -name analyzer -title $simtxt
     827    set f [$win.pager page analyzer]
     828    # note: simcontrol on but disabled due to _simState code above
     829    Rappture::Analyzer $f.analyze $ToolPreview -simcontrol on
     830    pack $f.analyze -expand yes -fill both
     831
     832    # copy the ToolXml object and pass to analyzer to show outputs
     833    set synthrun [Rappture::LibraryObj ::#auto "<?xml version=\"1.0\"?><run/>"]
     834    $synthrun copy "" from $ToolXml ""
     835    $f.analyze load $synthrun
     836    $f.analyze configure -notebookpage analyze
     837
     838    # turn off download options and clear button
     839    $f.analyze component download configure -state disabled
     840    $f.analyze component resultset component clear configure -state disabled
     841    # remove the "---" and "Download..." options from the result selector
     842    $f.analyze component resultselector choices delete end
     843    $f.analyze component resultselector choices delete end
    748844}
    749845
     
    841937button .func.build.options.errs.x -bitmap [Rappture::icon dismiss] \
    842938    -command {pack forget .func.build.options.errs}
    843 pack .func.build.options.errs.x -side right -anchor n -padx 2 -pady 2
    844 label .func.build.options.errs.exclaim -image [Rappture::icon cue24]
    845 pack .func.build.options.errs.exclaim -side left -anchor nw -padx 2 -pady 2
    846 label .func.build.options.errs.info -text "" -anchor w -justify left
    847 pack .func.build.options.errs.info -side left -expand yes -fill both
     939pack .func.build.options.errs.x -side right -anchor n -padx 4 -pady 8
     940label .func.build.options.errs.exclaim -image [Rappture::icon err24]
     941pack .func.build.options.errs.exclaim -side left -anchor nw -padx 4 -pady 4
     942label .func.build.options.errs.info -text "" -anchor nw -justify left
     943pack .func.build.options.errs.info -side left -expand yes -fill both -pady {6 0}
    848944bind .func.build.options.errs.info <Configure> {.func.build.options.errs.info configure -wraplength [expr {%w-4}]}
    849945
     
    862958
    863959bind $win.scrl.skel <<Selection>> main_options_load
     960bind $win.scrl.skel <<SelectionPath>> main_options_rename
    864961
    865962set win [.func.build.options.panes pane 1]
     
    9081005        frame $frame.cntls -borderwidth 4 -relief flat
    9091006        grid $frame.cntls -row 0 -column 0 -columnspan 2 -sticky nsew
    910         button $frame.cntls.del -text "Delete" -command main_options_delete
    911         pack $frame.cntls.del -side right
     1007
     1008        if {![string equal $type "Tool"]} {
     1009            # can't let people delete the tool info
     1010            button $frame.cntls.del -text "Delete" -command main_options_delete
     1011            pack $frame.cntls.del -side right
     1012        }
     1013
    9121014        button $frame.cntls.help -text "Help" -command main_options_help
    9131015        pack $frame.cntls.help -side right
    9141016
    9151017        # put this in last so it gets squeezed out
    916         label $frame.cntls.l -text "Object: $path" -anchor w -justify left -width 5
    917         pack $frame.cntls.l -side left -expand yes -fill both -padx {0 20}
    918         bind $frame.cntls.l <Configure> [format {%s.cntls.l configure -wraplength [expr {%%w-4}]} $frame]
     1018        Rappture::ObjPath $frame.cntls.path -label "Object" -pathtext $path \
     1019            -renamecommand main_options_rename
     1020        pack $frame.cntls.path -side left -expand yes -fill both
     1021
     1022        if {[string equal $type "Tool"]} {
     1023            # if this is a tool, then lose the rename button
     1024            pack forget [$frame.cntls.path component button]
     1025        }
    9191026
    9201027        array set ainfo [$hlist curselection -field attributes]
     
    9741081
    9751082# ----------------------------------------------------------------------
     1083# USAGE: main_options_rename ?<name>?
     1084#
     1085# Used to change the id of the current selection to the given <name>.
     1086# ----------------------------------------------------------------------
     1087proc main_options_rename {args} {
     1088    set win [.func.build.options.panes pane 0]
     1089    set hlist $win.scrl.skel
     1090    set node [$hlist curselection]
     1091
     1092    if {[llength $args] > 0} {
     1093        $hlist tree set $node id [lindex $args 0]
     1094    }
     1095
     1096    # get the updated path for this element and show in ObjPath widget
     1097    set path [$hlist curselection -path "%lc:type(%id)"]
     1098    regsub -all {\(%id\)} $path "" path
     1099
     1100    set win [.func.build.options.panes pane 1]
     1101    set frame [$win.vals contents frame]
     1102    $frame.cntls.path configure -pathtext $path
     1103}
     1104
     1105# ----------------------------------------------------------------------
    9761106# USAGE: main_options_save ?-clear?
    9771107#
     
    10811211
    10821212bind .func.preview.pager <Map> main_preview
     1213
     1214# use this frame to cover preview before it appears
     1215blt::tile::frame .func.preview.stripes -tile [Rappture::icon diag]
    10831216
    10841217# ----------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.