Working With EVRIADDON: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Scott
imported>Scott
Line 5: Line 5:


===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).
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:
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:
{| class="wikitable" border="1" cellpadding="3" style="width:100px; height:100px"|-
{| class="wikitable" border="1" cellpadding="3" style="width:100px; height:100px"|-
!width="100pt"|'''icon'''
!width="100pt"|'''tag'''
!width="100pt"|'''tag'''
!width="100pt"|'''icon'''
!width="100pt"|'''callback'''
!width="100pt"|'''callback'''
!width="100pt"|'''enable/disable'''
!width="100pt"|'''enable/disable'''
Line 21: Line 19:
|}
|}


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:
<pre>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'
  }];</pre>
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:
<pre>...


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


In the PLS_Toolbox/utilities/@evriaddon folder, open the addon_pls_toolbox.m file.
...</pre>
2)

Revision as of 11:34, 16 April 2010

The evriaddon object allows for existing functions to "query" for additional functionality. A good example is a function that lists import methods. This function might construct a list of known import methods then "query" evriaddon for any additional import methods that a user may have added.

Examples

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;

...