/****************************************************************\
 *
 *--------------------------------------------------------------
 *
 *  Name:ClkCreate()
 *
 *  Purpose:Intialize a newly created client window
 *
 *
 *
 *  Usage:
 *
 *  Method:
 *          -
 *
 *          -
 *          -
 *
 *          -
 *          -
 *
 *  Returns:
 *          1 - if sucessful execution completed
 *          0 - if error
\****************************************************************/
VOID ClkCreate ( HWND hwnd )
{
    LONG cxScreen , cyScreen;  /* screen dimensions */
    LONG xLeft , yBottom ;      /* frame window location */
    ULONG cbBuf;
    LONG cyHeight;
    LONG cxWidth;

    hwndClient = hwnd;

    WinLoadString(hab, NULLHANDLE, IDS_TITLE,  0, (PSZ)szTitle   );
    WinLoadString(hab, NULLHANDLE, IDS_HELPTITLE, 256, (PSZ)szHelpTitle);
    GetCountryDependent();
    /* we are called before the global hwndFrame is valid */
    hwndFrame = WinQueryWindow ( hwnd , QW_PARENT) ;
    hwndTitleBar = WinWindowFromID ( hwndFrame , FID_TITLEBAR ) ;
    hwndSysMenu = WinWindowFromID ( hwndFrame , FID_SYSMENU ) ;
    hwndMinMax = WinWindowFromID ( hwndFrame , FID_MINMAX ) ;

    /* load our menus */
    hwndMenu = WinLoadMenu (hwndFrame, NULLHANDLE, IDR_MAIN);
    /* determine screen dimensions */
    /* open a device context and create a presentation space */

    hdc = WinOpenWindowDC (hwnd);
    hps = GpiCreatePS (hab, hdc, &sizl, PU_ARBITRARY | GPIT_MICRO |
            GPIA_ASSOC);

    /*
     * Create our off-screen 'buffer'.
     */
    hdcBuffer = DevOpenDC ( (HAB)0L, OD_MEMORY, "*", 0L, NULL, hdc);
    hpsBuffer = GpiCreatePS (hab, hdcBuffer, &sizl, PU_ARBITRARY |
                               GPIT_MICRO | GPIA_ASSOC);

    GpiCreateLogColorTable (hpsBuffer, 0, LCOLF_RGB, 0, 0, (PLONG)NULL);

    /* get the device resolutions so we can make the face appear circular */
    DevQueryCaps (hdc, (LONG)CAPS_VERTICAL_RESOLUTION,(LONG) 1L, &cyRes);
    DevQueryCaps (hdc, CAPS_HORIZONTAL_RESOLUTION, 1L, &cxRes);
    DevQueryCaps (hdc, CAPS_COLOR_PLANES, 1L, &cColorPlanes);
    DevQueryCaps (hdc, CAPS_COLOR_BITCOUNT, 1L, &cColorBitcount);

    cxScreen = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
    cyScreen = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);

    /*
     * Calculate an initial window position and size.
     */
    xLeft = cxScreen / 8;
    yBottom = cyScreen / 2;
    cxWidth = cxScreen / 3;
    cyHeight = cyScreen / 2;
    WinSetWindowPos (hwndFrame, NULLHANDLE, xLeft, yBottom,
                       cxWidth, cyHeight,
                       SWP_SIZE | SWP_MOVE | SWP_ACTIVATE);

    cbBuf = sizeof(cp);
    if (!PrfQueryProfileData(HINI_USER, SZ_APPNAME, SZ_KEYNAME, &cp, &cbBuf))
    {
        cp.usMajorTickPref = CLKTM_ALWAYS;
        cp.usMinorTickPref = CLKTM_NOTICONIC;
        cp.clrBackground = 0x00008080;
        cp.clrFace = 0x00008080;
        cp.clrHourHand = RGB_RED;
        cp.clrMinuteHand = RGB_RED;
        cp.fControlsHidden = FALSE;
        cp.usDispMode = DM_TIME | DM_ANALOG | DM_SECONDHAND;
        cp.alarm.uchHour = 0;
        cp.alarm.uchMinutes = 0;
        cp.alarm.usMode = 0;
        SetRGBColors();
        /* position the window and make it visible */
        WinSetWindowPos( hwndFrame , NULLHANDLE ,
                           xLeft , yBottom ,
                           cxWidth , cyHeight ,
                           SWP_SIZE | SWP_MOVE | SWP_ACTIVATE);
        WinQueryWindowPos(hwndFrame, &cp.swp);
    }
    else
    { /*Protect against garbage swp*/

        cp.swp.hwnd = hwndFrame;
        cp.swp.hwndInsertBehind = HWND_TOP;

        cp.swp.fl = (cp.swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE)) | SWP_SIZE | SWP_MOVE | SWP_ACTIVATE;
        SetRGBColors();
        WinSetMultWindowPos(hab, &cp.swp, 1);
    }

    if (cp.fControlsHidden)
        ClkHideFrameControls (hwndFrame);

    /*
     * Check relevant items.
     */
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TIME, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_TIME)?  MIA_CHECKED
                                      : ~MIA_CHECKED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_DATE, TRUE),
                MPFROM2SHORT( MIA_DISABLED,
                              ( (!(cp.usDispMode & DM_TIME))?  MIA_DISABLED
                                      : ~MIA_DISABLED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_DATE, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_DATE)?  MIA_CHECKED
                                      : ~MIA_CHECKED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TIME, TRUE),
                MPFROM2SHORT( MIA_DISABLED,
                              ( ((!(cp.usDispMode & DM_DATE) || (cp.usDispMode & DM_ANALOG)))?  MIA_DISABLED
                                      : ~MIA_DISABLED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( (cp.usDispMode & DM_DIGITAL)
                                                          ?IDM_DIGITAL
                                                          :IDM_ANALOG,
                               TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              MIA_CHECKED));

    WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(IDM_SECONDHAND, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_SECONDHAND) ? MIA_CHECKED
                                      : ~MIA_CHECKED)));


    /*
     * Disable these items if the digital clock is visible
     * since they won't apply.
     */
    if (cp.usDispMode & DM_DIGITAL)
    {
        WinSendMsg (hwndMenu, MM_SETITEMATTR,
                MPFROM2SHORT(IDM_SECONDHAND, TRUE),
                MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));

        WinSendMsg (hwndMenu, MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TICKS, TRUE), MPFROM2SHORT( MIA_DISABLED,
                MIA_DISABLED));
    }

    /* have we been asked to start as an icon? */
    if (fStartAsIcon)
        WinSetWindowPos(hwndFrame, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE);

    WinShowWindow(hwndFrame, TRUE);

    /* get the time in a format for dislaying */
    DosGetDateTime(&dt);
    dt.hours = (UCHAR )(dt.hours * (UCHAR) 5) % (UCHAR) 60 + dt.minutes / (UCHAR)12;

    /* start a timer */
    WinStartTimer (hab, hwnd, IDR_MAIN, 1000);

    WinLoadString(hab, NULLHANDLE, IDS_TITLE, 80, (PSZ)szTitle);
    GetCountryDependent();

}
Пример #2
0
void	DrawWatermazeTrack( FILE *fp, TRACK *t, char *Label, int PointsPerPixel, int OriginX, int OriginY, INFO I, int DrawEvents, int frame, FILEINFO FileInfo, float Scale)
{
	RGBCOLOR	rgb[N_COLORS];

	int		i,j, FirstGoodPosition = 1, NewEvent;
	float		x, y;
	float		CenterX, CenterY, ArenaRadiusPix;
	double		asin(), acos(), atan2();
	double 		Y, X, ang, rad, RoomFrameIncrease;

    	SetRGBColors(rgb);
	
	ArenaRadiusPix = (float)DEFAULT_ARENA_RADIUS / Scale;	// iTrack sets the radius to be 127

	(void) fprintf(fp, "gsave\n");

	// Set coordinate system to arena center
	CenterX = (float)(OriginX);
	CenterY = (float)(OriginY - I.Arena.CenterY * PointsPerPixel - 20);
	(void) fprintf(fp, "%0.2f %0.2f translate\n", CenterX, CenterY);

	RoomFrameIncrease = (ROOM_FRAME_INCREASE / Scale);

	if(strcmp(Label,"")){
		// label the Figure
		(void) fprintf(fp, "/Times-Roman findfont\n");
		(void) fprintf(fp, "0.5 cm scalefont\n");
		(void) fprintf(fp, "setfont\n");

		(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", (0.0 - ArenaRadiusPix), (ArenaRadiusPix + 35.0));
		(void) fprintf(fp, "( %s %s ) show\n", I.Paradigm, Label);
	}

	// label the picture
	(void) fprintf(fp, "/Times-Roman findfont\n");
	(void) fprintf(fp, "0.3 cm scalefont\n");
	(void) fprintf(fp, "setfont\n");

	(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", (0.0 - ArenaRadiusPix), (ArenaRadiusPix + 20.0));
	(void) fprintf(fp, "( Subject: %d Trial %d) show\n", I.TrialSubjectId, I.TrialNumber);
	(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", (0.0 - ArenaRadiusPix), (ArenaRadiusPix + 10.0));
	(void) fprintf(fp, "( Start: %s) show\nnewpath\n", I.TrialStartLabel);

	// draw the arena in a thin line
	(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n1.0 setlinewidth\n", rgb[BLACK].r, rgb[BLACK].g, rgb[BLACK].b);

	switch(I.Arena.Type){
		case ARENA_TYPE_CIRCLE:
			/* draw a circle for the arena */
			(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix 0 360 arc\n", 0.0, 0.0, ArenaRadiusPix);
			(void) fprintf(fp, "closepath\nstroke\n");
			break;

		default:
			break;
	}

	/* draw a square for the room */
	(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n1.0 setlinewidth\n", rgb[GRAY].r, rgb[GRAY].g, rgb[GRAY].b);
	(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", 0.0 - (ArenaRadiusPix + RoomFrameIncrease) , 0.0 - (ArenaRadiusPix + RoomFrameIncrease));
	(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", (ArenaRadiusPix + RoomFrameIncrease), 0.0 - (ArenaRadiusPix + RoomFrameIncrease));
	(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", (ArenaRadiusPix + RoomFrameIncrease) , (ArenaRadiusPix + RoomFrameIncrease));
	(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", 0.0 - (ArenaRadiusPix + RoomFrameIncrease) , (ArenaRadiusPix + RoomFrameIncrease));
	(void) fprintf(fp, "closepath\nstroke\n");	
		
	/* draw the reinforced area */
	if(I.Target[frame].Show){
		switch(I.Target[frame].Type){
			case REINFORCED_CIRCLE:
				(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n0.5 setlinewidth\n", rgb[RED].r, rgb[RED].g, rgb[RED].b);
			
				// draw the same regardless of the defining frame
				// original target
				X = I.Target[frame].Circle.X - I.Arena.CenterX, 
				Y = I.Arena.CenterY - I.Target[frame].Circle.Y;
				X /= Scale;
				Y /= Scale;

				(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix 0 360 arc\n", X, Y, I.Target[frame].Circle.Rad/Scale);
				(void) fprintf(fp, "closepath\nstroke\n");
				rad = hypot(Y, X);
				ang = atan2(Y, X);

				// draw corresponding targets in the other quadrants
				(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n1.0 setlinewidth\n", rgb[GRAY].r, rgb[GRAY].g, rgb[GRAY].b);
					
				for(j = 1; j < 4; j++){
					X = cos(ang + j * (M_PI / 2.0)) * rad; 
					Y = sin(ang + j * (M_PI / 2.0)) * rad; 
					(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix 0 360 arc\n", X, Y, I.Target[frame].Circle.Rad/Scale);
					(void) fprintf(fp, "closepath\nstroke\n");
				}
				break;
			default:
				break;
		}
	}

	// draw track
	(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n1.0 setlinewidth\n", rgb[BLACK].r, rgb[BLACK].g, rgb[BLACK].b);
	FirstGoodPosition = 1;
	NewEvent = 1;
	for(i = 0; i < I.NumberOfSamps; i ++){
		// Was the object detected?
		if((!t[i].x) || (!t[i].y)){
			if(!FirstGoodPosition)
				(void) fprintf(fp, "stroke\n");
			FirstGoodPosition = 1;
			continue;
		}

		// Transform from tracker to Cartesian coordinates
		x = (float)(t[i].x - I.Arena.CenterX);
		y = (float)(I.Arena.CenterY - t[i].y);

		x /= Scale;
		y /= Scale;

		if(FirstGoodPosition){
			(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
			if(t[i].event){
				if((I.FileFormat == TRACKER_FORMAT) || (I.FileFormat == ITRACK_FORMAT)){ // Event is coded as a state
					if((NewEvent) && (t[i].event == PP_STATE_Feed)){
						(void) fprintf(fp, "stroke\n");
						DrawAnEvent(fp, x, y, rgb, PointsPerPixel, RED);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
						NewEvent = 0;
					}else{
						if(t[i].event != PP_STATE_Feed)
							NewEvent = 1;
					}
				}else{
					(void) fprintf(fp, "stroke\n");
					DrawAnEvent(fp, x, y, rgb, PointsPerPixel, RED);
					(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
					NewEvent = 0;
				}
			}	
			FirstGoodPosition = 0;
			continue;
		}
		(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", x,y);
		if(t[i].event){
			if((I.FileFormat == TRACKER_FORMAT) || (I.FileFormat == ITRACK_FORMAT)){ // Event is coded as a state
				if((NewEvent) && (t[i].event == PP_STATE_Feed)){
					(void) fprintf(fp, "stroke\n");
					DrawAnEvent(fp, x, y, rgb, PointsPerPixel, RED);
				}
				(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
				NewEvent = 0;
			}else{
				if(t[i].event != PP_STATE_Feed)
				NewEvent = 1;
			}
		}
	}
	if(!FirstGoodPosition)
		(void) fprintf(fp, "stroke\n");

	// reset coordinate system upon return
	(void) fprintf(fp, "grestore\n");

	return;
}
/****************************************************************\
 *
 *--------------------------------------------------------------
 *
 *  Name:ClkCommand()
 *
 *  Purpose:Handle  WM_COMMAND events.
 *
 *
 *
 *  Usage:
 *
 *  Method:
 *          -
 *
 *          -
 *          -
 *
 *          -
 *          -
 *
 *  Returns:
 *          VOID
 *
\****************************************************************/
VOID ClkCommand ( HWND hwnd , MPARAM mp1, MPARAM mp2 )
{
    DATETIME  dtNew ;

    switch ( SHORT1FROMMP ( mp1 ) )
    {

        case IDM_TICKS :
            WinDlgBox ( HWND_DESKTOP , hwndFrame , ClkTicksDlgProc ,
                        NULLHANDLE ,
                        IDD_TICKS , (PVOID )NULL ) ;
            break;

        case IDM_EXIT:
            /*
             *post the event semaphore
             *for our alarm thread
             */
            fEndThread = TRUE;
            DosPostEventSem(TimerResources.hTimerDev);
            WinPostMsg(hwnd, WM_QUIT,MPVOID, MPVOID);


            break;

        case IDM_COLORS :
            WinDlgBox ( HWND_DESKTOP , hwndFrame ,ClkColorsDlgProc ,
                        NULLHANDLE ,
                        IDD_COLORS , NULL ) ;
            SetRGBColors();
            ClkSize(hwnd);
            break ;

        case IDM_TOGGLECONTROLS :
            if (cp.fControlsHidden) {
                ClkShowFrameControls( hwndFrame );
            } else {
                ClkHideFrameControls ( hwndFrame ) ;
            }
            break ;

        case IDM_DATETIME:
            if (hDateTime == NULLHANDLE)
            {
                WinDlgBox(HWND_DESKTOP,hwndFrame,TimeDlgProc,
                          NULLHANDLE,IDD_TIME ,NULL);
                dt.minutes += 2; /*Fool the ClkTimer proc. It will now think it have
                                  to redraw*/
            } else {
                WinSetFocus (HWND_DESKTOP, hDateTime);
            }
            break;
        case IDM_ALARM:
            if (hAlarmTime == (HWND)NULL)
            {
                WinDlgBox(HWND_DESKTOP,hwndFrame,AlarmDlgProc,
                          NULLHANDLE,IDD_ALARM ,NULL);
            }
            else
            {
                WinSetFocus(HWND_DESKTOP,hAlarmTime);
            }

            break;

        case IDM_SECONDHAND:
            cp.usDispMode = ((cp.usDispMode & DM_SECONDHAND) ?
                    (cp.usDispMode & (~DM_SECONDHAND)) : (cp.usDispMode | DM_SECONDHAND));

            GpiSetMix(hps, FM_INVERT);

            /*
             * Depending on the current mode draw or remove the second hand.
             */
            if (cp.usDispMode & DM_SECONDHAND) {
                DosGetDateTime(&dtNew);
                ClkDrawHand(hps, HT_SECOND, dtNew.seconds);
                dt.seconds = dtNew.seconds;
            } else {
                ClkDrawHand(hps, HT_SECOND, dt.seconds);
            }

            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_SECONDHAND, TRUE),
                        MPFROM2SHORT( MIA_CHECKED,
                                      ( (cp.usDispMode & DM_SECONDHAND)?  MIA_CHECKED
                                              : ~MIA_CHECKED) ) );
            break;

        case IDM_TIME:
            cp.usDispMode = ((cp.usDispMode & DM_TIME) ? (cp.usDispMode & (~DM_TIME))
                                                      : (cp.usDispMode | DM_TIME));

            WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(IDM_TIME, TRUE),
                    MPFROM2SHORT(MIA_CHECKED, ((cp.usDispMode & DM_TIME) ?
                    MIA_CHECKED : ~MIA_CHECKED)));

            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_DATE, TRUE),
                        MPFROM2SHORT( MIA_DISABLED,
                                      ( (!(cp.usDispMode & DM_TIME)) ? MIA_DISABLED
                                              : ~MIA_DISABLED) ) );
            ClkSize(hwnd);
            WinInvalidateRect(hwnd, NULL, TRUE);
            break;

        case IDM_DATE:
            cp.usDispMode = ((cp.usDispMode & DM_DATE) ? (cp.usDispMode & (~DM_DATE))
                                                      : (cp.usDispMode | DM_DATE));
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_DATE, TRUE),
                        MPFROM2SHORT( MIA_CHECKED,
                                      ( (cp.usDispMode & DM_DATE)?  MIA_CHECKED
                                              : ~MIA_CHECKED) ) );
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_TIME, TRUE),
                        MPFROM2SHORT( MIA_DISABLED,
                                      ( ((!(cp.usDispMode & DM_DATE)) || (cp.usDispMode & DM_ANALOG))?  MIA_DISABLED
                                              : ~MIA_DISABLED) ) );
            ClkSize(hwnd);
            WinInvalidateRect(hwnd,(PRECTL)NULL,TRUE);

            break;
        case IDM_DIGITAL:
            cp.usDispMode |=  DM_DIGITAL;
            cp.usDispMode &=  (~DM_ANALOG);
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_DIGITAL, TRUE),
                        MPFROM2SHORT( MIA_CHECKED,
                                      MIA_CHECKED));
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_ANALOG , TRUE),
                        MPFROM2SHORT( MIA_CHECKED,
                                     ~MIA_CHECKED));
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_SECONDHAND, TRUE),
                        MPFROM2SHORT( MIA_DISABLED,
                                        MIA_DISABLED));
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_TICKS, TRUE),
                        MPFROM2SHORT( MIA_DISABLED,
                                        MIA_DISABLED));
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_TIME, TRUE),
                        MPFROM2SHORT( MIA_DISABLED,
                                      ( ((!(cp.usDispMode & DM_DATE)) || (cp.usDispMode & DM_ANALOG))?  MIA_DISABLED
                                              : ~MIA_DISABLED) ) );
            WinInvalidateRect(hwnd,(PRECTL)NULL,TRUE);
            break;
        case IDM_ANALOG :
            cp.usDispMode |=  DM_ANALOG;
            cp.usDispMode &=  (~DM_DIGITAL);
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_ANALOG, TRUE),
                        MPFROM2SHORT( MIA_CHECKED,
                                      MIA_CHECKED));
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_DIGITAL, TRUE),
                        MPFROM2SHORT( MIA_CHECKED,
                                     ~MIA_CHECKED));
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_TIME, TRUE),
                        MPFROM2SHORT( MIA_DISABLED,
                                        MIA_DISABLED));
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_DATE, TRUE),
                        MPFROM2SHORT( MIA_DISABLED,
                                        ~MIA_DISABLED));

            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_SECONDHAND, TRUE),
                        MPFROM2SHORT( MIA_DISABLED,
                                        ~MIA_DISABLED));
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_TICKS, TRUE),
                        MPFROM2SHORT( MIA_DISABLED,
                                        ~MIA_DISABLED));

            cp.usDispMode |= DM_TIME;
            WinSendMsg( hwndMenu,
                        MM_SETITEMATTR,
                        MPFROM2SHORT( IDM_TIME, TRUE),
                        MPFROM2SHORT( MIA_CHECKED,
                                      MIA_CHECKED));
            WinInvalidateRect(hwnd,(PRECTL)NULL,TRUE);
            break;


        case IDM_HELPHELPFORHELP:
            HelpHelpForHelp(mp2);
            break;

        case IDM_HELPEXTENDED:
            HelpExtended(mp2);
            break;

        case IDM_HELPKEYS:
            HelpKeys(mp2);
            break;

        case IDM_HELPINDEX:
            HelpIndex(mp2);
            break;

        case IDM_HELPTUTORIAL:
            HelpTutorial(mp2);
            break;

        case IDM_HELPABOUT:
            HelpAbout(mp2);
            break;

     case IDM_ALARM_EXPIRED:
           WinMessageBox(HWND_DESKTOP,
                         hwndFrame,
                         (PSZ)"Alarm Expired",
                         (PSZ)"The Bells Are Ringing",
                         0,
                         MB_OK);
            break;
    }
}
Пример #4
0
void	DrawTrack(FILE *fp, TRACK *t, char *Label, int PointsPerPixel, int OriginX, int OriginY, INFO I, int DrawEvents, int frame, FILEINFO FileInfo)
{
	RGBCOLOR	rgb[N_COLORS];

	int			i,j, FirstGoodPosition = 1, NewEvent;
	float		x, y;
	float		CenterX, CenterY, ArenaRadiusPix;
	float		MinShockAng, MaxShockAng, MinShockRad, MaxShockRad;
	double		asin(), acos(), atan2();
	double 		Y, X, ang, rad;
	unsigned char	**ReinforcedMap;

	SetRGBColors(rgb);
	
	// ArenaRadiusPix = (float)(I.Arena.Radius * I.PixelsPerCM);
	ArenaRadiusPix = (float)DEFAULT_ARENA_RADIUS;	// iTrack sets the radius to be 127

	(void) fprintf(fp, "gsave\n");

	// Set coordinate system to arena center
	CenterX = (float)(I.Arena.CenterX * PointsPerPixel + OriginX);
	CenterY = (float)(OriginY - I.Arena.CenterY * PointsPerPixel - 20);
	(void) fprintf(fp, "%0.2f %0.2f translate\n", CenterX, CenterY);

	// label the picture
	(void) fprintf(fp, "/Times-Roman findfont\n");
	(void) fprintf(fp, "0.5 cm scalefont\n");
	(void) fprintf(fp, "setfont\n");

	(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", (0.0 - ArenaRadiusPix), (ArenaRadiusPix + 10.0));
	// (void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", (0.0 - ArenaRadiusPix - ROOM_FRAME_INCREASE), (ArenaRadiusPix + 10.0));
	(void) fprintf(fp, "( Paradigm: %s ) show\n", I.Paradigm);

	(void) fprintf(fp, "%d pix %d pix mt\n", 0 - strlen(Label) / 2, 0 - (int)(ArenaRadiusPix + 20));
	(void) fprintf(fp, "( %s ) center show\nnewpath\n", Label);

	// draw the arena in a thin line
	(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n1.0 setlinewidth\n", rgb[BLACK].r, rgb[BLACK].g, rgb[BLACK].b);

	switch(I.Arena.Type){
		case ARENA_TYPE_CIRCLE:
			/* draw a circle for the arena */
			(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix 0 360 arc\n", 0.0, 0.0, ArenaRadiusPix);
			(void) fprintf(fp, "closepath\nstroke\n");

		break;

		default:
		break;
	}

	for(i = 0; i < I.NumberOfCoordFrames; i++){
		// draw the Coordinate frame in a thick line
		(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n3.0 setlinewidth\n", rgb[BLACK].r, rgb[BLACK].g, rgb[BLACK].b);
		switch(I.Target[i].CoordFrame){
			case ROOM_FRAME:
				/* draw a square for the room */
				(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", 0.0 - (ArenaRadiusPix + ROOM_FRAME_INCREASE) , 0.0 - (ArenaRadiusPix + ROOM_FRAME_INCREASE));
				(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", (ArenaRadiusPix + ROOM_FRAME_INCREASE), 0.0 - (ArenaRadiusPix + ROOM_FRAME_INCREASE));
				(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", (ArenaRadiusPix + ROOM_FRAME_INCREASE) , (ArenaRadiusPix + ROOM_FRAME_INCREASE));
				(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", 0.0 - (ArenaRadiusPix + ROOM_FRAME_INCREASE) , (ArenaRadiusPix + ROOM_FRAME_INCREASE));
				(void) fprintf(fp, "closepath\nstroke\n");	
			break;

			case ARENA_FRAME:
				switch(I.Arena.Type){
					case ARENA_TYPE_CIRCLE:
						/* draw a circle for the arena */	
						(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix 0 360 arc\n", 0.0, 0.0, ArenaRadiusPix);
						(void) fprintf(fp, "closepath\nstroke\n");
					break;
					
					default:
					break;
				}
			break;

			case ROOM_AND_ARENA_FRAME:
				/* draw a square for the room */
				(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", 0.0 - (ArenaRadiusPix + ROOM_FRAME_INCREASE) , 0.0 - (ArenaRadiusPix + ROOM_FRAME_INCREASE));
				(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", (ArenaRadiusPix + ROOM_FRAME_INCREASE), 0.0 - (ArenaRadiusPix + ROOM_FRAME_INCREASE));
				(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", (ArenaRadiusPix + ROOM_FRAME_INCREASE) , (ArenaRadiusPix + ROOM_FRAME_INCREASE));
				(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", 0.0 - (ArenaRadiusPix + ROOM_FRAME_INCREASE) , (ArenaRadiusPix + ROOM_FRAME_INCREASE));
				(void) fprintf(fp, "closepath\nstroke\n");
			
				switch(I.Arena.Type){
					case ARENA_TYPE_CIRCLE:
						/* draw a circle for the arena */	
						(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix 0 360 arc\n", 0.0, 0.0, ArenaRadiusPix);
						(void) fprintf(fp, "closepath\nstroke\n");
					break;

					default:
					break;
				}
			
			break;

			default:
			break;
		}
		
		/* draw the reinforced area */
		if(I.Target[i].Show && (i == frame)){

			switch(I.Target[i].Type){
				case REINFORCED_CIRCLE:
					(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n1.0 setlinewidth\n", rgb[RED].r, rgb[RED].g, rgb[RED].b);
				
					// draw the same regardless of the defining frame
					// original target
					X = I.Target[i].Circle.X - I.Arena.CenterX, 
					Y = I.Arena.CenterY - I.Target[i].Circle.Y;
					(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix 0 360 arc\n", X, Y, I.Target[i].Circle.Rad);
					(void) fprintf(fp, "closepath\nstroke\n");
					rad = hypot(Y, X);
					ang = atan2(Y, X);

					// draw corresponding targets in the other quadrants
					(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n1.0 setlinewidth\n", rgb[BLACK].r, rgb[BLACK].g, rgb[BLACK].b);
					
					for(j = 1; j < 4; j++){
						X = cos(ang + j * (M_PI / 2.0)) * rad; 
						Y = sin(ang + j * (M_PI / 2.0)) * rad; 
						(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix 0 360 arc\n", X, Y, I.Target[i].Circle.Rad);
						(void) fprintf(fp, "closepath\nstroke\n");
					}
				break;

				case REINFORCED_SECTOR:
					(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n3.0 setlinewidth\n", rgb[RED].r, rgb[RED].g, rgb[RED].b);
				
					MinShockAng = (float)(I.Target[i].Sector.Ang - (I.Target[i].Sector.Width / (float)2.0)) / (float)DEG_PER_RAD;
					MaxShockAng = (float)(I.Target[i].Sector.Ang + (I.Target[i].Sector.Width / (float)2.0)) / (float)DEG_PER_RAD;
					MinShockRad = (float)(I.Target[i].Sector.InRad);
					MaxShockRad = (float)(I.Target[i].Sector.OutRad);

					// draw according to the defining frame
					if((I.Target[i].CoordFrame == ROOM_FRAME) || (I.Target[i].CoordFrame == ROOM_AND_ARENA_FRAME)){
						double RoomRadius, WallRadius;

						RoomRadius = ArenaRadiusPix + ROOM_FRAME_INCREASE;
						// max ang: line in to out
						x = (float)(cos(MaxShockAng) * MinShockRad);
						y = (float)(sin(MaxShockAng) * MinShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);

						if(((MaxShockAng > (45.0 / DEG_PER_RAD)) && (MaxShockAng < (135.0 / DEG_PER_RAD))) ||
							((MaxShockAng > (225.0 / DEG_PER_RAD)) && (MaxShockAng < (315.0 / DEG_PER_RAD))))
							WallRadius = sqrt((double)(RoomRadius * RoomRadius) / (1.0 - cos(MaxShockAng) * cos(MaxShockAng)));
						else
							WallRadius = sqrt((double)(RoomRadius * RoomRadius) / (1.0 - sin(MaxShockAng) * sin(MaxShockAng)));
					
						x = (float)(cos(MaxShockAng) * WallRadius);
						y = (float)(sin(MaxShockAng) * WallRadius);
						(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", x,y);
				
						// max ang outer to min ang outer
						if(((MinShockAng > (45.0 / DEG_PER_RAD)) && (MinShockAng < (135.0 / DEG_PER_RAD))) ||
							((MinShockAng > (225.0 / DEG_PER_RAD)) && (MinShockAng < (315.0 / DEG_PER_RAD))))
							WallRadius = sqrt((double)(RoomRadius * RoomRadius) / (1.0 - cos(MinShockAng) * cos(MinShockAng)));
						else
							WallRadius = sqrt((double)(RoomRadius * RoomRadius) / (1.0 - sin(MinShockAng) * sin(MinShockAng)));

						x = (float)(cos(MinShockAng) * WallRadius);
						y = (float)(sin(MinShockAng) * WallRadius);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);

						// min ang: outer to inner
						x = (float)(cos(MinShockAng) * MinShockRad);
						y = (float)(sin(MinShockAng) * MinShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", x,y);
		
						// inner arc
						x = (float)(cos(MinShockAng) * MinShockRad);
						y = (float)(sin(MinShockAng) * MinShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
						x = 0.0;
						y = 0.0;
						(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix %0.2f %0.2f arc\n", x, y, MinShockRad, MinShockAng * DEG_PER_RAD, MaxShockAng * DEG_PER_RAD);
						x = (float)(cos(MaxShockAng) * MinShockRad);
						y = (float)(sin(MaxShockAng) * MinShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);

						(void) fprintf(fp, "closepath\nstroke\n");
					}
					if((I.Target[i].CoordFrame == ARENA_FRAME) || (I.Target[i].CoordFrame == ROOM_AND_ARENA_FRAME)){

						// max ang: line in to out
						x = (float)(cos(MaxShockAng) * MinShockRad);
						y = (float)(sin(MaxShockAng) * MinShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
						x = (float)(cos(MaxShockAng) * MaxShockRad);
						y = (float)(sin(MaxShockAng) * MaxShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", x,y);

						// outer arc
						x = (float)(cos(MinShockAng) * MaxShockRad);
						y = (float)(sin(MinShockAng) * MaxShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
						x = 0.0;
						y = 0.0;
						(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix %0.2f %0.2f arc\n", x, y, MaxShockRad, MinShockAng * DEG_PER_RAD, MaxShockAng * DEG_PER_RAD);
						
						// min ang: line out to in
						x = (float)(cos(MinShockAng) * MaxShockRad);
						y = (float)(sin(MinShockAng) * MaxShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
						x = (float)(cos(MinShockAng) * MinShockRad);
						y = (float)(sin(MinShockAng) * MinShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", x,y);

						// inner arc
						x = (float)(cos(MinShockAng) * MinShockRad);
						y = (float)(sin(MinShockAng) * MinShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
						x = 0.0;
						y = 0.0;
						(void) fprintf(fp, "%0.2f pix %0.2f pix %0.2f pix %0.2f %0.2f arc\n", x, y, MinShockRad, MinShockAng * DEG_PER_RAD, MaxShockAng * DEG_PER_RAD);
						x = (float)(cos(MaxShockAng) * MinShockRad);
						y = (float)(sin(MaxShockAng) * MinShockRad);
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);

						(void) fprintf(fp, "closepath\nstroke\n");
					}
				break;

				default:
				break;

			}	
		}
	}

	//  draw quadrant lines
	if(I.ParadigmType == OPEN_FIELD || I.ParadigmType == TRACKER){
		double RoomRadius, QuadAng;

		RoomRadius = ArenaRadiusPix + ROOM_FRAME_INCREASE;

		(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n0.5 setlinewidth\n", rgb[BLACK].r, rgb[BLACK].g, rgb[BLACK].b);

		QuadAng = 135.0 / (double)DEG_PER_RAD; // NW point
		x = (float)(cos(QuadAng) * RoomRadius);
		y = (float)(sin(QuadAng) * RoomRadius);
		(void) fprintf(fp, "newpath\n%0.2f pix %0.2f pix mt\n", x,y);

		QuadAng = 315.0 / (double)DEG_PER_RAD; // SE point
		x = (float)(cos(QuadAng) * RoomRadius);
		y = (float)(sin(QuadAng) * RoomRadius);
		(void) fprintf(fp, "%0.2f pix %0.2f pix lt\nclosepath\nstroke\n", x,y);

		QuadAng = 45.0 / (double)DEG_PER_RAD; // NE point
		x = (float)(cos(QuadAng) * RoomRadius);
		y = (float)(sin(QuadAng) * RoomRadius);
		(void) fprintf(fp, "newpath\n%0.2f pix %0.2f pix mt\n", x,y);

		QuadAng = 225.0 / (double)DEG_PER_RAD; // SW point
		x = (float)(cos(QuadAng) * RoomRadius);
		y = (float)(sin(QuadAng) * RoomRadius);
		(void) fprintf(fp, "%0.2f pix %0.2f pix lt\nclosepath\nstroke\n", x,y);

	}

	//  draw grid lines
	if(I.ParadigmType == OPEN_FIELD){
		double RoomRadius;
		int	OFPixelSize;
		float  point;

		RoomRadius = ArenaRadiusPix + ROOM_FRAME_INCREASE;
		OFPixelSize = (int)(TRACKER_XY_RESOLUTION / I.Options.OpenFieldDimension);

		(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n0.5 setlinewidth\n", rgb[BLACK].r, rgb[BLACK].g, rgb[BLACK].b);

		for(i = 0; i <= TRACKER_XY_RESOLUTION; i += OFPixelSize){
			point = (float)(i - (TRACKER_XY_RESOLUTION / 2));
			// vertical lines
			(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", point, RoomRadius);
			(void) fprintf(fp, "%0.2f pix %0.2f pix lt\nstroke\n", point, -1.0 * RoomRadius);
			// horizontal lines
			(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", -1.0 * RoomRadius, point);
			(void) fprintf(fp, "%0.2f pix %0.2f pix lt\nstroke\n", RoomRadius, point);
		}
	}

	// draw track

	// define the Reinforced sector for avoidance since this was not set in Tracker
	if(I.ParadigmType == PLACE_AVOIDANCE){
		if(I.Target[frame].Type == REINFORCED_SECTOR){
                	MakeAvoidSectorMap(&ReinforcedMap, I, I.Target[frame].Sector);
                }else if(I.Target[frame].Type == REINFORCED_CIRCLE){
                	MakeAvoidCircleMap(&ReinforcedMap, I, I.Target[frame].Circle, 1);
		}
	}

	(void) fprintf(fp, "%0.2f %0.2f %0.2f setrgbcolor\n0.5 setlinewidth\n", rgb[GRAY].r, rgb[GRAY].g, rgb[GRAY].b);
	FirstGoodPosition = 1;
	NewEvent = 1;
	for(i = 0; i < I.NumberOfSamps; i ++){
		// Was the object detected?
		if((!t[i].x) || (!t[i].y)){
			if(!FirstGoodPosition)
				(void) fprintf(fp, "stroke\n");
			FirstGoodPosition = 1;
			continue;
		}

		// Transform from tracker to Cartesian coordinates
		x = (float)(t[i].x - I.Arena.CenterX);
		y = (float)(I.Arena.CenterY - t[i].y);
		if(FirstGoodPosition){
			(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
			if(t[i].event){
				switch(DrawEvents){
					case 0: break;		/* don't draw anything */

					case 1: 		/* draw one mark per event */
						if((I.FileFormat == TRACKER_FORMAT) || (I.FileFormat == ITRACK_FORMAT) || (I.FileFormat == FGX_FORMAT)){ // Event is coded as a state
							if(t[i].event == SHOCK_STATE){
								if(NewEvent){
									(void) fprintf(fp, "stroke\n");
									if(I.Target[frame].Show){
										if(ReinforcedMap[t[i].y][t[i].x] == TARGET){	// make frame specific events
											DrawAnEvent(fp, x, y, rgb, PointsPerPixel, RED);
										}else{
											DrawAnEvent(fp, x, y, rgb, PointsPerPixel, BLUE);
										}
									}else{
										DrawAnEvent(fp, x, y, rgb, PointsPerPixel, BLUE);
									}
									(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
									NewEvent = 0;
								}
							}else{
								if(t[i].event != BAD_SPOT_STATE){	// Use the BadSpot flag introduced by Tracker
									NewEvent = 1;
								}
							}
						}else{
							(void) fprintf(fp, "stroke\n");
							if(I.Target[frame].Show){
								DrawAnEvent(fp, x, y, rgb, PointsPerPixel, RED);
							}else{
								DrawAnEvent(fp, x, y, rgb, PointsPerPixel, BLUE);
							}
							(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
						}
						break;

					case 2:
						(void) fprintf(fp, "stroke\n");
						if(I.Target[frame].Show){
							for(j = 0; j < t[i].event; j++){
								DrawAnEvent(fp, (float)(x + (j * 0.1)), (float)(y + (j * 0.1)), rgb, PointsPerPixel, RED);
							}
						}else{
							for(j = 0; j < t[i].event; j++){
								DrawAnEvent(fp, (float)(x + (j * 0.1)), (float)(y + (j * 0.1)), rgb, PointsPerPixel, BLUE);
							}
						}
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
						break;
					default:	
						break;
				}
			}else{
				if(t[i].event != BAD_SPOT_STATE){	// Use the BadSpot flag introduced by Tracker
					NewEvent = 1;
				}
			}	
			FirstGoodPosition = 0;
			continue;
		}
		(void) fprintf(fp, "%0.2f pix %0.2f pix lt\n", x,y);
		if(t[i].event){
			switch(DrawEvents){
				case 0: break;		/* don't draw anything */

				case 1: 		/* draw one mark per event */
					if((I.FileFormat == TRACKER_FORMAT) || (I.FileFormat == ITRACK_FORMAT) || (I.FileFormat == FGX_FORMAT)){ // Event is coded as a state
						if(t[i].event == SHOCK_STATE){
							if(NewEvent){
								(void) fprintf(fp, "stroke\n");
								if(I.Target[frame].Show){
									if(ReinforcedMap[t[i].y][t[i].x] == TARGET){	// make frame specific events
										// DEBUG(-1 * i)
										DrawAnEvent(fp, x, y, rgb, PointsPerPixel, RED);
									}else{
										DrawAnEvent(fp, x, y, rgb, PointsPerPixel, BLUE);
									}
								}else{
									DrawAnEvent(fp, x, y, rgb, PointsPerPixel, BLUE);
								}
								(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
								NewEvent = 0;
							}
						}else{
							if(t[i].event != BAD_SPOT_STATE){       // Use the BadSpot flag introduced by Tracker	
								NewEvent = 1;
							}
						}
					}else{
						(void) fprintf(fp, "stroke\n");
						if(I.Target[frame].Show){
							DrawAnEvent(fp, x, y, rgb, PointsPerPixel, RED);
						}else{
							DrawAnEvent(fp, x, y, rgb, PointsPerPixel, BLUE);
						}
						(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
					}
					break;

				case 2:
					(void) fprintf(fp, "stroke\n");
					if(I.Target[frame].Show){
						for(j = 0; j < t[i].event; j++){
							DrawAnEvent(fp, (float)(x + (j * 0.1)), (float)(y + (j * 0.1)), rgb, PointsPerPixel, RED);
						}
					}else{
						for(j = 0; j < t[i].event; j++){
							DrawAnEvent(fp, (float)(x + (j * 0.1)), (float)(y + (j * 0.1)), rgb, PointsPerPixel, BLUE);
						}
					}
					(void) fprintf(fp, "%0.2f pix %0.2f pix mt\n", x,y);
					break;

				default:	
					break;
			}
		}else{
			NewEvent = 1;
		}
	}
	if(!FirstGoodPosition)
		(void) fprintf(fp, "stroke\n");

	// reset coordinate system upon return
	(void) fprintf(fp, "grestore\n");

	return;
	
}