rasdaman complete source
rviewColMap.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
23 
37 #ifndef _RVIEW_COLMAP_H_
38 #define _RVIEW_COLMAP_H_
39 
40 #include "rviewUtils.hh"
41 
42 class colourspaceMapper;
43 class colourspaceFrame;
44 
45 
46 enum cspaceType
47 {
48  cst_gauss,
49  cst_linear,
50  cst_rectangle,
51  cst_asympt
52 };
53 
54 typedef struct colourspace_params_s
55 {
56  double peak_red, peak_green, peak_blue;
57  double sigm_red, sigm_green, sigm_blue;
58  double minVal, maxVal;
59  unsigned long floatRange;
60  cspaceType type;
61 } colourspace_params;
62 
63 
64 /*
65  * Colourspace configuration canvas
66  */
67 class colourspaceCanvas: public wxCanvas
68 {
69 public:
70 
71  colourspaceCanvas(colourspaceFrame *parent, colourspace_params *p, int x, int y, int w, int h, long style=0);
72  ~colourspaceCanvas(void);
73 
74  void enableOutlineSum(bool enable);
75  void setDrawingFunction(void);
76 
77  void Redraw(void);
78 
79  void OnSize(int w, int h);
80  void OnPaint(void);
81  void OnEvent(wxMouseEvent &mevt);
82 
83  // constants
84  // Colourspace canvas border
85  static const int colcanv_cborder;
86  // Height of markers on colourspace canvas
87  static const int colcanv_mheight;
88 
89 
90 protected:
91 
92  int setupRectangle(int &from, int &to, float &x, wxRect *rect);
93  void drawOutline(double peak, double sigma, wxPen *pen, wxRect *rect);
94  void drawOutlineSum(wxPen *pen, wxRect *rect);
95  // Function pointer
96  double (*conversionFunction)(double, double, double);
97 
98  colourspaceFrame *parentObj;
99  colourspace_params *params;
100  int canvX, canvY;
101  wxBrush brush;
102  wxPen redPen, greenPen, bluePen, blackPen;
103  wxFont *font;
104  float *values;
105  float height, base, step;
106  int cmin, cmax;
107 };
108 
109 
110 /*
111  * Colourspace configuration window
112  */
113 class colourspaceFrame: public rviewFrame
114 {
115 public:
116 
117  colourspaceFrame(colourspaceMapper *parent, const colourspace_params *p);
118  ~colourspaceFrame(void);
119 
120  void setRange(double newMinVal, double newMaxVal);
121  void unlinkParent(void);
122 
123  void OnSize(int w, int h);
124 
125  void label(void);
126  int process(wxObject &obj, wxEvent &evt);
127 
128  void updateSettings(void);
129  void updateDisplay(const colourspace_params *cp=NULL);
130  void processMouseEvent(wxMouseEvent &mevt);
131 
132  virtual const char *getFrameName(void) const;
133  virtual rviewFrameType getFrameType(void) const;
134 
135  // constants
136  // Colourspace editor borders
137  static const int colspc_border;
138  // Colourspace editor window
139  static const int colspc_width;
140  static const int colspc_height;
141  // Colourspace buttons
142  static const int colspc_bwidth;
143  static const int colspc_bheight;
144  // Colourspace text widgets
145  static const int colspc_twidth;
146  static const int colspc_theight;
147  // Colourspace checkbox widgets
148  static const int colspc_chkheight;
149  // Colourspace choice widgets
150  static const int colspc_chwidth;
151  static const int colspc_chheight;
152  // Colourspace control panel height
153  static const int colspc_cheight;
154 
155 
156 private:
157 
158  void makeUpdate(void);
159 
160  colourspaceMapper *parentObj;
161  colourspace_params newParams;
162  colourspace_params origParams; // in case of immediate update
163 
164  colourspaceCanvas *canvas;
165  wxPanel *panel;
166  rviewText *posR, *posG, *posB;
167  rviewText *sigR, *sigG, *sigB;
168  rviewButton *okBut, *cancelBut, *defaultBut;
169  rviewCheckBox *immediateUpdate;
170  rviewCheckBox *drawSum;
171  rviewText *minVal, *maxVal;
172  rviewChoice *csType;
173  bool doImmediateUpdate;
174  bool doDrawSum;
175  cspaceType cstype;
176  float mousex, mousey;
177  int mousebut;
178  int dragColour;
179  int canvX, canvY;
180  int didUpdate;
181 };
182 
183 
184 // modes for calling processRange
185 #define CSPACE_RANGE_ACTUAL 0
186 #define CSPACE_RANGE_FULL 1
187 #define CSPACE_RANGE_OLD 2
188 
189 /*
190  * Class for mapping large range values to RGB colourspace,
191  * implemented in rviewImage.cpp
192  */
193 class colourspaceMapper
194 {
195 public:
196 
197  colourspaceMapper(r_Ref<r_GMarray> &mdd, rviewBaseType bt, const colourspace_params *cp, bool fullrange=FALSE, const r_Minterval *domain=NULL, unsigned long frange=0x10000);
198  ~colourspaceMapper(void);
199 
200  void getObject(r_Ref<r_GMarray> &mdd, rviewBaseType &bt, bool *fullrange=NULL, r_Minterval **domain=NULL) const;
201  int bindMapper(r_Ref<r_GMarray> &mdd, rviewBaseType bt, bool fullrange=FALSE, const r_Minterval *domain=NULL, const colourspace_params *cp=NULL);
202 
203  inline unsigned short ValToCS15(double value)
204  {
205  return (this->*convert15)(value);
206  }
207  inline unsigned long ValToCS24(double value)
208  {
209  return (this->*convert24)(value);
210  }
211  unsigned short *buildCSTab15(bool forceRebuild=FALSE);
212  unsigned long *buildCSTab24(bool forceRebuild=FALSE);
213  double getMinVal(void);
214  double getMaxVal(void);
215  double getScalingFactor(void);
216  unsigned short *getCSTab15(void);
217  unsigned long *getCSTab24(void);
218  void processRange(int rangeMode);
219  void updateProjection(const r_Minterval *domain);
220  void colourspaceChanged(const colourspace_params *newParams, bool autoUpdate=TRUE);
221  void openEditor(void);
222  void closeEditor(bool activeClose=TRUE);
223  void getParameters(colourspace_params *dest);
224  void setMappingFunctions(void);
225 
226 
227 protected:
228 
229  static int getTableForType(rviewBaseType bt);
230 
231  unsigned short ValToGauss15(double value);
232  unsigned long ValToGauss24(double value);
233  unsigned short ValToLinear15(double value);
234  unsigned long ValToLinear24(double value);
235  unsigned short ValToRectangle15(double value);
236  unsigned long ValToRectangle24(double value);
237  unsigned short ValToAsymptotic15(double value);
238  unsigned long ValToAsymptotic24(double value);
239  // function pointers
240  unsigned short (colourspaceMapper::*convert15)(double value);
241  unsigned long (colourspaceMapper::*convert24)(double value);
242 
243  colourspace_params par; // all the important parameters
244  double realMinVal, realMaxVal; // actual range of object
245  bool didRange;
246  bool rangeModeFull;
247  double peakR, peakG, peakB;
248  double invSigR, invSigG, invSigB;
249  double scalingFactor;
250  int dimMDD;
251  int tableKind; // 15 or 24bpp tables?
252  unsigned short *IntToRGBTab15;
253  unsigned long *IntToRGBTab24;
254  cspaceType tableType;
255  colourspaceFrame *csFrame;
256  r_Ref<r_GMarray> mddObj;
257  rviewBaseType baseType;
258  long projPixels;
259  r_Minterval objInterv;
260  r_Minterval lastInterv;
261  const r_Minterval *useInterv;
262 };
263 
264 #endif
#define FALSE
Definition: defs.h:70
#define TRUE
Definition: defs.h:67