ID 411950 - Lists of options in the UI for Graph State Variables are not updated when underlying options string array parameters are modified

Follow

Problem summary:

When changing entries within the options child string array parameter of a global Graph State Variable group parameter underneath the variables group parameter on the root node, e.g. rootNode.variables.shot.options, for example in response to a change in another Graph State Variable, e.g. rootNode.variables.show.value, a popup form widget that was created for the GSV isn't updated to reflect the change in options. This means that the combo box dropdown still shows the options previously available, and can therefore be out of sync with the underlying data, ie. the values stored string parameters as children of the options string array parameter.

Steps to reproduce:

  1. Save the following Python script to a .py file in the UIPlugins folder in your .katana home directory, e.g. ~/.katana/UIPlugins/GSV_show_shot_switcher.py:
    • 
      from Katana import Utils, Callbacks, NodegraphAPI
      
      def on_parameter_finalizeValue(args):
          """
          Collapsed event handler for C{"parameter_finalizeValue"} Katana events.
      
          Checks if the value of the global Graph State Variable B{show} has been
          finalized, and if so, updates the options of the B{shot} global GSV based
          on a pre-defined mapping of shots per show.
      
          @type args: C{list} of C{tuple}
          @param args: A collection of descriptions of Katana events of the
              C{"parameter_finalizeValue"} event type.
          """
          rootNode = NodegraphAPI.GetRootNode()
          showValueParameter = rootNode.getParameter('variables.show.value')
          shotValueParameter = rootNode.getParameter('variables.shot.value')
          shotOptionsParameter = rootNode.getParameter('variables.shot.options')
          showValueChanged = False
      
          for _eventType, _eventID, kwargs in args:
              showValueChanged = kwargs.get('param') is showValueParameter
      
          if not showValueChanged:
              return
      
          # Determine list of shots for the chosen show
          show = showValueParameter.getValue(0)
          shotsPerShow = {
              'A': ['aa%d' % (1 + i) for i in range(5)],
              'B': ['bb%d' % (1 + i) for i in range(8)],
              'C': ['cc%d' % (1 + i) for i in range(3)],
              'D': ['dd%d' % (1 + i) for i in range(4)],
          }
          shotOptions = shotsPerShow.get(show, [])
      
          # Rebuild the children of the shot options string array parameter, but
          # leaving the parameter itself intact, so that UI components that have been
          # created on top of it are not suddenly working with an orphaned parameter
          shotOptionsParameter.removeArrayElements(
              0, shotOptionsParameter.getNumChildren())
          for i, shotOption in enumerate(shotOptions):
              shotOptionParameter = shotOptionsParameter.insertArrayElement(i)
              shotOptionParameter.setValue(shotOption, 0)
      
          # Optional: Reset the choice of shot if it's not an option in the chosen
          # show
          #shot = shotValueParameter.getValue(0)
          #if shot and shot not in shotOptions:
          #    shotValueParameter.setValue('', 0)
      
      Utils.EventModule.RegisterCollapsedHandler(on_parameter_finalizeValue,
                                                 'parameter_finalizeValue')
      
      def onNewScene(objectHash):
          """
          Callback that is called when a new Katana project is created.
      
          Creates global Graph State Variables named B{show} and B{shot} and sets up
          some options for the B{show} parameter.
      
          @type objectHash: C{int} or C{None}
          @param objectHash: The hash of an object that was passed when the callback
              was called. Is C{None} for C{onNewScene} callbacks.
          """
          rootNode = NodegraphAPI.GetRootNode()
          variablesGroupParameter = rootNode.getParameter('variables')
      
          # Create a show GSV
          showGroupParameter = variablesGroupParameter.createChildGroup('show')
          showGroupParameter.createChildNumber('enable', 0)
          showGroupParameter.createChildString('value', '')
          optionsStringArrayParameter = showGroupParameter.createChildStringArray(
              'options', 0)
          showOptions = ['A', 'B', 'C', 'D']
          for i, option in enumerate(showOptions):
              optionsStringArrayParameter.insertArrayElement(i).setValue(option, 0)
      
          # Create a shot GSV
          shotGroupParameter = variablesGroupParameter.createChildGroup('shot')
          shotGroupParameter.createChildNumber('enable', 0)
          shotGroupParameter.createChildString('value', '')
          shotGroupParameter.createChildStringArray('options', 0)
      
          # Choose the first show, which triggers the on_parameter_finalizeValue()
          # collapsed event handler that is defined and registered above
          showGroupParameter.getChild('enable').setValue('1', 0)
          showGroupParameter.getChild('value').setValue('A', 0)
      
      Callbacks.addCallback(Callbacks.Type.onNewScene, onNewScene)
  2. Start Katana.
  3. Choose one of the following UI components to test:
    • To test the Graph State Variables popup of the Katana main window, click the variables label next to the main menu bar.
    • To test the appearance of Graph State Variables in the Project Settings tab, go to the Project Settings tab and expand the variables group parameter.
  4. Open the dropdown of the show global Graph State Variable, and verify that the available options are A, B, C, and D.
  5. Note that show is set to A. (This is done in the onNewScene callback defined in the Python script above.)
  6. Open the dropdown of the shot global Graph State Variable, and check the available options.
  7. Set shot to aa4.
  8. Set show to C.
  9. Check the appearance of the shot variable.
  10. Open the dropdown of the shot variable again, and check the list of available options.

Expected behaviour:

The options available for the shot GSV are initially aa1, aa2, aa3, aa4, and aa5.

Before shot is set to aa4, in the Graph State Variables popup, an error icon is shown in the popup form widget of the shot GSV, as the shot GSV hasn't been set yet. After setting shot to aa4, the error icon disappears.

After setting show to C, in the Graph State Variables popup, the value of the shot GSV is shown as aa4 with an error icon, as it doesn't exist in the list of options for the variables.shot parameter on the root node. When clicking the menu arrow to open the dropdown, the list of options is up-to-date: cc1, cc2, and cc3.

In the Project Settings tab, the shot GSV appears as aa4 without an error icon, as editing of GSV is allowed. The list of options shown in the dropdown of the shot GSV is up-to-date: cc1, cc2, and cc3.

Actual behaviour:

The options available for the shot GSV are initially aa1, aa2, aa3, aa4aa5, and the empty string.

Before shot is set to aa4, in the Graph State Variables popup, the shot GSV appears as empty without showing an error icon.

After setting shot to aa4 and show to C, in the Graph State Variables popup and the Project Settings tab, the value of the shot GSV is shown as a normal value, even though it doesn't exist in the list of options for the variables.shot parameter on the root node. When clicking the menu arrow to open the dropdown, the list of options is out of date: aa1, aa2, aa3, aa4, and aa5.

Workaround:

  • You can close and reopen the Graph State Variables popup in the main menu bar in order for the combo box dropdown to refresh and list the right options.
  • On the Project Settings tab, you can collapse and re-expand the variables group parameter in order for the combo box dropdown to refresh and list the right options.

Tested versions/platforms:

This issue has existed since the introduction of Graph State Variables in the Katana 2.0 line:

  • 2.0v1 - Affected
  • 3.2v2 - Affected

Customer version/platform:

Not supplied

    We're sorry to hear that

    Please tell us why