// Copyright (C) 1999-2018 // Smithsonian Astrophysical Observatory, Cambridge, MA, USA // For conditions of distribution and use, see copyright notice in "copyright" #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(PSColorSpace mode) { BaseEllipse::renderPS(mode); Vector r0 = annuli_[0]; Vector r1 = annuli_[numAnnuli_-1]; for (int ii=0; iiTkCanvasPs(rr0) << ' ' << "moveto " << parent->TkCanvasPs(rr1) << ' ' << "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(char* xname, char* yname, char* ename, Coord::CoordSystem sys, int angnum) { double* xx; double* yy; double* ee; BBox* bb = new BBox[numAnnuli_]; for (int ii=0; iimarkerAnalysisPanda(this, &xx, &yy, &ee, numAnnuli_-1, annuli_, angnum, bb, sys); analysisXYEResult(xname, yname, ename, 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); double a1 = angles_[0]; double a2 = angles_[numAngles_-1]; str << type_ << '('; ptr->listFromRef(str,center,sys,sky,format); str << ','; parent->listAngleFromRef(str,a1,sys,sky); str << ','; parent->listAngleFromRef(str,a2,a1,sys,sky); str << ','; str << numAngles_-1; str << ','; ptr->listLenFromRef(str,annuli_[0][0],sys,Coord::ARCSEC); if (ptr->hasWCSCel(sys)) str << '"'; str << ','; ptr->listLenFromRef(str,annuli_[numAnnuli_-1][0],sys,Coord::ARCSEC); if (ptr->hasWCSCel(sys)) str << '"'; str << ','; str << numAnnuli_-1; str << ')'; listPost(str, conj, strip); } void Cpanda::listB(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, Coord::SkyFormat format, int conj, int strip) { FitsImage* ptr = parent->findFits(sys,center); for (int jj=1; jjlistFromRef(str,center,sys,sky,format); str << ','; parent->listAngleFromRef(str,a1,sys,sky); str << ','; parent->listAngleFromRef(str,a2,a1,sys,sky); str << ",1,"; ptr->listLenFromRef(str,annuli_[ii-1][0],sys,Coord::ARCSEC); if (ptr->hasWCSCel(sys)) str << '"'; str << ','; ptr->listLenFromRef(str,annuli_[ii][0],sys,Coord::ARCSEC); if (ptr->hasWCSCel(sys)) str << '"'; str << ",1)"; if (!strip) { if (conj) str << " ||"; str << " # panda="; if (ii==1 && jj==1 && !strip) { str << '('; for (int kk=0; kklistAngleFromRef(str,angles_[kk],sys,sky); str << ((kklistLenFromRef(str,annuli_[kk][0],sys,Coord::ARCSEC); if (ptr->hasWCSCel(sys)) str << '"'; str << ((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: for (int ii=0; iilistFromRef(str,center,Coord::PHYSICAL); str << ','; ptr->listLenFromRef(str,annuli_[ii][0],Coord::PHYSICAL); str << ','; ptr->listLenFromRef(str,annuli_[ii+1][0],Coord::PHYSICAL); str << ','; parent->listAngleFromRef(str,a1,Coord::PHYSICAL); str << ','; parent->listAngleFromRef(str,a2,a1,Coord::PHYSICAL); str << ')'; listCiaoPost(str, strip); } } break; default: for (int ii=0; iilistFromRef(str,center,sys,Coord::FK5,Coord::SEXAGESIMAL); str << ','; ptr->listLenFromRef(str,annuli_[ii][0],sys,Coord::ARCMIN); str << '\''; str << ','; ptr->listLenFromRef(str,annuli_[ii+1][0],sys,Coord::ARCMIN); str << '\''; str << ','; parent->listAngleFromRef(str,a1,Coord::PHYSICAL); str << ','; parent->listAngleFromRef(str,a2,a1,Coord::PHYSICAL); str << ')'; listCiaoPost(str, strip); } } } } // special composite funtionallity void Cpanda::setComposite(const Matrix& mx, double aa) { center *= mx; updateBBox(); }