~ubuntu-branches/ubuntu/karmic/digikam/karmic-backports

« back to all changes in this revision

Viewing changes to libs/widgets/common/histogrampainter.h

  • Committer: Bazaar Package Importer
  • Author(s): Ubuntu Archive Auto-Backport
  • Date: 2009-12-07 19:03:53 UTC
  • mfrom: (54.1.4 lucid)
  • Revision ID: james.westby@ubuntu.com-20091207190353-oara3lenjxymto3i
Tags: 2:1.0.0~rc-1ubuntu1~karmic1
Automated backport upload; no source changes.

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        : 2009-10-26
 
7
 * Description : a class that manages painting histograms
 
8
 *
 
9
 * Copyright (C) 2009 by Johannes Wienke <languitar at semipol dot de>
 
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) any later version.
 
15
 *
 
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.
 
20
 *
 
21
 * ============================================================ */
 
22
 
 
23
#ifndef HISTOGRAMPAINTER_H
 
24
#define HISTOGRAMPAINTER_H
 
25
 
 
26
// Qt includes
 
27
 
 
28
#include <QObject>
 
29
#include <QWidget>
 
30
 
 
31
// Local includes
 
32
 
 
33
#include "imagehistogram.h"
 
34
#include "globals.h"
 
35
#include "dcolor.h"
 
36
 
 
37
namespace Digikam
 
38
{
 
39
 
 
40
class HistogramPainterPriv;
 
41
 
 
42
/**
 
43
 * A class that paints a histogram on a QPixmap.
 
44
 *
 
45
 * Attention: Before first usage of the render method, you must call initFrom to
 
46
 * initialize the painter.
 
47
 */
 
48
class HistogramPainter : public QObject
 
49
{
 
50
    Q_OBJECT
 
51
 
 
52
public:
 
53
 
 
54
    /**
 
55
     * Constructor.
 
56
     *
 
57
     * @param parent parent for Qt's destruction mechanism
 
58
     */
 
59
    HistogramPainter(QObject* parent);
 
60
 
 
61
    /**
 
62
     * Destructor.
 
63
     */
 
64
    virtual ~HistogramPainter();
 
65
 
 
66
    /**
 
67
     * Set the histogram to paint with the next call to render.
 
68
     *
 
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.
 
71
     */
 
72
    void setHistogram(ImageHistogram* histogram);
 
73
 
 
74
    /**
 
75
     * Set the scale to paint the histogram with.
 
76
     *
 
77
     * @param scale scal to paint histogram with
 
78
     */
 
79
    void setScale(HistogramScale scale);
 
80
 
 
81
    /**
 
82
     * Set the channel type to render with the next call to render.
 
83
     *
 
84
     * @param channelType channel type to render
 
85
     */
 
86
    void setChannelType(ChannelType channelType);
 
87
 
 
88
    /**
 
89
     * Decide whether to highlight a specified selection in the histogram or
 
90
     * not. The selection must be defined with setHighlightSelection.
 
91
     *
 
92
     * @param highlightSelection if true, a selection will be highlighted
 
93
     */
 
94
    void setHighlightSelection(bool highlightSelection);
 
95
 
 
96
    /**
 
97
     * Sets the selection to highlight.
 
98
     *
 
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.
 
105
     */
 
106
    void setSelection(double selectionMin, double selectionMax);
 
107
 
 
108
    /**
 
109
     * Decide whether to render a separation of the histogram in x direction.
 
110
     *
 
111
     * @param renderXGrid if true, a separation at some significant value in
 
112
     *                    x direction is rendered.
 
113
     */
 
114
    void setRenderXGrid(bool renderXGrid);
 
115
 
 
116
    /**
 
117
     * Starts rendering a guide that indicates where in the histogram a
 
118
     * specified color can be found.
 
119
     *
 
120
     * @param color the color to highlight in the histogram
 
121
     */
 
122
    void enableHistogramGuideByColor(const DColor& color);
 
123
 
 
124
    /**
 
125
     * Disables the rendering of the color guide.
 
126
     */
 
127
    void disableHistogramGuide();
 
128
 
 
129
    /**
 
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
 
133
     * to this method!!!
 
134
     *
 
135
     * @param widget widget to initialize painting from
 
136
     */
 
137
    void initFrom(QWidget* widget);
 
138
 
 
139
    /**
 
140
     * Renders the given histogram on the pixmap. The whole size of the pixmap
 
141
     * is used for the histogram.
 
142
     *
 
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.
 
145
     *
 
146
     * @param paintDevice pixmap to paint the histogram on
 
147
     */
 
148
    void render(QPixmap& paintDevice);
 
149
 
 
150
private:
 
151
 
 
152
    HistogramPainterPriv* const d;
 
153
};
 
154
 
 
155
} // namespace Digikam
 
156
 
 
157
#endif /* HISTOGRAMPAINTER_H */