summaryrefslogtreecommitdiffstats
path: root/tksao/colorbar/lut.h
blob: 8b8bdf34f897546554a8956490146320d3eaaf7f (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (C) 1999-2018
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#ifndef __lut_h__
#define __lut_h__

#include "colormap.h"
#include "list.h"

// RGBColor
class RGBColor {
private:
  float red_;
  float green_;
  float blue_;
  RGBColor* next_;
  RGBColor* previous_;

public:
  RGBColor() {red_=green_=blue_=0;}
  RGBColor(float r, float g, float b) {red_=r; green_=g; blue_=b;}
  RGBColor(const RGBColor& a) {
    red_=a.red_; green_=a.green_; blue_=a.blue_; 
    next_=a.next_; previous_=a.previous_;
  }
  RGBColor& operator=(const RGBColor& a) {
    red_=a.red_; green_=a.green_; blue_=a.blue_; 
    next_=a.next_; previous_=a.previous_; return *this;
  }

  RGBColor* next() 
  {return next_;}
  RGBColor* previous()
  {return previous_;}
  void setNext(RGBColor* n) 
  {next_ = n;}
  void setPrevious(RGBColor* p)
  {previous_=p;}

  float red() {return red_;}
  float green() {return green_;}
  float blue() {return blue_;}

  friend istream& operator>>(istream&, RGBColor&);
  friend ostream& operator<<(ostream&, RGBColor&);
};

// LUTColorMap
class LUTColorMap : public ColorMapInfo {
protected:
  List<RGBColor> colors;

public:
  LUTColorMap(Colorbar* p);

  ColorMapInfo* dup() {return new LUTColorMap(*this);}
  int load();
  int load(const char* var);
  void save(const char*);

  unsigned char getRedChar(int, int);
  unsigned char getGreenChar(int, int);
  unsigned char getBlueChar(int, int);

  unsigned short getRedShrt(int, int);
  unsigned short getGreenShrt(int, int);
  unsigned short getBlueShrt(int, int);

  void newRGBColor(float,float,float);

  friend ostream& operator<<(ostream&, LUTColorMap&);
};

#endif