00001 // 00002 // C++ Interface: histogramwidget 00003 // 00004 // Author: Nicholas Phillips <Nicholas.G.Phillips@nasa.gov>, (C) 2008 00005 // 00006 // Copyright: See COPYING file that comes with this distribution 00007 // 00008 // 00009 #ifndef HISTOGRAMWIDGET_H 00010 #define HISTOGRAMWIDGET_H 00011 00012 #include <vector> 00013 #include <QWidget> 00014 00015 #include "enums.h" 00016 #include "histogram.h" 00017 #include "ui_histogramwidget.h" 00018 00019 //class HealpixMap; 00020 class Skymap; 00021 class ColorTable; 00022 00023 /* 00024 Main class for displaying and selecting the color table range 00025 baseded on a histogram of possible values. 00026 00027 The widget needs a vector of values and display options TBD. 00028 It emits a newRange signal when there is a new range. 00029 00030 There two basic parts to this widget. The top part is a custom 00031 HistoView widget. It has the responsibility of displaying the 00032 histogram and highlighting the current color range. 00033 00034 The bottom part are the range control sliders and present ComboBoxes. 00035 They have been laid out via Qt's designer. See histogramwidget.ui. 00036 00037 Finally, there are state variables including a Histogram object. 00038 00039 00040 A note on the sliders. They are 'rubber band' sliders, in that 00041 the distance of the slider from its mid-points determines the 00042 rate at which the value it controls changes. The further from 00043 the middle, the faster the value changes. Once the slider is 00044 released, it snaps back to the middle and the value stops changing. 00045 00046 While the slider is held, we use QTimers to monitor its position 00047 and update the value it is controling. If the updated value is 00048 still within range, the new values are sent to the HistoView. 00049 Otherwise, no update. This way we do not have to worry about out 00050 of range values being reached. We also have 'page step' turned 00051 off for all sliders. 00052 00053 Once the slider is released, the associated timer is stopped. 00054 00055 @author Nicholas Phillips <Nicholas.G.Phillips@nasa.gov> 00056 */ 00057 class HistogramWidget : public QWidget, private Ui::HistogramWidget 00058 { 00059 Q_OBJECT 00060 public: 00061 HistogramWidget(QWidget *); 00062 00063 // setup for the passed data 00064 void set(std::vector<float> &x); 00065 // Set based on a selected field of an Healpix Map 00066 void set(Skymap *map, Field fld); 00067 void set(ColorTable *); 00068 00069 signals: 00070 void newCenterZoom(float, float); 00071 void newRange(float, float); 00072 00073 private: 00074 const float minz; // Min allowed zoom 00075 00076 Histogram histogram; 00077 00078 float z; // Current zoom width 00079 float c; // Current Center 00080 float old_c; // Last valid center 00081 float old_z; // Lasr valid zoom 00082 00083 float lower; // Lower limit of current range 00084 float upper; // Upper limit of current range 00085 00086 float minr; // Min of range 00087 float maxr; // Max of range 00088 float cmean; // center for the data's mean 00089 float zstddev; // zoom for the data's std dev 00090 00091 00092 QTimer *cztimer; // Timer for sampling the center/zoom sliders 00093 QTimer *lutimer; // Timer for sampling the lower/upper sliders 00094 00095 private: 00096 void setComboBoxes(); 00097 void setNewRange(); 00098 00099 private slots: 00100 void on_zoomSlider_sliderPressed(); 00101 void on_zoomSlider_sliderReleased(); 00102 void on_centerSlider_sliderPressed(); 00103 void on_centerSlider_sliderReleased(); 00104 00105 void on_lowerSlider_sliderPressed(); 00106 void on_lowerSlider_sliderReleased(); 00107 void on_upperSlider_sliderPressed(); 00108 void on_upperSlider_sliderReleased(); 00109 00110 void on_zoomComboBox_activated(int); 00111 void on_centerComboBox_activated(int); 00112 00113 void setNewCenterZoom(); 00114 void setNewLowerUpper(); 00115 00116 }; 00117 00118 #endif