krita
kis_histogram.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KIS_HISTOGRAM_
00020 #define KIS_HISTOGRAM_
00021
00022 #include "kis_types.h"
00023 #include "kis_colorspace.h"
00024 #include "kis_histogram_producer.h"
00025
00026 enum enumHistogramType {
00027 LINEAR,
00028 LOGARITHMIC
00029 };
00043 class KisHistogram : public KShared {
00044
00045 public:
00050 class Calculations {
00051
00052 double m_max, m_min, m_mean, m_total, m_median, m_stddev;
00053
00054 Q_UINT32 m_high, m_low, m_count;
00055
00056 friend class KisHistogram;
00057
00058 public:
00059
00060 Calculations() : m_max(0.0), m_min(0.0), m_mean(0.0), m_total(0.0), m_median(0.0),
00061 m_stddev(0.0), m_high(0), m_low(0), m_count(0) {}
00066 inline double getMax() { return m_max; }
00071 inline double getMin() { return m_min; }
00073 inline Q_UINT32 getHighest() { return m_high; }
00075 inline Q_UINT32 getLowest() { return m_low; }
00077 inline double getMean() { return m_mean; }
00078
00079
00081 inline Q_UINT32 getCount() { return m_count; }
00083 inline double getTotal() { return m_total; }
00084
00085 };
00086
00087 KisHistogram(KisPaintLayerSP layer,
00088 KisHistogramProducerSP producer,
00089 const enumHistogramType type);
00090
00091 KisHistogram(KisPaintDeviceSP paintdev,
00092 KisHistogramProducerSP producer,
00093 const enumHistogramType type);
00094
00095 virtual ~KisHistogram();
00096
00098 void updateHistogram();
00099
00104 void computeHistogram();
00105
00107 Calculations calculations();
00109 Calculations selectionCalculations();
00110
00111 inline Q_UINT32 getValue(Q_UINT8 i) { return m_producer->getBinAt(m_channel, i); }
00112
00113 inline enumHistogramType getHistogramType() { return m_type; }
00114 inline void setHistogramType(enumHistogramType type) { m_type = type; }
00115 inline void setProducer(KisHistogramProducerSP producer) { m_producer = producer; }
00116 inline void setChannel(Q_INT32 channel) { m_channel = channel; }
00117 inline KisHistogramProducerSP producer() { return m_producer; }
00118 inline Q_INT32 channel() { return m_channel; }
00119
00120 inline bool hasSelection() { return m_selection; }
00121 inline double selectionFrom() { return m_selFrom; }
00122 inline double selectionTo() { return m_selTo; }
00123 inline void setNoSelection() { m_selection = false; }
00125 inline void setSelection(double from, double to)
00126 { m_selection = true; m_selFrom = from; m_selTo = to; }
00127
00128
00129 private:
00130
00131 void dump();
00132 QValueVector<Calculations> calculateForRange(double from, double to);
00133 Calculations calculateSingleRange(int channel, double from, double to);
00134
00135 KisPaintDeviceSP m_device;
00136 KisHistogramProducerSP m_producer;
00137
00138 enumHistogramType m_type;
00139
00140 Q_INT32 m_channel;
00141 double m_selFrom, m_selTo;
00142 bool m_selection;
00143
00144 KisPaintDeviceSP m_dev;
00145
00146 QValueVector<Calculations> m_completeCalculations, m_selectionCalculations;
00147 };
00148
00149
00150 #endif // KIS_HISTOGRAM_WIDGET_
|