00001
00010 #ifndef COLOR3MAP_H
00011 #define COLOR3MAP_H
00012
00013 #include "IS3DCommon.H"
00014
00015 namespace IS3D {
00016
00017
00018 typedef ReferenceCountedPointer<class Color3Val> Color3ValRef;
00019 class Color3Val;
00020
00021
00022 typedef ReferenceCountedPointer<class Color3Map> Color3MapRef;
00027 class Color3Map : public ReferenceCountedObject
00028 {
00029 public:
00030
00033 Color3Map();
00034
00037 Color3Map(double minVal, double maxVal);
00038
00039 virtual ~Color3Map();
00040
00042 Color3 getColor(const double value);
00043
00044
00046 void addToMap(const double value, const Color3 c);
00047
00051 void changeMap(const double value, const Color3 c, const double threshold);
00052
00053
00054
00055 void addRegion(double begin, double end, Color3 c, bool blend=true){
00056 addRegion(begin, end, c, c, blend);
00057 }
00058 void addRegion(double begin, double end, Color3 beginc, Color3 endc,
00059 bool blend=true);
00060 void clearRegion(double begin, double end);
00061 void setRegion(double begin, double end, double val, int index);
00062
00063
00064 void print();
00065
00066 virtual int getNumPoints() const;
00067 virtual double getValIndexPoint(const int num) const;
00068 virtual Color3 getColorIndexPoint(const int num) const;
00069 virtual Color3ValRef getColor3Val(const int num);
00070
00071 void removeVal(Color3ValRef const val);
00072 void addVal(Color3ValRef const val);
00073
00074 bool equals(Color3MapRef const map);
00075 void clear();
00076
00077 void setColor3Map(Color3MapRef map);
00078 Color3MapRef getCopy();
00079
00080 private:
00081
00082 void stupidSort();
00083
00084 Array<Color3ValRef> _colorVals;
00085
00086 };
00087
00088
00089
00090
00095 class Color3Val : public ReferenceCountedObject
00096 {
00097 public:
00098
00099 Color3Val(double val, Color3 c) {
00100 _val = val;
00101 _col = c;
00102 _lcol=c;
00103 _rcol=c;
00104 }
00105
00106 Color3Val(double val, Color3 left, Color3 right){
00107 _val=val;
00108 _col=left;
00109 _lcol=left;
00110 _rcol=right;
00111 }
00112
00113 Color3Val(double val,Color3 center, Color3 left, Color3 right){
00114 _val=val;
00115 _col=center;
00116 _lcol=left;
00117 _rcol=right;
00118 }
00119 virtual ~Color3Val() {}
00120
00121 double val() const { return _val; }
00122 void setVal(const double v) { _val = v; }
00123
00124 Color3 col() const { return _col; }
00125 void setCol(const Color3 c) { _col = c; _lcol=c; _rcol=c;}
00126
00127 Color3 leftCol() const { return _lcol;}
00128 void setLeftCol(const Color3 c) { _lcol=c; }
00129
00130 Color3 rightCol() const { return _rcol;}
00131 void setRightCol(const Color3 c) { _rcol=c; }
00132
00133 bool equals(Color3ValRef const val){
00134 return ((_val==val->val()) &&
00135 ((_col==val->col()) || (_lcol==val->leftCol() &&
00136 _rcol==val->rightCol())));
00137 }
00138
00139 Color3ValRef getCopy(){
00140 return new Color3Val(_val,_lcol,_rcol);
00141 }
00142
00143 protected:
00144
00145 double _val;
00146 Color3 _col;
00147 Color3 _rcol;
00148 Color3 _lcol;
00149 };
00150
00151
00152
00153 }
00154
00155 #endif