Resource-tree panel in SMTK3/CMB6


@Bob_Obara You asked in our weekly meeting about where the logic lives to handle updates to the resource panel when operations occur. It goes something like this:

  • When the SMTK plugins are loaded and/or a ParaView server connects, the PhraseModel for the tree panel is told to observe the resource and operation managers
  • When a resource is loaded, created, or modified by an operation, the PhraseModel’s handleResourceEvent and/or handleOperationEvent methods are invoked.
  • Some of these methods are not implemented yet (since I wrote them before TJ’s work on operations was not complete), but they are responsible for identifying which entries in the tree are about to have their children modified You can see that sometimes subclasses of PhraseModel take on this responsibility, e.g., ComponentPhraseModel::processResource, called by the subclass’s handleResourceEvent.
  • Once the methods in the PhraseModel or its subclasses identify children based on the event, they use the relevant SubphraseGenerator to obtain a new list of descriptive phrases and pass that list to PhraseModel::updateChildren().
  • PhraseModel::updateChildren looks at the difference between existing phrases and the new phrases, turning it into a list of edits (insert/remove/move/modify). It performs the edits, calling its trigger() method before and after each edit.
  • The trigger method simply invokes an observer that qtDescriptivePhraseModel added which tells Qt which QModelIndex objects are about to change in all the QTreeView widgets displaying the descriptive-phrase model.

It might seem like a a lot, but if we want updates to be efficient and not recompute the entire tree for every operation, it’s what’s needed.