source: trunk/src/Outputs/AnnotationWriter.hh @ 1126

Last change on this file since 1126 was 1126, checked in by MatthewWhiting, 12 years ago

Enabling the output of CASA region files. These include a box (acting as a region), plus annotation lines and text in the same manner as the other annotation files. Annotations are currently not supported by casaviewer (even the new v4.0.0!!!), but the region boxes will get picked up.

File size: 4.5 KB
Line 
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
39namespace 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:
54    /// @brief Default constructor
55    AnnotationWriter();
56    /// @brief Constructor with given filename
57    AnnotationWriter(std::string name);
58    /// @brief Copy constructor
59    AnnotationWriter(const AnnotationWriter& other);
60    /// @brief Copy operator
61    AnnotationWriter& operator= (const AnnotationWriter& other);
62    /// @brief Default destructor
63    virtual ~AnnotationWriter(){};
64
65    /// @brief Define how comments are represented - this string will be placed at the start of a comment line
66    void setCommentString(std::string s){itsComment = s;};
67    /// @brief Set the colour string
68    void setColourString(std::string s){itsColour = s;};
69
70    /// @brief Write header text describing what the file is for
71    virtual void writeHeader();
72    /// @brief Write a summary of the input parameters
73    virtual void writeParameters();
74    /// @brief Write a summary of the statistics used for detection
75    virtual void writeStats();
76    /// @brief Write the global properties for the file (colour, WCS info, ...)
77    virtual void writeTableHeader()=0;
78    /// @brief Write information describing a detected object
79    virtual void writeEntry(Detection *object);
80
81    /// @brief Write any information to go at the end of the file
82    virtual void writeFooter(){};
83
84    /// @brief Annotate with a text string
85    virtual void text(double x, double y, std::string text)=0;
86    /// @brief Annotate with a single line
87    virtual void line(double x1, double x2, double y1, double y2)=0;
88    /// @brief Annotate with a circle
89    virtual void circle(double x, double y, double r)=0;
90    /// @brief Annotate with a box
91    virtual void box(double x1, double x2, double y1, double y2, std::string label="")=0;
92    /// @brief Annotate with an ellipse
93    virtual void ellipse(double x, double y, double r1, double r2, double angle)=0;
94    /// @brief Annotate with a series of lines connecting points
95    virtual void joinTheDots(std::vector<double> x, std::vector<double> y)=0;
96
97  protected:
98    std::string itsComment; ///< How comments are denoted in the annotation file (may be just a single char, eg. '#', but make it flexible)
99    std::string itsColour; ///< What colour to make the annotations - set at the start of the file and applies to all annotations
100  };
101
102}
103
104#endif
Note: See TracBrowser for help on using the repository browser.