1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : a class that manages painting histograms
9
* Copyright (C) 2009 by Johannes Wienke <languitar at semipol dot de>
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) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* ============================================================ */
23
#ifndef HISTOGRAMPAINTER_H
24
#define HISTOGRAMPAINTER_H
33
#include "imagehistogram.h"
40
class HistogramPainterPriv;
43
* A class that paints a histogram on a QPixmap.
45
* Attention: Before first usage of the render method, you must call initFrom to
46
* initialize the painter.
48
class HistogramPainter : public QObject
57
* @param parent parent for Qt's destruction mechanism
59
HistogramPainter(QObject* parent);
64
virtual ~HistogramPainter();
67
* Set the histogram to paint with the next call to render.
69
* @param histogram an existing pointer to a histogram to paint on next call
70
* to render. The histogram must still exist at that call.
72
void setHistogram(ImageHistogram* histogram);
75
* Set the scale to paint the histogram with.
77
* @param scale scal to paint histogram with
79
void setScale(HistogramScale scale);
82
* Set the channel type to render with the next call to render.
84
* @param channelType channel type to render
86
void setChannelType(ChannelType channelType);
89
* Decide whether to highlight a specified selection in the histogram or
90
* not. The selection must be defined with setHighlightSelection.
92
* @param highlightSelection if true, a selection will be highlighted
94
void setHighlightSelection(bool highlightSelection);
97
* Sets the selection to highlight.
99
* @param selectionMin 0 <= value <= 1, percent of the histogram width to
100
* start highlighting as percent. Ensure that this value
101
* is smaller then selectionMax.
102
* @param selectionMax 0 <= value <= 1, percent of the histogram width to
103
* end highlighting as percent. Ensure that this value
104
* is greater then selectionMin.
106
void setSelection(double selectionMin, double selectionMax);
109
* Decide whether to render a separation of the histogram in x direction.
111
* @param renderXGrid if true, a separation at some significant value in
112
* x direction is rendered.
114
void setRenderXGrid(bool renderXGrid);
117
* Starts rendering a guide that indicates where in the histogram a
118
* specified color can be found.
120
* @param color the color to highlight in the histogram
122
void enableHistogramGuideByColor(const DColor& color);
125
* Disables the rendering of the color guide.
127
void disableHistogramGuide();
130
* Stores a widget that is used to initialize the painter used in the next
131
* call to render. Therefore you must ensure that this widget will not be
132
* destroyed as long as you want to use the render method without a new call
135
* @param widget widget to initialize painting from
137
void initFrom(QWidget* widget);
140
* Renders the given histogram on the pixmap. The whole size of the pixmap
141
* is used for the histogram.
143
* You must ensure that once before using this method a call to initFrom was
144
* made and the widget given in that call is still present.
146
* @param paintDevice pixmap to paint the histogram on
148
void render(QPixmap& paintDevice);
152
HistogramPainterPriv* const d;
155
} // namespace Digikam
157
#endif /* HISTOGRAMPAINTER_H */