Selection In ParaQ

From ParaQ Wiki
Jump to navigationJump to search

This documents discusses a design for Selection in ParaQ.

Background

  • pqServerManagerModel -- graph model for the vtkSMProxyManager state.
  • pqPipelineModel -- tree model generated using pqServerManagerModel. This is QAbstractItemModel subclass.


Design

SelectionModel.png

  • Qt provides a QItemSelectionModel. As per the Trolltech documentation it keeps the indexes for items in a model. The same selection model object can be shared among several views that have use the same underlying model. QItemSelectionModel, generally speaking, keeps a QItemSelection object. QItemSelection can be thought of as a collection QModelIndex objects for the selected enties. These QModelIndex objects depend on the model. Given a QModelIndex, pqPipelineModel knows exactly which pqServerManagerModelItem (and in turn which vtkSMProxy) the index is refering to.
  • pqServerManagerModel keeps a collection of pqServerManagerModelItems which represent source/filter/display proxies. We define a new class pqSelection which is a collection of pqServerManagerModelItems. Note pqSelection is not a subclass of QItemSelection nor does it use QModelIndex objects. Thus is due to the fact that QModelIndex use (row, column) to identify the model item, which doesn't apply to the graph model (pqServerManagerModel). Given a pqSelection object, pqServerManagerModel knows exactly what proxies are selected in the selection.
  • We define a Selection Adaptor. Given a pqPipelineModel and a QItemSelection for it, the Selection Adaptor generates a pqSelection object. This is quite trivial since it is very easy to obtain a pqServerManagerModelItem, given a pqPipelineModelItem. Additionally, the Selecion Adaptor can convert a pqSelection object to a QItemSelection object for the pqPipelineModel (again, a straight forward task).
  • Now, when user select elements in the Pipeline Browser, we have a QItemSelection. We take this selection, give it to the Selection Adaptor and obtain a pqSelection. The ServerManager can then be told to select the collection of proxies in pqSelection (once the selection mechanism is added to the Server Manager).
  • Similarly when the user does a rubber band select in the render window, the Server Manager will create a collection of selection proxies. pqServerManagerModel can build a pqSelection out of this collection of vtkSMProxies. The Selection Adaptor can translate pqSelection to QItemSelection suitable for any view on pqPipelineModel.
  • Once we add DataInformationView, if this view can be connected directly to pqPipelineModel well and good, we can use the same QItemSelection for both the pipeline browser tree view as well as the data informaiton view. If not, and we have to create a new model, say DataInformationModel on top of the pqServerManagerModel, then the selection mechanism still works. We have to write selection adaptors for every new model we write on top of the server manager model. This adaptor only needs to translate to and from pqSelection to QItemSelection for that particular model.