summaryrefslogtreecommitdiffstats
path: root/tksao/frame/fitsmask.C
blob: 6f0a74d15aaeb6184b20eec0576872a131462bf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (C) 1999-2017
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#include <tk.h>

#include "fitsmask.h"
#include "base.h"
#include "fitsimage.h"

FitsMask::FitsMask(Base* p, FitsImage* fits, char* clr, int mrk) 
  : parent_(p), mask_(fits)
{
  current_ = mask_;
  mptr_ = current_;
  colorName_ = dupstr(clr);
  color_ = parent_->getXColor(colorName_);
  parent_->encodeTrueColor(color_, trueColor_);
  mark_ = mrk;

  next_ = NULL;
  previous_ = NULL;
}

FitsMask::~FitsMask()
{
  if (colorName_)
    delete [] colorName_;

  FitsImage* ptr = mask_;
  while (ptr) {
    // better not have more that one slice
    FitsImage* sptr = ptr->nextSlice();
    while (sptr) {
      FitsImage* stmp = sptr->nextSlice();
      delete sptr;
      sptr = stmp;
    }

    FitsImage* tmp = ptr->nextMosaic();
    delete ptr;
    ptr = tmp;
  }
}

void FitsMask::nextMosaic() {
  if (mptr_) 
    mptr_ = mptr_->nextMosaic();
}