VAPoR  0.1
mapperfunction.h
Go to the documentation of this file.
1 //************************************************************************
2 // *
3 // Copyright (C) 2004 *
4 // University Corporation for Atmospheric Research *
5 // All Rights Reserved *
6 // *
7 //************************************************************************/
8 //
9 // File: mapperfunction.h
10 //
11 // Author: Alan Norton
12 // National Center for Atmospheric Research
13 // PO 3000, Boulder, Colorado
14 //
15 // Date: August 2005
16 //
17 // Description: Defines the MapperFunction class
18 // This is the mathematical definition of a function
19 // that can be used to map data to either colors or opacities
20 // Subclasses can either implement color or transparency
21 // mapping (or both)
22 #ifndef MAPPERFUNCTION_H
23 #define MAPPERFUNCTION_H
24 #define MAXCONTROLPOINTS 50
25 #include <iostream>
26 #include <qcolor.h>
27 #include <vapor/tfinterpolator.h>
28 #include <vapor/ExpatParseMgr.h>
29 #include <vapor/MapperFunctionBase.h>
30 #include <vapor/ParamNode.h>
31 #include "OpacityMap.h"
32 #include "Colormap.h"
33 
34 namespace VAPoR {
35 class Params;
36 class RenderParams;
37 class XmlNode;
38 class ParamNode;
39 
41 {
42 
43 public:
45  MapperFunction(const string& tag);
46  MapperFunction(RenderParams* p, int nBits = 8);
47  MapperFunction(const MapperFunction &mapper);
48  MapperFunction(const MapperFunctionBase &mapper);
50 
51  virtual ~MapperFunction();
52  virtual MapperFunction* deepCopy(ParamNode* newRoot = 0){
53  MapperFunction* mf = new MapperFunction(*this);
54  mf->SetRootParamNode(newRoot);
55  if(newRoot) newRoot->SetParamsBase(mf);
56  return mf;
57  }
58 
59  void setParams(RenderParams* p) { _params = p; }
60  RenderParams* getParams() { return _params; }
61 
62 
63 
64  //
65  // Function values
66  //
67  QRgb colorValue(float point);
68 
69  //
70  // Opacity Maps
71  //
72  virtual OpacityMap* createOpacityMap(OpacityMap::Type type=OpacityMap::CONTROL_POINT);
73 
74  virtual OpacityMap* getOpacityMap(int index);
75 
76  virtual VColormap* getColormap();
77 
78 
79 
80 protected:
81 
82  //
83  // Parent params
84  //
86 
87 };
89 public:
90  IsoControl();
91  IsoControl(RenderParams* p, int nBits = 8);
92  //Copy constructor
93  IsoControl(const IsoControl &mapper);
94  virtual IsoControl* deepCopy(ParamNode* newRoot = 0){
95  IsoControl* mf = new IsoControl(*this);
96  mf->SetRootParamNode(newRoot);
97  if(newRoot) newRoot->SetParamsBase(mf);
98  return mf;
99  }
100  static ParamsBase* CreateDefaultInstance(){return new IsoControl();}
101  virtual ~IsoControl();
102  void setIsoValue(double val){isoValues[0] = val;}
103  double getIsoValue(){return isoValues[0];}
104  void setIsoValues(const vector<double>& vals){isoValues = vals;}
105  const vector<double>& getIsoValues(){return isoValues;}
106 
107  virtual ParamNode* buildNode();
108  void setMinHistoValue(float val){
109  setMinMapValue(val);
110  }
111  void setMaxHistoValue(float val){
112  setMaxMapValue(val);
113  }
114  float getMinHistoValue() {return getMinMapValue();}
115  float getMaxHistoValue() {return getMaxMapValue();}
116 
117  virtual bool elementStartHandler(ExpatParseMgr*, int depth,
118  std::string&, const char **);
119 
120  virtual bool elementEndHandler(ExpatParseMgr*, int, std::string&);
121 protected:
122  static const string _leftHistoBoundAttr;
123  static const string _rightHistoBoundAttr;
124  static const string _leftHistoBoundTag;
125  static const string _rightHistoBoundTag;
126  vector<double> isoValues;
127 };
128 };
129 #endif //MAPPERFUNCTION_H
virtual IsoControl * deepCopy(ParamNode *newRoot=0)
#define PARAMS_API
Definition: common.h:63
A Params subclass for managing parameters used by Renderers.
Definition: params.h:569
virtual void SetRootParamNode(ParamNode *pn)
Definition: ParamsBase.h:222
static const string _leftHistoBoundTag
static ParamsBase * CreateDefaultInstance()
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:57
void setIsoValue(double val)
vector< double > isoValues
static ParamsBase * CreateDefaultInstance()
virtual MapperFunction * deepCopy(ParamNode *newRoot=0)
void setIsoValues(const vector< double > &vals)
void setMaxHistoValue(float val)
static const string _rightHistoBoundTag
static const string _rightHistoBoundAttr
void setMinHistoValue(float val)
const vector< double > & getIsoValues()
An Xml tree.
Definition: ParamNode.h:30
void setParams(RenderParams *p)
RenderParams * getParams()
static const string _leftHistoBoundAttr
RenderParams * _params