Here are some broad plans on how to customize descriptive phrases for RGG. The basic idea is to make the resource panel inherit qtBaseView and use its XML configuration to control what the panel displays. Then a ParaView-aware and RGG-aware selection observer can change what is rendered and selectable.
The qtResourceBrowser (inherited by pqSMTKResourceBrowser) should itself inherit qtBaseView and accept configuration via the smtk::view::View class. The specific things that should be configurable:
which smtk::view::PhraseModel subclass to use for its QAbstractItemModel;
whether to use an intermediate QSortFilterProxyModel and add GUI controls (a search text entry and sort control buttons) to the panel;
which smtk::view::SubphraseGenerator subclass to use (and any configuration controls that are required);
Custom RGG PhraseModel subclass
PhraseModel subclasses determine what phrases make up the top-level items of a QAbstractItemModel in a QTreeView. RGG wants this to be a fixed set corresponding to functional groups (pins, ducts, assemblies, cores). For the purpose of this discussion, let’s say the new class is named smtk::session::rgg::PhraseModel.
Customizable subphrase generator
Rather than hardcode a subphrase generator to list pins under the smtk::session::rgg::PhraseModel's top-level “pins” item, we should create a new class (say smtk::view::QueryPhraseModel for this discussion). That class could hold a map<std::string, std::string> that uses top-level phrase title() strings as keys and returns query-strings to pass to smtk::resource::Resource::find().
Note that the subphrase generator is responsible for implementing both the subphrases() and subphrasesForCreatedObjects() methods. The former is called when the view is first created or a tree item expanded ‒ it must provide an ordered list of subphrases on demand; the latter is invoked when SMTK operations report newly-created objects (components) in their results ‒ it must provide new phrases and their locations corresponding to each new object, but only where the parent phrase already exists.
RGG selection behavior
To provide RGG users with control over what is visualized, a selection observer can identify when a pin/duct/assembly/core is selected and update component visibility in ParaView (as well as change the camera as needed).
You should not need to write an RGGSubphraseGenerator class. Instead the rgg session will provide <View>...</View> configuration XML that tells the QueryPhraseModel what to do. For example, we might have
I think we are all set to allow a custom PhraseModel and SubphraseGenerator. I see RGG will be compiled in, so this should work:
Add new subclasses to the lists in smtk::view::Registrar
Copy ResourcePanelConfiguration.json from extension/paraview/appcomponents and modify it with the new class names. Add the new .json to CMakeLists.txt so it gets converted to a header
When RGG is activated, pass the string representing the json to the json parser, which creates a smtk::view::View to pass to pqSMTKResourcePanel::setView()
Of course, I’ve only tried it with ResourcePhraseModel, and default or TwoLevel SubphraseGenerator, so we’ll probably run into some issues, but hopefully my MR can get merged today(?) so you can try it out.
Copy ResourcePanelConfiguration.json from extension/paraview/appcomponents and modify it with the new class names in the Type attributes. Add the new .json to CMakeLists.txt so it gets converted to a header. The current one looks like:
# put contents of this file in a string in a header. It's not xml, but it still works.
Inside the plugin’s AutoStart file, get the json string:
// cmake puts the .json file contents into a static string, named _xml
In the setup() method, parse the json and create the view, something like this:
for (QWidget* w : QApplication::topLevelWidgets())
auto mainWindow = dynamic_cast<QMainWindow>(w);
auto dock = mainWindow->findChild<pqSMTKResourcePanel*>();
It turns out that we are hitting the indeterministic ordering of static initialization. In my case, the smtkRGGSessionPlugin is loaded before smtkPQComponentPlugin so the pqSMTKResourcePanel has not been constructed yet. I got a not so beautiful solution to solve the problem here. Ideas?