home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************/
-
- #include "std.h"
- #include "megatyp.h"
- #include "megacad.h"
- #include "megapar.h"
-
- /**********************************************************************/
-
- typedef ulong (_far _pascal _export *t_MegaCadIF)(t_MegaPars _far*,uint,uint);
-
- typedef union
- {
- struct
- {
- t_MegaCadIF fnIF;
- uint para;
- } tp;
- struct
- {
- char _far *file;
- char _far *args;
- } sm;
- struct
- {
- tCallBack func;
- void _far *data;
- } cb;
- } t_para;
-
- #define MI_CALLBACK 1
- #define MI_GETVERSION 2
- #define MI_TAKEPARA 3
- #define MI_STARTMAIN 4
-
- /**********************************************************************/
-
- static ulong _far _pascal IF_Dummy(
- t_MegaPars _far *pars,
- uint megaptr,
- uint funcnum )
- {
- if ( pars || megaptr || funcnum )
- return(0L);
- return(0L);
- }
-
- /**********************************************************************/
-
- static t_MegaCadIF MegaCAD_IF = IF_Dummy;
- static uint MegaCAD_ptr = 0;
-
- extern short MegaMain(char*,char*);
-
- #ifdef _WIN32
- __declspec(dllexport) short __stdcall MegaCAD_Entry();
- #endif
-
- /**********************************************************************/
- /* This function is the entry point that MegaCAD searches for, when */
- /* having loaded the DLL. */
- /**********************************************************************/
-
- short _far _pascal _export MegaCAD_Entry(
- uint fCode,
- t_para *par )
- {
- static char mFile[256];
- static char mArgs[256];
-
- switch ( fCode )
- {
- case MI_CALLBACK :
- // call the 'tCallBack' function with the given data pointer;
- // this indirect way assures that only this function has to
- // be '_export', not all the callback functions within the DLL.
- return( par->cb.func(par->cb.data) );
-
- case MI_GETVERSION :
- // return the version number of the MegaCAD interface
- // the number must match the number of the MegaCAD .EXE
- return( MI_VERSION );
-
- case MI_TAKEPARA :
- // save the MegaCAD entry function and parameter
- MegaCAD_IF = par->tp.fnIF;
- MegaCAD_ptr = par->tp.para;
- return(1);
-
- case MI_STARTMAIN :
- // call the 'MegaMain()' function of the DLL
- par->sm.file = strcpy(mFile,par->sm.file);
- if ( par->sm.args )
- par->sm.args = strcpy(mArgs,par->sm.args);
- return( MegaMain(par->sm.file,par->sm.args) );
- }
- return(-1);
- }
-
- /**********************************************************************/
- /* Local function, that calls the MegaCAD entry function. */
- /**********************************************************************/
-
- #if _MSC_VER >= 700 && _MSC_VER <= 800
- #define _pSTACK _based(_segname("_STACK"))
- #else
- #define _pSTACK
- #endif
-
- static ulong _near _fastcall CallMegaCAD(
- t_MegaPars _pSTACK *params,
- uint funcnum )
- {
- return( MegaCAD_IF(params,MegaCAD_ptr,funcnum) );
- }
-
- /**********************************************************************/
- #if defined ( _WIN32 )
- /**********************************************************************/
- /* In 32 bit DLL's there has to be an extra _matherr function!!! */
- /* Especially 'atan2()' would produce floating point errors with two */
- /* identical points. */
- /**********************************************************************/
-
- int _matherr(
- struct _exception *err )
- {
- err->retval = 0.0;
- return(1);
- }
-
- /**********************************************************************/
- #endif // _WIN32
- /**********************************************************************/
- /*--------------------------------------------------------------------*/
- /**********************************************************************/
- /* Function codes. */
- /**********************************************************************/
-
- #define GET_PNT_INV 1
- #define DRAW_INV 2
- #define DLG_INPUT 3
- #define GET_FILENAME 4
- #define STORE_MULTIPLE 5
- #define MEGA_CMD 6
- #define MESSAGE 7
- #define MOUSE_HELP 8
- #define GET_PNT 9
- #define SAVECOUNT 10
- #define SET_FUNC_TEXT 11
- #define CREATE_ENTITY 12
- #define GET_TEXT_VAL 13
- #define READ_TXT_FILE 14
- #define ADD_POLYLN_PT 15
- #define ERASE_INV 16
- #define GET_DIM_VAL 17
- #define PRINT_DIM_VAL 18
- #define CLICK_ENTITY 19
- #define EX_CHANGE_ENTITY 20
- #define BLINK 21
- #define ENTITY_LOOP 22
- #define DRAW_ENTITIES 23
- #define STRING_INPUT 24
- #define SELECT_INIT 25
- #define SELECT_LOOP 26
- #define INSERT_MACRO 27
- #define CALC_PATTERN 28
- #define DELETE_ENTITY 29
- #define GET_ENTITY 30
- #define SET_INC_PNT 31
- #define INFO_LOOP 32
- #define GET_INFO 33
- #define STORE_INFO 34
- #define EX_CHANGE_INFO 35
- #define GET_ATTRIBUTES 36
- #define GET_LAY_GRP_BITS 37
- #define GET_LAYER_NAMES 38
- #define GET_GROUP_NAMES 39
- #define GET_GRID_SETS 40
- #define SET_ATTRIBUTES 41
- #define SET_LAY_GRP_BITS 42
- #define SET_LAYER_NAMES 43
- #define SET_GROUP_NAMES 44
- #define SET_GRID_SETS 45
- #define GET_CURRENT_FILE 46
- #define CREATE_MACRO 47
- #define MACRO_LOOP 48
- #define CLICK_MACRO 49
- #define ENTITY_LEN 50
- #define PART_LIST 51
- #define GET_PATTERN_VAL 52
- #define GET_EXPRESSION 53
- #define DELETE_MACRO 54
- #define GET_MACRO_INFO 55
- #define SET_MACRO_INFO 56
- #define GET_PNT_SYMBOL 57
-
- /**********************************************************************/
- /* The functions of the MegaCAD interface. */
- /**********************************************************************/
-
- short GetPntInv( // get point and draw something with mouse move
- double *pkt, // point to be filled in
- short setinc, // incremental point to be set ?
- tCallBack func, // callback function
- void *para) // data pointer for callback function
- {
- t_MegaPars params;
-
- params.m_GetPntInv.pkt = pkt ;
- params.m_GetPntInv.setinc = setinc;
- params.m_GetPntInv.func = func ;
- params.m_GetPntInv.para = para ;
-
- return( (short) CallMegaCAD(¶ms,GET_PNT_INV) );
- }
-
- /**********************************************************************/
-
- void DrawInv( // draw and save a temporary object
- ushort type, // type of entity to be drawn
- void *ptr, // data of entity
- ushort lmode, // line attributes (see LMODE)
- ushort atype) // type to get attributes from
- {
- t_MegaPars params;
-
- params.m_DrawInv.type = type ;
- params.m_DrawInv.ptr = ptr ;
- params.m_DrawInv.lmode = lmode;
- params.m_DrawInv.atype = atype;
-
- CallMegaCAD(¶ms,DRAW_INV);
- }
-
- /**********************************************************************/
-
- short DlgInput( // input some values by dialog
- ushort num, // number of fields (1 - 10)
- char *title, // title string
- t_dlgdta *dta) // array of field descriptors
- {
- t_MegaPars params;
-
- params.m_DlgInput.num = num ;
- params.m_DlgInput.title = title;
- params.m_DlgInput.dta = dta ;
-
- return( (short) CallMegaCAD(¶ms,DLG_INPUT) );
- }
-
- /**********************************************************************/
-
- short GetFilename( // let the user select a filename
- char *title, // title string
- char *fname) // filename; must be initialized with path
- {
- t_MegaPars params;
-
- params.m_GetFilename.title = title;
- params.m_GetFilename.fname = fname;
-
- return( (short) CallMegaCAD(¶ms,GET_FILENAME) );
- }
-
- /**********************************************************************/
-
- void StoreMultiple( // store an entity (maybe multiple)
- double *data, // entity data
- ushort type) // entity type (may be or'ed with DO_SAVCNT)
- {
- t_MegaPars params;
-
- params.m_StoreMultiple.data = data;
- params.m_StoreMultiple.type = type;
-
- CallMegaCAD(¶ms,STORE_MULTIPLE);
- }
-
- /**********************************************************************/
-
- void MegaCMD( // call MegaCAD command
- char *cmd) // command string (+ arguments)
- {
- t_MegaPars params;
-
- params.m_MegaCMD.cmd = cmd;
-
- CallMegaCAD(¶ms,MEGA_CMD);
- }
-
- /**********************************************************************/
-
- short Message( // message box
- char *str1, // 1st line of text
- char *str2, // 2nd line of text
- char *but1, // 1st button (may be NULL)
- char *but2, // 2nd button (may be NULL)
- char *but3, // 3rd button
- short defbut) // number of default button (1-3)
- {
- t_MegaPars params;
-
- params.m_Message.str1 = str1 ;
- params.m_Message.str2 = str2 ;
- params.m_Message.but1 = but1 ;
- params.m_Message.but2 = but2 ;
- params.m_Message.but3 = but3 ;
- params.m_Message.defbut = defbut;
-
- return( (short) CallMegaCAD(¶ms,MESSAGE) );
- }
-
- /**********************************************************************/
-
- void MouseHelp( // help text for mouse buttons
- char *str1, // help text for left mouse button
- char *str2, // help text for right mouse button
- ushort inv) // colour (beep) for 1st text (see HLP_INV)
- {
- t_MegaPars params;
-
- params.m_MouseHelp.str1 = str1;
- params.m_MouseHelp.str2 = str2;
- params.m_MouseHelp.inv = inv ;
-
- CallMegaCAD(¶ms,MOUSE_HELP);
- }
-
- /**********************************************************************/
-
- short GetPnt( // get point
- double *pkt, // point to be filled in
- short setinc) // incremental point to be set ?
- {
- t_MegaPars params;
-
- params.m_GetPnt.pkt = pkt ;
- params.m_GetPnt.setinc = setinc;
-
- return( (short) CallMegaCAD(¶ms,GET_PNT) );
- }
-
- /**********************************************************************/
-
- void savecount( // end of operation
- void ) // must be called after creation of entities
- {
- t_MegaPars params;
-
- CallMegaCAD(¶ms,SAVECOUNT);
- }
-
- /**********************************************************************/
-
- void SetFuncText( // set name of current function
- char *text) // function text
- {
- t_MegaPars params;
-
- params.m_SetFuncText.text = text;
-
- CallMegaCAD(¶ms,SET_FUNC_TEXT);
- }
-
- /**********************************************************************/
-
- ulong CreateEntity( // store an entity (not multiple), returns ID
- ushort type, // entity type
- t_attribs *attr, // entity attributes (may be NULL)
- void *data) // entity data
- {
- t_MegaPars params;
-
- params.m_CreateEntity.type = type;
- params.m_CreateEntity.attr = attr;
- params.m_CreateEntity.data = data;
-
- return( (ulong) CallMegaCAD(¶ms,CREATE_ENTITY) );
- }
-
- /**********************************************************************/
-
- void GetTextVal( // retrieve text attributes
- ushort type, // line or block
- ushort init, // initialize (or just calculate box)
- t_text *txt) // text data
- {
- t_MegaPars params;
-
- params.m_GetTextVal.type = type;
- params.m_GetTextVal.init = init;
- params.m_GetTextVal.txt = txt ;
-
- CallMegaCAD(¶ms,GET_TEXT_VAL);
- }
-
- /**********************************************************************/
-
- ushort ReadTxtFile( // read in a text file
- char *fname, // filename
- char *buf, // buffer to be filled in
- uint bufsiz) // size of buffer
- {
- t_MegaPars params;
-
- params.m_ReadTxtFile.fname = fname ;
- params.m_ReadTxtFile.buf = buf ;
- params.m_ReadTxtFile.bufsiz = bufsiz;
-
- return( (ushort) CallMegaCAD(¶ms,READ_TXT_FILE) );
- }
-
- /**********************************************************************/
-
- ushort AddPolylnPt( // add a polyline point
- t_polyln *polyln, // polyline structure
- double *mpd, // may be NULL
- double px, // x-coordinate of point
- double py) // y-coordinate of point
- {
- t_MegaPars params;
-
- params.m_AddPolylnPt.polyln = polyln;
- params.m_AddPolylnPt.mpd = mpd ;
- params.m_AddPolylnPt.px = px ;
- params.m_AddPolylnPt.py = py ;
-
- return( (ushort) CallMegaCAD(¶ms,ADD_POLYLN_PT) );
- }
-
- /**********************************************************************/
-
- void EraseInv( // delete temporary objects
- void )
- {
- t_MegaPars params;
-
- CallMegaCAD(¶ms,ERASE_INV);
- }
-
- /**********************************************************************/
-
- void GetDimVal( // retrieve dimension attributes
- ushort type, // type of dimension
- ushort init, // initialize (or just calculate box)
- t_dimension *dim) // dimension data
- {
- t_MegaPars params;
-
- params.m_GetDimVal.type = type;
- params.m_GetDimVal.init = init;
- params.m_GetDimVal.dim = dim ;
-
- CallMegaCAD(¶ms,GET_DIM_VAL);
- }
-
- /**********************************************************************/
-
- void PrintDimVal( // print dimension text
- double value, // measured value
- char *str, // string buffer to fill
- char *tol1, // tolerance string 1
- char *tol2) // tolerance string 2
- {
- t_MegaPars params;
-
- params.m_PrintDimVal.value = value;
- params.m_PrintDimVal.str = str ;
- params.m_PrintDimVal.tol1 = tol1 ;
- params.m_PrintDimVal.tol2 = tol2 ;
-
- CallMegaCAD(¶ms,PRINT_DIM_VAL);
- }
-
- /**********************************************************************/
-
- short ClickEntity( // let the user click a single entity
- ulong filter, // allowed entity types
- double *pnt, // point where entity was clicked
- t_entity *ent, // entity data to be filled in
- void *edta, // data ptr of variable length entities
- ushort esiz, // size of data buffer
- uchar fModify) // entity to be modified?
- {
- t_MegaPars params;
-
- params.m_ClickEntity.filter = filter ;
- params.m_ClickEntity.pnt = pnt ;
- params.m_ClickEntity.ent = ent ;
- params.m_ClickEntity.edta = edta ;
- params.m_ClickEntity.esiz = esiz ;
- params.m_ClickEntity.fModify = fModify;
-
- return( (short) CallMegaCAD(¶ms,CLICK_ENTITY) );
- }
-
- /**********************************************************************/
-
- ulong ExChangeEntity( // exchange an entity, returns new ID
- t_entity *ent) // new entity data, old id
- {
- t_MegaPars params;
-
- params.m_ExChangeEntity.ent = ent;
-
- return( (ulong) CallMegaCAD(¶ms,EX_CHANGE_ENTITY) );
- }
-
- /**********************************************************************/
-
- short Blink( // draw something blinking
- tCallBack func, // callback function
- void *para) // data pointer for callback function
- {
- t_MegaPars params;
-
- params.m_Blink.func = func;
- params.m_Blink.para = para;
-
- return( (short) CallMegaCAD(¶ms,BLINK) );
- }
-
- /**********************************************************************/
-
- void EntityLoop( // loop through all entities
- ulong filter, // allowed entity types
- tCallBack func, // callback function
- void *para, // data pointer for callback function
- void *edta, // data ptr of variable length entities
- ushort esiz) // size of data buffer
- {
- t_MegaPars params;
-
- params.m_EntityLoop.filter = filter;
- params.m_EntityLoop.func = func ;
- params.m_EntityLoop.para = para ;
- params.m_EntityLoop.edta = edta ;
- params.m_EntityLoop.esiz = esiz ;
-
- CallMegaCAD(¶ms,ENTITY_LOOP);
- }
-
- /**********************************************************************/
-
- void DrawEntities( // draw array of entity-id's
- ulong *pid, // array of entity-id's
- ushort num) // number of id's
- {
- t_MegaPars params;
-
- params.m_DrawEntities.pid = pid;
- params.m_DrawEntities.num = num;
-
- CallMegaCAD(¶ms,DRAW_ENTITIES);
- }
-
- /**********************************************************************/
-
- short StringInput( // input a line of text
- char *title, // title string
- char *buf, // string buffer to be filled in
- ushort buflen) // size of buffer
- {
- t_MegaPars params;
-
- params.m_StringInput.title = title ;
- params.m_StringInput.buf = buf ;
- params.m_StringInput.buflen = buflen;
-
- return( (short) CallMegaCAD(¶ms,STRING_INPUT) );
- }
-
- /**********************************************************************/
-
- void SelectInit( // set select filter
- ulong filter) // allowed entity types
- {
- t_MegaPars params;
-
- params.m_SelectInit.filter = filter;
-
- CallMegaCAD(¶ms,SELECT_INIT);
- }
-
- /**********************************************************************/
-
- void SelectLoop( // select entities
- tCallBack func, // callback function
- void *para, // data pointer for callback function
- void *edta, // data ptr of variable length entities
- ushort esiz, // size of data buffer
- uchar fModify) // entities to be modified?
- {
- t_MegaPars params;
-
- params.m_SelectLoop.func = func ;
- params.m_SelectLoop.para = para ;
- params.m_SelectLoop.edta = edta ;
- params.m_SelectLoop.esiz = esiz ;
- params.m_SelectLoop.fModify = fModify;
-
- CallMegaCAD(¶ms,SELECT_LOOP);
- }
-
- /**********************************************************************/
-
- ushort InsertMacro( // insert macro-file
- char *fname, // macro filename
- tCallBack func, // callback function
- void *para, // data pointer for callback function
- void *edta, // data ptr of variable length entities
- ushort esiz, // size of data buffer
- t_placemac *pmac) // how (and where) to place the macro
- {
- t_MegaPars params;
-
- params.m_InsertMacro.fname = fname;
- params.m_InsertMacro.func = func ;
- params.m_InsertMacro.para = para ;
- params.m_InsertMacro.edta = edta ;
- params.m_InsertMacro.esiz = esiz ;
- params.m_InsertMacro.pmac = pmac ;
-
- return( (ushort) CallMegaCAD(¶ms,INSERT_MACRO) );
- }
-
- /**********************************************************************/
-
- ushort CalcPattern( // calc perimeter, area, pt. of gravity
- ushort which, // PERIM, AREA, GRAVITY
- ushort cnt, // cnt of polyline points
- t_polypt *ppt, // maybe NULL
- double *result) // value vs. point
- {
- t_MegaPars params;
-
- params.m_CalcPattern.which = which ;
- params.m_CalcPattern.cnt = cnt ;
- params.m_CalcPattern.ppt = ppt ;
- params.m_CalcPattern.result = result;
-
- return( (ushort) CallMegaCAD(¶ms,CALC_PATTERN) );
- }
-
- /**********************************************************************/
-
- ushort DeleteEntity( // delete an entity
- ulong id) // ID of entity
- {
- t_MegaPars params;
-
- params.m_DeleteEntity.id = id;
-
- return( (ushort) CallMegaCAD(¶ms,DELETE_ENTITY) );
- }
-
- /**********************************************************************/
-
- ushort GetEntity( // get entity data
- ulong id, // ID of entity
- t_entity *ent, // entity
- void *edta, // data ptr of variable length entities
- ushort esiz) // size of data buffer
- {
- t_MegaPars params;
-
- params.m_GetEntity.id = id ;
- params.m_GetEntity.ent = ent ;
- params.m_GetEntity.edta = edta;
- params.m_GetEntity.esiz = esiz;
-
- return( (ushort) CallMegaCAD(¶ms,GET_ENTITY) );
- }
-
- /**********************************************************************/
-
- void SetIncPnt( // set incremental point
- double *pnt) // new incremental point
- {
- t_MegaPars params;
-
- params.m_SetIncPnt.pnt = pnt;
-
- CallMegaCAD(¶ms,SET_INC_PNT);
- }
-
- /**********************************************************************/
-
- void InfoLoop( // loop through all entity infos
- tCallBack func, // callback function
- t_entinfo *inf ) // info buffer
- {
- t_MegaPars params;
-
- params.m_InfoLoop.func = func;
- params.m_InfoLoop.inf = inf ;
-
- CallMegaCAD(¶ms,INFO_LOOP);
- }
-
- /**********************************************************************/
-
- ushort GetInfo( // get entity info data
- ushort iID, // info ID
- t_entinfo *inf ) // info buffer
- {
- t_MegaPars params;
-
- params.m_GetInfo.iID = iID ;
- params.m_GetInfo.inf = inf ;
-
- return( (ushort) CallMegaCAD(¶ms,GET_INFO) );
- }
-
- /**********************************************************************/
-
- ushort StoreInfo( // store entity info
- t_entinfo *inf ) // info buffer
- {
- t_MegaPars params;
-
- params.m_StoreInfo.inf = inf ;
-
- return( (ushort) CallMegaCAD(¶ms,STORE_INFO) );
- }
-
- /**********************************************************************/
-
- ushort ExChangeInfo( // exchange entity info data
- t_entinfo *inf ) // info buffer
- {
- t_MegaPars params;
-
- params.m_ExChangeInfo.inf = inf ;
-
- return( (ushort) CallMegaCAD(¶ms,EX_CHANGE_INFO) );
- }
-
- /**********************************************************************/
-
- void GetAttributes( // get attributes (stl,col...)
- ushort type, // entity type
- t_attribs *attr) // buffer to be filled in
- {
- t_MegaPars params;
-
- params.m_GetAttributes.type = type;
- params.m_GetAttributes.attr = attr;
-
- CallMegaCAD(¶ms,GET_ATTRIBUTES);
- }
-
- /**********************************************************************/
-
- void GetLayGrpBits( // retrieve active/inactive layers
- uchar *bits) // buffer of 256 bytes !!!
- {
- t_MegaPars params;
-
- params.m_GetLayGrpBits.bits = bits;
-
- CallMegaCAD(¶ms,GET_LAY_GRP_BITS);
- }
-
- /**********************************************************************/
-
- void GetLayerNames( // retrieve layer names
- t_laygrp *lg) // buffer of 256 * 64 bytes
- {
- t_MegaPars params;
-
- params.m_GetLayerNames.lg = lg;
-
- CallMegaCAD(¶ms,GET_LAYER_NAMES);
- }
-
- /**********************************************************************/
-
- void GetGroupNames( // retrieve group names
- t_laygrp *lg) // buffer of 256 * 64 bytes
- {
- t_MegaPars params;
-
- params.m_GetGroupNames.lg = lg;
-
- CallMegaCAD(¶ms,GET_GROUP_NAMES);
- }
-
- /**********************************************************************/
-
- void GetGridSets( // retrieve grid settings
- t_gridsets *grid) // buffer to be filled in
- {
- t_MegaPars params;
-
- params.m_GetGridSets.grid = grid;
-
- CallMegaCAD(¶ms,GET_GRID_SETS);
- }
-
- /**********************************************************************/
-
- void SetAttributes( // alter attributes (stl,col...)
- ushort type, // entity type
- t_attribs *attr) // new attributes
- {
- t_MegaPars params;
-
- params.m_SetAttributes.type = type;
- params.m_SetAttributes.attr = attr;
-
- CallMegaCAD(¶ms,SET_ATTRIBUTES);
- }
-
- /**********************************************************************/
-
- void SetLayGrpBits( // set active/inactive layers
- uchar *bits) // new bits (256 bytes !!!)
- {
- t_MegaPars params;
-
- params.m_SetLayGrpBits.bits = bits;
-
- CallMegaCAD(¶ms,SET_LAY_GRP_BITS);
- }
-
- /**********************************************************************/
-
- void SetLayerNames( // set layer names
- t_laygrp *lg) // buffer of 256 * 64 Bytes
- {
- t_MegaPars params;
-
- params.m_SetLayerNames.lg = lg;
-
- CallMegaCAD(¶ms,SET_LAYER_NAMES);
- }
-
- /**********************************************************************/
-
- void SetGroupNames( // set group names
- t_laygrp *lg) // buffer of 256 * 64 Bytes
- {
- t_MegaPars params;
-
- params.m_SetGroupNames.lg = lg;
-
- CallMegaCAD(¶ms,SET_GROUP_NAMES);
- }
-
- /**********************************************************************/
-
- void SetGridSets( // alter grid settings
- t_gridsets *grid) // new settings
- {
- t_MegaPars params;
-
- params.m_SetGridSets.grid = grid;
-
- CallMegaCAD(¶ms,SET_GRID_SETS);
- }
-
- /**********************************************************************/
-
- short GetCurrentFile( // get name of currently loaded file
- uchar *fname) // name buffer to be filled in
- {
- t_MegaPars params;
-
- params.m_GetCurrentFile.fname = fname;
-
- return( (short) CallMegaCAD(¶ms,GET_CURRENT_FILE) );
- }
-
- /**********************************************************************/
-
- ulong CreateMacro( // create and insert a macro
- t_macro *mac, // macro data
- t_mkmacro *mkm, // entities to be created
- ushort cnt, // number of entries
- t_placemac *pmac) // how (and where) to place the macro
- {
- t_MegaPars params;
-
- params.m_CreateMacro.mac = mac ;
- params.m_CreateMacro.mkm = mkm ;
- params.m_CreateMacro.cnt = cnt ;
- params.m_CreateMacro.pmac = pmac;
-
- return( (ulong) CallMegaCAD(¶ms,CREATE_MACRO) );
- }
-
- /**********************************************************************/
-
- void MacroLoop( // loop through all macros
- ulong filter, // allowed entity types
- ulong start, // start ID (if 0L => all macros)
- tCallBack func, // callback function
- void *para, // data pointer for callback function
- void *edta, // data ptr of variable length entities
- ushort esiz) // size of data buffer
- {
- t_MegaPars params;
-
- params.m_MacroLoop.filter = filter;
- params.m_MacroLoop.start = start ;
- params.m_MacroLoop.func = func ;
- params.m_MacroLoop.para = para ;
- params.m_MacroLoop.edta = edta ;
- params.m_MacroLoop.esiz = esiz ;
-
- CallMegaCAD(¶ms,MACRO_LOOP);
- }
-
- /**********************************************************************/
-
- short ClickMacro( // let the user click a macro
- double *pnt, // point where macro was clicked
- t_entity *ent, // macro data to be filled in
- void *edta, // data ptr of variable length entities
- ushort esiz) // size of data buffer
- {
- t_MegaPars params;
-
- params.m_ClickMacro.pnt = pnt ;
- params.m_ClickMacro.ent = ent ;
- params.m_ClickMacro.edta = edta;
- params.m_ClickMacro.esiz = esiz;
-
- return( (short) CallMegaCAD(¶ms,CLICK_MACRO) );
- }
-
- /**********************************************************************/
-
- short EntityLen( // retrieve the length of an entity
- t_entity *ent, // entity to get length of
- double *len) // resulting length
- {
- t_MegaPars params;
-
- params.m_EntityLen.ent = ent;
- params.m_EntityLen.len = len;
-
- return( (short) CallMegaCAD(¶ms,ENTITY_LEN) );
- }
-
- /**********************************************************************/
-
- short PartList( // create a part list
- uchar *fmt, // name of format file
- uchar *out, // name of output file (maybe NULL)
- uchar flags) // flags (PART_....)
- {
- t_MegaPars params;
-
- params.m_PartList.fmt = fmt ;
- params.m_PartList.out = out ;
- params.m_PartList.flags = flags;
-
- return( (short) CallMegaCAD(¶ms,PART_LIST) );
- }
-
- /**********************************************************************/
-
- void GetPatternVal( // retrieve current pattern settings
- t_pattern *pat) // pattern data
- {
- t_MegaPars params;
-
- params.m_GetPatternVal.pat = pat;
-
- CallMegaCAD(¶ms,GET_PATTERN_VAL);
- }
-
- /**********************************************************************/
-
- short GetExpression( // evaluate expression
- uchar *expr, // expression to be evaluated
- double *retval) // result
- {
- t_MegaPars params;
-
- params.m_GetExpression.expr = expr ;
- params.m_GetExpression.retval = retval;
-
- return( (short) CallMegaCAD(¶ms,GET_EXPRESSION) );
- }
-
- /**********************************************************************/
-
- short DeleteMacro( // delete a whole macro
- ulong id) // ID of macro entity
- {
- t_MegaPars params;
-
- params.m_DeleteMacro.id = id;
-
- return( (short) CallMegaCAD(¶ms,DELETE_MACRO) );
- }
-
- /**********************************************************************/
-
- short GetMacroInfo( // retrieve info of current macro file
- t_macinfo *macinfo) // buffer to be filled in
- {
- t_MegaPars params;
-
- params.m_GetMacroInfo.macinfo = macinfo;
-
- return( (short) CallMegaCAD(¶ms,GET_MACRO_INFO) );
- }
-
- /**********************************************************************/
-
- short SetMacroInfo( // set info of current macro file
- t_macinfo *macinfo) // data to be set
- {
- t_MegaPars params;
-
- params.m_SetMacroInfo.macinfo = macinfo;
-
- return( (short) CallMegaCAD(¶ms,SET_MACRO_INFO) );
- }
-
- /**********************************************************************/
-
- void GetPntSymbol( // get current symbol settings
- t_symbol *sym) // data to be filled in
- {
- t_MegaPars params;
-
- params.m_GetPntSymbol.sym = sym;
-
- CallMegaCAD(¶ms,GET_PNT_SYMBOL);
- }
-
- /**********************************************************************/
-
-