This page illustrates the working of e2projectmanager.py
The new GUI for EMAN2 is known as e2projectmanager.py and is mainly used to organize electron microscopy projects, and execute e2programs. The projectmanager can be run in two modes, SPR(single particle reconstruction) and tomo (tomogramphic). Other modes can be added and this page describes how to do that. Each mode has a JSON file describing the workflow of a mode. The workflow is a tree that describes a flow of data from raw to final form, and traversing this tree describes the data flow(approximately, as some deviations are allowed). These JSON files can be easily modified to allow workflow modification without needing to touch the source code(a vast improvement over e2workflow.py).
Design of e2projectmanager.py
The projectmanager itself is implemented as a class named: EMProjectManager that inherits from QtGui.QMainWindow This class is quite large and has many methods.
method: makeStackedWidget(), this adds tree widgets to the workflow widget stack(the SPR and tomo workflow trees are inserted into a QWidgetStack). If you want to add a new mode to the projectmanager, add to this method the line:
1 self.tree_stacked_widget.addWidget(self.makeTreeWidget(os.getenv("EMAN2DIR")+'/lib/pmconfig/myjsonfile.json', 'name'))
where myjsonfile.json is the JSON file for this mode and name is the name of this mode(will be displayed in the mode combobox).
method: launchScript(cmd), this method actually starts the EMAN2 child process from the program+arg string cmd. If you want to alter child process behavior this method is the place to do it.
method: loadUsage(program), this method loads the Usage information from an e2program. If you change how this information is stored in the e2programs, you'll need to modify this method. I realize this makes for too much coupling, but I don't see anyway around this issue.
method: loadTree(filename, treename), this method loads in a mode JSON file to populate its workflow QTreeWidget. This method also sets all properties related to each e2program that this mode workflow runs. These properties include things such as wizard file location, expert mode availability, etc. If you want to add additional properties, this function is the place to start. This function calls _add_children(toplevel, widgetitem), a recursive function.
method: _set_GUI(program, mode), this method is called when the user clicks on a treeitem. If a GUI interface widget corresponding to this program exists it is brought to the top of the QWidgetStack(this is separate from the workflow stack, which is another QWidgetStack). If the widget does not exist, one is grated by instantiating PMProgramWidget(guioptions, programfile, self, mode). programfile is the name of the e2program andguioptions is generated from method:
method: _read_e2program(e2program, mode), this method reads the e2program options by eval'ing the addArgument lines of the argparser. Once the options are read into a dictionary, this dict is returned and used to instantiate PMProgramWidget.
method: update(), this method is called whenever the project changes state (usually when the user takes some action). Anything that needs to observe the projectmanager state needs to go here.
Major e2projectmanager.py classes
PMProgramWidget(QtGui.QTabWidget): This class implements the GUI(EMAN2 Program Interface) widget. This tab widget has three tabs, a GUI interface, a textbox(lists the command that PM will run), and a help tab that lists the usage information. This information is generated by the loadUsage() method of EMProjectManager.
PMGUIWidget(QtGui.QScrollArea): This class builds the actual GUI interface widget(first tab of the above class) from a dict containing the options listed by argparser in the e2program. If you want to expand the number of options you need to modify this class and also modify EMArgumentParser class in the EMAN2.py module.
EMPopen(subprocess.popen): This class is a subclass of the popen module. This was created to allow redirection of child process STDOUT in realtime, however this has proven to be buggy and is currently under development.
EMStatusbar(QtGui.QTextEdit): This class implements the projectmanager status bar, and its main function is to add HTML formatting to status messages. This is accomplished with the method, setMessage(text, style="") which takes a style argument in CSS format.
EMWizard(QtGui.QWizard): This class implements the EMAN2 wizard framework, but most of the wizard work is done by the class:
EMWizardPage(QtGui.QWizardPage): This class implements to wizard pages for the PM wizard framework. A key function of this class is to error check parameters passed into the wizard.
TheHelp(QtGui.QWidget): This class generates a GUI interface to e2help.py
NoteBook(QtGui.QWidget): This class generates the electronic notebook that the project manager uses, any changes/bug fixes to this electronic notebook to occur here.
TaskManager(QtGui.QWidget): This class generates the task manager for projectmanager. Any bug fixes realting to the taskmanager should be done here as the taskmanager is isolated from PM.
PMQTreeWidgetItem(QtGUi.QTreeWidgetItem): This class subclasses the QTreeWidgetItem to add additional properties to each tree item, such as program name, wiki page, expert mode, etc.
PMToolButton(QtGui.QToolButton): This class implements the PM tools buttons found on the right hand side of the projectmanager.