home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 1 / FFMCD01.bin / bbs / libdisks / d700t799 / disk719.lha / DrawMap / source.lha / source / drawmap.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-20  |  9.1 KB  |  288 lines

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