home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Graphics / graphics-16000.iso / amiga / mapping / drawmap.lha / DrawMap / source.lha / source / drawmap.h < prev    next >
C/C++ Source or Header  |  1992-04-06  |  8KB  |  256 lines

  1. /*  File drawmap.h  */
  2.  
  3. #ifndef MAX
  4. #define MAX(a,b) ((a)>=(b) ? (a) : (b))
  5. #define ABS(a) ((a)>=0 ? (a) : (-(a)))
  6. #endif
  7.  
  8. #define NOABORT 1<<1                   /* used in printmap() */
  9. #define U_ABORT 1<<2
  10. #define P_ABORT 1<<3
  11.  
  12. #ifndef PDERR_NOERR
  13. #define PDERR_NOERR 0L
  14. #endif
  15.  
  16. #define BITVAL(x,n)  ((x>>n)&1)
  17. #define BITSETT(x,n)  (x | bitval[n])
  18. #define BITCLEAR(x,n)  (x & (~bitval[n]))
  19. #define BITSTORE(x,n,val)  ((val==0) ? (x=BITCLEAR(x,n)) : (x=BITSETT(x,n)))
  20.  
  21. #define SHADOW_DISP  4                 /* shadow displacement (pix) */
  22.  
  23. #define WC WINDOWCLOSE
  24. #define WDP WINDOWDEPTH
  25.  
  26. #define IDCMPFLAGS (CLOSEWINDOW | MOUSEBUTTONS | MENUPICK)
  27.  
  28. #define WINFLAGS1 (SMART_REFRESH | ACTIVATE | BACKDROP)
  29. #define WINFLAGS2 (BORDERLESS | REPORTMOUSE)
  30.  
  31. #define WWIDTH 640                     /* window width (pixels)       */
  32. #define WHEIGHT 400                    /* window height (pixels)      */
  33. #define VMODE (HIRES | LACE)           /* view mode                   */
  34. #define DEPTH 4                        /* 16 colors => 4 bitplanes    */
  35.  
  36. #define CENTERX (WWIDTH/2)             /* place origin at center of   */
  37. #define CENTERY (WHEIGHT/2)            /*   window                    */
  38. #define HFACTOR (WWIDTH/360.)          /* horizontal scale (pix/deg)  */
  39. #define VFACTOR (WHEIGHT/180.)         /* vertical scale (pix/deg)    */
  40. #define M_VFACTOR (WHEIGHT/5.90)       /* vertical scale for Mercator */
  41.                                        /*   map (+/- 84 degrees lat.) */
  42. #define ASP_RAT ((640./400.)*(188./260.)) /* screen aspect ratio      */
  43.                                        /*  (max width / max hgt)      */
  44. #define VRADIUS 160                    /* vertical radius of ellipse  */
  45.                                        /*   (pixels)                  */
  46. #define HRADIUS (short)(ASP_RAT * VRADIUS+0.5) /* horiz. radius (pix) */
  47. #define ROWOFFSET (WWIDTH/8)           /* length of each screen row   */
  48.                                        /*   in bytes                  */
  49.  
  50. #define OK     0                       /* result flags */
  51. #define NOT_OK 1
  52. #define ABORT  2
  53.  
  54. #define BLUE       0L                  /* default colors */
  55. #define WHITE      1L
  56. #define LT_VIO     2L
  57. #define DK_VIO     3L
  58. #define LT_GRN     4L
  59. #define DK_GRN     5L
  60. #define LT_BL      6L
  61. #define DK_BL      7L
  62. #define LT_YEL     8L
  63. #define DK_YEL     9L
  64. #define LT_PUR    10L
  65. #define DK_PUR    11L
  66. #define LT_RED    12L
  67. #define DK_RED    13L
  68. #define BLACK     14L
  69. #define ORANGE    15L
  70.  
  71. UWORD mapcolors[] = {                  /* default color table            */
  72.    0x006b, 0x0fff, 0x0caf, 0x095f,     /* blue, white, lt vio, dk vio    */
  73.    0x00f0, 0x00a0, 0x00bf, 0x000f,     /* lt grn, dk grn, lt bl, dk bl   */
  74.    0x0ff0, 0x0cc0, 0x0f0f, 0x0b0b,     /* lt yel, dk yel, lt pur, dk pur */
  75.    0x0f44, 0x0c00, 0x0000, 0x0f90      /* lt red, dk red, black, orange  */
  76. };
  77.  
  78.                                        /* number of colors in color table */
  79. #define NUM_COLORS (sizeof(mapcolors)/sizeof(UWORD))
  80.  
  81. UWORD configcolors[NUM_COLORS];        /* color configuration */
  82.  
  83. char configfile[]   = "map.config";
  84. char limitsfile[]   = "map.limits.bin";
  85. char flatmapfile[]  = "map.flat.pic";
  86.  
  87. #define RE 6378.165                    /* radius of Earth (kilometers) */
  88. #define VIEW_HEIGHT 300.               /* default height for orbital   */
  89.                                        /*   view (km)                  */
  90. #define MIN_HEIGHT 10.                 /* minimum view height (km)     */
  91.  
  92. double view_height, eta, etap, facp;   /* declare global constants */
  93.  
  94. #define PI    3.141592653589793        /* define constants */
  95. #define PI2   (PI/2.)
  96. #define TWOPI (2.*PI)
  97. #define RAD   (PI/180.)
  98. #define EXPAND_SCALE_FACTOR 2.0        /* for box zoom out option */
  99.  
  100. char fontname[] = "topaz.font";        /* screen font name */
  101.  
  102. struct TextAttr mapfont = {            /* screen font */
  103.    (STRPTR) &fontname, 8, 0, 0
  104. };
  105.  
  106. struct NewScreen mapscreen = {
  107.    0, 0,
  108.    WWIDTH, WHEIGHT, DEPTH,
  109.    1, 0,
  110.    VMODE,
  111.    CUSTOMSCREEN,
  112.    &mapfont,
  113.    (UBYTE *) "Drawmap v. 4.0, by Bryan Brown",
  114.    NULL, NULL
  115. };
  116.  
  117. struct NewWindow mapWindow = {
  118.    0, 0,
  119.    WWIDTH, WHEIGHT,
  120.    0, 1,
  121.    IDCMPFLAGS,
  122.    WINFLAGS1 | WINFLAGS2,
  123.    NULL, NULL, NULL, NULL, NULL,
  124.    10, 10, WWIDTH, WHEIGHT,
  125.    CUSTOMSCREEN
  126. };
  127.  
  128. UWORD arrow_data[] = {                 /* mouse pointer = arrow  */
  129.    0x0000, 0x0000,
  130.  
  131.    0x8000, 0x0000,
  132.    0xc000, 0x0000,
  133.    0xe000, 0x0000,
  134.  
  135.    0xf000, 0x0000,
  136.  
  137.    0xe000, 0x0000,
  138.    0x2000, 0x0000,
  139.    0x0000, 0x0000,
  140.  
  141.    0x0000, 0x0000
  142. };
  143.  
  144. #define ARROW_X_OFFSET -1
  145. #define ARROW_Y_OFFSET  0
  146. #define ARROW_SIZE      sizeof(arrow_data)
  147.  
  148. UWORD cross_data[] = {                 /* mouse pointer = cross */
  149.    0x0000, 0x0000,
  150.  
  151.    0x0400, 0x0000,
  152.    0x0400, 0x0000,
  153.    0x0400, 0x0000,
  154.    0x0400, 0x0000,
  155.    0x0000, 0x0000,
  156.  
  157.    0xf1e0, 0x0000,
  158.  
  159.    0x0000, 0x0000,
  160.    0x0400, 0x0000,
  161.    0x0400, 0x0000,
  162.    0x0400, 0x0000,
  163.    0x0400, 0x0000,
  164.  
  165.    0x0000, 0x0000
  166. };
  167.  
  168. #define CROSS_X_OFFSET -6
  169. #define CROSS_Y_OFFSET -5
  170. #define CROSS_SIZE     (sizeof(cross_data))
  171.  
  172. UWORD waiter_data[] = {                /* mouse pointer = 'wait' */
  173.    0x0000, 0x0000,
  174.  
  175.    0x892e, 0x0000,
  176.    0xaaa4, 0x0000,
  177.    0xaba4, 0x0000,
  178.    0x52a4, 0x0000,
  179.  
  180.    0x0000, 0x0000
  181. };
  182.  
  183. #define WAITER_X_OFFSET -1
  184. #define WAITER_Y_OFFSET  0
  185. #define WAITER_SIZE      (sizeof(waiter_data))
  186.  
  187. UWORD transparent_data[] = {           /* mouse pointer = transparent */
  188.    0x0000, 0x0000,
  189.  
  190.    0x0000, 0x0000,
  191.    0x0000, 0x0000,
  192.    0x0000, 0x0000,
  193.  
  194.    0x0000, 0x0000
  195. };
  196.  
  197. #define TRANSPARENT_X_OFFSET 0
  198. #define TRANSPARENT_Y_OFFSET 0
  199. #define TRANSPARENT_SIZE     (sizeof(transparent_data))
  200.  
  201. #define MAX_DETAIL_LEVEL 5             /* maximum value of detail level */
  202.  
  203. int detail_level = MEDIUM;             /* drawing detail level */
  204.  
  205. struct Pt  {                           /* format for each point */
  206.    short code;
  207.    short lat;
  208.    short lam;
  209. };
  210.  
  211. struct Arc  {                          /* format for limits in */
  212.    short lat_min, lat_max;             /*   each segment       */
  213.    short lam_min, lam_max;
  214.    int first, last;
  215. };
  216.  
  217. typedef struct mapinfo {               /* format for general map info   */
  218.    char *mapname;                      /* map file name                 */
  219.    int numpts;                         /* number of points in map       */
  220.    int nsegs;                          /* number of segments in map     */
  221.    int first_seg;                      /* location in big segment array */
  222.    int plot;                           /* flag for plotting map         */
  223.    long color;                         /* color to use for plotting     */
  224.    struct Pt *pt;                      /* address of points buffer      */
  225.    struct Arc *seg;                    /* address of segment buffer     */
  226. }  MapInfo;
  227.  
  228. MapInfo map[] = {                     /* map information */
  229.    { "coast.pnt",   74967, 208,    0, TRUE, ORANGE, NULL, NULL },
  230.    { "country.pnt", 22359, 301,  208, TRUE, LT_RED, NULL, NULL },
  231.    { "state.pnt",    2259, 111,  509, TRUE, LT_RED, NULL, NULL },
  232.    { "island.pnt",  35171, 344,  620, TRUE, ORANGE, NULL, NULL },
  233.    { "lake.pnt",    15118, 103,  964, TRUE, DK_BL,  NULL, NULL },
  234.    { "river.pnt",   28194, 196, 1067, TRUE, LT_BL,  NULL, NULL }
  235. };
  236.  
  237. #define NUM_MAPS (sizeof(map)/sizeof(MapInfo))
  238.  
  239. #define NSEGS (208+301+111+344+103+196) /* number of segments */
  240.  
  241. short box_borderpts[] = {               /* border points for outline box */
  242.    0, 0,
  243.    1, 0,
  244.    1, 1,
  245.    0, 1,
  246.    0, 0
  247. };
  248.  
  249. struct Border box_border = {           /* border definition for box */
  250.    0, 0,
  251.    WHITE, BLACK, COMPLEMENT,
  252.    sizeof (box_borderpts) / (2*sizeof (short)),
  253.    &box_borderpts[0],
  254.    NULL
  255. };
  256.