#ifndef LWSDK_MODTOOL_H
#define LWSDK_MODTOOL_H

/*
 * LWSDK Header File
 * Copyright 1999, NewTek, Inc.
 *
 * LWMODTOOL.H -- Modeler Interactive Tools
 */

#include <lwtool.h>
#include <lwmeshedt.h>

#define LWMESHEDITTOOL_CLASS    "MeshEditTool"
#define LWMESHEDITTOOL_VERSION  4

/*
 * The MeshEdit tool is a LightWave viewport tool that performs its
 * action through a MeshEditOp.  The extra functions are:
 *
 * test     return a code for the edit action that needs to be
 *          performed.  Actions given below.
 *
 * build    perform the mesh edit operation to reflect the current
 *          tool settings.
 *
 * end      clear the state when the last edit action is completed.
 *          This can be a result of the 'test' update code or it can
 *          be triggered by an external action.
 */
typedef struct st_LWMeshEditTool
{
    LWInstance    instance;
    LWToolFuncs  *tool;

    int         (*test)  (LWInstance);
    LWError     (*build) (LWInstance, MeshEditOp *);
    void        (*end)   (LWInstance, int keep);

} LWMeshEditTool;

/*
 * The test function can return code for the next action to be performed
 * to modify the edit state.
 *
 * NOTHING  do nothing.  The edit state remains unchanged.
 *
 * UPDATE   reapply the operation with new settings.  The 'build' func
 *      is called.
 *
 * ACCEPT   keep the last operation.  The 'end' callback is called with
 *      the 'keep' argument true.
 *
 * REJECT   discard the last operation.  The 'end' callback is called
 *      with the 'keep' argument false.
 *
 * CLONE    keep the last operation and begin a new one.  'End' is
 *      called with a true 'keep' parameter, and then 'build' is 
 *      called again.
 */
#define LWT_TEST_NOTHING    0
#define LWT_TEST_UPDATE     1
#define LWT_TEST_ACCEPT     2
#define LWT_TEST_REJECT     3
#define LWT_TEST_CLONE      4
/*
 * The user memory normally passed to the MeshEdit->begin() is set with
 * the return from the test() function. OR these values with the flag 
 * bits above to get per-vertex and per-polygon data allocated and accessed
 * through userData pointers in the EDPointInfo and EDPolygonInfo structures.
 */
#define LWT_VMEM(siz)       ((((siz+7)>>3)<<24)&0xFF000000)
#define LWT_PMEM(siz)       ((((siz+7)>>3)<<16)&0x00FF0000)

#endif
