PSQt/include/WdgColorBar.h

Go to the documentation of this file.
00001 #ifndef WDGCOLORBAR_H
00002 #define WDGCOLORBAR_H
00003 
00004 #include <QWidget>
00005 #include <QLabel>
00006 #include <QPainter>
00007 #include <QPixmap>
00008 
00009 #include <Qt>
00010 #include <QtGui>
00011 #include <QtCore>
00012 
00013 #include "PSQt/QGUtils.h"
00014 #include "ndarray/ndarray.h"
00015 
00016 namespace PSQt {
00017 
00018 /**
00019  *  @ingroup PSQt
00020  *  @brief ORIENT - enumerator for four color bar orientations; horisontal with raising color index to right or left and vertical with rising color index from to up and down.  
00021  */
00022 enum ORIENT {HR=0, HL, VU, VD};
00023 
00024 
00025 /**
00026  *  @ingroup PSQt
00027  * 
00028  *  @brief QLable-type widget with interactive image of the color bar. 
00029  * 
00030  *  Parameters of the color bar are set through the constructor, public method setColorBar, 
00031  *  and slot:
00032  *  @code
00033  *   public slots:                                            
00034  *      void onHueAnglesUpdated(const float&, const float&) ; 
00035  *  @endcode
00036  * 
00037  *  Emits signals on mouse button press/release/move:
00038  *  @code
00039  *   signals :                                                
00040  *      void pressColorBar  (QMouseEvent*, const float&) ;      
00041  *      void releaseColorBar(QMouseEvent*, const float&) ;    
00042  *      void moveOnColorBar (QMouseEvent*, const float&) ;     
00043  *  @endcode
00044  *                                                            
00045  *
00046  *  This software was developed for the LCLS project.  If you use all or 
00047  *  part of it, please give an appropriate acknowledgment.
00048  *
00049  *  @see WdgColorTable.h
00050  *
00051  *  @version $Id: WdgColorBar.h 9841 2015-03-26 18:35:44Z dubrovin@SLAC.STANFORD.EDU $
00052  *
00053  *  @author Mikhail Dubrovin
00054  */
00055 
00056 class WdgColorBar : public QLabel
00057 {
00058  Q_OBJECT // macro is needed for connection of signals and slots
00059 
00060  public:
00061   /**
00062    *  @brief Class constructor with parameters
00063    *  
00064    *  @param[in] parent - pointer to the parent QWidget.
00065    *  @param[in] h1 - 1st boarder hue angle.
00066    *  @param[in] h2 - 2nd boarder hue angle.
00067    *  @param[in] colors - number of colors in the color bar.
00068    *  @param[in] orient - orientation from the numerated list: HR, HL, VU, VD
00069    *  @param[in] aspect - alpect ratio; width/length
00070    */ 
00071   WdgColorBar( QWidget *parent=0, 
00072                const float& h1=260, 
00073                const float& h2=-60, 
00074                const unsigned& colors=1024, 
00075                const ORIENT& orient=HR, 
00076                const float& aspect=0.03);
00077 
00078   virtual ~WdgColorBar();
00079 
00080     void setStyle() ;
00081     void showTips() ;
00082 
00083     void closeEvent (QCloseEvent  *event = 0) ;
00084     void moveEvent  (QMoveEvent   *event = 0) ;
00085 
00086     void setColorBar( const float&    h1=0,
00087                       const float&    h2=360,
00088                       const unsigned& colors=1024, 
00089                       const ORIENT&   orient=HR, 
00090                       const float&    aspect=0.03
00091                     );
00092 
00093  protected :
00094     void mousePressEvent   (QMouseEvent  *event = 0) ;
00095     void mouseReleaseEvent (QMouseEvent  *event = 0) ;
00096     void mouseMoveEvent    (QMouseEvent  *event = 0) ;
00097     void resizeEvent       (QResizeEvent *event = 0) ;
00098 
00099  signals :
00100   /**
00101    *  @brief Emiting signal parameters
00102    *  @param[in] - QMouseEvent*
00103    *  @param[in] - const float& - [0,1]-fraction of the color bar from zero index to the point of the click.
00104    */ 
00105     void pressColorBar(QMouseEvent*, const float&) ;
00106     void releaseColorBar(QMouseEvent*, const float&) ;
00107     void moveOnColorBar(QMouseEvent*, const float&) ;
00108 
00109  public slots:
00110     void onHueAnglesUpdated(const float&, const float&) ;
00111     void testPressColorBar(QMouseEvent*, const float&) ;
00112     void testReleaseColorBar(QMouseEvent*, const float&) ;
00113     void testMoveOnColorBar(QMouseEvent*, const float&) ; 
00114 
00115  private:
00116     float         m_h1;
00117     float         m_h2;
00118     unsigned      m_colors;
00119     ORIENT        m_orient;
00120     float         m_aspect; 
00121 
00122     QLabel*       m_lab_cbar;
00123     QPixmap*      m_pixmap_cbar;
00124 
00125     inline const char* _name_(){return "WdgColorBar";}
00126     float fractionOfColorBar(QMouseEvent *e);
00127     void connectForTest(); 
00128     void message(QMouseEvent* e, const float& frac, const char* comment);
00129 };
00130 
00131 } // namespace PSQt
00132 
00133 #endif // WDGCOLORBAR_H

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7