MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ColorMap.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  ColorMap.h Color mapping system
3  Copyright (C) 2014 The Regents of the University of New Mexico. All rights reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
27 #ifndef COLORMAP_H /* -*- C++ -*- */
28 #define COLORMAP_H
29 
30 #include "itype.h"
31 
32 namespace MFM
33 {
44  class ColorMap
45  {
46  public:
53  u32 GetSelectedColor(float value, float min, float max, u32 badColor) const;
54 
61  u32 GetInterpolatedColor(float value, float min, float max, u32 badColor) const;
62 
68  static u32 GetMapCount();
69 
77  static ColorMap & GetMap(u32 index);
78 
79  private:
80  virtual const u32 * GetColorArray() const = 0;
81  virtual const char * GetName() const = 0;
82  virtual u32 GetColorArrayLength() const = 0;
83  };
84 
85 
86 #define XXB(NAME) \
87  \
89  class ColorMap_##NAME : public ColorMap { \
90  virtual const char * GetName() const ; \
91  virtual const u32 * GetColorArray() const ; \
92  virtual u32 GetColorArrayLength() const ; \
93  public: \
94  static ColorMap_##NAME THE_INSTANCE; \
95  };
96 #define XX5(T,N,M1,M2,M3,M4,M5) \
97  XXB(T##5_##N)
98 #define XX6(T,N,M1,M2,M3,M4,M5,M6) \
99  XXB(T##6_##N)
100 
101 // A Dave Green 'cubehelix' map
102 // # Tue Jul 29 2014 05:04:08 GMT-0600 (MDT)
103 // # ---------------------------------------------
104 // # HEX R/G/B cubehelix colour scheme
105 // #
106 // # see http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/
107 // #----------------------------------------------
108 // # see Green (2011), BASI, 39, 289.
109 // #
110 // # start............: 0.5
111 // # rotations........: -1.5
112 // # hue..............: 1.4
113 // # gamma............: 1.0
114 // # number of levels.: 32
115 // #----------------------------------------------
116 // # Dave Green: dag@mrao.cam.ac.uk
117 // #----------------------------------------------
118 XXB(CubeHelix)
119 
120 // # Tue Jul 29 2014 05:36:46 GMT-0600 (MDT)
121 // # ---------------------------------------------
122 // # HEX R/G/B cubehelix colour scheme
123 // #
124 // # see http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/
125 // #----------------------------------------------
126 // # see Green (2011), BASI, 39, 289.
127 // #
128 // # start............: 0.5
129 // # rotations........: -1
130 // # hue..............: 2.0
131 // # gamma............: 1.0
132 // # number of levels.: 32
133 // # (flipped white to black)
134 // #----------------------------------------------
135 // # Dave Green: dag@mrao.cam.ac.uk
136 // #----------------------------------------------
137 
138 XXB(CubeHelixRev)
139 
140 #include "ColorMaps.h"
141 
142 #undef XXB
143 #undef XX5
144 #undef XX6
145 
146 } /* namespace MFM */
147 
148 #endif /*COLORMAP_H*/
u32 GetInterpolatedColor(float value, float min, float max, u32 badColor) const
Definition: ColorMap.cpp:161
u32 GetSelectedColor(float value, float min, float max, u32 badColor) const
Definition: ColorMap.cpp:146
static u32 GetMapCount()
Definition: ColorMap.cpp:21
Definition: ColorMap.h:44
static ColorMap & GetMap(u32 index)
Definition: ColorMap.cpp:42