casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ds9context.h
Go to the documentation of this file.
00001 #ifndef DISPLAY_DS9_DS9CONTEXT_H_
00002 #define DISPLAY_DS9_DS9CONTEXT_H_
00003 #include <string>
00004 #include <vector>
00005 #include <list>
00006 #include <measures/Measures/MDirection.h>
00007 #include <display/Display/WorldCanvas.h>
00008 
00009 namespace casa {
00010     namespace viewer {
00011 
00012         extern double degToRad(double);
00013         extern double radToDeg(double);
00014       
00015         double parseSEXStr(const char* d);
00016         extern double parseHMSStr(const char* str);
00017         extern double parseDMSStr(const char* str);
00018 
00019         std::vector<double> coordtovec( double * );
00020         std::vector<double> doubletovec( double x=1, double y=1, double z=1 );
00021 
00022         typedef std::vector<double> Vertex;
00023         typedef std::vector<double> Vector;
00024         typedef std::string Tag;
00025 
00026         enum CoordSystem { IMAGE, PHYSICAL, AMPLIFIER, DETECTOR, WCS,
00027                            WCSA, WCSB, WCSC, WCSD, WCSE, WCSF, WCSG, WCSH, WCSI,
00028                            WCSJ, WCSK, WCSL, WCSM, WCSN, WCSO, WCSP, WCSQ, WCSR,
00029                            WCSS, WCST, WCSU, WCSV, WCSW, WCSX, WCSY, WCSZ, WCS0 };
00030 
00031         enum SkyFrame {FK4, FK5, ICRS, GALACTIC, ECLIPTIC, NATIVEWCS};
00032         enum SkyFormat {DEGREES, SEXAGESIMAL, ARCMIN, ARCSEC};
00033 
00034         inline MDirection::Types todirection( SkyFrame frame ) {
00035             switch ( frame ) {
00036                 case FK4: return MDirection::B1950;
00037                 case FK5: return MDirection::J2000;
00038                 case GALACTIC: return MDirection::GALACTIC;
00039                 case ECLIPTIC: return MDirection::ECLIPTIC;
00040                 default: return MDirection::GALACTIC;
00041             }
00042         }
00043 
00044         inline const char *tostr(SkyFrame sf) {
00045             return sf == FK4 ? "FK4" :
00046                    sf == FK5 ? "FK5" :
00047                    sf == ICRS ? "ICRS" :
00048                    sf == ECLIPTIC ? "ECLIPTIC" : "NATIVEWCS";
00049         }
00050 
00051         inline const char * tostr(CoordSystem cs) {
00052             return cs == IMAGE ? "IMAGE" :
00053                    cs == PHYSICAL ? "PHYSICAL" :
00054                    cs == AMPLIFIER ? "AMPLIFIER" :
00055                    cs == DETECTOR ? "DETECTOR" :
00056                    cs == WCS ? "WCS" : cs == WCSA ? "WCSA" :
00057                    cs == WCSB ? "WCSB" : cs == WCSC ? "WCSC" :
00058                    cs == WCSD ? "WCSD" : cs == WCSE ? "WCSE" :
00059                    cs == WCSF ? "WCSF" : cs == WCSG ? "WCSG" :
00060                    cs == WCSH ? "WCSH" : cs == WCSI ? "WCSI" :
00061                    cs == WCSJ ? "WCSJ" : cs == WCSK ? "WCSK" :
00062                    cs == WCSL ? "WCSL" : cs == WCSM ? "WCSM" :
00063                    cs == WCSN ? "WCSN" : cs == WCSO ? "WCSO" :
00064                    cs == WCSP ? "WCSP" : cs == WCSQ ? "WCSQ" :
00065                    cs == WCSR ? "WCSR" : cs == WCSS ? "WCSS" :
00066                    cs == WCST ? "WCST" : cs == WCSU ? "WCSU" :
00067                    cs == WCSV ? "WCSV" : cs == WCSW ? "WCSW" :
00068                    cs == WCSX ? "WCSX" : cs == WCSY ? "WCSY" :
00069                    cs == WCSZ ? "WCSZ" : "WCS0";
00070         }
00071 
00072         inline const char *tostr( SkyFormat f ) {
00073             return f == DEGREES ? "DEGREES" :
00074                    f == SEXAGESIMAL ? "SEXAGESIMAL" :
00075                    f == ARCMIN ? "ARCMIN" : "ARCSEC";
00076         }
00077 
00078         class ds9context {
00079             public:
00080                 ds9context( WorldCanvas *wc ) : wc_(wc) { }
00081 
00082                 double mapAngleFromRef(double /*angle*/, CoordSystem /*sys*/, SkyFrame /*sky*/) { return 0; }
00083                 double mapAngleToRef(double /*angle*/, CoordSystem /*sys*/, SkyFrame /*sky*/) { return 0; }
00084                 // from Base::findFits(globalTile)->mapLenToRef(...)
00085                 double mapLenToRef(double d, CoordSystem sys, SkyFormat format=DEGREES);
00086                 // from Base::findFits(globalTile)->mapLenToRef(...)
00087                 Vector mapLenToRef(const Vector &, CoordSystem sys, SkyFormat format=DEGREES);
00088                 // from Base::findFits(globalTile)->mapToRef(...)
00089                 Vector mapToRef(const Vector& v, CoordSystem sys, SkyFrame format=FK5);
00090 
00091                 void resetCompositeMarker() { }
00092 
00093                 void createContourPolygonCmd( const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00094                                               const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00095                                               const std::list<Tag>& /*tag*/ ) { }
00096                 void createCompassCmd( const Vector& /*center*/, double /*r*/, const char* /*north*/, const char* /*east*/,
00097                                        int /*na*/, int /*ea*/, CoordSystem /*sys*/, SkyFrame /*sky*/, const char* /*color*/, int* /*dash*/,
00098                                        int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00099                                        const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00100                 void createCompositeCmd( const Vector& /*center*/, double /*angle*/, int /*global*/, const char* /*color*/, int* /*dash*/,
00101                                          int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00102                                          const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00103                 void createVectCmd( const Vector& /*center*/, const Vector& /*p2*/, int /*arrow*/,const char* /*color*/, int* /*dash*/,
00104                                     int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00105                                     const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00106                 void createVectCmd( const Vector& /*center*/, double /*mag*/, double /*ang*/, int /*arrow*/, const char* /*color*/, int* /*dash*/,
00107                                     int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00108                                     const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00109 
00110                 void createProjectionCmd( const Vector& /*center*/, const Vector& /*p2*/, double /*w*/, const char* /*mvcb*/,
00111                                           const char* /*delcb*/, const char* /*color*/, int* /*dash*/, int /*width*/,
00112                                           const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00113                                           const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00114                 void createRulerCmd( const Vector& /*center*/, const Vector& /*p2*/, CoordSystem /*sys*/, SkyFrame /*sky*/,
00115                                      CoordSystem /*distsys*/, SkyFormat /*distformat*/, const char* /*color*/, int* /*dash*/,
00116                                      int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00117                                      const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00118                 void createCircle3dCmd( const Vector& /*center*/, double /*radius*/, const char* /*mvcb*/,
00119                                         const char* /*delcb*/, const char* /*color*/, int* /*dash*/, int /*width*/,
00120                                         const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00121                                         const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00122                 void createAnnulusCmd( const Vector& /*center*/, double /*start*/, double /*stop*/, int /*num*/,
00123                                        const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00124                                        const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00125                                        const std::list<Tag>& /*tag*/ ) { }
00126                 void createAnnulusCmd( const Vector& /*center*/, int /*num*/, double* /*radii*/, const char* /*color*/, int* /*dash*/,
00127                                        int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00128                                        const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00129                 void createCpandaCmd( const Vector& /*center*/, double /*ang1*/, double /*ang2*/, int /*an*/,
00130                                       double /*rad1*/, double /*rad2*/, int /*rn*/, const char* /*color*/, int* /*dash*/,
00131                                       int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00132                                       const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00133                 void createCpandaCmd( const Vector& /*center*/, int /*an*/, double* /*a*/, int /*rn*/, double* /*r*/,
00134                                       const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00135                                       const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00136                                       const std::list<Tag>& /*tag*/ ) { }
00137                 void createEllipseAnnulusCmd( const Vector& /*center*/, const Vector& /*inner*/,
00138                                               const Vector& /*outer*/, int /*num*/, double /*angle*/,
00139                                               const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00140                                               const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00141                                               const std::list<Tag>& /*tag*/ ) { }
00142                 void createEllipseAnnulusCmd( const Vector& /*center*/, int /*num*/, Vector* /*radii*/, double /*angle*/,
00143                                               const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00144                                               const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00145                                               const std::list<Tag>& /*tag*/ ) { }
00146                 void createEpandaCmd( const Vector& /*center*/, double /*ang1*/, double /*ang2*/, int /*an*/,
00147                                       const Vector& /*rad1*/, const Vector& /*rad2*/, int /*rn*/, double /*angle*/,
00148                                       const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00149                                       const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00150                                       const std::list<Tag>& /*tag*/ ) { }
00151                 void createEpandaCmd( const Vector& /*center*/, int /*an*/, double* /*a*/, int /*rn*/, Vector* /*r*/,
00152                                       double /*angle*/, const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00153                                       const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00154                                       const std::list<Tag>& /*tag*/ ) { }
00155                 void createLineCmd( const Vector& /*center*/, const Vector& /*p2*/, int /*arrow1*/, int /*arrow2*/,
00156                                     const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00157                                     const char* /*text*/, unsigned short /*prop*/,
00158                                     const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00159                 void createBoxAnnulusCmd( const Vector& /*center*/, const Vector& /*inner*/, const Vector& /*outer*/,
00160                                           int /*num*/, double /*angle*/, const char* /*color*/, int* /*dash*/,
00161                                           int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00162                                           const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00163                 void createBoxAnnulusCmd( const Vector& /*center*/, int /*num*/, Vector* /*size*/, double /*angle*/,
00164                                           const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00165                                           const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00166                                           const std::list<Tag>& /*tag*/ ) { }
00167 
00168                 void createBpandaCmd( const Vector& /*center*/, double /*ang1*/, double /*ang2*/, int /*an*/,
00169                                       const Vector& /*rad1*/, const Vector& /*rad2*/, int /*rn*/, double /*angle*/,
00170                                       const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00171                                       const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00172                                       const std::list<Tag>& /*tag*/ ) { }
00173                 void createBpandaCmd( const Vector& /*center*/, int /*an*/, double* /*a*/, int /*rn*/, Vector* /*r*/,
00174                                       double /*angle*/,const char* /*color*/, int* /*dash*/, int /*width*/,
00175                                       const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00176                                       const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00177 
00178                 void createTextCmd( const Vector& /*center*/, double /*angle*/, int /*rotate*/, const char* /*color*/, int* /*dash*/,
00179                                     int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00180                                     const char* /*comment*/, const std::list<Tag>& /*tag*/ ) { }
00181 
00182 
00183                 // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
00184                 void createBoxCmd( const Vector& /*center*/, const Vector& /*size*/, double /*angle*/,
00185                                    const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00186                                    const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00187                                    const std::list<Tag>& /*tag*/ );
00188                 void createEllipseCmd( const Vector& /*center*/, const Vector& /*radius*/, double /*angle*/,
00189                                        const char* /*color*/, int* /*dash*/, int /*width*/, const char* /*font*/,
00190                                        const char* /*text*/, unsigned short /*prop*/, const char* /*comment*/,
00191                                        const std::list<Tag>& /*tag*/ );
00192                 void createCircleCmd( const Vector& /*center*/, double /*radius*/, const char* /*color*/, int* /*dash*/,
00193                                       int /*width*/, const char* /*font*/, const char* /*text*/, unsigned short /*prop*/,
00194                                       const char* /*comment*/, const std::list<Tag>& /*tag*/ );
00195                 void createPolygonCmd( const Vector& center, const Vector& bb, const char* color, int* dash, 
00196                                        int width, const char* font, const char* text, unsigned short prop,
00197                                        const char* comment, const std::list<Tag>& tag );
00198                 void createPolygonCmd( const std::list<Vertex>& list, const char* color, int* dash, 
00199                                        int width, const char* font, const char* text, unsigned short prop,
00200                                        const char* comment, const std::list<Tag>& tag );
00201 
00202                 void createCirclePointCmd( const Vector& center, int size, const char* color, int* dash, 
00203                                            int width, const char* font, const char* text, unsigned short prop,
00204                                            const char* comment, const std::list<Tag>& tag );
00205                 void createBoxPointCmd( const Vector& center, int size, const char* color, int* dash, 
00206                                         int width, const char* font, const char* text, unsigned short prop,
00207                                         const char* comment, const std::list<Tag>& tag );
00208                 void createDiamondPointCmd( const Vector& center, int size, const char* color, int* dash, 
00209                                             int width, const char* font, const char* text, unsigned short prop,
00210                                             const char* comment, const std::list<Tag>& tag );
00211                 void createCrossPointCmd( const Vector& center, int size, const char* color, int* dash, 
00212                                           int width, const char* font, const char* text, unsigned short prop,
00213                                           const char* comment, const std::list<Tag>& tag );
00214                 void createExPointCmd( const Vector& center, int size, const char* color, int* dash, 
00215                                        int width, const char* font, const char* text, unsigned short prop,
00216                                        const char* comment, const std::list<Tag>& tag );
00217                 void createArrowPointCmd( const Vector& center, int size, const char* color, int* dash, 
00218                                           int width, const char* font, const char* text, unsigned short prop,
00219                                           const char* comment, const std::list<Tag>& tag );
00220                 void createBoxCirclePointCmd( const Vector& center, int size, const char* color, int* dash, 
00221                                               int width, const char* font, const char* text, unsigned short prop,
00222                                               const char* comment, const std::list<Tag>& tag );
00223                 // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
00224 
00225 
00226                 void markerDeleteLastCmd() { }
00227 
00228             private:
00229                 WorldCanvas *wc_;
00230         };
00231     }
00232 }
00233 
00234 #endif