Beispiel #1
0
void on_button1_button_press_event(GtkButton *button, GdkEventButton *event)
{
	GdkEventButton *mouseevent = (GdkEventButton *)event; 
	if(mainmenu == NULL)
		mainmenu = create_mainmenu ();
	gtk_menu_popup(GTK_MENU(mainmenu), NULL, NULL, NULL, NULL, mouseevent->button, mouseevent->time);
}
Beispiel #2
0
/* show calculated bc */
static void show_calc_bc(void) {
  
float dist, vel;
int i,j,x,y;

  /* setup background */
  titlewindowbg();

  /* calculate trajectory of default bullet */
  bullet.bc = 1.0;
  firearm.v0 = calc_bc_param.v0;
  firearm.angle = 0.0;
  wind.x = wind.y = wind.z = 0.0;
  calctraj();

  /* find distance */
  dist = calc_bc_param.x1 - calc_bc_param.x0;
  if(calcparam.units == ENGLISH)
    dist *= 3.0;

  /* find standard velocity at distance */
  j = 1;
  while ( j < calcparam.nstep && drop_array[1][j] < dist)
    j++;

  vel = linint(drop_array[1][j-1],drop_array[0][j-1],drop_array[1][j],drop_array[0][j],dist);

  /* calculate bc & free memory */
  bullet.bc = (calc_bc_param.v0 - vel) / (calc_bc_param.v0 - calc_bc_param.v1);
  freetraj();

  /* print BC */
  y = LINES/2;
  x = (COLS - strlen(calc_bc_results) - 5) / 2;
  mvprintw(y,x,"%s %.3f",calc_bc_results,bullet.bc);

  refresh();

  /* wait for 'q' */
  i = TRUE;
  while(i==TRUE) {
    j = getch();
    switch (j) {
      case 27:	/* ESC */
      case 'q':
        i = FALSE;
      default:
      break;
    }
  }

  /* setup screen for return to main loop */
  create_mainmenu();
  return;

}
Beispiel #3
0
int main(int argc, char *argv[], char **envp)
{
	gEnvion = envp;
	// Connect to AxWin3 Server
	AxWin3_Connect(NULL);

	// TODO: Register to be told when the display layout changes
	AxWin3_GetDisplayDims(0, NULL, NULL, &giScreenWidth, &giScreenHeight);
	
	create_sidebar();
	create_mainmenu();
	create_run_dialog();
	
	AxWin3_RegisterAction(gSidebar, "Interface>Run", (tAxWin3_HotkeyCallback)mainmenu_run_dialog);
	AxWin3_RegisterAction(gSidebar, "Interface>Terminal", (tAxWin3_HotkeyCallback)mainmenu_app_terminal);
	AxWin3_RegisterAction(gSidebar, "Interface>TextEdit", (tAxWin3_HotkeyCallback)mainmenu_app_textedit);

	// Idle loop
	AxWin3_MainLoop();
	
	return 0;
}
Beispiel #4
0
/* trajectory results window */
void results_pad(void) {

    int j, padrows=0, padcols=0, row;
    float i,t,Vx,x,Vy,y,Vz,z,V,E,M,path,conv;
    float zero, drop;
    int start_y,start_x,end_x,end_y;

    /* setup background */
    calcwindowbg();

    /* determine pad length */
    for(i=printparam.start; i<=printparam.end; i+=printparam.step)
        padrows++;

    padcols = strlen(calc_headings)+1;

    /* create pad window */
    sub_window = newpad(padrows,padcols);

    keypad(sub_window,TRUE); /* enable keypad */
    wattrset(sub_window,COLOR_PAIR(MENU_PAIR)); /* setup colors */
    wbkgdset(sub_window,COLOR_PAIR(MENU_PAIR));
    werase(sub_window);	/* erase and color window */

    /* calculate trajectory */
    calctraj();

    /* conversion factor for elevation angle
       converts line of sight distance to horizontal distance
       so the path values are reported relative to line of sight,
       not horizontal distance */
    conv = cos((firearm.angle*M_PI)/180.0);

    /* write results */
    row = 0;
    for (i = printparam.start, j = 0; i <= printparam.end; i += printparam.step) {

        if(calcparam.units == ENGLISH) i *= 3.0;  /* convert yards to feet */

        /* get the zero data */
        while (j < calcparam.nstep && zero_array[1][j] < i) j++;
        t = linint(zero_array[1][j - 1], time_points[j - 1], zero_array[1][j], time_points[j], i);
        zero = linint(time_points[j - 1], zero_array[3][j - 1], time_points[j], zero_array[3][j], t);

        /* get the drop data */
        j = 0;
        while (j < calcparam.nstep && drop_array[1][j] < i) j++;
        t = linint(drop_array[1][j - 1], time_points[j - 1], drop_array[1][j], time_points[j], i);
        drop = linint(time_points[j - 1], drop_array[3][j - 1], time_points[j], drop_array[3][j], t);

        /* get the path data */
        /* path is reported according to line of sight distance, not
           horizontal distance */
        j = 0;
        while (j < calcparam.nstep && velpos_array[1][j] < i ) j++;
        t = linint(velpos_array[1][j - 1], time_points[j - 1], velpos_array[1][j], time_points[j], i * conv);
        Vx = linint(time_points[j - 1], velpos_array[0][j - 1], time_points[j], velpos_array[0][j], t);
        x = linint(time_points[j - 1], velpos_array[1][j - 1], time_points[j], velpos_array[1][j], t);
        Vy = linint(time_points[j - 1], velpos_array[2][j - 1], time_points[j], velpos_array[2][j], t);
        y = linint(time_points[j - 1], velpos_array[3][j - 1], time_points[j], velpos_array[3][j], t);
        Vz = linint(time_points[j - 1], velpos_array[4][j - 1], time_points[j], velpos_array[4][j], t);
        z = linint(time_points[j - 1], velpos_array[5][j - 1], time_points[j], velpos_array[5][j], t);
        V = sqrt(Vx*Vx + Vy*Vy + Vz*Vz);

        /* take care of elevation angle as the velpos_array coordinates are
           based on the horizontal, not the line of sight */
        path = y - x * tan((firearm.angle*M_PI)/180.0);

        /* unit conversions */
        if(calcparam.units == METRIC) {
            E = .5 * V * V * bullet.weight / 1000.0 / 1000.0;
            M = V * bullet.weight / 1000.0;
        }
        else {
            E = .5 * V * V * bullet.weight / 7000.0 / G_E;
            M = V * bullet.weight / 7000.0;
            x /= 3.0; /* feet to yards */
            path *= 12.0; /* feet to inches */
            z *= 12.0; /* feet to inches */
            drop *= 12.0; /* feet to inches */
            zero *= 12.0; /* feet to inches */
        }

        /*	12345678901234567890123456789012345678901234567890 */
        mvwprintw(sub_window,row,0,"%5.0f %8.1f  %7.2f %8.2f %7.2f %7.2f %7.2f %6.2f %5.1f",
                  x,V,E,M,path,zero,drop,z,t);
        row++;
        if(calcparam.units == ENGLISH)
            i = i / 3.0;  /* back to yards */
        if (j >= calcparam.nstep)
            break;
    }

    /* display the pad */
    start_x = (COLS - strlen(calc_headings)) / 2;
    start_y = 10;
    end_x = start_x + padcols;
    end_y = LINES - 4;
    prefresh(sub_window,0,0,start_y,start_x,end_y,end_x);

    results_pad_handler(padrows,start_y,start_x,end_y,end_x);

    /* free trajectory arrays */
    freetraj();

    /* setup everything for return to main loop */
    delwin(sub_window);
    create_mainmenu();
    return;

}