Example #1
0
int tiger()
{
  int argc;
  char **argv;
  //Initial windows(glut) and some gl projection
  testInit(argc, argv, 320 ,480, "ShivaVG: Tiger SVG Test");

#ifdef USE_GL
  //callbacks[type] = func
  testCallback(TEST_CALLBACK_CLEANUP, (CallbackFunc)cleanup);
  testCallback(TEST_CALLBACK_DISPLAY, (CallbackFunc)display);
  testCallback(TEST_CALLBACK_KEY, (CallbackFunc)key);
  testCallback(TEST_CALLBACK_BUTTON, (CallbackFunc)click);
  testCallback(TEST_CALLBACK_DRAG, (CallbackFunc)drag);
#endif //USE_GL
  
  time_t stime, etime;
  double tpp;
  double fps;

	loadTiger();
	display(0.05);

#ifdef USE_GL 
  testOverlayString("Press H for a list of commands");
  testRun();
#endif //USE_GL

  return EXIT_SUCCESS;
}
Example #2
0
int main(int argc, char **argv)
{
  testInit(argc, argv, 400,400, "ShivaVG: Radial Gradient Test");
  testCallback(TEST_CALLBACK_DISPLAY, (CallbackFunc)display);
  testCallback(TEST_CALLBACK_BUTTON, (CallbackFunc)click);
  testCallback(TEST_CALLBACK_DRAG, (CallbackFunc)drag);
  testCallback(TEST_CALLBACK_KEY, (CallbackFunc)key);
  
  p = testCreatePath();
  center = testCreatePath();
  focus = testCreatePath();
  radius = testCreatePath();
  
  cx = testWidth()/2;
  cy = testHeight()/2;
  fx = cx;
  fy = cy;
  r = sqx/2;
  
  radialFill = vgCreatePaint();
  blackFill = vgCreatePaint();
  vgSetParameterfv(blackFill, VG_PAINT_COLOR, 4, black);
  
  createSquare(p);
  createRadial();
  
  testOverlayString("Press H for a list of commands");
  testOverlayColor(1,1,1,1);
  testRun();
  
  return EXIT_SUCCESS;
}
Example #3
0
int main(int argc, char **argv)
{
  testInit(argc, argv, 400,400, "ShivaVG: Linear Gradient Test");
  testCallback(TEST_CALLBACK_DISPLAY, (CallbackFunc)display);
  testCallback(TEST_CALLBACK_BUTTON, (CallbackFunc)click);
  testCallback(TEST_CALLBACK_DRAG, (CallbackFunc)drag);
  testCallback(TEST_CALLBACK_KEY, (CallbackFunc)key);
  testCallback(TEST_CALLBACK_RESHAPE, (CallbackFunc)reshape);
  
  p = testCreatePath();
  org = testCreatePath();
  
  blackFill = vgCreatePaint();
  vgSetParameterfv(blackFill, VG_PAINT_COLOR, 4, black);
  
  backImage = createImageFromJpeg(IMAGE_DIR"test_img_violin.jpg");
  patternImage = createImageFromJpeg(IMAGE_DIR"test_img_shivavg.jpg");
  patternFill = vgCreatePaint();
  
  createSquare(p);
  createOrigin(org);
  createPattern();
  
  testOverlayString("Press H for a list of commands");
  testOverlayColor(1,1,1,1);
  testRun();
  
  return EXIT_SUCCESS;
}
Example #4
0
int main(int argc, char **argv)
{
  testInit(argc, argv, 500,500, "ShivaVG: VGU Primitives Test");
  testCallback(TEST_CALLBACK_DISPLAY, (CallbackFunc)display);
  
  createPrimitives();
  testRun();
  
  return EXIT_SUCCESS;
}
void testsReception(void) {
	testInit();
	testRun();
}
Example #6
0
//
//  函数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的: 处理主窗口的消息。
//
//  WM_COMMAND	- 处理应用程序菜单
//  WM_PAINT	- 绘制主窗口
//  WM_DESTROY	- 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	//TCHAR text[ ] = _T("Hello World!");
	RECT		rect;
	static bool bMulti;
	float* pImg = NULL;

	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// 分析菜单选择:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;

		case ID_SINGLE:
			bMulti = false;
			testRun( false );
			InvalidateRect(hWnd, NULL, TRUE);
			break;

		case ID_MULTI:
			bMulti = true;
			testRun( true );
			InvalidateRect(hWnd, NULL, TRUE);
			break;

		case ID_STAT_TIME:
			printTime( bMulti );
			InvalidateRect(hWnd, NULL, TRUE);
			break;

		case ID_RESET:
			reset();
			InvalidateRect(hWnd, NULL, TRUE);
			break;

		case ID_ACCUMULATE:
			mv.accumulate();
			InvalidateRect(hWnd, NULL, TRUE);
			break;

		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: 在此添加任意绘图代码...
		//TextOut(hdc, 0, 0, resultTest.c_str(), resultTest.size() );//  TextOut参考:http://msdn.microsoft.com/en-us/library/dd145133(VS.85).aspx  _tcslen参考:http://www.codeproject.com/Articles/76252/What-are-TCHAR-WCHAR-LPSTR-LPWSTR-LPCTSTR-etc
#if OUTPUT_TEXT_OR_IMAGE
		GetClientRect( hWnd, &rect );
		for (int i=0;i<resultString.size(); i++)
		{
			rect.left = i*rect.right/resultString.size();
			DrawText(hdc, resultString[i].c_str(), resultString[i].size() , &rect ,0);
		}
#else

		pImg = mv.getOutput();
		if (pImg)
		{
			int nStride = SIZE_WIDTH/ (1<<6);

			int xOffset = 1000 ;
			int yOffset = xOffset/2.0f;
			float nScale = SIZE_WIDTH/ (float)(1<<8);
			for ( int i=0;i<SIZE_HEIGHT-nStride;i+= nStride )
			{
				for (int j=0;j<SIZE_WIDTH-nStride;j+= nStride )
				{
					float * pCurrent = pImg + ((i*SIZE_WIDTH)+j)*ELEMENT_COUNT_POINT;
					int px1 = (int)*( pCurrent )/nScale;
					int py1 = (int)*( ++pCurrent )/nScale;
					MoveToEx( hdc, px1+xOffset, py1+yOffset, NULL );

					pCurrent = pImg + ((i*SIZE_WIDTH)+j+nStride)*ELEMENT_COUNT_POINT;
					int px2 = (int)*( pCurrent )/nScale;
					int py2 = (int)*( ++pCurrent )/nScale;
					LineTo(hdc, px2+xOffset, py2+yOffset );
					
					MoveToEx( hdc, (int)px1+xOffset, (int)py1+yOffset, NULL );

					pCurrent = pImg + (((i+nStride)*SIZE_WIDTH)+j)*ELEMENT_COUNT_POINT;
					int px3 = (int)*( pCurrent )/nScale;
					int py3 = (int)*( ++pCurrent )/nScale;
					LineTo(hdc, px3+xOffset, py3+yOffset );
				}
			}


		}
		
#endif
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Example #7
0
int main(int argc, char *argv[])
{
    if (argc <= 1)
    {
        std::cout << "Error: Please inform options and filename." << std::endl;
        printHelp(argv[0]);
        return 1;
    }

    std::string option = argv[1];

    if (option == "--test")
    {
        testRun();
        return 0;
    }

    if (option == "--help")
    {
        printHelp(argv[0]);
        return 0;
    }

    tsp::TSPLibData data;
    std::ifstream file(argv[2]);

    if (!file.is_open())
    {
        std::cout << "Error: cannot open file." << std::endl;
        printHelp(argv[0]);
        return 0;
    }

    data.load(file);

    if (option == "--only-constructive")
    {
        tsp::TSPNearestNeighborConstruct nn(data);
        tsp::TSPTour tour = nn.run();

        if (tour.isValid())
        {
            tour.print(std::cout);
        }
        return 0;
    }

    if (option == "--localsearch")
    {
        tsp::TSPNearestNeighborConstruct nn(data);
        tsp::TSPTour tour = nn.run();

        tsp::TSP2opt local(data, tour);
        tour = local.run();

        if (tour.isValid())
        {
            tour.print(std::cout);
        }
        return 0;
    }

    if (option == "--grasp")
    {
        tsp::TSPGrasp grasp(data, 100);
        tsp::TSPTour tourGrasp = grasp.run();

        if ( tourGrasp.isValid() )
        {
            tourGrasp.print(std::cout);
        }
        return 0;
    }

    if (option == "--tabu")
    {
        tsp::TSPTabu tabu(data, 100, 10, 10);
        tsp::TSPTour tourTabu = tabu.run();

        if ( tourTabu.isValid() )
        {
            tourTabu.print(std::cout);
        }
        return 0;
    }

    return 0;
}