Programmer's Guide - margoliashlab/arfview GitHub Wiki
Important Dependencies
Arfview uses the h5py interface to access arf files, along with the arf python library to save entries according to the arf specification. The graphical interface is created using PySide, a package which provides python bindings to the Qt 4 framework. The PySide API is identical to PyQt. A good tutorial on PySide/PyQt is here. The plotting is performed using pyqtgraph. The installation script is written using [setuptools] (https://pythonhosted.org/setuptools/). The stand-alone application is created from the python code using cx-freeze.
Modules
mainwin.py
The function main() in this module is the function called when arfview is started (this is accomplished by setting the function as an "entry point" in the setup.py script). This module contains the MainWindow class for the application, as well as functions related to exporting files and playing sound.
treemodel.py
This module contains classes related to the tree on the left side of the main window that is used to view, select, and check entries. Qt model/view framework. This is a very useful tutorial on model/view programming in PtQt/PySide. The first four parts of the tutorial are explain features used in the treemodel module.
TreeNode
This class represents a single arf entry, storing it's name, parents, children, and type (File, Group, or Dataset). The name is the path of the entry for a group or dataset, and the absolute path for a file. The TreeNode objects are what the TreeModel stores within its model indexes. The reason for this is that creating a QModelIndex containing an h5py object causes the application to crash. We could create a QModelIndex just containing the string representing the path of each entry, but the TreeNode class makes it quicker and cleaner to access the parent, sorted children, and type of each entry.
TreeModel
This class implements the data model. It contains the open arf files (as h5py.File objects) and handles the opening, closing, and most of the modification of the files. Most of the methods are virtual methods that are called automatically called by the tree view.
ArfTreeView
This class implements the data view. Most of this is handled by the parent class QTreeView. The additional methods defined in ArfTreeView are used to handle the context menu that pops up when an item is right-clicked.
labelPlot
This module contains classes used to plots label entries (arf datatype 2002).
labelRegion
A pyqtgraph.LinearRegion with a pyqtgraph.TextItem member, representing a single label and its name, respectively. The position_text_x method ensures that the name of the label will remain visible as long as a part of the LinearRegionItem is in the view range.