Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class 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 namespace InSpace {
00020 
00021 class ColorVal
00022 {
00023  public:
00024   ColorVal(double val, Color c) {
00025     _val = val;
00026     _col = c;
00027     _lcol=c;
00028     _rcol=c;
00029   }
00030 
00031   ColorVal(double val, Color left, Color right){
00032     _val=val;
00033     _col=left;
00034     _lcol=left;
00035     _rcol=right;
00036   }
00037   
00038   ColorVal(double val,Color center, Color left, Color right){
00039     _val=val;
00040     _col=center;
00041     _lcol=left;
00042     _rcol=right;
00043   }
00044   virtual ~ColorVal() {}
00045   
00046   double val()  const { return _val; }
00047   void   setVal(const double v) { _val = v; }
00048 
00049   Color  col()  const { return _col; }
00050   void   setCol(const Color c)  { _col = c; _lcol=c; _rcol=c;}
00051 
00052   Color leftCol() const { return _lcol;}
00053   void setLeftCol(const Color c){_lcol=c;}
00054 
00055   Color rightCol() const { return _rcol;}
00056   void setRightCol(const Color c){_rcol=c;}
00057 
00058   bool equals(ColorVal* const val){
00059     return ((_val==val->val()) && ((_col==val->col()) || 
00060                    (_lcol==val->leftCol() && 
00061                     _rcol==val->rightCol())));
00062   }
00063 
00064   ColorVal* getCopy(){
00065     return new ColorVal(_val,_lcol,_rcol);
00066   }
00067 
00068  protected:
00069   double _val;
00070   Color  _col;
00071   Color _rcol;
00072   Color _lcol;
00073 };
00074 
00075   
00076 
00077 class ColorMap
00078 {
00079  public:
00080 
00083   ColorMap();
00084   
00087   ColorMap(double minVal, double maxVal);
00088 
00089   virtual ~ColorMap();
00090 
00091 
00093   void addToMap(const double value,const Color c);
00095   void changeMap(const double value,const Color c,const double threshold);
00096 
00097   void addRegion(double begin, double end, Color c, bool blend=true){
00098     addRegion(begin, end, c,c,blend);
00099   }
00100   void addRegion(double begin, double end, Color beginc, Color endc,
00101          bool blend=true);
00102   void clearRegion(double begin, double end);
00103   void setRegion(double begin, double end, double val, int index);
00104 
00105   Color getColor(const double value);
00106 
00107   void print();
00108 
00109   virtual int getNumPoints() const;
00110   virtual double getValIndexPoint(const int num) const;
00111   virtual Color getColorIndexPoint(const int num) const;
00112   virtual ColorVal* getColorVal(const int num);
00113 
00114   void stupidSort();
00115 
00116   void removeVal(ColorVal* const val);
00117   void addVal(ColorVal* const val){_colorVals+=val;};
00118 
00119   bool equals(ColorMap* const map);
00120   void clear();
00121 
00122   void setColorMap(ColorMap* map);
00123   ColorMap* getCopy();
00124  protected:
00125   ARRAY<ColorVal*>  _colorVals;
00126 
00127 };
00128 
00129 //saving/loading operators
00130 ostream & operator <<(ostream &os, ColorMap &p);
00131 ColorMap* readColorMap(istream *ifs);
00132 
00133 }
00134 #endif

Generated on Thu Jul 8 15:19:28 2004 for inspace by doxygen 1.3.4