source: trunk/src/Utils/drawBlankEdges.cc @ 129

Last change on this file since 129 was 129, checked in by Matthew Whiting, 18 years ago

A couple of additions and some minor changes:

  • New function to draw lines separating the BLANK and non-BLANK

pixels on a 2-D image -- in Utils/drawBlankEdges.cc. Also have a
front-end to it in the Cube:: class (in Cubes/cubes.cc)

  • Consolidated all the pgplot-related .c code in Utils into one file:

Utils/pgplot_related.c. Added new function, cpgtest(), to check if
there is a PGPlot device currently open.

  • Utilised this function in the plotting.cc functions.
  • Changed the calls to Detection::getIntegFlux and Detection::calcWCSparams

so that the FitsHeader? object is passed as a reference.

  • Other minor typos.
File size: 2.0 KB
Line 
1#include <cpgplot.h>
2#include <duchamp.hh>
3#include <param.hh>
4#include <Utils/utils.hh>
5#include <string>
6
7void drawBlankEdges(float *dataArray, int xdim, int ydim, Param &par)
8{
9  /**
10   *  drawBlankEdges(float *dataArray, int xdim, int ydim, Param &par)
11   *
12   *   A subroutine that is designed to draw (in tasteful purple) the
13   *    edges of the blank region of the cube on a moment/detection map.
14   *   Uses the same procedure as used in the reconstruction subroutines.
15   *   Needs a pgplot device open!
16   *   INPUTS: dataArray  -- the array of pixel values
17   *           xdim, ydim -- the sizes of the array in the x- and y- directions
18   *           par        -- how we know what a BLANK pixel value is.
19   */
20
21  if(par.getFlagBlankPix()){
22
23//     char *status = new char[10];
24//     int statusLength = sizeof(status);
25//     cpgqinf("STATE",status,&statusLength);
26//     string stat = status;
27//     delete [] status;
28//     if( stat == "CLOSED" )
29//       duchampError("drawBlankEdges","There is no PGPlot device open!\n");
30//     else{
31
32    if(!cpgtest())
33      duchampError("drawBlankEdges","There is no PGPlot device open!\n");
34    else{
35
36      float xoff,x2,yoff,y2;
37      cpgqwin(&xoff,&x2,&yoff,&y2);
38
39      for(int x=0; x<xdim; x++){// for each column...
40        for(int y=1;y<ydim;y++){
41          int current = y*xdim + x;
42          int previous = (y-1)*xdim + x;
43          if(((par.isBlank(dataArray[current]))&&!par.isBlank(dataArray[previous])) ||
44             (!par.isBlank(dataArray[current])&&par.isBlank(dataArray[previous]))){
45            cpgmove(x+xoff,   y+yoff);
46            cpgdraw(x+xoff+1, y+yoff);
47          }
48        }
49      }
50     
51      for(int y=0; y<ydim; y++){// for each row...
52        for(int x=1;x<xdim;x++){
53          int current = y*xdim + x;
54          int previous = y*xdim + x-1;
55          if(((par.isBlank(dataArray[current]))&&!par.isBlank(dataArray[previous])) ||
56             (!par.isBlank(dataArray[current])&&par.isBlank(dataArray[previous]))){
57            cpgmove(x+xoff, y+yoff);
58            cpgdraw(x+xoff, y+yoff+1);
59          }
60        }
61      }
62     
63    }
64
65 
66  }
67
68}
Note: See TracBrowser for help on using the repository browser.