8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# Copyright (c) P.J.Gawthrop, 1996.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.15 1996/12/30 19:23:35 peterg
## Allows for bent bonds - ie bonds with more than 2 line segments.
##
## Revision 1.14 1996/12/21 19:47:53 peterg
## Changed \* to \\*
##
## Revision 1.13 1996/12/21 19:47:23 peterg
|
>
>
>
>
>
>
>
>
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# Copyright (c) P.J.Gawthrop, 1996.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.16 1996/12/30 20:00:29 peterg
## Fixed bent-bond bug.
## NB unfixed problems:
## 1. xfig writes multi line fields if more than about 5 segments.
## 2. rbg2abg takes a multi-segment bond as a straignt line between the
## end points - so computation of stroke and arrow directions may be
## iffy.
##
## Revision 1.15 1996/12/30 19:23:35 peterg
## Allows for bent bonds - ie bonds with more than 2 line segments.
##
## Revision 1.14 1996/12/21 19:47:53 peterg
## Changed \* to \\*
##
## Revision 1.13 1996/12/21 19:47:23 peterg
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# as follows:
#
# Bonds are firm (not dashed etc) polylines with n line segments -
# fig represents this by a firstline record where
# field 1 = 2 (always 2)
# field 2 = 1 (polyline)
# field 3 = 0 (style is a firm line)
# field 14 = 0 (no forward arrow)
# field 15 = 0 (backward arrow)
# field 16 = Number of point in line (points=segments+1)
# a data field starting with a tab followed by points (x,y) cordinates
#
#
# Strokes are polylines with 1 line segment and and no arrow
|
>
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# as follows:
#
# Bonds are firm (not dashed etc) polylines with n line segments -
# fig represents this by a firstline record where
# field 1 = 2 (always 2)
# field 2 = 1 (polyline)
# field 3 = 0 (style is a firm line)
# field 7 = 0 (depth is zero [top level])
# field 14 = 0 (no forward arrow)
# field 15 = 0 (backward arrow)
# field 16 = Number of point in line (points=segments+1)
# a data field starting with a tab followed by points (x,y) cordinates
#
#
# Strokes are polylines with 1 line segment and and no arrow
|
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
|
function process_text() {
# The text string is field 14 onwards
str = $14;
for (i=15; i<=NF; i++) {
str = sprintf("%s %s", str, $i)
}
# It is terminated by /001 - so delete this termination
str = substr(str,1,length(str)-4);
# A component string contains only alphanumeric _ and :
isa_plain_component = match(str, component_regexp)==0;
# A port is an integer within [] and no alpha characters
isa_port = (match(str, port_regexp)>0)&&(match(str, nonport_regexp)==0);
# A port component is SS followed by : followed by a port string
isa_port_component = 0;
if (match(str, delimiter)) {
split(str,a,delimiter);
isa_port_component = (exact_match(a[1], "SS"))&&
(match(a[2], port_regexp)>0)
}
# A component is a plain or a port component
isa_component = isa_plain_component||isa_port_component;
# Coordinates in fields 12 & 13
x_coord = $12;
y_coord = $13;
|
>
>
>
>
>
>
>
>
>
>
|
|
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
|
function process_text() {
# The text string is field 14 onwards
str = $14;
for (i=15; i<=NF; i++) {
str = sprintf("%s %s", str, $i)
}
# The depth is field 4
depth = $4;
# It is terminated by /001 - so delete this termination
str = substr(str,1,length(str)-4);
# A component string contains only alphanumeric _ and :
isa_plain_component = match(str, component_regexp)==0;
# It must also be specified at depth 0
isa_plain_component = isa_plain_component && (depth==0);
# A port is an integer within [] and no alpha characters
isa_port = (match(str, port_regexp)>0)&&(match(str, nonport_regexp)==0);
# It must also be specified at depth 0
isa_port = isa_port && (depth==0);
# A port component is SS followed by : followed by a port string
isa_port_component = 0;
if (match(str, delimiter)) {
split(str,a,delimiter);
isa_port_component = (exact_match(a[1], "SS"))&&
(match(a[2], port_regexp)>0)
}
# It must also be specified at depth 0
isa_port_component = isa_port_component && (depth==0);
# A component is a plain or a port component
isa_component = isa_plain_component||isa_port_component;
# Coordinates in fields 12 & 13
x_coord = $12;
y_coord = $13;
|
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
first_line = (data_line==0)&&(NF>min_line_length);
#Process firstline
if (first_line) {
object = $1;
sub_type = $2;
style = $3;
f_arrow = ($14==1)&&(object=polyline);
b_arrow = ($15==1)&&(object=polyline);
arrow = f_arrow||b_arrow;
arg_count = 0;
}
#Process text
if (object==text) {
process_text()
}
# Process bond
if ( \
(data_line)&& \
(object==polyline)&& \
(sub_type==sub_polyline)&& \
(style==firm_style) \
) {
process_bond()
}
|
>
|
|
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
first_line = (data_line==0)&&(NF>min_line_length);
#Process firstline
if (first_line) {
object = $1;
sub_type = $2;
style = $3;
zero_depth = (($7==0)&&(object=polyline)) || (($4==0)&&(object=text));
f_arrow = ($14==1)&&(object=polyline);
b_arrow = ($15==1)&&(object=polyline);
arrow = f_arrow||b_arrow;
arg_count = 0;
}
#Process text
if (object==text) {
process_text()
}
# Process bond
if ( \
(data_line)&& zero_depth &&\
(object==polyline)&& \
(sub_type==sub_polyline)&& \
(style==firm_style) \
) {
process_bond()
}
|