UItester.C
This demonstrates all the UI gadgets available to the plugin programmer.
/*
plugin Tutorial
example 2 - UItester.C
demonstrate all available UI gadgets, and the return mechanism
*/
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <memory.h>
#include <string.h>
#include "cpi.h"
// some constants to make the code more readable
#define FIRST_ELEM 0
#define SECND_ELEM 1
#define MAX_STRING 256
// define the user interface tabs and gadgets
CPIDSOEXPORT void upiCreateParameters( void )
{
int idef[] = {1, 150};
float fdef[] = {-0.5, 3.14159};
char *mdef[] = {"a choice", "another choice",
"default choice", NULL};
char sdef[] = {"/a/picture/file.pic"};
// define first tab
cpiAddTab( "some stuff" );
cpiAddInteger( "Integer", 1, 0, 10, P_ANIMATE );
cpiAddFloat( "Float", 1.0F, 0.0F, 10.0F, P_ANIMATE );
cpiAddIntVector( "Int Vector", 2, idef, 1, 100, 0);
cpiAddFloatVector( "Float Vector", 2, fdef, 0.0, 1.0, 0);
cpiAddToggle( "Toggle", 0, 0);
cpiAddButton( "Button" );
// define second tab
cpiAddTab( "more stuff" );
cpiAddString( "String", "default value", 0);
cpiAddMenu( "Menu", 2, mdef, 0);
cpiAddChannelMask( "Channel Mask", 0x0002, 0);
cpiAddFile( "File", "default file", 0);
cpiAddPicFile( "Picture File", sdef, 0);
}
// this routine is called by Chalice whenever a node parameter is
// changed - it comes in with the name of the parameter that changed
CPIDSOEXPORT void upiParameterChanged(char *name)
{
int ival, ivec[2];
float fval, fvec[2];
char string[MAX_STRING];
// you might just get all the values from the node, or you can
// check which was changed and only get that/those
if (!strcmp(name, "Integer"))
cpiGetInteger("Integer", 0, &ival);
else if (!strcmp(name, "Float"))
cpiGetFloat("Float", 0, &fval);
else if (!strcmp(name, "Int Vector"))
{
cpiGetIntVector("Int Vector", 0, FIRST_ELEM, &ivec[0]);
cpiGetIntVector("Int Vector", 0, SECND_ELEM, &ivec[1]);
}
else if (!strcmp(name, "Float Vector"))
{
cpiGetFloatVector("Float Vector", 0, FIRST_ELEM, &fvec[0]);
cpiGetFloatVector("Float Vector", 0, SECND_ELEM, &fvec[1]);
}
else if (!strcmp(name, "Toggle"))
cpiGetInteger("Toggle", 0, &ival); // returns 1 if toggle set
else if (!strcmp(name, "String"))
cpiGetString("String", 0, string);
else if (!strcmp(name, "Menu"))
// return an index into the menu array, starting at 0
cpiGetInteger("Menu", 0, &ival);
else if (!strcmp(name, "File"))
cpiGetString("File", 0, string);
else if (!strcmp(name, "Picture File"))
cpiGetString("Picture File", 0, string);
else if (!strcmp(name, "Button"))
do_button_function(); // get here if button pushed
}
[ Table of Contents ]
[ Index]
Copyright © 1998 Silicon Grail Inc.
710 Seward Street, Hollywood, CA 90038