summaryrefslogtreecommitdiffstats
path: root/tksao
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-08-18 18:54:37 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-08-18 18:54:37 (GMT)
commit5597764b8eea8a9d1222347c1c8c170f5ca90d97 (patch)
tree9f12d489d2285272c8395140c2443948a575aa66 /tksao
parent7da217d72bef995f506959b027cbf543c02eaa6a (diff)
downloadblt-5597764b8eea8a9d1222347c1c8c170f5ca90d97.zip
blt-5597764b8eea8a9d1222347c1c8c170f5ca90d97.tar.gz
blt-5597764b8eea8a9d1222347c1c8c170f5ca90d97.tar.bz2
simplify crop code
Diffstat (limited to 'tksao')
-rw-r--r--tksao/frame/basecommand.C34
-rw-r--r--tksao/frame/fitsimage.h3
-rw-r--r--tksao/frame/fitsmap.C25
3 files changed, 15 insertions, 47 deletions
diff --git a/tksao/frame/basecommand.C b/tksao/frame/basecommand.C
index 9c06a62..49e65c0 100644
--- a/tksao/frame/basecommand.C
+++ b/tksao/frame/basecommand.C
@@ -553,29 +553,31 @@ void Base::crop3dCmd()
}
void Base::crop3dCmd(double z0, double z1, Coord::CoordSystem sys,
- Coord::SkyFrame)
+ Coord::SkyFrame sky)
{
// params in DATA coords 0-n
-
// use first slice
FitsImage* ptr = currentContext->fits;
if (!ptr)
return;
- // ff/tt in data coords
- double ff = ptr->mapToImage3d(z0,sys)-.5;
- double tt = ptr->mapToImage3d(z1,sys)-.5;
+ // center in IMAGE
+ Vector3d cc = Vector3d(ptr->center(),1) * Translate3d(-.5,-.5,-.5);
+ Vector3d wcc = ptr->mapFromRef(cc,sys,sky);
+ Vector3d min = ptr->mapToRef(Vector3d(wcc[0],wcc[1],z0),sys,sky);
+ Vector3d max = ptr->mapToRef(Vector3d(wcc[0],wcc[1],z1),sys,sky);
- currentContext->setCrop3dParams(ff-.5,tt+.5);
+ // extend to edge from center
+ currentContext->setCrop3dParams(min[2]-.5,max[2]+.5);
// set current slice if needed
// setSlice() IMAGE (ranges 1-n)
// context->slice() IMAGE (ranges 1-n)
double sl = currentContext->slice(2)-.5;
- if (sl<ff)
- setSlice(2,ff+.5);
- if (sl>tt)
- setSlice(2,tt+.5);
+ if (sl<min[2])
+ setSlice(2,min[2]+.5);
+ if (sl>max[2])
+ setSlice(2,max[2]+.5);
currentContext->setSecMode(FrScale::CROPSEC);
@@ -1422,17 +1424,11 @@ void Base::getCrop3dCmd(Coord::CoordSystem sys, Coord::SkyFrame sky)
// need to move from edge to center of pixel
Vector3d rmax =
Vector3d(ptr->center(),zparams->zmax) * Translate3d(-.5,-.5,-.5);
- Vector3d wmin = ptr->mapFromRef(rmin,sys,sky);
- Vector3d wmax = ptr->mapFromRef(rmax,sys,sky);
-
- double ff = ptr->mapFromImage3d(zparams->zmin+.5+.5,sys);
- double tt = ptr->mapFromImage3d(zparams->zmax-.5+.5,sys);
-
- cerr << wmin[2] << '=' << ff << endl;
- cerr << wmax[2] << '=' << tt << endl;
+ Vector3d min = ptr->mapFromRef(rmin,sys,sky);
+ Vector3d max = ptr->mapFromRef(rmax,sys,sky);
ostringstream str;
- str << ff << ' ' << tt << ends;
+ str << min[2] << ' ' << max[2] << ends;
Tcl_AppendResult(interp, str.str().c_str(), NULL);
}
diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h
index 5ae1afc..c949167 100644
--- a/tksao/frame/fitsimage.h
+++ b/tksao/frame/fitsimage.h
@@ -441,9 +441,6 @@ class FitsImage {
Vector mapToRef(const Vector&, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5);
Vector3d mapToRef(const Vector3d&, Coord::CoordSystem, Coord::SkyFrame =Coord::FK5);
- double mapFromImage3d(double, Coord::CoordSystem);
- double mapToImage3d(double, Coord::CoordSystem);
-
double mapLenFromRef(double, Coord::CoordSystem, Coord::DistFormat =Coord::DEGREE);
Vector mapLenFromRef(const Vector&, Coord::CoordSystem, Coord::DistFormat =Coord::DEGREE);
double mapLenToRef(double, Coord::CoordSystem, Coord::DistFormat =Coord::DEGREE);
diff --git a/tksao/frame/fitsmap.C b/tksao/frame/fitsmap.C
index 97708ac..a1434d1 100644
--- a/tksao/frame/fitsmap.C
+++ b/tksao/frame/fitsmap.C
@@ -476,28 +476,3 @@ void FitsImage::listDistFromRef(ostream& str,
str << "0 0";
}
}
-
-// 3D
-
-double FitsImage::mapFromImage3d(double dd, Coord::CoordSystem sys)
-{
- if (hasWCS(sys)) {
- Vector3d cc(center(),dd);
- Vector3d rr = pix2wcs(cc,sys,Coord::FK5);
- return rr[2];
- }
- else
- return dd;
-}
-
-double FitsImage::mapToImage3d(double dd, Coord::CoordSystem sys)
-{
- if (hasWCS(sys)) {
- Vector3d cc(center(),1);
- Vector3d wcc = pix2wcs(cc,sys,Coord::FK5);
- Vector3d rr = wcs2pix(Vector3d(wcc[0],wcc[1],dd),sys,Coord::FK5);
- return rr[2];
- }
- else
- return dd;
-}