digiKam
histogramwidget.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2004-07-21
7  * Description : a widget to display an image histogram.
8  *
9  * Copyright (C) 2004-2022 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 DIGIKAM_HISTOGRAM_WIDGET_H
25 #define DIGIKAM_HISTOGRAM_WIDGET_H
26 
27 // Qt includes
28 
29 #include <QWidget>
30 #include <QEvent>
31 #include <QMouseEvent>
32 #include <QPaintEvent>
33 
34 // Local includes
35 
36 #include "dimg.h"
37 #include "dcolor.h"
38 #include "digikam_debug.h"
39 #include "digikam_export.h"
40 #include "digikam_globals.h"
41 
42 namespace Digikam
43 {
44 
45 class ImageHistogram;
46 
47 class DIGIKAM_EXPORT HistogramWidget : public QWidget
48 {
49  Q_OBJECT
50  Q_PROPERTY(int animationState READ animationState WRITE setAnimationState)
51 
52 public:
53 
57  HistogramWidget(int w, int h, // Widget size.
58  QWidget* const parent = nullptr,
59  bool selectMode=true,
60  bool showProgress=true,
61  bool statisticsVisible=false);
62 
63  ~HistogramWidget() override;
64 
68  void stopHistogramComputation();
69 
73  void updateData(const DImg& img, // full image data.
74  const DImg& sel=DImg(), // selection image data
75  bool showProgress=true);
76 
80  void updateSelectionData(const DImg& sel, bool showProgress=true);
81 
82  void setDataLoading();
83  void setLoadingFailed();
84 
85  void setHistogramGuideByColor(const DColor& color);
86  void setStatisticsVisible(bool b);
87 
88  void reset();
89 
90  HistogramScale scaleType() const;
91  ChannelType channelType() const;
92 
93  int animationState() const;
94  void setAnimationState(int animationState);
95 
96  void setRenderingType(HistogramRenderingType type);
97  HistogramRenderingType renderingType() const;
98 
101  ImageHistogram* currentHistogram() const;
102 
103 Q_SIGNALS:
104 
105  void signalIntervalChanged(int min, int max);
109 
110 public Q_SLOTS:
111 
112  void slotMinValueChanged(int min);
113  void slotMaxValueChanged(int max);
114  void setChannelType(ChannelType channel);
115  void setScaleType(HistogramScale scale);
116 
117 protected Q_SLOTS:
118 
119  void slotCalculationAboutToStart();
120  void slotCalculationFinished(bool success);
121 
122 protected:
123 
124  void paintEvent(QPaintEvent*) override;
125  void mousePressEvent(QMouseEvent*) override;
126  void mouseReleaseEvent(QMouseEvent*) override;
127  void mouseMoveEvent(QMouseEvent*) override;
128 
129 private:
130 
131  void notifyValuesChanged();
132  void connectHistogram(const ImageHistogram* const histogram);
133  void setup(int w, int h, bool selectMode, bool statisticsVisible);
134  void setState(int state);
135  void startWaitingAnimation();
136  void stopWaitingAnimation();
137 
138 private:
139 
140  class Private;
141  Private* const d;
142 };
143 
144 } // namespace Digikam
145 
146 #endif // DIGIKAM_HISTOGRAM_WIDGET_H
Definition: dcolor.h:43
Definition: dimg.h:62
Definition: histogramwidget.h:48
void signalMaximumValueChanged(int)
void signalHistogramComputationDone(bool)
void signalHistogramComputationFailed()
void signalIntervalChanged(int min, int max)
Definition: imagehistogram.h:44
Definition: datefolderview.cpp:43
ChannelType
Definition: digikam_globals.h:159
HistogramRenderingType
Definition: digikam_globals.h:151
HistogramScale
Definition: digikam_globals.h:145