Working With EVRIADDON: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Scott
No edit summary
imported>Scott
No edit summary
Line 2: Line 2:
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 those included with PLS_Toolbox.
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 those included with PLS_Toolbox.


==Object Properties==
=Object Properties=


Querying evriaddon_connection will return an object which has help built into it:
Querying evriaddon_connection will return an object which has help built into it:
Line 34: Line 34:
The help specifies what the function I/O is expected to be for the given entry point.
The help specifies what the function I/O is expected to be for the given entry point.


==Examples==
=Examples=


===Adding a Custom Import Function===
==Adding a Custom Import Function==
'''1)''' Create your import function using [[editds_userimport]] as a template.
'''1)''' Create your import function using [[editds_userimport]] as a template.


Line 43: Line 43:
'''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.


===Adding an PLOTGUI Toolbar Button===
==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.
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.



Revision as of 19:06, 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 those included with PLS_Toolbox.

Object Properties

Querying evriaddon_connection will return an object which has help built into it:

obj = evriaddon_connection

at the end of the object's entrypoint listing it says:

   Entry Points:
       analysistypes                        : ---
       importmethods                        : ---
       importmethods_filter                 : ---
       savemodelas                          : ---
       preprocess                           : ---
       browse_post_gui_init                 : ---
       browse_shortcuts                     : ---
       ...
       load_postload                        : ---
       autoimport_postload                  : ---
       addsourceinfo_prefilter              : ---
       plotgui_toolbar                      : ---
    Entrypoint Help: use "obj.help.entrypoint"

for example:

>> obj.help.analysis_calcmodel_callback
ans =
    fn(fig,eventdata,handles);  %perform user-specified events when calc model is clicked (calc or apply).


The help specifies what the function I/O is expected to be for the given entry point.

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)