File: graph.c

package info (click to toggle)
gpstrans 0.31b-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 480 kB
  • ctags: 520
  • sloc: ansic: 4,250; makefile: 127
file content (112 lines) | stat: -rw-r--r-- 2,365 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "defs.h"


extern Frame   frame;
extern Display *display;
extern int     dsp_width, dsp_height;



Frame  BarFrame;
Panel  BarPanel, BarGraph;

int    LastValue = 0;





void SetBarGraph(double value)
{
  int perc;

  perc = (int) (value * 100);
  if (value < 0) perc =   0;
  if (value > 1) perc = 100;

  if (LastValue == perc) return;

  xv_set(BarGraph, PANEL_VALUE, perc, NULL);
  XFlush(display);

  LastValue = perc;
}


void CreateBarGraph()
{
  int    BarWidth =  300;
  int    BarHeight =  80;


  BarFrame = (Frame) xv_create(frame,                  FRAME_CMD,
			       XV_WIDTH,                10,
			       XV_HEIGHT,               10,
			       FRAME_LABEL,            BarWindowHeader,
			       NULL);

  BarPanel = (Panel) xv_create(BarFrame,               PANEL,
			       XV_X,                    10,
			       XV_Y,                    10,
			       NULL);

  xv_create(BarPanel,           PANEL_MESSAGE,
	    XV_X,               5,
	    XV_Y,               5,
	    PANEL_LABEL_BOLD,   TRUE,
	    PANEL_LABEL_STRING, "Transfering GPS data:",
	    NULL);

  xv_create(BarPanel,           PANEL_MESSAGE,
	    XV_X,               300,
	    XV_Y,                 5,
	    PANEL_LABEL_BOLD,   TRUE,
	    PANEL_LABEL_STRING, "",
	    NULL);


  BarGraph = (Panel) xv_create(BarPanel,               PANEL_GAUGE,
			       XV_Y,                    50,
			       XV_X,                    50,
			       PANEL_MIN_VALUE,          0,
			       PANEL_MAX_VALUE,        100,
			       PANEL_GAUGE_WIDTH,      200,
			       PANEL_LABEL_STRING,     "",
			       PANEL_DIRECTION,        PANEL_HORIZONTAL,
			       PANEL_MIN_TICK_STRING,    "0%",
			       PANEL_MAX_TICK_STRING,  "100%",
			       PANEL_VALUE,            0,
			       NULL);

  window_fit(BarPanel);
  window_fit(BarFrame);

  
  xv_set(BarFrame, XV_X, (int) ((dsp_width - BarWidth) / 2),
	           XV_Y, (int) ((dsp_height / 2) - (BarHeight / 2)),
	 NULL);

  xv_set(BarFrame, XV_SHOW, TRUE, NULL);
  xv_set(BarFrame, XV_SHOW, FALSE, NULL);
  XFlush(display);
  sleep(1);
}


void InitBarGraph()
{
  xv_set(BarFrame, XV_SHOW,              TRUE,
                   FRAME_CMD_PUSHPIN_IN, TRUE,
	           NULL);
  XFlush(display);
  sleep(1);
}


void CloseBarGraph()
{	
  xv_set(BarFrame, FRAME_CMD_PUSHPIN_IN, FALSE,
	           XV_SHOW,              FALSE,
	           NULL);

}