source: trunk/src/Utils/PlottingUtilities.cc @ 1251

Last change on this file since 1251 was 1250, checked in by MatthewWhiting, 11 years ago

Ticket #195 - moving plotWCSaxes to Utils and renaming wcsAxes. Removing Cubes/plots.{cc,hh}.

File size: 4.0 KB
Line 
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
36void wcsAxes(struct wcsprm *wcs, size_t *axes, int textColour, int axisColour)
37{
38
39    /// @details
40    ///  A front-end to the cpgsbox command, to draw the gridlines for the WCS
41    ///    over the current plot.
42    ///  Lines are drawn in dark green over the full plot area, and the axis
43    ///    labels are written on the top and on the right hand sides, so as not
44    ///    to conflict with other labels.
45    ///  \param textColour The colour index to use for the text labels --
46    ///  defaults to duchamp::DUCHAMP_ID_TEXT_COLOUR
47    ///  \param axisColour The colour index to use for the axes --
48    ///  defaults to duchamp::DUCHAMP_WCS_AXIS_COLOUR
49
50    float boxXmin=0,boxYmin=0;
51
52    char idents[3][80], opt[2], nlcprm[1];
53
54    strcpy(idents[0], wcs->lngtyp);
55    strcpy(idents[1], wcs->lattyp);
56    strcpy(idents[2], "");
57    if(strcmp(wcs->lngtyp,"RA")==0) opt[0] = 'G';
58    else opt[0] = 'D';
59    opt[1] = 'E';
60
61    float  blc[2], trc[2];
62    //   float  scl; // --> unused here.
63    blc[0] = boxXmin + 0.5;
64    blc[1] = boxYmin + 0.5;
65    trc[0] = boxXmin + axes[0]+0.5;
66    trc[1] = boxYmin + axes[1]+0.5;
67 
68    int existingLineWidth;
69    cpgqlw(&existingLineWidth);
70    int existingColour;
71    cpgqci(&existingColour);
72    float existingSize;
73    cpgqch(&existingSize);
74    cpgsci(textColour);
75    cpgsch(0.8);
76    int    c0[7], ci[7], gcode[2], ic, ierr;
77    for(int i=0;i<7;i++) c0[i] = -1;
78    /* define the WCS axes colour */
79    mycpgplot::setWCSGreen();
80
81    gcode[0] = 2;  // type of grid to draw: 0=none, 1=ticks only, 2=full grid
82    gcode[1] = 2;
83
84    double cache[257][4], grid1[9], grid2[9], nldprm[8];
85    grid1[0] = 0.0; 
86    grid2[0] = 0.0;
87
88    // Draw the celestial grid with no intermediate tick marks.
89    // Set LABCTL=2100 to write 1st coord on top, and 2nd on right
90
91    //Colour indices used by cpgsbox: make it all the same colour for thin
92    // line case.
93    ci[0] = axisColour; // grid lines, coord 1
94    ci[1] = axisColour; // grid lines, coord 2
95    ci[2] = axisColour; // numeric labels, coord 1
96    ci[3] = axisColour; // numeric labels, coord 2
97    ci[4] = axisColour; // axis annotation, coord 1
98    ci[5] = axisColour; // axis annotation, coord 2
99    ci[6] = axisColour; // title
100
101    cpgsbox(blc, trc, idents, opt, 2100, 0, ci, gcode, 0.0, 0, grid1, 0, grid2,
102            0, pgwcsl_, 1, WCSLEN, 1, nlcprm, (int *)wcs,
103            nldprm, 256, &ic, cache, &ierr);
104
105    cpgsci(existingColour);
106    cpgsch(existingSize);
107    cpgslw(existingLineWidth);
108}
109
110
Note: See TracBrowser for help on using the repository browser.