1 #ifndef LUMINANCERANGE_WIDGET_H
2 #define LUMINANCERANGE_WIDGET_H
3 
4 /**
5  * @brief
6  *
7  * This file is a part of PFSTOOLS package.
8  * ----------------------------------------------------------------------
9  * Copyright (C) 2003,2004 Rafal Mantiuk and Grzegorz Krawczyk
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (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  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  * ----------------------------------------------------------------------
25  *
26  * @author Rafal Mantiuk, <mantiuk@mpi-sb.mpg.de>
27  *
28  * $Id: luminancerange_widget.h,v 1.4 2013/12/21 19:42:29 rafm Exp $
29  */
30 
31 #include <QMouseEvent>
32 #include <QPaintEvent>
33 #include <QFrame>
34 
35 class Histogram;
36 
37 namespace pfs
38 {
39   class Array2D;
40 }
41 
42 class LuminanceRangeWidget : public QFrame {
43   Q_OBJECT
44 public:
45   LuminanceRangeWidget( QWidget *parent=0 );
46   ~LuminanceRangeWidget();
47 
48   QSize sizeHint () const;
49 
50 protected:
51   void paintEvent( QPaintEvent * );
52   void mouseMoveEvent( QMouseEvent * );
53   void mousePressEvent( QMouseEvent * me );
54   void mouseReleaseEvent(QMouseEvent *);
55 
56   float draggedMin();
57   float draggedMax();
58 
59 signals:
60   void updateRangeWindow();
61 public slots:
62   void decreaseExposure();
63   void increaseExposure();
64   void extendRange();
65   void shrinkRange();
66   void fitToDynamicRange();
67   void lowDynamicRange();
68 
69 private:
70   float minValue;
71   float maxValue;
72 
73   float windowMin;
74   float windowMax;
75 
76 
77   static const int DRAGNOTSTARTED = -1;
78   int mouseDragStart;
79   float dragShift;
80   enum DragMode
81     {
82       DRAG_MIN, DRAG_MAX, DRAG_MINMAX, DRAG_NO
83     };
84   DragMode dragMode;
85 
86   float valuePointer;
87 
88   Histogram *histogram;
89   const pfs::Array2D *histogramImage;
90 
91   bool showVP;
92 
93   QRect getPaintRect() const;
94 
95 public:
getRangeWindowMin()96   float getRangeWindowMin() const
97     {
98       return windowMin;
99     }
getRangeWindowMax()100   float getRangeWindowMax() const
101     {
102       return windowMax;
103     }
104 
105   void setRangeWindowMinMax( float min, float max );
106 
107   void setHistogramImage( const pfs::Array2D *image );
108 
109   void showValuePointer( float value );
110   void hideValuePointer();
111 
112 
113 };
114 
115 
116 #endif
117