Table Of Contents
Using plugins is a two step process. First you write and compile the plugin using Xcode and then you load it in. Loading it is simple, just select the Graph IDE menu item ► ► and open the plugin you make. The rest of this section gives instructions on making the plugin.
Note: Only the Mac version supports Plugins. For other platforms your code must be linked directly into the Graph IDE project. See GitHub/VVI for additional information.
Premade Xcode Project
The fastest way to start with plugins is to use a premade one. Plugin resources are available from these links:
ExamplePlugin.zip | The compressed ExamplePlugin project located on your disk within this manual. |
ExamplePlugin.zip | The compressed ExamplePlugin project located at the vvidget.org web site. |
Xcode | The Xcode application on the Mac App Store. |
Download the ExamplePlugin zip file, uncompress, launch the Xcode project and click Run to make the plugin. The framework links and source code are already setup and ready to go. Eventually you may wish to make your own plugin project from scratch. For that purpose read the section below.
Xcode Instructions
The following gives the steps for making a Xcode plugin that can be utilized for programming graphics.
- Launch Xcode.
- In the Xcode menu select ►
- In the resulting panel select ► ► . Then click the Next button.
- In the resulting panel fill in the required entries. Make sure to choose a Cocoa Framework and do not use Automatic Reference Counting. Then click the Next button.
- In the resulting save panel navigate to where you wish to save the project and click the Create button.
- In ► change the Wrapper Extension from bundle to vviplugin.
- In ► click the plus (add) button. In the resulting panel click the button. In the resulting Open panel navigate to the Vvidget Frameworks (see the bullet below) and add all of them.
-
Adding the Vvidget Frameworks employs a trick. Normally programming frameworks are installed on a development system via a SDK installer which is complex, overly burdensome and in the case of programming a plugin unnecessary. That is because the necessary Frameworks are already on your computer and are contained in the Graph IDE application wrapper. To expose those frameworks do the following. First (important!) move Graph IDE to a permanent location (for example: /Applications). By making it permanent you ensure that the path to the Frameworks is fixed. That path is encoded into the plugin project and can be changed but it is easier at first to make it fixed. Once you have placed Graph IDE where you like it then, using Finder, navigate to Graph IDE. Then control click on Graph IDE and choose . Then navigate to the Contents/Frameworks folder. Select the Frameworks folder and drag it to the Xcode Open Panel. Within that Xcode panel, select all of the Frameworks and click the Open button.
- Doing the above places an entry into the Framework Search Paths. If you move the project or Graph IDE then modify the Framework Search Path entry appropriately. Specifically: You may wish to make the path an absolute path so you can move the plugin project as desired. Any which way, you will need to take appropriate measures if you move Graph IDE or the plugin project, however the measures are usual programming issues.
- Tidy up the project by dragging (moving) the framework references (within the Navigator view) to the Frameworks group.
- In the Xcode menu select ► ►
- In the resulting panel select ► ► . Then click the Next button. Give it the Class name MyFunction and Subclass of VVPUBLIC_Function. Then click the Next button. In the resulting panel make sure the target is selected and click the Create button.
- Add some source code to the MyFunction.h file, such as:
#import <Vvidget_GG/VVPUBLIC_Function.h>
@interface MyFunction : VVPUBLIC_Function
- (id)init;
- (void)doAllTheWork;
@end
|
- Add some source code to the MyFunction.m file, such as:
@implementation MyFunction
- (id)init
{
self = [super init];
NSLog(@"-[MyFunction init]");
return self;
}
- (void)doAllTheWork
{
NSLog(@"-[MyFunction doAllTheWork]");
int ii;
double xValue, yValue;
unsigned animationCount;
unsigned recursionCount;
double red;
animationCount = [self animationCount];
recursionCount = [self recursionCount];
[self emptyData];
for(ii = 0; ii < 500; ii++)
{
xValue = 0.01 * ii + animationCount * 0.5;
yValue = cos(xValue) + recursionCount;
[self appendXValue:xValue yValue:yValue];
}
red = (animationCount % 10) / 10.0;
[self setCurveRed:red green:0.0 blue:0.0 alpha:1.0];
if(recursionCount < 5)
{
[self recur];
}
return;
}
@end
|
- Click the Run button to build the plugin.
- In the Navigator view expand the Products group, select the plugin, control-click it and choose Show in Finder. In the resulting Finder window drag the plugin to where you want it.
- The plugin is now available for use within Graph IDE.
Calling the Plugin
In the source code above the Function object class was subclassed. To instantiate an object of your own subclass allocate it in a call like [MyFunction alloc]
instead of [Function alloc]
. Notice how you subclassed VVPUBLIC_Function
. As a matter of convenience to programming, the parser strips the prefix VVPUBLIC_
from the class name when appropriate however in Xcode the prefix is not stripped and must be included when subclassing a known class.
The instructions above detail how to make the plugin. The plugin is applicable to programming the Function graphic. You can call upon the object of your own class and its methods using script code such as the following.
Script without saving state
|
@@class() MyFunction:Object
@@method(public, class) (id)alloc;
@@method(public, instance) (id)init;
@@method(public, instance) (void)doAllTheWork;
@@method(public, instance) (void)release;
@@end
{
id myFunction;
myFunction = [[MyFunction alloc] init];
[myFunction doAllTheWork];
[myFunction release];
}
|
If your plugin needs to save state within the Graph IDE document (see the plugin example project) then the script is written as follows.
Script that permits the instance of MyFunction to save state in the Graph IDE document.
|
@@class() MyFunction:Object
@@method(public, class) (id)stored;
@@method(public, instance) (void)doAllTheWork;
@@end
{
id myFunction;
myFunction = [MyFunction stored];
[myFunction doAllTheWork];
}
|
The method doAllTheWork can implement most anything such as DSP processing, FEM modeling, stock data feed retrievals, statistical algorithms, etc.
The ExamplePlugin given at the links above implements a few other features such as saving a MyFunction instance state. It also contains some programming notes and comments. Please email support@vvi.com if you have difficulty obtaining the plugin or have a plugin question.