From 2e35c65a9a47731269c39522a6e53af9181bcbdd Mon Sep 17 00:00:00 2001 From: William Joye Date: Thu, 25 Oct 2018 13:12:34 -0400 Subject: new mask --- tksao/frame/base.h | 2 +- tksao/frame/context.C | 2 +- tksao/frame/fitsmask.h | 2 ++ tksao/frame/frame.C | 58 ++++++++++++++++++++++++++++++++++++++++++++++---- tksao/frame/frame.h | 2 ++ tksao/frame/framergb.C | 13 ++--------- tksao/frame/framergb.h | 1 - 7 files changed, 62 insertions(+), 18 deletions(-) diff --git a/tksao/frame/base.h b/tksao/frame/base.h index 0450ffc..17f9cea 100644 --- a/tksao/frame/base.h +++ b/tksao/frame/base.h @@ -379,7 +379,7 @@ public: virtual int isFrameRGB() {return 0;} virtual void loadDone(int, LayerType); - void loadDone(int); + virtual void loadDone(int); void markerAnalysisHistogram(Marker*, double**, double**, const BBox&, int); int markerAnalysisPlot2d(Marker*, double**, double**, double**, double**, diff --git a/tksao/frame/context.C b/tksao/frame/context.C index 9ed4018..e900df4 100644 --- a/tksao/frame/context.C +++ b/tksao/frame/context.C @@ -1421,7 +1421,7 @@ int Context::loadMosaicWFPC2(Base::MemType which, const char* fn, ptr->wfpc2WCS(istr); Matrix mm = parent_->calcAlignWCS(bfits_, ptr, Coord::WCS, - Coord::WCS, Coord::FK5); + Coord::WCS, Coord::FK5); ptr->setwcsToRef(mm); ptr = ptr->nextMosaic(); diff --git a/tksao/frame/fitsmask.h b/tksao/frame/fitsmask.h index 393e987..88a9b2a 100644 --- a/tksao/frame/fitsmask.h +++ b/tksao/frame/fitsmask.h @@ -13,6 +13,7 @@ class Context; class FitsMask { private: Context* context_; + Matrix mm_; char* colorName_; XColor* color_; @@ -29,6 +30,7 @@ class FitsMask { virtual ~FitsMask(); Context* context() {return context_;} + Matrix& mm() {return mm_;} XColor* color() {return color_;} char* trueColor() {return trueColor_;} int mark() {return mark_;} diff --git a/tksao/frame/frame.C b/tksao/frame/frame.C index 38f5175..119e63d 100644 --- a/tksao/frame/frame.C +++ b/tksao/frame/frame.C @@ -291,7 +291,7 @@ void Frame::pushMatrices() // now any masks FitsMask* msk = mask.tail(); while (msk) { - Base::pushMatrices(msk->context()->fits, rgbToRef); + Base::pushMatrices(msk->context()->fits, msk->mm()); msk = msk->previous(); } } @@ -356,6 +356,51 @@ void Frame::updateColorCells(unsigned char* cells, int cnt) memcpy(colorCells, cells, cnt*3); } +void Frame::updateMaskMatrices() +{ + // image,pysical,amplifier,detector are ok, check for wcs + if (maskSystem >= Coord::WCS) { + FitsMask* mptr = mask.head(); + while (mptr) { + if (mptr->context()->fits && !mptr->context()->fits->hasWCS(maskSystem)) { + maskSystem = Coord::IMAGE; + break; + } + mptr = mptr->next(); + } + } + + // mask align + FitsMask* mptr = mask.head(); + while (mptr) { + mptr->mm().identity(); + if (mptr->context()->fits) { + switch (maskSystem) { + case Coord::IMAGE: + // nothing to do here + break; + case Coord::PHYSICAL: + mptr->mm() = mptr->context()->fits->imageToPhysical * + keyContext->fits->physicalToImage; + break; + case Coord::AMPLIFIER: + mptr->mm() = mptr->context()->fits->imageToAmplifier * + keyContext->fits->amplifierToImage; + break; + case Coord::DETECTOR: + mptr->mm() = mptr->context()->fits->imageToDetector * + keyContext->fits->detectorToImage; + break; + default: + mptr->mm() = + calcAlignWCS(keyContext->fits, mptr->context()->fits, maskSystem, maskSystem, Coord::FK5); + break; + } + } + mptr = mptr->next(); + } +} + void Frame::unloadFits() { if (DebugPerf) @@ -681,12 +726,10 @@ void Frame::getTypeCmd() void Frame::iisCmd(int width, int height) { unloadAllFits(); - context->setIIS(); FitsImage* img = new FitsImageIIS(currentContext, interp, width, height); - - loadDone(currentContext->load(ALLOC, "", img), IMG); + loadDone(currentContext->load(ALLOC, "", img)); } void Frame::iisEraseCmd() @@ -992,3 +1035,10 @@ void Frame::loadFitsVarCmd(const char* ch, const char* fn, LayerType ll) break; } } + +void Frame::loadDone(int rr) +{ + if (rr) + updateMaskMatrices(); + Base::loadDone(rr); +} diff --git a/tksao/frame/frame.h b/tksao/frame/frame.h index 8ea57ff..2f981b1 100644 --- a/tksao/frame/frame.h +++ b/tksao/frame/frame.h @@ -49,6 +49,8 @@ class Frame : public FrameBase { unsigned char* fillMask(FitsMask*, int, int, Coord::InternalSystem); int validColorScale() {return colorScale ? 1 : 0;} void updateColorCells(unsigned char*, int); + void updateMaskMatrices(); + void loadDone(int); public: Frame(Tcl_Interp*, Tk_Canvas, Tk_Item*); diff --git a/tksao/frame/framergb.C b/tksao/frame/framergb.C index 2d2c5a8..1bbaeed 100644 --- a/tksao/frame/framergb.C +++ b/tksao/frame/framergb.C @@ -709,16 +709,6 @@ void FrameRGB::reset() Base::reset(); } -void FrameRGB::rgbAlignWCS(int ii) -{ - if (keyContext->fits && keyContext->fits->hasWCS(rgbSystem)) - rgb[ii] = calcAlignWCS(keyContext->fits, context[ii].fits, rgbSystem, - rgbSystem, Coord::FK5); - - if (DebugRGB) - cerr << "rgbAlignWCS " << rgb[ii] << endl; -} - void FrameRGB::setBinCursor() { for (int ii=0; ii<3; ii++) @@ -839,7 +829,8 @@ void FrameRGB::updateRGBMatrices() keyContext->fits->detectorToImage; break; default: - rgbAlignWCS(ii); + if (keyContext->fits->hasWCS(rgbSystem)) + rgb[ii] = calcAlignWCS(keyContext->fits, context[ii].fits, rgbSystem, rgbSystem, Coord::FK5); break; } } diff --git a/tksao/frame/framergb.h b/tksao/frame/framergb.h index a862636..19819a9 100644 --- a/tksao/frame/framergb.h +++ b/tksao/frame/framergb.h @@ -43,7 +43,6 @@ class FrameRGB : public FrameBase { void loadRGBFinish(); void reset(); - void rgbAlignWCS(int); void setBinCursor(); void setKeyFits(); -- cgit v0.12