[1072] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // KarmaAnnotationWriter.hh: Class for writing results to karma annotation files. |
---|
| 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 <duchamp/Outputs/KarmaAnnotationWriter.hh> |
---|
| 29 | #include <duchamp/Outputs/AnnotationWriter.hh> |
---|
| 30 | #include <duchamp/Outputs/CatalogueWriter.hh> |
---|
| 31 | #include <duchamp/Outputs/FileCatalogueWriter.hh> |
---|
| 32 | #include <duchamp/Detection/detection.hh> |
---|
| 33 | #include <ios> |
---|
| 34 | #include <iostream> |
---|
| 35 | #include <fstream> |
---|
[1074] | 36 | #include <iomanip> |
---|
[1072] | 37 | #include <string> |
---|
| 38 | |
---|
| 39 | namespace duchamp { |
---|
| 40 | |
---|
| 41 | KarmaAnnotationWriter::KarmaAnnotationWriter(): |
---|
| 42 | AnnotationWriter() |
---|
| 43 | { |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | KarmaAnnotationWriter::KarmaAnnotationWriter(std::string name): |
---|
| 47 | AnnotationWriter(name) |
---|
| 48 | { |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | KarmaAnnotationWriter::KarmaAnnotationWriter(const KarmaAnnotationWriter& other) |
---|
| 52 | { |
---|
| 53 | this->operator=(other); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | KarmaAnnotationWriter& KarmaAnnotationWriter::operator= (const KarmaAnnotationWriter& other) |
---|
| 57 | { |
---|
| 58 | if(this==&other) return *this; |
---|
| 59 | ((AnnotationWriter &) *this) = other; |
---|
| 60 | return *this; |
---|
| 61 | } |
---|
| 62 | void KarmaAnnotationWriter::writeTableHeader() |
---|
| 63 | { |
---|
| 64 | if(this->itsOpenFlag){ |
---|
[1076] | 65 | this->itsFileStream << "COLOR " << this->itsColour<<"\n"; |
---|
[1072] | 66 | if(this->itsHead->isWCS()) this->itsFileStream << "COORD W\n"; |
---|
| 67 | else this->itsFileStream << "COORD P\n"; |
---|
[1074] | 68 | this->itsFileStream << std::setprecision(6); |
---|
| 69 | this->itsFileStream.setf(std::ios::fixed); |
---|
[1072] | 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
[1074] | 73 | void KarmaAnnotationWriter::text(double x, double y, std::string text) |
---|
[1072] | 74 | { |
---|
| 75 | if(this->itsOpenFlag){ |
---|
| 76 | this->itsFileStream << "TEXT " << x << " " << y << " " << text<<"\n"; |
---|
| 77 | } |
---|
| 78 | } |
---|
[1074] | 79 | void KarmaAnnotationWriter::line(double x1, double x2, double y1, double y2) |
---|
[1072] | 80 | { |
---|
| 81 | if(this->itsOpenFlag){ |
---|
| 82 | this->itsFileStream << "LINE " << x1 << " " << y1 << " " << x2 << " " << y2 << "\n"; |
---|
| 83 | } |
---|
| 84 | } |
---|
[1074] | 85 | void KarmaAnnotationWriter::circle(double x, double y, double r) |
---|
[1072] | 86 | { |
---|
| 87 | if(this->itsOpenFlag){ |
---|
| 88 | this->itsFileStream << "CIRCLE " << x << " " << y << " " << r << "\n"; |
---|
| 89 | } |
---|
| 90 | } |
---|
[1074] | 91 | void KarmaAnnotationWriter::ellipse(double x, double y, double r1, double r2, double angle) |
---|
[1072] | 92 | { |
---|
| 93 | if(this->itsOpenFlag){ |
---|
| 94 | this->itsFileStream << "ELLIPSE " << x << " " << y << " " << r1 << " " << r2 << " " << angle << "\n"; |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | |
---|
[1076] | 98 | void KarmaAnnotationWriter::joinTheDots(std::vector<double> x, std::vector<double> y) |
---|
| 99 | { |
---|
| 100 | if(this->itsOpenFlag){ |
---|
| 101 | if(x.size()==y.size()){ |
---|
| 102 | this->itsFileStream << "CLINES"; |
---|
| 103 | for(size_t i=0;i<x.size();i++) this->itsFileStream <<" " << x[i] << " " << y[i]; |
---|
| 104 | this->itsFileStream << "\n"; |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | } |
---|
| 108 | |
---|
[1072] | 109 | |
---|
| 110 | } |
---|