source: tags/release-1.2.2/src/Utils/mycpgplot.cc

Last change on this file was 528, checked in by MatthewWhiting, 15 years ago

Changing the documentation comments to match the askapsoft style. Also have split ChanMap? and Object3D into separate files.

File size: 2.9 KB
Line 
1// -----------------------------------------------------------------------
2// mycpgplot.cc: Various useful functions for use with PGPLOT.
3// -----------------------------------------------------------------------
4// Copyright (C) 2006, Matthew Whiting, ATNF
5//
6// This program is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2 of the License, or (at your
9// option) any later version.
10//
11// Duchamp is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14// for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Duchamp; if not, write to the Free Software Foundation,
18// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
19//
20// Correspondence concerning Duchamp may be directed to:
21//    Internet email: Matthew.Whiting [at] atnf.csiro.au
22//    Postal address: Dr. Matthew Whiting
23//                    Australia Telescope National Facility, CSIRO
24//                    PO Box 76
25//                    Epping NSW 1710
26//                    AUSTRALIA
27// -----------------------------------------------------------------------
28#include <string>
29#include <cpgplot.h>
30#include <duchamp/Utils/mycpgplot.hh>
31
32namespace mycpgplot
33{
34 
35  int cpgIsPS()
36  {
37    ///  @details
38    ///     A front-end to cpgqinf, that tests whether the device is using a
39    ///     postscript (by which we mean "hardcopy") device
40    char answer[50];
41    int answer_len = sizeof(answer);
42    cpgqinf("TYPE", answer, &answer_len);
43    return ((answer[answer_len-2]=='P')&&((answer[answer_len-1]=='S')));
44  }
45 
46  void setDarkGreen(){
47    cpgscr(DARKGREEN,0.,0.7,0.);
48  }
49
50  void setWCSGreen(){
51    cpgscr(WCSGREEN,0.3,0.5,0.3);
52  }
53
54  int mycpgopen(std::string device)
55  {
56    ///  @details
57    /// This function opens the requested device using cpgopen.
58    ///
59    /// It also defines both the new colours DARKGREEN and WCSGREEN,
60    /// for later use so that they don't have to be defined manually.
61    ///
62    /// \param device The PGPLOT device to be opened.
63    /// \return The return value of cpgopen.
64    int status = cpgopen(device.c_str());
65    if(status>0){
66      setDarkGreen();
67      setWCSGreen();
68    }
69    return status;
70  }
71
72  void setWhite()
73  {
74  /// @details
75  /// Uses cpgIsPS() to determine whether a device is a postscript
76  /// one. If so, we use the BACKGND colour (ie. 0), otherwise use
77  /// FOREGND (1).
78    if(cpgIsPS()) cpgsci(BACKGND);
79    else cpgsci(FOREGND);
80  }
81
82 
83  void setBlack()
84  {
85  /// @details
86  /// Uses cpgIsPS() to determine whether a device is a postscript
87  /// one. If so, we use the FOREGND colour (ie. 1), otherwise use
88  /// BACKGND (0).
89    if(cpgIsPS()) cpgsci(FOREGND);
90    else cpgsci(BACKGND);
91  }
92
93}
Note: See TracBrowser for help on using the repository browser.