home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 1001.dms / 1001.adf / WorldDataBank / WDB.c < prev    next >
C/C++ Source or Header  |  1989-09-24  |  15KB  |  567 lines

  1. /***************** Display WorldData Base ********************/
  2.  
  3. #include    <clib/macros.h>
  4. #include    <functions.h>
  5. #include    <intuition/intuition.h>
  6. #include    <libraries/dosextens.h>
  7. #include    <exec/memory.h>
  8.  
  9. #define    QSPAN    90*6000
  10. #define HSPAN    QSPAN*2
  11. #define WSPAN    QSPAN*4
  12. #define gg_ix   gg_addr->GadgetID
  13. #define False 0
  14.  
  15. #define    gidMAGS 1
  16. #define gidLATS    2
  17. #define gidLONS    3
  18. #define gidMAG    4
  19. #define gidLAT    5
  20. #define gidLON    6
  21. #define gidPLOT    7
  22. #define gidQUIT 8
  23. #define gidSTRCH 9
  24. #define PCount    1024
  25.  
  26.     struct IntuitionBase *IntuitionBase;
  27.     struct GfxBase    *GfxBase;
  28.     struct Screen    *s;
  29.     struct Window    *w,*Contr,*win;
  30.     struct RastPort *rp;
  31.     struct Gadget    *gg_addr;
  32.  
  33. typedef struct { short Code, Lat, Lon; } PNT ;
  34. #define PNTSiz    sizeof(PNT)
  35.  
  36.     PNT    *p;
  37.     double    zoom,atof(),stretch = 1.2;
  38.     long    Latitude, Longitude,
  39.             Lat,Lon,X_Scale, Y_Scale,
  40.             ymax,ymin,xmax,xmin,xspan,yspan;
  41.     ULONG    class;
  42.     short    xx,yy;
  43.     char    *infile;
  44.     UBYTE    title[50],UndoBuf[10];
  45.  
  46.     struct TextAttr ta =
  47.         { (STRPTR)"topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT };
  48.  
  49.     UBYTE 
  50.         LonSGgtSIBuff[10] = "   0'0",
  51.         LatSGgtSIBuff[10] = "   0'0",
  52.         MagSGgtSIBuff[10] =  " 1.00",
  53.         StrchGgtSIBuff[10] = " 1.20";
  54.  
  55.     SHORT 
  56.         CTable[] = { 0x0000,0x0ddd,0x0d00,0x00a0,0x0ff0,0x05f5,0x0aaf,0x033f },
  57.         BoolVectors[] = { 0,0, 35,0, 35,10, 0,10, 0,0 },
  58.         BorderVectors3[] = { 0,0, 45,0, 45,9, 0,9, 0,0 },
  59.         BorderVectors4[] = { 0,0, 58,0, 58,9, 0,9, 0,0 },
  60.         BorderVectors5[] = { 0,0, 66,0, 66,9, 0,9, 0,0 };
  61.  
  62.     struct Border 
  63.         BoolBorder = { -2,-1, 1,0,JAM1, 5, BoolVectors, NULL },
  64.         Border3 = { -2,-1, 3,0,JAM1, 5, BorderVectors3, NULL },
  65.         Border4 = { -2,-1, 3,0,JAM1, 5, BorderVectors4, NULL },
  66.         Border5 = { -2,-1, 3,0,JAM1, 5, BorderVectors5, NULL };
  67.  
  68.     struct IntuiText 
  69.         quitIT = { 3,2,JAM1,  2,1,&ta,(UBYTE *)"Quit" ,NULL },
  70.         loadIT = { 3,2,JAM1,  2,1,&ta,(UBYTE *)"Load" ,NULL },
  71.         titlIT = { 3,2,JAM1,  2,1,&ta,(UBYTE *)"Title",NULL },
  72.         specIT = { 3,2,JAM1,  2,1,&ta,(UBYTE *)"Specs",NULL },
  73.         IText1 = { 2,0,JAM2, -120,1, NULL,
  74.             (UBYTE *)"Horiz Stretch:", NULL },
  75.         IText2 = { 1,2,JAM2, 0,1, NULL, (UBYTE *)"Quit", NULL },
  76.         IText3 = { 1,2,JAM2, 0,1, NULL, (UBYTE *)"Plot", NULL },
  77.         IText4 = { 2,0,JAM2, -80,0, NULL, (UBYTE *)"Longitude", NULL },
  78.         IText5 = { 2,0,JAM2, 64,0, NULL, (UBYTE *)"Latitude", NULL },
  79.         IText6 = { 2,0,JAM2, -120,1, NULL,
  80.             (UBYTE *)"Magnification:", NULL },
  81.         IText7 = { 2,0,JAM2, -9,-9, NULL, 
  82.             (UBYTE *)"x0       x40      x80     x120", NULL };
  83.  
  84.     struct StringInfo 
  85.         StrchGgtSInfo = { StrchGgtSIBuff, UndoBuf, 0, 8, 0,
  86.             0,0,0,0,0, 0, 0, NULL },
  87.         LonSGgtSInfo = { LonSGgtSIBuff, UndoBuf, 0, 8, 0,
  88.             0,0,0,0,0, 0, 0, NULL },
  89.         LatSGgtSInfo = { LatSGgtSIBuff, UndoBuf, 0, 7, 0,
  90.             0,0,0,0,0, 0, 0, NULL },
  91.         MagSGgtSInfo = { MagSGgtSIBuff, UndoBuf, 0, 6, 0,
  92.             0,0,0,0,0, 0, 0, NULL };
  93.  
  94.     struct PropInfo 
  95.         LonGgtSInfo = { AUTOKNOB+FREEHORIZ, 32767,-1, 1820,1456, },
  96.         MagGgtSInfo = { FREEHORIZ, 4400,0, 545,-1, },
  97.         LatGgtSInfo = { AUTOKNOB+FREEVERT, -1,32767, 1456,3640, };
  98.  
  99.     USHORT ImageData2[] = { 0x0800,0x1C00,0x3E00,0x7F00,0xFF80 };
  100.  
  101.     struct Image 
  102.         Image1 = { 155,0, 6,8, 1,       NULL, 0x0000,0x0000, NULL },
  103.         Image2 = {  13,1, 9,5, 1, ImageData2, 0x0002,0x0000, NULL },
  104.         Image3 = {   0,33,6,8, 1,       NULL, 0x0000,0x0000, NULL };
  105.  
  106.     struct Gadget 
  107.         StrchGgt = { NULL, 176,65, 45,8, NULL, RELVERIFY,
  108.             STRGADGET, (APTR)&Border5, NULL, &IText1, NULL,
  109.             (APTR)&StrchGgtSInfo, gidSTRCH, NULL },
  110.         QuitGgt = { &StrchGgt, 100,122, 32,9, NULL, RELVERIFY,
  111.             BOOLGADGET, (APTR)&BoolBorder, NULL, &IText2, NULL,
  112.             NULL, gidQUIT, NULL },
  113.         PlotGgt = { &QuitGgt, 60,122, 32,9, NULL, RELVERIFY,
  114.             BOOLGADGET, (APTR)&BoolBorder, NULL, &IText3, NULL,
  115.             NULL, gidPLOT, NULL },
  116.         LonSGgt = { &PlotGgt, 176,28, 66,8, NULL, RELVERIFY+STRINGRIGHT,
  117.             STRGADGET, (APTR)&Border5, NULL, &IText4, NULL,
  118.             (APTR)&LonSGgtSInfo, gidLONS, NULL },
  119.         LatSGgt = { &LonSGgt, 42,15, 56,8, NULL, RELVERIFY+STRINGRIGHT,
  120.             STRGADGET, (APTR)&Border4, NULL, &IText5, NULL,
  121.             (APTR)&LatSGgtSInfo, gidLATS, NULL },
  122.         LonGgt = { &LatSGgt, 60,43, 180,12, NULL, RELVERIFY+GADGIMMEDIATE,
  123.             PROPGADGET, (APTR)&Image1, NULL, NULL, NULL,
  124.             (APTR)&LonGgtSInfo, gidLON, NULL },
  125.         MagSGgt = { &LonGgt, 176,81, 45,8, NULL, RELVERIFY+STRINGRIGHT,
  126.             STRGADGET, (APTR)&Border5, NULL, &IText6, NULL,
  127.             (APTR)&MagSGgtSInfo, gidMAGS, NULL },
  128.         MagGgt = { &MagSGgt, 19,106, 220,11, GADGIMAGE, 
  129.             RELVERIFY+GADGIMMEDIATE,
  130.             PROPGADGET, (APTR)&Image2, NULL, &IText7, NULL,
  131.             (APTR)&MagGgtSInfo, gidMAG, NULL },
  132.         LatGgt = { &MagGgt, 18,14, 14,72, NULL, RELVERIFY+GADGIMMEDIATE,
  133.             PROPGADGET, (APTR)&Image3, NULL, NULL, NULL,
  134.             (APTR)&LatGgtSInfo, gidLAT, NULL };
  135.  
  136.  
  137.     long colr[] = { 3, 3, 2, 0, 4, 5, 6, 7 };    /* pen = line type DIV 1000 */
  138.  
  139.     #define MenuFlags  ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP
  140.  
  141.     struct MenuItem
  142.             quitMI = {    NULL,0,30,130,11,MenuFlags,NULL,
  143.                         (APTR)&quitIT,NULL,(BYTE)'Q',NULL },
  144.             loadMI = { &quitMI,0,20,130,11,MenuFlags,NULL,
  145.                         (APTR)&loadIT,NULL,(BYTE)'L',NULL },
  146.             titlMI = { &loadMI,0,10,130,11,MenuFlags,NULL,
  147.                         (APTR)&titlIT,NULL,(BYTE)'T',NULL },
  148.             specMI = { &titlMI,0, 0,130,11,MenuFlags,NULL,
  149.                         (APTR)&specIT,NULL,(BYTE)'S',NULL };
  150.  
  151.     struct Menu m = { NULL,0,0,64,11,MENUENABLED,(BYTE *)"Control",&specMI };
  152.  
  153.  
  154. /************** convert Minutes to "ddd'mm" *************/
  155. void MinToStr(str,min)
  156.     char    *str;
  157.     long    min;
  158. {
  159.     short    deg;
  160.  
  161.     deg = min / 60;
  162.     min = min - deg * 60;
  163.     if(min < 0)
  164.         min = -min;
  165.     sprintf(str,"%d'%d",deg,min);
  166. }
  167. /************* Convert "ddd'mm" to mins ***********/
  168. long    DegToMin(s)
  169.     char    *s;
  170. {
  171.     short    deg,min;
  172.     char    str[10],*strchr(),*cp;
  173.  
  174.     strcpy(str,s);
  175.     if(cp = strchr(str,'\047'))
  176.       { *cp = '\0';
  177.         min = atoi(++cp);
  178.       }
  179.     else
  180.         min = 0;
  181.     if((deg = atoi(str)) < 0)
  182.         min = -min;
  183.     return(deg * 60 + min);
  184. }
  185. /********************* Interpret Window Specs **********************/
  186. void SetSpecs()
  187. {
  188.  
  189.     Longitude = (Lon = DegToMin(LonSGgtSIBuff)) * 100;
  190.     Latitude  = (Lat = DegToMin(LatSGgtSIBuff)) * 100;
  191.     zoom      = atof(MagSGgtSIBuff);
  192.         /* 120/100 is correction for vertical stretch of 1080 Monitor    */
  193.     X_Scale   = zoom * 100.0 * stretch * 320.0 / 10800.0;    
  194.     Y_Scale   = zoom * 100.0 * 200.0 /  5400.0;    
  195.     ymax = QSPAN/zoom;
  196.     ymin = -ymax;
  197.     xmax = HSPAN / (zoom * stretch);
  198.     xmin = -xmax;
  199.     xspan = xmax - xmin;
  200.     yspan = ymax - ymin;
  201. }
  202.  
  203. /*******************  Initialize Graphics ****************/
  204. struct NewScreen ns = {
  205.     0,0,640,400,3,2,1,HIRES|LACE,CUSTOMSCREEN,&ta,
  206.     NULL,NULL,NULL
  207. };
  208.  
  209. struct NewWindow nw = {
  210.     0,0,640,400,-1,-1,NULL,NULL,
  211.     NULL,NULL,NULL,NULL,NULL,0,0,0,0,CUSTOMSCREEN
  212. };
  213.  
  214. void init_gfx()
  215. {
  216.     void quit();
  217.  
  218.     IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",0L);
  219.     GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0L);
  220.  
  221.     if (!(s = OpenScreen(&ns)))
  222.         quit();
  223.     LoadRGB4(&s->ViewPort, &CTable, 8L);
  224.     nw.Screen = s;
  225.     nw.IDCMPFlags = MENUPICK | MOUSEBUTTONS;
  226.     nw.Title = (UBYTE *)"Micro WorldDataBase-II  Version 2.0";
  227.  
  228.     if (!(w = OpenWindow(&nw)))
  229.         quit();
  230.     SetMenuStrip(w,&m);
  231.     rp = w->RPort;
  232. }
  233.  
  234. /************************** clean up **********************/
  235. void quit()
  236. {
  237.     if (w) {
  238.         ClearMenuStrip(w);
  239.         CloseWindow(w);
  240.     }
  241.     if(Contr) CloseWindow(Contr);
  242.     FreeMem(p,PCount*PNTSiz);
  243.     if (s) CloseScreen(s);
  244.     CloseLibrary(GfxBase);
  245.     CloseLibrary(IntuitionBase);
  246.     exit(0);
  247. }
  248.  
  249. /*********************** Open Window ************************/
  250. void OpenContrWindow()
  251. {
  252.     nw.Flags = SMART_REFRESH | ACTIVATE | WINDOWDRAG | WINDOWDEPTH;
  253.     nw.IDCMPFlags = GADGETUP | VANILLAKEY;
  254.     nw.TopEdge = 200;
  255.     nw.LeftEdge = 10;
  256.     nw.Width = 256;
  257.     nw.Height = 138;
  258.     nw.FirstGadget = &LatGgt;
  259.     nw.DetailPen = 3;
  260.     nw.Title = "Specs Control";
  261.     Contr = (struct Window *)OpenWindow(&nw);
  262. }
  263.  
  264. /******************** nitty gritty ***************************/
  265. void load(fn)
  266.     char    *fn;
  267. {
  268.     register long x, y, LonPrv,LatPrv;
  269.     register PNT    *pp;
  270.     PNT    *pend;
  271.     struct FileHandle    *fh,*Open();
  272.     long    xx,yy,z,xprv=0,yprv;
  273.     short    is_out=0,was_out=0,
  274.             n,ColorNum,SegNum,SegPrv,newseg;
  275.  
  276.     LonPrv = LatPrv = 0;
  277.     if(fh = Open(fn,MODE_OLDFILE))
  278.       {
  279.         while (n = (short) Read(fh, p, (long)PCount*PNTSiz))
  280.           {
  281.             for (pp = p,pend = p+n/6; pp < pend; pp++)
  282.             {                    /* do displacement    */
  283.                 x = pp->Lon*100 - Longitude;
  284.                 y = pp->Lat*100 - Latitude;
  285.                                 /* wrap around for East-West    */
  286.                 if (x < -HSPAN)
  287.                     x += WSPAN;
  288.                 else if (x > HSPAN)
  289.                     x -= WSPAN;
  290.  
  291.                 if (pp->Code > (int)5)
  292.                   {    
  293.                       SetAPen(rp, colr[ColorNum = (pp->Code / 1000)]);
  294.                     SegNum = pp->Code - 1000 * ColorNum;
  295.                       newseg = 1;
  296.                   }
  297.                             /* ignore pts outside magnified area    */
  298.                 if((x < xmin || x > xmax || y < ymin || y > ymax))
  299.                   {    
  300.                       is_out = 1;
  301.                     if(was_out)                /* out to out    */
  302.                       {
  303.                         LonPrv = x;
  304.                         LatPrv = y;
  305.                         SegPrv = SegNum;
  306.                           goto go_on;
  307.                       }
  308.                                               /* in to out    */
  309.                     xx = 320 + (LonPrv * X_Scale)/10000;
  310.                     yy = 200 - (LatPrv * Y_Scale)/10000;
  311.                     Move(rp, xx, yy);
  312.                   }
  313.                 else
  314.                   {                            /* out to in    */
  315.                     is_out = 0;
  316.                     if(was_out)
  317.                       {
  318.                         xx = 320 + (LonPrv * X_Scale)/10000;
  319.                         yy = 200 - (LatPrv * Y_Scale)/10000;
  320.                         Move(rp, xx, yy);
  321.                       }
  322.                                               /* in to in    */
  323.                   }
  324.                 LonPrv = x;
  325.                 LatPrv = y;
  326.  
  327.                         /* scale pts w/in area to interlace screen    */
  328.                 x = 320 + (x * X_Scale)/10000;
  329.                 y = 200 - (y * Y_Scale)/10000;
  330.                                 /* ignore duplicates    */
  331.                 if (newseg  == 0 && x == xprv && y == yprv)
  332.                     continue;
  333.                                 /* if new segment, move to place    */
  334.                 if (newseg == 1 || ABS(z - pp->Lon) > 10800)
  335.                   {    
  336.                     Move(rp, x, y);
  337.                     WritePixel(rp, x, y);
  338.                   }
  339.                 else            /* draw next point of seg    */
  340.                     Draw(rp, x, y);
  341.                 SegPrv = SegNum;
  342.                 xprv = x;
  343.                 yprv = y;
  344.                 z = pp->Lon;
  345. go_on:
  346.                 was_out = is_out;
  347.                 newseg = 0;
  348.             }
  349.           }
  350.         Close(fh);
  351.       }
  352. }
  353. /***************************** main routine ********************************/
  354. main(argc, argv)
  355.     int argc;
  356.     char *argv[];
  357. {
  358.     void load();
  359.     struct IntuiMessage *im;
  360.     long seetitle = FALSE,
  361.         MsgBits,MainMsgBit, ContrMsgBit;
  362.     struct FileLock    *lock,*Lock();
  363.     char    *infile,*PickFile();
  364.     short    NewLon,NewLat,deflt = 1;
  365.     USHORT newCenter = 0,code;
  366.  
  367.     if (argv[1][1] == '?')
  368.       {
  369.         Write(Output(), "Usage: WDB [data_file]\n", 14L);
  370.         exit(10);
  371.       }
  372.  
  373.     if (argc == 2)
  374.       {    if ((lock = Lock(argv[1], ACCESS_READ)) == NULL)
  375.             goto nofind;
  376.         UnLock(lock);
  377.         infile = argv[1];
  378.         deflt = 0;
  379.       }
  380.     else if ((infile = PickFile(1.0)) == NULL)
  381. nofind:
  382.       { Write(Output(), "Cannot find data file\n",21L);
  383.           exit(10);
  384.       }
  385.     if ((p = (USHORT *)AllocMem(code = PCount*PNTSiz,MEMF_FAST)) == NULL)
  386.     {
  387.         Write(Output(), "Insufficient memory for buffer\n", 31L);
  388.         exit(0);
  389.     }
  390.     init_gfx();
  391.     OpenContrWindow();
  392.     ModifyProp(&MagGgt,Contr,NULL,MagGgtSInfo.Flags,
  393.      (short)(0xffff/120.0 - 1.0), MagGgtSInfo.VertPot,
  394.      MagGgtSInfo.HorizBody, MagGgtSInfo.VertBody);
  395.     MainMsgBit = 1 << w->UserPort->mp_SigBit;
  396.     ContrMsgBit = 1 << Contr->UserPort->mp_SigBit;
  397.     FOREVER
  398.       { MsgBits = Wait(MainMsgBit | ContrMsgBit);
  399.           if(MsgBits & MainMsgBit)
  400.             win = w;
  401.         else if (MsgBits & ContrMsgBit)
  402.             win = Contr;
  403.         while (im = (struct IntuiMessage *) GetMsg(win->UserPort))
  404.           { code = im->Code;
  405.             class = im->Class;
  406.             gg_addr = im->IAddress;
  407.             xx = im->MouseX;
  408.             yy = im->MouseY;
  409.             ReplyMsg(im);
  410.             switch(class)
  411.               {    case GADGETUP:
  412.                       switch(gg_ix)
  413.                       {    case gidPLOT:
  414. draw_map:                    SetSpecs();                 /* redo parameters    */
  415.                             WindowToBack(Contr);
  416.                             SetAPen(rp,0);     /* clear screen    */
  417.                             RectFill(rp,0,0,639,399);
  418.                             SetAPen(rp,1);
  419.                             if(newCenter)
  420.                               {    Lon = NewLon;
  421.                                   Lat = NewLat;
  422.                                 newCenter = 0;
  423.                               }
  424.                             load(infile);         /* redisplay map    */
  425.                             ActivateWindow(Contr);
  426.                             WindowToFront(Contr);
  427.                               break;
  428.                         case gidQUIT:
  429.                             goto exit;
  430.                         case gidLAT:
  431.                             Lat =
  432.                              5400L - (((LatGgtSInfo.VertPot+1) * 10800L) >> 16);
  433.                             MinToStr(LatSGgtSIBuff,Lat);
  434.                             RefreshGadgets(&LatSGgt,Contr,NULL,1);
  435.                             break;
  436.                         case gidLON:
  437.                             Lon =
  438.                              (((LonGgtSInfo.HorizPot+1) * 21600L) >> 16)-10800L;
  439.                             MinToStr(LonSGgtSIBuff,Lon);
  440.                             RefreshGadgets(&LonSGgt,Contr,NULL,1);
  441.                             break;
  442.                           case gidMAG:
  443.                             zoom = ((MagGgtSInfo.HorizPot+1) * 120.0) / 0xffff;
  444. new_zoom:                    if(zoom < .86) 
  445.                                 zoom = .86;
  446.                             if(deflt)
  447.                                 infile = PickFile(zoom);
  448.                             Move(Contr->RPort,148,128);
  449.                             Text(Contr->RPort,infile,strlen(infile));
  450.                             sprintf(MagSGgtSIBuff,"%5.2f",zoom);
  451.                             RefreshGadgets(&MagSGgt,Contr,NULL,1);
  452.                               break;
  453.                         case gidLONS:
  454.                             Lon = DegToMin(LonSGgtSIBuff);
  455.                             ModifyProp(&LonGgt,Contr,NULL,LonGgtSInfo.Flags,
  456.                              (short)(((Lon + 10800L) << 16) / 21600 - 1),
  457.                              LonGgtSInfo.VertPot,
  458.                              LonGgtSInfo.HorizBody,
  459.                              LonGgtSInfo.VertBody);
  460.                             break;
  461.                         case gidLATS:
  462.                             Lat = DegToMin(LatSGgtSIBuff);
  463.                             ModifyProp(&LatGgt,Contr,NULL,LatGgtSInfo.Flags,
  464.                              LatGgtSInfo.HorizPot,
  465.                              (short)(1 - ((Lat + 5400L) << 16) / 21600L),
  466.                              LatGgtSInfo.HorizBody,
  467.                              LatGgtSInfo.VertBody);
  468.                             break;
  469.                         case gidMAGS:
  470.                             zoom = atof(MagSGgtSIBuff);
  471.                             ModifyProp(&MagGgt,Contr,NULL,MagGgtSInfo.Flags,
  472.                              (short)((zoom * 0xffff)/120.0 - 1.0),
  473.                              MagGgtSInfo.VertPot,
  474.                              MagGgtSInfo.HorizBody,
  475.                              MagGgtSInfo.VertBody);
  476.                             goto new_zoom;
  477.                         case gidSTRCH:
  478.                             stretch = atof(StrchGgtSIBuff);
  479.                             break;
  480.                       }
  481.                     break;
  482.                 case VANILLAKEY:
  483.                     switch(code)
  484.                       {
  485.                         case 'c':
  486.                             ActivateGadget(&MagSGgt,Contr,NULL);
  487.                             break;
  488.                         case 'o':
  489.                             goto draw_map;
  490.                         case 'q':
  491.                             goto exit;
  492.                         default:
  493.                             break;
  494.                       }
  495.                     break;
  496.                 case MENUPICK:
  497.                     switch (ITEMNUM(code))
  498.                       {    case 0:                     /* new specs    */
  499.                             WindowToFront(Contr);
  500.                             break;
  501.                         case 1:
  502.                             seetitle ^= TRUE;
  503.                             ShowTitle(s, seetitle);
  504.                             break;
  505.                         case 2:
  506.                             /*
  507.                             dbug = dbug ? 0 : 1;
  508.                             */
  509.                             break;
  510.                         case 3:
  511. exit:                        quit();
  512.                             break;
  513.                       }
  514.                 case MOUSEBUTTONS:
  515.                     if (zoom && code == SELECTUP)
  516.                       { 
  517.                         NewLon = Lon + 
  518.                          ((xx - 320.0) * 10800.0) / (320.0 * zoom * stretch);
  519.                         NewLat = Lat +
  520.                          ((200.0 - yy) * 5400.0) / (200.0 * zoom);
  521.                         newCenter = 1;
  522.                         MinToStr(LonSGgtSIBuff,NewLon); 
  523.                         MinToStr(LatSGgtSIBuff,NewLat); 
  524.                         RefreshGadgets(&LatSGgt,Contr,NULL,2);
  525.                         ModifyProp(&LonGgt,Contr,NULL,LonGgtSInfo.Flags,
  526.                          (short)(((NewLon + 10800L) << 16) / 21600 - 1),
  527.                          LonGgtSInfo.VertPot,
  528.                          LonGgtSInfo.HorizBody,LonGgtSInfo.VertBody);
  529.                         ModifyProp(&LatGgt,Contr,NULL,LatGgtSInfo.Flags,
  530.                          LatGgtSInfo.HorizPot,
  531.                          (short)(1 - ((NewLat + 5400L) << 16) / 10800),
  532.                          LatGgtSInfo.HorizBody,LatGgtSInfo.VertBody);
  533.                       }
  534.                     break;
  535.               }
  536.           }
  537.       }
  538. }
  539.  
  540. /********************************************/
  541. char    *PickFile(mag)
  542.     double    mag;
  543. {
  544.     static double    maglvl[] = { 0.0, 36.0, 12.0, 6.0, 2.0 };
  545.     static char        filename[12];
  546.     struct FileLock    *lock,*Lock();
  547.     short    level;
  548.  
  549. for(level = 1; level < 5; level++)
  550.   {
  551.     if(mag > maglvl[level])
  552.         break;
  553.   }
  554.  
  555. for( ; level < 6; level++)
  556.   {
  557.     sprintf(filename,"wdb.%d.all",level);
  558.     if (lock = Lock(filename, ACCESS_READ))
  559.       { UnLock(lock);
  560.         return(filename);
  561.       }
  562.   }
  563. return(NULL);
  564. }
  565.  
  566. _wb_parse() {}
  567.