00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TIL_HISTOGRAM_H
00020 #define TIL_HISTOGRAM_H
00021
00022 #include "TIL_API.h"
00023 #include <UT/UT_String.h>
00024 #include <UT/UT_Vector2.h>
00025 #include "TIL_Defines.h"
00026
00027 class TIL_Raster;
00028
00029 class TIL_API TIL_Histogram
00030 {
00031 public:
00032
00033 TIL_Histogram();
00034 virtual ~TIL_Histogram();
00035
00036
00037 void setRaster(const TIL_Raster *generate_from,
00038 int comp = -1);
00039 void setMaxBuckets(int max);
00040
00041 void generate(TIL_HistogramType type,
00042 bool usehue = true,
00043 bool primary = true,
00044 bool uvmode = false,
00045 float uvpos = 0.0f);
00046
00047
00048 int isHistogram() const;
00049 int isGraph() const;
00050
00051 const char *getName() const { return myGraphName; }
00052 void getXAxis(UT_String &label, int &limited_range,
00053 float &start, float &end,
00054 int &floatval, int &usesbwpoints,
00055 int &usehue) const;
00056 void getYAxis(UT_String &label, int &limited_range,
00057 float &start, float &end,
00058 int &floatval, int &usesbwpoints,
00059 int &usehue) const;
00060
00061 void getBWPoints(float &black, float &white) const;
00062
00063 unsigned int getHistogramSize(bool rebinned = true) const;
00064 const unsigned int *getHistogram(bool rebinned = true) const;
00065 float getCutoffPoint() const;
00066
00067 bool getUVPos(float &pos, int &dir) const;
00068
00069 void getGraphDimensions(int &width, int &height) const;
00070 const TIL_Raster *getGraph() const;
00071 unsigned int getGraphCount(int x, int y) const;
00072
00073
00074 static void RGBtoHSV(float r, float g, float b,
00075 float &h, float &s, float &v);
00076 static void HSVtoRGB(float h, float s, float v,
00077 float &r, float &g, float &b);
00078
00079 void rebin(const float histwidth);
00080 void getRangeForBar(int bar, float& start, float& end);
00081
00082 private:
00083 void reset();
00084 void scanRange(float &min, float &max);
00085 void scanHistogram(float &min, float &max);
00086 static void scanHistogram( unsigned int const* histogram, int num_buckets,
00087 float &start, float &end, float& cutoff_point
00088 );
00089
00090
00091
00092
00093
00094 unsigned int *allocHistogram(int size = -1);
00095 unsigned int *allocGraph(int width, int depth = -1);
00096
00097 void convertGraphToRaster(int use_huex, int use_huey,
00098 int cindex);
00099
00100 void generateRawHist();
00101 void generateHSVHist(int which);
00102
00103 void generateRaw(int uv, bool uvmode, float uvpos);
00104 void generateHSV(int which, int uv,
00105 bool uvmode, float uvpos);
00106 void generateHueGraph(int which);
00107
00108 private:
00109 const TIL_Raster * myRaster;
00110 int myComponent;
00111 int myGraphType;
00112
00113 TIL_HistogramType myType;
00114 const char *myGraphName;
00115 const char *myXLabel;
00116 const char *myYLabel;
00117 float myXStart, myXEnd;
00118 float myYStart, myYEnd;
00119 int myXFloat, myYFloat;
00120 int myXHue, myYHue;
00121 int myXLimited, myYLimited;
00122 int myWhitePointAxis;
00123 bool myUVMode;
00124 float myUVPos;
00125
00126
00127 int myMaxBuckets;
00128 int myNumBuckets;
00129 unsigned int *myHistogram;
00130 float myCutoffPoint;
00131
00132
00133 unsigned int* myRebinnedHistogram;
00134 unsigned int* myBinRangeTable;
00135 int myAllocatedBins;
00136 int myNumBins;
00137 float myRebinnedCutoffPoint;
00138 bool myHasRebinnedHistogram;
00139
00140
00141 unsigned int myGraphWidth;
00142 unsigned int myGraphHeight;
00143 unsigned char *myGraph;
00144 TIL_Raster *myDisplayGraph;
00145 };
00146
00147 #endif