File: rama_frame.c

package info (click to toggle)
garlic 1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 4,440 kB
  • ctags: 1,403
  • sloc: ansic: 52,465; makefile: 1,133
file content (335 lines) | stat: -rw-r--r-- 11,188 bytes parent folder | download | duplicates (5)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/* Copyright (C) 2000 Damir Zucic */

/*=============================================================================

				rama_frame.c

Purpose:
	Draw frame for Ramachandran plot, including labels.

Input:
	(1) Pointer to GUIS structure, with GUI data.

Output:
	(1) A rectangular frame drawn to the main window.

Return value:
	No return value.

========includes:============================================================*/

#include <stdio.h>

#include <string.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include "defines.h"
#include "typedefs.h"

/*======function prototypes:=================================================*/

int		ParseColor_ (RGBS *, unsigned long *, GUIS *, char *, char *);

/*======draw frame for Ramachandran plot:====================================*/

void RamaFrame_ (GUIS *guiSP)
{
int		free_width, free_height;
int		frame_screen_x0, frame_screen_y0;
int		frame_screen_x1, frame_screen_y1;
int		frame_screen_width, frame_screen_height;
RGBS		rgbS;
unsigned long	frame_color1ID, frame_color2ID, frame_color3ID;
int		i;
int		screen_x0, screen_y0;
char		stringA[SHORTSTRINGSIZE];
int		string_length;

/* Prepare geometric parameters: */
free_width  = (int) guiSP->main_win_free_area_width;
free_height = (int) guiSP->main_win_free_area_height;
frame_screen_x0 = guiSP->main_winS.text_line_height + 2;
frame_screen_y0 = frame_screen_x0;
frame_screen_x1 = free_width - frame_screen_x0;
if (frame_screen_x1 < frame_screen_x0) frame_screen_x1 = frame_screen_x0;
frame_screen_y1 = free_height - frame_screen_y0;
if (frame_screen_y1 < frame_screen_y0) frame_screen_y1 = frame_screen_y0;
frame_screen_width  = frame_screen_x1 - frame_screen_x0 + 1;
frame_screen_height = frame_screen_y1 - frame_screen_y0 + 1;

/* Prepare frame colors: */
ParseColor_ (&rgbS, &frame_color1ID, guiSP, "RGB:EEEE/EEEE/EEEE", "white");
ParseColor_ (&rgbS, &frame_color2ID, guiSP, "RGB:9999/9999/9999", "white");
ParseColor_ (&rgbS, &frame_color3ID, guiSP, "RGB:4444/4444/4444", "black");
XSetForeground (guiSP->displaySP, guiSP->theGCA[1], frame_color1ID);
XSetForeground (guiSP->displaySP, guiSP->theGCA[2], frame_color2ID);
XSetForeground (guiSP->displaySP, guiSP->theGCA[3], frame_color3ID);

/* Thin lines: */
for (i = 1; i < 12; i++)
	{
	if (i == 6) continue;
	screen_x0 = frame_screen_x0 + i * frame_screen_width / 12;
	if ((i % 3) == 0)
		{
		XDrawLine (guiSP->displaySP,
			   guiSP->main_hidden_pixmapID,
			   guiSP->theGCA[1],
			   screen_x0 - 1, frame_screen_y0,
			   screen_x0 - 1, frame_screen_y1);
		XDrawLine (guiSP->displaySP,
			   guiSP->main_hidden_pixmapID,
			   guiSP->theGCA[2],
			   screen_x0, frame_screen_y0,
			   screen_x0, frame_screen_y1);
		XDrawLine (guiSP->displaySP,
			   guiSP->main_hidden_pixmapID,
			   guiSP->theGCA[3],
			   screen_x0 + 1, frame_screen_y0,
			   screen_x0 + 1, frame_screen_y1);
		}
	else
		{
		XDrawLine (guiSP->displaySP,
			   guiSP->main_hidden_pixmapID,
			   guiSP->theGCA[2],
			   screen_x0, frame_screen_y0,
			   screen_x0, frame_screen_y1);
		}
	}
for (i = 1; i < 12; i++)
	{
	if (i == 6) continue;
	screen_y0 = frame_screen_y0 + i * frame_screen_height / 12;
	if ((i % 3) == 0)
		{
		XDrawLine (guiSP->displaySP,
			   guiSP->main_hidden_pixmapID,
			   guiSP->theGCA[1],
			   frame_screen_x0, screen_y0 - 1,
			   frame_screen_x1, screen_y0 - 1);
		XDrawLine (guiSP->displaySP,
			   guiSP->main_hidden_pixmapID,
			   guiSP->theGCA[2],
			   frame_screen_x0, screen_y0,
			   frame_screen_x1, screen_y0);
		XDrawLine (guiSP->displaySP,
			   guiSP->main_hidden_pixmapID,
			   guiSP->theGCA[3],
			   frame_screen_x0, screen_y0 + 1,
			   frame_screen_x1, screen_y0 + 1);
		}
	else
		{
		XDrawLine (guiSP->displaySP,
			   guiSP->main_hidden_pixmapID,
			   guiSP->theGCA[2],
			   frame_screen_x0, screen_y0,
			   frame_screen_x1, screen_y0);
		}
	}

/* Thick outer frame: */
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[2],
		frame_screen_x0, frame_screen_y0,
		(unsigned int) (frame_screen_width - 1),
		(unsigned int) (frame_screen_height - 1));
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[1],
	   frame_screen_x0 - 1, frame_screen_y0 - 1,
	   frame_screen_x0 - 1, frame_screen_y1 + 1);
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[1],
	   frame_screen_x0 - 1, frame_screen_y0 - 1,
	   frame_screen_x1 + 1, frame_screen_y0 - 1);
XDrawLine (guiSP->displaySP,
           guiSP->main_hidden_pixmapID,
           guiSP->theGCA[1],
           frame_screen_x1 - 1, frame_screen_y0 + 1,
           frame_screen_x1 - 1, frame_screen_y1 - 1);
XDrawLine (guiSP->displaySP,
           guiSP->main_hidden_pixmapID,
           guiSP->theGCA[1],
           frame_screen_x0 + 1, frame_screen_y1 - 1,
           frame_screen_x1 - 1, frame_screen_y1 - 1);
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[3],
	   frame_screen_x0 + 1, frame_screen_y0 + 1,
	   frame_screen_x0 + 1, frame_screen_y1 - 1);
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[3],
	   frame_screen_x0 + 1, frame_screen_y0 + 1,
	   frame_screen_x1 - 1, frame_screen_y0 + 1);
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[3],
	   frame_screen_x1 + 1, frame_screen_y0 - 1,
	   frame_screen_x1 + 1, frame_screen_y1 + 1);
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[3],
	   frame_screen_x0 - 1, frame_screen_y1 + 1,
	   frame_screen_x1 + 1, frame_screen_y1 + 1);

/* Thick inner frame: */
screen_x0 = (frame_screen_x0 + frame_screen_x1) / 2;
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[2],
	   screen_x0, frame_screen_y0,
	   screen_x0, frame_screen_y1);
XDrawLine (guiSP->displaySP,
           guiSP->main_hidden_pixmapID,
           guiSP->theGCA[1],
           screen_x0 - 1, frame_screen_y0 + 1,
           screen_x0 - 1, frame_screen_y1 - 1);
XDrawLine (guiSP->displaySP,
           guiSP->main_hidden_pixmapID,
           guiSP->theGCA[3],
           screen_x0 + 1, frame_screen_y0 + 1,
           screen_x0 + 1, frame_screen_y1 - 1);
screen_y0 = (frame_screen_y0 + frame_screen_y1) / 2;
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[2],
	   frame_screen_x0, screen_y0,
	   frame_screen_x1, screen_y0);
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[1],
	   frame_screen_x0 + 1, screen_y0 - 1,
	   frame_screen_x1 - 1, screen_y0 - 1);
XDrawLine (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID,
	   guiSP->theGCA[3],
	   frame_screen_x0 + 1, screen_y0 + 1,
	   frame_screen_x1 - 1, screen_y0 + 1);
XDrawLine (guiSP->displaySP,
           guiSP->main_hidden_pixmapID,
           guiSP->theGCA[2],
           screen_x0, screen_y0 - 1,
           screen_x0, screen_y0 + 1);

/* Draw labels: */
XSetForeground (guiSP->displaySP, guiSP->theGCA[0],
		guiSP->main_winS.fg_colorID);
strcpy (stringA, "abscisa: phi     ordinate: psi");
string_length = strlen (stringA);
screen_x0 = (frame_screen_x0 + frame_screen_x1) / 2 -
	     XTextWidth (guiSP->main_winS.fontSP, stringA, string_length) / 2;
screen_y0 = frame_screen_y0 - guiSP->main_winS.fontSP->descent - 1;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);

screen_y0 = frame_screen_y1 + guiSP->main_winS.text_line_height -
	    guiSP->main_winS.text_line_height / 5;
screen_x0 = frame_screen_x0 + 10;
strcpy (stringA, "trans");
string_length = strlen (stringA);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);
screen_x0 = frame_screen_x0 + (frame_screen_x1 - frame_screen_x0) / 4 + 10;
strcpy (stringA, "cis");
string_length = strlen (stringA);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);
screen_x0 = frame_screen_x0 + 2 * (frame_screen_x1 - frame_screen_x0) / 4 + 10;
strcpy (stringA, "bad / amino terminus");
string_length = strlen (stringA);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);

strcpy (stringA, "0");
string_length = strlen (stringA);
screen_x0 = (frame_screen_x0 + frame_screen_x1) / 2 + 3;
screen_y0 = (frame_screen_y0 + frame_screen_y1) / 2 - 3;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);

strcpy (stringA, "-180");
string_length = strlen (stringA);
screen_x0 = frame_screen_x0 + 3;
screen_y0 = (frame_screen_y0 + frame_screen_y1) / 2 - 3;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);
screen_x0 = (frame_screen_x0 + frame_screen_x1) / 2 + 3;
screen_y0 = frame_screen_y1 - 3;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);

strcpy (stringA, "-90");
string_length = strlen (stringA);
screen_x0 = frame_screen_x0 + (frame_screen_x1 - frame_screen_x0) / 4 + 3;
screen_y0 = (frame_screen_y0 + frame_screen_y1) / 2 - 3;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);
screen_x0 = (frame_screen_x0 + frame_screen_x1) / 2 + 3;
screen_y0 = frame_screen_y0 + 3 * (frame_screen_y1 - frame_screen_y0) / 4 - 3;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);

strcpy (stringA, "90");
string_length = strlen (stringA);
screen_x0 = frame_screen_x0 + 3 * (frame_screen_x1 - frame_screen_x0) / 4 + 3;
screen_y0 = (frame_screen_y0 + frame_screen_y1) / 2 - 3;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);
screen_x0 = (frame_screen_x0 + frame_screen_x1) / 2 + 3;
screen_y0 = frame_screen_y0 + (frame_screen_y1 - frame_screen_y0) / 4 - 3;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);

strcpy (stringA, "180");
string_length = strlen (stringA);
screen_x0 = frame_screen_x1 -
	    XTextWidth (guiSP->main_winS.fontSP, stringA, string_length) - 3;
screen_y0 = (frame_screen_y0 + frame_screen_y1) / 2 - 3;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);
screen_x0 = (frame_screen_x0 + frame_screen_x1) / 2 + 3;
screen_y0 = frame_screen_y0 + guiSP->main_winS.text_line_height -
	    guiSP->main_winS.text_line_height / 5;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0, stringA, string_length);

}

/*===========================================================================*/