Working With EVRIADDON: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Scott
imported>Scott
Line 7: Line 7:
'''1)''' Create your import function using [[editds_userimport]] as a template.
'''1)''' Create your import function using [[editds_userimport]] as a template.


'''2)''' Since there's already an entry in the '''@evriaddon/addon_pls_toolbox.m''' file that points to [[editds_importmethods]] we simply need to add the function created in step one to the list of import methods.
'''2)''' Since there's already an entry in the '''@evriaddon/addon_pls_toolbox.m''' file that points to [[editds_importmethods]] we simply need to add the function created in step one to the list of import methods within [[editds_importmethods]]. Edit this file and add an entry for the new import method.


'''3)''' Your entry will show up the next time you use the import menu item.
'''3)''' Your entry will show up the next time you use the import menu item.

Revision as of 14:27, 16 April 2010

The evriaddon object allows for existing functions to "query" for additional functionality. A good example is the editds_importmethods function that defines import methods. This function adds additional import methods to the methods included with PLS_Toolbox.

Examples

Adding a Custom Import Function

1) Create your import function using editds_userimport as a template.

2) Since there's already an entry in the @evriaddon/addon_pls_toolbox.m file that points to editds_importmethods we simply need to add the function created in step one to the list of import methods within editds_importmethods. Edit this file and add an entry for the new import method.

3) Your entry will show up the next time you use the import menu item.

Adding an PLOTGUI Toolbar Button

In this example we'll add a button to the plotgui toolbar (the toolbar that appears on the "target" figure) that creates a static plot.

1) The function that uses evriaddon in this situation is plotgui_toolbar.m. Opening this function we can see that to add a button we need to add an entry to the list (n x 7 cell array of strings) of buttons with the following format:

icon tag callback enable/disable tooltip separator on/off push/toggle button

Create a function (in the PLS_Toolbox/utilities folder) named "myplotguibuttons.m". All the function will do is take the existing button list and add an entry for an additional button. Looking at where plotgui_toolbar.m calls evriaddon I know it passes two inputs, the button list (btn) and figure handle (targfig). We ignore targfig for now because we don't need any figure information. The code should then be simply:

function btn = myplotguibuttons(btn,targfig)
%MYPLOTGUIBUTTONS Utility function to add toolbar buttons.

btn = [btn
  {
  'plot'  'makestaticplot'  'plotgui(''menuselection'',''ViewSpawn'')'  'enable' 'Create a static plot.' 'on'  'push'
  }];

I chose the "plot" icon, a unique tag name, a simple plotgui command, and appropriate values for the rest of the settings.


2) In the PLS_Toolbox/utilities/@evriaddon folder, open the addon_pls_toolbox.m file. Here, add a "entry point" for plotgui_toolbar and assign it the function handle of the function we created in step 1. It should look similar to:

...

out.priority = 1;
out.importmethods = @editds_importmethods;
out.preprocess    = @preprouser;
out.plotgui_toolbar = @myplotguibuttons;

...

3) Test your new button:

load arch
plogtgui(arch)