1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : a widget to display an image histogram.
9
* Copyright (C) 2004-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
* This program is free software; you can redistribute it
12
* and/or modify it under the terms of the GNU General
13
* Public License as published by the Free Software Foundation;
14
* either version 2, or (at your option)
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* ============================================================ */
24
#ifndef HISTOGRAMWIDGET_H
25
#define HISTOGRAMWIDGET_H
34
#include "digikam_export.h"
42
class HistogramWidgetPriv;
44
class DIGIKAM_EXPORT HistogramWidget : public QWidget
52
ValueHistogram = 0, // Luminosity.
53
RedChannelHistogram, // Red channel.
54
GreenChannelHistogram, // Green channel.
55
BlueChannelHistogram, // Blue channel.
56
AlphaChannelHistogram, // Alpha channel.
57
ColorChannelsHistogram // All color channels.
62
LinScaleHistogram=0, // Linear scale.
63
LogScaleHistogram // Logarithmic scale.
66
enum HistogramAllColorMode
68
RedColor=0, // Red color to foreground in All Colors Channel mode.
69
GreenColor, // Green color to foreground in All Colors Channel mode.
70
BlueColor // Blue color to foreground in All Colors Channel mode.
73
enum HistogramRenderingType
75
FullImageHistogram=0, // Full image histogram rendering.
76
ImageSelectionHistogram // Image selection histogram rendering.
81
/** Constructor without image data. Needed to use updateData() method after to create instance.*/
82
HistogramWidget(int w, int h, // Widget size.
83
QWidget *parent=0, bool selectMode=true,
84
bool blinkComputation=true,
85
bool statisticsVisible=false);
87
/** Constructor with image data and without image selection data.*/
88
HistogramWidget(int w, int h, // Widget size.
89
uchar *i_data, uint i_w, uint i_h, // Full image info.
90
bool i_sixteenBits, // 8 or 16 bits image.
91
QWidget *parent=0, bool selectMode=true,
92
bool blinkComputation=true,
93
bool statisticsVisible=false);
95
/** Constructor with image data and image selection data.*/
96
HistogramWidget(int w, int h, // Widget size.
97
uchar *i_data, uint i_w, uint i_h, // Full image info.
98
uchar *s_data, uint s_w, uint s_h, // Image selection info.
99
bool i_sixteenBits, // 8 or 16 bits image.
100
QWidget *parent=0, bool selectMode=true,
101
bool blinkComputation=true,
102
bool statisticsVisible=false);
104
void setup(int w, int h, bool selectMode=true,
105
bool blinkComputation=true,
106
bool statisticsVisible=false);
110
/** Stop current histogram computations.*/
111
void stopHistogramComputation(void);
113
/** Update full image histogram data methods.*/
114
void updateData(uchar *i_data, uint i_w, uint i_h,
115
bool i_sixteenBits, // 8 or 16 bits image.
116
uchar *s_data=0, uint s_w=0, uint s_h=0,
117
bool blinkComputation=true);
119
/** Update image selection histogram data methods.*/
120
void updateSelectionData(uchar *s_data, uint s_w, uint s_h,
121
bool i_sixteenBits, // 8 or 16 bits image.
122
bool blinkComputation=true);
124
void setDataLoading();
125
void setLoadingFailed();
127
void setHistogramGuideByColor(DColor color);
133
int m_channelType; // Channel type to draw.
134
int m_scaleType; // Scale to use for drawing.
135
int m_colorType; // Color to use for drawing in All Colors Channel mode.
136
int m_renderingType; // Using full image or image selection for histogram rendering.
138
ImageHistogram *m_imageHistogram; // Full image.
139
ImageHistogram *m_selectionHistogram; // Image selection.
143
void signalIntervalChanged( int min, int max );
144
void signalMaximumValueChanged( int );
145
void signalHistogramComputationDone( bool );
146
void signalHistogramComputationFailed( void );
150
void slotMinValueChanged( int min );
151
void slotMaxValueChanged( int max );
155
void slotBlinkTimerDone( void );
159
void paintEvent( QPaintEvent * );
160
void mousePressEvent ( QMouseEvent * e );
161
void mouseReleaseEvent ( QMouseEvent * e );
162
void mouseMoveEvent ( QMouseEvent * e );
166
void customEvent(QCustomEvent *event);
167
void notifyValuesChanged();
171
HistogramWidgetPriv* d;
175
} // namespace Digikam
177
#endif /* HISTOGRAMWIDGET_H */