~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/libs/widgets/common/histogramwidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.3.2 upstream) (37 hardy)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20080717202539-1bw3w3nrsso7yj4z
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2004-07-21
 
7
 * Description : a widget to display an image histogram.
 
8
 * 
 
9
 * Copyright (C) 2004-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 *
 
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)
 
15
 * any later version.
 
16
 * 
 
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.
 
21
 * 
 
22
 * ============================================================ */
 
23
 
 
24
#ifndef HISTOGRAMWIDGET_H
 
25
#define HISTOGRAMWIDGET_H
 
26
 
 
27
// Qt includes.
 
28
 
 
29
#include <qwidget.h>
 
30
 
 
31
// Local includes
 
32
 
 
33
#include "dcolor.h"
 
34
#include "digikam_export.h"
 
35
 
 
36
class QCustomEvent;
 
37
 
 
38
namespace Digikam
 
39
{
 
40
 
 
41
class ImageHistogram;
 
42
class HistogramWidgetPriv;
 
43
 
 
44
class DIGIKAM_EXPORT HistogramWidget : public QWidget
 
45
{
 
46
Q_OBJECT
 
47
 
 
48
public:
 
49
 
 
50
    enum HistogramType
 
51
    {
 
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.
 
58
    };
 
59
 
 
60
    enum HistogramScale
 
61
    {
 
62
        LinScaleHistogram=0,      // Linear scale.
 
63
        LogScaleHistogram         // Logarithmic scale.
 
64
    };
 
65
 
 
66
    enum HistogramAllColorMode
 
67
    {
 
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.
 
71
    };
 
72
 
 
73
    enum HistogramRenderingType
 
74
    {
 
75
        FullImageHistogram=0,     // Full image histogram rendering.
 
76
        ImageSelectionHistogram   // Image selection histogram rendering.
 
77
    };
 
78
 
 
79
public:
 
80
 
 
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);
 
86
 
 
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);
 
94
 
 
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);
 
103
 
 
104
    void setup(int w, int h, bool selectMode=true,
 
105
               bool blinkComputation=true,
 
106
               bool statisticsVisible=false);
 
107
 
 
108
    ~HistogramWidget();
 
109
 
 
110
    /** Stop current histogram computations.*/
 
111
    void stopHistogramComputation(void);
 
112
 
 
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);
 
118
 
 
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);
 
123
 
 
124
    void setDataLoading();
 
125
    void setLoadingFailed();
 
126
 
 
127
    void setHistogramGuideByColor(DColor color);
 
128
 
 
129
    void reset(void);
 
130
 
 
131
public:
 
132
 
 
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.
 
137
 
 
138
    ImageHistogram *m_imageHistogram;      // Full image.
 
139
    ImageHistogram *m_selectionHistogram;  // Image selection.
 
140
 
 
141
signals:
 
142
 
 
143
    void signalIntervalChanged( int min, int max );
 
144
    void signalMaximumValueChanged( int );
 
145
    void signalHistogramComputationDone( bool );
 
146
    void signalHistogramComputationFailed( void );
 
147
 
 
148
public slots:
 
149
 
 
150
    void slotMinValueChanged( int min );
 
151
    void slotMaxValueChanged( int max );
 
152
 
 
153
protected slots:
 
154
 
 
155
    void slotBlinkTimerDone( void );
 
156
 
 
157
protected:
 
158
 
 
159
    void paintEvent( QPaintEvent * );
 
160
    void mousePressEvent ( QMouseEvent * e );
 
161
    void mouseReleaseEvent ( QMouseEvent * e );
 
162
    void mouseMoveEvent ( QMouseEvent * e );
 
163
 
 
164
private :
 
165
 
 
166
    void customEvent(QCustomEvent *event);
 
167
    void notifyValuesChanged();
 
168
 
 
169
private:
 
170
 
 
171
    HistogramWidgetPriv* d;
 
172
 
 
173
};
 
174
 
 
175
}  // namespace Digikam
 
176
 
 
177
#endif /* HISTOGRAMWIDGET_H */