1 #ifndef PFSVIEW_WIDGET_H
2 #define PFSVIEW_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: pfsview_widget.h,v 1.10 2011/04/30 14:01:17 rafm Exp $
29  */
30 
31 #include <qpainter.h>
32 #include <qimage.h>
33 #include <QEvent>
34 #include <QMouseEvent>
35 #include <QAction>
36 #include <QScrollArea>
37 
38 #include <array2d.h>
39 
40 namespace pfs {
41   class DOMIO;
42   class Frame;
43 }
44 
45 enum RGBClippingMethod {
46   CLIP_SIMPLE = 0,
47   CLIP_COLORCODED,
48   CLIP_KEEP_BRI_HUE,
49   CLIP_COUNT
50 };
51 
52 enum LumMappingMethod {
53   MAP_LINEAR,
54   MAP_GAMMA1_4,
55   MAP_GAMMA1_8,
56   MAP_GAMMA2_2,
57   MAP_GAMMA2_6,
58   MAP_LOGARITHMIC
59 };
60 
61 enum InfNaNTreatment {
62   INFNAN_HIDE=0,
63   INFNAN_MARK_AS_RED
64 };
65 
66 enum NegativeTreatment {
67   NEGATIVE_BLACK=0,
68   NEGATIVE_MARK_AS_RED,
69   NEGATIVE_GREEN_SCALE,
70   NEGATIVE_ABSOLUTE,
71   NEGATIVE_COUNT
72 };
73 
74 
75 struct PointerValue
76 {
77   int x, y;
78   float value[3];
79   int valuesUsed;
80   bool valid;
81 };
82 
83 
84 class PFSViewWidgetArea : public QScrollArea {
85   Q_OBJECT
86 public:
87   PFSViewWidgetArea( QWidget *parent=0 );
88 
89   QSize sizeHint() const;
90 
91 };
92 
93 
94 class PFSViewWidget : public QWidget {
95   Q_OBJECT
96 public:
97   PFSViewWidget( QWidget *parent=0 );
98   ~PFSViewWidget();
99 
100 public slots:
101   void zoomIn();
102   void zoomOut();
103   void zoomOriginal();
104 
105   void setRGBClippingMethod( QAction *action );
106   void setInfNaNTreatment( QAction *action );
107   void setNegativeTreatment( QAction *action );
108   void setLumMappingMethod( int method );
109 
110 signals:
111   void updatePointerValue();
112 
113 protected:
114 //  void paintEvent( QPaintEvent * );
115 
116 
117   void updateZoom();
118   void updateMapping();
119   void postUpdateMapping();
120 
121   void mouseMoveEvent( QMouseEvent *mouseEvent );
122   void setPointer( int x = -1, int y = -1 );
123   void leaveEvent( QEvent * );
124 
125   void paintEvent( QPaintEvent *event );
126 
127 private:
128   pfs::Frame *pfsFrame;
129   const char *visibleChannel;
130   QByteArray visibleChannelName;
131 
132   bool colorChannelsPresent;
133 
134   bool updateMappingRequested;
135 
136   QImage *image;
137 
138   float minValue;
139   float maxValue;
140 
141   RGBClippingMethod clippingMethod;
142   InfNaNTreatment infNaNTreatment;
143   NegativeTreatment negativeTreatment;
144   LumMappingMethod mappingMethod;
145 
146   bool fit_to_content_mode; // If true, newly loaded frames are resized to fit the window
147 
148   float zoom;
149 
150   pfs::Array2D *workArea[3];
151 
152   PointerValue pointerValue;
153 
154   QRegion selection;
155 
156 public:
157   QSize sizeHint() const;
158 
159   const PointerValue &getPointerValue();
160   void setRangeWindow( float min, float max );
161 
162   const pfs::Array2D *getPrimaryChannel();
163 
164   const QList<const char*> getChannels();
165 
166   void setVisibleChannel( const char *channelName );
167   const char *getVisibleChannel();
168 
169   bool hasColorChannels( pfs::Frame *frame = NULL );
170 
171 /*  void setFitToContentMode( bool active )
172   {
173     fit_to_content_mode = active;
174     }*/
175 
176 
getZoom()177   float getZoom() const
178     {
179       return zoom;
180     }
181 
182   void setFrame( pfs::Frame *frame );
183 
getDisplayedImage()184   QImage *getDisplayedImage()
185     {
186       assert( image != NULL );
187       return image;
188     }
189 
190 
191 };
192 
193 
194 class PFSViewException
195 {
196 };
197 
198 extern const char* COLOR_CHANNELS;
199 
200 #endif
201