home *** CD-ROM | disk | FTP | other *** search
/ Enter 1998 December / ENTER12_1.iso / Dema / Cad_Proj.ekt / Mega48t / CC / MEGACAD.H_ / MEGACAD.H
Encoding:
C/C++ Source or Header  |  1997-10-13  |  13.5 KB  |  336 lines

  1. /**********************************************************************/
  2. /* MegaCAD colour values                                              */
  3. /**********************************************************************/
  4.  
  5. #define BLACK          0
  6. #define BLUE           1
  7. #define GREEN          2
  8. #define CYAN           3
  9. #define RED            4
  10. #define MAGENTA        5
  11. #define YELLOW         6
  12. #define WHITE          7
  13. #define BRIGHT_BLACK   8
  14. #define BRIGHT_BLUE    9
  15. #define BRIGHT_GREEN   10
  16. #define BRIGHT_CYAN    11
  17. #define BRIGHT_RED     12
  18. #define BRIGHT_MAGENTA 13
  19. #define BRIGHT_YELLOW  14
  20. #define BRIGHT_WHITE   15
  21.  
  22. /**********************************************************************/
  23.  
  24. #define NIB(i,s)       (((i) & 0xf)<<(s))
  25.  
  26. #define LMODE(s,c,w) ((ushort)(NIB(s,0) | (((c)&0xff)<<8) | NIB(w,12)))
  27. //    s = linestyle, c = colour, w = linewidth
  28. //    with 'DrawInv()' values may be constant or 0,
  29. //                       if 0, current values are taken
  30. //      if you want a continuous line with width 1, you can call :
  31. //        DrawInv(E_LINE,&line,LMODE(1,WHITE,1),0);
  32. //      if you want the current settings of entity type 'type', you call :
  33. //        DrawInv(E_LINE,&line,LMODE(0,0,0),type);
  34.  
  35. #define HLP_INV(f,b,s) ((ushort)(NIB(f,0) | NIB(b,4) | ((s)<<15)))
  36. //      f = foreground colour, b = background colour, s = sound ?
  37. //      if you set both colours to 0, the default colours are taken
  38.  
  39. #define DO_SAVCNT      (1<<7)
  40. //      calls 'savecount()' at the end of 'StoreMultiple()'
  41. //      if or'ed together with entity type
  42.  
  43. #if defined ( MEGATECH_C )
  44.     #define tCallBack void *
  45. #else
  46.     typedef short (_far *tCallBack)(void _far *para);
  47. #endif
  48.  
  49. #define CONTINUE_LOOP  0
  50. #define CALL_SAVECOUNT 1
  51. #define BREAK_LOOP     2
  52.  
  53. #define CALC_PERIM   0
  54. #define CALC_AREA    1
  55. #define CALC_GRAVITY 2
  56.  
  57. #define LAY_ON      (1<<0)
  58. #define LAY_LOCK  (1<<1)
  59. #define LAY_ATTR  (1<<2)
  60.  
  61. #define GRP_ON      (1<<4)
  62. #define GRP_LOCK  (1<<5)
  63. #define GRP_ATTR  (1<<6)
  64.  
  65. #define PART_ALL 1
  66. #define PART_MAC 2
  67. #define PART_ENT 4
  68.  
  69. #define InsertMac(f,c,p,e,s) InsertMacro(f,c,p,e,s,NULL)
  70.  
  71. /**********************************************************************/
  72. /* Tell C++ compilers that these functions are C functions!           */
  73. /**********************************************************************/
  74. #ifdef __cplusplus
  75. extern "C" {
  76. #endif
  77. /**********************************************************************/
  78. /* MegaCAD function prototypes.                                       */
  79. /**********************************************************************/
  80.  
  81. EXT(201) short GetPntInv(     // get point and draw something with mouse move
  82.         double      *pkt,     // point to be filled in
  83.         short       setinc,   // incremental point to be set ?
  84.         tCallBack   func,     // callback function
  85.         void        *para);   // data pointer for callback function
  86.  
  87. EXT(202) void DrawInv(        // draw and save a temporary object
  88.         ushort      type,     // type of entity to be drawn
  89.         void        *ptr,     // data of entity
  90.         ushort      lmode,    // line attributes (see LMODE)
  91.         ushort      atype);   // type to get attributes from
  92.  
  93. EXT(203) short DlgInput(      // input some values by dialog
  94.         ushort      num,      // number of fields (1 - 10)
  95.         char        *title,   // title string
  96.         t_dlgdta    *dta);    // array of field descriptors
  97.  
  98. EXT(204) short GetFilename(   // let the user select a filename
  99.         char        *title,   // title string
  100.         char        *fname);  // filename; must be initialized with path
  101.  
  102. EXT(205) void StoreMultiple(  // store an entity (maybe multiple)
  103.         double      *data,    // entity data
  104.         ushort      type);    // entity type (may be or'ed with DO_SAVCNT)
  105.  
  106. EXT(206) void MegaCMD(        // call MegaCAD command
  107.         char        *cmd);    // command string (+ arguments)
  108.  
  109. EXT(207) short Message(       // message box
  110.         char        *str1,    // 1st line of text
  111.         char        *str2,    // 2nd line of text
  112.         char        *but1,    // 1st button (may be NULL)
  113.         char        *but2,    // 2nd button (may be NULL)
  114.         char        *but3,    // 3rd button
  115.         short       defbut);  // number of default button (1-3)
  116.  
  117. EXT(208) void MouseHelp(      // help text for mouse buttons
  118.         char        *str1,    // help text for left mouse button
  119.         char        *str2,    // help text for right mouse button
  120.         ushort      inv);     // colour (beep) for 1st text (see HLP_INV)
  121.  
  122. EXT(209) short GetPnt(        // get point
  123.         double      *pkt,     // point to be filled in
  124.         short       setinc);  // incremental point to be set ?
  125.  
  126. EXT(210) void savecount(      // end of operation
  127.         void );               // must be called after creation of entities
  128.  
  129. EXT(211) void SetFuncText(    // set name of current function
  130.         char        *text);   // function text
  131.  
  132. EXT(212) ulong CreateEntity(  // store an entity (not multiple), returns ID
  133.         ushort      type,     // entity type
  134.         t_attribs   *attr,    // entity attributes (may be NULL)
  135.         void        *data);   // entity data
  136.  
  137. EXT(213) void GetTextVal(     // retrieve text attributes
  138.         ushort      type,     // line or block
  139.         ushort      init,     // initialize (or just calculate box)
  140.         t_text      *txt);    // text data
  141.  
  142. EXT(214) ushort ReadTxtFile(  // read in a text file
  143.         char        *fname,   // filename
  144.         char        *buf,     // buffer to be filled in
  145.         uint        bufsiz);  // size of buffer
  146.  
  147. EXT(215) ushort AddPolylnPt(  // add a polyline point
  148.         t_polyln    *polyln,  // polyline structure
  149.         double      *mpd,     // may be NULL
  150.         double      px,       // x-coordinate of point
  151.         double      py);      // y-coordinate of point
  152.  
  153. EXT(216) void EraseInv(       // delete temporary objects
  154.         void );
  155.  
  156. EXT(217) void GetDimVal(      // retrieve dimension attributes
  157.         ushort      type,     // type of dimension
  158.         ushort      init,     // initialize (or just calculate box)
  159.         t_dimension *dim);    // dimension data
  160.  
  161. EXT(218) void PrintDimVal(    // print dimension text
  162.         double      value,    // measured value
  163.         char        *str,     // string buffer to fill
  164.         char        *tol1,    // tolerance string 1
  165.         char        *tol2);   // tolerance string 2
  166.  
  167. EXT(219) short ClickEntity(   // let the user click a single entity
  168.         ulong       filter,   // allowed entity types
  169.         double      *pnt,     // point where entity was clicked
  170.         t_entity    *ent,     // entity data to be filled in
  171.         void        *edta,    // data ptr of variable length entities
  172.     ushort        esiz,     // size of data buffer
  173.     uchar        fModify); // entity to be modified?
  174.  
  175. EXT(220) ulong ExChangeEntity(// exchange an entity, returns new ID
  176.         t_entity    *ent);    // new entity data, old id
  177.  
  178. EXT(221) short Blink(         // draw something blinking
  179.         tCallBack   func,     // callback function
  180.         void        *para);   // data pointer for callback function
  181.  
  182. EXT(222) void EntityLoop(     // loop through all entities
  183.         ulong       filter,   // allowed entity types
  184.         tCallBack   func,     // callback function
  185.         void        *para,    // data pointer for callback function
  186.         void        *edta,    // data ptr of variable length entities
  187.     ushort        esiz);    // size of data buffer
  188.  
  189. EXT(223) void DrawEntities(   // draw array of entity-id's
  190.         ulong       *pid,     // array of entity-id's
  191.         ushort      num);     // number of id's
  192.  
  193. EXT(224) short StringInput(   // input a line of text
  194.         char        *title,   // title string
  195.         char        *buf,     // string buffer to be filled in
  196.         ushort      buflen);  // size of buffer
  197.  
  198. EXT(225) void SelectInit(     // set select filter
  199.         ulong       filter);  // allowed entity types
  200.  
  201. EXT(226) void SelectLoop(     // select entities
  202.         tCallBack   func,     // callback function
  203.         void        *para,    // data pointer for callback function
  204.         void        *edta,    // data ptr of variable length entities
  205.     ushort        esiz,     // size of data buffer
  206.     uchar        fModify); // entities to be modified?
  207.  
  208. EXT(227) ushort InsertMacro(  // insert macro-file
  209.         char        *fname,   // macro filename
  210.         tCallBack   func,     // callback function
  211.         void        *para,    // data pointer for callback function
  212.         void        *edta,    // data ptr of variable length entities
  213.         ushort      esiz,     // size of data buffer
  214.         t_placemac  *pmac);   // how (and where) to place the macro
  215.  
  216. EXT(228) ushort CalcPattern(  // calc perimeter, area, pt. of gravity
  217.         ushort      which,    // PERIM, AREA, GRAVITY
  218.         ushort      cnt,      // cnt of polyline points
  219.         t_polypt    *ppt,     // maybe NULL
  220.         double      *result); // value vs. point
  221.  
  222. EXT(229) ushort DeleteEntity( // delete an entity
  223.         ulong       id);      // ID of entity
  224.  
  225. EXT(230) ushort GetEntity(    // get entity data
  226.         ulong       id,       // ID of entity
  227.         t_entity    *ent,     // entity
  228.         void        *edta,    // data ptr of variable length entities
  229.         ushort      esiz);    // size of data buffer
  230.  
  231. EXT(231) void SetIncPnt(      // set incremental point
  232.         double      *pnt);    // new incremental point
  233.  
  234. EXT(232) void InfoLoop(       // loop through all entity infos
  235.         tCallBack   func,     // callback function
  236.         t_entinfo   *inf );   // info buffer
  237.  
  238. EXT(233) ushort GetInfo(      // get entity info data
  239.         ushort      iID,      // info ID
  240.         t_entinfo   *inf );   // info buffer
  241.  
  242. EXT(234) ushort StoreInfo(    // store entity info
  243.         t_entinfo   *inf );   // info buffer
  244.  
  245. EXT(235) ushort ExChangeInfo( // exchange entity info data
  246.         t_entinfo   *inf );   // info buffer
  247.  
  248. EXT(236) void GetAttributes(  // get attributes (stl,col...)
  249.         ushort      type,     // entity type
  250.         t_attribs   *attr);   // buffer to be filled in
  251.  
  252. EXT(237) void GetLayGrpBits(  // retrieve active/inactive layers
  253.     uchar        *bits);   // buffer of 256 bytes !!!
  254.  
  255. EXT(238) void GetLayerNames(  // retrieve layer names
  256.         t_laygrp    *lg);     // buffer of 256 * 64 bytes
  257.  
  258. EXT(239) void GetGroupNames(  // retrieve group names
  259.         t_laygrp    *lg);     // buffer of 256 * 64 bytes
  260.  
  261. EXT(240) void GetGridSets(    // retrieve grid settings
  262.         t_gridsets  *grid);   // buffer to be filled in
  263.  
  264. EXT(241) void SetAttributes(  // alter attributes (stl,col...)
  265.         ushort      type,     // entity type
  266.         t_attribs   *attr);   // new attributes
  267.  
  268. EXT(242) void SetLayGrpBits(  // set active/inactive layers
  269.     uchar        *bits);   // new bits (256 bytes !!!)
  270.  
  271. EXT(243) void SetLayerNames(  // set layer names
  272.         t_laygrp    *lg);     // buffer of 256 * 64 Bytes
  273.  
  274. EXT(244) void SetGroupNames(  // set group names
  275.         t_laygrp    *lg);     // buffer of 256 * 64 Bytes
  276.  
  277. EXT(245) void SetGridSets(    // alter grid settings
  278.         t_gridsets  *grid);   // new settings
  279.  
  280. EXT(246) short GetCurrentFile(// get name of currently loaded file
  281.         uchar       *fname);  // name buffer to be filled in
  282.  
  283. EXT(247) ulong CreateMacro(   // create and insert a macro
  284.         t_macro     *mac,     // macro data
  285.         t_mkmacro   *mkm,     // entities to be created
  286.         ushort      cnt,      // number of entries
  287.         t_placemac  *pmac);   // how (and where) to place the macro
  288.  
  289. EXT(248) void MacroLoop(      // loop through all macros
  290.         ulong       filter,   // allowed entity types
  291.         ulong       start,    // start ID (if 0L => all macros)
  292.         tCallBack   func,     // callback function
  293.         void        *para,    // data pointer for callback function
  294.         void        *edta,    // data ptr of variable length entities
  295.         ushort      esiz);    // size of data buffer
  296.  
  297. EXT(249) short ClickMacro(    // let the user click a macro
  298.         double      *pnt,     // point where macro was clicked
  299.         t_entity    *ent,     // macro data to be filled in
  300.         void        *edta,    // data ptr of variable length entities
  301.         ushort      esiz);    // size of data buffer
  302.  
  303. EXT(250) short EntityLen(     // retrieve the length of an entity
  304.         t_entity    *ent,     // entity to get length of
  305.         double      *len);    // resulting length
  306.  
  307. EXT(251) short PartList(      // create a part list
  308.         uchar       *fmt,     // name of format file
  309.         uchar       *out,     // name of output file (maybe NULL)
  310.         uchar       flags);   // flags (PART_....)
  311.  
  312. EXT(252) void GetPatternVal(  // retrieve current pattern settings
  313.         t_pattern   *pat);    // pattern data
  314.  
  315. EXT(253) short GetExpression( // evaluate expression
  316.         uchar       *expr,    // expression to be evaluated
  317.         double      *retval); // result
  318.  
  319. EXT(254) short DeleteMacro(   // delete a whole macro
  320.     ulong        id);      // ID of macro entity
  321.  
  322. EXT(255) short GetMacroInfo(  // retrieve info of current macro file
  323.     t_macinfo   *macinfo);// buffer to be filled in
  324.  
  325. EXT(256) short SetMacroInfo(  // set info of current macro file
  326.     t_macinfo   *macinfo);// data to be set
  327.  
  328. EXT(257) void GetPntSymbol(   // get current symbol settings
  329.     t_symbol    *sym);    // data to be filled in
  330.  
  331. /**********************************************************************/
  332. #ifdef __cplusplus
  333. }
  334. #endif
  335. /**********************************************************************/
  336.