casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ds9writer.h
Go to the documentation of this file.
00001 //# ds9writer.h: class used for writing ds9 region files
00002 //# Copyright (C) 2012
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: $
00027 
00028 #ifndef DISPLAY_DS9_DS9WRITER_H_
00029 #define DISPLAY_DS9_DS9WRITER_H_
00030 #include <stdio.h>
00031 
00032 namespace casa {
00033 
00034     class WorldCanvas;
00035 
00036     namespace viewer {
00037 
00038         class ds9writer {
00039             public:
00040                 ds9writer( const char *output_path, const char *coord_sys );
00041                 virtual ~ds9writer( );
00042                 void setCsysSource(const char *);
00043                 bool open( );
00044                 bool rectangle( WorldCanvas *, const std::vector<std::pair<double,double> > &pts );
00045                 bool ellipse( WorldCanvas *, const std::vector<std::pair<double,double> > &pts );
00046                 bool polygon( WorldCanvas *, const std::vector<std::pair<double,double> > &pts );
00047                 bool polyline( WorldCanvas *, const std::vector<std::pair<double,double> > &pts );
00048                 bool point( WorldCanvas *, const std::vector<std::pair<double,double> > &pts );
00049             private:
00050                 typedef std::map<std::string,std::string> str_map_type;
00051                 str_map_type defaults;
00052 
00053                 struct cs {
00054                     typedef void (*from_linear_2_type)(WorldCanvas*wc,double,double,double&,double&);
00055                     typedef void (*from_linear_4_type)(WorldCanvas*wc,double,double,double,double,double&,double&,double&,double&);
00056                     cs( const char *ds9_type, MDirection::Types t,
00057                         from_linear_2_type func2, from_linear_4_type func4 ) : ds9(ds9_type), type(t), cvt2(func2), cvt4(func4) { }
00058                     ~cs( ) { }
00059                     const std::string ds9;
00060                     const MDirection::Types type;
00061                     from_linear_2_type cvt2;
00062                     from_linear_4_type cvt4;
00063                 };
00064                 typedef std::map<std::string,cs> coord_map_type;
00065                 coord_map_type coord_systems;
00066                 char *path;
00067                 char *csys;
00068                 char *csys_file_path;
00069                 bool opened;
00070                 FILE *fptr;
00071         };
00072     }
00073 }
00074 
00075 #endif