Beispiel #1
0
int main()
{
    int i, j;
    int d, dev[maxdev]={-1, -1, -1, -1, -1,-1, -1, -1, -1, -1};
    int ndev=0;
    char str[256];
    double y;

    printf("\nG2_VERSION %s\n", G2_VERSION);
    
    d=g2_open_vd();      /* open virtual device */

    printf("Adding..");
    
#ifdef DO_PS
    printf("..PS");
    dev[ndev]=g2_open_PS("g2_arc.ps", g2_A4, g2_PS_land);
    g2_attach(d, dev[ndev]);
    ndev++;
 
    printf("..EPSF");
    dev[ndev]=g2_open_EPSF("g2_arc.eps");
    g2_attach(d, dev[ndev]);
    ndev++;
    printf("..EPSF_CLIP");
    dev[ndev]=g2_open_EPSF_CLIP("g2_arc_clip.eps",400,400);
    g2_attach(d, dev[ndev]);
    ndev++;
#endif
#ifdef DO_FIG
    printf("..FIG");
    dev[ndev]=g2_open_FIG("g2_arc.fig");
    g2_attach(d, dev[ndev]);
    ndev++;
#endif
#ifdef DO_X11
    printf("..X11");
    dev[ndev]=g2_open_X11(400,400);
    g2_attach(d, dev[ndev]);
    ndev++;
#endif
#ifdef DO_GD
    printf("..GD(png)");
    dev[ndev]=g2_open_gd("g2_arc.png", 400, 400,g2_gd_png);
    g2_attach(d, dev[ndev]);
    ndev++;
    printf("..GD(jpeg)");
    dev[ndev]=g2_open_gd("g2_arc.jpg", 400, 400,g2_gd_jpeg);
    g2_attach(d, dev[ndev]);
    ndev++;
#endif
#ifdef DO_WIN32
    printf("..WIN32");
    dev[ndev]=g2_open_win32(400, 400,"g2_arc",0);
    g2_attach(d, dev[ndev]);
    ndev++;
#endif
#ifdef DO_WMF32
    printf("..WMF32");
    dev[ndev]=g2_open_win32(775, 575,"g2_arc.emf",1);
    g2_attach(d, dev[ndev]);
    ndev++;
#endif
    g2_set_auto_flush(d,0);

    printf("\n");

    g2_string(d,10, 50,"90,90");
    g2_string(d,10,100,"90,360");
    g2_string(d,10,150,"90,0");
    g2_string(d,10,200,"360,90");
    g2_string(d,10,250,"-45,45");
    g2_string(d,10,300,"-45,-315");
    g2_string(d,10,350,"-495,-405");

    g2_arc(d, 100,  50, 45, 25, 90, 90);
    g2_arc(d, 100, 100, 45, 25, 90, 360);
    g2_arc(d, 100, 150, 45, 25, 90, 0);
    g2_arc(d, 100, 200, 45, 25, 360, 90);
    g2_arc(d, 100, 250, 45, 25, -45, 45);
    g2_arc(d, 100, 300, 45, 25, -45, -315);
    g2_arc(d, 100, 350, 45, 25, -495, -405);

    g2_filled_arc(d, 100,  50, 40, 20, 90, 90);
    g2_filled_arc(d, 100, 100, 40, 20, 90, 360);
    g2_filled_arc(d, 100, 150, 40, 20, 90, 0);
    g2_filled_arc(d, 100, 200, 40, 20, 360, 90);
    g2_filled_arc(d, 100, 250, 40, 20, -45, 45);
    g2_filled_arc(d, 100, 300, 40, 20, -45, -315);
    g2_filled_arc(d, 100, 350, 40, 20, -495, -405);


    
    g2_string(d,320, 50,"0,0");
    g2_string(d,320,100,"360,90");
    g2_string(d,320,150,"0,90");
    g2_string(d,320,200,"90,360");
    g2_string(d,320,250,"45,-45");
    g2_string(d,320,300,"-315,-45");
    g2_string(d,320,350,"-405,-495");

    g2_arc(d, 250,  50, 45, 25, 0, 0);
    g2_arc(d, 250, 100, 45, 25, 360, 90);
    g2_arc(d, 250, 150, 45, 25, 0, 90);
    g2_arc(d, 250, 200, 45, 25, 90, 360);
    g2_arc(d, 250, 250, 45, 25, 45, -45);
    g2_arc(d, 250, 300, 45, 25, -315, -45);
    g2_arc(d, 250, 350, 45, 25, -405, -495);

    g2_filled_arc(d, 250,  50, 40, 20, 90, 90);
    g2_filled_arc(d, 250, 100, 40, 20, 360, 90);
    g2_filled_arc(d, 250, 150, 40, 20, 0, 90);
    g2_filled_arc(d, 250, 200, 40, 20, 90, 360);
    g2_filled_arc(d, 250, 250, 40, 20, 45, -45);
    g2_filled_arc(d, 250, 300, 40, 20, -315, -45);
    g2_filled_arc(d, 250, 350, 40, 20, -405, -495);

    g2_flush(d);
    printf("\nDone.\n[Enter]\n");
    getchar();
    g2_close(d);
    return 0;
}
Beispiel #2
0
int main()
{
	struct main_data data;
	struct point *tail = 0;
	struct point *start = 0;

	pthread_t t_cockpit = 0, t_fisica = 0, t_graph = 0;

	data.option = -1;
	data.pdev = -1;
	data.vdev = -1;
	data.font_size = 16;
	data.label_value_dist = 10;			/*Define Some variables from main_data*/
	data.window_h = 600;
	data.window_w = 800;
	data.tempo = 0;
	data.radius = 5;
	data.force_t = 0;
	data.force_r = 0;
	data.terminate_cp = 0;


	while(1)										/* Main Loop */
	{
		
		printf("\033[2J");
		printf("\n");
		printf(" 1. Especificação dos dados do módulo e das condições iniciais do voo (Unidades S.I.).\n");
		printf(" 2. Simulação do voo em modo de \"cockpit\".\n");
		printf(" 3. Apresentação em modo gráfico da trajectória do módulo.\n");
		printf(" 4. Definição do perfil  da superfície lunar.\n");
		printf(" 5. Simulação do voo em modo gráfico.\n");
		printf(" 0. Terminar Programa\n");
		printf("\n");
		printf(" Escolha uma opção: ");
		
		if((scanf("%d", &data.option)) < 1){
			printf("Opção Invalida\n");
			__fpurge(stdin);
		}
		
		switch(data.option)
		{
			case 1 :
				spec_input(&data);
				data.option = -1;
				break;
			case 2 :
				if(data.vdev == -1 || data.pdev == -1)
				{
					data.pdev = g2_open_X11(data.window_w, data.window_h);
					data.vdev = g2_open_vd();
					g2_attach(data.vdev, data.pdev);
					strcpy(data.landing_status,"Ready");
				}
				pthread_join(t_cockpit, NULL);
				pthread_join(t_fisica, NULL);
				pthread_join(t_graph, NULL);
				
				pthread_create(&t_cockpit, NULL, &cockpit_display, &data);
				pthread_create(&t_fisica, NULL, &fisica, &data);
				data.option = -1;
				
				break;
			case 3 :
				data.terminate_cp = 1;
				pthread_join(t_cockpit, NULL);
				pthread_join(t_fisica, NULL);
				pthread_join(t_graph, NULL);
				data.terminate_cp = 0;
				
				pthread_create(&t_graph, NULL, &pos_graph, &data);
				data.option = -1;
				break;
			case 4 :
				pthread_join(t_cockpit, NULL);
				pthread_join(t_fisica, NULL);
				pthread_join(t_graph, NULL);
				
				surface_setup(start, tail);
				
				break;
			case 5 :
				printf("\nList Points\n");



				break;
			case 0 :
				g2_detach(data.vdev, data.pdev);
				g2_close(data.pdev);
				exit(0);
			default :
				if(data.vdev != -1 || data.pdev != -1)
					data.pdev = -1; data.vdev = -1;

				break;
		}
		
		usleep(100000);
	}
	
	return 0;
}
Beispiel #3
0
F_REAL FIF(g2_open_x11)(F_REAL *width, F_REAL *height)
{
    return (F_REAL)g2_open_X11(*width, *height);
}