⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initial.c

📁 基于S3C44B0X开发的一个校园导航系统
💻 C
字号:
///////////////////////////////////////////////////////////////////////////////
// Functions that are called by the --Wnd() functions                        //
///////////////////////////////////////////////////////////////////////////////
#include "Initial.h"

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//Display the finding path result in finding path function
void DisplayResult(PDC pdc,int StartEndPointArray[2],
                    structPOINT PlacePointArray[])
{

	// variable used for displaying path and distance
	int i = 0;
	int m = 0;
	int iDistance = 0;
	U16 UDistance[10];		
	int PathNbr[16];
	int PathLength = 0;

	int a = 0;
	int b = 0;

	// Define and intialize the graph information 
	// which stroes the map information
	Graph newGraph;
	newGraph.Vnum = 15;
	for( a = 0; a < 15;a++)
	{
		for( b = 0; b < 15; b++)
		{
			newGraph.Arcs[a][b] = INFINITY;
		}
	}
	newGraph.Arcs[0][11] = 30;
	newGraph.Arcs[11][0] = 30;
	
	newGraph.Arcs[1][9] = 33;
	newGraph.Arcs[9][1] = 33;
	
	newGraph.Arcs[1][8] = 38;
	newGraph.Arcs[8][1] = 38;

	newGraph.Arcs[2][4] = 39;
	newGraph.Arcs[4][2] = 39;
	
	newGraph.Arcs[2][14] = 12;
	newGraph.Arcs[14][2] = 12;

	newGraph.Arcs[3][14] = 23;
	newGraph.Arcs[14][3] = 23;
	
	newGraph.Arcs[4][6] = 72;
	newGraph.Arcs[6][4] = 72;

	newGraph.Arcs[5][6] = 26;
	newGraph.Arcs[6][5] = 26;

	newGraph.Arcs[6][12] = 61;
	newGraph.Arcs[12][6] = 61;
	
	newGraph.Arcs[7][12] = 23;
	newGraph.Arcs[12][7] = 23;

	newGraph.Arcs[7][11] = 90;
	newGraph.Arcs[11][7] = 90;

	newGraph.Arcs[8][11] = 25;
	newGraph.Arcs[11][8] = 25;

	newGraph.Arcs[9][10] = 26;
	newGraph.Arcs[10][9] = 26;

	newGraph.Arcs[10][13] = 73;
	newGraph.Arcs[13][10] = 73;

	newGraph.Arcs[12][13] = 53;
	newGraph.Arcs[13][12] = 53;
	
	newGraph.Arcs[13][14] = 24;
	newGraph.Arcs[14][13] = 24;

	// Start finding path operation and display the result
	ClearScreen();
	ShowBmp(pdc,"map.bmp",0,0);	
	TextOut(pdc,15,215,UchDistance,TRUE,FONTSIZE_SMALL);

	if( shortestPath( newGraph,StartEndPointArray[0],StartEndPointArray[1],
	                  PathNbr, &PathLength) )
	{
		// Fill the two pointw between which shortest path are required to 
		// found
		FillRect2( pdc,&PointRect[StartEndPointArray[0]],
		            GRAPH_MODE_NORMAL,RGB(0,255,0));
		FillRect2( pdc,&PointRect[StartEndPointArray[1]],
		            GRAPH_MODE_NORMAL,RGB(0,255,0));
		MoveTo(pdc,PlacePointArray[PathNbr[0]].x,PlacePointArray[PathNbr[0]].y);

		// Draw the path
		for(i = 1; i<PathLength - 1; i++)
		{
			SetPenColor(pdc,RGB(0,255,0));
			SetPenWidth(pdc,2);
			LineToDelay( pdc,PlacePointArray[PathNbr[i]].x,
			             PlacePointArray[PathNbr[i]].y,5);
		}

		// Dispaly the distance 
		iDistance = PathNbr[PathLength -1];
		Int2Unicode(iDistance,UDistance);
		TextOut(pdc,70,215,UDistance,TRUE,1);
	}
	return;	
}

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// Create the start point list box used in finding path by list box function
void CreateStartPosList()
{
	structRECT StartPosRect;
	U16 UStartPosName[8][25];
	int i=0;

	// Set the list box position and size
	SetRect(&StartPosRect,5,20,140,200);	
	pStartPosListCtrl = CreateListCtrl( ID_StartPosListBox, &StartPosRect, 
					100,FONTSIZE_MIDDLE,CTRL_STYLE_DBFRAME,NULL);
	SetWndCtrlFocus(NULL, ID_StartPosListBox);
	
	// Add strings into the listctrl
	while(i < 8)
	{
		strChar2Unicode(UStartPosName[i],PosName[i]);
		AddStringListCtrl(pStartPosListCtrl , UStartPosName[i]);
 		i++;
	}

	DrawListCtrl(pStartPosListCtrl);

	return;
}

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// Create the end point list box used in finding path by list box function
void CreateEndPosList()
{
	structRECT EndPosRect;
         
	U16 UEndPosName[8][25];
	int i=0;

	// Set the list box position and size
	SetRect(&EndPosRect,180,20,315,200);	
	pEndPosListCtrl = CreateListCtrl( ID_EndPosListBox, &EndPosRect, 
				       			100,FONTSIZE_MIDDLE,CTRL_STYLE_DBFRAME,NULL);
	SetWndCtrlFocus(NULL, ID_EndPosListBox);
	 
	// Add strings into the listctrl
	while(i < 8)
	{
		strChar2Unicode(UEndPosName[i],PosName[i]);
		AddStringListCtrl(pEndPosListCtrl, UEndPosName[i]);
		i++;	
	}

	DrawListCtrl(pEndPosListCtrl);

	return;
}

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// Create the list box used in watching introduction function
void CreateIntrodList()
{
	structRECT IntrodRect;
  	U16 UStartPosName[8][25];
	int i=0;

	// Set the list box position and size
	SetRect(&IntrodRect,5,20,140,200);	
	pIntrodListCtrl = CreateListCtrl( ID_IntrodListBox, &IntrodRect, 
					100,FONTSIZE_MIDDLE,CTRL_STYLE_DBFRAME,NULL);
	SetWndCtrlFocus(NULL, ID_IntrodListBox);
	
	// Add strings into the listctrl
	while(i < 8)
	{
		strChar2Unicode(UStartPosName[i],PosName[i]);
		AddStringListCtrl(pIntrodListCtrl , UStartPosName[i]);
 		i++;
	}

	DrawListCtrl(pIntrodListCtrl);

	return;
}

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// This function is used in Finding path by using the keyboard choosing points
// function, whose aim is to judge the points choosed by the keyboard 
// and display them.
void LoadChoosedPoint(int PntNbr,int KeyChoosePnt[2], int ChoosePntState[2])
{	
	if(ChoosePntState[0] == 0)
	{
		KeyChoosePnt[0] = PntNbr-1;
		ChoosePntState[0] = 2;
	}
	else if(ChoosePntState[1] == 0)
	{
		KeyChoosePnt[1] = PntNbr-1;
		ChoosePntState[1] = 2;
		ChoosePntState[0] = 1;
	}
	else if(ChoosePntState[0] == 2)
	{
		KeyChoosePnt[1] = PntNbr-1;
		ChoosePntState[1] = 2;
		ChoosePntState[0] = 1;
	}
	else if(ChoosePntState[1] == 2)
	{
		KeyChoosePnt[0] = PntNbr-1;
		ChoosePntState[0] = 2;
		ChoosePntState[1] = 1;
	}
	// Display thyose two choosed points
    if(ChoosePntState[0] != 0)
	{
 		ClearScreen();
 		ShowBmp(pdc,"map.bmp",0,0);
 		TextOut(pdc,15,215,UchDistance,TRUE,FONTSIZE_SMALL);
 		FillRect2(pdc,&PointRect[KeyChoosePnt[0]],GRAPH_MODE_NORMAL,RGB(0,255,0));
 		if(ChoosePntState[1] != 0)
 		{
 			FillRect2(pdc,&PointRect[KeyChoosePnt[1]],GRAPH_MODE_NORMAL,RGB(0,255,0));
 		}
 	}
	return;
}

// over

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -