line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LaTeX::PGF::Diagram2D; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
53614
|
use 5.000000; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
65
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
54
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
54
|
|
6
|
1
|
|
|
1
|
|
119
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
96
|
|
7
|
1
|
|
|
1
|
|
993
|
use POSIX; |
|
1
|
|
|
|
|
7455
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require LaTeX::PGF::Diagram2D::Axis; |
12
|
|
|
|
|
|
|
require LaTeX::PGF::Diagram2D::Plot; |
13
|
|
|
|
|
|
|
require LaTeX::PGF::Diagram2D::NumberPrinter; |
14
|
|
|
|
|
|
|
require LaTeX::PGF::Diagram2D::Label; |
15
|
|
|
|
|
|
|
require LaTeX::PGF::Diagram2D::Polyline; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Preloaded methods go here. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
0
|
|
|
my $self = undef; |
27
|
0
|
0
|
|
|
|
|
if($#_ < 2) { |
28
|
0
|
|
|
|
|
|
croak "Usage: LaTeX::PGF::Diagram2D->new(width,height)"; |
29
|
|
|
|
|
|
|
} else { |
30
|
0
|
|
|
|
|
|
my $class = shift; |
31
|
0
|
|
|
|
|
|
my $width = shift; |
32
|
0
|
|
|
|
|
|
my $height = shift; |
33
|
0
|
|
|
|
|
|
my @pl; |
34
|
|
|
|
|
|
|
my @co; |
35
|
0
|
|
|
|
|
|
my $ab = LaTeX::PGF::Diagram2D::Axis->new(); $ab->{'n'} = 'b'; |
|
0
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $al = LaTeX::PGF::Diagram2D::Axis->new(); $al->{'n'} = 'l'; |
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $ar = LaTeX::PGF::Diagram2D::Axis->new(); $ar->{'n'} = 'r'; |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $at = LaTeX::PGF::Diagram2D::Axis->new(); $at->{'n'} = 't'; |
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$ab->{'used'} = 1; |
40
|
0
|
|
|
|
|
|
$al->{'used'} = 1; |
41
|
0
|
|
|
|
|
|
$self = { |
42
|
|
|
|
|
|
|
'type' => 0, # Type: 0=grid, 1=quantitative, 2=qualitative |
43
|
|
|
|
|
|
|
'units' => 0, # Units: 0=cm, 1=inches, 2=bp |
44
|
|
|
|
|
|
|
'w' => $width, # Graph width |
45
|
|
|
|
|
|
|
'h' => $height, # Graph height |
46
|
|
|
|
|
|
|
'p' => \@pl, # Plots in the diagram |
47
|
|
|
|
|
|
|
'np' => 0, # Number of plots in array above |
48
|
|
|
|
|
|
|
'b' => $ab, # Bottom x axis |
49
|
|
|
|
|
|
|
'l' => $al, # Left y axis |
50
|
|
|
|
|
|
|
'r' => $ar, # Right y axis |
51
|
|
|
|
|
|
|
't' => $at, # Top x axis |
52
|
|
|
|
|
|
|
'texpre' => undef, # Additional LaTeX preamble lines |
53
|
|
|
|
|
|
|
'fs' => 10.0, # Font size |
54
|
|
|
|
|
|
|
'decsgn' => ',', # Decimal sign |
55
|
|
|
|
|
|
|
'contents' => \@co, # Additional contents |
56
|
|
|
|
|
|
|
'nco' => 0, # Number of elements in array above |
57
|
|
|
|
|
|
|
'x0' => 0.0, |
58
|
|
|
|
|
|
|
'x1' => 0.0, |
59
|
|
|
|
|
|
|
'x2' => 0.0, |
60
|
|
|
|
|
|
|
'x3' => 0.0, |
61
|
|
|
|
|
|
|
'x4' => 0.0, |
62
|
|
|
|
|
|
|
'x5' => 0.0, |
63
|
|
|
|
|
|
|
'x6' => 0.0, |
64
|
|
|
|
|
|
|
'x7' => 0.0, |
65
|
|
|
|
|
|
|
'y0' => 0.0, |
66
|
|
|
|
|
|
|
'y1' => 0.0, |
67
|
|
|
|
|
|
|
'y2' => 0.0, |
68
|
|
|
|
|
|
|
'y3' => 0.0, |
69
|
|
|
|
|
|
|
'y4' => 0.0, |
70
|
|
|
|
|
|
|
'y5' => 0.0, |
71
|
|
|
|
|
|
|
'y6' => 0.0, |
72
|
|
|
|
|
|
|
'y7' => 0.0, |
73
|
|
|
|
|
|
|
'x0bp' => 0.0, |
74
|
|
|
|
|
|
|
'x1bp' => 0.0, |
75
|
|
|
|
|
|
|
'x2bp' => 0.0, |
76
|
|
|
|
|
|
|
'x3bp' => 0.0, |
77
|
|
|
|
|
|
|
'x4bp' => 0.0, |
78
|
|
|
|
|
|
|
'x5bp' => 0.0, |
79
|
|
|
|
|
|
|
'x6bp' => 0.0, |
80
|
|
|
|
|
|
|
'x7bp' => 0.0, |
81
|
|
|
|
|
|
|
'y0bp' => 0.0, |
82
|
|
|
|
|
|
|
'y1bp' => 0.0, |
83
|
|
|
|
|
|
|
'y2bp' => 0.0, |
84
|
|
|
|
|
|
|
'y3bp' => 0.0, |
85
|
|
|
|
|
|
|
'y4bp' => 0.0, |
86
|
|
|
|
|
|
|
'y5bp' => 0.0, |
87
|
|
|
|
|
|
|
'y6bp' => 0.0, |
88
|
|
|
|
|
|
|
'y7bp' => 0.0, |
89
|
|
|
|
|
|
|
'f1' => undef, # Output file handle |
90
|
|
|
|
|
|
|
'fn1' => undef, # LaTeX output file name |
91
|
|
|
|
|
|
|
'ftf' => 0, # Flag: Full LaTeX file |
92
|
|
|
|
|
|
|
'debug' => 0, # Debugging |
93
|
|
|
|
|
|
|
'pgf_c' => undef, # Current color |
94
|
|
|
|
|
|
|
'pgf_w' => undef, # Current linewidth |
95
|
|
|
|
|
|
|
}; |
96
|
0
|
|
|
|
|
|
bless($self, $class); |
97
|
0
|
|
|
|
|
|
$ab->set_linear(0.0, $width)->set_grid_step(1.0)->set_tic_step(1.0); |
98
|
0
|
|
|
|
|
|
$al->set_linear(0.0, $height)->set_grid_step(1.0)->set_tic_step(1.0); |
99
|
0
|
|
|
|
|
|
$ar->set_linear(0.0, $height); |
100
|
0
|
|
|
|
|
|
$at->set_linear(0.0, $width); |
101
|
0
|
|
|
|
|
|
$ab->{'dg'} = $self; $al->{'dg'} = $self; |
|
0
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$ar->{'dg'} = $self; $at->{'dg'} = $self; |
|
0
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} |
104
|
0
|
|
|
|
|
|
return $self; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub rd |
110
|
|
|
|
|
|
|
{ |
111
|
0
|
|
|
0
|
|
|
my $back = undef; |
112
|
0
|
0
|
|
|
|
|
if($#_ < 2) { |
113
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->rd(value,digits)"; |
114
|
|
|
|
|
|
|
} else { |
115
|
0
|
|
|
|
|
|
my $self = shift; |
116
|
0
|
|
|
|
|
|
$back = shift; |
117
|
0
|
|
|
|
|
|
my $digits = shift; |
118
|
0
|
|
|
|
|
|
my $i = 0; |
119
|
0
|
|
|
|
|
|
for($i = 0; $i < $digits; $i++) { |
120
|
0
|
|
|
|
|
|
$back = 10.0 * $back; |
121
|
|
|
|
|
|
|
} |
122
|
0
|
|
|
|
|
|
$back = floor($back + 0.5); |
123
|
0
|
|
|
|
|
|
for($i = 0; $i < $digits; $i++) { |
124
|
0
|
|
|
|
|
|
$back = $back / 10.0; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
0
|
|
|
|
|
|
return $back; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub write_tex_coord |
133
|
|
|
|
|
|
|
{ |
134
|
0
|
|
|
0
|
|
|
my $self = shift; |
135
|
0
|
|
|
|
|
|
my $value = shift; |
136
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
137
|
0
|
|
|
|
|
|
$value = $self->rd($value, 5); |
138
|
0
|
|
|
|
|
|
my $t = sprintf("%g", $value); |
139
|
|
|
|
|
|
|
# ##### Exponentialschreibweise deaktivieren |
140
|
0
|
|
|
|
|
|
print $fh $t; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub write_point |
146
|
|
|
|
|
|
|
{ |
147
|
0
|
|
|
0
|
|
|
my $self = shift; |
148
|
0
|
|
|
|
|
|
my $x = shift; |
149
|
0
|
|
|
|
|
|
my $y = shift; |
150
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
151
|
0
|
|
|
|
|
|
print $fh "\\pgfpoint{"; |
152
|
0
|
|
|
|
|
|
$self->write_tex_coord($x); |
153
|
0
|
|
|
|
|
|
print $fh "bp}{"; |
154
|
0
|
|
|
|
|
|
$self->write_tex_coord($y); |
155
|
0
|
|
|
|
|
|
print $fh "bp}"; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub prepare_for_output |
161
|
|
|
|
|
|
|
{ |
162
|
0
|
|
|
0
|
|
|
my $back = undef; |
163
|
0
|
0
|
|
|
|
|
if($#_ < 0) { |
164
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->prepare_for_output()"; |
165
|
|
|
|
|
|
|
} else { |
166
|
0
|
|
|
|
|
|
my $self = shift; |
167
|
0
|
|
|
|
|
|
$back = 1; |
168
|
0
|
|
|
|
|
|
$self->{'b'}->correct_if_necessary($self, 0, $self->{'debug'}); |
169
|
0
|
|
|
|
|
|
$self->{'l'}->correct_if_necessary($self, 1, $self->{'debug'}); |
170
|
0
|
|
|
|
|
|
$self->{'r'}->correct_if_necessary($self, 1, $self->{'debug'}); |
171
|
0
|
|
|
|
|
|
$self->{'t'}->correct_if_necessary($self, 0, $self->{'debug'}); |
172
|
0
|
|
|
|
|
|
$self->{'x0'} = 0.0; |
173
|
0
|
|
|
|
|
|
$self->{'x3'} = $self->{'l'}->{'bo'}; |
174
|
0
|
|
|
|
|
|
$self->{'x2'} = $self->{'x3'}; $self->{'x1'} = $self->{'x3'}; |
|
0
|
|
|
|
|
|
|
175
|
0
|
0
|
|
|
|
|
if($self->{'l'}->{'to'} > 0.0) { |
176
|
0
|
|
|
|
|
|
$self->{'x2'} = $self->{'x3'} - $self->{'l'}->{'to'}; |
177
|
|
|
|
|
|
|
} |
178
|
0
|
0
|
|
|
|
|
if($self->{'l'}->{'lo'} > 0.0) { |
179
|
0
|
|
|
|
|
|
$self->{'x1'} = $self->{'x3'} - $self->{'l'}->{'lo'}; |
180
|
|
|
|
|
|
|
} |
181
|
0
|
|
|
|
|
|
$self->{'x4'} = $self->{'x3'} + $self->{'w'}; |
182
|
0
|
|
|
|
|
|
$self->{'x5'} = $self->{'x4'}; $self->{'x6'} = $self->{'x4'}; |
|
0
|
|
|
|
|
|
|
183
|
0
|
0
|
|
|
|
|
if($self->{'r'}->{'to'} > 0.0) { |
184
|
0
|
|
|
|
|
|
$self->{'x5'} = $self->{'x4'} + $self->{'r'}->{'to'}; |
185
|
|
|
|
|
|
|
} |
186
|
0
|
0
|
|
|
|
|
if($self->{'r'}->{'lo'} > 0.0) { |
187
|
0
|
|
|
|
|
|
$self->{'x6'} = $self->{'x4'} + $self->{'r'}->{'lo'}; |
188
|
|
|
|
|
|
|
} |
189
|
0
|
|
|
|
|
|
$self->{'x7'} = $self->{'x4'} + $self->{'r'}->{'bo'}; |
190
|
0
|
|
|
|
|
|
$self->{'y0'} = 0.0; |
191
|
0
|
|
|
|
|
|
$self->{'y3'} = $self->{'b'}->{'bo'}; |
192
|
0
|
|
|
|
|
|
$self->{'y1'} = $self->{'y3'}; $self->{'y2'} = $self->{'y3'}; |
|
0
|
|
|
|
|
|
|
193
|
0
|
0
|
|
|
|
|
if($self->{'b'}->{'to'} > 0.0) { |
194
|
0
|
|
|
|
|
|
$self->{'y2'} = $self->{'y3'} - $self->{'b'}->{'to'}; |
195
|
0
|
0
|
|
|
|
|
if($self->{'units'} == 1) { |
196
|
0
|
|
|
|
|
|
$self->{'y2'} = $self->{'y2'} - ($self->{'fs'} / 72.27); |
197
|
|
|
|
|
|
|
} else { |
198
|
0
|
0
|
|
|
|
|
if($self->{'units'} == 2) { |
199
|
0
|
|
|
|
|
|
$self->{'y2'} = $self->{'y2'} - ((72.0 * $self->{'fs'}) / 72.27); |
200
|
|
|
|
|
|
|
} else { |
201
|
0
|
|
|
|
|
|
$self->{'y2'} = $self->{'y2'} - ((2.54 * $self->{'fs'}) / 72.27); |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
} |
205
|
0
|
0
|
|
|
|
|
if($self->{'b'}->{'lo'} > 0.0) { |
206
|
0
|
|
|
|
|
|
$self->{'y1'} = $self->{'y3'} - $self->{'b'}->{'lo'}; |
207
|
|
|
|
|
|
|
} |
208
|
0
|
|
|
|
|
|
$self->{'y4'} = $self->{'y3'} + $self->{'h'}; |
209
|
0
|
|
|
|
|
|
$self->{'y5'} = $self->{'y4'}; $self->{'y6'} = $self->{'y4'}; |
|
0
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
$self->{'y7'} = $self->{'y4'} + $self->{'t'}->{'bo'}; |
211
|
0
|
0
|
|
|
|
|
if($self->{'t'}->{'to'} > 0.0) { |
212
|
0
|
|
|
|
|
|
$self->{'y5'} = $self->{'y4'} + $self->{'t'}->{'to'}; |
213
|
|
|
|
|
|
|
} |
214
|
0
|
0
|
|
|
|
|
if($self->{'t'}->{'lo'} > 0.0) { |
215
|
0
|
|
|
|
|
|
$self->{'y6'} = $self->{'y4'} + $self->{'t'}->{'lo'}; |
216
|
|
|
|
|
|
|
} |
217
|
0
|
|
|
|
|
|
my $scf; |
218
|
0
|
0
|
|
|
|
|
if($self->{'units'} == 1) { |
219
|
0
|
|
|
|
|
|
$scf = 72.0; |
220
|
|
|
|
|
|
|
} else { |
221
|
0
|
0
|
|
|
|
|
if($self->{'units'} == 2) { |
222
|
0
|
|
|
|
|
|
$scf = 1.0; |
223
|
|
|
|
|
|
|
} else { |
224
|
0
|
|
|
|
|
|
$scf = 72.0 / 2.54; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
} |
227
|
0
|
|
|
|
|
|
$self->{'x0bp'} = $self->rd($scf * $self->{'x0'}, 5); |
228
|
0
|
|
|
|
|
|
$self->{'x1bp'} = $self->rd($scf * $self->{'x1'}, 5); |
229
|
0
|
|
|
|
|
|
$self->{'x2bp'} = $self->rd($scf * $self->{'x2'}, 5); |
230
|
0
|
|
|
|
|
|
$self->{'x3bp'} = $self->rd($scf * $self->{'x3'}, 5); |
231
|
0
|
|
|
|
|
|
$self->{'x4bp'} = $self->rd($scf * $self->{'x4'}, 5); |
232
|
0
|
|
|
|
|
|
$self->{'x5bp'} = $self->rd($scf * $self->{'x5'}, 5); |
233
|
0
|
|
|
|
|
|
$self->{'x6bp'} = $self->rd($scf * $self->{'x6'}, 5); |
234
|
0
|
|
|
|
|
|
$self->{'x7bp'} = $self->rd($scf * $self->{'x7'}, 5); |
235
|
0
|
|
|
|
|
|
$self->{'y0bp'} = $self->rd($scf * $self->{'y0'}, 5); |
236
|
0
|
|
|
|
|
|
$self->{'y1bp'} = $self->rd($scf * $self->{'y1'}, 5); |
237
|
0
|
|
|
|
|
|
$self->{'y2bp'} = $self->rd($scf * $self->{'y2'}, 5); |
238
|
0
|
|
|
|
|
|
$self->{'y3bp'} = $self->rd($scf * $self->{'y3'}, 5); |
239
|
0
|
|
|
|
|
|
$self->{'y4bp'} = $self->rd($scf * $self->{'y4'}, 5); |
240
|
0
|
|
|
|
|
|
$self->{'y5bp'} = $self->rd($scf * $self->{'y5'}, 5); |
241
|
0
|
|
|
|
|
|
$self->{'y6bp'} = $self->rd($scf * $self->{'y6'}, 5); |
242
|
0
|
|
|
|
|
|
$self->{'y7bp'} = $self->rd($scf * $self->{'y7'}, 5); |
243
|
|
|
|
|
|
|
# ##### Check and prepare |
244
|
0
|
0
|
|
|
|
|
if($self->{'debug'}) { |
245
|
0
|
|
|
|
|
|
print "DEBUG x0 = " . $self->{'x0'} . "\n"; |
246
|
0
|
|
|
|
|
|
print "DEBUG x1 = " . $self->{'x1'} . "\n"; |
247
|
0
|
|
|
|
|
|
print "DEBUG x2 = " . $self->{'x2'} . "\n"; |
248
|
0
|
|
|
|
|
|
print "DEBUG x3 = " . $self->{'x3'} . "\n"; |
249
|
0
|
|
|
|
|
|
print "DEBUG x4 = " . $self->{'x4'} . "\n"; |
250
|
0
|
|
|
|
|
|
print "DEBUG x5 = " . $self->{'x5'} . "\n"; |
251
|
0
|
|
|
|
|
|
print "DEBUG x6 = " . $self->{'x6'} . "\n"; |
252
|
0
|
|
|
|
|
|
print "DEBUG x7 = " . $self->{'x7'} . "\n"; |
253
|
0
|
|
|
|
|
|
print "DEBUG y0 = " . $self->{'y0'} . "\n"; |
254
|
0
|
|
|
|
|
|
print "DEBUG y1 = " . $self->{'y1'} . "\n"; |
255
|
0
|
|
|
|
|
|
print "DEBUG y2 = " . $self->{'y2'} . "\n"; |
256
|
0
|
|
|
|
|
|
print "DEBUG y3 = " . $self->{'y3'} . "\n"; |
257
|
0
|
|
|
|
|
|
print "DEBUG y4 = " . $self->{'y4'} . "\n"; |
258
|
0
|
|
|
|
|
|
print "DEBUG y5 = " . $self->{'y5'} . "\n"; |
259
|
0
|
|
|
|
|
|
print "DEBUG y6 = " . $self->{'y6'} . "\n"; |
260
|
0
|
|
|
|
|
|
print "DEBUG y7 = " . $self->{'y7'} . "\n"; |
261
|
0
|
|
|
|
|
|
print "DEBUG x0bp = " . $self->{'x0bp'} . "\n"; |
262
|
0
|
|
|
|
|
|
print "DEBUG x1bp = " . $self->{'x1bp'} . "\n"; |
263
|
0
|
|
|
|
|
|
print "DEBUG x2bp = " . $self->{'x2bp'} . "\n"; |
264
|
0
|
|
|
|
|
|
print "DEBUG x3bp = " . $self->{'x3bp'} . "\n"; |
265
|
0
|
|
|
|
|
|
print "DEBUG x4bp = " . $self->{'x4bp'} . "\n"; |
266
|
0
|
|
|
|
|
|
print "DEBUG x5bp = " . $self->{'x5bp'} . "\n"; |
267
|
0
|
|
|
|
|
|
print "DEBUG x6bp = " . $self->{'x6bp'} . "\n"; |
268
|
0
|
|
|
|
|
|
print "DEBUG x7bp = " . $self->{'x7bp'} . "\n"; |
269
|
0
|
|
|
|
|
|
print "DEBUG y0bp = " . $self->{'y0bp'} . "\n"; |
270
|
0
|
|
|
|
|
|
print "DEBUG y1bp = " . $self->{'y1bp'} . "\n"; |
271
|
0
|
|
|
|
|
|
print "DEBUG y2bp = " . $self->{'y2bp'} . "\n"; |
272
|
0
|
|
|
|
|
|
print "DEBUG y3bp = " . $self->{'y3bp'} . "\n"; |
273
|
0
|
|
|
|
|
|
print "DEBUG y4bp = " . $self->{'y4bp'} . "\n"; |
274
|
0
|
|
|
|
|
|
print "DEBUG y5bp = " . $self->{'y5bp'} . "\n"; |
275
|
0
|
|
|
|
|
|
print "DEBUG y6bp = " . $self->{'y6bp'} . "\n"; |
276
|
0
|
|
|
|
|
|
print "DEBUG y7bp = " . $self->{'y7bp'} . "\n"; |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
} |
279
|
0
|
|
|
|
|
|
return $back; |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
sub write_rect |
285
|
|
|
|
|
|
|
{ |
286
|
0
|
|
|
0
|
|
|
my $self = shift; |
287
|
0
|
|
|
|
|
|
my $x0 = shift; my $y0 = shift; my $x1 = shift; my $y1 = shift; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
288
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
289
|
0
|
|
|
|
|
|
print $fh "\\pgfpathmoveto{"; |
290
|
0
|
|
|
|
|
|
$self->write_point($x0, $y0); |
291
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfpathlineto{"; |
292
|
0
|
|
|
|
|
|
$self->write_point($x1, $y0); |
293
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfpathlineto{"; |
294
|
0
|
|
|
|
|
|
$self->write_point($x1, $y1); |
295
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfpathlineto{"; |
296
|
0
|
|
|
|
|
|
$self->write_point($x0, $y1); |
297
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfpathclose\n"; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
sub write_clip |
304
|
|
|
|
|
|
|
{ |
305
|
0
|
|
|
0
|
|
|
my $self = shift; |
306
|
0
|
|
|
|
|
|
my $x0 = shift; my $y0 = shift; my $x1 = shift; my $y1 = shift; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
308
|
0
|
|
|
|
|
|
$self->write_rect($x0, $y0, $x1, $y1); |
309
|
0
|
|
|
|
|
|
print $fh "\\pgfusepath{clip}\n"; |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
sub setlinewidth_mm |
314
|
|
|
|
|
|
|
{ |
315
|
0
|
|
|
0
|
|
|
my $self = undef; |
316
|
0
|
0
|
|
|
|
|
if($#_ < 1) { |
317
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->setlinewidth_mm(value)"; |
318
|
|
|
|
|
|
|
} else { |
319
|
0
|
|
|
|
|
|
$self = shift; my $value = shift; |
|
0
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
321
|
0
|
|
|
|
|
|
$value = $value / 10.0; $value = $self->rd($value, 5); |
|
0
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
|
my $mustprint = 1; |
323
|
0
|
0
|
|
|
|
|
if(defined($self->{'pgf_w'})) { |
324
|
0
|
0
|
|
|
|
|
if($self->{'pgf_w'} eq "$value") { |
325
|
0
|
|
|
|
|
|
$mustprint = 0; |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
} |
328
|
0
|
0
|
|
|
|
|
if($mustprint) { |
329
|
0
|
|
|
|
|
|
print $fh "\\pgfsetlinewidth{" . $value . "cm}\n"; |
330
|
0
|
|
|
|
|
|
$self->{'pgf_w'} = $value; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
} |
333
|
0
|
|
|
|
|
|
return $self; |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub set_color |
339
|
|
|
|
|
|
|
{ |
340
|
0
|
|
|
0
|
|
|
my $self = shift; |
341
|
0
|
|
|
|
|
|
my $color = shift; |
342
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
343
|
0
|
|
|
|
|
|
my $mustprint = 1; |
344
|
0
|
0
|
|
|
|
|
if(defined($self->{'pgf_c'})) { |
345
|
0
|
0
|
|
|
|
|
if($self->{'pgf_c'} eq "$color") { |
346
|
0
|
|
|
|
|
|
$mustprint = 0; |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
} |
349
|
0
|
0
|
|
|
|
|
if($mustprint) { |
350
|
0
|
|
|
|
|
|
print $fh "\\pgfsetcolor{$color}\n"; |
351
|
0
|
|
|
|
|
|
$self->{'pgf_c'} = $color; |
352
|
|
|
|
|
|
|
} |
353
|
0
|
|
|
|
|
|
return $self; |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
sub begin_pgfscope |
359
|
|
|
|
|
|
|
{ |
360
|
0
|
|
|
0
|
|
|
my $self = shift; |
361
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
362
|
0
|
|
|
|
|
|
print $fh "\\begin{pgfscope}\n"; |
363
|
0
|
|
|
|
|
|
return $self; |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
sub end_pgfscope |
369
|
|
|
|
|
|
|
{ |
370
|
0
|
|
|
0
|
|
|
my $self = shift; |
371
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
372
|
0
|
|
|
|
|
|
print $fh "\\end{pgfscope}\n"; |
373
|
0
|
|
|
|
|
|
$self->{'pgf_c'} = undef; |
374
|
0
|
|
|
|
|
|
$self->{'pgf_w'} = undef; |
375
|
0
|
|
|
|
|
|
return $self; |
376
|
|
|
|
|
|
|
} |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
sub draw_axis_grid |
381
|
|
|
|
|
|
|
{ |
382
|
0
|
|
|
0
|
|
|
my $self = shift; |
383
|
0
|
|
|
|
|
|
my $ax = shift; |
384
|
0
|
|
|
|
|
|
my $xyflag = shift; |
385
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
386
|
0
|
|
|
|
|
|
my $xs = $ax->{'min'}; my $xe = $ax->{'max'}; |
|
0
|
|
|
|
|
|
|
387
|
0
|
|
|
|
|
|
my $st = $ax->{'gs'}; |
388
|
0
|
0
|
|
|
|
|
if($st > 0.0) { |
389
|
0
|
0
|
|
|
|
|
if($ax->{'min'} > $ax->{'max'}) { |
390
|
0
|
|
|
|
|
|
$xs = $ax->{'max'}; $xe = $ax->{'min'}; |
|
0
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
} |
392
|
0
|
|
|
|
|
|
my $x = $xs; my $num = 0; |
|
0
|
|
|
|
|
|
|
393
|
0
|
|
|
|
|
|
my $mustprint = 1; my $co = 0.0; |
|
0
|
|
|
|
|
|
|
394
|
0
|
0
|
|
|
|
|
if($self->{'debug'}) { |
395
|
0
|
|
|
|
|
|
print "DEBUG (1) xs=$xs xe=$xe st=$st x=$x\n"; |
396
|
|
|
|
|
|
|
} |
397
|
0
|
|
0
|
|
|
|
while(($x < $xe) && ($num < 1000)) { |
398
|
0
|
0
|
|
|
|
|
if($ax->{'t'}) { |
399
|
0
|
0
|
|
|
|
|
if($st > 1.0) { |
400
|
0
|
|
|
|
|
|
$x = $x * $st; |
401
|
|
|
|
|
|
|
} else { |
402
|
0
|
|
|
|
|
|
$x = $x / $st; |
403
|
|
|
|
|
|
|
} |
404
|
|
|
|
|
|
|
} else { |
405
|
0
|
|
|
|
|
|
$x = $x + $st; |
406
|
|
|
|
|
|
|
} |
407
|
0
|
0
|
|
|
|
|
if($self->{'debug'}) { |
408
|
0
|
|
|
|
|
|
print "DEBUG (2) xs=$xs xe=$xe st=$st x=$x\n"; |
409
|
|
|
|
|
|
|
} |
410
|
0
|
|
|
|
|
|
$mustprint = 1; |
411
|
0
|
0
|
|
|
|
|
if($ax->{'t'}) { |
412
|
0
|
0
|
|
|
|
|
if($st > 1.0) { |
413
|
0
|
0
|
|
|
|
|
if($x < ($xs * sqrt($st))) { |
414
|
0
|
|
|
|
|
|
$mustprint = 0; |
415
|
|
|
|
|
|
|
} else { |
416
|
0
|
0
|
|
|
|
|
if($x > ($xe / sqrt($st))) { |
417
|
0
|
|
|
|
|
|
$mustprint = 0; |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
} else { |
421
|
0
|
0
|
|
|
|
|
if($x < ($xs / sqrt($st))) { |
422
|
0
|
|
|
|
|
|
$mustprint = 0; |
423
|
|
|
|
|
|
|
} else { |
424
|
0
|
0
|
|
|
|
|
if($x < ($xs * sqrt($st))) { |
425
|
0
|
|
|
|
|
|
$mustprint = 0; |
426
|
|
|
|
|
|
|
} |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
} |
429
|
|
|
|
|
|
|
} else { |
430
|
0
|
0
|
|
|
|
|
if($x < ($xs + 0.5 * $st)) { |
431
|
0
|
|
|
|
|
|
$mustprint = 0; |
432
|
|
|
|
|
|
|
} else { |
433
|
0
|
0
|
|
|
|
|
if($x > ($xe - 0.5 * $st)) { |
434
|
0
|
|
|
|
|
|
$mustprint = 0; |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
} |
438
|
0
|
0
|
|
|
|
|
if($mustprint) { |
439
|
0
|
|
|
|
|
|
my $co = $ax->value_to_coord($x); |
440
|
0
|
|
|
|
|
|
print $fh "\\pgfpathmoveto{"; |
441
|
0
|
0
|
|
|
|
|
if($xyflag) { |
442
|
0
|
|
|
|
|
|
$self->write_point($self->{'x3bp'}, $co); |
443
|
|
|
|
|
|
|
} else { |
444
|
0
|
|
|
|
|
|
$self->write_point($co, $self->{'y3bp'}); |
445
|
|
|
|
|
|
|
} |
446
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfpathlineto{"; |
447
|
0
|
0
|
|
|
|
|
if($xyflag) { |
448
|
0
|
|
|
|
|
|
$self->write_point($self->{'x4bp'}, $co); |
449
|
|
|
|
|
|
|
} else { |
450
|
0
|
|
|
|
|
|
$self->write_point($co, $self->{'y4bp'}); |
451
|
|
|
|
|
|
|
} |
452
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfusepath{stroke}\n"; |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
} |
456
|
0
|
|
|
|
|
|
return $self; |
457
|
|
|
|
|
|
|
} |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
sub draw_grid |
461
|
|
|
|
|
|
|
{ |
462
|
0
|
|
|
0
|
|
|
my $self = shift; |
463
|
0
|
|
|
|
|
|
$self->draw_axis_grid($self->{'b'}, 0); |
464
|
0
|
|
|
|
|
|
$self->draw_axis_grid($self->{'l'}, 1); |
465
|
0
|
|
|
|
|
|
return $self; |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
sub text_label_number |
471
|
|
|
|
|
|
|
{ |
472
|
0
|
|
|
0
|
|
|
my $self = shift; |
473
|
0
|
|
|
|
|
|
my $x = shift; # X coordinate |
474
|
0
|
|
|
|
|
|
my $y = shift; # Y coordinate |
475
|
0
|
|
|
|
|
|
my $p = shift; # Position string |
476
|
0
|
|
|
|
|
|
my $n = shift; # NumberPrinter |
477
|
0
|
|
|
|
|
|
my $v = shift; # Value |
478
|
0
|
|
|
|
|
|
my $vt; |
479
|
|
|
|
|
|
|
my $pa; |
480
|
0
|
|
|
|
|
|
my $pb; |
481
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
482
|
0
|
|
|
|
|
|
print $fh "\\pgftext[$p,at={"; |
483
|
0
|
|
|
|
|
|
$self->write_point($x, $y); |
484
|
0
|
|
|
|
|
|
print $fh "}]{"; |
485
|
0
|
0
|
|
|
|
|
if(defined($n)) { |
486
|
0
|
|
|
|
|
|
$n->write_number($fh, $v); |
487
|
|
|
|
|
|
|
} else { |
488
|
0
|
|
|
|
|
|
$vt = sprintf("%g", $v); |
489
|
0
|
0
|
|
|
|
|
if("$vt" =~ /(.*)\.(.*)/o) { |
490
|
0
|
|
|
|
|
|
$pa = $1; $pb = $2; |
|
0
|
|
|
|
|
|
|
491
|
0
|
|
|
|
|
|
print $fh "$pa" . $self->{'decsgn'} . "$pb"; |
492
|
|
|
|
|
|
|
} else { |
493
|
0
|
|
|
|
|
|
print $fh "$vt"; |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
} |
496
|
0
|
|
|
|
|
|
print $fh "}\n"; |
497
|
0
|
|
|
|
|
|
return $self; |
498
|
|
|
|
|
|
|
} |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
sub text_label |
503
|
|
|
|
|
|
|
{ |
504
|
0
|
|
|
0
|
|
|
my $self = shift; |
505
|
0
|
|
|
|
|
|
my $x = shift; # X coordinate |
506
|
0
|
|
|
|
|
|
my $y = shift; # Y coordinate |
507
|
0
|
|
|
|
|
|
my $p = shift; # Position string |
508
|
0
|
|
|
|
|
|
my $t = shift; # NumberPrinter |
509
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
510
|
0
|
|
|
|
|
|
print $fh "\\pgftext[$p,at={"; |
511
|
0
|
|
|
|
|
|
$self->write_point($x, $y); |
512
|
0
|
|
|
|
|
|
print $fh "}]{$t}\n"; |
513
|
0
|
|
|
|
|
|
return $self; |
514
|
|
|
|
|
|
|
} |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
sub tics_for_axis |
518
|
|
|
|
|
|
|
{ |
519
|
0
|
|
|
0
|
|
|
my $self = shift; |
520
|
0
|
|
|
|
|
|
my $ax = shift; |
521
|
0
|
0
|
0
|
|
|
|
if(($ax->{'used'}) && ($ax->{'ts'} > 0.0)) { |
522
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
523
|
0
|
|
|
|
|
|
my $co = $self->{'y2bp'}; |
524
|
0
|
|
|
|
|
|
my $c2 = 0.0; |
525
|
0
|
|
|
|
|
|
my $xyflag = 0; |
526
|
0
|
|
|
|
|
|
my $position = "base"; |
527
|
0
|
|
|
|
|
|
my $xs = $ax->{'min'}; |
528
|
0
|
|
|
|
|
|
my $xe = $ax->{'max'}; |
529
|
0
|
|
|
|
|
|
my $st = $ax->{'ts'}; |
530
|
0
|
|
|
|
|
|
my $num = 0; # Number of attempts |
531
|
0
|
|
|
|
|
|
my $in = 0; # Inner values |
532
|
0
|
|
|
|
|
|
my $ci = 0; # Current inner value |
533
|
0
|
|
|
|
|
|
my $x = 0.0; # Current x to handle |
534
|
0
|
|
|
|
|
|
my $cc = 1; # Flag: Can continue |
535
|
0
|
|
|
|
|
|
my $ca = 0; # Flag: Candidate |
536
|
0
|
|
|
|
|
|
my $mut = 0; # Flag: Must use this |
537
|
0
|
|
|
|
|
|
my $np = LaTeX::PGF::Diagram2D::NumberPrinter->new(); |
538
|
0
|
|
|
|
|
|
my $pnp = $np; |
539
|
0
|
0
|
|
|
|
|
if($ax->{'t'}) { |
540
|
0
|
|
|
|
|
|
$pnp = undef; |
541
|
|
|
|
|
|
|
} |
542
|
0
|
|
|
|
|
|
$np->init(); |
543
|
0
|
0
|
|
|
|
|
if($ax->{'n'} eq 'l') { |
544
|
0
|
|
|
|
|
|
$xyflag = 1; $co = $self->{'x2bp'}; $position = "right"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
} |
546
|
0
|
0
|
|
|
|
|
if($ax->{'n'} eq 'r') { |
547
|
0
|
|
|
|
|
|
$xyflag = 1; $co = $self->{'x5bp'}; $position = "right"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
} |
549
|
0
|
0
|
|
|
|
|
if($ax->{'n'} eq 't') { |
550
|
0
|
|
|
|
|
|
$co = $self->{'y5bp'}; |
551
|
|
|
|
|
|
|
} |
552
|
0
|
|
|
|
|
|
for(my $passno = 0; $passno < 3; $passno++) { |
553
|
|
|
|
|
|
|
# first value |
554
|
0
|
0
|
|
|
|
|
if($passno == 1) { |
555
|
0
|
|
|
|
|
|
$np->add_number($xs); |
556
|
|
|
|
|
|
|
} |
557
|
0
|
0
|
|
|
|
|
if($passno == 2) { |
558
|
0
|
|
|
|
|
|
$c2 = $ax->value_to_coord($xs); |
559
|
0
|
0
|
|
|
|
|
if($xyflag) { |
560
|
0
|
|
|
|
|
|
$self->text_label_number($co, $c2, $position, $pnp, $xs); |
561
|
|
|
|
|
|
|
} else { |
562
|
0
|
|
|
|
|
|
$self->text_label_number($c2, $co, $position, $pnp, $xs); |
563
|
|
|
|
|
|
|
} |
564
|
|
|
|
|
|
|
} |
565
|
|
|
|
|
|
|
# last value |
566
|
0
|
0
|
|
|
|
|
if($passno == 1) { |
567
|
0
|
|
|
|
|
|
$np->add_number($xe); |
568
|
|
|
|
|
|
|
} |
569
|
0
|
0
|
|
|
|
|
if($passno == 2) { |
570
|
0
|
|
|
|
|
|
$c2 = $ax->value_to_coord($xe); |
571
|
0
|
0
|
|
|
|
|
if($xyflag) { |
572
|
0
|
|
|
|
|
|
$self->text_label_number($co, $c2, $position, $pnp, $xe); |
573
|
|
|
|
|
|
|
} else { |
574
|
0
|
|
|
|
|
|
$self->text_label_number($c2, $co, $position, $pnp, $xe); |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
# values in the middle |
578
|
0
|
|
|
|
|
|
$x = $xs; $cc = 1; $num = 0; $ci = 0; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
579
|
0
|
|
|
|
|
|
while($cc) { |
580
|
0
|
0
|
|
|
|
|
if($num++ > 1000) { |
581
|
0
|
|
|
|
|
|
$cc = 0; |
582
|
|
|
|
|
|
|
} |
583
|
0
|
|
|
|
|
|
$ca = 0; |
584
|
0
|
0
|
|
|
|
|
if($xe > $xs) { # Normal scale |
585
|
0
|
0
|
|
|
|
|
if($ax->{'t'}) { |
586
|
0
|
0
|
|
|
|
|
if($st > 1.0) { |
587
|
0
|
|
|
|
|
|
$x = $x * $st; |
588
|
0
|
0
|
|
|
|
|
if($x > ($xs * sqrt($st))) { |
589
|
0
|
0
|
|
|
|
|
if($x < ($xe / sqrt($st))) { |
590
|
0
|
|
|
|
|
|
$ca = 1; |
591
|
|
|
|
|
|
|
} else { |
592
|
0
|
|
|
|
|
|
$cc = 0; |
593
|
|
|
|
|
|
|
} |
594
|
|
|
|
|
|
|
} |
595
|
|
|
|
|
|
|
} else { |
596
|
0
|
|
|
|
|
|
$x = $x / $st; |
597
|
0
|
0
|
|
|
|
|
if($x > ($xs / sqrt($st))) { |
598
|
0
|
0
|
|
|
|
|
if($x < ($xe * sqrt($st))) { |
599
|
0
|
|
|
|
|
|
$ca = 1; |
600
|
|
|
|
|
|
|
} else { |
601
|
0
|
|
|
|
|
|
$cc = 0; |
602
|
|
|
|
|
|
|
} |
603
|
|
|
|
|
|
|
} |
604
|
|
|
|
|
|
|
} |
605
|
|
|
|
|
|
|
} else { |
606
|
0
|
|
|
|
|
|
$x = $x + $st; |
607
|
0
|
0
|
|
|
|
|
if($x > ($xs + 0.5 * $st)) { |
608
|
0
|
0
|
|
|
|
|
if($x < ($xe - 0.5 * $st)) { |
609
|
0
|
|
|
|
|
|
$ca = 1; |
610
|
|
|
|
|
|
|
} else { |
611
|
0
|
|
|
|
|
|
$cc = 0; |
612
|
|
|
|
|
|
|
} |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
} |
615
|
|
|
|
|
|
|
} else { # Inverted scale |
616
|
0
|
0
|
|
|
|
|
if($ax->{'t'}) { |
617
|
0
|
0
|
|
|
|
|
if($st > 1.0) { |
618
|
0
|
|
|
|
|
|
$x = $x / $st; |
619
|
0
|
0
|
|
|
|
|
if($x < ($xs / sqrt($st))) { |
620
|
0
|
0
|
|
|
|
|
if($x > ($xe * sqrt($st))) { |
621
|
0
|
|
|
|
|
|
$ca = 1; |
622
|
|
|
|
|
|
|
} else { |
623
|
0
|
|
|
|
|
|
$cc = 0; |
624
|
|
|
|
|
|
|
} |
625
|
|
|
|
|
|
|
} |
626
|
|
|
|
|
|
|
} else { |
627
|
0
|
|
|
|
|
|
$x = $x * $st; |
628
|
0
|
0
|
|
|
|
|
if($x < ($xs * sqrt($st))) { |
629
|
0
|
0
|
|
|
|
|
if($x > ($xe / sqrt($st))) { |
630
|
0
|
|
|
|
|
|
$ca = 1; |
631
|
|
|
|
|
|
|
} else { |
632
|
0
|
|
|
|
|
|
$cc = 0; |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
} |
636
|
|
|
|
|
|
|
} else { |
637
|
0
|
|
|
|
|
|
$x = $x - $st; |
638
|
0
|
0
|
|
|
|
|
if($x < ($xs - 0.5 * $st)) { |
639
|
0
|
0
|
|
|
|
|
if($x > ($xe + 0.5 * $st)) { |
640
|
0
|
|
|
|
|
|
$ca = 1; |
641
|
|
|
|
|
|
|
} else { |
642
|
0
|
|
|
|
|
|
$cc = 0; |
643
|
|
|
|
|
|
|
} |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
} |
646
|
|
|
|
|
|
|
} |
647
|
0
|
0
|
|
|
|
|
if($ca) { |
648
|
0
|
0
|
|
|
|
|
if($passno == 0) { |
649
|
0
|
|
|
|
|
|
$in++; |
650
|
|
|
|
|
|
|
} else { |
651
|
0
|
|
|
|
|
|
$mut = 1; |
652
|
0
|
0
|
|
|
|
|
if(defined($ax->{'u'})) { |
653
|
0
|
0
|
|
|
|
|
if($ax->{'omit'}) { |
654
|
0
|
0
|
|
|
|
|
if($ci >= ($in - $ax->{'omit'})) { |
655
|
0
|
|
|
|
|
|
$mut = 0; |
656
|
|
|
|
|
|
|
} |
657
|
|
|
|
|
|
|
} |
658
|
|
|
|
|
|
|
} |
659
|
0
|
0
|
|
|
|
|
if($mut) { |
660
|
0
|
0
|
|
|
|
|
if($passno == 1) { |
661
|
0
|
|
|
|
|
|
$np->add_number($x); |
662
|
|
|
|
|
|
|
} |
663
|
0
|
0
|
|
|
|
|
if($passno == 2) { |
664
|
0
|
|
|
|
|
|
$c2 = $ax->value_to_coord($x); |
665
|
0
|
0
|
|
|
|
|
if($xyflag) { |
666
|
0
|
|
|
|
|
|
$self->text_label_number($co, $c2, $position, $pnp, $x); |
667
|
|
|
|
|
|
|
} else { |
668
|
0
|
|
|
|
|
|
$self->text_label_number($c2, $co, $position, $pnp, $x); |
669
|
|
|
|
|
|
|
} |
670
|
|
|
|
|
|
|
} |
671
|
|
|
|
|
|
|
} |
672
|
|
|
|
|
|
|
} |
673
|
0
|
|
|
|
|
|
$ci++; |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
} |
676
|
|
|
|
|
|
|
} |
677
|
0
|
0
|
|
|
|
|
if(defined($ax->{'u'})) { |
678
|
0
|
|
|
|
|
|
$x = (1.0 * $in + 0.5 - 0.5 * $ax->{'omit'})/(1.0 + $in); |
679
|
0
|
0
|
|
|
|
|
if($xyflag) { |
680
|
0
|
|
|
|
|
|
$x = $self->{'y3bp'} + $x * ($self->{'y4bp'} - $self->{'y3bp'}); |
681
|
0
|
|
|
|
|
|
$self->text_label($co, $x, $position, $ax->{'u'}); |
682
|
|
|
|
|
|
|
} else { |
683
|
0
|
|
|
|
|
|
$x = $self->{'x3bp'} + $x * ($self->{'x4bp'} - $self->{'x3bp'}); |
684
|
0
|
|
|
|
|
|
$self->text_label($x, $co, $position, $ax->{'u'}); |
685
|
|
|
|
|
|
|
} |
686
|
|
|
|
|
|
|
} |
687
|
|
|
|
|
|
|
} |
688
|
0
|
|
|
|
|
|
return $self; |
689
|
|
|
|
|
|
|
} |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
sub draw_tics |
694
|
|
|
|
|
|
|
{ |
695
|
0
|
|
|
0
|
|
|
my $self = shift; |
696
|
0
|
|
|
|
|
|
$self->tics_for_axis($self->{'b'}); |
697
|
0
|
|
|
|
|
|
$self->tics_for_axis($self->{'l'}); |
698
|
0
|
|
|
|
|
|
$self->tics_for_axis($self->{'r'}); |
699
|
0
|
|
|
|
|
|
$self->tics_for_axis($self->{'t'}); |
700
|
0
|
|
|
|
|
|
return $self; |
701
|
|
|
|
|
|
|
} |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
sub arrow |
706
|
|
|
|
|
|
|
{ |
707
|
0
|
|
|
0
|
|
|
my $self = shift; |
708
|
0
|
|
|
|
|
|
my $x0 = shift; |
709
|
0
|
|
|
|
|
|
my $y0 = shift; |
710
|
0
|
|
|
|
|
|
my $d = shift; |
711
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
712
|
0
|
|
|
|
|
|
my $x1 = $x0 + 23.811; |
713
|
0
|
|
|
|
|
|
my $y1 = $y0; |
714
|
0
|
|
|
|
|
|
my $x2 = $x0 + 28.346; |
715
|
0
|
|
|
|
|
|
my $y2 = $y0; |
716
|
0
|
|
|
|
|
|
my $x3 = $x0 + 19.843; |
717
|
0
|
|
|
|
|
|
my $y3 = $y0 + 2.1; |
718
|
0
|
|
|
|
|
|
my $x4 = $x3; |
719
|
0
|
|
|
|
|
|
my $y4 = $y0 - 2.1; |
720
|
0
|
0
|
|
|
|
|
if($d == 1) { |
721
|
0
|
|
|
|
|
|
$x1 = $x0; $y1 = $y0 + 23.811; |
|
0
|
|
|
|
|
|
|
722
|
0
|
|
|
|
|
|
$x2 = $x0; $y2 = $y0 + 28.346; |
|
0
|
|
|
|
|
|
|
723
|
0
|
|
|
|
|
|
$x3 = $x0 - 2.1; $y3 = $y0 + 19.843; |
|
0
|
|
|
|
|
|
|
724
|
0
|
|
|
|
|
|
$x4 = $x0 + 2.1; $y4 = $y3; |
|
0
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
} else { |
726
|
0
|
0
|
|
|
|
|
if($d == 2) { |
727
|
0
|
|
|
|
|
|
$x1 = $x0 - 23.811; $y1 = $y0; |
|
0
|
|
|
|
|
|
|
728
|
0
|
|
|
|
|
|
$x2 = $x0 - 28.346; $y2 = $y0; |
|
0
|
|
|
|
|
|
|
729
|
0
|
|
|
|
|
|
$x3 = $x0 - 19.843; $y3 = $y0 + 2.1; |
|
0
|
|
|
|
|
|
|
730
|
0
|
|
|
|
|
|
$x4 = $x3; $y4 = $y0 - 2.1; |
|
0
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
} else { |
732
|
0
|
0
|
|
|
|
|
if($d == 3) { |
733
|
0
|
|
|
|
|
|
$x1 = $x0; $y1 = $y0 - 23.811; |
|
0
|
|
|
|
|
|
|
734
|
0
|
|
|
|
|
|
$x2 = $x0; $y2 = $y0 - 28.346; |
|
0
|
|
|
|
|
|
|
735
|
0
|
|
|
|
|
|
$x3 = $x0 - 2.1; $y3 = $y0 - 19.843; |
|
0
|
|
|
|
|
|
|
736
|
0
|
|
|
|
|
|
$x4 = $x0 + 2.1; $y4 = $y3; |
|
0
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
} |
738
|
|
|
|
|
|
|
} |
739
|
|
|
|
|
|
|
} |
740
|
0
|
|
|
|
|
|
print $fh "\\pgfpathmoveto{"; |
741
|
0
|
|
|
|
|
|
$self->write_point($x0, $y0); |
742
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfpathlineto{"; |
743
|
0
|
|
|
|
|
|
$self->write_point($x1, $y1); |
744
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfusepath{stroke}\n"; |
745
|
0
|
|
|
|
|
|
print $fh "\\pgfpathmoveto{"; |
746
|
0
|
|
|
|
|
|
$self->write_point($x2, $y2); |
747
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfpathlineto{"; |
748
|
0
|
|
|
|
|
|
$self->write_point($x3, $y3); |
749
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfpathlineto{"; |
750
|
0
|
|
|
|
|
|
$self->write_point($x4, $y4); |
751
|
0
|
|
|
|
|
|
print $fh "}\n\\pgfpathclose\n\\pgfusepath{fill}\n"; |
752
|
0
|
|
|
|
|
|
return $self; |
753
|
|
|
|
|
|
|
} |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
sub axis_arrows_and_units |
758
|
|
|
|
|
|
|
{ |
759
|
0
|
|
|
0
|
|
|
my $self = shift; |
760
|
0
|
|
|
|
|
|
my $ax = shift; |
761
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
762
|
0
|
0
|
|
|
|
|
if($ax->{'used'}) { |
763
|
0
|
0
|
|
|
|
|
if(defined($ax->{'l'})) { |
764
|
0
|
|
|
|
|
|
my $xyflag = 0; |
765
|
0
|
|
|
|
|
|
my $co = $self->{'y1bp'}; |
766
|
0
|
|
|
|
|
|
my $m = $self->{'x3bp'} + 0.5 * ($self->{'x4bp'} - $self->{'x3bp'}); |
767
|
0
|
0
|
|
|
|
|
if($ax->{'n'} eq 'l') { |
768
|
0
|
|
|
|
|
|
$xyflag = 1; |
769
|
0
|
|
|
|
|
|
$co = $self->{'x1bp'}; |
770
|
0
|
|
|
|
|
|
$m = $self->{'y3bp'} + 0.5 * ($self->{'y4bp'} - $self->{'y3bp'}); |
771
|
|
|
|
|
|
|
} |
772
|
0
|
0
|
|
|
|
|
if($ax->{'n'} eq 'r') { |
773
|
0
|
|
|
|
|
|
$xyflag = 1; |
774
|
0
|
|
|
|
|
|
$co = $self->{'x6bp'}; |
775
|
0
|
|
|
|
|
|
$m = $self->{'y3bp'} + 0.5 * ($self->{'y4bp'} - $self->{'y3bp'}); |
776
|
|
|
|
|
|
|
} |
777
|
0
|
0
|
|
|
|
|
if($ax->{'n'} eq 't') { |
778
|
0
|
|
|
|
|
|
$co = $self->{'y6bp'}; |
779
|
|
|
|
|
|
|
} |
780
|
0
|
0
|
|
|
|
|
if(defined($ax->{'color'})) { |
781
|
0
|
|
|
|
|
|
$self->set_color($ax->{'color'}); |
782
|
|
|
|
|
|
|
} |
783
|
0
|
0
|
|
|
|
|
if($xyflag) { |
784
|
0
|
0
|
|
|
|
|
if($ax->{'max'} > $ax->{'min'}) { |
785
|
0
|
|
|
|
|
|
$self->text_label($co, ($m - 2.8346), "top", $ax->{'l'}); |
786
|
0
|
|
|
|
|
|
$self->arrow($co, ($m + 2.8346), 1); |
787
|
|
|
|
|
|
|
} else { |
788
|
0
|
|
|
|
|
|
$self->text_label($co, ($m + 2.8346), "bottom", $ax->{'l'}); |
789
|
0
|
|
|
|
|
|
$self->arrow($co, ($m - 2.8346), 3); |
790
|
|
|
|
|
|
|
} |
791
|
|
|
|
|
|
|
} else { |
792
|
0
|
0
|
|
|
|
|
if($ax->{'max'} > $ax->{'min'}) { |
793
|
0
|
|
|
|
|
|
$self->text_label(($m - 2.8346), $co, "right", $ax->{'l'}); |
794
|
0
|
|
|
|
|
|
$self->arrow(($m + 2.8346), $co, 0); |
795
|
|
|
|
|
|
|
} else { |
796
|
0
|
|
|
|
|
|
$self->text_label(($m + 2.8346), $co, "left", $ax->{'l'}); |
797
|
0
|
|
|
|
|
|
$self->arrow(($m - 2.8346), $co, 2); |
798
|
|
|
|
|
|
|
} |
799
|
|
|
|
|
|
|
} |
800
|
|
|
|
|
|
|
} |
801
|
|
|
|
|
|
|
} |
802
|
0
|
|
|
|
|
|
return $self; |
803
|
|
|
|
|
|
|
} |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
sub arrows_and_units |
808
|
|
|
|
|
|
|
{ |
809
|
0
|
|
|
0
|
|
|
my $self = shift; |
810
|
0
|
|
|
|
|
|
$self->axis_arrows_and_units($self->{'b'}); |
811
|
0
|
|
|
|
|
|
$self->axis_arrows_and_units($self->{'l'}); |
812
|
0
|
|
|
|
|
|
$self->axis_arrows_and_units($self->{'r'}); |
813
|
0
|
|
|
|
|
|
$self->axis_arrows_and_units($self->{'t'}); |
814
|
0
|
|
|
|
|
|
return $self; |
815
|
|
|
|
|
|
|
} |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
sub draw_polylines_and_labels |
820
|
|
|
|
|
|
|
{ |
821
|
0
|
|
|
0
|
|
|
my $self = shift; |
822
|
0
|
|
|
|
|
|
my $ar = $self->{'contents'}; |
823
|
0
|
|
|
|
|
|
my $ai = $self->{'nco'}; |
824
|
0
|
|
|
|
|
|
my $or; |
825
|
0
|
|
|
|
|
|
for(my $i = 0; $i < $ai; $i++) { |
826
|
0
|
|
|
|
|
|
$or = $ar->[$i]; |
827
|
0
|
|
|
|
|
|
$or->plot(); |
828
|
|
|
|
|
|
|
} |
829
|
0
|
|
|
|
|
|
return $self; |
830
|
|
|
|
|
|
|
} |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
sub draw_plots |
835
|
|
|
|
|
|
|
{ |
836
|
0
|
|
|
0
|
|
|
my $self = shift; |
837
|
0
|
|
|
|
|
|
my $ap = $self->{'p'}; |
838
|
0
|
|
|
|
|
|
my $np = $self->{'np'}; |
839
|
0
|
|
|
|
|
|
my $pref; |
840
|
0
|
|
|
|
|
|
for(my $i = 0; $i < $np; $i++) { |
841
|
0
|
|
|
|
|
|
$pref = $ap->[$i]; |
842
|
0
|
|
|
|
|
|
$pref->plot_to($self); |
843
|
|
|
|
|
|
|
} |
844
|
0
|
|
|
|
|
|
return $self; |
845
|
|
|
|
|
|
|
} |
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
sub write_image_contents |
849
|
|
|
|
|
|
|
{ |
850
|
0
|
|
|
0
|
|
|
my $self = shift; |
851
|
0
|
|
|
|
|
|
my $fh = $self->{'f1'}; |
852
|
|
|
|
|
|
|
# Bounding box |
853
|
0
|
|
|
|
|
|
$self->write_clip( |
854
|
|
|
|
|
|
|
floor($self->{'x0bp'}), floor($self->{'y0bp'}), |
855
|
|
|
|
|
|
|
ceil($self->{'x7bp'}), ceil($self->{'y7bp'}) |
856
|
|
|
|
|
|
|
); |
857
|
|
|
|
|
|
|
# Grid |
858
|
0
|
|
|
|
|
|
print $fh "\% Grid\n"; |
859
|
0
|
|
|
|
|
|
$self->setlinewidth_mm(0.05); |
860
|
0
|
|
|
|
|
|
$self->set_color('black'); |
861
|
0
|
|
|
|
|
|
$self->draw_grid(); |
862
|
|
|
|
|
|
|
# Tics |
863
|
0
|
|
|
|
|
|
print $fh "\% Scale values\n"; |
864
|
0
|
|
|
|
|
|
$self->draw_tics(); |
865
|
0
|
|
|
|
|
|
$self->begin_pgfscope(); |
866
|
0
|
|
|
|
|
|
$self->write_clip( |
867
|
|
|
|
|
|
|
$self->{'x3bp'}, $self->{'y3bp'}, |
868
|
|
|
|
|
|
|
$self->{'x4bp'}, $self->{'y4bp'} |
869
|
|
|
|
|
|
|
); |
870
|
|
|
|
|
|
|
# Curves |
871
|
0
|
|
|
|
|
|
print $fh "\% Curves\n"; |
872
|
0
|
|
|
|
|
|
$self->setlinewidth_mm(0.2); |
873
|
0
|
|
|
|
|
|
$self->draw_plots(); |
874
|
0
|
|
|
|
|
|
$self->end_pgfscope(); |
875
|
|
|
|
|
|
|
# Polylines and arrow |
876
|
0
|
|
|
|
|
|
print $fh "\% Text labels and polylines\n"; |
877
|
0
|
|
|
|
|
|
$self->draw_polylines_and_labels(); |
878
|
|
|
|
|
|
|
# Frame |
879
|
0
|
|
|
|
|
|
print $fh "\% Frame\n"; |
880
|
0
|
|
|
|
|
|
$self->set_color('black'); |
881
|
0
|
|
|
|
|
|
$self->setlinewidth_mm(0.1); |
882
|
0
|
|
|
|
|
|
$self->write_rect( |
883
|
|
|
|
|
|
|
$self->{'x3bp'}, $self->{'y3bp'}, |
884
|
|
|
|
|
|
|
$self->{'x4bp'}, $self->{'y4bp'} |
885
|
|
|
|
|
|
|
); |
886
|
0
|
|
|
|
|
|
print $fh "\\pgfusepath{stroke}\n"; |
887
|
|
|
|
|
|
|
# Arrows and Labels |
888
|
0
|
|
|
|
|
|
print $fh "\% Axis labels and arrows\n"; |
889
|
0
|
|
|
|
|
|
$self->setlinewidth_mm(0.2); |
890
|
0
|
|
|
|
|
|
$self->arrows_and_units(); |
891
|
|
|
|
|
|
|
} |
892
|
|
|
|
|
|
|
|
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
sub write |
895
|
|
|
|
|
|
|
{ |
896
|
0
|
|
|
0
|
|
|
my $self = undef; |
897
|
0
|
|
|
|
|
|
my $fh = undef; |
898
|
0
|
0
|
|
|
|
|
if($#_ < 1) { |
899
|
|
|
|
|
|
|
} else { |
900
|
0
|
|
|
|
|
|
$self = shift; $self->{'fn1'} = shift; |
|
0
|
|
|
|
|
|
|
901
|
0
|
|
|
|
|
|
$self->{'ftf'} = 0; |
902
|
0
|
0
|
|
|
|
|
if($self->{'fn1'} =~ /.*\.[Tt][Ee][Xx]/o) { |
903
|
0
|
|
|
|
|
|
$self->{'ftf'} = 1; |
904
|
|
|
|
|
|
|
} |
905
|
0
|
0
|
|
|
|
|
if(open($fh, '>', $self->{'fn1'})) { |
906
|
0
|
|
|
|
|
|
$self->{'f1'} = $fh; |
907
|
0
|
|
|
|
|
|
$self->prepare_for_output(); |
908
|
0
|
0
|
|
|
|
|
if($self->{'ftf'}) { |
909
|
0
|
|
|
|
|
|
my $utfflag = 0; |
910
|
0
|
0
|
|
|
|
|
if(exists($ENV{"LANG"})) { |
911
|
0
|
0
|
|
|
|
|
if($ENV{"LANG"} =~ /\.[Uu][Tt][Ff]\-8/o) { |
912
|
0
|
|
|
|
|
|
$utfflag = 1; |
913
|
|
|
|
|
|
|
} |
914
|
|
|
|
|
|
|
} |
915
|
0
|
|
|
|
|
|
print $fh "\\documentclass[" . $self->{'fs'} . "pt]{article}\n"; |
916
|
0
|
0
|
|
|
|
|
if($utfflag) { |
917
|
0
|
|
|
|
|
|
print $fh "\\usepackage[utf8]{inputenc}\n"; |
918
|
|
|
|
|
|
|
} else { |
919
|
0
|
|
|
|
|
|
print $fh "\\usepackage[latin1]{inputenc}\n"; |
920
|
|
|
|
|
|
|
} |
921
|
0
|
|
|
|
|
|
print $fh "\\usepackage[T1]{fontenc}\n"; |
922
|
0
|
|
|
|
|
|
print $fh "\\usepackage{textcomp}\n"; |
923
|
0
|
|
|
|
|
|
print $fh "\\usepackage{mathptmx}\n"; |
924
|
0
|
|
|
|
|
|
print $fh "\\usepackage[scaled=.92]{helvet}\n"; |
925
|
0
|
|
|
|
|
|
print $fh "\\usepackage{courier}\n"; |
926
|
0
|
|
|
|
|
|
print $fh "\\usepackage[intlimits]{amsmath}\n"; |
927
|
0
|
|
|
|
|
|
print $fh "\\usepackage{graphicx}\n"; |
928
|
0
|
|
|
|
|
|
print $fh "\\usepackage{color}\n"; |
929
|
0
|
|
|
|
|
|
print $fh "\\usepackage{ifpdf}\n"; |
930
|
0
|
|
|
|
|
|
print $fh "\\usepackage{fancybox}\n"; |
931
|
0
|
|
|
|
|
|
print $fh "\\usepackage{pgfcore}\n"; |
932
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\paperwidth}{" |
933
|
|
|
|
|
|
|
. ceil($self->{'x7bp'}) . "bp}\n"; |
934
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\paperheight}{" |
935
|
|
|
|
|
|
|
. ceil($self->{'y7bp'}) . "bp}\n"; |
936
|
0
|
|
|
|
|
|
print $fh "\\pagestyle{empty}\n"; |
937
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\voffset}{-1in}\n"; |
938
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\topmargin}{0mm}\n"; |
939
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\headheight}{0mm}\n"; |
940
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\headsep}{0mm}\n"; |
941
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\topskip}{0mm}\n"; |
942
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\hoffset}{-1in}\n"; |
943
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\oddsidemargin}{0mm}\n"; |
944
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\evensidemargin}{0mm}\n"; |
945
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\marginparwidth}{0mm}\n"; |
946
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\marginparsep}{0mm}\n"; |
947
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\textwidth}{\\paperwidth}\n"; |
948
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\textheight}{\\paperheight}\n"; |
949
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\parskip}{0mm}\n"; |
950
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\parindent}{0mm}\n"; |
951
|
0
|
|
|
|
|
|
print $fh "\\ifpdf\n"; |
952
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\pdfpagewidth}{\\paperwidth}\n"; |
953
|
0
|
|
|
|
|
|
print $fh "\\setlength{\\pdfpageheight}{\\paperheight}\n"; |
954
|
0
|
|
|
|
|
|
print $fh "\\fi\n"; |
955
|
0
|
|
|
|
|
|
print $fh "\\begin{document}%\n"; |
956
|
|
|
|
|
|
|
} |
957
|
|
|
|
|
|
|
|
958
|
0
|
|
|
|
|
|
print $fh "\\begin{pgfpicture}\n"; |
959
|
0
|
|
|
|
|
|
$self->write_image_contents(); |
960
|
0
|
|
|
|
|
|
print $fh "\\end{pgfpicture}\%\n"; |
961
|
|
|
|
|
|
|
|
962
|
0
|
0
|
|
|
|
|
if($self->{'ftf'}) { |
963
|
0
|
|
|
|
|
|
print $fh "\\end{document}\n"; |
964
|
|
|
|
|
|
|
} |
965
|
|
|
|
|
|
|
|
966
|
0
|
|
|
|
|
|
close($fh); |
967
|
|
|
|
|
|
|
} |
968
|
0
|
|
|
|
|
|
$self->{'ftf'} = 0; |
969
|
|
|
|
|
|
|
} |
970
|
0
|
|
|
|
|
|
return $self; |
971
|
|
|
|
|
|
|
} |
972
|
|
|
|
|
|
|
|
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
|
975
|
|
|
|
|
|
|
sub set_font_size |
976
|
|
|
|
|
|
|
{ |
977
|
0
|
|
|
0
|
|
|
my $self = undef; |
978
|
0
|
0
|
|
|
|
|
if($#_ < 1) { |
979
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->set_font_size(fontsize)"; |
980
|
|
|
|
|
|
|
} else { |
981
|
0
|
|
|
|
|
|
$self = shift; $self->{'fs'} = shift; |
|
0
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
} |
983
|
0
|
|
|
|
|
|
return $self; |
984
|
|
|
|
|
|
|
} |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
|
987
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
sub axis |
989
|
|
|
|
|
|
|
{ |
990
|
0
|
|
|
0
|
|
|
my $back = undef; |
991
|
0
|
0
|
|
|
|
|
if($#_ < 1) { |
992
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->axis(name)"; |
993
|
|
|
|
|
|
|
} else { |
994
|
0
|
|
|
|
|
|
my $self = shift; |
995
|
0
|
|
|
|
|
|
my $name = shift; |
996
|
0
|
0
|
0
|
|
|
|
if(("$name" eq "b") || ("$name" eq "bottom")) { $back = $self->{'b'}; } |
|
0
|
|
|
|
|
|
|
997
|
0
|
0
|
0
|
|
|
|
if(("$name" eq "l") || ("$name" eq "left")) { $back = $self->{'l'}; } |
|
0
|
|
|
|
|
|
|
998
|
0
|
0
|
0
|
|
|
|
if(("$name" eq "r") || ("$name" eq "right")) { $back = $self->{'r'}; } |
|
0
|
|
|
|
|
|
|
999
|
0
|
0
|
0
|
|
|
|
if(("$name" eq "t") || ("$name" eq "top")) { $back = $self->{'t'}; } |
|
0
|
|
|
|
|
|
|
1000
|
0
|
0
|
|
|
|
|
if(!defined($back)) { |
1001
|
0
|
|
|
|
|
|
croak "ERROR: Wrong axis name \"$name\"! Allowed names:\n" |
1002
|
|
|
|
|
|
|
. " 'b' (bottom), 'l', (left), 'r' (right) or 't' (top)."; |
1003
|
|
|
|
|
|
|
} |
1004
|
|
|
|
|
|
|
} |
1005
|
0
|
|
|
|
|
|
return $back; |
1006
|
|
|
|
|
|
|
} |
1007
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
sub plot |
1011
|
|
|
|
|
|
|
{ |
1012
|
0
|
|
|
0
|
|
|
my $back = undef; |
1013
|
0
|
0
|
|
|
|
|
if($#_ < 2) { |
1014
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->plot(axisname,axisname)"; |
1015
|
|
|
|
|
|
|
} else { |
1016
|
0
|
|
|
|
|
|
my $self = shift; |
1017
|
0
|
|
|
|
|
|
my $an1 = shift; |
1018
|
0
|
|
|
|
|
|
my $an2 = shift; |
1019
|
0
|
|
|
|
|
|
my $ax = undef; my $ay = undef; |
|
0
|
|
|
|
|
|
|
1020
|
0
|
|
|
|
|
|
foreach my $i ($an1, $an2) { |
1021
|
0
|
|
|
|
|
|
my $nok = 0; |
1022
|
0
|
0
|
0
|
|
|
|
if(("$i" eq "b") || ("$i" eq "bottom")) { $ax = $self->{'b'}; $nok = 1; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1023
|
0
|
0
|
0
|
|
|
|
if(("$i" eq "l") || ("$i" eq "left")) { $ay = $self->{'l'}; $nok = 1; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1024
|
0
|
0
|
0
|
|
|
|
if(("$i" eq "r") || ("$i" eq "right")) { $ay = $self->{'r'}; $nok = 1; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1025
|
0
|
0
|
0
|
|
|
|
if(("$i" eq "t") || ("$i" eq "top")) { $ax = $self->{'t'}; $nok = 1; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1026
|
0
|
0
|
|
|
|
|
if(!$nok) { |
1027
|
0
|
|
|
|
|
|
croak "ERROR: Wrong axis name \"$i\"! Allowed names:\n" |
1028
|
|
|
|
|
|
|
. " 'b' (bottom), 'l', (left), 'r' (right) or 't' (top)."; |
1029
|
|
|
|
|
|
|
} |
1030
|
|
|
|
|
|
|
} |
1031
|
0
|
0
|
0
|
|
|
|
if(defined($ax) && defined($ay)) { |
1032
|
0
|
|
|
|
|
|
my $ar = $self->{'p'}; |
1033
|
0
|
|
|
|
|
|
my $an = $self->{'np'}; |
1034
|
0
|
|
|
|
|
|
$back = LaTeX::PGF::Diagram2D::Plot->new(); |
1035
|
0
|
|
|
|
|
|
$ar->[$an++] = $back; |
1036
|
0
|
|
|
|
|
|
$self->{'np'} = $an; |
1037
|
0
|
|
|
|
|
|
$back->{'ax'} = $ax; $back->{'ay'} = $ay; |
|
0
|
|
|
|
|
|
|
1038
|
0
|
|
|
|
|
|
$ax->{'used'} = 1; $ay->{'used'} = 1; |
|
0
|
|
|
|
|
|
|
1039
|
0
|
|
|
|
|
|
$back->{'debug'} = $self->{'debug'}; |
1040
|
|
|
|
|
|
|
} else { |
1041
|
0
|
|
|
|
|
|
croak "ERROR: One x-axis and one y-axis needed!"; |
1042
|
|
|
|
|
|
|
} |
1043
|
|
|
|
|
|
|
} |
1044
|
0
|
|
|
|
|
|
return $back; |
1045
|
|
|
|
|
|
|
} |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
sub copy_plot |
1050
|
|
|
|
|
|
|
{ |
1051
|
0
|
|
|
0
|
|
|
my $back = undef; |
1052
|
0
|
0
|
|
|
|
|
if($#_ < 1) { |
1053
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->copy_plot(plot)"; |
1054
|
|
|
|
|
|
|
} else { |
1055
|
0
|
|
|
|
|
|
my $self = shift; my $src = shift; |
|
0
|
|
|
|
|
|
|
1056
|
0
|
|
|
|
|
|
my $ar = $self->{'p'}; |
1057
|
0
|
|
|
|
|
|
my $an = $self->{'np'}; |
1058
|
0
|
|
|
|
|
|
$back = LaTeX::PGF::Diagram2D::Plot->new(); |
1059
|
0
|
|
|
|
|
|
foreach my $k(keys %$src) { |
1060
|
0
|
|
|
|
|
|
$back->{"$k"} = $src->{"$k"}; |
1061
|
|
|
|
|
|
|
} |
1062
|
0
|
|
|
|
|
|
$ar->[$an++] = $back; |
1063
|
0
|
|
|
|
|
|
$self->{'np'} = $an; |
1064
|
|
|
|
|
|
|
} |
1065
|
0
|
|
|
|
|
|
return $back; |
1066
|
|
|
|
|
|
|
} |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
|
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
sub label |
1071
|
|
|
|
|
|
|
{ |
1072
|
0
|
|
|
0
|
|
|
my $back = undef; |
1073
|
0
|
0
|
|
|
|
|
if($#_ < 3) { |
1074
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->label(xaxis, yaxis, x, y, text[, position])"; |
1075
|
|
|
|
|
|
|
} else { |
1076
|
0
|
|
|
|
|
|
my $self = shift; |
1077
|
0
|
|
|
|
|
|
my $xan = shift; |
1078
|
0
|
|
|
|
|
|
my $yan = shift; |
1079
|
0
|
|
|
|
|
|
my $x = shift; |
1080
|
0
|
|
|
|
|
|
my $y = shift; |
1081
|
0
|
|
|
|
|
|
my $t = shift; |
1082
|
0
|
|
|
|
|
|
my $p = undef; |
1083
|
0
|
0
|
|
|
|
|
if($#_ >= 0) { |
1084
|
0
|
|
|
|
|
|
$p = shift; |
1085
|
|
|
|
|
|
|
} |
1086
|
0
|
|
|
|
|
|
my $ax = undef; my $ay = undef; |
|
0
|
|
|
|
|
|
|
1087
|
0
|
0
|
0
|
|
|
|
if(("$xan" eq "b") || ("$xan" eq "bottom")) { $ax = $self->{'b'}; } |
|
0
|
|
|
|
|
|
|
1088
|
0
|
0
|
0
|
|
|
|
if(("$xan" eq "l") || ("$xan" eq "left")) { $ay = $self->{'l'}; } |
|
0
|
|
|
|
|
|
|
1089
|
0
|
0
|
0
|
|
|
|
if(("$xan" eq "r") || ("$xan" eq "right")) { $ay = $self->{'r'}; } |
|
0
|
|
|
|
|
|
|
1090
|
0
|
0
|
0
|
|
|
|
if(("$xan" eq "t") || ("$xan" eq "top")) { $ax = $self->{'t'}; } |
|
0
|
|
|
|
|
|
|
1091
|
0
|
0
|
0
|
|
|
|
if(("$yan" eq "b") || ("$yan" eq "bottom")) { $ax = $self->{'b'}; } |
|
0
|
|
|
|
|
|
|
1092
|
0
|
0
|
0
|
|
|
|
if(("$yan" eq "l") || ("$yan" eq "left")) { $ay = $self->{'l'}; } |
|
0
|
|
|
|
|
|
|
1093
|
0
|
0
|
0
|
|
|
|
if(("$yan" eq "r") || ("$yan" eq "right")) { $ay = $self->{'r'}; } |
|
0
|
|
|
|
|
|
|
1094
|
0
|
0
|
0
|
|
|
|
if(("$yan" eq "t") || ("$yan" eq "top")) { $ax = $self->{'t'}; } |
|
0
|
|
|
|
|
|
|
1095
|
0
|
0
|
0
|
|
|
|
if((defined($ax) && defined($ay))) { |
1096
|
0
|
0
|
|
|
|
|
if(defined($p)) { |
1097
|
0
|
|
|
|
|
|
$back = LaTeX::PGF::Diagram2D::Label->new($self, $ax, $ay, $x, $y, $t, $p); |
1098
|
|
|
|
|
|
|
} else { |
1099
|
0
|
|
|
|
|
|
$back = LaTeX::PGF::Diagram2D::Label->new($self, $ax, $ay, $x, $y, $t); |
1100
|
|
|
|
|
|
|
} |
1101
|
0
|
|
|
|
|
|
my $ar = $self->{'contents'}; |
1102
|
0
|
|
|
|
|
|
my $ai = $self->{'nco'}; |
1103
|
0
|
|
|
|
|
|
$ar->[$ai++] = $back; |
1104
|
0
|
|
|
|
|
|
$self->{'nco'} = $ai; |
1105
|
|
|
|
|
|
|
} else { |
1106
|
0
|
|
|
|
|
|
croak "ERROR: One x- and one y-axis is needed!"; |
1107
|
|
|
|
|
|
|
} |
1108
|
|
|
|
|
|
|
} |
1109
|
0
|
|
|
|
|
|
return $back; |
1110
|
|
|
|
|
|
|
} |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
sub polyline |
1115
|
|
|
|
|
|
|
{ |
1116
|
0
|
|
|
0
|
|
|
my $back = undef; |
1117
|
0
|
0
|
|
|
|
|
if($#_ < 3) { |
1118
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->polyline(xaxis,yaxis,pointsarrayref)"; |
1119
|
|
|
|
|
|
|
} else { |
1120
|
0
|
|
|
|
|
|
my $self = shift; |
1121
|
0
|
|
|
|
|
|
my $xan = shift; |
1122
|
0
|
|
|
|
|
|
my $yan = shift; |
1123
|
0
|
|
|
|
|
|
my $pref = shift; |
1124
|
0
|
|
|
|
|
|
my $ax = undef; my $ay = undef; |
|
0
|
|
|
|
|
|
|
1125
|
0
|
0
|
0
|
|
|
|
if(("$xan" eq "b") || ("$xan" eq "bottom")) { $ax = $self->{'b'}; } |
|
0
|
|
|
|
|
|
|
1126
|
0
|
0
|
0
|
|
|
|
if(("$xan" eq "l") || ("$xan" eq "left")) { $ay = $self->{'l'}; } |
|
0
|
|
|
|
|
|
|
1127
|
0
|
0
|
0
|
|
|
|
if(("$xan" eq "r") || ("$xan" eq "right")) { $ay = $self->{'r'}; } |
|
0
|
|
|
|
|
|
|
1128
|
0
|
0
|
0
|
|
|
|
if(("$xan" eq "t") || ("$xan" eq "top")) { $ax = $self->{'t'}; } |
|
0
|
|
|
|
|
|
|
1129
|
0
|
0
|
0
|
|
|
|
if(("$yan" eq "b") || ("$yan" eq "bottom")) { $ax = $self->{'b'}; } |
|
0
|
|
|
|
|
|
|
1130
|
0
|
0
|
0
|
|
|
|
if(("$yan" eq "l") || ("$yan" eq "left")) { $ay = $self->{'l'}; } |
|
0
|
|
|
|
|
|
|
1131
|
0
|
0
|
0
|
|
|
|
if(("$yan" eq "r") || ("$yan" eq "right")) { $ay = $self->{'r'}; } |
|
0
|
|
|
|
|
|
|
1132
|
0
|
0
|
0
|
|
|
|
if(("$yan" eq "t") || ("$yan" eq "top")) { $ax = $self->{'t'}; } |
|
0
|
|
|
|
|
|
|
1133
|
0
|
0
|
0
|
|
|
|
if(defined($ax) && defined($ay)) { |
1134
|
0
|
0
|
|
|
|
|
if($#$pref >= 3) { |
1135
|
0
|
|
|
|
|
|
$back = LaTeX::PGF::Diagram2D::Polyline->new($self, $ax, $ay, $pref); |
1136
|
0
|
|
|
|
|
|
my $ar = $self->{'contents'}; |
1137
|
0
|
|
|
|
|
|
my $ai = $self->{'nco'}; |
1138
|
0
|
|
|
|
|
|
$ar->[$ai++] = $back; |
1139
|
0
|
|
|
|
|
|
$self->{'nco'} = $ai; |
1140
|
|
|
|
|
|
|
} else { |
1141
|
0
|
|
|
|
|
|
croak "ERROR: At least 2 points are needed!"; |
1142
|
|
|
|
|
|
|
} |
1143
|
|
|
|
|
|
|
} else { |
1144
|
0
|
|
|
|
|
|
croak "ERROR: One x- and one y-axis is needed!"; |
1145
|
|
|
|
|
|
|
} |
1146
|
|
|
|
|
|
|
} |
1147
|
0
|
|
|
|
|
|
return $back; |
1148
|
|
|
|
|
|
|
} |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
sub value_to_coord |
1153
|
|
|
|
|
|
|
{ |
1154
|
0
|
|
|
0
|
|
|
my $back = 0.0; |
1155
|
0
|
|
|
|
|
|
my $self = shift; |
1156
|
0
|
|
|
|
|
|
my $ax = shift; |
1157
|
0
|
|
|
|
|
|
my $ay = shift; |
1158
|
0
|
|
|
|
|
|
my $v = shift; |
1159
|
0
|
|
|
|
|
|
my $i = shift; |
1160
|
0
|
0
|
|
|
|
|
if($i % 2) { |
1161
|
0
|
0
|
0
|
|
|
|
if(("$v" eq "t") || ("$v" eq "top")) { |
1162
|
0
|
|
|
|
|
|
$back = $self->{'y5bp'}; |
1163
|
|
|
|
|
|
|
} else { |
1164
|
0
|
0
|
0
|
|
|
|
if(("$v" eq "b") || ("$v" eq "bottom")) { |
1165
|
0
|
|
|
|
|
|
$back = $self->{'y2bp'}; |
1166
|
|
|
|
|
|
|
} else { |
1167
|
0
|
|
|
|
|
|
$back = $ay->value_to_coord($v); |
1168
|
|
|
|
|
|
|
} |
1169
|
|
|
|
|
|
|
} |
1170
|
|
|
|
|
|
|
} else { |
1171
|
0
|
0
|
0
|
|
|
|
if(("$v" eq "l") || ("$v" eq "left")) { |
1172
|
0
|
|
|
|
|
|
$back = $self->{'x2bp'}; |
1173
|
|
|
|
|
|
|
} else { |
1174
|
0
|
0
|
0
|
|
|
|
if(("$v" eq "r") || ("$v" eq "right")) { |
1175
|
0
|
|
|
|
|
|
$back = $self->{'x5bp'}; |
1176
|
|
|
|
|
|
|
} else { |
1177
|
0
|
|
|
|
|
|
$back = $ax->value_to_coord($v); |
1178
|
|
|
|
|
|
|
} |
1179
|
|
|
|
|
|
|
} |
1180
|
|
|
|
|
|
|
} |
1181
|
0
|
|
|
|
|
|
return $back; |
1182
|
|
|
|
|
|
|
} |
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
sub set_debug |
1187
|
|
|
|
|
|
|
{ |
1188
|
0
|
|
|
0
|
|
|
my $self = undef; |
1189
|
0
|
0
|
|
|
|
|
if($#_ < 1) { |
1190
|
0
|
|
|
|
|
|
croak "Usage: \$diagram->set_debug(flag)"; |
1191
|
|
|
|
|
|
|
} else { |
1192
|
0
|
|
|
|
|
|
$self = shift; $self->{'debug'} = shift; |
|
0
|
|
|
|
|
|
|
1193
|
0
|
|
|
|
|
|
my $ar = $self->{'p'}; |
1194
|
0
|
|
|
|
|
|
my $ai = $self->{'np'}; |
1195
|
0
|
|
|
|
|
|
my $pref; |
1196
|
0
|
|
|
|
|
|
for(my $i = 0; $i < $ai; $i++) { |
1197
|
0
|
|
|
|
|
|
$pref = $ar->[$i]; |
1198
|
0
|
|
|
|
|
|
$pref->{'debug'} = $self->{'debug'}; |
1199
|
|
|
|
|
|
|
} |
1200
|
|
|
|
|
|
|
} |
1201
|
0
|
|
|
|
|
|
return $self; |
1202
|
|
|
|
|
|
|
} |
1203
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
1; |
1206
|
|
|
|
|
|
|
__END__ |