// Copyright (C) 1999-2018 // Smithsonian Astrophysical Observatory, Cambridge, MA, USA // For conditions of distribution and use, see copyright notice in "copyright" #include #include "bpanda.h" #include "fitsimage.h" Bpanda::Bpanda(Base* p, const Vector& ctr, double a1, double a2, int an, const Vector& r1, const Vector& r2, int rn, double ang, 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) : BaseBox(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) { numAnnuli_ = rn+1; annuli_ = new Vector[numAnnuli_]; for (int i=0; i& tg, const List& cb) : BaseBox(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb) { numAnnuli_ = rn; annuli_ = new Vector[numAnnuli_]; for (int i=0; igetColor("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 Bpanda::renderPS(Widget::PSColorSpace mode) { BaseBox::renderPS(mode); renderPSGC(mode); Vector r0 = annuli_[0]/2; Vector r1 = annuli_[numAnnuli_-1]/2; 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 Bpanda::renderMACOSX() { BaseBox::renderMACOSX(); renderMACOSXGC(); Vector r0 = annuli_[0]/2; Vector r1 = annuli_[numAnnuli_-1]/2; 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 Bpanda::isIn(const Vector& vv, Coord::InternalSystem sys, int nn, int aa) { Vector pp = bckMap(vv,sys); return BaseBox::isIn(vv,sys,nn) && isInAngle(pp,aa); } void Bpanda::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::ROTATECB, 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::ROTATECB, 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::ROTATECB, 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::ROTATECB, analysisStatsCB_[0]); deleteCallBack(CallBack::UPDATECB, analysisStatsCB_[0]); deleteCallBack(CallBack::DELETECB, analysisStatsCB_[1]); } analysisStats_ = which; break; default: // na break; } } void Bpanda::analysisPanda(char* xname, char* yname, char* ename, Coord::CoordSystem sys, int angnum) { double* xx; double* yy; double* ee; BBox* bb = new BBox[numAnnuli_]; Matrix mm = Rotate(angle) * Translate(center); for (int ii=0; iimarkerAnalysisPanda(this, &xx, &yy, &ee, numAnnuli_-1, annuli_, angnum, bb, sys); analysisXYEResult(xname, yname, ename, xx, yy, ee, num); } void Bpanda::analysisStats(Coord::CoordSystem sys, Coord::SkyFrame sky) { ostringstream str; BBox* bb = new BBox[numAnnuli_]; Matrix mm = Rotate(angle) * Translate(center); 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 Bpanda::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); str << type_ << '('; ptr->listFromRef(str,center,sys,sky,format); str << ','; parent->listAngleFromRef(str,angles_[0],sys,sky); str << ','; parent->listAngleFromRef(str,angles_[numAngles_-1],angles_[0],sys,sky); str << ','; str << numAngles_-1; str << ','; if (ptr->hasWCSCel(sys)) str << setunit('"'); ptr->listLenFromRef(str,annuli_[0],sys,Coord::ARCSEC); str << ','; if (ptr->hasWCSCel(sys)) str << setunit('"'); ptr->listLenFromRef(str,annuli_[numAnnuli_-1],sys,Coord::ARCSEC); str << ','; str << numAnnuli_-1; str << ','; parent->listAngleFromRef(str,angle,sys,sky); str << ')'; listPost(str, conj, strip); } void Bpanda::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,"; if (ptr->hasWCSCel(sys)) str << setunit('"'); ptr->listLenFromRef(str,annuli_[ii-1],sys,Coord::ARCSEC); str << ','; if (ptr->hasWCSCel(sys)) str << setunit('"'); ptr->listLenFromRef(str,annuli_[ii],sys,Coord::ARCSEC); str << ",1,"; parent->listAngleFromRef(str,angle,sys,sky); str << ')'; if (!strip) { if (conj) str << " ||"; str << " # bpanda="; if (ii==1 && jj==1 && !strip) { str << '('; for (int kk=0; kklistAngleFromRef(str,angles_[kk],sys,sky); str << ((kkhasWCSCel(sys)) str << setunit('"'); ptr->listLenFromRef(str,annuli_[kk],sys,Coord::ARCSEC); str << ((kklistAngleFromRef(str,angle,sys,sky); str << ')'; listProps(str); } else str << "ignore"; str << (strip ? ';' : '\n'); } else { if (conj) str << "||"; else str << ";"; } } } } void Bpanda::listXML(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky, Coord::SkyFormat format) { FitsImage* ptr = parent->findFits(sys,center); XMLRowInit(); XMLRow(XMLSHAPE,type_); XMLRowCenter(ptr,sys,sky,format); XMLRowRadius(ptr,sys,annuli_,numAnnuli_); XMLRowAng(sys,sky); XMLRowAng(sys,sky,angles_,numAngles_); XMLRowProps(ptr,sys); XMLRowEnd(str); }