1 | // ----------------------------------------------------------------------- |
---|
2 | // PlottingUtilities.cc : Utility functions to help plotting, |
---|
3 | // particularly for using cpgsbox. |
---|
4 | // ----------------------------------------------------------------------- |
---|
5 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
6 | // |
---|
7 | // This program is free software; you can redistribute it and/or modify it |
---|
8 | // under the terms of the GNU General Public License as published by the |
---|
9 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
10 | // option) any later version. |
---|
11 | // |
---|
12 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
13 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
14 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
15 | // for more details. |
---|
16 | // |
---|
17 | // You should have received a copy of the GNU General Public License |
---|
18 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
19 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
20 | // |
---|
21 | // Correspondence concerning Duchamp may be directed to: |
---|
22 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
23 | // Postal address: Dr. Matthew Whiting |
---|
24 | // Australia Telescope National Facility, CSIRO |
---|
25 | // PO Box 76 |
---|
26 | // Epping NSW 1710 |
---|
27 | // AUSTRALIA |
---|
28 | // ----------------------------------------------------------------------- |
---|
29 | #include <duchamp/duchamp.hh> |
---|
30 | #include <duchamp/Utils/mycpgplot.hh> |
---|
31 | #include <wcslib/cpgsbox.h> |
---|
32 | #include <wcslib/pgwcsl.h> |
---|
33 | #include <wcslib/wcs.h> |
---|
34 | #include <cpgplot.h> |
---|
35 | #include <string.h> |
---|
36 | |
---|
37 | void wcsAxes(struct wcsprm *wcs, size_t *axes, int textColour, int axisColour) |
---|
38 | { |
---|
39 | |
---|
40 | /// @details |
---|
41 | /// A front-end to the cpgsbox command, to draw the gridlines for the WCS |
---|
42 | /// over the current plot. |
---|
43 | /// Lines are drawn in dark green over the full plot area, and the axis |
---|
44 | /// labels are written on the top and on the right hand sides, so as not |
---|
45 | /// to conflict with other labels. |
---|
46 | /// \param textColour The colour index to use for the text labels -- |
---|
47 | /// defaults to duchamp::DUCHAMP_ID_TEXT_COLOUR |
---|
48 | /// \param axisColour The colour index to use for the axes -- |
---|
49 | /// defaults to duchamp::DUCHAMP_WCS_AXIS_COLOUR |
---|
50 | |
---|
51 | float boxXmin=0,boxYmin=0; |
---|
52 | |
---|
53 | char idents[3][80], opt[2], nlcprm[1]; |
---|
54 | |
---|
55 | strcpy(idents[0], wcs->lngtyp); |
---|
56 | strcpy(idents[1], wcs->lattyp); |
---|
57 | strcpy(idents[2], ""); |
---|
58 | if(strcmp(wcs->lngtyp,"RA")==0) opt[0] = 'G'; |
---|
59 | else opt[0] = 'D'; |
---|
60 | opt[1] = 'E'; |
---|
61 | |
---|
62 | float blc[2], trc[2]; |
---|
63 | // float scl; // --> unused here. |
---|
64 | blc[0] = boxXmin + 0.5; |
---|
65 | blc[1] = boxYmin + 0.5; |
---|
66 | trc[0] = boxXmin + axes[0]+0.5; |
---|
67 | trc[1] = boxYmin + axes[1]+0.5; |
---|
68 | |
---|
69 | int existingLineWidth; |
---|
70 | cpgqlw(&existingLineWidth); |
---|
71 | int existingColour; |
---|
72 | cpgqci(&existingColour); |
---|
73 | float existingSize; |
---|
74 | cpgqch(&existingSize); |
---|
75 | cpgsci(textColour); |
---|
76 | cpgsch(0.8); |
---|
77 | int c0[7], ci[7], gcode[2], ic, ierr; |
---|
78 | for(int i=0;i<7;i++) c0[i] = -1; |
---|
79 | /* define the WCS axes colour */ |
---|
80 | mycpgplot::setWCSGreen(); |
---|
81 | |
---|
82 | gcode[0] = 2; // type of grid to draw: 0=none, 1=ticks only, 2=full grid |
---|
83 | gcode[1] = 2; |
---|
84 | |
---|
85 | double cache[257][4], grid1[9], grid2[9], nldprm[8]; |
---|
86 | grid1[0] = 0.0; |
---|
87 | grid2[0] = 0.0; |
---|
88 | |
---|
89 | // Draw the celestial grid with no intermediate tick marks. |
---|
90 | // Set LABCTL=2100 to write 1st coord on top, and 2nd on right |
---|
91 | |
---|
92 | //Colour indices used by cpgsbox: make it all the same colour for thin |
---|
93 | // line case. |
---|
94 | ci[0] = axisColour; // grid lines, coord 1 |
---|
95 | ci[1] = axisColour; // grid lines, coord 2 |
---|
96 | ci[2] = axisColour; // numeric labels, coord 1 |
---|
97 | ci[3] = axisColour; // numeric labels, coord 2 |
---|
98 | ci[4] = axisColour; // axis annotation, coord 1 |
---|
99 | ci[5] = axisColour; // axis annotation, coord 2 |
---|
100 | ci[6] = axisColour; // title |
---|
101 | |
---|
102 | cpgsbox(blc, trc, idents, opt, 2100, 0, ci, gcode, 0.0, 0, grid1, 0, grid2, |
---|
103 | 0, pgwcsl_, 1, WCSLEN, 1, nlcprm, (int *)wcs, |
---|
104 | nldprm, 256, &ic, cache, &ierr); |
---|
105 | |
---|
106 | cpgsci(existingColour); |
---|
107 | cpgsch(existingSize); |
---|
108 | cpgslw(existingLineWidth); |
---|
109 | } |
---|
110 | |
---|
111 | |
---|