Beispiel #1
0
/**
 * uber_line_graph_get_next_data:
 * @graph: A #UberGraph.
 *
 * XXX
 *
 * Returns: None.
 * Side effects: None.
 */
static gboolean
uber_line_graph_get_next_data (UberGraph *graph) /* IN */
{
	UberLineGraphPrivate *priv;
	LineInfo *line;
	gdouble val;
	gboolean ret = FALSE;
	gint i;

	g_return_val_if_fail(UBER_IS_LINE_GRAPH(graph), FALSE);

	priv = UBER_LINE_GRAPH(graph)->priv;
	/*
	 * Retrieve the next data point.
	 */
	if (priv->func) {
		for (i = 0; i < priv->lines->len; i++) {
			val = 0.;
			line = &g_array_index(priv->lines, LineInfo, i);
			if (!(ret = priv->func(UBER_LINE_GRAPH(graph),
			                       i + 1, &val,
			                       priv->func_data))) {
				val = -INFINITY;
			}
			g_ring_append_val(line->raw_data, val);
			/*
			 * TODO: Scale value.
			 */
			g_ring_append_val(line->scaled_data, val);
		}
	}
	return ret;
}
/**
 * uber_line_graph_get_next_data:
 * @graph: A #UberGraph.
 *
 * XXX
 *
 * Returns: None.
 * Side effects: None.
 */
static gboolean
uber_line_graph_get_next_data (UberGraph *graph) /* IN */
{
	UberLineGraphPrivate *priv;
	gboolean scale_changed = FALSE;
	gboolean ret = FALSE;
	LineInfo *line;
	gdouble val;
	gint i;

	g_return_val_if_fail(UBER_IS_LINE_GRAPH(graph), FALSE);

	priv = UBER_LINE_GRAPH(graph)->priv;
	/*
	 * Retrieve the next data point.
	 */
	if (priv->func) {
		for (i = 0; i < priv->lines->len; i++) {
			val = 0.;
			line = &g_array_index(priv->lines, LineInfo, i);
			if (!(ret = priv->func(UBER_LINE_GRAPH(graph),
			                       i + 1, &val,
			                       priv->func_data))) {
				val = -INFINITY;
			}
			g_ring_append_val(line->raw_data, val);
			if (priv->autoscale) {
				if (val < priv->range.begin) {
					priv->range.begin = val - (val * SCALE_FACTOR);
					priv->range.range = priv->range.end - priv->range.begin;
					scale_changed = TRUE;
				} else if (val > priv->range.end) {
					priv->range.end = val + (val * SCALE_FACTOR);
					priv->range.range = priv->range.end - priv->range.begin;
					scale_changed = TRUE;
				}
			}
		}
	}
	if (scale_changed) {
		uber_graph_scale_changed(graph);
	}
	return ret;
}