Exemplo n.º 1
0
int main(int argc, char *argv[])
{
	MiscAppInit();
	if (SDL_Init(SDL_INIT_VIDEO) < 0) 
	{
		MiscTrace("Couldn't initialize SDL: %s\n",SDL_GetError());
		return 1;
	}
	MainFrameSetTitle(SSS_TITLE);
	s_screen = CanvasInit();
	MouseInit();
	KeyboardInit();
	s_screenArea.x = 0;
	s_screenArea.y = 0;
	s_screenArea.w = WINDOW_WIDTH;
	s_screenArea.h = WINDOW_HEIGHT;
	s_done = 0;
#if 0
	while (1) 
	{
		if(MainFrameGetMsg())
		{
			break;
		}
		{
			int k = 0;
			int width = WINDOW_WIDTH;
			int height = WINDOW_HEIGHT;
			CanvasLock();
			CanvasSetColor(CanvasRGB(0xff, 0, 0));
			CanvasMoveTo(0, 0);
			CanvasLineTo(width * 2, height * 2);
			for (k = height / 4; k < height / 2; k++)
			{
				CanvasSetPixel(width / 2, k, 
					CanvasRGB(0xff, 0, 0xff));
			}
			CanvasDrawLine(-width, height * 2, width * 2, -height, 
				CanvasRGB(0, 0, 0xff));
			CanvasUnlock();
			MainFrameRefresh();
		}
	}
#else
	ScriptRun();
#endif
	KeyboardRelease();
	MouseRelease();
	CanvasRelease();
	SDL_Quit();
	return 0;
}
/// HIFN draws lines marking the spot pattern
void drawSpotLines(int Panel, int Canvas)
{
	// if the current SLM pattern is a spot pattern, we plot a grid
	// indicating the spot positions
	if (SLM_getCurrentPattern() == SLM_BEAMSPLIT_IFTA)
	{
		// get the canvas dimensions
		int CanvasX, CanvasY;
		GetCtrlAttribute(Panel, Canvas, ATTR_WIDTH,  &CanvasX);
		GetCtrlAttribute(Panel, Canvas, ATTR_HEIGHT, &CanvasY);
		
		// retrieve the current settings from the control panel
		int Nx, Ny, sigxoffset, sigyoffset, spotxoffset, spotyoffset, spotxspacing, spotyspacing;
		GetCtrlVal(TabPage_1_2, TABPANEL_5_NumXSpots,    &Nx);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_NumYSpots,    &Ny);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SpotXOffset,  &spotxoffset);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SpotYOffset,  &spotyoffset);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SigXOffset,   &sigxoffset);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SigYOffset,   &sigyoffset);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SpotXSpacing, &spotxspacing);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SpotYSpacing, &spotyspacing);
		
		// convenience variables for the lattice periods
		double periodx = spotxspacing + 1.0;
		double periody = spotyspacing + 1.0;
		
		// compute the upper left spot coordinates in camera space
		int ulxpos = gOx + gCamMPx * (spotxoffset + sigxoffset + 1);
		int ulypos = gOy + gCamMPy * (spotyoffset + sigyoffset + 1);
		
		// compute the lower right spot coordinates
		int lrxpos = gOx + gCamMPx * ((spotxoffset + sigxoffset + 1) + (Nx - 1) * (periodx));
		int lrypos = gOy + gCamMPy * ((spotyoffset + sigyoffset + 1) + (Ny - 1) * (periody));
		
		// set the pen color
		SetCtrlAttribute(Panel, Canvas, ATTR_PEN_COLOR, 0x00AAAAAA);
		
		// draw a cross at the origin
		int xo = TransformBitmapToCamCanvasX(gOx);
		int yo = TransformBitmapToCamCanvasY(gOy);
		CanvasDrawLine(Panel, Canvas, MakePoint(xo, 0), MakePoint(xo, CanvasY));
		CanvasDrawLine(Panel, Canvas, MakePoint(0, yo), MakePoint(CanvasX, yo));
		
		// draw vertical lines indicating the grid
		for (int k = 0; k <= Nx; k++)
		{
			// get the coordinates of the endpoints of the gridline
			int xc = TransformBitmapToCamCanvasX((int) (ulxpos + gCamMx * SLM_getFocalUnitX() * (-periodx / 2.0 + k * periodx) / (gCamPixelSize * 1e6)));
			int y1 = TransformBitmapToCamCanvasY((int) (ulypos - gCamMy * SLM_getFocalUnitY() * periody * 0.5 / (gCamPixelSize * 1e6)));
			int y2 = TransformBitmapToCamCanvasY((int) (lrypos + gCamMy * SLM_getFocalUnitY() * periody * 0.5 / (gCamPixelSize * 1e6)));

			// draw the line
			CanvasDrawLine(Panel, Canvas, MakePoint(xc, y1), MakePoint(xc, y2));
		}

		// draw horizontal lines indicating the grid
		for (int l = 0; l <= Ny; l++)
		{
			// get the coordinates of the endpoints of the gridline
			int yc = TransformBitmapToCamCanvasY((int) (ulypos + gCamMy * SLM_getFocalUnitY() * (-periody / 2.0 + l * periody) / (gCamPixelSize * 1e6)));
			int x1 = TransformBitmapToCamCanvasX((int) (ulxpos - gCamMx * SLM_getFocalUnitX() * periodx * 0.5 / (gCamPixelSize * 1e6)));
			int x2 = TransformBitmapToCamCanvasX((int) (lrxpos + gCamMx * SLM_getFocalUnitX() * periodx * 0.5 / (gCamPixelSize * 1e6)));

			// draw the line
			CanvasDrawLine(Panel, Canvas, MakePoint(x1, yc), MakePoint(x2, yc));
		}
	}	
}