Class Reference

DK_Tool

DK_Tool is an abstract data class that is responsible for rendering your custom effect, as well as holding parameter values and providing methods for setting up, copying, answering queries, reading and writing function files, displaying progress, and so on. It contains several pure virtual functions, so you cannot instantiate an object directly from this class; you need to write the implementation for the pure virtual functions first.

Constructor

DK_Tool(DevKit &parent);
Creates a DK_Tool object.

Destructor

virtual ~DK_Tool(void);
Destroys a DK_Tool object. You can override this method if desired: memory should be freed in the destructor to avoid memory leaks.

copy

virtual void copy(const DK_Tool *other) = 0;
Copies the *other tool into this DK_Tool object. It is called when users choose Copy from the Tool menu, and is also used to restore values when users click Cancel in a tool editor.

This method must be overridden. It should copy the private data members you defined in the class you derived from DK_Tool (that is, your custom tool class).

init

virtual void init(void) = 0;
Initializes the tool and readies it for use.

This method must be overridden. It should set all parameters to their default values and create all required target legs. You do not need to create the OptionalBackground target leg.

getToolName

const char *getToolName(void) const;
Returns the name of the tool. The default name is the classID, but the user can change the name of a tool instance in the Eddie interface.

classID

virtual const char *classID(void) const = 0;
Returns the class name of the tool.

This method must be overridden. The class name should be the third argument passed to the DK_DSOFUNC macro from the DK_ToolGUI subclass of your tool, as well as the base name of your .so and .icon files.

willChange

virtual Boolval willChange(float from_frame,
                           float to_frame);
Returns TRUE if the image that the tool will render changes between the specified frames.

You can override this method if desired. You need only examine the state of your internal data; any DK_AnimParam instances you create are examined directly by Eddie.

isAttachable

virtual Boolval isAttachable(void) const;
Specifies whether the tool can be attached to a target leg of another tool in a hierarchy. The default is TRUE.

You should override this function and return FALSE if the tool cannot be attached (for example, an output tool).

IsPackageable

virtual Boolval IsPackageable(void) const;
Specifies whether the tool can be included in a packaged hierarchy. The default is TRUE.

If your tool is an input tool that generates images rather than processes them, you should override this function and return FALSE.

defaultRect

virtual DK_IRect2 defaultRect(float frame);
Called by Eddie to determine the preferred size and position of your tool's rendered image. The default uses the size and position of the child image attached to leg 0.

You can override this function if desired. Note that Eddie can also override this function based on user input: for example, rendering the Processing Region only.

RenderStatus

enum RenderStatus {
   FAILURE,
   DID_REQUEST,
   DID_ALL
};
Enumerates the status after rendering:

Your render method should return one of these values.

render

virtual RenderStatus render
                    (float     frame,
                     DK_Image  &outim,
                     DK_IRect2 &area_to_do) = 0;
Renders the specified image at the specified frame.

This method must be overridden. This is where your custom effect is applied. You can ignore the area_to_do argument if desired, but you should return the RenderStatus as enumerated in the previous section. For an overview the steps involved in writing a render method, see Rendering.

discardCachedResults

void discardCachedResults(void);
Discards all cached information. This forces Eddie to call the render method when it needs to update a frame from your tool.

write

virtual void write(FILE *fp);
Writes to an ASCII function file (.fn3). The default does not write anything.

You should override this method. You should sequentially write out all data needed to preserve the state of your tool, in the order and format expected by the read method. You can use simple fprintf() calls to write out the state of your variables; for example:

fprintf(fp, "_myPrivateString %s\n",
                              _myPrivateString);
fprintf(fp, "_myPrivateBool %d\n",
                              _myPrivateBool);

read

virtual void read(FILE *fp);
Reads an ASCII description of the variables for this tool from the specified function file (.fn3). By default, nothing is read.

You should override this method. The format and sequence of variables being read from the function should be identical to the one written out by the write method. Simple fscanf() calls can be used to read the variable descriptions; for example:

char dummyString[1024];
long dummyLong;
fscanf(fp, "%s %s", dummyString,
                            _myPrivateString);
fscanf(fp, "%s %ld", dummyString, &dummyLong);
_myPrivateBool = (Boolval) dummyLong;

pushProgress

static void pushProgress
                     (const char *process_name);
Creates an entry with the specified process name in the Progress Meter.

updateProgress

static Boolval updateProgress
                      (float fraction_complete);
Updates the last entry in the Progress Meter. The argument must be a number between 0 and 1; Eddie estimates the time remaining based on this fraction. This function returns TRUE if the users clicks Cancel or if Eddie abandons the operation for any reason.

popProgress

static void popProgress(void);
Removes the last entry from the Progress Meter.

createLeg

void createLeg(const char *name, 
               DK_LegColour colour, 
               Boolval isOptional);
Creates a new target leg. This function is used in the init method of your tool's DK_Tool subclass. DK_LegColour is enumerated in DK_Types.h. If the isOptional parameter is 0, the leg is always displayed; if it is 1, the leg is displayed only when the user chooses Targets -> Show from the Tool menu.

deleteLeg

void deleteLeg();
Deletes the last target leg created.

deleteAllLegs

void deleteAllLegs();
Deletes all target legs except for OptionalBackground.

isConnected

Boolval isConnected(u_int leg_index);
Returns TRUE if the specified target leg is connected to a child tool.

getChildImage

DK_Image &getChildImage(float frame_no, 
                        u_int leg_index);
Gets the image rendered by the child tool connected to the specified target leg, at the specified frame.

Note:
The rendering of the child image may be interrupted, for example, if the user clicks Cancel or manipulates the interface. You should check whether getDataPtr returns NULL, and return FAILURE if the returned image fails the check. For example:

if ((sptr = img->getDataPtr()) == NULL) 
{ delete img;
  return FAILURE;
}

getChildRect

DK_IRect2 getChildRect(float frame_no, 
                       u_int leg_index);
Gets the coordinates of the rectangular region used at the specified frame by the child tool connected to the specified target leg.

willChangeChild

Boolval willChangeChild(float from_frame,
                        float to_frame, 
                        u_int leg_index);
Returns TRUE if the image from the child connected to the specified target leg changes between the specified frames.

getGlobalScale

float getGlobalScale(void);
Returns the Global Scale set in the main Eddie workspace. This is a positive value, where 1.0 represents full scale. Depending on your tool, it may be necessary to adjust the size of brushes and so on, based on the Global Scale value.

getCurrentCamera

DK_IVector2 getCurrentCamera(void);
Returns the x and y resolution of the camera as set in the Preferences dialogue box or in an output tool.

getFrameRange

virtual void getFrameRange(int &first, 
                           int &last) const;
Returns the range of frames your tool is capable of providing. The default indicates that the tool can handle all frames.

You should override this function if your tool reads an external data source that has definite duration, such as a 3D scene or a disk recorder. To specify that your tool can handle all frame numbers, set the first frame larger than the last frame.

updateDuration

void updateDuration();
Forces the Eddie kernel to call getFrameRange in order to re-evaluate the frame range that your tool can provide.

Constructor
Destructor
copy
init
getToolName
classID
willChange
isAttachable
IsPackageable
defaultRect
RenderStatus
render
discardCachedResults
write
read
pushProgress
updateProgress
popProgress
createLeg
deleteLeg
deleteAllLegs
isConnected
getChildImage
getChildRect
willChangeChild
getGlobalScale
getCurrentCamera
getFrameRange
updateDuration

SOFTIMAGE Eddie 3.5 - 10 JAN 1997