diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-11-06 19:32:19 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-11-06 19:32:19 (GMT) |
commit | 45d295ad2080045c1eea4fbf7885724e806567d6 (patch) | |
tree | c15ea914bdd7b72c1bd09ae2bb41ec3a61ec2943 /tksao/frame | |
parent | 28de41b7743e154e7e30e2ddf3693e67c439f5d4 (diff) | |
download | blt-45d295ad2080045c1eea4fbf7885724e806567d6.zip blt-45d295ad2080045c1eea4fbf7885724e806567d6.tar.gz blt-45d295ad2080045c1eea4fbf7885724e806567d6.tar.bz2 |
update AST WCS
Diffstat (limited to 'tksao/frame')
-rw-r--r-- | tksao/frame/base.C | 57 | ||||
-rw-r--r-- | tksao/frame/base.h | 17 | ||||
-rw-r--r-- | tksao/frame/basecommand.C | 119 | ||||
-rw-r--r-- | tksao/frame/frame3dbase.C | 177 | ||||
-rw-r--r-- | tksao/frame/frame3dbase.h | 9 | ||||
-rw-r--r-- | tksao/frame/framebase.C | 154 | ||||
-rw-r--r-- | tksao/frame/framebase.h | 8 | ||||
-rw-r--r-- | tksao/frame/framergb.C | 2 | ||||
-rw-r--r-- | tksao/frame/marker.C | 55 | ||||
-rw-r--r-- | tksao/frame/marker.h | 4 |
10 files changed, 409 insertions, 193 deletions
diff --git a/tksao/frame/base.C b/tksao/frame/base.C index da40bcf..581a8af 100644 --- a/tksao/frame/base.C +++ b/tksao/frame/base.C @@ -746,14 +746,6 @@ void Base::coordToTclArray(FitsImage* ptr, const Vector3d& vv, doubleToTclArray(rr[1], var, base, "y"); } -void Base::coord3ToTclArray(FitsImage* ptr, const Vector3d& vv, - Coord::CoordSystem out, - const char* var, const char* base) -{ - double ss = ptr->mapFromRef3axis(((Vector3d&)vv)[2],out,2); - doubleToTclArray(ss, var, base, "z"); -} - int Base::doRender() { return context->cfits ? 1 : 0; @@ -897,55 +889,6 @@ void Base::getInfoClearWCS(char* var) } } -void Base::getInfoWCS(char* var, const Vector3d& rr, FitsImage* ptr, - FitsImage* sptr) -{ - Vector img = Vector(rr) * sptr->refToData; - - for (int ii=0; ii<MULTWCS; ii++) { - char buf[64]; - char ww = !ii ? '\0' : '`'+ii; - Coord::CoordSystem www = (Coord::CoordSystem)(Coord::WCS+ii); - - if (hasWCS(www)) { - char buff[128]; - Vector uu = img * dataToImage; - sptr->pix2wcs(uu, www, wcsSky_, wcsSkyFormat_, buff); - - int argc; - const char** argv; - Tcl_SplitList(interp, buff, &argc, &argv); - - if (argc > 0 && argv && argv[0]) - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),argv[0],0); - else - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); - if (argc > 1 && argv && argv[1]) - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),argv[1],0); - else - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); - // use first slice - coord3ToTclArray(ptr,rr,www,var,"wcs"); - - char* wcsname = (char*)sptr->getWCSName(www); - if (wcsname) - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),wcsname,0); - else if (argc > 2 && argv && argv[2]) - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),argv[2],0); - else - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); - - Tcl_Free((char*)argv); - } - else { - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",z"),"",0); - Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); - } - } -} - int Base::hasATMV() { return currentContext->cfits && currentContext->cfits->hasATMV(); diff --git a/tksao/frame/base.h b/tksao/frame/base.h index 764a97c..a115077 100644 --- a/tksao/frame/base.h +++ b/tksao/frame/base.h @@ -114,6 +114,7 @@ class Base : public Widget { friend class Vect; public: + enum FrameType {F2D, F3D}; enum CompressType {NOCOMPRESS, GZ}; enum FileNameType {ROOTBASE, FULLBASE, ROOT, FULL}; enum MarkerFormat {DS9, XML, CIAO, SAOTNG, SAOIMAGE, PROS, RAWXY}; @@ -319,11 +320,6 @@ public: private: void bltHist(char*, char*); // frblt.C - void getInfoClearName(char*); - void getInfoClearValue(char*); - void getInfoClearWCS(char*); - void getInfoWCS(char*, const Vector3d&, FitsImage*, FitsImage*); - void invalidPixmap(); int updatePixmap(const BBox&); @@ -347,8 +343,6 @@ public: virtual void centerImage(); void coordToTclArray(FitsImage*, const Vector3d&, Coord::CoordSystem, const char*, const char*); - void coord3ToTclArray(FitsImage*, const Vector3d&, Coord::CoordSystem, - const char*, const char*); void createMarker(Marker*); void createTemplate(const Vector&, istream&); void contourCreatePolygon(List<ContourLevel>&); @@ -362,6 +356,10 @@ public: virtual unsigned char* fillImage(int, int, Coord::InternalSystem) =0; + void getInfoClearName(char*); + void getInfoClearValue(char*); + void getInfoClearWCS(char*); + Coord::Orientation getOrientation() {return orientation;} double getRotation() {return rotation + wcsRotation;} Coord::Orientation getWCSOrientation() {return wcsOrientation;} @@ -530,6 +528,7 @@ public: Base(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item); virtual ~Base(); + virtual FrameType frameType() =0; void calcAlignWCS(FitsImage*, Coord::CoordSystem, Coord::SkyFrame, Coord::Orientation*, Matrix*, double*); #ifndef NEWWCS @@ -553,9 +552,7 @@ public: int isBinTable(); virtual Vector mapFromRef(const Vector&, Coord::InternalSystem) =0; - virtual Vector3d mapFromRef3d(const Vector&, Coord::InternalSystem) =0; virtual Vector mapToRef(const Vector&, Coord::InternalSystem) =0; - virtual Vector3d mapToRef3d(const Vector&, Coord::InternalSystem) =0; double mapAngleFromRef(double,Coord::CoordSystem,Coord::SkyFrame =Coord::FK5); double mapAngleToRef(double, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5); @@ -1025,7 +1022,7 @@ public: // Info Commands void getInfoCmd(char*); - virtual void getInfoCmd(const Vector&, Coord::InternalSystem, char*); + virtual void getInfoCmd(const Vector&, Coord::InternalSystem, char*) =0; void getInfoClipCmd(); void getValueCmd(const Vector&, Coord::InternalSystem); diff --git a/tksao/frame/basecommand.C b/tksao/frame/basecommand.C index ef20eec..9909d21 100644 --- a/tksao/frame/basecommand.C +++ b/tksao/frame/basecommand.C @@ -1880,125 +1880,6 @@ void Base::getInfoCmd(char* var) getInfoClearWCS(var); } -void Base::getInfoCmd(const Vector& vv, Coord::InternalSystem ref, char* var) -{ - FitsBound* params; - int mosaic; - - Vector3d rr = mapToRef3d(vv,ref); - - // make sure we have an image - FitsImage* ptr = currentContext->cfits; - FitsImage* sptr = currentContext->cfits; - if (!ptr) - goto noFits; - - mosaic = isMosaic(); - params = sptr->getDataParams(currentContext->secMode()); - - if (!mosaic) { - Tcl_SetVar2(interp,var,"filename",(char*)sptr->getFileName(ROOTBASE),0); - Tcl_SetVar2(interp,var,"object",(char*)sptr->objectKeyword(),0); - Tcl_SetVar2(interp,var,"min",(char*)sptr->getMin(),0); - Tcl_SetVar2(interp,var,"min,x",(char*)sptr->getMinX(),0); - Tcl_SetVar2(interp,var,"min,y",(char*)sptr->getMinY(),0); - Tcl_SetVar2(interp,var,"max",(char*)sptr->getMax(),0); - Tcl_SetVar2(interp,var,"max,x",(char*)sptr->getMaxX(),0); - Tcl_SetVar2(interp,var,"max,y",(char*)sptr->getMaxY(),0); - Tcl_SetVar2(interp,var,"low",(char*)sptr->getLow(),0); - Tcl_SetVar2(interp,var,"high",(char*)sptr->getHigh(),0); - } - - if (((Vector&)vv)[0]<0 && ((Vector&)vv)[1]<0) - goto noImage; - - // clear values - Tcl_SetVar2(interp,var,"value","",0); - Tcl_SetVar2(interp,var,"value,red","",0); - Tcl_SetVar2(interp,var,"value,green","",0); - Tcl_SetVar2(interp,var,"value,blue","",0); - - do { - Vector img = Vector(rr) * sptr->refToData; - - if (img[0]>=params->xmin && img[0]<params->xmax && - img[1]>=params->ymin && img[1]<params->ymax) { - - if (mosaic) { - Tcl_SetVar2(interp,var,"filename",(char*)sptr->getFileName(ROOTBASE),0); - Tcl_SetVar2(interp,var,"object",(char*)sptr->objectKeyword(),0); - Tcl_SetVar2(interp,var,"min",(char*)sptr->getMin(),0); - Tcl_SetVar2(interp,var,"min,x",(char*)sptr->getMinX(),0); - Tcl_SetVar2(interp,var,"min,y",(char*)sptr->getMinY(),0); - Tcl_SetVar2(interp,var,"max",(char*)sptr->getMax(),0); - Tcl_SetVar2(interp,var,"max,x",(char*)sptr->getMaxX(),0); - Tcl_SetVar2(interp,var,"max,y",(char*)sptr->getMaxY(),0); - Tcl_SetVar2(interp,var,"low",(char*)sptr->getLow(),0); - Tcl_SetVar2(interp,var,"high",(char*)sptr->getHigh(),0); - } - - SETSIGBUS - Tcl_SetVar2(interp,var,"value",(char*)sptr->getValue(img),0); - CLEARSIGBUS - - coordToTclArray(sptr,rr,Coord::IMAGE,var,"image"); - // use first slice - coord3ToTclArray(ptr,rr,Coord::IMAGE,var,"image"); - - coordToTclArray(sptr,rr,Coord::PHYSICAL,var,"physical"); - // use first slice - coord3ToTclArray(ptr,rr,Coord::PHYSICAL,var,"physical"); - - if (hasATMV()) { - coordToTclArray(sptr,rr,Coord::AMPLIFIER,var,"amplifier"); - // use first slice - coord3ToTclArray(ptr,rr,Coord::AMPLIFIER,var,"amplifier"); - } - else { - Tcl_SetVar2(interp,var,"amplifier,x","",0); - Tcl_SetVar2(interp,var,"amplifier,y","",0); - Tcl_SetVar2(interp,var,"amplifier,z","",0); - } - - if (hasDTMV()) { - coordToTclArray(sptr,rr,Coord::DETECTOR,var,"detector"); - // use first slice - coord3ToTclArray(ptr,rr,Coord::DETECTOR,var,"detector"); - } - else { - Tcl_SetVar2(interp,var,"detector,x","",0); - Tcl_SetVar2(interp,var,"detector,y","",0); - Tcl_SetVar2(interp,var,"detector,z","",0); - } - - getInfoWCS(var,rr,ptr,sptr); - return; - } - else { - if (mosaic) { - sptr = sptr->nextMosaic(); - if (sptr) - params = sptr->getDataParams(currentContext->secMode()); - } - else { - getInfoWCS(var,rr,ptr,sptr); - goto noImage; - } - } - } - while (mosaic && sptr); - - // mosaic gap - getInfoWCS(var,rr,ptr,ptr); - - // else, return blanks - noFits: - getInfoClearName(var); - - noImage: - getInfoClearValue(var); -} - void Base::getInfoClipCmd() { if (currentContext->cfits) { diff --git a/tksao/frame/frame3dbase.C b/tksao/frame/frame3dbase.C index 47a4abf..e5e2416 100644 --- a/tksao/frame/frame3dbase.C +++ b/tksao/frame/frame3dbase.C @@ -9,6 +9,7 @@ #include "marker.h" #include "context.h" #include "ps.h" +#include "sigbus.h" Frame3dBase::Frame3dBase(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) : Base(i, c, item) @@ -57,6 +58,182 @@ Frame3dBase::~Frame3dBase() } +void Frame3dBase::getInfoCmd(const Vector& vv, Coord::InternalSystem ref, char* var) +{ + FitsBound* params; + int mosaic; + + Vector3d rr = mapToRef3d(vv,ref); + + // make sure we have an image + FitsImage* ptr = currentContext->cfits; + FitsImage* sptr = currentContext->cfits; + if (!ptr) + goto noFits; + + mosaic = isMosaic(); + params = sptr->getDataParams(currentContext->secMode()); + + if (!mosaic) { + Tcl_SetVar2(interp,var,"filename",(char*)sptr->getFileName(ROOTBASE),0); + Tcl_SetVar2(interp,var,"object",(char*)sptr->objectKeyword(),0); + Tcl_SetVar2(interp,var,"min",(char*)sptr->getMin(),0); + Tcl_SetVar2(interp,var,"min,x",(char*)sptr->getMinX(),0); + Tcl_SetVar2(interp,var,"min,y",(char*)sptr->getMinY(),0); + Tcl_SetVar2(interp,var,"max",(char*)sptr->getMax(),0); + Tcl_SetVar2(interp,var,"max,x",(char*)sptr->getMaxX(),0); + Tcl_SetVar2(interp,var,"max,y",(char*)sptr->getMaxY(),0); + Tcl_SetVar2(interp,var,"low",(char*)sptr->getLow(),0); + Tcl_SetVar2(interp,var,"high",(char*)sptr->getHigh(),0); + } + + if (((Vector&)vv)[0]<0 && ((Vector&)vv)[1]<0) + goto noImage; + + // clear values + Tcl_SetVar2(interp,var,"value","",0); + Tcl_SetVar2(interp,var,"value,red","",0); + Tcl_SetVar2(interp,var,"value,green","",0); + Tcl_SetVar2(interp,var,"value,blue","",0); + + do { + Vector img = Vector(rr) * sptr->refToData; + + if (img[0]>=params->xmin && img[0]<params->xmax && + img[1]>=params->ymin && img[1]<params->ymax) { + + if (mosaic) { + Tcl_SetVar2(interp,var,"filename",(char*)sptr->getFileName(ROOTBASE),0); + Tcl_SetVar2(interp,var,"object",(char*)sptr->objectKeyword(),0); + Tcl_SetVar2(interp,var,"min",(char*)sptr->getMin(),0); + Tcl_SetVar2(interp,var,"min,x",(char*)sptr->getMinX(),0); + Tcl_SetVar2(interp,var,"min,y",(char*)sptr->getMinY(),0); + Tcl_SetVar2(interp,var,"max",(char*)sptr->getMax(),0); + Tcl_SetVar2(interp,var,"max,x",(char*)sptr->getMaxX(),0); + Tcl_SetVar2(interp,var,"max,y",(char*)sptr->getMaxY(),0); + Tcl_SetVar2(interp,var,"low",(char*)sptr->getLow(),0); + Tcl_SetVar2(interp,var,"high",(char*)sptr->getHigh(),0); + } + + SETSIGBUS + Tcl_SetVar2(interp,var,"value",(char*)sptr->getValue(img),0); + CLEARSIGBUS + + coordToTclArray(sptr,rr,Coord::IMAGE,var,"image"); + // use first slice + coord3ToTclArray(ptr,rr,Coord::IMAGE,var,"image"); + + coordToTclArray(sptr,rr,Coord::PHYSICAL,var,"physical"); + // use first slice + coord3ToTclArray(ptr,rr,Coord::PHYSICAL,var,"physical"); + + if (hasATMV()) { + coordToTclArray(sptr,rr,Coord::AMPLIFIER,var,"amplifier"); + // use first slice + coord3ToTclArray(ptr,rr,Coord::AMPLIFIER,var,"amplifier"); + } + else { + Tcl_SetVar2(interp,var,"amplifier,x","",0); + Tcl_SetVar2(interp,var,"amplifier,y","",0); + Tcl_SetVar2(interp,var,"amplifier,z","",0); + } + + if (hasDTMV()) { + coordToTclArray(sptr,rr,Coord::DETECTOR,var,"detector"); + // use first slice + coord3ToTclArray(ptr,rr,Coord::DETECTOR,var,"detector"); + } + else { + Tcl_SetVar2(interp,var,"detector,x","",0); + Tcl_SetVar2(interp,var,"detector,y","",0); + Tcl_SetVar2(interp,var,"detector,z","",0); + } + + getInfoWCS(var,rr,ptr,sptr); + return; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + if (sptr) + params = sptr->getDataParams(currentContext->secMode()); + } + else { + getInfoWCS(var,rr,ptr,sptr); + goto noImage; + } + } + } + while (mosaic && sptr); + + // mosaic gap + getInfoWCS(var,rr,ptr,ptr); + + // else, return blanks + noFits: + getInfoClearName(var); + + noImage: + getInfoClearValue(var); +} + +void Frame3dBase::getInfoWCS(char* var, const Vector3d& rr, FitsImage* ptr, + FitsImage* sptr) +{ + Vector img = Vector(rr) * sptr->refToData; + + for (int ii=0; ii<MULTWCS; ii++) { + char buf[64]; + char ww = !ii ? '\0' : '`'+ii; + Coord::CoordSystem www = (Coord::CoordSystem)(Coord::WCS+ii); + + if (hasWCS(www)) { + char buff[128]; + Vector uu = img * dataToImage; + sptr->pix2wcs(uu, www, wcsSky_, wcsSkyFormat_, buff); + + int argc; + const char** argv; + Tcl_SplitList(interp, buff, &argc, &argv); + + if (argc > 0 && argv && argv[0]) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),argv[0],0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); + if (argc > 1 && argv && argv[1]) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),argv[1],0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); + // use first slice + coord3ToTclArray(ptr,rr,www,var,"wcs"); + + char* wcsname = (char*)sptr->getWCSName(www); + if (wcsname) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),wcsname,0); + else if (argc > 2 && argv && argv[2]) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),argv[2],0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); + + Tcl_Free((char*)argv); + } + else { + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",z"),"",0); + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); + } + } +} + +void Frame3dBase::coord3ToTclArray(FitsImage* ptr, const Vector3d& vv, + Coord::CoordSystem out, + const char* var, const char* base) +{ + double ss = ptr->mapFromRef3axis(((Vector3d&)vv)[2],out,2); + doubleToTclArray(ss, var, base, "z"); +} + void Frame3dBase::calcBorder(Coord::InternalSystem sys, FrScale::SecMode mode, Vector3d* vv, int* dd) { diff --git a/tksao/frame/frame3dbase.h b/tksao/frame/frame3dbase.h index aea15f8..9bf2985 100644 --- a/tksao/frame/frame3dbase.h +++ b/tksao/frame/frame3dbase.h @@ -90,6 +90,9 @@ class Frame3dBase : public Base { void calcBorder(Coord::InternalSystem, FrScale::SecMode mode, Vector3d* vv, int* dd); void calcHighlite(Coord::InternalSystem, Vector*, int*); + void coord3ToTclArray(FitsImage*, const Vector3d&, Coord::CoordSystem, + const char*, const char*); + void getInfoWCS(char*, const Vector3d&, FitsImage*, FitsImage*); protected: double calcZoomPanner(); @@ -97,6 +100,7 @@ class Frame3dBase : public Base { virtual void cancelDetach() =0; void centerImage(); + int isAzElZero() {return !az_ && !el_;} Vector3d imageCenter3d(FrScale::SecMode); @@ -132,6 +136,8 @@ class Frame3dBase : public Base { Frame3dBase(Tcl_Interp*, Tk_Canvas, Tk_Item*); virtual ~Frame3dBase(); + FrameType frameType() {return F3D;} + void setSlice(int,int); Vector mapFromRef(const Vector& vv, Coord::InternalSystem sys) @@ -152,6 +158,9 @@ class Frame3dBase : public Base { // Clip Commands void clipScopeCmd(FrScale::ClipScope) {} // scope is always GLOBAL + // Info Commands + void getInfoCmd(const Vector&, Coord::InternalSystem, char*); + // Coordinate Commands void getCursorCmd(Coord::InternalSystem); void getCursorCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat); diff --git a/tksao/frame/framebase.C b/tksao/frame/framebase.C index 8b1a25b..1c4ee1b 100644 --- a/tksao/frame/framebase.C +++ b/tksao/frame/framebase.C @@ -9,6 +9,7 @@ #include "marker.h" #include "context.h" #include "ps.h" +#include "sigbus.h" // Public @@ -36,6 +37,159 @@ FrameBase::~FrameBase() XFreeGC(display, colormapGCXOR); } +void FrameBase::getInfoCmd(const Vector& vv, Coord::InternalSystem ref, char* var) +{ + FitsBound* params; + int mosaic; + + Vector rr = mapToRef(vv,ref); + + // make sure we have an image + FitsImage* ptr = currentContext->cfits; + FitsImage* sptr = currentContext->cfits; + if (!ptr) + goto noFits; + + mosaic = isMosaic(); + params = sptr->getDataParams(currentContext->secMode()); + + if (!mosaic) { + Tcl_SetVar2(interp,var,"filename",(char*)sptr->getFileName(ROOTBASE),0); + Tcl_SetVar2(interp,var,"object",(char*)sptr->objectKeyword(),0); + Tcl_SetVar2(interp,var,"min",(char*)sptr->getMin(),0); + Tcl_SetVar2(interp,var,"min,x",(char*)sptr->getMinX(),0); + Tcl_SetVar2(interp,var,"min,y",(char*)sptr->getMinY(),0); + Tcl_SetVar2(interp,var,"max",(char*)sptr->getMax(),0); + Tcl_SetVar2(interp,var,"max,x",(char*)sptr->getMaxX(),0); + Tcl_SetVar2(interp,var,"max,y",(char*)sptr->getMaxY(),0); + Tcl_SetVar2(interp,var,"low",(char*)sptr->getLow(),0); + Tcl_SetVar2(interp,var,"high",(char*)sptr->getHigh(),0); + } + + if (((Vector&)vv)[0]<0 && ((Vector&)vv)[1]<0) + goto noImage; + + // clear values + Tcl_SetVar2(interp,var,"value","",0); + Tcl_SetVar2(interp,var,"value,red","",0); + Tcl_SetVar2(interp,var,"value,green","",0); + Tcl_SetVar2(interp,var,"value,blue","",0); + + do { + Vector img = rr * sptr->refToData; + + if (img[0]>=params->xmin && img[0]<params->xmax && + img[1]>=params->ymin && img[1]<params->ymax) { + + if (mosaic) { + Tcl_SetVar2(interp,var,"filename",(char*)sptr->getFileName(ROOTBASE),0); + Tcl_SetVar2(interp,var,"object",(char*)sptr->objectKeyword(),0); + Tcl_SetVar2(interp,var,"min",(char*)sptr->getMin(),0); + Tcl_SetVar2(interp,var,"min,x",(char*)sptr->getMinX(),0); + Tcl_SetVar2(interp,var,"min,y",(char*)sptr->getMinY(),0); + Tcl_SetVar2(interp,var,"max",(char*)sptr->getMax(),0); + Tcl_SetVar2(interp,var,"max,x",(char*)sptr->getMaxX(),0); + Tcl_SetVar2(interp,var,"max,y",(char*)sptr->getMaxY(),0); + Tcl_SetVar2(interp,var,"low",(char*)sptr->getLow(),0); + Tcl_SetVar2(interp,var,"high",(char*)sptr->getHigh(),0); + } + + SETSIGBUS + Tcl_SetVar2(interp,var,"value",(char*)sptr->getValue(img),0); + CLEARSIGBUS + + coordToTclArray(sptr,rr,Coord::IMAGE,var,"image"); + coordToTclArray(sptr,rr,Coord::PHYSICAL,var,"physical"); + if (hasATMV()) + coordToTclArray(sptr,rr,Coord::AMPLIFIER,var,"amplifier"); + else { + Tcl_SetVar2(interp,var,"amplifier,x","",0); + Tcl_SetVar2(interp,var,"amplifier,y","",0); + Tcl_SetVar2(interp,var,"amplifier,z","",0); + } + if (hasDTMV()) + coordToTclArray(sptr,rr,Coord::DETECTOR,var,"detector"); + else { + Tcl_SetVar2(interp,var,"detector,x","",0); + Tcl_SetVar2(interp,var,"detector,y","",0); + Tcl_SetVar2(interp,var,"detector,z","",0); + } + + getInfoWCS(var,rr,ptr,sptr); + return; + } + else { + if (mosaic) { + sptr = sptr->nextMosaic(); + if (sptr) + params = sptr->getDataParams(currentContext->secMode()); + } + else { + getInfoWCS(var,rr,ptr,sptr); + goto noImage; + } + } + } + while (mosaic && sptr); + + // mosaic gap + getInfoWCS(var,rr,ptr,ptr); + + // else, return blanks + noFits: + getInfoClearName(var); + + noImage: + getInfoClearValue(var); +} + +void FrameBase::getInfoWCS(char* var, const Vector& rr, FitsImage* ptr, + FitsImage* sptr) +{ + Vector img = Vector(rr) * sptr->refToData; + + for (int ii=0; ii<MULTWCS; ii++) { + char buf[64]; + char ww = !ii ? '\0' : '`'+ii; + Coord::CoordSystem www = (Coord::CoordSystem)(Coord::WCS+ii); + + if (hasWCS(www)) { + char buff[128]; + Vector uu = img * dataToImage; + sptr->pix2wcs(uu, www, wcsSky_, wcsSkyFormat_, buff); + + int argc; + const char** argv; + Tcl_SplitList(interp, buff, &argc, &argv); + + if (argc > 0 && argv && argv[0]) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),argv[0],0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); + if (argc > 1 && argv && argv[1]) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),argv[1],0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); + + char* wcsname = (char*)sptr->getWCSName(www); + if (wcsname) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),wcsname,0); + else if (argc > 2 && argv && argv[2]) + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),argv[2],0); + else + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); + + Tcl_Free((char*)argv); + } + else { + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",x"),"",0); + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",y"),"",0); + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",z"),"",0); + Tcl_SetVar2(interp,var,varcat(buf,(char*)"wcs",ww,(char*)",sys"),"",0); + } + } +} + double FrameBase::calcZoomPanner() { if (!(keyContext->fits && pannerPixmap)) diff --git a/tksao/frame/framebase.h b/tksao/frame/framebase.h index 5fef352..c7d26a3 100644 --- a/tksao/frame/framebase.h +++ b/tksao/frame/framebase.h @@ -23,6 +23,8 @@ protected: double calcZoomPanner(); void cancelDetach() {}; + void getInfoWCS(char*, const Vector&, FitsImage*, FitsImage*); + void rotateMotion(); void saveFitsResampleFits(OutFitsStream&); @@ -38,14 +40,13 @@ public: FrameBase(Tcl_Interp*, Tk_Canvas, Tk_Item*); virtual ~FrameBase(); + FrameType frameType() {return F2D;} void setSlice(int,int); Vector mapFromRef(const Vector&, Coord::InternalSystem); Vector3d mapFromRef3d(const Vector& vv, Coord::InternalSystem sys) {return mapFromRef(vv,sys);} Vector mapToRef(const Vector&, Coord::InternalSystem); - Vector3d mapToRef3d(const Vector& vv, Coord::InternalSystem sys) - {return mapToRef(vv,sys);} // Bin Commands void binToFitCmd(); @@ -61,6 +62,9 @@ public: void gridCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, Grid::GridType, const char*, const char*); + // Info Commands + void getInfoCmd(const Vector&, Coord::InternalSystem, char*); + // Fits Commands void saveFitsResample(OutFitsStream&); void saveFitsResampleFileCmd(const char*); diff --git a/tksao/frame/framergb.C b/tksao/frame/framergb.C index af243fd..deb8a84 100644 --- a/tksao/frame/framergb.C +++ b/tksao/frame/framergb.C @@ -1227,7 +1227,7 @@ void FrameRGB::getInfoCmd(const Vector& vv, Coord::InternalSystem ref, char* var FitsBound* params = sptr->getDataParams(context[ii].secMode()); do { - Vector3d rr = mapToRef3d(vv,ref); + Vector3d rr = mapToRef(vv,ref); Vector img = Vector(rr) * sptr->refToData; if (img[0]>=params->xmin && img[0]<params->xmax && diff --git a/tksao/frame/marker.C b/tksao/frame/marker.C index c31cc84..ca43585 100644 --- a/tksao/frame/marker.C +++ b/tksao/frame/marker.C @@ -5,6 +5,8 @@ #include <tk.h> #include "marker.h" +#include "framebase.h" +#include "frame3dbase.h" #include "fitsimage.h" extern "C" { @@ -1203,7 +1205,52 @@ Vector Marker::modifyArrow(const Vector& p1, const Vector& p2, return nn * Scale(ll-tip) * Translate(aa); } -Vector* Marker::arrow(const Vector& p1, const Vector& p2, Coord::InternalSystem sys) +Vector* Marker::arrow(const Vector& p1, const Vector& p2, + Coord::InternalSystem sys) +{ + switch (parent->frameType()) { + case Base::F2D: + return arrow2D(p1,p2,sys); + case Base::F3D: + return arrow3D(p1,p2,sys); + } +} + +Vector* Marker::arrow2D(const Vector& p1, const Vector& p2, + Coord::InternalSystem sys) +{ + Vector aa = ((FrameBase*)parent)->mapFromRef(p1,sys); + Vector bb = ((FrameBase*)parent)->mapFromRef(p2,sys); + + const int tip = 6; // length from end of line to tip of arrow + const int tail = 2; // length from end of line to tails of arrow + const int wc = 2; // width of arrow at end of line + const int wt = 3; // width of arrow at tails + + Vector vv[6]; + vv[0] = Vector(0, tip); + vv[1] = Vector(-wc, 0); + vv[2] = Vector(-wt, -tail); + vv[3] = Vector(0, 0); + vv[4] = Vector(wt, -tail); + vv[5] = Vector(wc, 0); + + Vector dd = (aa-bb).normalize(); + Matrix mm = Translate(0,-tip) * + Scale(1.5) * + Rotate(-M_PI/2) * + Rotate(-dd.angle()) * + Translate(bb); + + Vector* ww = new Vector[6]; + for (int ii=0; ii<6; ii++) + ww[ii] = vv[ii]*mm; + + return ww; +} + +Vector* Marker::arrow3D(const Vector& p1, const Vector& p2, + Coord::InternalSystem sys) { Vector p3; if (((p2-p1)[0]) == 0) @@ -1211,9 +1258,9 @@ Vector* Marker::arrow(const Vector& p1, const Vector& p2, Coord::InternalSystem else p3 = p1+Vector(0,1); - Vector3d aa = parent->mapFromRef3d(p1,sys); - Vector3d bb = parent->mapFromRef3d(p2,sys); - Vector3d cc = parent->mapFromRef3d(p3,sys); + Vector3d aa = ((Frame3dBase*)parent)->mapFromRef3d(p1,sys); + Vector3d bb = ((Frame3dBase*)parent)->mapFromRef3d(p2,sys); + Vector3d cc = ((Frame3dBase*)parent)->mapFromRef3d(p3,sys); const int tip = 6; // length from end of line to tip of arrow const int tail = 2; // length from end of line to tails of arrow diff --git a/tksao/frame/marker.h b/tksao/frame/marker.h index 6f5846d..82cc798 100644 --- a/tksao/frame/marker.h +++ b/tksao/frame/marker.h @@ -43,6 +43,10 @@ public: enum AnalysisTask {STATS,PLOT2D,PLOT3D,RADIAL,PANDA,HISTOGRAM}; enum AnalysisMethod {SUM,AVERAGE}; + private: + Vector* arrow2D(const Vector&, const Vector&, Coord::InternalSystem); + Vector* arrow3D(const Vector&, const Vector&, Coord::InternalSystem); + protected: int id; char type_[64]; |