VAPOR3 3.9.4
OpacityMap.h
Go to the documentation of this file.
1//--OpacityMap.h ---------------------------------------------------------
2//
3// Copyright (C) 2006 Kenny Gruchalla. All rights reserved.
4//
5// Various types of mappings from opacity to data value.
6//
7//----------------------------------------------------------------------------
8
9#ifndef OpacityMap_H
10#define OpacityMap_H
11
12#include <iostream>
13#include <vapor/ParamsBase.h>
15
16#ifdef WIN32
17 #include <vapor/glutil.h>
18#endif
19
20namespace VAPoR {
21
23public:
24 enum Type { CONTROL_POINT, GAUSSIAN, INVERTED_GAUSSIAN, SINE };
25
27 //
29
31 //
33
34 virtual ~OpacityMap();
35 void clear();
36
37 float opacityDataAtNorm(float nv) const;
38 float opacityData(float value) const;
39 bool inDataBounds(float value) const;
40
42
43 OpacityMap::Type GetType() const { return (OpacityMap::Type)GetValueLong(_typeTag, CONTROL_POINT); }
44
45 void SetDataBounds(const vector<double> &bounds);
46 vector<double> GetDataBounds() const;
47
48 double minValue() const;
49 double maxValue() const;
50
51 void setMinValue(double val);
52 void setMaxValue(double val);
53
54 bool IsEnabled() { return (GetValueLong(_enabledTag, 0) != 0 ? true : false); }
55 void SetEnabled(bool enabled);
56 double GetMean() const { return GetValueDouble(_meanTag, 0.5); }
57 void SetMean(double mean);
58 double GetSSQ() const { return GetValueDouble(_ssqTag, 0.1); }
59 void SetSSQ(double ssq);
60 double GetFreq() const { return GetValueDouble(_freqTag, 5.0); }
61 void SetFreq(double freq);
62 double GetPhase() const { return GetValueDouble(_phaseTag, 2 * M_PI); }
63 void SetPhase(double phase);
64
65 int numControlPoints() const { return (int)GetControlPoints().size() / 2; }
66
67 void addNormControlPoint(float normv, float opacity); // Normalized Coords
68 void addControlPoint(float value, float opacity); // Data Coordinates
69 void deleteControlPoint(int index);
70 void moveControlPoint(int index, float dx, float dy); // Data Coordinates
71
72 float controlPointOpacity(int index) const;
73 void controlPointOpacity(int index, float opacity);
74
75 float controlPointValueNormalized(int index) const;
76 float controlPointValue(int index) const; // Data Coordinates
77 void controlPointValueNormalized(int index, float nv);
78 void controlPointValue(int index, float value); // Data Coordinates
79
80 void setOpaque();
81 bool isOpaque() const;
82
84
85 TFInterpolator::type GetInterpType() const { return (TFInterpolator::type)GetValueLong(_interpTypeTag, TFInterpolator::linear); }
86
87 vector<double> GetControlPoints() const;
88 void SetControlPoints(const vector<double> &opacityControlPoints);
89
90 // Get static string identifier for this params class
91 //
92 static string GetClassType() { return ("OpacityMapParams"); }
93
94private:
95 int leftControlIndex(float val) const;
96
97 double normSSq(double ssq);
98 double denormSSq(double ssq);
99
100 double normSineFreq(double freq);
101 double denormSineFreq(double freq);
102
103 double normSinePhase(double phase);
104 double denormSinePhase(double phase);
105
106 const double _minSSq;
107 const double _maxSSq;
108 const double _minFreq;
109 const double _maxFreq;
110 const double _minPhase;
111 const double _maxPhase;
112
113 static const string _relMinTag;
114 static const string _relMaxTag;
115 static const string _enabledTag;
116 static const string _meanTag;
117 static const string _ssqTag;
118 static const string _freqTag;
119 static const string _phaseTag;
120 static const string _typeTag;
121 static const string _controlPointsTag;
122 static const string _interpTypeTag;
123 static const string _opacityMapIndexTag;
124 static const string _dataBoundsTag;
125};
126}; // namespace VAPoR
127
128#endif // OpacityMap_H
double GetPhase() const
Definition: OpacityMap.h:62
double maxValue() const
static string GetClassType()
Definition: OpacityMap.h:92
void SetPhase(double phase)
void SetEnabled(bool enabled)
float controlPointOpacity(int index) const
void setMaxValue(double val)
void SetDataBounds(const vector< double > &bounds)
void deleteControlPoint(int index)
void SetMean(double mean)
double GetMean() const
Definition: OpacityMap.h:56
bool inDataBounds(float value) const
void SetInterpType(TFInterpolator::type t)
float opacityData(float value) const
bool isOpaque() const
double GetFreq() const
Definition: OpacityMap.h:60
void moveControlPoint(int index, float dx, float dy)
vector< double > GetDataBounds() const
double minValue() const
void controlPointValue(int index, float value)
void SetControlPoints(const vector< double > &opacityControlPoints)
void addNormControlPoint(float normv, float opacity)
float opacityDataAtNorm(float nv) const
void SetFreq(double freq)
vector< double > GetControlPoints() const
OpacityMap(ParamsBase::StateSave *ssave, XmlNode *node)
Create a OpacityMap object from an existing XmlNode tree.
virtual ~OpacityMap()
void SetType(OpacityMap::Type type)
void controlPointValueNormalized(int index, float nv)
float controlPointValue(int index) const
double GetSSQ() const
Definition: OpacityMap.h:58
void controlPointOpacity(int index, float opacity)
void SetSSQ(double ssq)
OpacityMap::Type GetType() const
Definition: OpacityMap.h:43
TFInterpolator::type GetInterpType() const
Definition: OpacityMap.h:85
float controlPointValueNormalized(int index) const
OpacityMap(ParamsBase::StateSave *ssave)
Create a OpacityMap object from scratch.
void setMinValue(double val)
void addControlPoint(float value, float opacity)
int numControlPoints() const
Definition: OpacityMap.h:65
State capture class.
Definition: ParamsBase.h:62
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:50
An Xml tree.
Definition: XmlNode.h:49
#define PARAMS_API
Definition: common.h:77
#define M_PI
Definition: common.h:90