% $Id: pp3.w,v 1.42 2004/08/14 13:46:22 bronger Exp $ @q======================================================================@> @q pp3.w - Star Catalog Chart Creator @> @q Copyright 2002--2004 Torsten Bronger @> @q @> @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 #include #include #include #include #include #include #include #include #include #include @# using namespace std; @@;@# @* 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 @@;@# 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() : @ { } 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; @ @= 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'@> @= 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'@> @= 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@> @= 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 @@; else @@; else @@; else @@; else @@; else @@; else @@; 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@> @= 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@> @= 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@> @= 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@> @= 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'@> @= 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@> @= 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)'@> @= 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. @= typedef map index_list; @ Here I create the data structures that make the above mentioned mapping possible. FixMe: They should be defined globally, so that the constellation lines construction can profit by it, too. And then they needn't be given in the parameter lists of the routines. This mapping is not vital for the program, but the alternative would be to look through the whole of |nebulae| or |stars| to find a star with a certain \NGC/ or \HD/ number. This is probably way to inefficient. @q'@> @= const int max_ngc = 7840, max_ic = 5386, max_messier = 110; index_list ngc, ic, messier; for (int i = 0; i < nebulae.size(); i++) { if (nebulae[i].ngc > 0 && nebulae[i].ngc <= max_ngc) ngc[nebulae[i].ngc] = i; if (nebulae[i].ic > 0 && nebulae[i].ic <= max_ic) ic[nebulae[i].ic] = i; if (nebulae[i].messier > 0 && nebulae[i].messier <= max_messier) messier[nebulae[i].messier] = i; } index_list henry_draper; map flamsteed; for (int i = 0; i < stars.size(); i++) { if (stars[i].hd > 0) henry_draper[stars[i].hd] = i; if (stars[i].flamsteed > 0) flamsteed[stars[i].constellation][stars[i].flamsteed] = i; } @ This is a general warning producing routine. Such tests are vital, especially if the nebulae file has been deleted in order to save disk space. I want it to be a warning because it would be very annowing to delete all such opcodes from an input script only because one wants to dispense with e.\,g.\ nebulae. I need three incarnations of this function: One for nebulae, one for Flamsteed number, and one for Henry Draper catalogue numbers. @= bool assure_valid_catalogue_index(const int index, const index_list& catalogue, const string catalogue_name) { if (catalogue.find(index) == catalogue.end()) { cerr << "pp3: Warning: Invalid " << catalogue_name << " index: " << index << ".\n"; return false; } else return true; } bool assure_valid_catalogue_index(const int index, const string constellation, map& flamsteed) { bool found = true; if (flamsteed.find(constellation) == flamsteed.end()) found = false; else if (flamsteed[constellation].find(index) == flamsteed[constellation].end()) found = false; if (!found) cerr << "pp3: Warning: Invalid Flamsteed number: " << index << ".\n"; return found; } bool assure_valid_catalogue_index(const int index, const index_list& henry_draper) { if (henry_draper.find(index) == henry_draper.end()) { cerr << "pp3: Warning: Invalid HD number: " << index << ".\n"; return false; } else return true; } @ In this routine I scan a list of stellar objects, given by a token pair of catalogue name and catalogue index. Such lists are used after some top-level commands below. A mandatory `\.{;}' ends such a list. Five catalogues are supported: \NGC/, \IC/, Messier, Henry-Draper~(\HD/), and Flamsteed numbers (in the form ``{\it Constellation}\SP{\it Flamsteed number}''). You may use the program `Celestia' to get the \HD/ numbers for the stars. @= void search_objects(istream& script, index_list& ngc, index_list& ic, index_list& messier, index_list& henry_draper, map& flamsteed, vector& found_stars, vector& found_nebulae) { found_stars.clear(); found_nebulae.clear(); string catalogue_name; int catalogue_index; script >> catalogue_name; while (script && catalogue_name != ";") { script >> catalogue_index; if (catalogue_index <= 0) { stringstream error_message; error_message << "Invalid index: " << catalogue_index; throw error_message.str(); } if (!script) throw string("Unexpected end of input script"); if (params.nebulae_visible || (catalogue_name != "NGC" && catalogue_name != "IC" && catalogue_name != "M")) { if (catalogue_name == "NGC") { if (assure_valid_catalogue_index(catalogue_index,ngc,"NGC")) found_nebulae.push_back(ngc[catalogue_index]); } else if (catalogue_name == "IC") { if (assure_valid_catalogue_index(catalogue_index,ic,"IC")) found_nebulae.push_back(ic[catalogue_index]); } else if (catalogue_name == "M") { if (assure_valid_catalogue_index(catalogue_index,messier,"M")) found_nebulae.push_back(messier[catalogue_index]); } else if (catalogue_name == "HD") { if (assure_valid_catalogue_index(catalogue_index,henry_draper)) found_stars.push_back(henry_draper[catalogue_index]); } else { if (assure_valid_catalogue_index(catalogue_index, catalogue_name,flamsteed)) found_stars. push_back(flamsteed[catalogue_name][catalogue_index]); } } script >> catalogue_name; } } @ This routine essentially does the same as the prevous one, however only for {\it one\/} celestial object. This is used for commands that don't take an object list but only one object. @q'@> @= view_data* identify_object(istream& script, index_list& ngc, index_list& ic, index_list& messier, index_list& henry_draper, map& flamsteed, stars_list& stars, nebulae_list& nebulae) { string catalogue_name; int catalogue_index; script >> catalogue_name >> catalogue_index; if (!script) throw string("Unexpected end of input script"); if (catalogue_name == "NGC") { if (assure_valid_catalogue_index(catalogue_index,ngc,"NGC")) return &nebulae[ngc[catalogue_index]]; } else if (catalogue_name == "IC") { if (assure_valid_catalogue_index(catalogue_index,ic,"IC")) return &nebulae[ic[catalogue_index]]; } else if (catalogue_name == "M") { if (assure_valid_catalogue_index(catalogue_index,messier,"M")) return &nebulae[messier[catalogue_index]]; } else if (catalogue_name == "HD") { if (assure_valid_catalogue_index(catalogue_index,henry_draper)) return &stars[henry_draper[catalogue_index]]; } else { if (assure_valid_catalogue_index(catalogue_index, catalogue_name,flamsteed)) return &stars[flamsteed[catalogue_name][catalogue_index]]; } return 0; } @ Here now the main routine for the second part of the input script. The top-level commands in this section are: ``\.{reposition}'', ``\.{delete\_labels}'', ``\.{add\_labels}'', ``\.{delete}'', ``\.{add}'', ``\.{set\_text\_label}'', and ``\.{text}''. @.reposition@> @.delete\_labels@> @.add\_labels@> @.delete@> @.add@> @.text@> @.set\_label\_text@> @= void read_objects_and_labels(istream& script, const dimensions_list& dimensions, objects_list& objects, stars_list& stars, nebulae_list& nebulae, texts_list& texts, flexes_list& flexes, const transformation& mytransform, bool included = false) { if (!params.filename_include.empty() && !included) { ifstream included_file(params.filename_include.c_str()); @@; read_objects_and_labels(included_file, dimensions, objects, stars, nebulae, texts, flexes, mytransform, true); } string opcode; script >> opcode; if (!script) return; @@; while (script) { if (opcode[0] == '#') { // skip comment line string rest_of_line; getline(script,rest_of_line); } else @