[1072] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // AnnotationWriter.hh: Base class for writing results to annotation files, |
---|
| 3 | // annotating images in some FITS viewer. |
---|
| 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 | // ----------------------------------------------------------------------- |
---|
| 29 | #ifndef DUCHAMP_ANNOTATION_WRITER_H_ |
---|
| 30 | #define DUCHAMP_ANNOTATION_WRITER_H_ |
---|
| 31 | |
---|
| 32 | #include <duchamp/Outputs/CatalogueWriter.hh> |
---|
| 33 | #include <duchamp/Outputs/FileCatalogueWriter.hh> |
---|
| 34 | #include <duchamp/Detection/detection.hh> |
---|
| 35 | #include <ios> |
---|
| 36 | #include <iostream> |
---|
| 37 | #include <fstream> |
---|
| 38 | |
---|
| 39 | namespace duchamp { |
---|
| 40 | |
---|
| 41 | /// @brief Base class for writing FITS annotation files |
---|
| 42 | /// @details This class supports the creation of annotation files |
---|
| 43 | /// that can be used to supplement the viewing of FITS files in |
---|
| 44 | /// external viewers. Examples include kvis, ds9, casaviewer. The |
---|
| 45 | /// class will support the I/O, writing of different types of |
---|
| 46 | /// annotations (text, lines, circles, ellipses) and other basic |
---|
| 47 | /// functionality. Classes to write to specific types of annotation |
---|
| 48 | /// files should derive from this and implement their own header and |
---|
| 49 | /// primitive methods. |
---|
| 50 | |
---|
| 51 | class AnnotationWriter : public FileCatalogueWriter |
---|
| 52 | { |
---|
| 53 | public: |
---|
[1075] | 54 | /// @brief Default constructor |
---|
[1072] | 55 | AnnotationWriter(); |
---|
[1075] | 56 | /// @brief Constructor with given filename |
---|
[1072] | 57 | AnnotationWriter(std::string name); |
---|
[1075] | 58 | /// @brief Copy constructor |
---|
[1072] | 59 | AnnotationWriter(const AnnotationWriter& other); |
---|
[1075] | 60 | /// @brief Copy operator |
---|
[1072] | 61 | AnnotationWriter& operator= (const AnnotationWriter& other); |
---|
[1075] | 62 | /// @brief Default destructor |
---|
[1072] | 63 | virtual ~AnnotationWriter(){}; |
---|
| 64 | |
---|
[1075] | 65 | /// @brief Define how comments are represented - this string will be placed at the start of a comment line |
---|
[1072] | 66 | void setCommentString(std::string s){itsComment = s;}; |
---|
[1076] | 67 | /// @brief Set the colour string |
---|
| 68 | void setColourString(std::string s){itsColour = s;}; |
---|
[1072] | 69 | |
---|
[1075] | 70 | /// @brief Write header text describing what the file is for |
---|
[1072] | 71 | virtual void writeHeader(); |
---|
[1075] | 72 | /// @brief Write a summary of the input parameters |
---|
[1072] | 73 | virtual void writeParameters(); |
---|
[1075] | 74 | /// @brief Write a summary of the statistics used for detection |
---|
[1072] | 75 | virtual void writeStats(); |
---|
[1075] | 76 | /// @brief Write the global properties for the file (colour, WCS info, ...) |
---|
[1072] | 77 | virtual void writeTableHeader()=0; |
---|
[1075] | 78 | /// @brief Write information describing a detected object |
---|
[1072] | 79 | virtual void writeEntry(Detection *object); |
---|
| 80 | |
---|
[1228] | 81 | /// @brief Write a comment line, starting with the approriate character |
---|
| 82 | virtual void writeCommentString(std::string line); |
---|
| 83 | |
---|
[1075] | 84 | /// @brief Write any information to go at the end of the file |
---|
[1072] | 85 | virtual void writeFooter(){}; |
---|
| 86 | |
---|
[1075] | 87 | /// @brief Annotate with a text string |
---|
[1074] | 88 | virtual void text(double x, double y, std::string text)=0; |
---|
[1075] | 89 | /// @brief Annotate with a single line |
---|
[1074] | 90 | virtual void line(double x1, double x2, double y1, double y2)=0; |
---|
[1075] | 91 | /// @brief Annotate with a circle |
---|
[1074] | 92 | virtual void circle(double x, double y, double r)=0; |
---|
[1126] | 93 | /// @brief Annotate with a box |
---|
| 94 | virtual void box(double x1, double x2, double y1, double y2, std::string label="")=0; |
---|
[1075] | 95 | /// @brief Annotate with an ellipse |
---|
[1074] | 96 | virtual void ellipse(double x, double y, double r1, double r2, double angle)=0; |
---|
[1076] | 97 | /// @brief Annotate with a series of lines connecting points |
---|
| 98 | virtual void joinTheDots(std::vector<double> x, std::vector<double> y)=0; |
---|
[1072] | 99 | |
---|
| 100 | protected: |
---|
| 101 | std::string itsComment; ///< How comments are denoted in the annotation file (may be just a single char, eg. '#', but make it flexible) |
---|
[1076] | 102 | std::string itsColour; ///< What colour to make the annotations - set at the start of the file and applies to all annotations |
---|
[1072] | 103 | }; |
---|
| 104 | |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | #endif |
---|