1 /*******************************************************************************
2 **
3 ** Photivo
4 **
5 ** Copyright (C) 2008,2009 Jos De Laender <jos.de_laender@telenet.be>
6 ** Copyright (C) 2009,2010 Michael Munzert <mail@mm-log.com>
7 **
8 ** This file is part of Photivo.
9 **
10 ** Photivo is free software: you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License version 3
12 ** as published by the Free Software Foundation.
13 **
14 ** Photivo is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ** GNU General Public License for more details.
18 **
19 ** You should have received a copy of the GNU General Public License
20 ** along with Photivo.  If not, see <http://www.gnu.org/licenses/>.
21 **
22 *******************************************************************************/
23 
24 #ifndef DLHISTOGRAMWINDOW_H
25 #define DLHISTOGRAMWINDOW_H
26 
27 #include "ptImage8.h"
28 
29 #include <QAction>
30 #include <QTimer>
31 #include <QLabel>
32 
33 //==============================================================================
34 
35 // forward for faster compilation
36 class ptImage;
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 //
40 // ptHistogramWindow is a Gui element showing a histogram.
41 //
42 ////////////////////////////////////////////////////////////////////////////////
43 
44 class ptHistogramWindow : public QWidget {
45 
46 Q_OBJECT
47 
48 public :
49 
50   const ptImage*      m_RelatedImage;
51   QTimer*             m_ResizeTimer; // To circumvent multi resize events.
52 
53   // Constructor.
54   ptHistogramWindow(const ptImage* RelatedImage,
55                           QWidget* Parent);
56   // Destructor.
57   ~ptHistogramWindow();
58 
59   // NewRelatedImage to associate anonter ptImage with this window.
60   void UpdateView(const ptImage* NewRelatedImage = NULL);
61   void Init();
62   void PixelInfo(const QString R, const QString G, const QString B);
63 
64 protected:
65   void resizeEvent(QResizeEvent*);
66   void paintEvent(QPaintEvent*);
sizeHint()67   QSize sizeHint() const { return QSize(200,200); }
minimumSizeHint()68   QSize minimumSizeHint() const { return QSize(100,100); }
heightForWidth(int w)69   int  heightForWidth(int w) const { return MIN(150,w); }
70   void contextMenuEvent(QContextMenuEvent *event);
71 
72 private slots:
73   void ResizeTimerExpired();
74   void MenuLnX();
75   void MenuLnY();
76   void MenuCrop();
77   void MenuChannel();
78   void MenuMode();
79 
80 public slots:
81   void PixelInfoHide();
82 
83 private:
84   ptImage8        m_Image8;
85   QPixmap*        m_QPixmap;
86   short           m_RecalcNeeded;
87   uint32_t        m_HistoMax;
88   short           m_PreviousHistogramGamma;
89   short           m_PreviousHistogramLogX;
90   short           m_PreviousHistogramLogY;
91   QString         m_PreviousFileName;
92   QAction*        m_AtnLnX;
93   QAction*        m_AtnLnY;
94   QAction*        m_AtnCrop;
95   QActionGroup*   m_ModeGroup;
96   QAction*        m_AtnLinear;
97   QAction*        m_AtnPreview;
98   QAction*        m_AtnOutput;
99   QActionGroup*   m_ChannelGroup;
100   QAction*        m_AtnRGB;
101   QAction*        m_AtnR;
102   QAction*        m_AtnG;
103   QAction*        m_AtnB;
104   uint16_t*       m_LookUp;
105 
106   void CalculateHistogram();
107   void FillLookUp();
108   void InitOverlay();
109   void setInfoIconState(bool AIsActive);
110 
111   QLabel*         m_PixelInfoR;
112   QLabel*         m_PixelInfoG;
113   QLabel*         m_PixelInfoB;
114   QLabel*         m_InfoIcon;
115   QTimer*         m_PixelInfoTimer;
116   QPalette*       m_OverlayPalette;
117 };
118 
119 #endif
120 
121 ////////////////////////////////////////////////////////////////////////////////
122