Saturday, April 25, 2009

Improved way to convert Python and C into buttons and more

"menu.txt" has been replaced with "clibraries.txt" and "pythonscripts.txt", because the fashion in which C libraries and Python scripts were loaded into TinkerCell has been reconstructed. Both of the new files contain much more flexibility about where and how the C and Python programs run. The screenshot on the right shows Python scripts in the context menu and the tools.

Here is how it works now:

The DynamicLibraryMenu class provides the following functions:

addFunction : adds a function to the functions tree.
arguments: function category, name, and icon

addMenuItem : adds a function to the function menu at the top (play button).
arguments: function name and icon

addContextMenuItem : adds a function to the context menu (mouse right button) when items of a particular family are selected; optionally shows the graphical tool.
arguments: target family, function name and icon, and whether or not to show the graphical tool

Therefore, this class simply serves to add actions and buttons to the functions tree, tool bar, and context menu. The actual actions themselves are determined by two other classes:

The LoadCLibrary class performs the following tasks:
  1. read and parse clibraries.txt
  2. setup the signals and slots that call each function specified in clibraries.txt
  3. place actions and toolbuttons using DynamicLibraryMenu
This class can be summarized by the following logic:

text file ---> actions group
action triggered ---> get name ---> get library name ---> new LibraryThread

The PythonTool class performs the following tasks:
  1. read and parse pythonscripts.txt
  2. host the Python interpreter thread
  3. setup the signals and slots that call each script specified in pythonscripts.txt
  4. place actions and toolbuttons using DynamicLibraryMenu
This class can be summarized by the following logic:

text file ---> actions group
action triggered ---> get name ---> get file name ---> call runPy

Rationale for the new setup:

  1. More modular: if a new interpreter needs to be hosted, say Ruby, then it can use the same format at the PythonTool class.
  2. More GUI: a C and Python program can appear in up to four places, i.e. the functions tree, the main toolbar menu, context menu, graphical tools




Sunday, April 19, 2009

Data get/set C and Python routines

One of the chief design features in TinkerCell is the ability to store tables associated with items or the model. For example, a typical reaction would have a Numerical Data Table called "Stoichiometry" and a Text Data Table called "Rates". Most items have a Numerical Data Table called "Numerical Attributes", i.e. parameters. 

Now, there are certain plug-ins, e.g. the flux balance analysis plug-in, that store data in the model, not pertaining to any particular item. These data are stored in the scene->symbolsTable.modelItem item. 

Plug-ins may provide easier C and Python functions to access these tables, e.g. functions like stoichiometry(), setRates(), getRates(), etc.

But, the Core library provides generic Python and C functions to access any of these data:

use getNumericalDataNames(item) and getTextDataNames(item) to get the list of all table names for that item. Use a null argument to get the tables for the model item.

similarly, there is setNumericalData(item,tablename,rowname,colname,value), getNumericalDataMatrix(item,tablename), and a few other functions.

Saturday, April 18, 2009

Improved Plot Window


The plot window can show multiple plots, as shown above. 

The plot window provides an input box for users to write any set of functions and plot those functions. This feature should be useful when designing rate expressions or other functions in the model, i.e. the user can copy the rate expressions here and plot them to see what they look like.

The options on the right-hand side of the input box allow users to specify the variable on the x-axis and other details of the equations they want to plot.