aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generic/Track.c202
1 files changed, 196 insertions, 6 deletions
diff --git a/generic/Track.c b/generic/Track.c
index 0b741b0..a8b78de 100644
--- a/generic/Track.c
+++ b/generic/Track.c
@@ -33,6 +33,7 @@
#include "Item.h"
#include "Types.h"
#include "WidgetInfo.h"
+#include "Image.h"
#include "tkZinc.h"
#include <ctype.h>
@@ -1044,7 +1045,7 @@ Draw(Item item)
/* Draw the marker */
if (track->marker_size_dev != 0) {
- SetLineStyle(wi->dpy, wi->gc, track->marker_style);
+ SetLineStyle(wi, track->marker_style);
values.foreground = ZnPixel(track->marker_color);
values.line_width = 0;
if (ISSET(track->flags, MARKER_FILLED_BIT)) {
@@ -1107,10 +1108,10 @@ Draw(Item item)
/*
* Draw the leader.
*/
- if (track->field_set.label_format && track->leader_width > 0) {
+ if (track->field_set.label_format && (track->leader_width > 0)) {
ZnPoint end_points[LINE_END_POINTS];
XPoint xpoints[LINE_END_POINTS];
- ZnPoint *points;
+ ZnPoint *points;
int num_points;
points = (ZnPoint *) ZnListArray(track->leader_points);
@@ -1237,11 +1238,200 @@ Draw(Item item)
static void
Render(Item item)
{
- /* WidgetInfo *wi = item->wi;
- TrackItem track = (TrackItem) item;*/
+#ifdef GLX
+ WidgetInfo *wi = item->wi;
+ TrackItem track = (TrackItem) item;
+ TrackItem c_item;
+ char tmp_str[] = ".";
+ History hist;
+ int h_side_size, side_size, width=0, height=0;
+ int i, j, nb_hist, num_acc_pos;
+ XColor *color;
+ ZnPoint *points;
+ int num_points;
+ ZnReal x0, y0, size;
+
+ /* Draw the marker */
+ if (track->marker_size_dev != 0) {
+ points = GetCirclePoints(3, ZN_CIRCLE_MEDIUM, 0, 360, &num_points, NULL);
+ x0 = track->dev.x;
+ y0 = track->dev.y;
+ size = track->marker_size_dev;
+ color = track->connection_color;
+ glColor4us(color->red, color->green, color->blue, 65535);
+ if (ISSET(track->flags, MARKER_FILLED_BIT)) {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ if (track->marker_fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */
+ /*
+ * Setup polygon stippling.
+ */
+ glEnable(GL_POLYGON_STIPPLE);
+ glPolygonStipple(GetBitmapMask(wi->dpy, track->marker_fill_pattern)->pixels);
+ }
+ glBegin(GL_TRIANGLE_FAN);
+ for (i = 0; i < num_points; i++) {
+ glVertex2f(x0, y0);
+ glVertex2f(x0 + points[i].x*size, y0 + points[i].y*size);
+ }
+ glEnd();
+ }
+ else {
+ glLineWidth(1);
+ SetLineStyle(wi, track->marker_style);
+ glBegin(GL_LINE_LOOP);
+ for (i = 0; i < num_points; i++) {
+ glVertex2f(x0 + points[i].x*size, y0 + points[i].y*size);
+ }
+ glEnd();
+ }
+ }
-}
+ /*
+ * Draw the connection.
+ */
+ c_item = (TrackItem) item->connected_item;
+ if ((c_item != ZN_NO_ITEM) && (track->connection_width > 0)) {
+ color = track->connection_color;
+ glColor4us(color->red, color->green, color->blue, 65535);
+ glLineWidth(track->connection_width);
+ glBegin(GL_LINES);
+ glVertex2f(track->dev.x, track->dev.y);
+ glVertex2f(c_item->dev.x, c_item->dev.y);
+ glEnd();
+ }
+
+ /*
+ * Draw the speed vector.
+ */
+ if ((item->class == ZnTrack) && (track->speed_vector_width > 0)) {
+ color = track->speed_vector_color;
+ glColor4us(color->red, color->green, color->blue, 65535);
+ glLineWidth(track->speed_vector_width);
+ glBegin(GL_LINES);
+ glVertex2f(track->dev.x, track->dev.y);
+ glVertex2f(track->speed_vector_dev.x, track->speed_vector_dev.y);
+ glEnd();
+ }
+
+ /*
+ * Draw the leader.
+ */
+ if (track->field_set.label_format && (track->leader_width > 0)) {
+ points = ZnListArray(track->leader_points);
+ num_points = ZnListSize(track->leader_points);
+ color = track->leader_color;
+ glColor4us(color->red, color->green, color->blue, 65535);
+ glLineWidth(track->leader_width);
+ glBegin(GL_LINE_STRIP);
+ for (i = 0; i < num_points; i++, points++) {
+ glVertex2f(points->x, points->y);
+ }
+ glEnd();
+ if (track->leader_first_end != NULL) {
+ }
+ if (track->leader_last_end != NULL) {
+ }
+ }
+ tmp_str[0] = track->symbol;
+ if (track->symbol != ZnUnspecifiedPattern) {
+ Tk_SizeOfBitmap(wi->dpy, track->symbol, &width, &height);
+ }
+
+ /*
+ * Draw the history, current pos excepted.
+ */
+ if ((item->class == ZnTrack) && track->history) {
+ points = GetCirclePoints(3, ZN_CIRCLE_COARSE, 0, 360, &num_points, NULL);
+ color = track->history_color;
+ glColor4us(color->red, color->green, color->blue, 65535);
+ glLineWidth(1);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ num_acc_pos = MIN(track->visible_history_size, ZnListSize(track->history));
+ hist = ZnListArray(track->history);
+ side_size = MAX(width, height);
+ /*glDisable(GL_LINE_SMOOTH);*/
+ for (i = 0, nb_hist = 0; i < num_acc_pos; i++) {
+ if (ISSET(track->flags, LAST_AS_FIRST_BIT) &&
+ (i == track->visible_history_size-1)) {
+ color = track->symbol_color;
+ glColor4us(color->red, color->green, color->blue, 65535);
+ }
+ side_size--;
+ side_size = MAX(1, side_size);
+ h_side_size = (side_size+1)/2;
+ if (hist[i].visible) {
+ x0 = hist[i].dev.x;
+ y0 = hist[i].dev.y;
+ if ((ISSET(track->flags, DOT_MIXED_HISTORY_BIT) && !(nb_hist++ % 2)) ||
+ (side_size == 1)) {
+ glPointSize(1);
+ glBegin(GL_POINTS);
+ glVertex2f(x0, y0);
+ glEnd();
+ }
+ else {
+ if (ISSET(track->flags, CIRCLE_HISTORY_BIT)) {
+ if (ISSET(track->flags, FILLED_HISTORY_BIT)) {
+ glPointSize(side_size);
+ glBegin(GL_POINTS);
+ glVertex2f(x0, y0);
+ glEnd();
+ }
+ else {
+ RenderHollowDot(wi, &hist[i].dev, side_size+1);
+#if 0
+ glBegin(GL_LINE_LOOP);
+ for (j = 0; j < num_points; j++) {
+ glVertex2f(x0 + points[j].x*h_side_size,
+ y0 + points[j].y*h_side_size);
+ }
+ glEnd();
+#endif
+ }
+ }
+ else {
+ if (ISSET(track->flags, FILLED_HISTORY_BIT)) {
+ glBegin(GL_QUADS);
+ glVertex2f(x0 - h_side_size, y0 - h_side_size);
+ glVertex2f(x0 - h_side_size, y0 + h_side_size);
+ glVertex2f(x0 + h_side_size, y0 + h_side_size);
+ glVertex2f(x0 + h_side_size, y0 - h_side_size);
+ glEnd();
+ }
+ else {
+ glBegin(GL_LINE_LOOP);
+ glVertex2f(x0 - h_side_size, y0 - h_side_size);
+ glVertex2f(x0 - h_side_size, y0 + h_side_size);
+ glVertex2f(x0 + h_side_size, y0 + h_side_size);
+ glVertex2f(x0 + h_side_size, y0 - h_side_size);
+ glEnd();
+ }
+ }
+ }
+ }
+ }
+ /*glEnable(GL_LINE_SMOOTH);*/
+ }
+
+ /*
+ * Draw the current position using a pattern for Tk.
+ */
+ if (track->symbol != ZnUnspecifiedPattern) {
+ ZnPoint p;
+
+ p.x = track->dev.x - (width+1)/2;
+ p.y = track->dev.y - (height+1)/2;
+ RenderImage(wi, (ImageBits *) GetBitmapTexture(wi->dpy, track->symbol),
+ track->symbol_color, 255, &p);
+ }
+
+ /*
+ * Render the label.
+ */
+ ITEM_P.RenderFields(&track->field_set);
+#endif
+}
/*
**********************************************************************************