[299] | 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 | // ----------------------------------------------------------------------- |
---|
[129] | 29 | #include <cpgplot.h> |
---|
[463] | 30 | #include <duchamp/Cubes/cubeUtils.hh> |
---|
[393] | 31 | #include <duchamp/duchamp.hh> |
---|
| 32 | #include <duchamp/param.hh> |
---|
| 33 | #include <duchamp/Utils/mycpgplot.hh> |
---|
[129] | 34 | #include <string> |
---|
| 35 | |
---|
[378] | 36 | namespace duchamp |
---|
[129] | 37 | { |
---|
| 38 | |
---|
[884] | 39 | void drawBlankEdges(float *dataArray, size_t xdim, size_t ydim, Param &par) |
---|
[378] | 40 | { |
---|
[528] | 41 | /// @details |
---|
| 42 | /// A subroutine that is designed to draw the edges of the blank |
---|
| 43 | /// region of the cube on a moment/detection map. Uses the same |
---|
| 44 | /// procedure as used in the reconstruction subroutines. |
---|
| 45 | /// |
---|
| 46 | /// Note that it needs a PGPLOT device open. The colour used is the current |
---|
| 47 | /// PGPLOT colour. |
---|
| 48 | /// |
---|
| 49 | /// \param dataArray The array of pixel values |
---|
| 50 | /// \param xdim The size of the array in the x-direction. |
---|
| 51 | /// \param ydim The size of the array in the y-direction. |
---|
| 52 | /// \param par The Param set telling us what a BLANK pixel is. |
---|
[129] | 53 | |
---|
[378] | 54 | if(par.getFlagBlankPix()){ |
---|
[129] | 55 | |
---|
[913] | 56 | if(!cpgtest()){ |
---|
| 57 | DUCHAMPERROR("Draw Blank Edges","There is no PGPlot device open."); |
---|
| 58 | } |
---|
[378] | 59 | else{ |
---|
[316] | 60 | |
---|
[378] | 61 | int colour; |
---|
| 62 | cpgqci(&colour); |
---|
| 63 | cpgsci(DUCHAMP_BLANK_EDGE_COLOUR); |
---|
[129] | 64 | |
---|
[378] | 65 | float xoff,x2,yoff,y2; |
---|
| 66 | cpgqwin(&xoff,&x2,&yoff,&y2); |
---|
[142] | 67 | |
---|
[1393] | 68 | size_t size=xdim*ydim; |
---|
| 69 | std::vector<bool> blank = par.makeBlankMask(dataArray,size); |
---|
[378] | 70 | |
---|
[884] | 71 | for(size_t x=0; x<xdim; x++){// for each column... |
---|
| 72 | for(size_t y=1;y<ydim;y++){ |
---|
| 73 | size_t current = y*xdim + x; |
---|
| 74 | size_t previous = (y-1)*xdim + x; |
---|
[378] | 75 | if( (blank[current]&&!blank[previous]) || |
---|
| 76 | (!blank[current]&&blank[previous]) ){ |
---|
| 77 | cpgmove(x-0.5, y-0.5); |
---|
| 78 | cpgdraw(x+0.5, y-0.5); |
---|
| 79 | } |
---|
[129] | 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|
[884] | 83 | for(size_t y=0; y<ydim; y++){// for each row... |
---|
| 84 | for(size_t x=1;x<xdim;x++){ |
---|
| 85 | size_t current = y*xdim + x; |
---|
| 86 | size_t previous = y*xdim + x-1; |
---|
[378] | 87 | if( (blank[current]&&!blank[previous]) || |
---|
| 88 | (!blank[current]&&blank[previous]) ){ |
---|
| 89 | cpgmove(x-0.5, y-0.5); |
---|
| 90 | cpgdraw(x-0.5, y+0.5); |
---|
| 91 | } |
---|
[129] | 92 | } |
---|
| 93 | } |
---|
[142] | 94 | |
---|
[316] | 95 | |
---|
[378] | 96 | cpgsci(colour); |
---|
[316] | 97 | |
---|
[378] | 98 | } |
---|
| 99 | |
---|
| 100 | |
---|
[129] | 101 | } |
---|
| 102 | |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | } |
---|