-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpp3.w
4079 lines (3551 loc) · 171 KB
/
pp3.w
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
336
337
338
339
340
341
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% $Id$
@q======================================================================@>
@q pp3.w - Star Catalog Chart Creator @>
@q Copyright 2002--2004 Torsten Bronger @>
@q <bronger@@users.sourceforge.net> @>
@q @>
@q This program may be distributed and/or modified under the @>
@q conditions of the MIT licence with the following contraint: @>
@q If you copy or distribute a modified version of this Software, the @>
@q entire resulting derived work must be given a different name and @>
@q distributed under the terms of a permission notice identical to @>
@q this one. @>
@q @>
@q For the full licence see below under "*LICENCE*" or the printed @>
@q version of this program. @>
@q @>
@q To get a compilable C++ source code, use @>
@q ctangle pp3.w - pp3.cc @>
@q To get a structured documentation of the program, use @>
@q cweave pp3.w @>
@q tex pp3 @>
@q @>
@q cweave and ctangle belong to the cweb system by Levy/Knuth. @>
@q Further information can be obtained at @>
@q http://www-cs-faculty.stanford.edu/~knuth/cweb.html @>
@q======================================================================@>
\catcode`@@=11
% First the default font setup
\font\ninett=cmtt9
\font\nineit=cmti9
\font\stitlefont=cmss10 scaled\magstep3 % sans serif type in title
\font\sbtitlefont=cmssbx10 scaled\magstep3 % sans bold type in title
\font\sf=cmss10 \font\sfbf=cmssbx10
\font\sfa=cmss7
%% From here with Palatino
\font\tenrm=pplr7t % roman text
\font\ninerm=pplr7t scaled 900
\font\eightrm=pplr7t scaled 800
\font\sevenrm=pplr7t scaled 700
\font\fiverm=pplr7t scaled 500
\font\teni=zplmr7m % math italic (zptmcm7m for Times, zplmr7m for Palatino)
\font\seveni=zplmr7m scaled 700
\font\fivei=zplmr7m scaled 500
\font\tensy=zplmr7y % math symbols (zptmcm7y for Times, zplmr7y for Palatino)
\font\sevensy=zplmr7y scaled 700
\font\fivesy=zplmr7y scaled 500
\font\tenex=zplmr7v % math extension (zptmcm7v for Times, zplmr7v f. Palatino)
\font\tenbf=pplb7t % boldface extended
\font\sevenbf=pplb7t scaled 700
\font\fivebf=pplb7t scaled 500
\font\tentt=cmtt10 % typewriter
\font\ninett=cmtt9 % typewriter
\font\tensl=pplro7t % slanted roman
\font\tenit=pplri7t % text italic
\skewchar\teni='177 \skewchar\seveni='177 \skewchar\fivei='177
\skewchar\tensy='60 \skewchar\sevensy='60 \skewchar\fivesy='60
\textfont0=\tenrm \scriptfont0=\sevenrm \scriptscriptfont0=\fiverm
\def\rm{\fam\z@@\tenrm}
\textfont1=\teni \scriptfont1=\seveni \scriptscriptfont1=\fivei
\def\mit{\fam\@@ne} \def\oldstyle{\fam\@@ne\teni}
\textfont2=\tensy \scriptfont2=\sevensy \scriptscriptfont2=\fivesy
\def\cal{\fam\tw@@}
\textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
\newfam\itfam \def\it{\fam\itfam\tenit} % \it is family 4
\textfont\itfam=\tenit
\newfam\slfam \def\sl{\fam\slfam\tensl} % \sl is family 5
\textfont\slfam=\tensl
\newfam\bffam \def\bf{\fam\bffam\tenbf} % \bf is family 6
\textfont\bffam=\tenbf \scriptfont\bffam=\sevenbf
\scriptscriptfont\bffam=\fivebf
\newfam\ttfam \def\tt{\fam\ttfam\tentt} % \tt is family 7
\textfont\ttfam=\tentt
\catcode`@@=12
\font\eightpplr=pplr7t scaled 800
\font\ninepplr=pplr7t scaled 900
\font\ninepplri=pplri7t scaled 900
\font\tenpplr=pplr7t
\font\tenpplb=pplb7t
\font\tenpplri=pplri7t
\font\titlefont=pplr7t scaled 1728 % title on the contents page
\font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
\font\tentex=cmtex10 % TeX extended character set (used in strings)
\fontdimen7\tentex=0pt % no double space after sentences
\let\mainfont=\tenpplr
\let\sc=\ninepplr
\let\mc=\ninepplr
\let\it=\tenpplri
\let\nineit=\ninepplri
\let\tt=\tentt
\let\cmntfont\tenpplr
\mainfont\baselineskip12.7pt
%% Now for the title page
\font\sf=bfrr8t \font\sfbf=bfrb8t
\font\sfa=bfrr8t scaled 700
\font\stitlefont=phvr7t scaled\magstep3 % sans serif type in title
\font\sbtitlefont=phvb7t scaled\magstep3 % sans bold type in title
\font\ttitlefont=pcrb7t scaled\magstep3 % typewriter type in title
\font\stitlefont=bfrr8t scaled\magstep3 % sans serif type in title
\font\sbtitlefont=bfrb8t scaled\magstep3 % sans serif type in title
%\font\sbtitlefont=0t3x8r scaled\magstep3 % sans bold type in title
%\font\sf=0t3r8r \font\sfbf=0t3b8r
%\font\sfa=0t3r8r scaled 700
\hyphenation{white-space}
\secpagedepth=1
\def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX}
\def\LaTeX{L\kern-.36em%
{\setbox0=\hbox{T}%
\vbox to\ht0{\hbox{\sevenrm A}\vss}%
}%
\kern-.15em%
\TeX}
\def\LaTeXbf{L\kern-.36em%
{\setbox0=\hbox{T}%
\vbox to\ht0{\hbox{\sevenbf A}\vss}%
}%
\kern-.15em%
\TeX}
\def\AMSinner{\cal A\mkern-2mu\raise-0.5ex\hbox{$\cal M$}\mkern-2muS}
\def\AMS{\ifmmode\AMSinner\else$\AMSinner$\fi}
\def\BSC/{{\mc BSC\spacefactor1000}}
\def\HSB/{{\mc HSB\spacefactor1000}}
\def\EPS/{{\mc EPS\spacefactor1000}}
\def\PS/{{\mc PS\spacefactor1000}}
\def\PDF/{{\mc PDF\spacefactor1000}}
\def\RGB/{{\mc RGB\spacefactor1000}}
\def\NGC/{{\mc NGC\spacefactor1000}}
\def\IC/{{\mc IC\spacefactor1000}}
\def\HD/{{\mc HD\spacefactor1000}}
\def\9#1{}
\def\sloppy{\tolerance9999\emergencystretch3em\hfuzz .5pt\vfuzz\hfuzz}
\def\title{PP3 (Version 1.3)}
\def\topofcontents{\null\vfill\vskip-1.5cm
\centerline{\titlefont The Sky Map Creator
{\sbtitlefont PP\lower.35ex\hbox{3}}}
\vskip 15pt
\centerline{(Version 1.3)}
\vfill}
\def\botofcontents{\parindent2em\vfill\vfill\vfill\vfill\vfill
\noindent
%
% *LICENCE*
%
%
Copyright \copyright\ 2002--2004 Torsten Bronger
({\tt bronger@@users.sourceforge.net})
\ninerm\baselineskip0.9\baselineskip\let\it\nineit
\bigskip\noindent
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the ``Software''), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
\leftskip1cm\rightskip\leftskip
\medskip\noindent
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
If you copy or distribute a modified version of this Software, the entire
resulting derived work must be given a different name and distributed under the
terms of a permission notice identical to this one.
\leftskip0cm\rightskip\leftskip\bigskip\noindent
The Software is provided ``as~is'', without warranty of any kind, express or
implied, including but not limited to the warranties of {\it merchantability},
{\it fitness for a particular purpose\/} and {\it noninfringement}. In no
event shall the authors or copyright holders be liable for any claim, damages
or other liability, whether in an action of contract, tort or otherwise,
arising from, out of or in connection with the Software or the use or other
dealings in the Software.\vskip-1cm}
\def\PPTHREE/{{\sf PP\lower.35ex\hbox{3}}}
@i c++lib.w
@s ios int
@** Introduction. \ifpdftex (Please note that you can find a table of contents
at the end of this document). \fi This program \PPTHREE/ (``parvum
planetarium'') takes the data of various celestial data files and turns them
into a \LaTeX\ file that uses \PS/Tricks to draw a nice sky chart containing a
certain region of the sky. Current versions are available on its
\pdfURL{homepage}{http://pp3.sourceforge.net}.
You call \PPTHREE/ with e.\,g.\medskip
\.{pp3 mychart.pp3}
\medskip\noindent The data files (\.{stars.dat}, \.{nebulae.dat},
\.{boundaries.dat}, \.{labeldimens.dat}, \.{lines.dat}, and
\.{milkyway}\hskip0pt\.{.dat}) must be in the proper directory. The proper
directory was compiled into \PPTHREE/. With Linux, normally it's
\.{/usr/local/share/pp3/}, with Windows the current directory simply. But the
environment variable \.{PP3DATA} can override that.
The resulting chart is by default sent to standard output which you may
redirect into a file. But you can define an output filename explicitly in the
input script.
If you want to use other data with this program, you may well provide your own
catalogue files. Their file formats are very simple, and they are explained in
this document together with the respective |read_@t\dots@>()| function.
If you give a single dash ``\.{-}'' as the only parameter to \PPTHREE/, the
input script is read from standard input. So if you write\medskip
\.{pp3 - > test.tex \AM\AM{} latex test \AM\AM{} dvips test}
\medskip\noindent and type \.{\CF D} (\hbox{Control-D})\footnote{$^1$}{it's
Control-Z-Return on Windows}, a file \.{test.ps} should be produced that
contains a sample chart.
Very important is to know how to write an input script. Please consult the
following section ``The input script'' for this. Here is an example input
script: \medskip
{\parindent2em\baselineskip10.5pt\ninett\obeylines\obeyspaces
\# Chart of the Scorpion, printable on a
\# black and white printing device
\vskip\baselineskip
set constellation SCO \# This is highlighted
set center\UL{}rectascension 17
set center\UL{}declination -28
set grad\UL{}per\UL{}cm 2.5
\vskip\baselineskip
switch milky\UL{}way on
switch eps\UL{}output on \# Please call LaTeX and dvips for us
switch colored\UL{}stars off \# All the same colour ...
color stars 0 0 0 \# ...\ namely this one
color nebulae 0 0 0
color background 1 1 1
color grid 0.5 0.5 0.5
color ecliptic 0.3 0.3 0.3
color constellation\UL{}lines 0.7 0.7 0.7
color labels 0 0 0
color boundaries 0.8 0.8 0.8
color highlighted\UL{}boundaries 0 0 0
color milky\UL{}way 0.5 0.5 0.5
\vskip\baselineskip
filename output test.tex \# Here should it go
\vskip\baselineskip
\vskip\baselineskip
objects\UL{}and\UL{}labels \# Now for the second part
\vskip\baselineskip
delete M 18 NGC 6590 NGC 6634 ; \# Delete superfluous
reposition SCO 20 S ; \# Force sig Sco to be labelled.
text "\BS\BS{}Huge Sco" at 16.2 -41.5 color 0 0 0 towards NW ;
}
@ The resulting \LaTeX\ file doesn't use packages special to \PPTHREE/. In
fact the preamble is rather small. This makes it possible to copy the (maybe
huge) \.{\BS vbox} with the complete map into an own \LaTeX\ file. However
this may be a stupid decision because (especially if the Milky Way is switched
on) this consumes much of \TeX's pool size.
Some \PPTHREE/ figures will need a lot of \TeX's memory. Normally this is
problematic only if the Milky Way is included. If you show a too large portion
of the sky, and a lot of Milky Way area is involved, it may even happen that
\LaTeX\ simply cannot process it. You should use Milky Way data with lower
resolution in this case.
Make sure that the \PS/Tricks package is properly installed.
Please note that you cannot use pdf\/\LaTeX\ with \PPTHREE/, because \PS/Tricks
can't be used with pdf\/\LaTeX\spacefactor1000. This is not a problem. First,
you can convert all \EPS/ files easily to \PDF/ by hand, and secondly \PPTHREE/
can even call \PS/2\PDF/ for you.
@ In order to use the program, you must have a complete and modern \LaTeX\
distribution installed, and a modern Ghostscript. On a Linux system, both
programs are possibly already available, and if not you may install them with a
package management program.
{\sloppy On Windows, you will probably have to install them by hand. You can
download the \pdfURL{Mik\TeX\ distribution}{http://www.miktex.org} or get the
\pdfURL{\TeX{}Live~{\mc CD}}{http://www.tug.org/texlive/}\spacefactor1000. If
you install
\pdfURL{Ghostscript}{http://www.cs.wisc.edu/\TILDE/ghost/doc/AFPL/get811.htm},
notice that \pdfURL{{\mc
GS}View}{http://www.cs.wisc.edu/\TILDE/ghost/gsview/get45.htm} is a very
sensible program, too.\par}
@ Some flaws and bugs in this program are already known to its author.
The input script processing is shaky. The comment character `\.{\#}' must be
at the beginning of a line or must be preceded by whitespace. The special
token ``\.{objects\UL and\UL labels}'' must not occur within strings. If an
error is found in the input script, \PPTHREE/ doesn't tell the line number. It
should be possible to include more than one file, and it should allow for a
nesting depth greater than one.
At the moment almost all data structures are kept in memory completely. For
the author's needs this is perfectly sufficient, however if you want to use
data bases with hundreds of thousands of objects, you will run into trouble.
On the other hand it's only necessary to keep all object in memory that are
actually drawn. So memory usage could be reduced drastically.
@ Okay, let's start with the header files~\dots
@q'}}}}@>
@c
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include <map>
#include <list>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cfloat>@#
using namespace std;
@<Missing math routines@>@;@#
@* Global parameters and default values. I have to break a strict \CPLUSPLUS/
rule here: Never use \hbox{|#@t\hskip-\fontdimen2\mainfont@>define|}! However
I really found no alternative to~|OUT|. No |const| construct worked, and if it
had done, I'd have to use it in every single routine. And ubiquitous
|*params.out|'s are ugly.
@d OUT (*params.out)
@ The following makes it possible to compile a directory prefix into \PPTHREE/
for the data files. By default, the data files must be in the current
directory. You may say e.\,g.\ $$\hbox{\.{g++
-DPP3DATA=\BS"/usr/share/pp3/\BS" -O2 -s pp3.cc -o pp3}}$$ then they are
searched in \.{/usr/share/pp3/}. If set, an environment variable called
\.{PP3DATA} has highest priority though.
\def\NULL{0}
@s NULL TeX
@c
const char* pp3data_env_raw = getenv("PP3DATA");
const string pp3data_env = (pp3data_env_raw == NULL ?
"" : pp3data_env_raw);
#ifdef PP3DATA
const string pp3data(PP3DATA);
#else
const string pp3data;
#endif
const string filename_prefix(!pp3data_env.empty() ?
pp3data_env + '/' : (pp3data.empty() ?
"" : pp3data + "/"));
@ I declare {\it and\/} define the structure |parameters| here.
@c
@<Define |color| data structure@>@;@#
struct parameters {
double center_rectascension, center_declination;
double view_frame_width, view_frame_height;
double grad_per_cm;
double label_skip, minimal_nebula_radius, faintest_cluster_magnitude,
faintest_diffuse_nebula_magnitude, faintest_star_magnitude,
star_scaling, minimal_star_radius, faintest_star_disk_magnitude,
faintest_star_with_label_magnitude, shortest_constellation_line;
string constellation;
int font_size;
double penalties_label, penalties_star, penalties_nebula,
penalties_boundary, penalties_boundary_rim, penalties_cline,
penalties_cline_rim, penalties_threshold, penalties_rim;
string filename_stars, filename_nebulae, filename_dimensions,
filename_lines, filename_boundaries, filename_milkyway,
filename_preamble, filename_include;
string filename_output;
ostream* out;
istream* in;
bool input_file;
color bgcolor, gridcolor, eclipticcolor, boundarycolor, hlboundarycolor,
starcolor, nebulacolor, labelcolor, textlabelcolor, clinecolor,
milkywaycolor;
double linewidth_grid, linewidth_ecliptic, linewidth_boundary,
linewidth_hlboundary, linewidth_cline, linewidth_nebula;
string linestyle_grid, linestyle_ecliptic, linestyle_boundary,
linestyle_hlboundary, linestyle_cline, linestyle_nebula;
bool milkyway_visible, nebulae_visible, colored_stars, show_grid,
show_ecliptic, show_boundaries, show_lines, show_labels;
bool create_eps, create_pdf;
parameters() : @<Default values of all global parameters@> { }
int view_frame_width_in_bp() {
return int(ceil(view_frame_width / 2.54 * 72));
}
int view_frame_height_in_bp() {
return int(ceil(view_frame_height / 2.54 * 72));
}
} params;
@ @<Default values of all global parameters@>=
center_rectascension(5.8), center_declination(0.0),
view_frame_width(15.0), view_frame_height(15.0),
grad_per_cm(4.0),
constellation("ORI"), font_size(10), @/
label_skip(0.06), minimal_nebula_radius(0.1),
faintest_cluster_magnitude(4.0),
faintest_diffuse_nebula_magnitude(8.0),
faintest_star_magnitude(7.0), star_scaling(1.0),
minimal_star_radius(0.015),
faintest_star_disk_magnitude(4.5),
faintest_star_with_label_magnitude(3.7),
shortest_constellation_line(0.1), @/
penalties_label(1.0), penalties_star(1.0),
penalties_nebula(1.0), penalties_boundary(1.0),
penalties_boundary_rim(1.0), penalties_cline(1.0),
penalties_cline_rim(1.0), penalties_threshold(1.0),
penalties_rim(1.0), @/
filename_stars(filename_prefix + "stars.dat"),
filename_nebulae(filename_prefix + "nebulae.dat"),
filename_dimensions("labeldimens.dat"),
filename_lines(filename_prefix + "lines.dat"),
filename_boundaries(filename_prefix + "boundaries.dat"),
filename_milkyway(filename_prefix + "milkyway.dat"), @/
filename_preamble(), filename_include(),
filename_output(), out(&cout), in(0), input_file(false), @/
bgcolor("bgcolor", 0, 0, 0.4),
gridcolor("gridcolor", 0, 0.298, 0.447),
eclipticcolor("eclipticcolor", 1, 0, 0),
boundarycolor("boundarycolor", 0.5, 0.5, 0),
hlboundarycolor("hlboundarycolor", 1, 1, 0),
starcolor("starcolor", 1, 1, 1),
nebulacolor("nebulacolor", 1, 1, 1),
labelcolor("labelcolor", 0, 1, 1),
textlabelcolor(1, 1, 0),
clinecolor("clinecolor", 0, 1, 0),
milkywaycolor(0, 0, 1), @/
linewidth_grid(0.025), linewidth_ecliptic(0.018),
linewidth_boundary(0.035), linewidth_hlboundary(0.035),
linewidth_cline(0.035), linewidth_nebula(0.018), @/
linestyle_grid("solid"), linestyle_ecliptic("dashed"),
linestyle_boundary("dashed"),
linestyle_hlboundary("dashed"), linestyle_cline("solid"),
linestyle_nebula("solid"), @/
milkyway_visible(false),
nebulae_visible(true),
colored_stars(true),
show_grid(true), show_ecliptic(true), show_boundaries(true),
show_lines(true), show_labels(true), @/
create_eps(false),
create_pdf(false)
@** The input script. The input script is a text file that is given as the
first and only parameter to \PPTHREE/. Its format is very simple: First, a
`\.{\#}' introduces a comment and the rest of the line is ignored. Secondly,
every command has an opcode--parameter(s) form. Thirdly, opcodes and
parameters are separated by whitespace (no matter which type and how much).
Forthly, parameters and celestial objects must be separated by
``\.{objects\_and\_labels}''.
@* Part~I: Global parameters. Every input script can be divided into two
parts, however the second may be absent. They are separated from each other by
the token ``\.{objects\_and\_labels}''. Here we process the first part of the
input script.
First two small helping routines that just read simple values from the file.
@q'@>
@<Routines for reading the input script@>=
bool read_boolean(istream& script) {
string boolean;
script >> boolean;
if (boolean == "on") return true;
else if (boolean == "off") return false;
else throw string("Expected \"on\" or \"off\" in \"switch\" construct "
"in input script");
}
@ You can give strings in a similar way as on a shell command line: If it
doesn't contain spaces, just input it. In the other case you have to enclose
it within \.{"..."}. The same is necessary if it starts with a~\.{"}. Within
the double braces, backslashes and double braces have to be escaped with a
backslash. This is not necessary if you had a simple string.
So you may write e.\,g.: \.{Leo}, \.{"Leo Minor"}, \.{\BS alpha}, and
\.{"\LB\BS\BS sfseries Leo\RB"}. An empty string can only be written as
\.{""}.
@q'@>
@<Routines for reading the input script@>=
string read_string(istream& script) {
const string UnexpectedEOS("Unexpected end of input script while reading a"
" string parameter");
char c;
string contents;
while (script.get(c)) if (!isspace(c)) break;
if (!script) throw UnexpectedEOS;
if (c != '"') {
script >> contents;
if (script) contents.insert(contents.begin(),c); else contents = c;
} else {
while (script.get(c)) {
if (c == '"') break;
if (c == '\\') {
if (!script.get(c))
throw UnexpectedEOS;
switch (c) {
case '\\': case '"': contents += c; break;
default: throw string("Unknown escape sequence in string");
}
} else contents += c;
}
if (!script)
throw UnexpectedEOS;
}
return contents;
}
@ {\sloppy Here the actual routine for this first part. The top-level keywords
are: ``\.{color}'', ``\.{line\_width}'', ``\.{line\_style}'', ``\.{switch}'',
``\.{penalties}'', ``\.{filename}'', and ``\.{set}''.\par}
@.color@>
@.line\_width@>
@.line\_style@>
@.switch@>
@.penalties@>
@.filename@>
@.set@>
@<Routines for reading the input script@>=
void read_parameters_from_script(istream& script) {
string opcode;
script >> opcode;
while (opcode != "objects_and_labels" && script) {
if (opcode[0] == '#') { // skip comment line
string rest_of_line;
getline(script,rest_of_line);
} else
@<Set color parameters@>@;
else
@<Set line widths@>@;
else
@<Set line styles@>@;
else
@<Set on/off parameters@>@;
else
@<Set penalty parameters@>@;
else
@<Set filename parameters@>@;
else
@<Set single value parameters@>@;
else throw string("Undefined opcode in input script: \"")
+ opcode + '"';
script >> opcode;
}
}
@ {\sloppy Colours are given as red--green--blue values from $0$ to~$1$. For example,
$$\hbox{\.{color labels 1 0 0}}$$ which makes all labels red. The following
sub-keywords can be used: ``\.{background}'', ``\.{grid}'',
``\.{eclip}\-\.{tic}'', ``\.{boundaries}'', ``\.{highlighted\_boundaries}'',
``\.{stars}'', ``\.{nebulae}'', ``\.{labels}'',
``\.{text\_}\hskip0pt\.{labels}'', ``\.{constellation\_}\hskip0pt\.{lines}'',
and ``\.{milky\_way}''. In case of the milky way, the colour denotes the
brightest regions. (The darkest have \.{back}\-\.{ground} colour.)\par}
@.color@>
@.background@>
@.grid@>
@.ecliptic@>
@.boundaries@>
@.highlighted\_boundaries@>
@.stars@>
@.nebulae@>
@.labels@>
@.text\_labels@>
@.constellation\_lines@>
@.milky\_way@>
@<Set color parameters@>=
if (opcode == "color") {
string color_name;
script >> color_name;
if (color_name == "background") script >> params.bgcolor;
else if (color_name == "grid") script >> params.gridcolor;
else if (color_name == "ecliptic") script >> params.eclipticcolor;
else if (color_name == "boundaries")
script >> params.boundarycolor;
else if (color_name == "highlighted_boundaries")
script >> params.hlboundarycolor;
else if (color_name == "stars") script >> params.starcolor;
else if (color_name == "nebulae") script >> params.nebulacolor;
else if (color_name == "labels") script >> params.labelcolor;
else if (color_name == "text_labels")
script >> params.textlabelcolor;
else if (color_name == "constellation_lines")
script >> params.clinecolor;
else if (color_name == "milky_way") script >> params.milkywaycolor;
else throw string("Undefined \"color\" construct"
" in input script: \"") + color_name + '"';
}
@ {\sloppy\raggedright The following lines can be modified: ``\.{grid}'',
``\.{ecliptic}'', ``\.{boundaries}'',
``\.{highlighted\_}\hskip0pt\.{boundaries}'', ``\.{nebulae}'', and
``\.{constellation\_lines}''. The linewidth in centimetres must follow.\par}
@.line\_width@>
@.grid@>
@.ecliptic@>
@.boundaries@>
@.highlighted\_boundaries@>
@.nebulae@>
@.constellation\_lines@>
@<Set line widths@>=
if (opcode == "line_width") {
string line_name;
script >> line_name;
if (line_name == "grid") script >> params.linewidth_grid;
else if (line_name == "ecliptic")
script >> params.linewidth_ecliptic;
else if (line_name == "boundaries")
script >> params.linewidth_boundary;
else if (line_name == "highlighted_boundaries")
script >> params.linewidth_hlboundary;
else if (line_name == "nebulae")
script >> params.linewidth_nebula;
else if (line_name == "constellation_lines")
script >> params.linewidth_cline;
else throw string("Undefined \"line_width\" construct"
" in input script: \"") + line_name + '"';
}
@ {\sloppy\raggedright The following lines can be modified: ``\.{grid}'',
``\.{ecliptic}'', ``\.{boundaries}'',
``\.{highlighted\_}\hskip0pt\.{boundaries}'', ``\.{nebulae}'', and
``\.{constellation\_lines}''. You can set the respective line style to
``\.{solid}'', ``\.{dashed}'', and ``\.{dotted}''.\par}
@.line\_style@>
@.solid@>
@.dashed@>
@.dotted@>
@.grid@>
@.ecliptic@>
@.boundaries@>
@.highlighted\_boundaries@>
@.nebulae@>
@.constellation\_lines@>
@<Set line styles@>=
if (opcode == "line_style") {
string line_name;
script >> line_name;
if (line_name == "grid") script >> params.linestyle_grid;
else if (line_name == "ecliptic")
script >> params.linestyle_ecliptic;
else if (line_name == "boundaries")
script >> params.linestyle_boundary;
else if (line_name == "highlighted_boundaries")
script >> params.linestyle_hlboundary;
else if (line_name == "nebulae")
script >> params.linestyle_nebula;
else if (line_name == "constellation_lines")
script >> params.linestyle_cline;
else throw string("Undefined \"line_width\" construct"
" in input script: \"") + line_name + '"';
}
@ {\sloppy There are the following boolean values: ``\.{milky\_may}'',
``\.{nebulae}'', ``\.{colored\_stars}'', ``\.{grid}'', ``\.{ecliptic}'',
``\.{boundaries}'', ``\.{constellation\_lines}'', ``\.{labels}'',
``\.{eps\_output}'', and ``\.{pdf\_output}''. You can switch them ``\.{on}''
or ``\.{off}''.\par}
@.switch@>
@.on@>
@.off@>
@.milky\_way@>
@.nebulae@>
@.colored\_stars@>
@.grid@>
@.ecliptic@>
@.boundaries@>
@.constellation\_lines@>
@.labels@>
@.eps\_output@>
@.pdf\_output@>
@<Set on/off parameters@>=
if (opcode == "switch") {
string switch_name;
script >> switch_name;
if (switch_name == "milky_way")
params.milkyway_visible = read_boolean(script);
else if (switch_name == "nebulae")
params.nebulae_visible = read_boolean(script);
else if (switch_name == "colored_stars")
params.colored_stars = read_boolean(script);
else if (switch_name == "grid")
params.show_grid = read_boolean(script);
else if (switch_name == "ecliptic")
params.show_ecliptic = read_boolean(script);
else if (switch_name == "boundaries")
params.show_boundaries = read_boolean(script);
else if (switch_name == "constellation_lines")
params.show_lines = read_boolean(script);
else if (switch_name == "labels")
params.show_labels = read_boolean(script);
else if (switch_name == "eps_output")
params.create_eps = read_boolean(script);
else if (switch_name == "pdf_output")
params.create_pdf = read_boolean(script);
else throw string("Undefined \"switch\" construct"
" in input script: \"") + switch_name + '"';
}
@ In order to avoid overlaps, \PPTHREE/ uses a simple penalty algorithm. The
standard value for all penalty values is~1000. The meanings of ``\.{stars}'',
``\.{labels}'', ``\.{nebulae}'', ``\.{boundaries}'', and
``\.{constellation\_lines}'' is pretty easy to explain: They come into play
when the current label (that is to be positioned) overlaps with the respective
object. For example, if you want overlaps with constellation lines to be less
probable, you can say $$\hbox{\.{penalties constellation\_lines 2000}}$$
There is another concept of importance here: The rim. A rim is a rectangular
margin around every label with a width of |skip|. Overlaps in the rim are
counted, too, however normally they don't hurt that much. Normally they hurt
half as much as the label area ({\it core}) itself, but this can be changed
with ``\.{rim}''. With $$\hbox{\.{penalties rim 0}}$$ the rim loses its
complete significance. But notice that for each core penalty a rim penalty is
added, too, so that the rim can never be more significant than the core.
Within the rim, ``\.{boundaries\_rim}'' and ``\.{constellation\_lines\_rim}''
are used instead of the normal ones. This is because lines are not so bad in
the rim as other stars or nebulae would be, because other stars in the vicinity
of a label may cause confusion, lines not.
\medskip The third thing about penalties is the maximal penalty of a label. If
the penalties of a label exceed this value, the label is supressed. You may
overrule this behaviour with an explicit repositioning of the label. You can
adjust this maximal badness of the label with ``\.{threshold}''. With
$$\hbox{\.{penalties threshold 10000}}$$ probably all labels are printed.
@.penalties@>
@.stars@>
@.labels@>
@.nebulae@>
@.boundaries@>
@.boundaries\_rim@>
@.constellation\_lines@>
@.constellation\_lines\_rim@>
@.threshold@>
@.rim@>
@q'@>
@<Set penalty parameters@>=
if (opcode == "penalties") {
string penalty_name;
double value;
script >> penalty_name >> value;
value /= 1000.0;
if (penalty_name == "stars")
params.penalties_star = value;
else if (penalty_name == "labels")
params.penalties_label = value;
else if (penalty_name == "nebulae")
params.penalties_nebula = value;
else if (penalty_name == "boundaries")
params.penalties_boundary = value;
else if (penalty_name == "boundaries_rim")
params.penalties_boundary_rim = value;
else if (penalty_name == "constellation_lines")
params.penalties_cline = value;
else if (penalty_name == "constellation_lines_rim")
params.penalties_cline_rim = value;
else if (penalty_name == "threshold")
params.penalties_threshold = value;
else if (penalty_name == "rim")
params.penalties_rim = value;
else throw string("Undefined \"penalties\" construct"
" in input script: \"") + penalty_name + '"';
}
@ @q(@> The most important filename is ``\.{output}''. By default it's unset
so that the output is sent to standard output. With $$\hbox{\.{filename output
orion.tex}}$$ the output is written to \.{orion.tex}. Most of the other
filenames denote the data files. Their file format is described at the
functions that read them. Their names are: ``\.{stars}'', ``\.{nebulae}'',
``\.{label\_dimensions}'', ``\.{constellation\_lines}'', ``\.{boundaries}'',
and ``\.{milky\_way}''.
``\.{latex\_preamble}'' is a file with a \LaTeX\ excerpt with a preamble
fragment for the \LaTeX\ output. See |@<|create_preamble()| for writing the
\LaTeX\ preamble@>|.
``\.{include}'' denotes a file that is included at the current position as an
insert script file. This command particularly makes sense at the very
beginning of the input script because then you can overwrite the values
locally. Note that you can only include zero or one file, and included script
files must not contain further \.{include}s. Apart from that included scripts
have the same structure as usual scripts. (This is also true for a possible
`\.{objects\_and\_labels}' part.)
@q;@>
The meaning of this is of course to write a master script with global settings
(e.\,g.\ colour, line style, data file names etc.), and to overwrite them for
certain regions of the sky, typically stellar constellations.
@.output@>
@.stars@>
@.nebulae@>
@.label\_dimensions@>
@.constellation\_lines@>
@.boundaries@>
@.milky\_way@>
@.latex\_preamble@>
@.include@>
@<Set filename parameters@>=
if (opcode == "filename") {
string object_name;
script >> object_name;
if (object_name == "output")
params.filename_output = read_string(script);
else if (object_name == "stars")
params.filename_stars = read_string(script);
else if (object_name == "nebulae")
params.filename_nebulae = read_string(script);
else if (object_name == "label_dimensions")
params.filename_dimensions = read_string(script);
else if (object_name == "constellation_lines")
params.filename_lines = read_string(script);
else if (object_name == "boundaries")
params.filename_boundaries = read_string(script);
else if (object_name == "milky_way")
params.filename_milkyway = read_string(script);
else if (object_name == "latex_preamble")
params.filename_preamble = read_string(script);
else if (object_name == "include") {
if (!params.filename_include.empty())
throw string("Nesting depth of include files greater"
" than one");
params.filename_include = read_string(script);
ifstream included_script(params.filename_include.c_str());
if (!included_script.good())
cerr << "pp3: Warning: included file "
<< params.filename_include
<< " not found; ignored" << endl;
else read_parameters_from_script(included_script);
}
else throw string("Undefined \"filename\" construct"
" in input script: \"") + object_name + '"';
}
@ Most of these values are numeric, only \.{constellation} is a string, namely
a three-letter all-uppercase astronomic abbreviation of the constellation to be
highlighted. It's default is ``\.{ORI}'' but you may set it to the empty
string with $$\hbox{\.{set constellation ""}}$$ so no constellation gets
highlighted. At the moment highlighting means that the boundaries have a
brighter colour than normal.
{\sloppy\raggedright
``\.{center\_rectascension}'' and ``\.{center\_declination}'' are the celestial
coordinates of the view frame centre. ``\.{box\_width}'' and
``\.{box\_height}'' are the dimensions of the view frame in centimetres.
``\.{grad\_per\_cm}'' is the magnification (scale).
``\.{star\_scaling}'' denotes a radial scaling of the star
disks. ``\.{fontsize}'' is the global \LaTeX\ font size (in points). It must
be 10, 11, or~12. Default is~10.
Many parameters deal with the graphical representation of stars and nebulae:
``\.{shortest\_constellation\_line}'' is the shortest length for a
constellation line that is supposed to be drawn. ``\.{label\_skip}'' is the
distance between label and celestial object. ``\.{minimal\_nebula\_radius}''
is the radius under which a nebula is drawn as a mere circle of {\it that\/}
radius. ``\.{minimal\_star\_radius}'' is the radius of the smallest stellar
dots of the graphics. All these parameters are measured in centimetres.
But there are also some magnitudes: The faintest stellar clusters that are
drawn by default are of the ``\.{faintest\_cluster\_magnitude}'', all other
nebulae drawn by default of the ``\.{faintest\_diffuse\_nebula\_magnitude}''.
Stars brighter than ``\.{faintest\_star\_magnitude}'' are drawn at all, if they
are even brighter than ``\.{faintest\_star\_with\_label\_magnitude}'' they get
a label. Stars brighter than ``\.{faintest\_star\_disk\_magnitude}'' are not
just mere dots in the background, but get a radius according to their
brightness.\par}
Many of these parameters trigger the default behaviour that you can overrule by
commands in the second part of the input script.
@.set@>
@.center\_rectascension@>
@.center\_declination@>
@.box\_width@>
@.box\_height@>
@.grad\_per\_cm@>
@.shortest\_constellation\_line@>
@.label\_skip@>
@.minimal\_nebula\_radius@>
@.faintest\_cluster\_magnitude@>
@.faintest\_diffuse\_nebula\_magnitude@>
@.faintest\_star\_magnitude@>
@.minimal\_star\_radius@>
@.faintest\_star\_disk\_magnitude@>
@.faintest\_star\_with\_label\_magnitude@>
@.star\_scaling@>
@.constellation@>
@.fontsize@>
@q)'@>
@<Set single value parameters@>=
if (opcode == "set") {
string param_name;
script >> param_name;
if (param_name == "center_rectascension")
script >> params.center_rectascension;
else if (param_name == "center_declination")
script >> params.center_declination;
else if (param_name == "box_width")
script >> params.view_frame_width;
else if (param_name == "box_height")
script >> params.view_frame_height;
else if (param_name == "grad_per_cm")
script >> params.grad_per_cm;
else if (param_name == "constellation")
params.constellation = read_string(script);
else if (param_name == "shortest_constellation_line")
script >> params.shortest_constellation_line;
else if (param_name == "label_skip")
script >> params.label_skip;
else if (param_name == "minimal_nebula_radius")
script >> params.minimal_nebula_radius;
else if (param_name == "faintest_cluster_magnitude")
script >> params.faintest_cluster_magnitude;
else if (param_name == "faintest_diffuse_nebula_magnitude")
script >> params.faintest_diffuse_nebula_magnitude;
else if (param_name == "faintest_star_magnitude")
script >> params.faintest_star_magnitude;
else if (param_name == "minimal_star_radius")
script >> params.minimal_star_radius;
else if (param_name == "faintest_star_disk_magnitude")
script >> params.faintest_star_disk_magnitude;
else if (param_name == "faintest_star_with_label_magnitude")
script >> params.faintest_star_with_label_magnitude;
else if (param_name == "star_scaling")
script >> params.star_scaling;
else if (param_name == "fontsize")
script >> params.font_size;
else
throw string("Undefined \"set\" construct in input script: \"")
+ param_name + '"';
}
@* Part~II: Change printed objects and labels. Here I read and interpret the
second part of the input script, {\it after\/} the |"objects_and_labels"|.
This part doesn't need to be available, and both parts may be empty.
First I define a type that is often used in the following routines for a
mapping from a catalogue number on the index in \PPTHREE/'s internal |vectors|.
This makes access a lot faster.
@<Routines for reading the input script@>=
typedef map<int,int> index_list;