home *** CD-ROM | disk | FTP | other *** search
- /*=========================================================================
- Star7.c -- This module displays star data in a window, it uses PrintItext
- routine to do all of the writing to the screen. The routine has it's own
- IDCMP loop that waits for the user to click the CONTINUE gadget.
-
- Credits for Star Chart:
- Robert L. Hill of the Orange County, CA. Amiga Friends User Group
- wrote the original version of StarChart in AmigaBasic
- The star data and many of the main functions of this
- version are derived from that program.
-
- Ray R. Larson wrote the c version 1.0 of StarChart, 'intuitionizing'
- and enhancing the speed and functions of the original.
-
- Copyright (c) 1986 by Ray R. Larson
-
- This program may be freely distributed and copied, but may not be sold
- without the permission of the author. If you modify or enhance it,
- please include the above credits (and please send me a copy!).
-
- Ray R. Larson
- 6425 Central Ave. #304
- El Cerrito, CA 94530
-
- BitNet LARSON@UCBCMSA
- =========================================================================*/
- /*------------Header file for all of the standard stuff----*/
- /*-------------plus definitions of global structures-------*/
- #include "star.h"
-
- /*------------ External function declarations ------------*/
-
- extern struct Window *OpenWindow();
- extern struct IntuiMessage *GetMsg();
-
- /*------------------ extern vars ------------------*/
-
- extern struct star_rec StarTable[];
- extern struct Coord coords[];
- extern char *Greek[];
- extern struct cons_rec Constel[];
- extern struct ParamStruct Parms;
- extern FLOAT P1, P12;
-
- /*------------------- global variables -------------------*/
-
- extern struct Screen *scr; /* pointer to the custom screen - RRL */
-
- /**********************************************************************
- * Text attribute structures used in rendering IntuiTexts
- **********************************************************************/
- extern struct TextAttr TxtAt_Plain,TxtAt_BIU,TxtAt_BU,TxtAt_BI,TxtAt_B,
- TxtAt_IU,TxtAt_I,TxtAt_U;
-
- /**********************************************************************
- * IntuiTexts for the ContinueG gadget.
- **********************************************************************/
-
- struct IntuiText ContinueG_Text_0 = {
- 15, 2, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 0, 0, /* LeftEdge, TopEdge */
- &TxtAt_B, /* ITextFont Pointer */
- /* The IText */
- (UBYTE *)" CONTINUE ",
- NULL
- };
-
-
-
- /**********************************************************************
- * Gadget Structure definition for the ContinueG gadget.
- **********************************************************************/
- #define CONTINUEGGAD 1
-
- struct Gadget ContinueG = {
- NULL, /* NextGadget pointer */
- -97,-8, /* LeftEdge, TopEdge */
- 80, 8, /* Width, Height */
- /* Gadget Flags */
- GADGHCOMP | GRELBOTTOM | GRELRIGHT ,
- /* Activation Flags */
- RELVERIFY | GADGIMMEDIATE | BOTTOMBORDER | ENDGADGET,
- /* GadgetType */
- BOOLGADGET,
- NULL, /* GadgetRender */
- NULL, /* SelectRender */
- &ContinueG_Text_0, /* GadgetText */
- 0x0, /* MutualExclude */
- NULL, /* SpecialInfo */
- CONTINUEGGAD, /* GadgetID */
- 0x1 /* UserData Pointer */
- };
-
-
-
- /**********************************************************************
- * IntuiTexts for the Display requester
- **********************************************************************/
- UBYTE comment3_text[60];
- struct IntuiText disp_comment3 = {
- 2, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 91, /* LeftEdge, TopEdge */
- &TxtAt_Plain, /* ITextFont Pointer */
- /* The IText */
- comment3_text,
- NULL
- };
-
- UBYTE comment2_text[60];
- struct IntuiText disp_comment2 = {
- 2, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 81, /* LeftEdge, TopEdge */
- &TxtAt_Plain, /* ITextFont Pointer */
- /* The IText */
- comment2_text,
- &disp_comment3
- };
-
- UBYTE comment_text[60];
- struct IntuiText disp_comment = {
- 2, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 71, /* LeftEdge, TopEdge */
- &TxtAt_Plain, /* ITextFont Pointer */
- /* The IText */
- comment_text,
- &disp_comment2
- };
-
-
- UBYTE distance_text[50];
- struct IntuiText disp_distance = {
- 0, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 60, /* LeftEdge, TopEdge */
- &TxtAt_I, /* ITextFont Pointer */
- /* The IText */
- distance_text,
- &disp_comment /* NextText */
- };
-
- UBYTE magnitude_text[50];
- struct IntuiText disp_magnitude = {
- 0, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 51, /* LeftEdge, TopEdge */
- &TxtAt_I, /* ITextFont Pointer */
- /* The IText */
- magnitude_text,
- &disp_distance /* NextText */
- };
-
-
- UBYTE declination_text[50];
- struct IntuiText disp_declination = {
- 0, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 41, /* LeftEdge, TopEdge */
- &TxtAt_I, /* ITextFont Pointer */
- /* The IText */
- declination_text,
- &disp_magnitude /* NextText */
- };
-
-
- UBYTE RA_text[50];
- struct IntuiText disp_RA = {
- 0, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 32, /* LeftEdge, TopEdge */
- &TxtAt_I, /* ITextFont Pointer */
- /* The IText */
- RA_text,
- &disp_declination /* NextText */
- };
-
-
- UBYTE constmeaning_text[50];
- struct IntuiText disp_consmeaning = {
- 2, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 22, /* LeftEdge, TopEdge */
- &TxtAt_Plain, /* ITextFont Pointer */
- /* The IText */
- constmeaning_text,
- &disp_RA /* NextText */
- };
-
-
- UBYTE connames_text[50];
- struct IntuiText disp_greekcons = {
- 2, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 12, /* LeftEdge, TopEdge */
- &TxtAt_Plain, /* ITextFont Pointer */
- /* The IText */
- connames_text,
- &disp_consmeaning /* NextText */
- };
-
-
- UBYTE starname_text[50];
- struct IntuiText disp_starname= {
- 11, 1, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 14, 3, /* LeftEdge, TopEdge */
- &TxtAt_BU, /* ITextFont Pointer */
- /* The IText */
- starname_text,
- &disp_greekcons /* NextText */
- };
-
-
-
- /*------------ Display Window Definition ------------*/
-
-
- /* new window structure */
- struct NewWindow dispNW = {
- 0, 0, 400, 125, 0, 1,
-
- /* IDCMP Flags */
-
- GADGETDOWN
- | NEWSIZE
- | GADGETUP,
-
- /* Flags */
- WINDOWDEPTH
- | WINDOWSIZING
- | WINDOWDRAG
- | ACTIVATE,
-
- &ContinueG, /* First gadget */
- NULL, /* Checkmark */
- (UBYTE *) "Star Information: ", /* Window title */
- NULL, /* custom screen -if it exists*/
- NULL, /* Not a super bitmap window */
- 150, 31, 400, 125, /* Not used, but set up anyway */
- WBENCHSCREEN
- };
-
- /*=========================================================================
- DisplayInfo - star data display routine of the StarChart program.
- ========================================================================*/
- DisplayInfo(list, numstars, defaultHL, shortdisp)
- SHORT list[];
- SHORT numstars, defaultHL, shortdisp;
- {
- /*---------------- local vars ---------------*/
- struct IntuiMessage *mes; /* Message pointer */
- ULONG class; /* Message class */
- USHORT code; /* Message code */
- struct Gadget *gad; /* IAddress from Intuimessage */
- struct Window *dispwin;
- struct RastPort *disprp;
- BOOL go = TRUE;
- SHORT i, starnum;
- FLOAT xRad,yRad,Xpos,Ypos;
- SHORT yeardif;
- struct star_rec *s;
- UBYTE workstr[100], *workp, *index(), *rindex();
-
- /* Set window pointer to the custom screen, if needed */
-
- if (scr != NULL)
- { dispNW.Screen = scr ;
- dispNW.Type = CUSTOMSCREEN;
- }
-
- /*----------- open window ----------*/
- if ((dispwin = OpenWindow(&dispNW)) == NULL) {
- DisplayBeep();
- return(0);
- }
-
- /* ------------- Initialize the display text -------------*/
-
- disprp = dispwin->RPort;
- yeardif = Parms.Year - 1950;
-
- /* --------------- main loop -----------------*/
- for (i=0; i < numstars; i++)
- {
- /* get a pointer to the star record to be displayed */
- s = &StarTable[list[i]];
-
- /* skip the star if the display flags indicate that the user */
- /* has requested major star displays only, and the star is */
- /* not a major star. */
- if ((shortdisp & 4) && (s->GreekNum == 0)) continue;
- if ((shortdisp & 1))
- HighLightStar(list[i],3,8);
-
-
- /* clear the window to white */
- SetAPen(disprp,1L);
- RectFill(disprp,4L,10L,
- (LONG)(dispwin->Width - 4),(LONG)(dispwin->Height - 10));
-
- if (yeardif) {
- /* convert right Asc. and declination of star to radians */
- xRad = s->Ra * P12;
- yRad = s->Dc * P1;
-
-
- /* correct for year - uses mathffp routines*/
- Xpos = s->Ra +
- (3.07 + 1.34 * (FLOAT)sin((DOUBLE)xRad) * (FLOAT)tan((DOUBLE)xRad))
- * (FLOAT)yeardif / 3600.0;
-
-
- Ypos = s->Dc + 20 * (FLOAT)cos((DOUBLE)yRad) * (FLOAT)yeardif / 3600.0;
- }
- else { /* year is 1950 - basis for the star table */
- Xpos = s->Ra;
- Ypos = s->Dc;
- }
-
- /* put the infomation into the intuitext buffers */
- if (coords[list[i]].x != 0L) sprintf(comment3_text," ");
- else sprintf(comment3_text,"Not Currently Visible");
-
-
- strcpy(workstr,s->Comment);
- workp = rindex(workstr,'-');
-
- if (workp)
- { workp--;
- if (*workp == ' ')
- {
- *workp = '\0';
- workp++;
- sprintf(comment_text,"Comments: %s",workstr);
- sprintf(comment2_text," %s",workp);
- }
- else if (strlen(s->Comment) < 39)
- {sprintf(comment_text,"Comments: %s",s->Comment);
- comment2_text[0] = '\0';
- }
- else
- {
- sprintf(comment_text,"Comments:");
- sprintf(comment2_text,"%s",s->Comment);
- }
- }
- else if (strlen(s->Comment) < 39)
- {sprintf(comment_text,"Comments: %s",s->Comment);
- comment2_text[0] = '\0';
- }
- else
- {
- sprintf(comment_text,"Comments:");
- sprintf(comment2_text,"%s",s->Comment);
- }
-
-
- if (s->Dist > 0.0)
- sprintf(distance_text," Distance: %ld Light Years",
- (LONG)(s->Dist * 1000.0));
- else
- sprintf(distance_text, " Distance: not available.");
- sprintf(magnitude_text, " Magnitude: %10.2f",s->Mag);
- sprintf(declination_text," Declination: %10.2f",s->Dc);
- sprintf(RA_text, " Right Ascension: %10.2f",s->Ra);
-
- if(s->GreekNum == 0)
- { sprintf(constmeaning_text," - known as the %s",
- Constel[s->ConsNum].ConsMean);
- sprintf(connames_text,"Located in the constellation %s",
- Constel[s->ConsNum].ConsName);
- }
- else
- { strcpy(workstr,Constel[s->ConsNum].ConsMean);
- if (( workp = index(workstr,'-')) == NULL)
- { sprintf(constmeaning_text,"");
- sprintf(connames_text,"%s %s - The %s",
- Greek[s->GreekNum],Constel[s->ConsNum].ConsName,
- Constel[s->ConsNum].ConsMean);
- }
- else
- { sprintf(constmeaning_text,workp);
- *workp = '\0';
- sprintf(connames_text,"%s %s - The %s",
- Greek[s->GreekNum],Constel[s->ConsNum].ConsName,
- workstr);
- }
- }
- sprintf(starname_text," %s ",s->StarName);
-
- PrintIText(disprp,&disp_starname,2L,10L);
- RefreshWindowFrame(dispwin);
- RefreshGadgets(&ContinueG,dispwin,NULL);
-
- go = TRUE;
-
- while(go)
- {
- if ((mes = GetMsg(dispwin->UserPort)) == NULL)
- {
- Wait(1L << dispwin->UserPort->mp_SigBit);
- continue;
- }
-
- class = mes->Class;
- code = mes->Code;
- gad = (struct Gadget *)mes->IAddress;
- ReplyMsg(mes);
-
- if ((class == GADGETUP) && (gad->GadgetID == CONTINUEGGAD))
- go = FALSE;
-
- if (class == NEWSIZE) /* user resized the window, so redraw stuff */
- {
- /* clear the window to white */
- SetAPen(disprp,1L);
- RectFill(disprp,4L,10L,
- (LONG)(dispwin->Width - 4),(LONG)(dispwin->Height - 10));
- PrintIText(disprp,&disp_starname,2L,10L);
- RefreshWindowFrame(dispwin);
- RefreshGadgets(&ContinueG,dispwin,NULL);
- }
-
- } /* end of while loop */
-
- if ((shortdisp & 1))
- HighLightStar(list[i],defaultHL,8);
-
- } /* end of for loop */
-
- CloseWindow(dispwin);
-
- }/* end of displayinfo */
-
-