[1302] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // detection.cc : Member functions for the Detection class. |
---|
| 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 <vector> |
---|
| 29 | #include <cpgplot.h> |
---|
| 30 | #include <duchamp/duchamp.hh> |
---|
| 31 | #include <duchamp/Detection/detection.hh> |
---|
| 32 | #include <duchamp/PixelMap/Voxel.hh> |
---|
| 33 | |
---|
| 34 | using namespace PixelInfo; |
---|
| 35 | |
---|
| 36 | namespace duchamp |
---|
| 37 | { |
---|
| 38 | void Detection::drawBorders(int xoffset, int yoffset) |
---|
| 39 | { |
---|
| 40 | /// @details |
---|
| 41 | /// For a given object, draw borders around the spatial extent of the object. |
---|
| 42 | /// \param xoffset The offset from 0 of the x-axis of the plotting window |
---|
| 43 | /// \param yoffset The offset from 0 of the y-axis of the plotting window |
---|
| 44 | |
---|
| 45 | if(!cpgtest()){ |
---|
| 46 | DUCHAMPERROR("Draw Borders","There is no PGPlot device open."); |
---|
| 47 | } |
---|
| 48 | else{ |
---|
| 49 | |
---|
| 50 | float x1,x2,y1,y2; |
---|
| 51 | cpgqwin(&x1,&x2,&y1,&y2); |
---|
| 52 | int xsize = int(x2 - x1) + 1; |
---|
| 53 | int ysize = int(y2 - y1) + 1; |
---|
| 54 | |
---|
| 55 | cpgswin(0,xsize-1,0,ysize-1); |
---|
| 56 | |
---|
| 57 | std::vector<std::vector<Voxel> > vertexSets = this->getVertexSet(); |
---|
| 58 | |
---|
| 59 | for(size_t n=0;n<vertexSets.size();n++){ |
---|
| 60 | // for each set of vertices |
---|
| 61 | |
---|
| 62 | cpgmove(vertexSets[n][0].getX()-xoffset,vertexSets[n][0].getY()-yoffset); |
---|
| 63 | for(size_t i=1;i<vertexSets[n].size();i++) |
---|
| 64 | cpgdraw(vertexSets[n][i].getX()-xoffset,vertexSets[n][i].getY()-yoffset); |
---|
| 65 | |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | cpgswin(x1,x2,y1,y2); |
---|
| 69 | |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | } |
---|