~ubuntu-branches/ubuntu/raring/boxshade/raring-proposed

« back to all changes in this revision

Viewing changes to .pc/kickOutGets.patch/dv_fig.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille, David Paleino, Andreas Tille
  • Date: 2011-01-14 08:27:01 UTC
  • Revision ID: james.westby@ubuntu.com-20110114082701-etwd13n9n7nz8h78
Tags: 3.3.1-5
[ David Paleino ]
* Removed myself from Uploaders

[ Andreas Tille ]
* debian/control
  - Standards-Version: 3.9.1 (no changes needed)
  - Debhelper 7
  - Fix spelling of Debian Med in maintainer address
* debian/rules: s/dh_clean -k/dh_prep/
* debian/source/format: 3.0 (quilt)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "dv_all.h"
 
2
 
 
3
/*--------------------------------------------------------------------------*/
 
4
/*   fig specific section                                                   */
 
5
/*--------------------------------------------------------------------------*/
 
6
 
 
7
typedef struct figrecord {
 
8
  int bgnd, fgnd, fontno;
 
9
} figrecord;
 
10
 
 
11
static int fig_fontsize;         /* XFIG specifics */
 
12
static int fig_fontno_offset;   /* 0=Tms,12=Cour,16=Helv,28=Palat */
 
13
static figrecord figrec[5];
 
14
 
 
15
static int fig_fontno;           /* current values go here*/
 
16
static int fig_fgnd, fig_bgnd;   /*            ... to here*/
 
17
 
 
18
static void menu_fig(figrecord *figrec, BOOL *lc, char *txt, char *parstring)
 
19
{
 
20
  char code;
 
21
  char instring[51];
 
22
 
 
23
  if (interactflag) {
 
24
    printf("\n----------------------------------------------------------------\n"
 
25
           "Enter the text attributes for printing of **>%s<** residues:\n",
 
26
           txt);
 
27
    printf("First choose the color/gray-value of the letter **>background<**\n"
 
28
           "Different letters specify different colors,\n"
 
29
           "(B) black  (W) white (1,2,3,4) 4 different gray values, 4 is darkest\n\n"
 
30
           "choose from  BW1234 ( * %c * ) : ", parstring[0]);
 
31
    Fgets(instring, 51, stdin);
 
32
  } else
 
33
    *instring = '\0';
 
34
  if (*instring == '\0')
 
35
    code = parstring[0];
 
36
  else
 
37
    code = instring[0];
 
38
  code = toupper(code);
 
39
  if (strchr("BW1234", code) == NULL)
 
40
    code = 'W';
 
41
  switch (code) {
 
42
    case 'B': figrec->bgnd = 21; break;
 
43
    case 'W': figrec->bgnd = 0;  break;
 
44
    case '1': figrec->bgnd = 4;  break;
 
45
    case '2': figrec->bgnd = 8;  break;
 
46
    case '3': figrec->bgnd = 12; break;
 
47
    case '4': figrec->bgnd = 16; break;
 
48
  }
 
49
  if (interactflag) {
 
50
    printf("\n\nNow choose the color/gray-value of the letter **>foreground<**\n"
 
51
           "lowercase choices mean lowercase letters in the sequence:\n"
 
52
           "(B,b) black,normal    (E,e) black, emphasized\n"
 
53
           "(W,w) white normal    (F,f) white, emphasized\n"
 
54
           "(L,l) Blue (M,m) Magenta (Y,y) Yellow (G,g) Green (R,r) Red\n\n"
 
55
           "choose from  BbEeWwFfLlMmYyGgRr ( * %c * ) : ", parstring[1]);
 
56
    Fgets(instring, 51, stdin);
 
57
  } else
 
58
    *instring = '\0';
 
59
  if (*instring == '\0')
 
60
    code = parstring[1];
 
61
  else
 
62
    code = instring[0];
 
63
  if (strchr("BEWFLMYGR", toupper(code)) == NULL)
 
64
    code = 'B';
 
65
  *lc = islower(code);
 
66
  code = toupper(code);
 
67
  switch (code) {
 
68
    case 'B':
 
69
      figrec->fgnd = 0;
 
70
      figrec->fontno = 0;
 
71
      break;
 
72
    case 'E':
 
73
      figrec->fgnd = 0;
 
74
      figrec->fontno = 2;
 
75
      break;
 
76
    case 'W':
 
77
      figrec->fgnd = 7;
 
78
      figrec->fontno = 0;
 
79
      break;
 
80
    case 'F':
 
81
      figrec->fgnd = 7;
 
82
      figrec->fontno = 2;
 
83
      break;
 
84
    case 'L':
 
85
      figrec->fgnd = 1;
 
86
      figrec->fontno = 0;
 
87
      break;
 
88
    case 'M':
 
89
      figrec->fgnd = 5;
 
90
      figrec->fontno = 0;
 
91
      break;
 
92
    case 'Y':
 
93
      figrec->fgnd = 6;
 
94
      figrec->fontno = 0;
 
95
      break;
 
96
    case 'G':
 
97
      figrec->fgnd = 2;
 
98
      figrec->fontno = 0;
 
99
      break;
 
100
    case 'R':
 
101
      figrec->fgnd = 4;
 
102
      figrec->fontno = 0;
 
103
      break;
 
104
  }
 
105
}
 
106
 
 
107
 
 
108
static void ask_fig(void)
 
109
{
 
110
  char parstring[6];
 
111
  char instring[41];
 
112
 
 
113
  term_par("FIG");
 
114
  if (interactflag)
 
115
    printf("-------------------------------------------------------------\n");
 
116
  Fgets(parstring, 6, parfile);
 
117
  parstring[2] = '\0';
 
118
  menu_fig(&figrec[0], &lc[0], "different", parstring);
 
119
  Fgets(parstring, 6, parfile);
 
120
  parstring[2] = '\0';
 
121
  menu_fig(&figrec[1], &lc[1], "identical", parstring);
 
122
  Fgets(parstring, 6, parfile);
 
123
  parstring[2] = '\0';
 
124
  if (simflag)
 
125
    menu_fig(&figrec[2], &lc[2], "similar", parstring);
 
126
  else {
 
127
    figrec[2] = figrec[0];
 
128
    lc[2] = lc[0];
 
129
  }
 
130
  Fgets(parstring, 6, parfile);
 
131
  parstring[2] = '\0';
 
132
  if (globalflag)
 
133
    menu_fig(&figrec[3], &lc[3], "conserved", parstring);
 
134
  else {
 
135
    figrec[3] = figrec[1];
 
136
    lc[3] = lc[1];
 
137
  }
 
138
  figrec[4].bgnd = 0;
 
139
  figrec[4].fgnd = 0;
 
140
  figrec[4].fontno = 0;
 
141
  lc[4] = FALSE;
 
142
 
 
143
  fscanf(parfile, "%d%*[^\n]", &fig_fontno_offset);
 
144
  getc(parfile);
 
145
  fscanf(parfile, "%d%*[^\n]", &fig_fontsize);
 
146
  getc(parfile);
 
147
  if (interactflag) {
 
148
    do {
 
149
      printf("Character size in Points ( * %4d * ) : ", fig_fontsize);
 
150
      Fgets(instring, 41, stdin);
 
151
      if (*instring != '\0')
 
152
        fig_fontsize = str2int((void *)instring);
 
153
    } while (fig_fontsize < 1 || fig_fontsize > 100);
 
154
  }
 
155
  if (!cloutflag) {
 
156
    printf("name of fig-file  : ");
 
157
    gets(outname);
 
158
  }
 
159
}
 
160
 
 
161
 
 
162
static void FIGinit(double *xpos, double *ypos) {
 
163
  assert(outopen(&outfile, outname) != NULL);
 
164
  dev_minx = fig_fontsize * 4.0;
 
165
  dev_miny = fig_fontsize * 4.0;
 
166
  dev_maxx = 10000.0;
 
167
  dev_maxy = 10000.0;
 
168
  dev_xsize = fig_fontsize + 1.0;
 
169
  dev_ysize = fig_fontsize;
 
170
  *xpos = dev_minx;
 
171
  *ypos = dev_miny;
 
172
  uwriteln(&outfile, "#FIG 2.1");
 
173
  uwriteln(&outfile, "80 2");
 
174
}
 
175
 
 
176
static void FIGsetcolor(int colno) {
 
177
  dev_xsize = fig_fontsize + 1.0;
 
178
  fig_fontno = fig_fontno_offset + figrec[colno].fontno;
 
179
  fig_fgnd = figrec[colno].fgnd;
 
180
  fig_bgnd = figrec[colno].bgnd;
 
181
}
 
182
 
 
183
static void FIGcharout(char c, double *xpos, double *ypos) {
 
184
 
 
185
  if (fig_bgnd > 0) {  /*draw box*/
 
186
    double bxshift, byshift;
 
187
    int bx1, by1, bx2, by2;
 
188
 
 
189
    bxshift = fig_fontsize * 0.25;
 
190
    byshift = fig_fontsize * 0.15;
 
191
    bx1 = (int)(*xpos + 0.5 - bxshift);
 
192
    bx2 = (int)(*xpos + dev_xsize + 0.5 - bxshift);
 
193
    by2 = (int)(*ypos + 0.5 + byshift);
 
194
    by1 = (int)(*ypos - dev_ysize + 0.5 + byshift);
 
195
 
 
196
    /*compound object*/
 
197
    uwriteln(&outfile, "6 %5d%5d%5d%5d", bx2, by1, bx1, by2);
 
198
    uwriteln(&outfile, "2 2 0 0 0 5 0 "    /*box*/
 
199
                       "%3d 0.0 0 0 0", fig_bgnd);
 
200
    fprintf(outfile.f, "\t ");
 
201
    fprintf(outfile.f, "%5d%5d%5d%5d%5d%5d", bx2, by2, bx2, by1, bx1, by1);
 
202
    uwriteln(&outfile, "%5d%5d%5d%5d 9999 9999", bx1, by2, bx2, by2);
 
203
  }
 
204
 
 
205
  fprintf(outfile.f, "4 0 %2d%3d", fig_fontno, fig_fontsize);
 
206
  fprintf(outfile.f, " 0 %2d 0 0.0 4 ", fig_fgnd);
 
207
  fprintf(outfile.f, "%3ld%3ld",(long)(dev_ysize+0.5), (long)(dev_xsize+0.5));
 
208
  fprintf(outfile.f, "%5ld%5ld %c",(long)(*xpos+0.5), (long)(*ypos+0.5), c);
 
209
  uwriteln(&outfile, "\001");
 
210
 
 
211
  if (fig_bgnd > 0)   /*end of compound*/
 
212
    uwriteln(&outfile, "-6");
 
213
 
 
214
  *xpos += dev_xsize;
 
215
}
 
216
 
 
217
static void FIGnewline(double *xpos, double *ypos) {
 
218
  *xpos = dev_minx;
 
219
  *ypos += dev_ysize;
 
220
}
 
221
 
 
222
static void FIGnewpage(double *xpos, double *ypos) {
 
223
  /* this should never happen*/
 
224
  FIGnewline(xpos, ypos);
 
225
}
 
226
 
 
227
static void FIGexit(void) {
 
228
  if (outfile.f != NULL)
 
229
    fclose(outfile.f);
 
230
  outfile.f = NULL;
 
231
}
 
232
 
 
233
GraphicsDevice Fig = {
 
234
  "fig",
 
235
  ask_fig,
 
236
  FIGinit,
 
237
  FIGsetcolor,
 
238
  FIGcharout,
 
239
  GenericStringOut,
 
240
  FIGnewline,
 
241
  FIGnewpage,
 
242
  FIGexit
 
243
};