source: tags/release-1.1.1/src/Cubes/drawBlankEdges.cc @ 1323

Last change on this file since 1323 was 316, checked in by Matthew Whiting, 17 years ago
  • Centralised the definitions of the various colours used in the graphical output.
  • Removed the function Cube::plotBlankEdges(), replacing it with direct calls to drawBlankEdges, using a defined colour.
File size: 3.2 KB
Line 
1// -----------------------------------------------------------------------
2// drawBlankEdges.cc: Draw the edge of the BLANK region of the cube on
3//                    a PGPLOT map.
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 <cpgplot.h>
30#include <duchamp.hh>
31#include <param.hh>
32#include <Utils/mycpgplot.hh>
33#include <string>
34
35void drawBlankEdges(float *dataArray, int xdim, int ydim, Param &par)
36{
37  /**   
38   *   A subroutine that is designed to draw the edges of the blank
39   *   region of the cube on a moment/detection map. Uses the same
40   *   procedure as used in the reconstruction subroutines.
41   *
42   *   Note that it needs a PGPLOT device open. The colour used is the current
43   *    PGPLOT colour.
44   *
45   *   \param dataArray The array of pixel values
46   *   \param xdim      The size of the array in the x-direction.
47   *   \param ydim      The size of the array in the y-direction.
48   *   \param par       The Param set telling us what a BLANK pixel is.
49   */
50
51  if(par.getFlagBlankPix()){
52
53    if(!cpgtest())
54      duchampError("Draw Blank Edges","There is no PGPlot device open!\n");
55    else{
56
57      int colour;
58      cpgqci(&colour);
59      cpgsci(DUCHAMP_BLANK_EDGE_COLOUR);
60
61      float xoff,x2,yoff,y2;
62      cpgqwin(&xoff,&x2,&yoff,&y2);
63
64      bool *blank = new bool[xdim*ydim];
65      for(int i=0;i<xdim*ydim;i++) blank[i] = par.isBlank(dataArray[i]);
66
67      for(int x=0; x<xdim; x++){// for each column...
68        for(int y=1;y<ydim;y++){
69          int current = y*xdim + x;
70          int previous = (y-1)*xdim + x;
71          if( (blank[current]&&!blank[previous]) ||
72              (!blank[current]&&blank[previous])   ){
73            cpgmove(x-0.5, y-0.5);
74            cpgdraw(x+0.5, y-0.5);
75          }
76        }
77      }
78     
79      for(int y=0; y<ydim; y++){// for each row...
80        for(int x=1;x<xdim;x++){
81          int current = y*xdim + x;
82          int previous = y*xdim + x-1;
83          if( (blank[current]&&!blank[previous]) ||
84              (!blank[current]&&blank[previous])   ){
85            cpgmove(x-0.5, y-0.5);
86            cpgdraw(x-0.5, y+0.5);
87          }
88        }
89      }
90
91      delete [] blank;
92     
93      cpgsci(colour);
94 
95    }
96
97 
98  }
99
100}
Note: See TracBrowser for help on using the repository browser.