casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtPCColorTable.h
Go to the documentation of this file.
1 #if !defined(QTPCCOLORTABLE_H)
2 #define QTPCCOLORTABLE_H
3 
4 #include <vector>
5 
6 #include <casa/aips.h>
7 
8 #include <casa/Arrays/Vector.h>
9 #include <casa/Arrays/Matrix.h>
12 #include <casa/BasicMath/Math.h>
13 
14 #include <graphics/X11/X_enter.h>
15 #include <QImage>
16 #include <QColor>
17 #include <graphics/X11/X_exit.h>
18 
19 namespace casa {
20 
22 
23  public:
24 
26  virtual ~QtPCColorTable() { }
27 
28 
29  //# only-vaguely-informative boilerplate...
30 
32  return true;
33  }
34 
35  virtual casacore::Bool resize(casacore::uInt /*nReds*/, casacore::uInt /*nGreens*/, casacore::uInt /*nBlues*/) {
36  return false;
37  }
38 
39  virtual void nColors(casacore::uInt &n1, casacore::uInt &n2, casacore::uInt &n3) const {
40  n1 = 256;
41  n2 = 256;
42  n3 = 256;
43  }
44 
45  virtual casacore::uInt depth() const {
46  return 32;
47  }
48  // The non-indexed 'true' color depth that Qt supports, and
49  // the number of bits in a Qrgb. This includes room for the
50  // alpha channel (yay). FYI, component byte order in Qrgb
51  // (most- to least-significant) is A-R-G-B.
52 
53  virtual Display::ColorModel colorModel() const {
54  return Display::Index;
55  }
56 
57 
58 # define MAX_QTPCCT_SIZE 5000u
59  // maximum color slots this colortable can hold (distributed
60  // among its colormaps). Could be expanded a lot, but it's
61  // probably unnecessary.
62 
63 # define INITIAL_QTPCCT_SIZE 256u
64  // Initial size of the colortable.
65 
66  virtual casacore::uInt nColors() const {
67  return size_;
68  }
69  // Current number of slots usable by colormaps.
70  // can be expanded at runtime up to MAX_QTPCCT_SIZE.
71 
72  virtual casacore::uInt nSpareColors() const {
73  return MAX_QTPCCT_SIZE - size_;
74  }
75 
76  virtual casacore::Bool resize(casacore::uInt newSize);
77 
78  // Called by corresp. ColormapManager to actually fill color slots
79  // for the Colormaps. r,g,b ahould be in range [0,1].
84  casacore::uInt offset = 0);
85 
86  // Translate casacore::Array of colormap indices into graphics platform's colors.
87 
88  //# The version actually used...
89  virtual void mapToColor(const Colormap * map,
91  const casacore::Array<casacore::uInt> & inArray,
92  casacore::Bool rangeCheck = true) const;
93 
94 
95  //# The one of these really needed when/if non-Index (3-channel)
96  // ColorModels are implemented for QtPixelCanvas.
98  const casacore::Array<casacore::uInt> & /*chan1in*/,
99  const casacore::Array<casacore::uInt> & /*chan2in*/,
100  const casacore::Array<casacore::uInt> & /*chan3in*/) { }
101 
102 
103  //# irrelevant, unused versions:
104  virtual void mapToColor(const Colormap * /*map*/,
105  casacore::Array<casacore::uChar> & /*outArray*/,
106  const casacore::Array<casacore::uChar> & /*inArray*/,
107  casacore::Bool /*rangeCheck*/ = true) const { }
108 
109  virtual void mapToColor(const Colormap * /*map*/,
110  casacore::Array<casacore::uShort> & /*outArray*/,
111  const casacore::Array<casacore::uShort> & /*inArray*/,
112  casacore::Bool /*rangeCheck*/ = true) const { }
113 
114  virtual void mapToColor(const Colormap * /*map*/,
115  casacore::Array<casacore::uLong> & /*outArray*/,
116  const casacore::Array<casacore::uLong> & /*inArray*/,
117  casacore::Bool /*rangeCheck*/ = true) const { }
118 
119  virtual void mapToColor(const Colormap * /*map*/,
120  casacore::Array<casacore::uChar> & /*inOutArray*/,
121  casacore::Bool /*rangeCheck*/ = true) const { }
122 
123  virtual void mapToColor(const Colormap * /*map*/,
124  casacore::Array<casacore::uShort> & /*inOutArray*/,
125  casacore::Bool /*rangeCheck*/ = true) const { }
126 
127  virtual void mapToColor(const Colormap * /*map*/,
128  casacore::Array<casacore::uInt> & /*inOutArray*/,
129  casacore::Bool /*rangeCheck*/ = true) const { }
130 
131  virtual void mapToColor(const Colormap * /*map*/,
132  casacore::Array<casacore::uLong> & /*inOutArray*/,
133  casacore::Bool /*rangeCheck*/ = true) const { }
134 
136  const casacore::Array<casacore::Float> & /*chan1in*/,
137  const casacore::Array<casacore::Float> & /*chan2in*/,
138  const casacore::Array<casacore::Float> & /*chan3in*/) { }
140  const casacore::Array<casacore::Double> & /*chan1in*/,
141  const casacore::Array<casacore::Double> & /*chan2in*/,
142  const casacore::Array<casacore::Double> & /*chan3in*/) { }
143 
145  const casacore::Array<casacore::uShort> & /*chan1in*/,
146  const casacore::Array<casacore::uShort> & /*chan2in*/,
147  const casacore::Array<casacore::uShort> & /*chan3in*/) { }
148 
150  const casacore::Array<casacore::Float> & /*chan1in*/,
151  const casacore::Array<casacore::Float> & /*chan2in*/,
152  const casacore::Array<casacore::Float> & /*chan3in*/,
153  casacore::Array<casacore::Float> & /*chan1out*/,
154  casacore::Array<casacore::Float> & /*chan2out*/,
155  casacore::Array<casacore::Float> & /*chan3out*/) {
156  return false;
157  }
158  // (could move X11 version down to base class and use
159  // that -- it has no X11 dependencies...)
160 
161  protected:
162 
164  return casacore::Int(casacore::min( casacore::max(0.f,f)*256.f, 255.f ));
165  }
166  // translate color component in the range [0., 1.]
167  // to clrByte, with 0 <= clrByte < 256
168 
169  private:
170 
172  // actual storage for the color slots.
174  // Current size of the colortable; number of slots usable by colormaps.
175  // can be expanded at runtime, up to MAX_QTPCCT_SIZE.
176 
177 
178  };
179 
180 
181 }
182 #endif
int Int
Definition: aipstype.h:50
Abstract interface to underlying graphics library&#39;s colortable.
virtual void mapToColor(const Colormap *, casacore::Array< casacore::uInt > &, casacore::Bool=true) const
virtual Display::ColorModel colorModel() const
The non-indexed &#39;true&#39; color depth that Qt supports, and the number of bits in a Qrgb.
virtual casacore::uInt depth() const
Return the depth of the map in bits.
virtual void mapToColor(const Colormap *, casacore::Array< casacore::uChar > &, const casacore::Array< casacore::uChar > &, casacore::Bool=true) const
map [0,N-1] into colorpixels, where N is the current colormap size The values are returned as unsigne...
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
virtual casacore::Bool resize(casacore::uInt, casacore::uInt, casacore::uInt)
virtual casacore::Bool staticSize()
Is the hardware colormap resizeable? ie.
virtual void mapToColor(const Colormap *, casacore::Array< casacore::uLong > &, casacore::Bool=true) const
casacore::uInt size_
actual storage for the color slots.
#define MAX_QTPCCT_SIZE
virtual void mapToColor(const Colormap *, casacore::Array< casacore::uChar > &, casacore::Bool=true) const
same as above except the matrix is operated on in place.
casacore::Int clrByte(casacore::Float f)
(could move X11 version down to base class and use that – it has no X11 dependencies...)
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
virtual void mapToColor3(casacore::Array< casacore::uLong > &, const casacore::Array< casacore::Float > &, const casacore::Array< casacore::Float > &, const casacore::Array< casacore::Float > &)
Functions for dealing with multi-channel mapping.
virtual casacore::Bool colorSpaceMap(Display::ColorModel, const casacore::Array< casacore::Float > &, const casacore::Array< casacore::Float > &, const casacore::Array< casacore::Float > &, casacore::Array< casacore::Float > &, casacore::Array< casacore::Float > &, casacore::Array< casacore::Float > &)
(Multichannel Color) Transform arrays from the passed color model into the colormodel of the XPCCT...
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void mapToColor3(casacore::Array< casacore::uLong > &, const casacore::Array< casacore::uShort > &, const casacore::Array< casacore::uShort > &, const casacore::Array< casacore::uShort > &)
This one maps values between 0 and the integer maximum value for each channel into a single output im...
casacore::Vector< casacore::uInt > maps_
translate color component in the range [0., 1.
float Float
Definition: aipstype.h:54
virtual void nColors(casacore::uInt &n1, casacore::uInt &n2, casacore::uInt &n3) const
Return the number of colors per component used in the map.
virtual void mapToColor3(casacore::Array< casacore::uLong > &, const casacore::Array< casacore::uInt > &, const casacore::Array< casacore::uInt > &, const casacore::Array< casacore::uInt > &)
ColorModels are implemented for QtPixelCanvas.
Describes a method of generating a table of colors.
Definition: Colormap.h:104
virtual casacore::Bool installRGBColors(const casacore::Vector< casacore::Float > &r, const casacore::Vector< casacore::Float > &g, const casacore::Vector< casacore::Float > &b, const casacore::Vector< casacore::Float > &alpha, casacore::uInt offset=0)
Called by corresp.
virtual void mapToColor(const Colormap *, casacore::Array< casacore::uShort > &, casacore::Bool=true) const
virtual void mapToColor(const Colormap *map, casacore::Array< casacore::uInt > &outArray, const casacore::Array< casacore::uInt > &inArray, casacore::Bool rangeCheck=true) const
Translate casacore::Array of colormap indices into graphics platform&#39;s colors.
virtual void mapToColor(const Colormap *, casacore::Array< casacore::uLong > &, const casacore::Array< casacore::uLong > &, casacore::Bool=true) const
virtual void mapToColor3(casacore::Array< casacore::uLong > &, const casacore::Array< casacore::Double > &, const casacore::Array< casacore::Double > &, const casacore::Array< casacore::Double > &)
virtual casacore::uInt nColors() const
Initial size of the colortable.
virtual casacore::uInt nSpareColors() const
Current number of slots usable by colormaps.
ColorIndex mode.
Definition: DisplayEnums.h:76
virtual void mapToColor(const Colormap *, casacore::Array< casacore::uShort > &, const casacore::Array< casacore::uShort > &, casacore::Bool=true) const
ColorModel
Different ways of handling color on the display.
Definition: DisplayEnums.h:74
unsigned int uInt
Definition: aipstype.h:51