Пример #1
0
//Main Function--------------------------------------------------------------------------------
int main()
{
	srand(time (NULL));
	struct Rectangle RandomRect[MAX_RECTS];
	Rectangle r;
	int NumBoxes,TempNum;
	printf(" How many boxes you want? (max 25): ");
	scanf("%i",&NumBoxes);

	
	
	for (int i=0; i < MAX_RECTS; i++)
	{	
		if (i<NumBoxes)
		{		
			RandomRect[i] = GenRect();	
		} 
		else 
		{		
			RandomRect[i] = 0;
		}
	}
	
	while (true){

		printf("%i",NumBoxes);
		PrintRect(RandomRect, NumBoxes);
		
		switch (menu())
		{
			case '1':
				printf("\n\nEnter The Rectangle Number You'd Like To Write To: ");
				scanf("%i",&TempNum);
				if (TempNum>NumBoxes)
				{
					NumBoxes+=1;
					RandomRect[NumBoxes-1]=ManualRect();
				} else {				
					RandomRect[TempNum-1]=ManualRect();
				}
				break;
			case '2':
				printf("\n\nEnter The Rectangle Number You'd Like To Delete: ");
				scanf("%i",&TempNum);
				for (int i=0; i < (NumBoxes); i++)
				{
					RandomRect[TempNum-2+i]=RandomRect[TempNum-1+i];
				}
				NumBoxes-=1;
				break;
			default:
				printf("\n Either Invalid Selection or Not yet implemented feature :(");
		
		}
	
		getch();
		}
		
		getch();
	return 0;
}
Пример #2
0
void UIOS::OnCreate()
{
	//
	SetCB_View_ShowMsg( View0 );
	SetCB_View_ShowOSWaveLenList( View5 );
	SetCB_View_ShowOSOutPutPMList( View6 );

	PCB_View_ShowMsg = View0;
	PCB_View_ShowKB = View101;
	PCB_View_ShowResistance = View102;
	PCB_View_ShowVerifyKB = View103;

	//
	string str;


	_tabX1.Create( 0, this, _clientRC, UILayoutCalc::SIZE_X|UILayoutCalc::SIZE_Y );
	_tabX1.HideTab();
	_tabX1.SetCellNum( 2 );
	_tabX1.SetCell( 0, "定标", &_canvas1 );
	_tabX1.SetCell( 1, "监视", &_canvas2 );
	_tabX1.SetCurCell( 0 );

	_canvas1.CreateDirect( &_tabX1 );

	_but1.Create( 101, &_canvas1 );
	_but1.SetString( "获取采样值" );
	_but2.Create( 102, &_canvas1 );
	_but2.SetString( "获取功率值" );
	_but3.Create( 103, &_canvas1 );
	_but3.SetString( "打开光源" );
	_but4.Create( 104, &_canvas1 );
	_but4.SetString( "关闭光源" );
	_but5.Create( 105, &_canvas1 );
	_but5.SetString( "读取波长" );
	_but6.Create( 106, &_canvas1 );
	_but6.SetString( "设置波长" );
	_but7.Create( 107, &_canvas1 );
	_but7.SetString( "读取出光功率" );
	_but8.Create( 108, &_canvas1 );
	_but8.SetString( "获取电流、电阻值" );
	_but9.Create( 109, &_canvas1 );
	_but9.SetString( "计算KB" );
	_but10.Create( 110, &_canvas1 );
	_but10.SetString( "设置定标数据" );
	_but11.Create( 111, &_canvas1 );
	_but11.SetString( "验证定标数据" );
	_but12.Create( 112, &_canvas1 );
	_but12.SetString( "写数据库" );
	_but13.Create( 113, &_canvas1 );
	_but13.SetString( "读数据库" );

	_grid1.Create( 0, &_canvas1, GenRect()( 280, 20, 480, 400 ) );
	_grid1.SetRowColumn( 18, 3 );
	_grid1.SetRowFix();
	_grid1.SetColumnFix();
	_grid1.SetColumnWidth( 0, 50 );
	_grid1.SetColumnWidth( 1, 70 );
	_grid1.SetCellString( 0, 0, "序号" );
	_grid1.SetCellString( 0, 1, "出光功率" );
	_grid1.SetCellString( 0, 2, "波长" );
	_grid1.SetCellString( 1, 0, "端口数" );
	for( int i=0; i<16; ++i )
	{
		STRING_FORMAT( str, "%d", i+1 );
		_grid1.SetCellString( i+2, 0, str );
	}

	_grid2.Create( 0, &_canvas1 );
	_grid2.SetRowColumn( 3, 2 );
	_grid2.SetRowFix();
	_grid2.SetColumnFix();
	_grid2.SetColumnWidth( 1, 80 );
	_grid2.SetColumnWidth( 2, 80 );
	_grid2.SetCellString( 0, 0, "序号" );
	_grid2.SetCellString( 1, 0, "K" );
	_grid2.SetCellString( 2, 0, "B" );

	_grid3.Create( 0, &_canvas1 );
	_grid3.SetRowColumn( 4, 4 );
	_grid3.SetRowFix();
	_grid3.SetColumnFix();
	_grid3.SetColumnWidth( 0, 90 );
	_grid3.SetColumnWidth( 1, 90 );
	_grid3.SetCellString( 0, 0, "项" );
	_grid3.SetCellString( 0, 1, "k值" );
	_grid3.SetCellString( 0, 2, "当前值" );
	_grid3.SetCellString( 0, 3, "告警阈值" );
	_grid3.SetCellString( 1, 0, "驱动电流(mA)" );
	_grid3.SetCellString( 2, 0, "背光电流(uA)" );
	_grid3.SetCellString( 3, 0, "电阻值(欧姆)" );
	_grid3.SetCellString( 1, 3, "100" );
	_grid3.SetCellString( 2, 3, "1000" );
	_grid3.SetCellString( 3, 3, "1000" );
	_grid3.SetCellString( 1, 1, OSLogic::GetSingleton()->k1[0] );
	_grid3.SetCellString( 2, 1, OSLogic::GetSingleton()->k1[1] );

	_grid4.Create( 0, &_canvas1 );
	_grid4.SetRowColumn( 3, 4 );
	_grid4.SetRowFix();
	_grid4.SetColumnFix();
	_grid4.SetCellString( 0, 0, "点" );
	_grid4.SetCellString( 0, 1, "读取值" );
	_grid4.SetCellString( 0, 2, "参考值" );
	_grid4.SetCellString( 0, 3, "差值" );
	_grid4.SetCellString( 1, 0, "1" );
	_grid4.SetCellString( 2, 0, "2" );

	_check1.Create( 121, &_canvas1 );
	_check1.SetString( "cyoptics" );
	_check1.SetCheck( true );
	_check2.Create( 122, &_canvas1 );
	_check2.SetString( "accelink" );
	UISetCheckButtonMutex( &_check1, &_check2 );

	_lable1.Create( 0, &_canvas1 );
	_lable1.SetString( "Step 1:" );
	_lable1.SetColor( _BLUE_ );
	_lable2.Create( 0, &_canvas1 );
	_lable2.SetString( "Step 2:" );
	_lable2.SetColor( _BLUE_ );
	_lable3.Create( 0, &_canvas1 );
	_lable3.SetString( "Step 3:" );
	_lable3.SetColor( _BLUE_ );
	_lable4.Create( 0, &_canvas1 );
	_lable4.SetString( "Step 4:" );
	_lable4.SetColor( _BLUE_ );
	_lable5.Create( 0, &_canvas1 );
	_lable5.SetString( "( 端口值=端口X功率-端口1功率 )自动计算差值,只填写功率值." );
	_lable6.Create( 0, &_canvas1 );
	_lable6.SetString( "设备SN号:" );

	_edit1.Create( 0, &_canvas1 );
	

	_canvas2.CreateDirect( &_tabX1 );
	//
	//
	_but21.Create( 21, &_canvas2 );
	_but21.SetString( "开始监视" );
	_but22.Create( 22, &_canvas2 );
	_but22.SetString( "停止监视" );
	_but23.Create( 23, &_canvas2 );
	_but23.SetString( "读取最大最小值" );
	_but24.Create( 24, &_canvas2 );
	_but24.SetString( "添加设备" );
	_but25.Create( 25, &_canvas2 );
	_but25.SetString( "删除选中设备" );
	_but26.Create( 26, &_canvas2 );
	_but26.SetString( "清除所有设备" );
	//
	_lable21.Create( 0, &_canvas2 );
	_lable21.SetString( "注意:设备IP地址需与主机位于同一网段内.." );
	_edit21.Create( 0, &_canvas2 );
	_grid21.Create( 0, &_canvas2 );
	_grid21.SetRowColumn( 1, 5 );
	_grid21.SetRowFix();
	_grid21.SetColumnFix();
	_grid21.SetCellString( 0, 0, "序号" );
	_grid21.SetColumnWidth( 0, 100 );
	_grid21.SetCellString( 0, 1, "IP地址" );
	_grid21.SetColumnWidth( 1, 150 );
	_grid21.SetCellString( 0, 2, "监测标志" );
	_grid21.SetColumnWidth( 2, 120 );
	_grid21.SetCellString( 0, 3, "MAX" );
	_grid21.SetColumnWidth( 3, 120 );
	_grid21.SetCellString( 0, 4, "MIN" );
	_grid21.SetColumnWidth( 4, 120 );


	_layoutGrid1.InitPoint( GenPoint()( 20, 20 ) );
	_layoutGrid1.SetRowColumn( 10, 2 );
	for( int r=0; r<10; ++r )
		_layoutGrid1.SetRowHeightInterval( r, 50 );
	//
	_layoutGrid1.SetCell( 0, 0, &_but1 );
	_layoutGrid1.SetCell( 0, 1, &_but2 );
	_layoutGrid1.SetCell( 1, 0, &_but3 );
	_layoutGrid1.SetCell( 1, 1, &_but4 );
	_layoutGrid1.SetCell( 3, 0, &_but5 );
	_layoutGrid1.SetCell( 3, 1, &_but6 );
	_layoutGrid1.SetCell( 4, 0, 4, 1, &_but7 );
	_layoutGrid1.SetCell( 7, 0, 7, 1, &_but8 );
	//
	_layoutGrid1.CalcGridPos();

	_layoutGrid2.InitPoint( GenPoint()( 280, 450 ) );
	_layoutGrid2.SetRowColumn( 4, 3 );
	//
	_layoutGrid2.SetCell( 0, 0, &_check1 );
	_layoutGrid2.SetCell( 0, 1, &_check2 );
	_layoutGrid2.SetCell( 1, 0, 3, 2, &_grid3 );
	//
	_layoutGrid2.CalcGridPos();


	_layoutGrid3.InitPoint( GenPoint()( 500, 20 ) );
	_layoutGrid3.SetRowColumn( 10, 4 );
	_layoutGrid3.SetColumnWidthInterval( 0, 60 );
	_layoutGrid3.SetColumnWidthInterval( 1, 120 );
	_layoutGrid3.SetColumnWidthInterval( 2, 120 );
	_layoutGrid3.SetColumnWidthInterval( 3, 120 );
	//
	_layoutGrid3.SetCell( 0, 0, &_lable1 );
	_layoutGrid3.SetCell( 0, 1, &_but9 );
	_layoutGrid3.SetCell( 0, 2, 1, 3, &_grid2 );
	_layoutGrid3.SetCell( 2, 0, 2, 3, &_lable5 );
	_layoutGrid3.SetCell( 3, 0, &_lable2 );
	_layoutGrid3.SetCell( 3, 1, &_but10 );
	_layoutGrid3.SetCell( 4, 0, &_lable3 );
	_layoutGrid3.SetCell( 4, 1, &_but11 );
	_layoutGrid3.SetCell( 4, 2, 5, 3, &_grid4 );
	_layoutGrid3.SetCell( 6, 0, &_lable4 );
	_layoutGrid3.SetCell( 6, 1, &_but12 );
	_layoutGrid3.SetCell( 6, 2, &_but13 );
	_layoutGrid3.SetCell( 7, 1, &_lable6 );
	_layoutGrid3.SetCell( 7, 2, &_edit1 );
	//
	_layoutGrid3.CalcGridPos();	

	_layoutGrid4.InitPoint( GenPoint()( 20, 20 ) );
	_layoutGrid4.SetRowColumn( 12, 8 );
	//
	_layoutGrid4.SetCell( 0, 0, 0, 5, &_lable21 );
	_layoutGrid4.SetCell( 1, 0, 8, 5, &_grid21 );
	_layoutGrid4.SetCell( 9, 0, 10, 1, &_but21 );
	_layoutGrid4.SetCell( 9, 2, 10, 3, &_but22 );
	_layoutGrid4.SetCell( 9, 4, 10, 5, &_but23 );
	_layoutGrid4.SetCell( 1, 6, 2, 7, &_but24 );
	_layoutGrid4.SetCell( 3, 6, 3, 7, &_edit21 );
	//_layoutGrid4.SetCell( 5, 6, 6, 7, &_but25 );
	_layoutGrid4.SetCell( 7, 6, 8, 7, &_but26 );
	//
	_layoutGrid4.CalcGridPos();
}
Пример #3
0
//Main Function--------------------------------------------------------------------------------
int main()
{
	srand(time (NULL));
	struct Rectangle RandomRect[MAX_RECTS];
	Rectangle r;
	bool Run = true;
	int NumBoxes= 100;
	int TempNum,TempNum2,TempNum3;
	
	//How many you want?
	while (NumBoxes>25)
	{
	printf(" How many boxes you want? (max 25): ");
	scanf("%i",&NumBoxes);
	}
	
	//Initialize Boxes
	for (int i=0; i < MAX_RECTS; i++)
	{	
		RandomRect[i] = GenRect();		
	}
	
	//Main Run Loop
	while (Run=true)
	{

		printf("%i",NumBoxes);
		PrintRect(RandomRect, NumBoxes);
		
		switch (menu())
		{
			case '1':
				printf("\n\nEnter the rectangle number you'd like to write to: ");
				scanf("%i",&TempNum);
				if (TempNum>NumBoxes)
				{
					NumBoxes+=1;
					RandomRect[NumBoxes-1]=ManualRect();
				} else {				
					RandomRect[TempNum-1]=ManualRect();
				}
				break;
				
			case '2':
				printf("\n\nEnter the rectangle number you'd like to delete: ");
				scanf("%i",&TempNum);
				for (int i=0; i < (NumBoxes); i++)
				{
					RandomRect[TempNum-2+i]=RandomRect[TempNum-1+i];
				}
				NumBoxes-=1;
				break;
				
			case '3':
				printf("\n\nEnter the first rectangle to compare: ");
				scanf("%i",&TempNum);
				printf("\n\nEnter the second rectangle to compare: ");
				scanf("%i",&TempNum2);
				Intersection(RandomRect[TempNum-1],RandomRect[TempNum2-1]);
				break;
				
			case '6':
				printf("\n\nEnter the X coodinate: ");
				scanf("%i",&TempNum);
				printf("\n\nEnter the X coodinate: ");
				scanf("%i",&TempNum2);
				printf("\n\nEnter the rectangle to compare: ");
				scanf("%i",&TempNum3);
				
				printf("\n%s",PointWithin(RandomRect[TempNum3],TempNum,TempNum2))
				
			case '7':
				Run=false;
				break;
				
			default:
				printf("\n Either invalid selection or not yet implemented feature :(");		
		}
	
	}
		
	getch();
	return 0;
}