summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-08-15 16:49:49 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-08-15 16:49:49 (GMT)
commit423d274f21444ed957fc437d17984b32b01a1a7b (patch)
tree78e124b6a2573919abf27a197dbf1cf84f16482d
parentf0aec96f44f51db8acd90846e9f7d52258c1b837 (diff)
downloadblt-423d274f21444ed957fc437d17984b32b01a1a7b.zip
blt-423d274f21444ed957fc437d17984b32b01a1a7b.tar.gz
blt-423d274f21444ed957fc437d17984b32b01a1a7b.tar.bz2
simplify marker code
-rw-r--r--tksao/frame/boxannulus.C109
-rw-r--r--tksao/frame/ellipseannulus.C110
-rw-r--r--tksao/vector/vectorstr.C64
-rw-r--r--tksao/vector/vectorstr.h32
4 files changed, 172 insertions, 143 deletions
diff --git a/tksao/frame/boxannulus.C b/tksao/frame/boxannulus.C
index a328f15..2f85be2 100644
--- a/tksao/frame/boxannulus.C
+++ b/tksao/frame/boxannulus.C
@@ -277,38 +277,17 @@ void BoxAnnulus::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky,
FitsImage* ptr = parent->findFits(sys,center);
listPre(str, sys, sky, ptr, strip, 0);
- double aa = parent->mapAngleFromRef(angle,sys,sky);
-
str << "box(";
- switch (sys) {
- case Coord::IMAGE:
- case Coord::PHYSICAL:
- case Coord::DETECTOR:
- case Coord::AMPLIFIER:
- str << setprecision(parent->precLinear_) << ptr->mapFromRef(center,sys);
- str << setprecision(parent->precLenLinear_);
- for (int ii=0; ii<numAnnuli_; ii++)
- str << ',' << ptr->mapLenFromRef(annuli_[ii],sys);
- break;
- default:
- listWCS(ptr,center,sys,sky,format);
- str << ra << ',' << dec;
-
- if (ptr->hasWCSCel(sys)) {
- str << setprecision(parent->precArcsec_) << fixed;
- for (int ii=0; ii<numAnnuli_; ii++) {
- Vector rr = ptr->mapLenFromRef(annuli_[ii],sys,Coord::ARCSEC);
- str << ',' << setunit('"') << rr;
- }
- str.unsetf(ios_base::floatfield);
- }
- else {
- str << setprecision(parent->precLenLinear_);
- for (int ii=0; ii<numAnnuli_; ii++)
- str << ',' << ptr->mapLenFromRef(annuli_[ii],sys);
- }
+ ptr->listFromRef(str,center,sys,sky,format);
+ for (int ii=0; ii<numAnnuli_; ii++) {
+ str << ',';
+ if (ptr->hasWCSCel(sys))
+ str << setunit('"');
+ ptr->listLenFromRef(str,annuli_[ii],sys,Coord::ARCSEC);
}
- str << ',' << setprecision(parent->precAngle_) << radToDeg(aa) << ')';
+ str << ',';
+ parent->listAngleFromRef(str,angle,sys,sky);
+ str << ')';
listPost(str, conj, strip);
}
@@ -343,63 +322,51 @@ void BoxAnnulus::listPros(ostream& str, Coord::CoordSystem sys,
case Coord::PHYSICAL:
for (int ii=0; ii<numAnnuli_; ii++) {
coord.listProsCoordSystem(str,sys,sky);
- str << "; box "
- << setprecision(parent->precLinear_)
- << ptr->mapFromRef(center,sys) << ' '
- << setprecision(parent->precLenLinear_)
- << ptr->mapLenFromRef(annuli_[ii],Coord::IMAGE) << ' '
- << setprecision(parent->precAngle_)
- << radToDeg(angle);
+ str << "; box ";
+ ptr->listFromRef(str,center,sys);
+ str << ' ';
+ ptr->listLenFromRef(str,annuli_[ii],Coord::IMAGE);
+ str << ' ';
+ parent->listAngleFromRef(str,angle,Coord::IMAGE);
if (ii!=0) {
- str << " & !box "
- << setprecision(parent->precLinear_)
- << ptr->mapFromRef(center,sys) << ' '
- << setprecision(parent->precLenLinear_)
- << ptr->mapLenFromRef(annuli_[ii-1],Coord::IMAGE) << ' '
- << setprecision(parent->precAngle_)
- << radToDeg(angle);
+ str << " & !box ";
+ ptr->listFromRef(str,center,sys);
+ str << ' ';
+ ptr->listLenFromRef(str,annuli_[ii-1],Coord::IMAGE);
+ str << ' ';
+ parent->listAngleFromRef(str,angle,Coord::IMAGE);
}
listProsPost(str, strip);
}
break;
default:
- listWCSPros(ptr,center,sys,sky,format);
for (int ii=0; ii<numAnnuli_; ii++) {
coord.listProsCoordSystem(str,sys,sky);
str << "; box ";
- switch (format) {
- case Coord::DEGREES:
- str << ra << 'd' << ' ' << dec << 'd' << ' ';
- break;
- case Coord::SEXAGESIMAL:
- str << ra << ' ' << dec << ' ';
- break;
- }
- str << setprecision(parent->precArcsec_) << setunit('"') << fixed
- << ptr->mapLenFromRef(annuli_[ii],sys,Coord::ARCSEC) << ' ';
- str.unsetf(ios_base::floatfield);
- str << setprecision(parent->precLinear_)
- << radToDeg(angle);
+ if (format == Coord::DEGREES)
+ str << setunit('d');
+ ptr->listFromRef(str,center,sys,sky,format);
+ str << ' ';
+ str << setunit('"');
+ ptr->listLenFromRef(str,annuli_[ii],sys,Coord::ARCSEC);
+ str << ' ';
+ parent->listAngleFromRef(str,angle,Coord::IMAGE);
if (ii!=0) {
str << " & !box ";
- switch (format) {
- case Coord::DEGREES:
- str << ra << 'd' << ' ' << dec << 'd' << ' ';
- break;
- case Coord::SEXAGESIMAL:
- str << ra << ' ' << dec << ' ';
- break;
- }
- str << setprecision(parent->precArcsec_) << setunit('"') << fixed
- << ptr->mapLenFromRef(annuli_[ii-1],sys,Coord::ARCSEC) << ' ';
- str.unsetf(ios_base::floatfield);
- str << setprecision(parent->precLinear_)
- << radToDeg(angle);
+ if (format == Coord::DEGREES)
+ str << setunit('d');
+ ptr->listFromRef(str,center,sys,sky,format);
+ str << ' ';
+ str << setunit('"');
+ ptr->listLenFromRef(str,annuli_[ii-1],sys,Coord::ARCSEC);
+ str << ' ';
+ parent->listAngleFromRef(str,angle,Coord::IMAGE);
}
listProsPost(str, strip);
}
+ break;
}
}
diff --git a/tksao/frame/ellipseannulus.C b/tksao/frame/ellipseannulus.C
index a53660e..dbd3504 100644
--- a/tksao/frame/ellipseannulus.C
+++ b/tksao/frame/ellipseannulus.C
@@ -245,38 +245,17 @@ void EllipseAnnulus::list(ostream& str, Coord::CoordSystem sys,
FitsImage* ptr = parent->findFits(sys,center);
listPre(str, sys, sky, ptr, strip, 0);
- double aa = parent->mapAngleFromRef(angle,sys,sky);
-
str << "ellipse(";
- switch (sys) {
- case Coord::IMAGE:
- case Coord::PHYSICAL:
- case Coord::DETECTOR:
- case Coord::AMPLIFIER:
- str << setprecision(parent->precLinear_) << ptr->mapFromRef(center,sys);
- str << setprecision(parent->precLenLinear_);
- for (int ii=0; ii<numAnnuli_; ii++)
- str << ',' << ptr->mapLenFromRef(annuli_[ii],sys);
- break;
- default:
- listWCS(ptr,center,sys,sky,format);
- str << ra << ',' << dec;
-
- if (ptr->hasWCSCel(sys)) {
- str << setprecision(parent->precArcsec_) << fixed;
- for (int ii=0; ii<numAnnuli_; ii++) {
- Vector rr = ptr->mapLenFromRef(annuli_[ii],sys,Coord::ARCSEC);
- str << ',' << setunit('"') << rr;
- }
- str.unsetf(ios_base::floatfield);
- }
- else {
- str << setprecision(parent->precLenLinear_);
- for (int ii=0; ii<numAnnuli_; ii++)
- str << ',' << ptr->mapLenFromRef(annuli_[ii],sys);
- }
+ ptr->listFromRef(str,center,sys,sky,format);
+ for (int ii=0; ii<numAnnuli_; ii++) {
+ str << ',';
+ if (ptr->hasWCSCel(sys))
+ str << setunit('"');
+ ptr->listLenFromRef(str,annuli_[ii],sys,Coord::ARCSEC);
}
- str << ',' << setprecision(parent->precAngle_) << radToDeg(aa) << ')';
+ str << ',';
+ parent->listAngleFromRef(str,angle,sys,sky);
+ str << ')';
listPost(str, conj, strip);
}
@@ -311,64 +290,51 @@ void EllipseAnnulus::listPros(ostream& str, Coord::CoordSystem sys,
case Coord::PHYSICAL:
for (int ii=0; ii<numAnnuli_; ii++) {
coord.listProsCoordSystem(str,sys,sky);
- str << "; ellipse "
- << setprecision(parent->precLinear_)
- << ptr->mapFromRef(center,sys) << ' '
- << setprecision(parent->precLenLinear_)
- << ptr->mapLenFromRef(annuli_[ii],Coord::IMAGE) << ' '
- << setprecision(parent->precAngle_)
- << radToDeg(angle);
+ str << "; ellipse ";
+ ptr->listFromRef(str,center,sys);
+ str << ' ';
+ ptr->listLenFromRef(str,annuli_[ii],Coord::IMAGE);
+ str << ' ';
+ parent->listAngleFromRef(str,angle,Coord::IMAGE);
if (ii!=0) {
- str << " & !ellipse "
- << setprecision(parent->precLinear_)
- << ptr->mapFromRef(center,sys) << ' '
- << setprecision(parent->precLenLinear_)
- << ptr->mapLenFromRef(annuli_[ii-1],Coord::IMAGE) << ' '
- << setprecision(parent->precAngle_)
- << radToDeg(angle);
+ str << " & !ellipse ";
+ ptr->listFromRef(str,center,sys);
+ str << ' ';
+ ptr->listLenFromRef(str,annuli_[ii-1],Coord::IMAGE);
+ str << ' ';
+ parent->listAngleFromRef(str,angle,Coord::IMAGE);
}
listProsPost(str, strip);
}
break;
default:
- listWCSPros(ptr,center,sys,sky,format);
for (int ii=0; ii<numAnnuli_; ii++) {
coord.listProsCoordSystem(str,sys,sky);
str << "; ellipse ";
- switch (format) {
- case Coord::DEGREES:
- str << ra << 'd' << ' ' << dec << 'd' << ' ';
- break;
- case Coord::SEXAGESIMAL:
- str << ra << ' ' << dec << ' ';
- break;
- }
- str << setprecision(parent->precArcsec_) << setunit('"') << fixed
- << ptr->mapLenFromRef(annuli_[ii],sys,Coord::ARCSEC) << ' ';
- str.unsetf(ios_base::floatfield);
- str << setprecision(parent->precAngle_)
- << radToDeg(angle);
+ if (format == Coord::DEGREES)
+ str << setunit('d');
+ ptr->listFromRef(str,center,sys,sky,format);
+ str << ' ';
+ str << setunit('"');
+ ptr->listLenFromRef(str,annuli_[ii],sys,Coord::ARCSEC);
+ str << ' ';
+ parent->listAngleFromRef(str,angle,Coord::IMAGE);
if (ii!=0) {
str << " & !ellipse ";
- switch (format) {
- case Coord::DEGREES:
- str << ra << 'd' << ' ' << dec << 'd' << ' ';
- break;
- case Coord::SEXAGESIMAL:
- str << ra << ' ' << dec << ' ';
- break;
- }
- str << setprecision(parent->precArcsec_) << setunit('"') << fixed
- << ptr->mapLenFromRef(annuli_[ii-1],sys,Coord::ARCSEC) << ' ';
- str.unsetf(ios_base::floatfield);
- str << setprecision(parent->precAngle_)
- << radToDeg(angle);
+ if (format == Coord::DEGREES)
+ str << setunit('d');
+ ptr->listFromRef(str,center,sys,sky,format);
+ str << ' ';
+ str << setunit('"');
+ ptr->listLenFromRef(str,annuli_[ii-1],sys,Coord::ARCSEC);
+ str << ' ';
+ parent->listAngleFromRef(str,angle,Coord::IMAGE);
}
-
listProsPost(str, strip);
}
+ break;
}
}
diff --git a/tksao/vector/vectorstr.C b/tksao/vector/vectorstr.C
new file mode 100644
index 0000000..145bebc
--- /dev/null
+++ b/tksao/vector/vectorstr.C
@@ -0,0 +1,64 @@
+// Copyright (C) 1999-2018
+// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+// For conditions of distribution and use, see copyright notice in "copyright"
+
+#include "vectorstr.h"
+#include "vector.h"
+#include "util.h"
+
+// VectorStr
+
+VectorStr::~VectorStr()
+{
+ if (c[0])
+ delete [] c[0];
+ if (c[1])
+ delete [] c[1];
+}
+
+VectorStr::VectorStr(const char* aa, const char* bb)
+{
+ c[0] = dupstr(aa);
+ c[1] = dupstr(bb);
+}
+
+VectorStr::VectorStr(const VectorStr& vv)
+{
+ c[0] = dupstr(vv.c[0]);
+ c[1] = dupstr(vv.c[1]);
+}
+
+VectorStr& VectorStr::operator=(const VectorStr& vv)
+{
+ if (c[0])
+ delete [] c[0];
+ c[0]=dupstr(vv.c[0]);
+ if (c[1])
+ delete [] c[1];
+ c[1]=dupstr(vv.c[1]);
+ return *this;
+}
+
+ostream& operator<<(ostream& os, const VectorStr& vv)
+{
+ unsigned char sep = (unsigned char)os.iword(Vector::separator);
+ if (!sep)
+ sep = ' ';
+
+ unsigned char unit = (unsigned char)os.iword(Vector::unit);
+ if (!unit)
+ os << vv.c[0] << sep << vv.c[1];
+ else
+ os << vv.c[0] << unit << sep << vv.c[1] << unit;
+
+ // reset unit
+ os.iword(Vector::unit) = '\0';
+
+ return os;
+}
+
+istream& operator>>(istream& ss, VectorStr& vv)
+{
+ ss >> vv.c[0] >> vv.c[1];
+ return ss;
+}
diff --git a/tksao/vector/vectorstr.h b/tksao/vector/vectorstr.h
new file mode 100644
index 0000000..dbf8d49
--- /dev/null
+++ b/tksao/vector/vectorstr.h
@@ -0,0 +1,32 @@
+// Copyright (C) 1999-2018
+// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+// For conditions of distribution and use, see copyright notice in "copyright"
+
+#ifndef __vectorstr_h__
+#define __vectorstr_h__
+
+#include <iostream>
+using namespace std;
+
+class VectorStr {
+ public:
+ char* c[2];
+
+ public:
+ VectorStr() {c[0]=NULL; c[1]=NULL;}
+ ~VectorStr();
+ VectorStr(const char*, const char*);
+ VectorStr(const VectorStr&);
+ VectorStr& operator=(const VectorStr&);
+
+ const char* operator[](int i) const {return c[i];} // return element
+ char** cc() {return c;} // return vector
+};
+
+ostream& operator<<(ostream&, const VectorStr&);
+istream& operator>>(istream&, VectorStr&);
+#endif
+
+
+
+