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 #include <display/QtViewer/RegionToolManager.qo.h>
00009
00010 namespace casa {
00011 namespace viewer {
00012
00013 extern double degToRad(double);
00014 extern double radToDeg(double);
00015
00016 double parseSEXStr(const char* d);
00017 extern double parseHMSStr(const char* str);
00018 extern double parseDMSStr(const char* str);
00019
00020 std::vector<double> coordtovec( double * );
00021 std::vector<double> doubletovec( double x=1, double y=1, double z=1 );
00022
00023 typedef std::vector<double> Vertex;
00024 typedef std::vector<double> Vector;
00025 typedef std::string Tag;
00026
00027 enum CoordSystem { IMAGE, PHYSICAL, AMPLIFIER, DETECTOR, WCS,
00028 WCSA, WCSB, WCSC, WCSD, WCSE, WCSF, WCSG, WCSH, WCSI,
00029 WCSJ, WCSK, WCSL, WCSM, WCSN, WCSO, WCSP, WCSQ, WCSR,
00030 WCSS, WCST, WCSU, WCSV, WCSW, WCSX, WCSY, WCSZ, WCS0
00031 };
00032
00033 enum SkyFrame {FK4, FK5, ICRS, GALACTIC, ECLIPTIC, NATIVEWCS};
00034 enum SkyFormat {DEGREES, SEXAGESIMAL, ARCMIN, ARCSEC};
00035
00036 inline MDirection::Types todirection( SkyFrame frame ) {
00037 switch ( frame ) {
00038 case FK4:
00039 return MDirection::B1950;
00040 case FK5:
00041 return MDirection::J2000;
00042 case GALACTIC:
00043 return MDirection::GALACTIC;
00044 case ECLIPTIC:
00045 return MDirection::ECLIPTIC;
00046 default:
00047 return MDirection::GALACTIC;
00048 }
00049 }
00050
00051 inline const char *tostr(SkyFrame sf) {
00052 return sf == FK4 ? "FK4" :
00053 sf == FK5 ? "FK5" :
00054 sf == ICRS ? "ICRS" :
00055 sf == ECLIPTIC ? "ECLIPTIC" : "NATIVEWCS";
00056 }
00057
00058 inline const char * tostr(CoordSystem cs) {
00059 return cs == IMAGE ? "IMAGE" :
00060 cs == PHYSICAL ? "PHYSICAL" :
00061 cs == AMPLIFIER ? "AMPLIFIER" :
00062 cs == DETECTOR ? "DETECTOR" :
00063 cs == WCS ? "WCS" : cs == WCSA ? "WCSA" :
00064 cs == WCSB ? "WCSB" : cs == WCSC ? "WCSC" :
00065 cs == WCSD ? "WCSD" : cs == WCSE ? "WCSE" :
00066 cs == WCSF ? "WCSF" : cs == WCSG ? "WCSG" :
00067 cs == WCSH ? "WCSH" : cs == WCSI ? "WCSI" :
00068 cs == WCSJ ? "WCSJ" : cs == WCSK ? "WCSK" :
00069 cs == WCSL ? "WCSL" : cs == WCSM ? "WCSM" :
00070 cs == WCSN ? "WCSN" : cs == WCSO ? "WCSO" :
00071 cs == WCSP ? "WCSP" : cs == WCSQ ? "WCSQ" :
00072 cs == WCSR ? "WCSR" : cs == WCSS ? "WCSS" :
00073 cs == WCST ? "WCST" : cs == WCSU ? "WCSU" :
00074 cs == WCSV ? "WCSV" : cs == WCSW ? "WCSW" :
00075 cs == WCSX ? "WCSX" : cs == WCSY ? "WCSY" :
00076 cs == WCSZ ? "WCSZ" : "WCS0";
00077 }
00078
00079 inline const char *tostr( SkyFormat f ) {
00080 return f == DEGREES ? "DEGREES" :
00081 f == SEXAGESIMAL ? "SEXAGESIMAL" :
00082 f == ARCMIN ? "ARCMIN" : "ARCSEC";
00083 }
00084
00085 class ds9context {
00086 public:
00087 ds9context( WorldCanvas *wc, RegionToolManager *mgr ) : wc_(wc), toolmgr(mgr) { }
00088
00089 SHARED_PTR<RegionTool> tool ( region::RegionTypes t )
00090 { return toolmgr->tool(t); }
00091
00092 double mapAngleFromRef(double , CoordSystem , SkyFrame ) {
00093 return 0;
00094 }
00095 double mapAngleToRef(double , CoordSystem , SkyFrame ) {
00096 return 0;
00097 }
00098
00099 double mapLenToRef(double d, CoordSystem sys, SkyFormat format=DEGREES);
00100
00101 Vector mapLenToRef(const Vector &, CoordSystem sys, SkyFormat format=DEGREES);
00102
00103 Vector mapToRef(const Vector& v, CoordSystem sys, SkyFrame format=FK5);
00104
00105 void resetCompositeMarker() { }
00106
00107 void createContourPolygonCmd( const char* , int* , int , const char* ,
00108 const char* , unsigned short , const char* ,
00109 const std::list<Tag>& ) { }
00110 void createCompassCmd( const Vector& , double , const char* , const char* ,
00111 int , int , CoordSystem , SkyFrame , const char* , int* ,
00112 int , const char* , const char* , unsigned short ,
00113 const char* , const std::list<Tag>& ) { }
00114 void createCompositeCmd( const Vector& , double , int , const char* , int* ,
00115 int , const char* , const char* , unsigned short ,
00116 const char* , const std::list<Tag>& ) { }
00117 void createVectCmd( const Vector& , const Vector& , int ,const char* , int* ,
00118 int , const char* , const char* , unsigned short ,
00119 const char* , const std::list<Tag>& ) { }
00120 void createVectCmd( const Vector& , double , double , int , const char* , int* ,
00121 int , const char* , const char* , unsigned short ,
00122 const char* , const std::list<Tag>& ) { }
00123
00124 void createProjectionCmd( const Vector& , const Vector& , double , const char* ,
00125 const char* , const char* , int* , int ,
00126 const char* , const char* , unsigned short ,
00127 const char* , const std::list<Tag>& ) { }
00128 void createRulerCmd( const Vector& , const Vector& , CoordSystem , SkyFrame ,
00129 CoordSystem , SkyFormat , const char* , int* ,
00130 int , const char* , const char* , unsigned short ,
00131 const char* , const std::list<Tag>& ) { }
00132 void createCircle3dCmd( const Vector& , double , const char* ,
00133 const char* , const char* , int* , int ,
00134 const char* , const char* , unsigned short ,
00135 const char* , const std::list<Tag>& ) { }
00136 void createAnnulusCmd( const Vector& , double , double , int ,
00137 const char* , int* , int , const char* ,
00138 const char* , unsigned short , const char* ,
00139 const std::list<Tag>& ) { }
00140 void createAnnulusCmd( const Vector& , int , double* , const char* , int* ,
00141 int , const char* , const char* , unsigned short ,
00142 const char* , const std::list<Tag>& ) { }
00143 void createCpandaCmd( const Vector& , double , double , int ,
00144 double , double , int , const char* , int* ,
00145 int , const char* , const char* , unsigned short ,
00146 const char* , const std::list<Tag>& ) { }
00147 void createCpandaCmd( const Vector& , int , double* , int , double* ,
00148 const char* , int* , int , const char* ,
00149 const char* , unsigned short , const char* ,
00150 const std::list<Tag>& ) { }
00151 void createEllipseAnnulusCmd( const Vector& , const Vector& ,
00152 const Vector& , int , double ,
00153 const char* , int* , int , const char* ,
00154 const char* , unsigned short , const char* ,
00155 const std::list<Tag>& ) { }
00156 void createEllipseAnnulusCmd( const Vector& , int , Vector* , double ,
00157 const char* , int* , int , const char* ,
00158 const char* , unsigned short , const char* ,
00159 const std::list<Tag>& ) { }
00160 void createEpandaCmd( const Vector& , double , double , int ,
00161 const Vector& , const Vector& , int , double ,
00162 const char* , int* , int , const char* ,
00163 const char* , unsigned short , const char* ,
00164 const std::list<Tag>& ) { }
00165 void createEpandaCmd( const Vector& , int , double* , int , Vector* ,
00166 double , const char* , int* , int , const char* ,
00167 const char* , unsigned short , const char* ,
00168 const std::list<Tag>& ) { }
00169 void createLineCmd( const Vector& , const Vector& , int , int ,
00170 const char* , int* , int , const char* ,
00171 const char* , unsigned short ,
00172 const char* , const std::list<Tag>& ) { }
00173 void createBoxAnnulusCmd( const Vector& , const Vector& , const Vector& ,
00174 int , double , const char* , int* ,
00175 int , const char* , const char* , unsigned short ,
00176 const char* , const std::list<Tag>& ) { }
00177 void createBoxAnnulusCmd( const Vector& , int , Vector* , double ,
00178 const char* , int* , int , const char* ,
00179 const char* , unsigned short , const char* ,
00180 const std::list<Tag>& ) { }
00181
00182 void createBpandaCmd( const Vector& , double , double , int ,
00183 const Vector& , const Vector& , int , double ,
00184 const char* , int* , int , const char* ,
00185 const char* , unsigned short , const char* ,
00186 const std::list<Tag>& ) { }
00187 void createBpandaCmd( const Vector& , int , double* , int , Vector* ,
00188 double ,const char* , int* , int ,
00189 const char* , const char* , unsigned short ,
00190 const char* , const std::list<Tag>& ) { }
00191
00192 void createTextCmd( const Vector& , double , int , const char* , int* ,
00193 int , const char* , const char* , unsigned short ,
00194 const char* , const std::list<Tag>& ) { }
00195
00196
00197
00198 void createBoxCmd( const Vector& , const Vector& , double ,
00199 const char* , int* , int , const char* ,
00200 const char* , unsigned short , const char* ,
00201 const std::list<Tag>& );
00202 void createEllipseCmd( const Vector& , const Vector& , double ,
00203 const char* , int* , int , const char* ,
00204 const char* , unsigned short , const char* ,
00205 const std::list<Tag>& );
00206 void createCircleCmd( const Vector& , double , const char* , int* ,
00207 int , const char* , const char* , unsigned short ,
00208 const char* , const std::list<Tag>& );
00209 void createPolygonCmd( const Vector& center, const Vector& bb, const char* color, int* dash,
00210 int width, const char* font, const char* text, unsigned short prop,
00211 const char* comment, const std::list<Tag>& tag );
00212 void createPolygonCmd( const std::list<Vertex>& list, const char* color, int* dash,
00213 int width, const char* font, const char* text, unsigned short prop,
00214 const char* comment, const std::list<Tag>& tag );
00215
00216 void createCirclePointCmd( const Vector& center, int size, const char* color, int* dash,
00217 int width, const char* font, const char* text, unsigned short prop,
00218 const char* comment, const std::list<Tag>& tag );
00219 void createBoxPointCmd( const Vector& center, int size, const char* color, int* dash,
00220 int width, const char* font, const char* text, unsigned short prop,
00221 const char* comment, const std::list<Tag>& tag );
00222 void createDiamondPointCmd( const Vector& center, int size, const char* color, int* dash,
00223 int width, const char* font, const char* text, unsigned short prop,
00224 const char* comment, const std::list<Tag>& tag );
00225 void createCrossPointCmd( const Vector& center, int size, const char* color, int* dash,
00226 int width, const char* font, const char* text, unsigned short prop,
00227 const char* comment, const std::list<Tag>& tag );
00228 void createExPointCmd( const Vector& center, int size, const char* color, int* dash,
00229 int width, const char* font, const char* text, unsigned short prop,
00230 const char* comment, const std::list<Tag>& tag );
00231 void createArrowPointCmd( const Vector& center, int size, const char* color, int* dash,
00232 int width, const char* font, const char* text, unsigned short prop,
00233 const char* comment, const std::list<Tag>& tag );
00234 void createBoxCirclePointCmd( const Vector& center, int size, const char* color, int* dash,
00235 int width, const char* font, const char* text, unsigned short prop,
00236 const char* comment, const std::list<Tag>& tag );
00237
00238
00239
00240 void markerDeleteLastCmd() { }
00241
00242 private:
00243 WorldCanvas *wc_;
00244 RegionToolManager *toolmgr;
00245 };
00246 }
00247 }
00248
00249 #endif