Popup HUD - part 1 of 2
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This is a simple example showing how to create a "pop-up HUD" which allow you to move widgets off the interface to a separate screen ( HUD ) which can be hidden or shown with one click.
This lets you keep your main model interface free of clutter and easier to understand.
It's particularly nice if you only use the sliders during SETUP.
ALERT
There are two paired models here.
This model, "HUD-enabled-model.nlogo" assumes that the second model, "callable-HUD.nlogo" be in the same directory.
HOW IT WORKS
The extension LevelSpace ( ls ) is used to manage a second model which implements the HUD
HOW TO USE IT
The buttons SETUP, ONE STEP, and GO are the usual NetLogo controls. A few circular turtles are created that wander around the viewport.
The START-HUD button pops up the HUD where you can adjust the sliders which will set the number of turtles, their size, and their shape, but nothing is sent from the HUD to the main model until one of two things happens after you have all the new settings the way you want them:
1) you click the REQUEST-UPDATE button. or
2) you turn on automatic updates. ( more about that in a minute.)
In either case, if you have just started or if you have changed some slider from the starting value the "dirty-bit" is set to TRUE. meaning an update is warranted.
If either #1 or #2 is true, AND the dirty-bit is set, then the next pass of the main model's GO loop it will see that an update is available, fetch it from the HUD, and apply it to the viewport. At the same time, the HUDs status will be changed back to "idle", and the dirty-bit will be set to FALSE.
AUTO-UPDATE
If you have turned on the "document-updates?" switch on the HUD, a summary of the changes just made will be posted in the HUD's output area so you can confirm it.
If the main model's GO loop is not running, the HUD will wait with status = "ready" and the output-area showing "waiting..." until the main model's GO loop begins again.
Changed values are not queued up like transactions. If the HUD is "waiting" and you reset the sliders to some new values and click REQUEST-UPDATE again the old slider values request is simply discarded and the new ones put in its place.
If you don't want to batch your changes and fire them off manually with the REQUEST=UPDATE button, you can use automatic update instead.
To do that, turn ON the "AUTO-UPDATE?" switch on the HUD and press the START button just under it on the HUD. The "ticks" count on the HUD should be increasing. Every time you change something it will set the dirty-bit and every next pass of the main model's GO step those changes will be incorporated. For the most part your sliders are now "live" and as you move them the main model will update at the next pass of the GO loop.
HIDING AND SHOWING THE HUD
The hide-hud and show-HUD buttons leave the HUD running but hide or show the window.
STOPPING AND REMOVING and RESTARTING A NEW HUD
If you are entirely done with HUD you can remove it with the REMOVE-HUD button. If you want to restart the HUD, you can use the RESTART HUD Button.
THINGS TO TRY: Extending the Model
The HUD's viewing area could potentially be used to monitor creation of some input parameter, such as a Normal or Poisson distribution, tweak it to be what you want, and then click to change your main model to use the new distribution.
Potentially multiple HUDs could be used to change different parts of very complex models, involving a hundred sliders with only a dozen or so per HUD, while still fitting your main interface on a reasonable size screen. Each HUD could have its own viewing area to help setting your parameters, leaving your main viewing area for your model free.
Alternamtively, LevelSpace might create a viewing area that you position over your main interface and effectively lets you swap what is being displayed in the viewport.
NETLOGO FEATURES
This model uses LevelSpace, an extension that comes bundled with NetLogo 6.0+.
RELATED MODELS
KNOWN BUGS AND TESTING
As of 16-Jun-2022 this is new code with no history
- the comments in the Command Center are now always correct
- under some conditions unrequired output is generated in the HUD
- Aside fron that, the rest of the features seem to work correctly
- Please send information about detected bugs to wade.schuette@gmail.com
CREDITS AND PERMISSIONS
Copyright(c) 2022 by R. Wade Schuette ( wade.schuette@gmail.com) Attribution 4.0 International (CC BY 4.0) You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
for any purpose, even commercially.
Under the following terms:
Attribution — You must give appropriate credit and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
No warranty is made of fitness for any purpose. Use at your own risk!
Comments and Questions
;; model version 1.0, June 16, 2022 extensions [ ls ] globals [ ;;============= HUD related golbals HUD ;; model-ID reference HUD-state ;; none, idle, ready safety-delay-seconds;; wait time after an update, possibly not needed ;;============== variables in my main model ;; named differently from the HUD so it's clear which is which number-T size-T shape-T ] to setup clear-all ;; ====== HUD RELATED commands set HUD-state "none" set safety-delay-seconds 0 ;; ======= normal model commands ;; local version of these variables set number-T 3 set size-T 3 set shape-T "circle" create-turtles number-T [ set size size-T set shape shape-T set xcor random-xcor set ycor random-ycor ] reset-ticks end to go if not ( HUD-state = "none") [ check-HUD ] ;; The only HUD command in the GO loop ;; === usual model commands go next ask turtles [ set heading random 360 forward 1 ] tick end ;; ========= HUD related CODE begins here ==================================== ;; ;; NOTE: all the subroutines are named-HUD ;; ;; "HUD" is not a magic word. The Head's Up Display could ;; be called "apple" everywhere on both ends and this would still run. ;; ;; NOTE: all HUD interactions are driven by the model ;; the HUD never asks the model to do anything. ;; IN fact, the HUD has zero LevelSpace code in it and ;; doesn't even list the "ls" extension. ;; inbound commands, getting data FROM the HUD are like this: ;; substituting your values for "< something > " ;; ;; pattern: set[ HUD-variable ] ls:of HUD ;; example: set size-T [size-of-turtles ] ls:of HUD ;; ;; outbonund commands, setting a HUD variable from the model are like this: ;; pattern: ls:assign HUD;; example: ls:assign HUD status "idle" ;; ;; or to run a HUD subroutine from the model ;; pattern: ls:ask HUD [ < hud subroutine name > ] ;; example: ls:ask HUD [ mark-update-complete ] to check-HUD set HUD-state [status] ls:of HUD ;print (word "HUD-state is " HUD-state) if HUD-state = "ready" [ set number-T [number-of-turtles ] ls:of HUD set size-T [size-of-turtles ] ls:of HUD set shape-T [shape-of-turtles ] ls:of HUD ask turtles [die] create-turtles number-T[ set size size-T set shape shape-T set xcor random-xcor set ycor random-ycor ] ls:assign HUD status "idle" set HUD-state [status] ls:of HUD ls:ask HUD [ mark-update-complete ] ] wait safety-delay-seconds end to start-HUD ;; ?? are there dead models ??? if not ( HUD-state = "none") [ print "Destroying current HUD and starting fresh."] ls:reset startup-HUD setup-HUD check-HUD end to startup-HUD ;; this code expects callable-HUD.nlogo to be in the same directory as this model ;; if that is not true the path in the following line needs to be adjusted ls:create-interactive-models 1 "./callable-HUD.nlogo" set HUD last ls:models end to setup-HUD ls:ask HUD [ setup ] ; calls setup in all models in LevelSpace ls:assign HUD status "idle" reset-ticks ; now we're ready to go, so reset ticks end to show-HUD ifelse not (HUD-state = "none") [ ls:show HUD ][ print "There is no HUD to show!"] end to hide-HUD ifelse not (HUD-state = "none") [ ls:hide HUD ][ print "There is no HUD to hide!"] end to remove-HUD ifelse not (HUD-state = "none") [ ls:close HUD set HUD-state "none" ][ print "There is no HUD to remove!"] end ;; =========================== HUD RELATED CODE ENDS ========================= ; carefully [] might come in handy ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There is only one version of this model, created about 3 years ago by R. Wade Schuette.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Popup HUD - part 1 of 2.png | preview | Preview for 'Popup HUD - part 1 of 2' | about 3 years ago, by R. Wade Schuette | Download |
This model does not have any ancestors.
This model does not have any descendants.