1
/* twpsk - A gui application for PSK
2
* Copyright (C) 1999 Ted Williams WA0EIR (ted_williams@HP.com)
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of
7
* the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be
10
* useful, but WITHOUT ANY WARRANTY; without even the implied
11
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
* PURPOSE. See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the Free
16
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
19
* Version: 2.0 - Aug 2001
22
#include "twpskScope.h"
27
* Initialize drawing stuff for scope
30
void Scope::setup (Widget shell, Widget scopeWid)
35
x = SCOPE_WIDTH/2; /* initialize these to 64 so first time wont't draw */
36
y = SCOPE_WIDTH/2; /* a line from 0,0 to center. */
39
gc = XCreateGC(XtDisplay(shell),
40
RootWindowOfScreen (XtScreen(shell)),
43
display = XtDisplay (scopeDA);
44
window = XtWindow (scopeDA);
45
screen = DefaultScreen (display);
46
dcmap = DefaultColormap (display, screen);
48
XAllocNamedColor (display, dcmap, "red", &color[0], &nill);
49
XAllocNamedColor (display, dcmap, "yellow", &color[1], &nill);
50
XAllocNamedColor (display, dcmap, "green2", &color[2], &nill);
51
XAllocNamedColor (display, dcmap, "light gray", &color[3], &nill); /*Outer*/
52
XAllocNamedColor (display, dcmap, "slate gray", &color[4], &nill); /*Inner*/
57
* drawline - draws the phase lines in the scope
59
void Scope::drawline (int phdelta, int strength, int icolor)
61
Position cx = SCOPE_WIDTH/2, cy = SCOPE_WIDTH/2;
65
/* fudge factor - converts 0->256 thingies to radians */
66
float fudge = 2.0 * M_PI / 256.0;
67
theta = phdelta * fudge;
69
XSetForeground (display, gc, color[4].pixel); /* fg color to color[4] to */
70
XDrawLine (display, window, gc, /* undraw the last line */
71
cx, cy, /* Start of last line */
72
x, y); /* End of the last line */
74
XSetForeground (display, gc, color[icolor].pixel);
76
dx = (float)strength * cos(theta+M_PI_2) * SCOPE_WIDTH/128;
77
dy = (float)strength * sin(theta+M_PI_2) * SCOPE_WIDTH/128;
79
x = (int) ((float)cx + dx);
80
y = (int) ((float)cy - dy);
81
XDrawLine (display, window, gc,
82
cx, cy, /* Start of new line */
83
x, y); /* End of new line */
84
XSetForeground (display, gc, color[3].pixel);
89
* drawcirc - redraws the circle
91
void Scope::drawcirc()
93
/* Draw outer circle */
94
XSetForeground (display, gc, color[3].pixel); /* fg = white */
95
XSetLineAttributes (display, gc, OUTER_CIRCLE_WIDTH,
96
LineSolid, CapRound, JoinRound);
97
XDrawArc (display, window, gc,
98
BORDER_WIDTH, BORDER_WIDTH, /* upper left corner */
99
SCOPE_WIDTH - 2 * BORDER_WIDTH,
100
SCOPE_WIDTH - 2 * BORDER_WIDTH, /* axis lengths */
101
0, 23040); /* start/stop points */
103
/* Change the gc for inner circle */
104
gcv.foreground = color[4].pixel;
105
XChangeGC (display, gc, GCForeground, &gcv);
106
XSetLineAttributes (display, gc, LINE_WIDTH,
107
LineSolid, CapRound, JoinRound);
109
/* Draw filled inner circle */
110
XFillArc (display, window, gc,
111
BORDER_WIDTH, BORDER_WIDTH, /* upper left corner */
112
SCOPE_WIDTH - 2 * BORDER_WIDTH,
113
SCOPE_WIDTH - 2 * BORDER_WIDTH, /* axis lengths */
114
0, 23040); /* start/stop points */