[1] | 1 | # ---------------------------------------------------------------------- |
---|
| 2 | # COMPONENT: analyzer - output area for Rappture |
---|
| 3 | # |
---|
| 4 | # This widget acts as the output side of a Rappture application. |
---|
| 5 | # When the input has changed, it displays a Simulate button that |
---|
| 6 | # launches the simulation. When a simulation is running, this |
---|
| 7 | # area shows status. When it is finished, the results appear |
---|
| 8 | # in place of the button, according to the specs in the <analyze> |
---|
| 9 | # XML data. |
---|
| 10 | # ====================================================================== |
---|
| 11 | # AUTHOR: Michael McLennan, Purdue University |
---|
[115] | 12 | # Copyright (c) 2004-2005 Purdue Research Foundation |
---|
| 13 | # |
---|
| 14 | # See the file "license.terms" for information on usage and |
---|
| 15 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
[1] | 16 | # ====================================================================== |
---|
| 17 | package require Itk |
---|
| 18 | |
---|
[173] | 19 | option add *Analyzer.width 3.5i widgetDefault |
---|
[69] | 20 | option add *Analyzer.height 4i widgetDefault |
---|
[11] | 21 | option add *Analyzer.simControl "auto" widgetDefault |
---|
| 22 | option add *Analyzer.simControlBackground "" widgetDefault |
---|
| 23 | option add *Analyzer.simControlOutline gray widgetDefault |
---|
| 24 | option add *Analyzer.simControlActiveBackground #ffffcc widgetDefault |
---|
| 25 | option add *Analyzer.simControlActiveOutline black widgetDefault |
---|
[1830] | 26 | option add *Analyzer.notebookpage "about" widgetDefault |
---|
[11] | 27 | |
---|
| 28 | option add *Analyzer.font \ |
---|
[676] | 29 | -*-helvetica-medium-r-normal-*-12-* widgetDefault |
---|
[170] | 30 | option add *Analyzer.codeFont \ |
---|
[676] | 31 | -*-courier-medium-r-normal-*-12-* widgetDefault |
---|
[1] | 32 | option add *Analyzer.textFont \ |
---|
[676] | 33 | -*-helvetica-medium-r-normal-*-12-* widgetDefault |
---|
[11] | 34 | option add *Analyzer.boldTextFont \ |
---|
[676] | 35 | -*-helvetica-bold-r-normal-*-12-* widgetDefault |
---|
[1] | 36 | |
---|
| 37 | itcl::class Rappture::Analyzer { |
---|
| 38 | inherit itk::Widget |
---|
| 39 | |
---|
[170] | 40 | itk_option define -codefont codeFont Font "" |
---|
[11] | 41 | itk_option define -textfont textFont Font "" |
---|
| 42 | itk_option define -boldtextfont boldTextFont Font "" |
---|
| 43 | itk_option define -simcontrol simControl SimControl "" |
---|
| 44 | itk_option define -simcontroloutline simControlOutline Background "" |
---|
| 45 | itk_option define -simcontrolbackground simControlBackground Background "" |
---|
| 46 | itk_option define -simcontrolactiveoutline simControlActiveOutline Background "" |
---|
| 47 | itk_option define -simcontrolactivebackground simControlActiveBackground Background "" |
---|
[1] | 48 | itk_option define -holdwindow holdWindow HoldWindow "" |
---|
[1830] | 49 | itk_option define -notebookpage notebookPage NotebookPage "" |
---|
[1] | 50 | |
---|
[11] | 51 | constructor {tool args} { # defined below } |
---|
[1] | 52 | destructor { # defined below } |
---|
| 53 | |
---|
[11] | 54 | public method simulate {args} |
---|
[745] | 55 | public method reset {{when -eventually}} |
---|
[903] | 56 | public method load {xmlobj} |
---|
[11] | 57 | public method clear {} |
---|
[210] | 58 | public method download {option args} |
---|
[1] | 59 | |
---|
[11] | 60 | protected method _plot {args} |
---|
| 61 | protected method _reorder {comps} |
---|
| 62 | protected method _autoLabel {xmlobj path title cntVar} |
---|
[1] | 63 | protected method _fixResult {} |
---|
[11] | 64 | protected method _fixSize {} |
---|
| 65 | protected method _fixSimControl {} |
---|
[1159] | 66 | protected method _fixNotebook {} |
---|
[11] | 67 | protected method _simState {state args} |
---|
[23] | 68 | protected method _simOutput {message} |
---|
[413] | 69 | protected method _resultTooltip {} |
---|
[1797] | 70 | protected method _isPdbTrajectory {data} |
---|
| 71 | protected method _isLammpsTrajectory {data} |
---|
| 72 | protected method _pdbToSequence {xmlobj path id child data} |
---|
| 73 | protected method _lammpsToSequence {xmlobj path id child data} |
---|
| 74 | protected method _trajToSequence {xmlobj {path ""}} |
---|
[1] | 75 | |
---|
[11] | 76 | private variable _tool "" ;# belongs to this tool |
---|
[1606] | 77 | private variable _appName "" ;# Name of application |
---|
[1] | 78 | private variable _control "manual" ;# start mode |
---|
[11] | 79 | private variable _runs "" ;# list of XML objects with results |
---|
| 80 | private variable _pages 0 ;# number of pages for result sets |
---|
| 81 | private variable _label2page ;# maps output label => result set |
---|
[413] | 82 | private variable _label2desc ;# maps output label => description |
---|
[210] | 83 | private variable _lastlabel "" ;# label of last example loaded |
---|
[11] | 84 | private variable _plotlist "" ;# items currently being plotted |
---|
[1] | 85 | |
---|
| 86 | private common job ;# array var used for blt::bgexec jobs |
---|
| 87 | } |
---|
[413] | 88 | |
---|
[1] | 89 | itk::usual Analyzer { |
---|
| 90 | keep -background -cursor foreground -font |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | # ---------------------------------------------------------------------- |
---|
| 94 | # CONSTRUCTOR |
---|
| 95 | # ---------------------------------------------------------------------- |
---|
[11] | 96 | itcl::body Rappture::Analyzer::constructor {tool args} { |
---|
| 97 | set _tool $tool |
---|
| 98 | |
---|
| 99 | itk_option add hull.width hull.height |
---|
| 100 | pack propagate $itk_component(hull) no |
---|
| 101 | |
---|
| 102 | frame $itk_interior.simol -borderwidth 1 -relief flat |
---|
| 103 | pack $itk_interior.simol -fill x |
---|
| 104 | |
---|
[1274] | 105 | itk_component add simbg { |
---|
[1663] | 106 | frame $itk_interior.simol.simbg -borderwidth 0 |
---|
[1274] | 107 | } { |
---|
[1663] | 108 | usual |
---|
| 109 | rename -background -simcontrolcolor simControlColor Color |
---|
[1274] | 110 | } |
---|
| 111 | pack $itk_component(simbg) -expand yes -fill both |
---|
[11] | 112 | |
---|
[1124] | 113 | set simtxt [$tool xml get tool.action.label] |
---|
| 114 | if {"" == $simtxt} { |
---|
[1663] | 115 | set simtxt "Simulate" |
---|
[1124] | 116 | } |
---|
[11] | 117 | itk_component add simulate { |
---|
[1663] | 118 | button $itk_component(simbg).simulate -text $simtxt \ |
---|
| 119 | -command [itcl::code $this simulate] |
---|
[1274] | 120 | } { |
---|
[1663] | 121 | usual |
---|
| 122 | rename -highlightbackground -simcontrolcolor simControlColor Color |
---|
[11] | 123 | } |
---|
| 124 | pack $itk_component(simulate) -side left -padx 4 -pady 4 |
---|
| 125 | |
---|
[1274] | 126 | # if there's a hub url, then add "About" and "Questions" links |
---|
[1606] | 127 | set _appName [$_tool xml get tool.id] |
---|
[1274] | 128 | set url [Rappture::Tool::resources -huburl] |
---|
[1606] | 129 | if {"" != $url && "" != $_appName} { |
---|
[1663] | 130 | itk_component add hubcntls { |
---|
| 131 | frame $itk_component(simbg).hubcntls |
---|
| 132 | } { |
---|
| 133 | usual |
---|
| 134 | rename -background -simcontrolcolor simControlColor Color |
---|
| 135 | } |
---|
| 136 | pack $itk_component(hubcntls) -side right -padx 4 |
---|
[1274] | 137 | |
---|
[1663] | 138 | itk_component add icon { |
---|
| 139 | label $itk_component(hubcntls).icon -image [Rappture::icon ask] \ |
---|
| 140 | -highlightthickness 0 |
---|
| 141 | } { |
---|
| 142 | usual |
---|
| 143 | ignore -highlightthickness |
---|
| 144 | rename -background -simcontrolcolor simControlColor Color |
---|
| 145 | } |
---|
| 146 | pack $itk_component(icon) -side left |
---|
[1274] | 147 | |
---|
[1663] | 148 | itk_component add about { |
---|
| 149 | button $itk_component(hubcntls).about -text "About this tool" \ |
---|
| 150 | -command [list Rappture::filexfer::webpage \ |
---|
| 151 | "$url/tools/$_appName"] |
---|
| 152 | } { |
---|
| 153 | usual |
---|
| 154 | ignore -font |
---|
| 155 | rename -background -simcontrolcolor simControlColor Color |
---|
| 156 | rename -highlightbackground -simcontrolcolor simControlColor Color |
---|
| 157 | } |
---|
| 158 | pack $itk_component(about) -side top -anchor w |
---|
[1274] | 159 | |
---|
[1663] | 160 | itk_component add questions { |
---|
| 161 | button $itk_component(hubcntls).questions -text Questions? \ |
---|
| 162 | -command [list Rappture::filexfer::webpage \ |
---|
| 163 | "$url/resources/$_appName/questions"] |
---|
| 164 | } { |
---|
| 165 | usual |
---|
| 166 | ignore -font |
---|
| 167 | rename -background -simcontrolcolor simControlColor Color |
---|
| 168 | rename -highlightbackground -simcontrolcolor simControlColor Color |
---|
| 169 | } |
---|
| 170 | pack $itk_component(questions) -side top -anchor w |
---|
[1274] | 171 | } |
---|
| 172 | |
---|
[11] | 173 | itk_component add simstatus { |
---|
[1663] | 174 | text $itk_component(simbg).simstatus -borderwidth 0 \ |
---|
| 175 | -highlightthickness 0 -height 1 -width 1 -wrap none \ |
---|
| 176 | -state disabled |
---|
[11] | 177 | } { |
---|
[1663] | 178 | usual |
---|
| 179 | ignore -highlightthickness |
---|
| 180 | rename -background -simcontrolcolor simControlColor Color |
---|
| 181 | rename -font -textfont textFont Font |
---|
[11] | 182 | } |
---|
| 183 | pack $itk_component(simstatus) -side left -expand yes -fill x |
---|
| 184 | |
---|
| 185 | $itk_component(simstatus) tag configure popup \ |
---|
[1663] | 186 | -underline 1 -foreground blue |
---|
[11] | 187 | |
---|
| 188 | $itk_component(simstatus) tag bind popup \ |
---|
[1663] | 189 | <Enter> {%W configure -cursor center_ptr} |
---|
[11] | 190 | $itk_component(simstatus) tag bind popup \ |
---|
[1663] | 191 | <Leave> {%W configure -cursor ""} |
---|
[11] | 192 | $itk_component(simstatus) tag bind popup \ |
---|
[1663] | 193 | <ButtonPress> {after idle {Rappture::Tooltip::tooltip show %W}} |
---|
[11] | 194 | |
---|
| 195 | |
---|
[1] | 196 | itk_component add notebook { |
---|
[1663] | 197 | Rappture::Notebook $itk_interior.nb |
---|
[1] | 198 | } |
---|
| 199 | pack $itk_interior.nb -expand yes -fill both |
---|
| 200 | |
---|
| 201 | # ------------------------------------------------------------------ |
---|
[11] | 202 | # ABOUT PAGE |
---|
| 203 | # ------------------------------------------------------------------ |
---|
| 204 | set w [$itk_component(notebook) insert end about] |
---|
| 205 | |
---|
| 206 | Rappture::Scroller $w.info -xscrollmode off -yscrollmode auto |
---|
| 207 | pack $w.info -expand yes -fill both -padx 4 -pady 20 |
---|
| 208 | itk_component add toolinfo { |
---|
[1663] | 209 | text $w.info.text -width 1 -height 1 -wrap word \ |
---|
| 210 | -borderwidth 0 -highlightthickness 0 |
---|
[11] | 211 | } { |
---|
[1663] | 212 | usual |
---|
| 213 | ignore -borderwidth -relief |
---|
| 214 | rename -font -textfont textFont Font |
---|
[11] | 215 | } |
---|
| 216 | $w.info contents $w.info.text |
---|
| 217 | |
---|
| 218 | # ------------------------------------------------------------------ |
---|
[1] | 219 | # SIMULATION PAGE |
---|
| 220 | # ------------------------------------------------------------------ |
---|
| 221 | set w [$itk_component(notebook) insert end simulate] |
---|
| 222 | frame $w.cntls |
---|
[11] | 223 | pack $w.cntls -side bottom -fill x -pady 12 |
---|
| 224 | frame $w.cntls.sep -background black -height 1 |
---|
| 225 | pack $w.cntls.sep -side top -fill x |
---|
[1] | 226 | |
---|
[11] | 227 | itk_component add abort { |
---|
[1663] | 228 | button $w.cntls.abort -text "Abort" \ |
---|
| 229 | -command [itcl::code $_tool abort] |
---|
[1] | 230 | } |
---|
[11] | 231 | pack $itk_component(abort) -side left -expand yes -padx 4 -pady 4 |
---|
[1] | 232 | |
---|
[168] | 233 | Rappture::Scroller $w.info -xscrollmode auto -yscrollmode auto |
---|
[11] | 234 | pack $w.info -expand yes -fill both -padx 4 -pady 4 |
---|
| 235 | itk_component add runinfo { |
---|
[1663] | 236 | text $w.info.text -width 1 -height 1 -wrap none \ |
---|
| 237 | -borderwidth 0 -highlightthickness 0 \ |
---|
| 238 | -state disabled |
---|
[1] | 239 | } { |
---|
[1663] | 240 | usual |
---|
| 241 | ignore -borderwidth -relief |
---|
| 242 | rename -font -codefont codeFont Font |
---|
[1] | 243 | } |
---|
| 244 | $w.info contents $w.info.text |
---|
| 245 | |
---|
[23] | 246 | itk_component add progress { |
---|
[1663] | 247 | Rappture::Progress $w.progress |
---|
[23] | 248 | } |
---|
| 249 | |
---|
[1] | 250 | # ------------------------------------------------------------------ |
---|
| 251 | # ANALYZE PAGE |
---|
| 252 | # ------------------------------------------------------------------ |
---|
| 253 | set w [$itk_component(notebook) insert end analyze] |
---|
| 254 | |
---|
[11] | 255 | frame $w.top |
---|
| 256 | pack $w.top -side top -fill x -pady 8 |
---|
| 257 | label $w.top.l -text "Result:" -font $itk_option(-font) |
---|
| 258 | pack $w.top.l -side left |
---|
| 259 | |
---|
[172] | 260 | itk_component add resultselector { |
---|
[1663] | 261 | Rappture::Combobox $w.top.sel -width 10 -editable no |
---|
[172] | 262 | } { |
---|
[1663] | 263 | usual |
---|
| 264 | rename -font -textfont textFont Font |
---|
[172] | 265 | } |
---|
| 266 | pack $itk_component(resultselector) -side left -expand yes -fill x |
---|
| 267 | bind $itk_component(resultselector) <<Value>> [itcl::code $this _fixResult] |
---|
[210] | 268 | bind $itk_component(resultselector) <Enter> \ |
---|
[1663] | 269 | [itcl::code $this download coming] |
---|
[172] | 270 | |
---|
[413] | 271 | Rappture::Tooltip::for $itk_component(resultselector) \ |
---|
[1663] | 272 | "@[itcl::code $this _resultTooltip]" |
---|
[413] | 273 | |
---|
[1077] | 274 | $itk_component(resultselector) choices insert end \ |
---|
[1663] | 275 | --- "---" |
---|
[1077] | 276 | |
---|
| 277 | itk_component add download { |
---|
[1663] | 278 | button $w.top.dl -image [Rappture::icon download] -anchor e \ |
---|
| 279 | -borderwidth 1 -relief flat -overrelief raised \ |
---|
| 280 | -command [itcl::code $this download start $w.top.dl] |
---|
[1077] | 281 | } |
---|
| 282 | pack $itk_component(download) -side right -padx {4 0} |
---|
| 283 | bind $itk_component(download) <Enter> \ |
---|
[1663] | 284 | [itcl::code $this download coming] |
---|
[1077] | 285 | |
---|
| 286 | $itk_component(resultselector) choices insert end \ |
---|
[1663] | 287 | @download [Rappture::filexfer::label download] |
---|
[1077] | 288 | |
---|
[171] | 289 | if {[Rappture::filexfer::enabled]} { |
---|
[1663] | 290 | Rappture::Tooltip::for $itk_component(download) "Downloads the current result to a new web browser window on your desktop. From there, you can easily print or save results. |
---|
[171] | 291 | |
---|
| 292 | NOTE: Your web browser must allow pop-ups from this site. If your output does not appear, look for a 'pop-up blocked' message and enable pop-ups." |
---|
[1077] | 293 | } else { |
---|
[1663] | 294 | Rappture::Tooltip::for $itk_component(download) "Saves the current result to a file on your desktop." |
---|
[171] | 295 | } |
---|
| 296 | |
---|
[1] | 297 | itk_component add results { |
---|
[1663] | 298 | Rappture::Panes $w.pane -sashwidth 1 -sashrelief solid -sashpadding {4 0} |
---|
[1] | 299 | } |
---|
[11] | 300 | pack $itk_component(results) -expand yes -fill both |
---|
| 301 | set f [$itk_component(results) pane 0] |
---|
[1] | 302 | |
---|
[11] | 303 | itk_component add resultpages { |
---|
[1663] | 304 | Rappture::Notebook $f.nb |
---|
[11] | 305 | } |
---|
| 306 | pack $itk_component(resultpages) -expand yes -fill both |
---|
| 307 | |
---|
| 308 | set f [$itk_component(results) insert end -fraction 0.1] |
---|
| 309 | itk_component add resultset { |
---|
[1663] | 310 | Rappture::ResultSet $f.rset \ |
---|
| 311 | -clearcommand [itcl::code $this clear] \ |
---|
| 312 | -settingscommand [itcl::code $this _plot] \ |
---|
| 313 | -promptcommand [itcl::code $this _simState] |
---|
[11] | 314 | } |
---|
| 315 | pack $itk_component(resultset) -expand yes -fill both |
---|
| 316 | bind $itk_component(resultset) <<Control>> [itcl::code $this _fixSize] |
---|
[413] | 317 | bind $itk_component(results) <Configure> [itcl::code $this _fixSize] |
---|
[11] | 318 | |
---|
[1] | 319 | eval itk_initialize $args |
---|
[11] | 320 | |
---|
[170] | 321 | $itk_component(runinfo) tag configure ERROR -foreground red |
---|
| 322 | $itk_component(runinfo) tag configure text -font $itk_option(-textfont) |
---|
| 323 | |
---|
[11] | 324 | # |
---|
| 325 | # Load up tool info on the first page. |
---|
| 326 | # |
---|
| 327 | $itk_component(toolinfo) tag configure title \ |
---|
[1663] | 328 | -font $itk_option(-boldtextfont) |
---|
[11] | 329 | |
---|
| 330 | set mesg [$tool xml get tool.title] |
---|
| 331 | if {"" != $mesg} { |
---|
[1663] | 332 | $itk_component(toolinfo) insert end $mesg title |
---|
| 333 | $itk_component(toolinfo) insert end "\n\n" |
---|
[11] | 334 | } |
---|
| 335 | |
---|
| 336 | set mesg [$tool xml get tool.about] |
---|
| 337 | if {"" != $mesg} { |
---|
[1663] | 338 | $itk_component(toolinfo) insert end $mesg |
---|
[11] | 339 | } |
---|
| 340 | $itk_component(toolinfo) configure -state disabled |
---|
| 341 | $itk_component(notebook) current about |
---|
| 342 | |
---|
| 343 | # tool can run on "manual" (default) or "auto" |
---|
| 344 | set cntl [$tool xml get tool.control] |
---|
[22] | 345 | if {"" == $cntl} { |
---|
[1663] | 346 | set cntl [$tool xml get tool.control.type] |
---|
[22] | 347 | } |
---|
[11] | 348 | if {"" != $cntl} { |
---|
[1663] | 349 | set _control $cntl |
---|
[11] | 350 | } |
---|
[12] | 351 | |
---|
| 352 | # reset everything to a clean state |
---|
| 353 | reset |
---|
[1] | 354 | } |
---|
| 355 | |
---|
| 356 | # ---------------------------------------------------------------------- |
---|
| 357 | # DESTRUCTOR |
---|
| 358 | # ---------------------------------------------------------------------- |
---|
| 359 | itcl::body Rappture::Analyzer::destructor {} { |
---|
[11] | 360 | foreach obj $_runs { |
---|
[1663] | 361 | itcl::delete object $obj |
---|
[1] | 362 | } |
---|
[11] | 363 | after cancel [itcl::code $this simulate] |
---|
[1] | 364 | } |
---|
| 365 | |
---|
| 366 | # ---------------------------------------------------------------------- |
---|
[11] | 367 | # USAGE: simulate ?-ifneeded? |
---|
| 368 | # USAGE: simulate ?<path1> <value1> <path2> <value2> ...? |
---|
[1] | 369 | # |
---|
[11] | 370 | # Kicks off the simulator by executing the tool.command associated |
---|
| 371 | # with the tool. If any arguments are specified, they are used to |
---|
| 372 | # set parameters for the simulation. While the simulation is running, |
---|
| 373 | # it shows status. When the simulation is finished, it switches |
---|
| 374 | # automatically to "analyze" mode and shows the results. |
---|
[1] | 375 | # ---------------------------------------------------------------------- |
---|
[11] | 376 | itcl::body Rappture::Analyzer::simulate {args} { |
---|
| 377 | if {$args == "-ifneeded"} { |
---|
[1663] | 378 | # check to see if simulation is really needed |
---|
| 379 | $_tool sync |
---|
| 380 | if {[$itk_component(resultset) contains [$_tool xml object]] |
---|
| 381 | && ![string equal $_control "manual-resim"]} { |
---|
| 382 | # not needed -- show results and return |
---|
| 383 | $itk_component(notebook) current analyze |
---|
| 384 | return |
---|
| 385 | } |
---|
| 386 | set args "" |
---|
[1442] | 387 | } |
---|
[1] | 388 | |
---|
[11] | 389 | # simulation is needed -- go to simulation page |
---|
| 390 | $itk_component(notebook) current simulate |
---|
[1] | 391 | |
---|
[23] | 392 | # no progress messages yet |
---|
| 393 | pack forget $itk_component(progress) |
---|
| 394 | lappend args -output [itcl::code $this _simOutput] |
---|
| 395 | |
---|
[11] | 396 | _simState off |
---|
| 397 | $itk_component(runinfo) configure -state normal |
---|
| 398 | $itk_component(runinfo) delete 1.0 end |
---|
[170] | 399 | $itk_component(runinfo) insert end "Running simulation...\n\n" text |
---|
[11] | 400 | $itk_component(runinfo) configure -state disabled |
---|
[1] | 401 | |
---|
[11] | 402 | # if the hold window is set, then put up a busy cursor |
---|
| 403 | if {$itk_option(-holdwindow) != ""} { |
---|
[1663] | 404 | blt::busy hold $itk_option(-holdwindow) |
---|
| 405 | raise $itk_component(hull) |
---|
[11] | 406 | } |
---|
[1] | 407 | |
---|
[11] | 408 | # execute the job |
---|
| 409 | foreach {status result} [eval $_tool run $args] break |
---|
[1] | 410 | |
---|
[11] | 411 | # if job was aborted, then allow simulation again |
---|
| 412 | if {$result == "ABORT"} { |
---|
[1663] | 413 | _simState on "Aborted" |
---|
[11] | 414 | } |
---|
[1] | 415 | |
---|
[903] | 416 | # load results from run.xml into analyzer |
---|
[11] | 417 | if {$status == 0 && $result != "ABORT"} { |
---|
[1663] | 418 | set status [catch {load $result} result] |
---|
[1] | 419 | } |
---|
[11] | 420 | |
---|
| 421 | # back to normal |
---|
| 422 | if {$itk_option(-holdwindow) != ""} { |
---|
[1663] | 423 | blt::busy release $itk_option(-holdwindow) |
---|
[11] | 424 | } |
---|
| 425 | $itk_component(abort) configure -state disabled |
---|
| 426 | |
---|
| 427 | if {$status != 0} { |
---|
[1663] | 428 | $itk_component(runinfo) configure -state normal |
---|
| 429 | $itk_component(runinfo) delete 1.0 end |
---|
| 430 | $itk_component(runinfo) insert end "Problem launching job:\n\n" text |
---|
| 431 | _simOutput $result |
---|
| 432 | $itk_component(runinfo) configure -state disabled |
---|
| 433 | $itk_component(runinfo) see 1.0 |
---|
[724] | 434 | |
---|
[1663] | 435 | # Try to create a support ticket for this error. |
---|
| 436 | # It may be a real problem. |
---|
| 437 | if {[Rappture::bugreport::shouldReport for jobs]} { |
---|
[2611] | 438 | set ::errorInfo "\n\n== RAPPTURE INPUT ==\n[$_tool xml xml]" |
---|
[1861] | 439 | Rappture::bugreport::register "Problem launching job:\n$result" |
---|
[2686] | 440 | Rappture::bugreport::attachment [$_tool xml xml] |
---|
[1861] | 441 | Rappture::bugreport::send |
---|
[1663] | 442 | } |
---|
[11] | 443 | } else { |
---|
[1663] | 444 | $itk_component(notebook) current analyze |
---|
[11] | 445 | } |
---|
[168] | 446 | |
---|
| 447 | # do this last -- after _simOutput above |
---|
| 448 | pack forget $itk_component(progress) |
---|
[1] | 449 | } |
---|
| 450 | |
---|
| 451 | # ---------------------------------------------------------------------- |
---|
[745] | 452 | # USAGE: reset ?-eventually|-now? |
---|
[1] | 453 | # |
---|
| 454 | # Used to reset the analyzer whenever the input to a simulation has |
---|
| 455 | # changed. Sets the mode back to "simulate", so the user has to |
---|
| 456 | # simulate again to see the output. If the <start> option is set |
---|
| 457 | # to "auto", the simulation is invoked immediately. |
---|
| 458 | # ---------------------------------------------------------------------- |
---|
[745] | 459 | itcl::body Rappture::Analyzer::reset {{when -eventually}} { |
---|
| 460 | if {$when == "-eventually"} { |
---|
[1663] | 461 | after cancel [list catch [itcl::code $this reset -now]] |
---|
| 462 | after idle [list catch [itcl::code $this reset -now]] |
---|
| 463 | return |
---|
[745] | 464 | } |
---|
| 465 | |
---|
[11] | 466 | # check to see if simulation is really needed |
---|
| 467 | $_tool sync |
---|
[768] | 468 | if {![$itk_component(resultset) contains [$_tool xml object]] |
---|
[1663] | 469 | || [string equal $_control "manual-resim"]} { |
---|
| 470 | # if control mode is "auto", then simulate right away |
---|
| 471 | if {[string match auto* $_control]} { |
---|
| 472 | # auto control -- don't need button |
---|
| 473 | pack forget $itk_interior.simol |
---|
[1] | 474 | |
---|
[1663] | 475 | after cancel [itcl::code $this simulate] |
---|
| 476 | after idle [itcl::code $this simulate] |
---|
| 477 | } else { |
---|
| 478 | _simState on "new input parameters" |
---|
| 479 | } |
---|
[11] | 480 | } else { |
---|
[1663] | 481 | _simState off |
---|
[1] | 482 | } |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | # ---------------------------------------------------------------------- |
---|
[903] | 486 | # USAGE: load <xmlobj> |
---|
[1] | 487 | # |
---|
[903] | 488 | # Loads the data from the given <xmlobj> into the appropriate results |
---|
[11] | 489 | # sets. If necessary, new results sets are created to store the data. |
---|
[1] | 490 | # ---------------------------------------------------------------------- |
---|
[903] | 491 | itcl::body Rappture::Analyzer::load {xmlobj} { |
---|
[43] | 492 | # only show the last result? then clear first |
---|
| 493 | if {[$_tool xml get tool.analyzer] == "last"} { |
---|
[1663] | 494 | clear |
---|
[43] | 495 | } |
---|
| 496 | |
---|
[1217] | 497 | # look for all output.load children and load them first |
---|
| 498 | # each run.xml is loaded as a previous simulation. |
---|
| 499 | foreach item [$xmlobj children -type run output.load] { |
---|
[1663] | 500 | set loadfile [$xmlobj get output.load.$item] |
---|
| 501 | set loadobj [Rappture::library $loadfile] |
---|
| 502 | load $loadobj |
---|
[1217] | 503 | } |
---|
| 504 | |
---|
| 505 | foreach item [$xmlobj children -type run output.include] { |
---|
[1663] | 506 | set id [$xmlobj element -as id output.include.$item] |
---|
| 507 | set inclfile [$xmlobj get output.include.$item] |
---|
| 508 | set inclobj [Rappture::library $inclfile] |
---|
| 509 | foreach c [$inclobj children output] { |
---|
| 510 | switch -glob -- $c { |
---|
[1830] | 511 | # We don't want to include these tags. |
---|
[1663] | 512 | include* - time* - status* - user* { |
---|
| 513 | continue |
---|
| 514 | } |
---|
| 515 | default { |
---|
| 516 | set oldid [$inclobj element -as id output.$c] |
---|
| 517 | set oldtype [$inclobj element -as type output.$c] |
---|
| 518 | set newcomp "$oldtype\($id-$oldid\)" |
---|
| 519 | $xmlobj copy output.$newcomp from $inclobj output.$c |
---|
| 520 | } |
---|
| 521 | } |
---|
| 522 | } |
---|
[1217] | 523 | } |
---|
| 524 | |
---|
[11] | 525 | lappend _runs $xmlobj |
---|
| 526 | |
---|
[1830] | 527 | # Detect molecule elements that contain trajectory data and convert |
---|
[1791] | 528 | # to sequences. |
---|
[1797] | 529 | _trajToSequence $xmlobj output |
---|
[1791] | 530 | |
---|
[1830] | 531 | # Go through the analysis and find all result sets. |
---|
[11] | 532 | set haveresults 0 |
---|
| 533 | foreach item [_reorder [$xmlobj children output]] { |
---|
[1929] | 534 | switch -glob -- $item { |
---|
| 535 | log* { |
---|
| 536 | _autoLabel $xmlobj output.$item "Output Log" counters |
---|
| 537 | } |
---|
| 538 | number* { |
---|
| 539 | _autoLabel $xmlobj output.$item "Number" counters |
---|
| 540 | } |
---|
| 541 | integer* { |
---|
| 542 | _autoLabel $xmlobj output.$item "Integer" counters |
---|
| 543 | } |
---|
| 544 | string* { |
---|
| 545 | _autoLabel $xmlobj output.$item "String" counters |
---|
| 546 | } |
---|
[2259] | 547 | histogram* - curve* - field* { |
---|
[1929] | 548 | _autoLabel $xmlobj output.$item "Plot" counters |
---|
| 549 | } |
---|
[2385] | 550 | drawing* { |
---|
[2259] | 551 | _autoLabel $xmlobj output.$item "Drawing" counters |
---|
| 552 | } |
---|
[1929] | 553 | structure* { |
---|
| 554 | _autoLabel $xmlobj output.$item "Structure" counters |
---|
| 555 | } |
---|
| 556 | table* { |
---|
| 557 | _autoLabel $xmlobj output.$item "Energy Levels" counters |
---|
| 558 | } |
---|
| 559 | sequence* { |
---|
| 560 | _autoLabel $xmlobj output.$item "Sequence" counters |
---|
| 561 | } |
---|
[2259] | 562 | default { |
---|
[2266] | 563 | if 0 { |
---|
| 564 | puts stderr "unknown output $item" |
---|
| 565 | } |
---|
[2259] | 566 | } |
---|
[1929] | 567 | } |
---|
| 568 | set label [$xmlobj get output.$item.about.group] |
---|
| 569 | if {"" == $label} { |
---|
| 570 | set label [$xmlobj get output.$item.about.label] |
---|
| 571 | } |
---|
[11] | 572 | |
---|
[1663] | 573 | set hidden [$xmlobj get output.$item.hide] |
---|
| 574 | set hidden [expr {"" != $hidden && $hidden}] |
---|
[17] | 575 | |
---|
[1663] | 576 | if {"" != $label && !$hidden} { |
---|
| 577 | set haveresults 1 |
---|
| 578 | } |
---|
[1] | 579 | } |
---|
[11] | 580 | # if there are any valid results, add them to the resultset |
---|
| 581 | if {$haveresults} { |
---|
[1663] | 582 | set index [$itk_component(resultset) add $xmlobj] |
---|
[1] | 583 | |
---|
[1663] | 584 | # add each result to a result viewer |
---|
| 585 | foreach item [_reorder [$xmlobj children output]] { |
---|
| 586 | set label [$xmlobj get output.$item.about.group] |
---|
| 587 | if {"" == $label} { |
---|
| 588 | set label [$xmlobj get output.$item.about.label] |
---|
| 589 | } |
---|
| 590 | set hidden [$xmlobj get output.$item.hide] |
---|
[2241] | 591 | if { $hidden == "" } { |
---|
| 592 | set hidden 0 |
---|
| 593 | } |
---|
[1663] | 594 | if {"" != $label && !$hidden} { |
---|
| 595 | if {![info exists _label2page($label)]} { |
---|
| 596 | set name "page[incr _pages]" |
---|
| 597 | set page [$itk_component(resultpages) insert end $name] |
---|
| 598 | set _label2page($label) $page |
---|
| 599 | set _label2desc($label) \ |
---|
| 600 | [$xmlobj get output.$item.about.description] |
---|
| 601 | Rappture::ResultViewer $page.rviewer |
---|
| 602 | pack $page.rviewer -expand yes -fill both -pady 4 |
---|
[11] | 603 | |
---|
[1663] | 604 | set end [$itk_component(resultselector) \ |
---|
| 605 | choices index -value ---] |
---|
| 606 | if {$end < 0} { |
---|
| 607 | set end "end" |
---|
| 608 | } |
---|
| 609 | $itk_component(resultselector) choices insert $end \ |
---|
| 610 | $name $label |
---|
| 611 | } |
---|
[11] | 612 | |
---|
[1663] | 613 | # add/replace the latest result into this viewer |
---|
| 614 | set page $_label2page($label) |
---|
[13] | 615 | |
---|
[1663] | 616 | if {![info exists reset($page)]} { |
---|
| 617 | $page.rviewer clear $index |
---|
| 618 | set reset($page) 1 |
---|
| 619 | } |
---|
| 620 | $page.rviewer add $index $xmlobj output.$item |
---|
| 621 | } |
---|
| 622 | } |
---|
[1] | 623 | } |
---|
[11] | 624 | |
---|
| 625 | # show the first page by default |
---|
[210] | 626 | set max [$itk_component(resultselector) choices size] |
---|
| 627 | for {set i 0} {$i < $max} {incr i} { |
---|
[1663] | 628 | set first [$itk_component(resultselector) choices get -label $i] |
---|
| 629 | if {$first != ""} { |
---|
| 630 | set page [$itk_component(resultselector) choices get -value $i] |
---|
| 631 | set char [string index $page 0] |
---|
| 632 | if {$char != "@" && $char != "-"} { |
---|
| 633 | $itk_component(resultpages) current $page |
---|
| 634 | $itk_component(resultselector) value $first |
---|
| 635 | set _lastlabel $first |
---|
| 636 | break |
---|
| 637 | } |
---|
| 638 | } |
---|
[11] | 639 | } |
---|
[1] | 640 | } |
---|
| 641 | |
---|
| 642 | # ---------------------------------------------------------------------- |
---|
[11] | 643 | # USAGE: clear |
---|
[1] | 644 | # |
---|
[11] | 645 | # Discards all results previously loaded into the analyzer. |
---|
[1] | 646 | # ---------------------------------------------------------------------- |
---|
[11] | 647 | itcl::body Rappture::Analyzer::clear {} { |
---|
| 648 | foreach obj $_runs { |
---|
[1663] | 649 | itcl::delete object $obj |
---|
[11] | 650 | } |
---|
| 651 | set _runs "" |
---|
| 652 | |
---|
[13] | 653 | $itk_component(resultset) clear |
---|
| 654 | |
---|
[413] | 655 | # reset the size of the controls area |
---|
| 656 | set ht [winfo height $itk_component(results)] |
---|
| 657 | set cntlht [$itk_component(resultset) size -controlarea] |
---|
| 658 | set frac [expr {double($cntlht)/$ht}] |
---|
| 659 | $itk_component(results) fraction end $frac |
---|
| 660 | |
---|
[11] | 661 | foreach label [array names _label2page] { |
---|
[1663] | 662 | set page $_label2page($label) |
---|
[2241] | 663 | destroy $page.rviewer |
---|
| 664 | #$page.rviewer clear |
---|
[11] | 665 | } |
---|
[13] | 666 | $itk_component(resultselector) value "" |
---|
| 667 | $itk_component(resultselector) choices delete 0 end |
---|
| 668 | catch {unset _label2page} |
---|
[413] | 669 | catch {unset _label2desc} |
---|
[13] | 670 | set _plotlist "" |
---|
[11] | 671 | |
---|
[1077] | 672 | $itk_component(resultselector) choices insert end --- "---" |
---|
| 673 | $itk_component(resultselector) choices insert end \ |
---|
[1663] | 674 | @download [Rappture::filexfer::label download] |
---|
[216] | 675 | set _lastlabel "" |
---|
[210] | 676 | |
---|
[13] | 677 | # |
---|
| 678 | # HACK ALERT!! |
---|
| 679 | # The following statement should be in place, but it causes |
---|
| 680 | # vtk to dump core. Leave it out until we can fix the core dump. |
---|
| 681 | # In the mean time, we leak memory... |
---|
| 682 | # |
---|
| 683 | #$itk_component(resultpages) delete -all |
---|
| 684 | #set _pages 0 |
---|
[11] | 685 | |
---|
| 686 | _simState on |
---|
| 687 | _fixSimControl |
---|
[12] | 688 | reset |
---|
[11] | 689 | } |
---|
| 690 | |
---|
| 691 | # ---------------------------------------------------------------------- |
---|
[193] | 692 | # USAGE: download coming |
---|
[464] | 693 | # USAGE: download controls <downloadCommand> |
---|
| 694 | # USAGE: download start ?widget? |
---|
[210] | 695 | # USAGE: download now ?widget? |
---|
[50] | 696 | # |
---|
| 697 | # Spools the current result so the user can download it. |
---|
| 698 | # ---------------------------------------------------------------------- |
---|
[210] | 699 | itcl::body Rappture::Analyzer::download {option args} { |
---|
[1077] | 700 | set title [$itk_component(resultselector) value] |
---|
| 701 | set page [$itk_component(resultselector) translate $title] |
---|
[193] | 702 | |
---|
[1077] | 703 | switch -- $option { |
---|
[1663] | 704 | coming { |
---|
| 705 | # |
---|
| 706 | # Warn result that a download is coming, in case |
---|
| 707 | # it needs to take a screen snap. |
---|
| 708 | # |
---|
| 709 | if {![regexp {^(|@download|---)$} $page]} { |
---|
| 710 | set f [$itk_component(resultpages) page $page] |
---|
| 711 | $f.rviewer download coming |
---|
| 712 | } |
---|
| 713 | } |
---|
| 714 | controls { |
---|
| 715 | # no controls for this download yet |
---|
| 716 | return "" |
---|
| 717 | } |
---|
| 718 | start { |
---|
| 719 | set widget $itk_component(download) |
---|
| 720 | if {[llength $args] > 0} { |
---|
| 721 | set widget [lindex $args 0] |
---|
| 722 | if {[catch {winfo class $widget}]} { |
---|
| 723 | set widget $itk_component(download) |
---|
| 724 | } |
---|
| 725 | } |
---|
| 726 | # |
---|
| 727 | # See if this download has any controls. If so, then |
---|
| 728 | # post them now and let the user continue the download |
---|
| 729 | # after selecting a file format. |
---|
| 730 | # |
---|
| 731 | if {$page != ""} { |
---|
| 732 | set ext "" |
---|
| 733 | set f [$itk_component(resultpages) page $page] |
---|
| 734 | set arg [itcl::code $this download now $widget] |
---|
| 735 | set popup [$f.rviewer download controls $arg] |
---|
| 736 | if {"" != $popup} { |
---|
| 737 | $popup activate $widget below |
---|
| 738 | } else { |
---|
| 739 | download now $widget |
---|
| 740 | } |
---|
| 741 | } else { |
---|
| 742 | # this shouldn't happen |
---|
| 743 | set file error.html |
---|
| 744 | set data "<h1>Not Found</h1>There is no result selected." |
---|
| 745 | } |
---|
| 746 | } |
---|
| 747 | now { |
---|
| 748 | set widget $itk_component(download) |
---|
| 749 | if {[llength $args] > 0} { |
---|
| 750 | set widget [lindex $args 0] |
---|
| 751 | if {[catch {winfo class $widget}]} { |
---|
| 752 | set widget $itk_component(download) |
---|
| 753 | } |
---|
| 754 | } |
---|
| 755 | # |
---|
| 756 | # Perform the actual download. |
---|
| 757 | # |
---|
| 758 | if {$page != ""} { |
---|
| 759 | set ext "" |
---|
| 760 | set f [$itk_component(resultpages) page $page] |
---|
| 761 | set item [$itk_component(resultselector) value] |
---|
| 762 | set result [$f.rviewer download now $widget $_appName $item] |
---|
| 763 | if { $result == "" } { |
---|
| 764 | return; # User cancelled the download. |
---|
| 765 | } |
---|
| 766 | foreach {ext data} $result break |
---|
| 767 | if {"" == $ext} { |
---|
| 768 | if {"" != $widget} { |
---|
| 769 | Rappture::Tooltip::cue $widget \ |
---|
| 770 | "Can't download this result." |
---|
| 771 | } |
---|
| 772 | return |
---|
| 773 | } |
---|
| 774 | regsub -all {[\ -\/\:-\@\{-\~]} $title {} title |
---|
| 775 | set file "$title$ext" |
---|
| 776 | } else { |
---|
| 777 | # this shouldn't happen |
---|
| 778 | set file error.html |
---|
| 779 | set data "<h1>Not Found</h1>There is no result selected." |
---|
| 780 | } |
---|
[50] | 781 | |
---|
[1663] | 782 | set mesg [Rappture::filexfer::download $data $file] |
---|
| 783 | if {[string length $mesg] > 0} { |
---|
| 784 | Rappture::Tooltip::cue $widget $mesg |
---|
| 785 | } |
---|
| 786 | } |
---|
| 787 | default { |
---|
| 788 | error "bad option \"$option\": should be coming, controls, now, start" |
---|
| 789 | } |
---|
[50] | 790 | } |
---|
| 791 | } |
---|
| 792 | |
---|
| 793 | # ---------------------------------------------------------------------- |
---|
[11] | 794 | # USAGE: _plot ?<index> <options> <index> <options>...? |
---|
| 795 | # |
---|
| 796 | # Used internally to update the plot shown in the current result |
---|
| 797 | # viewer whenever the resultset settings have changed. Causes the |
---|
| 798 | # desired results to show up on screen. |
---|
| 799 | # ---------------------------------------------------------------------- |
---|
| 800 | itcl::body Rappture::Analyzer::_plot {args} { |
---|
| 801 | set _plotlist $args |
---|
| 802 | |
---|
[1] | 803 | set page [$itk_component(resultselector) value] |
---|
| 804 | set page [$itk_component(resultselector) translate $page] |
---|
[43] | 805 | if {"" != $page} { |
---|
[1663] | 806 | set f [$itk_component(resultpages) page $page] |
---|
| 807 | $f.rviewer plot clear |
---|
| 808 | foreach {index opts} $_plotlist { |
---|
| 809 | $f.rviewer plot add $index $opts |
---|
| 810 | } |
---|
[11] | 811 | } |
---|
[1] | 812 | } |
---|
| 813 | |
---|
| 814 | # ---------------------------------------------------------------------- |
---|
[13] | 815 | # USAGE: _reorder <compList> |
---|
[1] | 816 | # |
---|
[11] | 817 | # Used internally to change the order of a series of output components |
---|
| 818 | # found in the <output> section. Moves the <log> elements to the end |
---|
| 819 | # and returns the updated list. |
---|
[1] | 820 | # ---------------------------------------------------------------------- |
---|
[11] | 821 | itcl::body Rappture::Analyzer::_reorder {comps} { |
---|
| 822 | set i 0 |
---|
| 823 | set max [llength $comps] |
---|
| 824 | while {$i < $max} { |
---|
[1663] | 825 | set c [lindex $comps $i] |
---|
| 826 | if {[string match log* $c]} { |
---|
| 827 | set comps [lreplace $comps $i $i] |
---|
| 828 | lappend comps $c |
---|
| 829 | incr max -1 |
---|
| 830 | } else { |
---|
| 831 | incr i |
---|
| 832 | } |
---|
[1] | 833 | } |
---|
[11] | 834 | return $comps |
---|
[1] | 835 | } |
---|
| 836 | |
---|
| 837 | # ---------------------------------------------------------------------- |
---|
[11] | 838 | # USAGE: _autoLabel <xmlobj> <path> <title> <cntVar> |
---|
[1] | 839 | # |
---|
[11] | 840 | # Used internally to check for an about.label property at the <path> |
---|
| 841 | # in <xmlobj>. If this object doesn't have a label, then one is |
---|
| 842 | # supplied using the given <title>. The <cntVar> is an array of |
---|
| 843 | # counters in the calling scopes for titles that have been used |
---|
| 844 | # in the past. This is used to create titles like "Plot #2" the |
---|
| 845 | # second time it is encountered. |
---|
| 846 | # |
---|
| 847 | # The <xmlobj> is updated so that the label is inserted directly in |
---|
| 848 | # the tree. |
---|
[1] | 849 | # ---------------------------------------------------------------------- |
---|
[11] | 850 | itcl::body Rappture::Analyzer::_autoLabel {xmlobj path title cntVar} { |
---|
| 851 | upvar $cntVar counters |
---|
| 852 | |
---|
[13] | 853 | set group [$xmlobj get $path.about.group] |
---|
[11] | 854 | set label [$xmlobj get $path.about.label] |
---|
| 855 | if {"" == $label} { |
---|
[1663] | 856 | # no label -- make one up using the title specified |
---|
| 857 | if {![info exists counters($group-$title)]} { |
---|
| 858 | set counters($group-$title) 1 |
---|
| 859 | set label $title |
---|
| 860 | } else { |
---|
| 861 | set label "$title (#[incr counters($group-$title)])" |
---|
| 862 | } |
---|
| 863 | $xmlobj put $path.about.label $label |
---|
[11] | 864 | } else { |
---|
[1663] | 865 | # handle the case of two identical labels in <output> |
---|
| 866 | if {![info exists counters($group-$label)]} { |
---|
| 867 | set counters($group-$label) 1 |
---|
| 868 | } else { |
---|
| 869 | set label "$label (#[incr counters($group-$label)])" |
---|
| 870 | $xmlobj put $path.about.label $label |
---|
| 871 | } |
---|
[1] | 872 | } |
---|
[11] | 873 | return $label |
---|
[1] | 874 | } |
---|
| 875 | |
---|
| 876 | # ---------------------------------------------------------------------- |
---|
[11] | 877 | # USAGE: _fixResult |
---|
[1] | 878 | # |
---|
[11] | 879 | # Used internally to change the result page being displayed whenever |
---|
| 880 | # the user selects a page from the results combobox. |
---|
[1] | 881 | # ---------------------------------------------------------------------- |
---|
[11] | 882 | itcl::body Rappture::Analyzer::_fixResult {} { |
---|
[210] | 883 | set name [$itk_component(resultselector) value] |
---|
| 884 | set page "" |
---|
| 885 | if {"" != $name} { |
---|
[1663] | 886 | set page [$itk_component(resultselector) translate $name] |
---|
[210] | 887 | } |
---|
| 888 | if {$page == "@download"} { |
---|
[1663] | 889 | # put the combobox back to its last value |
---|
| 890 | $itk_component(resultselector) component entry configure -state normal |
---|
| 891 | $itk_component(resultselector) component entry delete 0 end |
---|
| 892 | $itk_component(resultselector) component entry insert end $_lastlabel |
---|
| 893 | $itk_component(resultselector) component entry configure -state disabled |
---|
| 894 | # perform the actual download |
---|
| 895 | download start $itk_component(download) |
---|
[210] | 896 | } elseif {$page == "---"} { |
---|
[1663] | 897 | # put the combobox back to its last value |
---|
| 898 | $itk_component(resultselector) component entry configure -state normal |
---|
| 899 | $itk_component(resultselector) component entry delete 0 end |
---|
| 900 | $itk_component(resultselector) component entry insert end $_lastlabel |
---|
| 901 | $itk_component(resultselector) component entry configure -state disabled |
---|
[216] | 902 | } elseif {$page != ""} { |
---|
[1663] | 903 | set _lastlabel $name |
---|
| 904 | set win [winfo toplevel $itk_component(hull)] |
---|
| 905 | blt::busy hold $win |
---|
| 906 | $itk_component(resultpages) current $page |
---|
[11] | 907 | |
---|
[1663] | 908 | set f [$itk_component(resultpages) page $page] |
---|
| 909 | $f.rviewer plot clear |
---|
| 910 | eval $f.rviewer plot add $_plotlist |
---|
| 911 | blt::busy release [winfo toplevel $itk_component(hull)] |
---|
[13] | 912 | } |
---|
[11] | 913 | } |
---|
| 914 | |
---|
| 915 | # ---------------------------------------------------------------------- |
---|
| 916 | # USAGE: _fixSize |
---|
| 917 | # |
---|
| 918 | # Used internally to change the size of the result set area whenever |
---|
| 919 | # a new control appears. Adjusts the size available for the result |
---|
| 920 | # set up to some maximum. |
---|
| 921 | # ---------------------------------------------------------------------- |
---|
| 922 | itcl::body Rappture::Analyzer::_fixSize {} { |
---|
[413] | 923 | set ht [winfo height $itk_component(results)] |
---|
| 924 | if {$ht <= 1} { set ht [winfo reqheight $itk_component(results)] } |
---|
| 925 | set cntlht [$itk_component(resultset) size -controlarea] |
---|
| 926 | set frac [expr {double($cntlht)/$ht}] |
---|
| 927 | |
---|
| 928 | if {$frac < 0.4} { |
---|
[1663] | 929 | $itk_component(results) fraction end $frac |
---|
[1] | 930 | } |
---|
[11] | 931 | _fixSimControl |
---|
| 932 | } |
---|
[1] | 933 | |
---|
[11] | 934 | # ---------------------------------------------------------------------- |
---|
| 935 | # USAGE: _simState <boolean> ?<message>? ?<settings>? |
---|
| 936 | # |
---|
| 937 | # Used internally to change the "Simulation" button on or off. |
---|
| 938 | # If the <boolean> is on, then any <message> and <settings> are |
---|
[1159] | 939 | # displayed as well. If the <boolean> is off, then only display |
---|
| 940 | # the message. The <message> is a note to the user about |
---|
[11] | 941 | # what will be simulated, and the <settings> are a list of |
---|
| 942 | # tool parameter settings of the form {path1 val1 path2 val2 ...}. |
---|
| 943 | # When these are in place, the next Simulate operation will use |
---|
| 944 | # these settings. This helps fill in missing data values. |
---|
| 945 | # ---------------------------------------------------------------------- |
---|
| 946 | itcl::body Rappture::Analyzer::_simState {state args} { |
---|
| 947 | if {$state} { |
---|
[1663] | 948 | $itk_interior.simol configure \ |
---|
| 949 | -background $itk_option(-simcontrolactiveoutline) |
---|
| 950 | configure -simcontrolcolor $itk_option(-simcontrolactivebackground) |
---|
[1] | 951 | |
---|
[1663] | 952 | $itk_component(abort) configure -state disabled |
---|
| 953 | $itk_component(simulate) configure -state normal \ |
---|
| 954 | -command [itcl::code $this simulate] |
---|
[1] | 955 | |
---|
[1663] | 956 | # |
---|
| 957 | # If there's a special message, then put it up next to the button. |
---|
| 958 | # |
---|
| 959 | set mesg [lindex $args 0] |
---|
| 960 | if {"" != $mesg} { |
---|
| 961 | $itk_component(simstatus) configure -state normal |
---|
| 962 | $itk_component(simstatus) delete 1.0 end |
---|
| 963 | $itk_component(simstatus) insert end $mesg |
---|
[1] | 964 | |
---|
[1663] | 965 | # |
---|
| 966 | # If there are any settings, then install them in the |
---|
| 967 | # "Simulate" button. Also, pop them up as a tooltip |
---|
| 968 | # for the message. |
---|
| 969 | # |
---|
| 970 | set settings [lindex $args 1] |
---|
| 971 | if {[llength $settings] > 0} { |
---|
| 972 | $itk_component(simulate) configure \ |
---|
| 973 | -command [eval itcl::code $this simulate $settings] |
---|
[8] | 974 | |
---|
[1663] | 975 | set details "" |
---|
| 976 | foreach {path val} $settings { |
---|
| 977 | set str [$_tool xml get $path.about.label] |
---|
| 978 | if {"" == $str} { |
---|
[2241] | 979 | set str [$_tool xml element -as id $path] |
---|
[1663] | 980 | } |
---|
| 981 | append details "$str = $val\n" |
---|
| 982 | } |
---|
| 983 | set details [string trim $details] |
---|
[8] | 984 | |
---|
[1663] | 985 | Rappture::Tooltip::for $itk_component(simstatus) $details |
---|
| 986 | $itk_component(simstatus) insert end " " |
---|
| 987 | $itk_component(simstatus) insert end "(details...)" popup |
---|
| 988 | } |
---|
| 989 | $itk_component(simstatus) configure -state disabled |
---|
| 990 | } |
---|
[11] | 991 | } else { |
---|
[1663] | 992 | if {"" != $itk_option(-simcontrolbackground)} { |
---|
| 993 | set simcbg $itk_option(-simcontrolbackground) |
---|
| 994 | } else { |
---|
| 995 | set simcbg $itk_option(-background) |
---|
| 996 | } |
---|
| 997 | $itk_interior.simol configure \ |
---|
| 998 | -background $itk_option(-simcontroloutline) |
---|
| 999 | configure -simcontrolcolor $simcbg |
---|
[1] | 1000 | |
---|
[1663] | 1001 | $itk_component(simulate) configure -state disabled |
---|
| 1002 | $itk_component(abort) configure -state normal |
---|
[11] | 1003 | |
---|
[1663] | 1004 | $itk_component(simstatus) configure -state normal |
---|
| 1005 | $itk_component(simstatus) delete 1.0 end |
---|
| 1006 | set mesg [lindex $args 0] |
---|
| 1007 | if {"" != $mesg} { |
---|
| 1008 | $itk_component(simstatus) insert end $mesg |
---|
| 1009 | } |
---|
| 1010 | $itk_component(simstatus) configure -state disabled |
---|
[1] | 1011 | } |
---|
[11] | 1012 | } |
---|
[1] | 1013 | |
---|
[11] | 1014 | # ---------------------------------------------------------------------- |
---|
[23] | 1015 | # USAGE: _simOutput <message> |
---|
| 1016 | # |
---|
| 1017 | # Invoked automatically whenever output comes in while running the |
---|
| 1018 | # tool. Extracts any =RAPPTURE-???=> messages from the output and |
---|
| 1019 | # sends the output to the display. For example, any |
---|
| 1020 | # =RAPPTURE-PROGRESS=> message pops up the progress meter and updates |
---|
| 1021 | # it to show the latest progress message. This is useful for |
---|
| 1022 | # long-running tools, to let the user know how much longer the |
---|
| 1023 | # simulation will take. |
---|
| 1024 | # ---------------------------------------------------------------------- |
---|
| 1025 | itcl::body Rappture::Analyzer::_simOutput {message} { |
---|
| 1026 | # |
---|
| 1027 | # Scan through and pick out any =RAPPTURE-PROGRESS=> messages first. |
---|
| 1028 | # |
---|
| 1029 | while {[regexp -indices \ |
---|
[1663] | 1030 | {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)} $message \ |
---|
| 1031 | match percent mesg]} { |
---|
[23] | 1032 | |
---|
[1663] | 1033 | foreach {i0 i1} $percent break |
---|
| 1034 | set percent [string range $message $i0 $i1] |
---|
[23] | 1035 | |
---|
[1663] | 1036 | foreach {i0 i1} $mesg break |
---|
| 1037 | set mesg [string range $message $i0 $i1] |
---|
[23] | 1038 | |
---|
[1663] | 1039 | pack $itk_component(progress) -fill x -padx 10 -pady 10 |
---|
| 1040 | $itk_component(progress) settings -percent $percent -message $mesg |
---|
[23] | 1041 | |
---|
[1663] | 1042 | foreach {i0 i1} $match break |
---|
| 1043 | set message [string replace $message $i0 $i1] |
---|
[23] | 1044 | } |
---|
| 1045 | |
---|
| 1046 | # |
---|
| 1047 | # Break up the remaining lines according to =RAPPTURE-ERROR=> messages. |
---|
| 1048 | # Show errors in a special color. |
---|
| 1049 | # |
---|
| 1050 | $itk_component(runinfo) configure -state normal |
---|
| 1051 | |
---|
| 1052 | while {[regexp -indices \ |
---|
[1663] | 1053 | {=RAPPTURE-([a-zA-Z]+)=>([^\n]*)(\n|$)} $message \ |
---|
| 1054 | match type mesg]} { |
---|
[23] | 1055 | |
---|
[1663] | 1056 | foreach {i0 i1} $match break |
---|
| 1057 | set first [string range $message 0 [expr {$i0-1}]] |
---|
| 1058 | if {[string length $first] > 0} { |
---|
| 1059 | $itk_component(runinfo) insert end $first |
---|
| 1060 | $itk_component(runinfo) insert end \n |
---|
| 1061 | } |
---|
[23] | 1062 | |
---|
[1663] | 1063 | foreach {t0 t1} $type break |
---|
| 1064 | set type [string range $message $t0 $t1] |
---|
| 1065 | foreach {m0 m1} $mesg break |
---|
| 1066 | set mesg [string range $message $m0 $m1] |
---|
| 1067 | if {[string length $mesg] > 0 && $type != "RUN"} { |
---|
| 1068 | $itk_component(runinfo) insert end $mesg $type |
---|
| 1069 | $itk_component(runinfo) insert end \n $type |
---|
| 1070 | } |
---|
[23] | 1071 | |
---|
[1663] | 1072 | set message [string range $message [expr {$i1+1}] end] |
---|
[23] | 1073 | } |
---|
| 1074 | |
---|
| 1075 | if {[string length $message] > 0} { |
---|
[1663] | 1076 | $itk_component(runinfo) insert end $message |
---|
| 1077 | if {[$itk_component(runinfo) get end-2char] != "\n"} { |
---|
| 1078 | $itk_component(runinfo) insert end "\n" |
---|
| 1079 | } |
---|
| 1080 | $itk_component(runinfo) see end |
---|
[23] | 1081 | } |
---|
| 1082 | $itk_component(runinfo) configure -state disabled |
---|
| 1083 | } |
---|
| 1084 | |
---|
| 1085 | # ---------------------------------------------------------------------- |
---|
[413] | 1086 | # USAGE: _resultTooltip |
---|
| 1087 | # |
---|
| 1088 | # Used internally to build the tooltip string displayed for the |
---|
| 1089 | # result selector. If the current page has an associated description, |
---|
| 1090 | # then it is displayed beneath the result. |
---|
| 1091 | # |
---|
| 1092 | # Returns the string for the tooltip. |
---|
| 1093 | # ---------------------------------------------------------------------- |
---|
| 1094 | itcl::body Rappture::Analyzer::_resultTooltip {} { |
---|
| 1095 | set tip "" |
---|
| 1096 | set name [$itk_component(resultselector) value] |
---|
| 1097 | if {[info exists _label2desc($name)] && |
---|
[1663] | 1098 | [string length $_label2desc($name)] > 0} { |
---|
| 1099 | append tip "$_label2desc($name)\n\n" |
---|
[413] | 1100 | } |
---|
| 1101 | if {[array size _label2page] > 1} { |
---|
[1663] | 1102 | append tip "Use this control to display other output results." |
---|
[413] | 1103 | } |
---|
| 1104 | return $tip |
---|
| 1105 | } |
---|
| 1106 | |
---|
| 1107 | # ---------------------------------------------------------------------- |
---|
[11] | 1108 | # USAGE: _fixSimControl |
---|
| 1109 | # |
---|
| 1110 | # Used internally to add or remove the simulation control at the |
---|
| 1111 | # top of the analysis area. This is controlled by the -simcontrol |
---|
| 1112 | # option. |
---|
| 1113 | # ---------------------------------------------------------------------- |
---|
| 1114 | itcl::body Rappture::Analyzer::_fixSimControl {} { |
---|
| 1115 | switch -- $itk_option(-simcontrol) { |
---|
[1663] | 1116 | on { |
---|
| 1117 | pack $itk_interior.simol -fill x -before $itk_interior.nb |
---|
| 1118 | } |
---|
| 1119 | off { |
---|
| 1120 | pack forget $itk_interior.simol |
---|
| 1121 | } |
---|
| 1122 | auto { |
---|
| 1123 | # |
---|
| 1124 | # If we have two or more radiodials, then there is a |
---|
| 1125 | # chance of encountering a combination of parameters |
---|
| 1126 | # with no data, requiring simulation. |
---|
| 1127 | # |
---|
| 1128 | if {[$itk_component(resultset) size -controls] >= 2} { |
---|
| 1129 | pack $itk_interior.simol -fill x -before $itk_interior.nb |
---|
| 1130 | } else { |
---|
| 1131 | pack forget $itk_interior.simol |
---|
| 1132 | } |
---|
| 1133 | } |
---|
| 1134 | default { |
---|
| 1135 | error "bad value \"$itk_option(-simcontrol)\": should be on, off, auto" |
---|
| 1136 | } |
---|
[1] | 1137 | } |
---|
| 1138 | } |
---|
[11] | 1139 | |
---|
| 1140 | # ---------------------------------------------------------------------- |
---|
[1159] | 1141 | # USAGE: _fixNotebook |
---|
| 1142 | # |
---|
| 1143 | # Used internally to switch the active notebook page |
---|
| 1144 | # ---------------------------------------------------------------------- |
---|
| 1145 | itcl::body Rappture::Analyzer::_fixNotebook {} { |
---|
| 1146 | switch -- $itk_option(-notebookpage) { |
---|
[1663] | 1147 | about { |
---|
| 1148 | $itk_component(notebook) current about |
---|
| 1149 | } |
---|
| 1150 | simulate { |
---|
| 1151 | $itk_component(notebook) current simulate |
---|
| 1152 | } |
---|
| 1153 | analyze { |
---|
| 1154 | $itk_component(notebook) current analyze |
---|
| 1155 | } |
---|
| 1156 | default { |
---|
| 1157 | error "bad value \"$itk_option(-notebookpage)\": should be about, simulate, analyze" |
---|
| 1158 | } |
---|
[1159] | 1159 | } |
---|
| 1160 | } |
---|
| 1161 | |
---|
| 1162 | # ---------------------------------------------------------------------- |
---|
[1797] | 1163 | # USAGE: _isPdbTrajectory <data> |
---|
[1791] | 1164 | # |
---|
| 1165 | # Used internally to determine whether pdb or lammps data represents a |
---|
[2175] | 1166 | # trajectory rather than a single frame |
---|
[1791] | 1167 | # ---------------------------------------------------------------------- |
---|
[1797] | 1168 | itcl::body Rappture::Analyzer::_isPdbTrajectory {data} { |
---|
| 1169 | if { [llength $data] == 0 } { |
---|
[1929] | 1170 | return 0 |
---|
[1791] | 1171 | } |
---|
[1797] | 1172 | set nModels 0 |
---|
| 1173 | foreach line $data { |
---|
[1929] | 1174 | if { [string match "MODEL*" $line] } { |
---|
| 1175 | incr nModels |
---|
| 1176 | if { $nModels > 1 } { |
---|
| 1177 | # Stop if more than one model found. No need to count them |
---|
| 1178 | # all. |
---|
| 1179 | return 1 |
---|
| 1180 | } |
---|
| 1181 | } |
---|
[1797] | 1182 | } |
---|
| 1183 | return 0 |
---|
| 1184 | } |
---|
[1791] | 1185 | |
---|
[1797] | 1186 | # ---------------------------------------------------------------------- |
---|
| 1187 | # USAGE: _isLammpsTrajectory <data> |
---|
| 1188 | # |
---|
| 1189 | # Used internally to determine whether pdb or lammps data represents a |
---|
[2175] | 1190 | # trajectory rather than a single frame |
---|
[1797] | 1191 | # ---------------------------------------------------------------------- |
---|
| 1192 | itcl::body Rappture::Analyzer::_isLammpsTrajectory { data } { |
---|
| 1193 | if { [llength $data] == 0 } { |
---|
[1929] | 1194 | return 0 |
---|
[1797] | 1195 | } |
---|
| 1196 | set nModels 0 |
---|
| 1197 | foreach line $data { |
---|
[1929] | 1198 | if { [regexp {^[\t ]*ITEM:[ \t]+TIMESTEP} $line] } { |
---|
| 1199 | incr nModels |
---|
| 1200 | if { $nModels > 1 } { |
---|
| 1201 | # Stop if more than one model found. No need to count them |
---|
| 1202 | # all. |
---|
| 1203 | return 1 |
---|
| 1204 | } |
---|
| 1205 | } |
---|
[1797] | 1206 | } |
---|
| 1207 | return 0 |
---|
[1791] | 1208 | } |
---|
| 1209 | |
---|
| 1210 | # ---------------------------------------------------------------------- |
---|
[1830] | 1211 | # USAGE: _pdbToSequence <xmlobj> ?<path>? |
---|
[1791] | 1212 | # |
---|
[1830] | 1213 | # If the molecule element is a trajectory, delete the original |
---|
| 1214 | # and create a sequence of individual molecules. |
---|
[1791] | 1215 | # Used internally to detect any molecule output elements that contain |
---|
| 1216 | # trajectory data. Trajectories will be converted into sequences of |
---|
| 1217 | # individual molecules. All other elements will be unaffected. Scans |
---|
| 1218 | # the entire xml tree if a starting path is not specified. |
---|
| 1219 | # ---------------------------------------------------------------------- |
---|
[1797] | 1220 | itcl::body Rappture::Analyzer::_pdbToSequence {xmlobj path id child data} { |
---|
[1791] | 1221 | |
---|
[1797] | 1222 | set seqLabel [$xmlobj get ${child}.about.label] |
---|
| 1223 | set descr [$xmlobj get ${child}.about.description] |
---|
| 1224 | set formula [$xmlobj get ${child}.components.molecule.formula] |
---|
| 1225 | $xmlobj remove $child |
---|
[1791] | 1226 | |
---|
[1830] | 1227 | set sequence $path.sequence($id) |
---|
| 1228 | $xmlobj put ${sequence}.about.label $seqLabel |
---|
| 1229 | $xmlobj put ${sequence}.about.description $descr |
---|
[2175] | 1230 | $xmlobj put ${sequence}.index.label "Frame" |
---|
[1791] | 1231 | |
---|
[2175] | 1232 | set frameNum 0 |
---|
[1830] | 1233 | set numLines [llength $data] |
---|
| 1234 | for { set i 0 } { $i < $numLines } { incr i } { |
---|
[1929] | 1235 | set line [lindex $data $i] |
---|
| 1236 | set line [string trim $line] |
---|
| 1237 | set contents {} |
---|
| 1238 | if { [string match "MODEL*" $line] } { |
---|
| 1239 | # Save the contents until we get an ENDMDL record. |
---|
| 1240 | for {} { $i < $numLines } { incr i } { |
---|
| 1241 | set line [lindex $data $i] |
---|
| 1242 | set line [string trim $line] |
---|
| 1243 | if { $line == "" } { |
---|
| 1244 | continue; # Skip blank lines. |
---|
| 1245 | } |
---|
| 1246 | if { [string match "ENDMDL*" $line] } { |
---|
| 1247 | break; |
---|
| 1248 | } |
---|
| 1249 | append contents $line\n |
---|
| 1250 | } |
---|
[2175] | 1251 | set frame ${sequence}.element($frameNum) |
---|
| 1252 | $xmlobj put ${frame}.index $frameNum |
---|
[1929] | 1253 | |
---|
[2175] | 1254 | set molecule ${frame}.structure.components.molecule |
---|
[1929] | 1255 | $xmlobj put ${molecule}.pdb $contents |
---|
| 1256 | $xmlobj put ${molecule}.formula $formula |
---|
[2175] | 1257 | incr frameNum |
---|
[1929] | 1258 | } |
---|
[1797] | 1259 | } |
---|
| 1260 | } |
---|
[1791] | 1261 | |
---|
[1830] | 1262 | # ---------------------------------------------------------------------- |
---|
| 1263 | # USAGE: _lammpsToSequence <xmlobj> ?<path>? |
---|
| 1264 | # |
---|
| 1265 | # If the molecule element is a trajectory, delete the original |
---|
| 1266 | # and create a sequence of individual molecules. |
---|
| 1267 | # Used internally to detect any molecule output elements that contain |
---|
| 1268 | # trajectory data. Trajectories will be converted into sequences of |
---|
| 1269 | # individual molecules. All other elements will be unaffected. Scans |
---|
| 1270 | # the entire xml tree if a starting path is not specified. |
---|
| 1271 | # ---------------------------------------------------------------------- |
---|
[1797] | 1272 | itcl::body Rappture::Analyzer::_lammpsToSequence {xmlobj path id child data} { |
---|
| 1273 | |
---|
| 1274 | set seqLabel [$xmlobj get ${child}.about.label] |
---|
| 1275 | set descr [$xmlobj get ${child}.about.description] |
---|
| 1276 | set typemap [$xmlobj get ${child}.components.molecule.lammpstypemap] |
---|
| 1277 | $xmlobj remove $child |
---|
| 1278 | |
---|
[1830] | 1279 | set sequence ${path}.sequence($id) |
---|
| 1280 | $xmlobj put ${sequence}.about.label $seqLabel |
---|
| 1281 | $xmlobj put ${sequence}.about.description $descr |
---|
[2175] | 1282 | $xmlobj put ${sequence}.index.label "Frame" |
---|
[1797] | 1283 | |
---|
[2175] | 1284 | set frameNum 0 |
---|
| 1285 | set frameContents "" |
---|
[1797] | 1286 | set inModel 0 |
---|
| 1287 | foreach line $data { |
---|
[1929] | 1288 | set line [string trim $line] |
---|
| 1289 | if { $line == "" } { |
---|
| 1290 | continue; # Skip blank lines |
---|
| 1291 | } |
---|
| 1292 | if {[regexp {^[\t ]*ITEM:[ \t]+ATOMS} $line] } { |
---|
[2175] | 1293 | if { $inModel && $frameContents != "" } { |
---|
| 1294 | set frame ${sequence}.element($frameNum) |
---|
| 1295 | $xmlobj put ${frame}.index $frameNum |
---|
[1929] | 1296 | |
---|
[2175] | 1297 | set molecule ${frame}.structure.components.molecule |
---|
| 1298 | $xmlobj put ${molecule}.lammps $frameContents |
---|
[1929] | 1299 | $xmlobj put ${molecule}.lammpstypemap $typemap |
---|
| 1300 | |
---|
[2175] | 1301 | incr frameNum |
---|
| 1302 | set frameContents "" |
---|
[1929] | 1303 | } |
---|
| 1304 | set inModel 1 |
---|
| 1305 | } elseif { [scan $line "%d %d %f %f %f" a b c d e] == 5 } { |
---|
| 1306 | if { !$inModel } { |
---|
| 1307 | puts stderr "found \"$line\" without previous \"ITEM: ATOMS\"" |
---|
| 1308 | set inModel 1 |
---|
| 1309 | } |
---|
[2175] | 1310 | append frameContents $line\n |
---|
[1929] | 1311 | } |
---|
[1797] | 1312 | } |
---|
[2175] | 1313 | if { $frameContents != "" } { |
---|
| 1314 | set frame ${sequence}.element($frameNum) |
---|
| 1315 | $xmlobj put ${frame}.index $frameNum |
---|
[1929] | 1316 | |
---|
[2175] | 1317 | set molecule ${frame}.structure.components.molecule |
---|
| 1318 | $xmlobj put ${molecule}.lammps $frameContents |
---|
[1929] | 1319 | $xmlobj put ${molecule}.lammpstypemap $typemap |
---|
[1797] | 1320 | } |
---|
[1791] | 1321 | } |
---|
| 1322 | |
---|
| 1323 | # ---------------------------------------------------------------------- |
---|
[1830] | 1324 | # USAGE: _trajToSequence <xmlobj> ?<path>? |
---|
[1797] | 1325 | # |
---|
| 1326 | # Check for PDB and LAMMPS trajectories in molecule data and rewrite |
---|
| 1327 | # the individual models as a sequence of molecules. Used internally |
---|
| 1328 | # to detect any molecule output elements that contain trajectory data. |
---|
| 1329 | # Trajectories will be converted into sequences of individual molecules. |
---|
| 1330 | # All other elements will be unaffected. Scans the entire xml tree if a |
---|
| 1331 | # starting path is not specified. |
---|
| 1332 | # |
---|
| 1333 | # ---------------------------------------------------------------------- |
---|
| 1334 | itcl::body Rappture::Analyzer::_trajToSequence {xmlobj {path ""}} { |
---|
| 1335 | # Remove leading dot from path, if present. |
---|
| 1336 | if { [string index $path 0] == "." } { |
---|
[1929] | 1337 | set path [string range $path 1 end] |
---|
[1797] | 1338 | } |
---|
| 1339 | # Otherwise check each child. |
---|
| 1340 | foreach child [$xmlobj children $path] { |
---|
[1929] | 1341 | set current ${path}.${child} |
---|
| 1342 | if { [string match "structure*" $child] } { |
---|
| 1343 | set isTraj [$xmlobj get ${current}.components.molecule.trajectory] |
---|
| 1344 | if { $isTraj == "" || !$isTraj } { |
---|
| 1345 | continue; # Not a trajectory. |
---|
| 1346 | } |
---|
| 1347 | # Look for trajectory if molecule element found. Check both pdb |
---|
| 1348 | # data and lammps data. |
---|
| 1349 | set type [$xmlobj element -as type $current] |
---|
| 1350 | set id [$xmlobj element -as id $current] |
---|
| 1351 | set pdbdata [$xmlobj get ${current}.components.molecule.pdb] |
---|
| 1352 | set lammpsdata [$xmlobj get ${current}.components.molecule.lammps] |
---|
| 1353 | if { $pdbdata != "" && $lammpsdata != "" } { |
---|
| 1354 | puts stderr \ |
---|
| 1355 | "found both <pdb> and <lammps> elements: picking pdb" |
---|
| 1356 | } |
---|
| 1357 | set pdbdata [split $pdbdata \n] |
---|
| 1358 | set lammpsdata [split $lammpsdata \n] |
---|
| 1359 | if { [_isPdbTrajectory $pdbdata] } { |
---|
| 1360 | _pdbToSequence $xmlobj $path $id $current $pdbdata |
---|
| 1361 | } elseif { [_isLammpsTrajectory $lammpsdata] } { |
---|
| 1362 | _lammpsToSequence $xmlobj $path $id $current $lammpsdata |
---|
| 1363 | } |
---|
| 1364 | continue |
---|
| 1365 | } |
---|
| 1366 | if 0 { |
---|
| 1367 | # Recurse over all child nodes. |
---|
| 1368 | _trajToSequence $xmlobj $current |
---|
| 1369 | } |
---|
[1797] | 1370 | } |
---|
| 1371 | } |
---|
| 1372 | |
---|
| 1373 | # ---------------------------------------------------------------------- |
---|
[11] | 1374 | # CONFIGURATION OPTION: -simcontrol |
---|
| 1375 | # |
---|
| 1376 | # Controls whether or not the Simulate button is showing. In some |
---|
| 1377 | # cases, it is not needed. |
---|
| 1378 | # ---------------------------------------------------------------------- |
---|
| 1379 | itcl::configbody Rappture::Analyzer::simcontrol { |
---|
| 1380 | _fixSimControl |
---|
| 1381 | } |
---|
[1159] | 1382 | |
---|
| 1383 | # ---------------------------------------------------------------------- |
---|
| 1384 | # CONFIGURATION OPTION: -notebookpage |
---|
| 1385 | # |
---|
| 1386 | # Controls which page of the analyzer notebook is shown. It is |
---|
| 1387 | # particularly needed when using rerun, when you don't want to |
---|
| 1388 | # "simulate -ifneeded" because an actual simulation might be |
---|
| 1389 | # kicked off due to differences between tool.xml and run.xml |
---|
| 1390 | # ---------------------------------------------------------------------- |
---|
| 1391 | itcl::configbody Rappture::Analyzer::notebookpage { |
---|
| 1392 | _fixNotebook |
---|
| 1393 | } |
---|