source: tags/release-1.0.5/src/Utils/drawBlankEdges.cc @ 1455

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

Large range of changes -- related to image cutouts and spectral units mostly.

duchamp.hh -- changed name of spectral type, and introduced one for frequency.
Cubes/getImage.cc -- changed the way the spectral type and spectral units are

looked at. Now is able to use frequency units (defaults
to MHz) when there isn't a good velocity transformation
possible (ie. if there is no restfreq defined).

Cubes/drawMomentCutout.cc -- Range of changes here:

  • improved the way unwanted pixels (those BLANK and outside image coundaries) are dealt with in the image array in drawMomentCutout
  • removed the way the blank pixel information was changed. Now behaves in a consistent way whether or not there are blank pixels
  • improved call to plotBlankEdges()
  • added call to drawFieldEdge() -- a new function that draws a yellow line around the boundary of the pixels of the image.
  • improved the tick mark that shows the angular scale of the cutout. Now adaptable to any pixel scale.
  • added calls to cpgtest() to all functions

Also these files were changed in relation to these edits:
Utils/drawBlankEdges.cc -- improved execution, with "blank" array.
Cubes/cubes.cc -- added call to Param::drawBlankEdge in Cube::plotBlankEdges()
Cubes/outputSpectra.cc -- moved spectra away from left and right axes.
param.cc -- added necessary calls for the new parameter. Other minor changes

to formatting. Added a missed call to stringize.

mainDuchamp.cc -- added #include <param.hh>
param.hh -- Added a new parameter: blankEdge
Cubes/cubes.hh -- improved appearance of comments
Cubes/plots.hh -- improved appearance of comments
InputComplete? -- added new parameter.
docs/Guide.tex -- added text about blank edge plotting.
All six images were changed as well.

CHANGES -- some of these changes -- not up to date yet!

File size: 1.7 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    if(!cpgtest())
24      duchampError("drawBlankEdges","There is no PGPlot device open!\n");
25    else{
26
27      float xoff,x2,yoff,y2;
28      cpgqwin(&xoff,&x2,&yoff,&y2);
29
30      bool *blank = new bool[xdim*ydim];
31      for(int i=0;i<xdim*ydim;i++) blank[i] = par.isBlank(dataArray[i]);
32
33      for(int x=0; x<xdim; x++){// for each column...
34        for(int y=1;y<ydim;y++){
35          int current = y*xdim + x;
36          int previous = (y-1)*xdim + x;
37          if( (blank[current]&&!blank[previous]) ||
38              (!blank[current]&&blank[previous])   ){
39            cpgmove(x-0.5, y-0.5);
40            cpgdraw(x+0.5, y-0.5);
41          }
42        }
43      }
44     
45      for(int y=0; y<ydim; y++){// for each row...
46        for(int x=1;x<xdim;x++){
47          int current = y*xdim + x;
48          int previous = y*xdim + x-1;
49          if( (blank[current]&&!blank[previous]) ||
50              (!blank[current]&&blank[previous])   ){
51            cpgmove(x-0.5, y-0.5);
52            cpgdraw(x-0.5, y+0.5);
53          }
54        }
55      }
56
57      delete [] blank;
58     
59    }
60
61 
62  }
63
64}
Note: See TracBrowser for help on using the repository browser.