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