MorphoGraphX  2.0-1-227
ColorMap.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2016 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef COLOR_MAP_HPP
12 #define COLOR_MAP_HPP
13 
14 #include <Config.hpp>
15 #include <Color.hpp>
16 
17 namespace mgx
18 {
21 
22  class mgx_EXPORT ColorMap
23  {
24  public:
25  ColorMap(std::vector<Colorb> *cols, Point2f *bnds)
26  : colorsP(cols), boundsP(bnds) {}
27  ColorMap(std::vector<Colorb> *cols)
28  : colorsP(cols), boundsP(0) {}
29 
31  Colorb getColor(int index) const;
33  Colorb getColor(float s, float sBegin, float sEnd, int iBegin, int iEnd) const;
34  Colorb getColor(float s, float sBegin, float sEnd) const;
35  Colorb getColor(float s, int iBegin, int iEnd) const;
36  Colorb getColor(float s) const;
37 
39  bool setColorMap(const QString &map, uint sz = 0);
41  QStringList getColorMapList() const;
43  bool hasBounds() const { return boundsP != 0; }
44 
45  std::vector<Colorb> &colors() { return *colorsP; }
46  const std::vector<Colorb> &colors() const { return *colorsP; }
47  Point2f &bounds() { return hasBounds() ? *boundsP : dummyBounds; }
48  const Point2f &bounds() const { return hasBounds() ? *boundsP : dummyBounds; }
49 
50  private:
51  std::vector<Colorb> *colorsP;
52  Point2f *boundsP;
53  Point2f dummyBounds;
54  };
55 }
56 
57 #endif
mgx::uint
unsigned int uint
Definition: Geometry.hpp:41
mgx::ColorMap::hasBounds
bool hasBounds() const
Does Color Map have bounds.
Definition: ColorMap.hpp:43
mgx::Point4f
Vector< 4, float > Point4f
Definition: ColorMap.hpp:20
mgx::ColorMap::bounds
Point2f & bounds()
Definition: ColorMap.hpp:47
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::ColorMap
Definition: ColorMap.hpp:22
mgx::ColorMap::colors
const std::vector< Colorb > & colors() const
Definition: ColorMap.hpp:46
mgx::ColorMap::colors
std::vector< Colorb > & colors()
Definition: ColorMap.hpp:45
mgx::Point2f
Vector< 2, float > Point2f
Definition: ColorMap.hpp:19
mgx::Vector< 2, float >
Color.hpp
mgx::Color
A utility class to encapsulate color data.
Definition: Color.hpp:34
mgx::ColorMap::bounds
const Point2f & bounds() const
Definition: ColorMap.hpp:48
mgx::ColorMap::ColorMap
ColorMap(std::vector< Colorb > *cols)
Definition: ColorMap.hpp:27
mgx::ColorMap::ColorMap
ColorMap(std::vector< Colorb > *cols, Point2f *bnds)
Definition: ColorMap.hpp:25
mgx::map
CU_HOST_DEVICE Vector< dim, T > map(const T &(*fct)(const T1 &), const Vector< dim, T1 > &v)
Definition: Vector.hpp:1380