Exemplo n.º 1
0
Arquivo: unitconv.c Projeto: adsr/agar
static void
CreateUI(void)
{
	const struct {
		const char *name;
		const AG_Unit *p;
	} units[] = {
		{ "Len", agLengthUnits },
		{ "Ang", agAngleUnits },
		{ "Mass", agMassUnits },
		{ "Area", agAreaUnits },
		{ "Vol", agVolumeUnits },
		{ "Spd", agSpeedUnits },
		{ "Time", agTimeUnits },
		{ "Temp", agTemperatureUnits },
		{ "Pwr", agPowerUnits },
		{ "Press", agPressureUnits },
		{ "Vac", agVacuumUnits },
		{ "Met", agMetabolicExpenditureUnits },
	};
	int i;
	AG_Window *win;
	AG_Toolbar *tb;

	win = AG_WindowNew(0);
	AG_WindowSetCaption(win, "Unit Converter");
	AG_WindowSetPadding(win, 10, 10, 10, 10);

	tb = AG_ToolbarNew(win, AG_TOOLBAR_HORIZ, 2, AG_TOOLBAR_HOMOGENOUS|
	                                             AG_TOOLBAR_STICKY|
						     AG_TOOLBAR_HFILL);

	for (i = 0; i < sizeof(units)/sizeof(units[0]); i++) {
		if (i == 6) {
			AG_ToolbarRow(tb, 1);
		}
		AG_ToolbarButton(tb, units[i].name, (i == 0),
		    SelectCategory, "%p", units[i].p);
	}

	AG_SeparatorNewHoriz(win);

	n1 = AG_NumericalNewS(win, AG_NUMERICAL_HFILL, "in", "Value: ");
	n2 = AG_NumericalNewS(win, AG_NUMERICAL_HFILL, "mm", "Value: ");
	AG_BindDouble(n1, "value", &value);
	AG_BindDouble(n2, "value", &value);
	AG_NumericalSizeHint(n1, "0000.00");
	AG_NumericalSizeHint(n2, "0000.00");
	AG_NumericalSetPrecision(n1, "g", 6);
	AG_NumericalSetPrecision(n2, "g", 6);

	AG_WindowShow(win);
}
Exemplo n.º 2
0
static void OnConfigMenuScreen(struct gui_disp *cfg, AG_NotebookTab *parent)
{
	AG_Radio *radio;
	AG_Checkbox *check;
	AG_Numerical *fps;
	AG_Box *box;
	AG_Box *box2;
        AG_Combo *combo;
        AG_TlistItem *TlistItem[RENDERING_END];
	int i;
	int limit;
	
	box = AG_BoxNewHoriz(AGWIDGET(parent), AG_BOX_VFILL);
	{
		radio = AG_RadioNewFn(AGWIDGET(box), 0, ScreenSizeName, OnChangeScreenReso, "%p", cfg);
		limit = sizeof(ScreenSizeHeight) / sizeof(WORD);
		for(i = 0; i <= limit; i++){
		  if((ScreenSizeWidth[i] == cfg->uWidth) && (ScreenSizeHeight[i] == cfg->uHeight)) break;
		}
		if(i >= limit) i = 2;
		AG_SetInt(radio, "value", i);
		box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_HFILL);
		fps = AG_NumericalNewS(AGWIDGET(box), AG_NUMERICAL_HFILL, NULL ,gettext("Display rate"));
		AG_BindUint16(fps, "value", &(cfg->nDrawFPS));
		{
		  AG_SetInt(fps, "min", 2);
		  AG_SetInt(fps, "max", 75);
		  AG_SetInt(fps, "inc", 1);
		}

		fps = AG_NumericalNewS(AGWIDGET(box), AG_NUMERICAL_HFILL, NULL ,gettext("Emulation rate"));
		AG_BindUint16(fps, "value", &(cfg->nEmuFPS));
		{
		  AG_SetInt(fps, "min", 2);
		  AG_SetInt(fps, "max", 75);
		  AG_SetInt(fps, "inc", 1);
		}

	   
		box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL);
		combo = AG_ComboNewS(AGWIDGET(box2), AG_COMBO_SCROLLTOSEL | AG_COMBO_HFILL, gettext("Rendering Method"));
	        AG_ComboSizeHint(combo, "XXXXXXXXXXXXXX", RENDERING_END); 
	        TlistItem[0] = AG_TlistAddPtrHead(combo->list, NULL, gettext("Full Draw"),   (void *)&RenderMethodsList[0]);
	        TlistItem[1] = AG_TlistAddPtr(combo->list,     NULL, gettext("Diff Block"),  (void *)&RenderMethodsList[1]);
	        TlistItem[2] = AG_TlistAddPtr(combo->list,     NULL, gettext("Diff Raster"), (void *)&RenderMethodsList[2]);
	        for(i = RENDERING_FULL; i < RENDERING_END; i++) {
		   if(i == cfg->nRenderMethod) {
			AG_ComboSelect(combo, TlistItem[i]);
		   }
		}
		AG_SetEvent(combo, "combo-selected", RenderMethodSelected, "%p", cfg);
	   
		box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL);
		check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("Full Scan (15KHz)"), &(cfg->bFullScan));
		box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL);
		check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("SMOOSING"), &(cfg->bSmoosing));
		box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL);
		check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("Use OpenCL(Need REBOOT)"), &(cfg->bUseOpenCL));
		box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL);
		check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("Use SIMD instructions(Need REBOOT)"), &(cfg->bUseSIMD));
	}
}
Exemplo n.º 3
0
static int
TestGUI(void *obj, AG_Window *win)
{
	M_Plotter *plt;
	AG_Pane *pane;
	AG_Numerical *num;
	AG_Box *box;
	int i;

	pane = AG_PaneNew(win, AG_PANE_HORIZ, AG_PANE_EXPAND);
	{
		/* Create our plotter widget */
		plt = M_PlotterNew(pane->div[1], M_PLOTTER_EXPAND);

		/*
		 * Create the velocity plot item. This is what our algorithm
		 * computes.
		 */
		plVel = M_PlotNew(plt, M_PLOT_LINEAR);
		M_PlotSetLabel(plVel, "m/s");
		M_PlotSetYoffs(plVel, -45);
		M_PlotSetScale(plVel, 0.0, 50.0);

		/* Create a label we will use to show the "case". */
		plblCase = M_PlotLabelNew(plVel, M_LABEL_OVERLAY, 0, 16, "-");

		/* Plot the derivative of the velocity (the acceleration). */
		plAcc = M_PlotFromDerivative(plt, M_PLOT_LINEAR, plVel);
		M_PlotSetLabel(plAcc, "m/s^2");
		M_PlotSetScale(plAcc, 0.0, 3000.0);

		/* Plot the derivative of the acceleration (the jerk). */
		plJerk = M_PlotFromDerivative(plt, M_PLOT_LINEAR, plAcc);
		M_PlotSetLabel(plJerk, "m/s^3");
		M_PlotSetScale(plJerk, 0.0, 100.0);
		M_PlotSetScale(plJerk, 0.0, 150000.0);
		M_PlotSetYoffs(plJerk, 70);
	}

	/* Allow the user to play with the parameters. */
	box = AG_BoxNew(pane->div[0], AG_BOX_VERT, AG_BOX_EXPAND);
	{
		struct {
			const char *name;
			M_Real *f;
			double incr;
		} param[7] = {
			{ "Jmax: ",	&Jmax,	0.00001 },
			{ "Amax: ",	&Amax,	0.0005 },
			{ "F: ",	&F,	0.01 },
			{ "L: ",	&L,	10.0 },
			{ "Ts tweak: ",	&uTs,	1.0 },
			{ "Ta tweak: ",	&uTa,	1.0 },
			{ "To tweak: ",	&uTo,	1.0 },
		};

		for (i = 0; i < 7; i++) {
			num = AG_NumericalNewS(box, AG_NUMERICAL_HFILL, NULL,
			    param[i].name);
			AG_BindDouble(num, "value", param[i].f);
			AG_SetDouble(num, "inc", param[i].incr);
			AG_SetEvent(num, "numerical-changed",
			    GeneratePlot, "%p", plt);
		}

		AG_SeparatorNewHoriz(box);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "Aref: %lf", &Aref);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "v1: %lf", &v1);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "v2: %lf", &v2);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "v3: %lf", &v3);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "Ts: %lf", &Ts);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "Ta: %lf", &Ta);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "To: %lf", &To);

		AG_ButtonNewFn(box, AG_BUTTON_HFILL, "Generate",
		    GeneratePlot, "%p", plt);
	}
	AG_SetEvent(win, "window-shown", GeneratePlot, "%p", plt);
	AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 50, 30);
	return (0);
}