// Copyright (C) 1999-2017 // Smithsonian Astrophysical Observatory, Cambridge, MA, USA // For conditions of distribution and use, see copyright notice in "copyright" #include #include "cpanda.h" #include "fitsimage.h" Cpanda::Cpanda(Base* p, const Vector& ctr, double a1, double a2, int an, double r1, double r2, int rn, const char* clr, int* dsh, int wth, const char* fnt, const char* txt, unsigned short prop, const char* cmt, const List& tg, const List& cb) : BaseEllipse(p, ctr, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) { numAnnuli_ = rn+1; annuli_ = new Vector[numAnnuli_]; for (int ii=0; ii& tg, const List& cb) : BaseEllipse(p, ctr, 0, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) { numAnnuli_ = rn; annuli_ = new Vector[numAnnuli_]; for (int ii=0; iigetColor("red")); else if (ii == numAngles_-1) XSetForeground(display, gc, parent->getColor("blue")); else XSetForeground(display, gc, color); } else XSetForeground(display, gc, color); } XDrawLine(display, drawable, lgc, rr0[0], rr0[1], rr1[0], rr1[1]); } } void Cpanda::renderPS(int mode) { BaseEllipse::renderPS(mode); Vector r0 = annuli_[0]; Vector r1 = annuli_[numAnnuli_-1]; for (int ii=0; iicanvas) << ' ' << "moveto " << rr1.TkCanvasPs(parent->canvas) << ' ' << "lineto stroke" << endl << ends; Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); } } #ifdef MAC_OSX_TK void Cpanda::renderMACOSX() { BaseEllipse::renderMACOSX(); Vector r0 = annuli_[0]; Vector r1 = annuli_[numAnnuli_-1]; for (int ii=0; ii4) { int hh = h-4-1; if (numAnnuli_>2 && hh2 && hh<(numAnnuli_+numAngles_)) { hh -= numAnnuli_; deleteAngle(hh); } numHandle = 4 + numAnnuli_ + numAngles_; startAng_ = angles_[0]; stopAng_ = angles_[numAngles_-1]; updateBBox(); doCallBack(CallBack::EDITCB); } } int Cpanda::isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa) { Vector pp = bckMap(vv,sys); return BaseEllipse::isIn(vv,sys,nn) && isInAngle(pp,aa); } void Cpanda::analysis(AnalysisTask mm, int which) { switch (mm) { case PANDA: if (!analysisPanda_ && which) { addCallBack(CallBack::MOVECB, analysisPandaCB_[0], parent->options->cmdName); addCallBack(CallBack::EDITCB, analysisPandaCB_[0], parent->options->cmdName); addCallBack(CallBack::EDITENDCB, analysisPandaCB_[0], parent->options->cmdName); addCallBack(CallBack::UPDATECB, analysisPandaCB_[0], parent->options->cmdName); addCallBack(CallBack::DELETECB, analysisPandaCB_[1], parent->options->cmdName); } if (analysisPanda_ && !which) { deleteCallBack(CallBack::MOVECB, analysisPandaCB_[0]); deleteCallBack(CallBack::EDITCB, analysisPandaCB_[0]); deleteCallBack(CallBack::EDITENDCB, analysisPandaCB_[0]); deleteCallBack(CallBack::UPDATECB, analysisPandaCB_[0]); deleteCallBack(CallBack::DELETECB, analysisPandaCB_[1]); } analysisPanda_ = which; break; case STATS: if (!analysisStats_ && which) { addCallBack(CallBack::MOVECB, analysisStatsCB_[0], parent->options->cmdName); addCallBack(CallBack::EDITCB, analysisStatsCB_[0], parent->options->cmdName); addCallBack(CallBack::EDITENDCB, analysisStatsCB_[0], parent->options->cmdName); addCallBack(CallBack::UPDATECB, analysisStatsCB_[0], parent->options->cmdName); addCallBack(CallBack::DELETECB, analysisStatsCB_[1], parent->options->cmdName); } if (analysisStats_ && !which) { deleteCallBack(CallBack::MOVECB, analysisStatsCB_[0]); deleteCallBack(CallBack::EDITCB, analysisStatsCB_[0]); deleteCallBack(CallBack::EDITENDCB, analysisStatsCB_[0]); deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); } analysisStats_ = which; break; default: // na break; } } void Cpanda::analysisPanda(Coord::CoordSystem sys) { double* xx; double* yy; double* ee; BBox* bb = new BBox[numAnnuli_]; for (int ii=0; iimarkerAnalysisPanda(this, &xx, &yy, &ee, numAnnuli_-1, annuli_, numAngles_-1, angles_, bb, sys); analysisXYEResult(xx, yy, ee, num); } void Cpanda::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) { ostringstream str; BBox* bb = new BBox[numAnnuli_]; for (int ii=0; iimarkerAnalysisStats(this, str, numAnnuli_-1, numAngles_-1, bb, sys, sky); str << ends; Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); } // list void Cpanda::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, Coord::SkyFormat format, int conj, int strip) { int regular = 1; if (numAngles_>2) { double delta; if (angles_[1] > angles_[0]) delta = angles_[1]-angles_[0]; else delta = angles_[1]+M_TWOPI-angles_[0]; for (int ii=2; ii angles_[ii-1]) diff = angles_[ii]-angles_[ii-1]; else diff = angles_[ii]+M_TWOPI-angles_[ii-1]; if (!teq(diff,delta,FLT_EPSILON)) { regular = 0; break; } } } if (numAnnuli_>2) { double delta = annuli_[1][0]-annuli_[0][0]; for (int i=2; ifindFits(sys,center); listPre(str, sys, sky, ptr, strip, 0); switch (sys) { case Coord::IMAGE: case Coord::PHYSICAL: case Coord::DETECTOR: case Coord::AMPLIFIER: listANonCel(ptr, str, sys); break; default: if (ptr->hasWCSCel(sys)) { double a1 = radToDeg(parent->mapAngleFromRef(angles_[0],sys,sky)); double a2 = radToDeg(parent->mapAngleFromRef(angles_[numAngles_-1],sys,sky)); double r1 = ptr->mapLenFromRef(annuli_[0][0],sys,Coord::ARCSEC); double r2 = ptr->mapLenFromRef(annuli_[numAnnuli_-1][0],sys,Coord::ARCSEC); if (a2<=a1+FLT_EPSILON) a2 += 360; listRADEC(ptr,center,sys,sky,format); str << type_ << '(' << ra << ',' << dec << ',' << setprecision(parent->precLinear) << a1 << ',' << a2 << ',' << numAngles_-1 << ',' << setprecision(parent->precArcsec) << fixed << r1 << '"' << ',' << r2 << '"' << ','; str.unsetf(ios_base::floatfield); str << setprecision(parent->precLinear) << numAnnuli_-1 << ')'; } else listANonCel(ptr, str, sys); } listPost(str, conj, strip); } void Cpanda::listANonCel(FitsImage* ptr, ostream& str, Coord::CoordSystem sys) { double a1 = radToDeg(parent->mapAngleFromRef(angles_[0],sys)); double a2 = radToDeg(parent->mapAngleFromRef(angles_[numAngles_-1],sys)); if (a2<=a1+FLT_EPSILON) a2 += 360; Vector vv = ptr->mapFromRef(center,sys); double r1 = ptr->mapLenFromRef(annuli_[0][0],sys); double r2 = ptr->mapLenFromRef(annuli_[numAnnuli_-1][0],sys); str << type_ << '(' << setprecision(parent->precLinear) << vv << ',' << a1 << ',' << a2 << ',' << numAngles_-1 << ',' << r1 << ',' << r2 << ',' << numAnnuli_-1 << ')'; } void Cpanda::listB(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, Coord::SkyFormat format, int conj, int strip) { FitsImage* ptr = parent->findFits(sys,center); switch (sys) { case Coord::IMAGE: case Coord::PHYSICAL: case Coord::DETECTOR: case Coord::AMPLIFIER: listBNonCel(ptr, str, sys, sky, format, conj, strip); break; default: if (ptr->hasWCSCel(sys)) { listRADEC(ptr,center,sys,sky,format); for (int jj=1; jjmapFromRef(center,sys); for (int jj=1; jjmapAngleFromRef(angles_[jj-1],sys)); double a2 = radToDeg(parent->mapAngleFromRef(angles_[jj],sys)); if (a2<=a1+FLT_EPSILON) a2 += 360; for (int ii=1; iimapLenFromRef(annuli_[ii-1][0],sys); double r2 = ptr->mapLenFromRef(annuli_[ii][0],sys); str << type_ << '(' << setprecision(parent->precLinear) << vv << ',' << a1 << ',' << a2 << ",1," << r1 << ',' << r2 << ",1)"; if (!strip) { if (conj) str << " ||"; str << " # panda="; if (ii==1 && jj==1 && !strip) { str << '('; for (int kk=0; kkmapAngleFromRef(angles_[kk],sys); str << radToDeg(ar) << ((kkmapLenFromRef(annuli_[kk][0],sys); str << rr << ((kkmapAngleFromRef(angles_[jj-1],sys,sky)); double a2 = radToDeg(parent->mapAngleFromRef(angles_[jj],sys,sky)); if (a2<=a1+FLT_EPSILON) a2 += 360; double r1 = ptr->mapLenFromRef(annuli_[ii-1][0],sys,Coord::ARCSEC); double r2 = ptr->mapLenFromRef(annuli_[ii][0],sys,Coord::ARCSEC); str << setprecision(parent->precLinear) << a1 << ',' << a2 << ",1," << setprecision(parent->precArcsec) << fixed << r1 << '"' << ',' << r2 << '"' << ",1)"; str.unsetf(ios_base::floatfield); if (!strip) { if (conj) str << " ||"; str << " # panda="; if (ii==1 && jj==1 && !strip) { str << '(' << setprecision(parent->precLinear); for (int kk=0; kkmapAngleFromRef(angles_[kk],sys,sky); str << radToDeg(aa) << ((kkprecArcsec) << fixed; for (int kk=0; kkmapLenFromRef(annuli_[kk][0],sys,Coord::ARCSEC); str << rr << '"' << ((kkfindFits(sys,center); XMLRowInit(); XMLRow(XMLSHAPE,type_); XMLRowCenter(ptr,sys,sky,format); XMLRowRadiusX(ptr,sys,annuli_,numAnnuli_); XMLRowAng(sys,sky,angles_,numAngles_); XMLRowProps(ptr,sys); XMLRowEnd(str); } void Cpanda::listCiao(ostream& str, Coord::CoordSystem sys, int strip) { FitsImage* ptr = parent->findFits(); switch (sys) { case Coord::IMAGE: case Coord::PHYSICAL: case Coord::DETECTOR: case Coord::AMPLIFIER: { Vector vv = ptr->mapFromRef(center,Coord::PHYSICAL); for (int ii=0; iimapLenFromRef(annuli_[ii][0],Coord::PHYSICAL); double r2 = ptr->mapLenFromRef(annuli_[ii+1][0],Coord::PHYSICAL); for (int jj=0; jjprecLinear) << vv << ',' << r1 << ',' << r2 << ',' << a1 << ',' << a2 << ')'; listCiaoPost(str, strip); } } } break; default: if (ptr->hasWCSCel(sys)) { listRADEC(ptr,center,sys,Coord::FK5,Coord::SEXAGESIMAL); for (int ii=0; iimapLenFromRef(annuli_[ii][0],sys,Coord::ARCMIN); double r2 = ptr->mapLenFromRef(annuli_[ii+1][0],sys,Coord::ARCMIN); for (int jj=0; jjprecLinear) << ra << ',' << dec << ',' << r1 << '\'' << ',' << r2 << '\'' << ',' << a1 << ',' << a2 << ')'; listCiaoPost(str, strip); } } } } } // special composite funtionallity void Cpanda::setComposite(const Matrix& mx, double aa) { center *= mx; updateBBox(); }