MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00004 00010 //---------------------------------------------------------------------------------- 00011 00012 00013 #ifndef __mlLUTFLinear_H 00014 #define __mlLUTFLinear_H 00015 00016 // Local includes 00017 #ifndef __mlLUTSystem_H 00018 #include "mlLUTSystem.h" 00019 #endif 00020 #ifndef __mlLUTFunction_H 00021 #include "mlLUTFunction.h" 00022 #endif 00023 00024 #include <vector> 00025 00026 ML_START_NAMESPACE 00027 00029 class MLLUT_EXPORT LUTRGBAPoint 00030 { 00031 public: 00033 LUTRGBAPoint(); 00035 LUTRGBAPoint(double posArg, double rArg, double gArg, double bArg, double aArg); 00036 00038 double pos() const { return _v[0]; } 00040 void setPos(double posArg) { _v[0] = posArg; } 00041 00043 double r() const { return _v[1]; } 00044 void setR(double rArg) { _v[1] = rArg; } 00045 double g() const { return _v[2]; } 00046 void setG(double gArg) { _v[2] = gArg; } 00047 double b() const { return _v[3]; } 00048 void setB(double bArg) { _v[3] = bArg; } 00049 double a() const { return _v[4]; } 00050 void setA(double aArg) { _v[4] = aArg; } 00051 00053 void setL(double lArg) { 00054 _v[1] = lArg; _v[2] = lArg; _v[3] = lArg; 00055 } 00056 00058 double l() const { 00059 return _v[1]; 00060 } 00061 00062 void setRGBA(double rArg, double gArg, double bArg, double aArg) { 00063 _v[1] = rArg; 00064 _v[2] = gArg; 00065 _v[3] = bArg; 00066 _v[4] = aArg; 00067 } 00068 00069 void setRGB(double rArg, double gArg, double bArg) { 00070 _v[1] = rArg; 00071 _v[2] = gArg; 00072 _v[3] = bArg; 00073 } 00074 00076 00079 double &operator [](int idx) { 00080 return _v[idx]; 00081 } 00082 00086 const double &operator [](int idx) const { 00087 return _v[idx]; 00088 } 00089 00091 bool operator <(const LUTRGBAPoint& p) const { 00092 return this->pos()<p.pos(); 00093 } 00094 00096 bool operator >(const LUTRGBAPoint& p) const { 00097 return this->pos()>p.pos(); 00098 } 00099 00100 private: 00102 double _v[5]; 00103 }; 00104 00105 00106 00108 typedef std::vector<LUTRGBAPoint> LUTRGBAPointList; 00109 00110 00111 00114 class MLLUT_EXPORT LUTFLinear : public LUTFunction 00115 { 00116 public: 00117 00118 // Set current version number 00119 ML_SET_ADDSTATE_VERSION(1); 00120 00122 typedef enum { 00123 InterpolateRGB, 00124 InterpolateHLS, 00125 InterpolateHLSpos, 00126 InterpolateHLSneg, 00127 InterpolateConstant, 00128 00129 numColorInterpolation 00130 } ColorInterpolation; 00131 00133 static const char *ColorInterpolationNames[numColorInterpolation]; 00134 00135 00137 LUTFLinear (void); 00138 00139 00141 00142 00145 virtual bool setPoints(const LUTRGBAPointList& points); 00146 00148 const LUTRGBAPointList& getPoints() const { return _points; } 00149 00152 LUTRGBAPointList& getModifiablePoints() { return _points; } 00153 00155 void setVisualType(LUTVisualType visualType) { _visualType = visualType; changed(); } 00156 00158 int insertPoint(const LUTRGBAPoint& point); 00159 00161 void removePoint(int idx); 00162 00164 const LUTRGBAPoint& getPoint(int idx) const; 00165 00167 void setPoint(int idx, const LUTRGBAPoint& point); 00168 00170 virtual double getStartIndex (void) const; 00171 00173 virtual double getEndIndex (void) const; 00174 00176 virtual ColorInterpolation getColorInterpolation (void) const { return _colorInterpolation; } 00177 00179 virtual void setColorInterpolation (ColorInterpolation c) { _colorInterpolation = c; changed(); } 00180 00182 void setAlphaFactor(float factor) { 00183 _alphaFactor = factor; 00184 changed(); 00185 } 00186 00188 float getAlphaFactor() const { 00189 return _alphaFactor; 00190 } 00191 00194 bool relativeUsesNativeRange() const { return _relativeUsesNativeRange; } 00195 00198 void setRelativeUsesNativeRange(bool flag) { _relativeUsesNativeRange = flag; } 00199 00201 00202 00204 00205 00207 virtual bool isValid (void) const; 00208 00210 virtual int getNativeMinIndex (void) const; 00211 00213 virtual int getNativeMaxIndex (void) const; 00214 00216 00217 00218 protected: 00219 00220 virtual void addStateToTree(TreeNode *parent) const; 00221 virtual void readStateFromTree(TreeNode *parent); 00222 00224 00225 00230 virtual bool renderLUTNative (LUTDataBase *lutData, LUTIteratorBase *lutIterator) const; 00231 00238 virtual bool renderLUTRescaled (LUTDataBase *lutData, LUTIteratorBase *lutIterator, 00239 double minIndex, double maxIndex) const; 00240 00244 template <typename T> 00245 bool renderLUT (LUTData<T> *lutData, LUTIterator<T> *lutIterator, 00246 double startIndex, double endIndex) const; 00247 00249 00250 00252 void copyPoint(int idx, double* array) const; 00253 00254 00256 LUTRGBAPointList _points; 00257 00259 float _alphaFactor; 00260 00263 bool _relativeUsesNativeRange; 00264 00266 ColorInterpolation _colorInterpolation; 00267 00268 00269 ML_CLASS_HEADER(LUTFLinear); 00270 00271 }; 00272 00273 00274 ML_END_NAMESPACE 00275 00276 00277 #endif 00278 // __mlLUTFLinear_H