Example #1
0
void gwinGraphDrawPoint(GHandle gh, coord_t x, coord_t y) {
	#define gg	((GGraphObject *)gh)

	if (gh->vmt != &graphVMT || !_gwinDrawStart(gh))
		return;

	if ((gh->flags & GGRAPH_FLG_CONNECTPOINTS)) {
		// Draw the line
		lineto(gg, gg->lastx, gg->lasty, x, y, &gg->style.line);

		// Redraw the previous point because the line may have overwritten it
		pointto(gg, gg->lastx, gg->lasty, &gg->style.point);

	} else
		gh->flags |= GGRAPH_FLG_CONNECTPOINTS;

	// Save this point for next time.
	gg->lastx = x;
	gg->lasty = y;

	// Draw this point.
	pointto(gg, x, y, &gg->style.point);

	_gwinDrawEnd(gh);
	#undef gg
}
Example #2
0
void gwinGraphDrawPoints(GHandle gh, const point *points, unsigned count) {
	#define gg	((GGraphObject *)gh)
	unsigned		i;
	const point		*p;

	if (gh->vmt != &graphVMT || !_gwinDrawStart(gh))
		return;

	// Draw the connecting lines
	for(p = points, i = 0; i < count; p++, i++) {
		if ((gh->flags & GGRAPH_FLG_CONNECTPOINTS)) {
			// Draw the line
			lineto(gg, gg->lastx, gg->lasty, p->x, p->y, &gg->style.line);

			// Redraw the previous point because the line may have overwritten it
			if (i == 0)
				pointto(gg, gg->lastx, gg->lasty, &gg->style.point);

		} else
			gh->flags |= GGRAPH_FLG_CONNECTPOINTS;

		// Save this point for next time.
		gg->lastx = p->x;
		gg->lasty = p->y;
	}


	// Draw the points.
	for(p = points, i = 0; i < count; p++, i++)
		pointto(gg, p->x, p->y, &gg->style.point);

	_gwinDrawEnd(gh);
	#undef gg
}
Example #3
0
bool_t _gwinDrawStart(GHandle gh) {
	// This test should occur inside the lock. We do this
	//	here as well as an early out (more efficient).
	if (!(gh->flags & GWIN_FLG_SYSVISIBLE))
		return FALSE;

	// Obtain the drawing lock
	gfxSemWait(&gwinsem, TIME_INFINITE);

	// Re-test visibility as we may have waited a while
	if (!(gh->flags & GWIN_FLG_SYSVISIBLE)) {
		_gwinDrawEnd(gh);
		return FALSE;
	}

	// OK - we are ready to draw.
	#if GDISP_NEED_CLIP
		gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height);
	#endif
	return TRUE;
}
Example #4
0
void gwinGraphDrawAxis(GHandle gh) {
	#define gg	((GGraphObject *)gh)
	coord_t		i, xmin, ymin, xmax, ymax;

	if (gh->vmt != &graphVMT || !_gwinDrawStart(gh))
		return;

	xmin = -gg->xorigin;
	xmax = gh->width-gg->xorigin-1;
	ymin = -gg->yorigin;
	ymax = gh->height-gg->yorigin-1;

	// x grid - this code assumes that the GGraphGridStyle is a superset of GGraphListStyle
	if (gg->style.xgrid.type != GGRAPH_LINE_NONE && gg->style.xgrid.spacing >= 2) {
		for(i = gg->style.xgrid.spacing; i <= xmax; i += gg->style.xgrid.spacing)
			lineto(gg, i, ymin, i, ymax, (GGraphLineStyle *)&gg->style.xgrid);
		for(i = -gg->style.xgrid.spacing; i >= xmin; i -= gg->style.xgrid.spacing)
			lineto(gg, i, ymin, i, ymax, (GGraphLineStyle *)&gg->style.xgrid);
	}

	// y grid - this code assumes that the GGraphGridStyle is a superset of GGraphListStyle
	if (gg->style.ygrid.type != GGRAPH_LINE_NONE && gg->style.ygrid.spacing >= 2) {
		for(i = gg->style.ygrid.spacing; i <= ymax; i += gg->style.ygrid.spacing)
			lineto(gg, xmin, i, xmax, i, (GGraphLineStyle *)&gg->style.ygrid);
		for(i = -gg->style.ygrid.spacing; i >= ymin; i -= gg->style.ygrid.spacing)
			lineto(gg, xmin, i, xmax, i, (GGraphLineStyle *)&gg->style.ygrid);
	}

	// x axis
	lineto(gg, xmin, 0, xmax, 0, &gg->style.xaxis);
	if ((gg->style.flags & GWIN_GRAPH_STYLE_XAXIS_NEGATIVE_ARROWS)) {
		if (xmin > 0 || xmin < -(GGRAPH_ARROW_SIZE+1)) {
			lineto(gg, xmin, 0, xmin+GGRAPH_ARROW_SIZE, GGRAPH_ARROW_SIZE, &gg->style.xaxis);
			lineto(gg, xmin, 0, xmin+GGRAPH_ARROW_SIZE, -GGRAPH_ARROW_SIZE, &gg->style.xaxis);
		}
	}
	if ((gg->style.flags & GWIN_GRAPH_STYLE_XAXIS_POSITIVE_ARROWS)) {
		if (xmax < 0 || xmax > (GGRAPH_ARROW_SIZE+1)) {
			lineto(gg, xmax, 0, xmax-GGRAPH_ARROW_SIZE, GGRAPH_ARROW_SIZE, &gg->style.xaxis);
			lineto(gg, xmax, 0, xmax-GGRAPH_ARROW_SIZE, -GGRAPH_ARROW_SIZE, &gg->style.xaxis);
		}
	}

	// y axis
	lineto(gg, 0, ymin, 0, ymax, &gg->style.yaxis);
	if ((gg->style.flags & GWIN_GRAPH_STYLE_YAXIS_NEGATIVE_ARROWS)) {
		if (ymin > 0 || ymin < -(GGRAPH_ARROW_SIZE+1)) {
			lineto(gg, 0, ymin, GGRAPH_ARROW_SIZE, ymin+GGRAPH_ARROW_SIZE, &gg->style.yaxis);
			lineto(gg, 0, ymin, -GGRAPH_ARROW_SIZE, ymin+GGRAPH_ARROW_SIZE, &gg->style.yaxis);
		}
	}
	if ((gg->style.flags & GWIN_GRAPH_STYLE_YAXIS_POSITIVE_ARROWS)) {
		if (ymax < 0 || ymax > (GGRAPH_ARROW_SIZE+1)) {
			lineto(gg, 0, ymax, GGRAPH_ARROW_SIZE, ymax-GGRAPH_ARROW_SIZE, &gg->style.yaxis);
			lineto(gg, 0, ymax, -GGRAPH_ARROW_SIZE, ymax-GGRAPH_ARROW_SIZE, &gg->style.yaxis);
		}
	}

	_gwinDrawEnd(gh);
	#undef gg
}