Ejemplo n.º 1
0
AG_Slider *
AG_SliderNewDblR(void *parent, enum ag_slider_type type, Uint flags,
    double *val, double min, double max)
{
	AG_Slider *sl = AG_SliderNew(parent, type, flags);
	if (val != NULL) { AG_BindDouble(sl, "value", val); }
	AG_SetDouble(sl, "min", min);
	AG_SetDouble(sl, "max", max);
	return (sl);
}
Ejemplo n.º 2
0
void
AG_SliderSetRealIncrement(AG_Slider *sl, double inc)
{
	AG_ObjectLock(sl);
	AG_SetDouble(sl, "inc", inc);
	AG_ObjectUnlock(sl);
}
Ejemplo n.º 3
0
bool GuiConfig::Write(const string &option, const double &value)
{
	if(!option.size())
		return true;

	if(AG_SetDouble(agConfig, option.c_str(), value) == NULL)
		return true;

	return false;
}
Ejemplo n.º 4
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);
}
Ejemplo n.º 5
0
void
agar_gui_widget_set_double (AG_Widget *w, const char *binding, double val)
{
  AG_SetDouble (w, binding, val);
}