Focal Point Basics Jobsheets

Megawidget Modification Examples

Purpose:

This jobsheet guides users through potential modifications to the dialog interfaces of the HID and recommenders, giving focal points increased exposure to the ease of modifying megawidgets. Specifically, the FFW HID dialogs will be edited. (Another task tweaking the FFRec may be added in the future)

Tasks:

RECOMMENDED PREPARATION: This jobsheet skips some of the exploration and understanding of Megawidget construction. For a jobsheet which includes this context, the following is recommended: "Changing the Default Impact Statement Selection For FL.W" (also called "Megawidget Default Logic" on jobsheets main page). 

 

TASK 1 (of 1): Specifying a finer increment in the "Rain So Far" spinner

This task will change the step value for the "Rain So Far" spinner box from 1 to a smaller increment of 0.5. This "Rain So Far" megawidget is common to the FF.W-specific HID and several others, and is housed in the CommonMetaData.py folder.

  1. Generate a blank FF.W hazard by following the below steps:
    1. Launch Hazard Services in CAVE
    2. Zoom to WFO Scale in your spatial display
    3. Click the "Drawing Tools" (Pencil icon) on the Hazard Services Toolbar, and select "Draw Polygon"
    4. Draw a polygon in the spatial display by left-clicking to create several vertices and right-clicking to finish
    5. In the HID which appears, select "FF.W.Convective (Flash Flood Warning)" from the Hazard Type drop-down
  2. Observe the default behavior of the "Rain So Far" megawidget as follows:
    1. Scroll down in the "Details" section of the HID until you see "Rain so far:"
    2. Click on any of the up/down arrows attached to the numerical entry fields in the "Between [#] and [#] inches of rain have fallen" choice

    3. Notice the default increment value, specifically that each click adds or subtracts 1.0 from the field value (in baseline behavior at least). This increment is what we aim to adjust.

    4. [BONUS STEP] Make note of the text labeling for this megawidget, such as "Rain so far:" and "inches of rain have fallen", etc., and try to spot that in the configuration files to come.

  3. Switch to the Localization Perspective by clicking on the "Open Perspective" icon at the top-right of your CAVE window, and choosing "Localization"
  4. In the Localization Perspective, navigate to the Hazard Meta Data sub-directory under the Hazard Services folder.
  5. Double click on CommonMetaData.py to show the available versions
    1. ADVANCED TIP: A Focal Point who did not know that this was the file to edit could have, among other techniques, used the Localization Perspective Search Tool to easily scan files for the "Rain so far" or "inches of rain have fallen" text labels which appear to be associated with the megawidget.
  6. Create a user override version if none exists (user override is best practice for testing changes):
    1. If there is only a BASE version: right click on BASE and select Create Override File, then select User
    2. If there is another version (e.g. SITE) you wish to use: right click on that file and select Copy To, then select User
  7. Double click on the USER version of CommonMetaData.py to open it for editing
  8. Open a reference copy of the existing CommonMetaData.py file, which will be used for comparing to and copying existing code for overrides.
    1. It's typically best to open the BASE version because most methods have not already been overridden in a higher-level override
  9. In the reference file you opened, scroll or search to find the "enterAmount" method (whose first line appears as "def enterAmount(self):" in CommonMetaData.py)
    1. INFO: This method defines the construction of just the "Between # and # inches of rain have fallen" megawidget, which itself is used as a choice under "Rain so far"
    2. [BONUS STEP] Notice that two methods above the "enterAmount" method is a method called "getRainAmt".
      1. This is the "parent" megawidget for our "enterAmount" choice, which you can see is constructed as a "RadioButtons" fieldType, AND which has the label "Rain so far:", as we see in the HID.
      2. Notice that, for the radio button "choices", we have a Python LIST with two entries, one of which is for "unknown" rain amount, and the second of which is our "enterAmount" method!
      3. The "Rain so far" megawiget, then, houses our "Between # and #" megawidget as one of its choices. It is very common in Hazard Services for some megawidgets to be embedded in other megawidgets
  10. Once found, select the entire enterAmount method by clicking and dragging from (and including) the "def enterAmount(self):" line which begins the function, all the way to (and including) the last line of the function which has the closing } bracket after the return statement.
  11. Copy the selected contents by right-clicking and selecting "Copy" from the pop-up menu, or by hitting CTRL-C on your keyboard
  12. Switch back to the USER override you were working on
  13. Paste the enterAmount method into your USER override on a blank line after the "class..." and "pass" lines, by right-clicking and selecting "Paste" from the pop-up menu, or by hitting CTRL-V on your keyboard
  14. In the USER copy of the enterAmount method you just pasted in, identify the two "FractionSpinner" fieldTypes embedded in the multi-level dictionary returned by this "enterAmount" method
    1. One will have a fieldName "rainSoFarLowerBound" below it, the other a fieldName "rainSoFarUpperBound"
  15. Identify the "incrementDelta" dictionary keys accompanying each fraction spinner, and observe their current value of 1 (in baseline behavior)
    1. This parameter for the "FractionSpinner" fieldType specifies how much the field value changes whenever the up/down arrows are pressed
  16. Change each of the incrementDelta values to 0.5, so that each line looks like the code below:
    "incrementDelta": 0.5,
    1. Make sure you've maintained proper indentation for your line by checking that it lines up with the previous line's "values" key, and also that there's a comma after 0.5
    2. Perform this step for both "FractionSpinners" fields in the "enterAmount" method
  17. [BONUS STEP] Notice how this megawidget constructs the "Between # and # inches of rain have fallen" label that we see in the HID:
    1. The primary "displayString" for this enterAmount choice is simply "Between"
    2. The first sub-megawidget presents a fraction spinner box, with no label
    3. The second sub-megawidget presents another fraction spinner box, but this time with a label "and" which will appear immediately to its left
    4. There is a third and final sub-megawidget, this time a simple "Label" fieldType, which allows simple text to be displayed, and which displays as its value "inches of rain have fallen", thus completing the choice text that we see in the HID
  18. You're finished with the needed edits! Proofread for Python syntax mistakes in any areas you edited.
  19. When finished, save the file by hitting Ctrl+S, or selecting Save from the File menu
    1. If a "File Version Conflict" is encountered, click OK to accept merge
    2. In the two-panel "Merge" tab that opens, make no changes, once again save the file by hitting Ctrl+s, then close the "Merge" tab
    3. When a "File Changed" message appears,  click Yes.
    4. This behavior will only be encountered each time a new override file that did not exist before is created and saved
  20. Switch back to D2D (or whichever localization you were previously using) to once again view Hazard Services
  21. Close any open HID, and then click on your FF.W hazard in the Hazard Services console to re-launch the HID
  22. Observe the UPDATED behavior of the "Rain So Far" megawidget:
    1. Scroll down in the "Details" section of the HID until you see "Rain so far:", and again click on any of the up/down arrows next to the numerical entry fields
    2. Notice the new increment of 0.5 in the field value- success!
  23. [BONUS STEP] Notice that we've actually affected this megawidget wherever it is used, i.e. by other hazard types as well
    1. In your open HID, switch the Hazard Type to "FA.Y (AREAL FLOOD ADVISORY)"
    2. Scroll down in the "Details" section of the HID until you see "Rain so far:", and again click on any of the up/down arrows next to the numerical entry fields, noticing that here too the fields increment by 0.5

    3. EXPLANATION: This gets at the commonality of certain megawidgets and how they are shared through CommonMetaData.py for multiple hazards. FF.W and FA.Y both consult CommonMetaData for the construction of this particular "enterAmount" fractionSpinner megawidget, and so the override we've applied to CommonMetaData.py affects both hazards! If you wanted different behavior for each, you would have to make hazard-specific overrides of this megawidget, but that is not covered here.

  24. Task Complete!

    1. IMPORTANT: You may wish to delete the override you made for the "enterAmount"  method if it is not suitable to your office.