Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

ColorMap.H

Go to the documentation of this file.
00001 
00010 #ifndef COLORMAP_H
00011 #define COLORMAP_H
00012 
00013 // Gluebase includes
00014 #define OUTSIDE_GLUE_CORE
00015 #include <std/list.H>
00016 
00017 #include "Color.H"
00018 
00019 
00020 class ColorVal
00021 {
00022  public:
00023   ColorVal(double val, Color c) {
00024     _val = val;
00025     _col = c;
00026     _lcol=c;
00027     _rcol=c;
00028   }
00029 
00030   ColorVal(double val, Color left, Color right){
00031     _val=val;
00032     _col=left;
00033     _lcol=left;
00034     _rcol=right;
00035   }
00036   
00037   ColorVal(double val,Color center, Color left, Color right){
00038     _val=val;
00039     _col=center;
00040     _lcol=left;
00041     _rcol=right;
00042   }
00043   virtual ~ColorVal() {}
00044   
00045   double val()  const { return _val; }
00046   void   setVal(const double v) { _val = v; }
00047 
00048   Color  col()  const { return _col; }
00049   void   setCol(const Color c)  { _col = c; _lcol=c; _rcol=c;}
00050 
00051   Color leftCol() const { return _lcol;}
00052   void setLeftCol(const Color c){_lcol=c;}
00053 
00054   Color rightCol() const { return _rcol;}
00055   void setRightCol(const Color c){_rcol=c;}
00056 
00057   bool equals(ColorVal* const val){
00058     return ((_val==val->val()) && ((_col==val->col()) || 
00059                    (_lcol==val->leftCol() && 
00060                     _rcol==val->rightCol())));
00061   }
00062 
00063   ColorVal* getCopy(){
00064     return new ColorVal(_val,_lcol,_rcol);
00065   }
00066 
00067  protected:
00068   double _val;
00069   Color  _col;
00070   Color _rcol;
00071   Color _lcol;
00072 };
00073 
00074   
00075 
00076 class ColorMap
00077 {
00078  public:
00079 
00082   ColorMap();
00083   
00086   ColorMap(double minVal, double maxVal);
00087 
00088   virtual ~ColorMap();
00089 
00090 
00092   void addToMap(const double value,const Color c);
00094   void changeMap(const double value,const Color c,const double threshold);
00095 
00096   void addRegion(double begin, double end, Color c, bool blend=true){
00097     addRegion(begin, end, c,c,blend);
00098   }
00099   void addRegion(double begin, double end, Color beginc, Color endc,
00100          bool blend=true);
00101   void clearRegion(double begin, double end);
00102   void setRegion(double begin, double end, double val, int index);
00103 
00104   Color getColor(const double value);
00105 
00106   void print();
00107 
00108   virtual int getNumPoints() const;
00109   virtual double getValIndexPoint(const int num) const;
00110   virtual Color getColorIndexPoint(const int num) const;
00111   virtual ColorVal* getColorVal(const int num);
00112 
00113   void stupidSort();
00114 
00115   void removeVal(ColorVal* const val);
00116   void addVal(ColorVal* const val){_colorVals+=val;};
00117 
00118   bool equals(ColorMap* const map);
00119   void clear();
00120 
00121   void setColorMap(ColorMap* map);
00122   ColorMap* getCopy();
00123  protected:
00124   ARRAY<ColorVal*>  _colorVals;
00125 
00126 };
00127 
00128 //saving/loading operators
00129 ostream & operator <<(ostream &os, ColorMap &p);
00130 ColorMap* readColorMap(istream *ifs);
00131 
00132 #endif

Generated on Mon Sep 15 16:27:55 2003 for inspace by doxygen1.2.18