Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Widget.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLQt/src/ICLQt/Widget.h                               **
00010 ** Module : ICLQt                                                  **
00011 ** Authors: Christof Elbrechter                                    **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #include <ICLUtils/CompatMacros.h>
00034 #include <ICLCore/ImgBase.h>
00035 #include <QtOpenGL/QGLWidget>
00036 #include <ICLCore/Types.h>
00037 #include <ICLQt/ImageStatistics.h>
00038 #include <ICLQt/MouseHandler.h>
00039 #include <ICLQt/WidgetCaptureMode.h>
00040 #include <ICLQt/GUI.h>
00041 #include <ICLUtils/Function.h>
00042 #include <ICLCore/Color.h>
00043 
00044 namespace icl{
00045   namespace qt{
00046   
00048     class PaintEngine;
00049     class OSDGLButton;
00052 
00053 
00066     class ICLQt_API ICLWidget : public QGLWidget{
00067       Q_OBJECT
00068       public:
00070       friend class OSDGLButton;
00071 
00072       class Data;   
00073       class OutputBufferCapturer;
00074     
00076       enum fitmode{ 
00077         fmNoScale=0,  
00078         fmHoldAR=1,   
00079         fmFit=2,      
00080         fmZoom=3      
00081       };
00082     
00084       enum rangemode { 
00085         rmOn = 1 ,  
00086         rmOff = 2 , 
00087         rmAuto      
00088       };   
00089     
00091       ICLWidget(QWidget *parent = 0);
00092     
00094       virtual ~ICLWidget();
00095 
00097       virtual void initializeGL();
00098     
00100       virtual void resizeGL(int w, int h);
00101     
00103       virtual void paintGL();
00104 
00106       virtual void paintEvent(QPaintEvent *e);
00107     
00109       virtual void customPaintEvent(PaintEngine *e);
00110 
00111       virtual void setVisible(bool visible);
00112 
00114       void setFitMode(fitmode fm);
00115     
00117       void setRangeMode(rangemode rm);
00118     
00120       void setBCI(int brightness, int contrast, int intensity);
00121 
00122     
00124       utils::Size getSize() { return utils::Size(width(),height()); }
00125     
00127       utils::Size getImageSize(bool fromGUIThread = false);
00128 
00130       utils::Rect getImageRect(bool fromGUIThread = false);
00131 
00133       fitmode getFitMode();
00134         
00136       rangemode getRangeMode();
00137 
00139       std::vector<std::string> getImageInfo();
00140 
00141     
00143 
00144       void install(MouseHandler *h);
00145 
00147 
00148       void uninstall(MouseHandler *h);
00149 
00151 
00161       void registerCallback(const GUI::Callback &cb, const std::string &eventList = "drag,press");
00162 
00164       void removeCallbacks();
00165 
00167 
00168       void render();
00169 
00171       virtual bool event(QEvent *event);
00172     
00174       const ImageStatistics &getImageStatistics();
00175 
00177       void setMenuEnabled(bool enabled);
00178     
00180       void setImageInfoIndicatorEnabled(bool enabled);
00181     
00183       void setShowNoImageWarnings(bool showWarnings);
00184     
00186 
00188       void setViewPort(const utils::Size &size);
00189 
00191 
00207       void addSpecialToggleButton(const std::string &id,
00208                                   const core::ImgBase* untoggledIcon = 0, 
00209                                   const core::ImgBase *toggledIcon = 0, 
00210                                   bool initiallyToggled = 0, 
00211                                   const utils::Function<void,bool> &cb=(utils::FunctionImpl<void,bool>*)0,//Function<void,bool>(), fix for clang
00212                                   const std::string &toolTipText="");
00213 
00215 
00216       void addSpecialButton(const std::string &id,
00217                             const core::ImgBase* icon = 0, 
00218                             const utils::Function<void> &cb=(utils::FunctionImpl<void>*)0,//Function<void>(), fix for clang
00219                             const std::string &toolTipText="");
00220 
00222 
00224       void setInfoText(const std::string &text);
00225     
00227       void removeSpecialButton(const std::string &id);
00228 
00230 
00232       void setAutoRenderOnSetImage(bool on);
00233     
00234       public slots:
00236       void setImage(const core::ImgBase *image);
00237 
00238       signals:
00240       void mouseEvent(const MouseEvent &event);
00241 
00243       void specialButtonClicked(const std::string &id);
00244 
00246       void specialButtonToggled(const std::string &id, bool down);
00247 
00248       public:
00250       typedef utils::Function<core::Color> BGColorSource;
00251 
00253 
00257       void setBackgroundColorSource(BGColorSource src);
00258 
00259       protected:
00260       
00262         void showInfoDialog();
00263 
00265 
00266       virtual void swapQueues(){}
00267 
00268       public:
00269       virtual void mousePressEvent(QMouseEvent *e);
00270       virtual void mouseReleaseEvent(QMouseEvent *e);
00271       virtual void mouseMoveEvent(QMouseEvent *e);
00272       virtual void enterEvent(QEvent *e);
00273       virtual void leaveEvent(QEvent *e);
00274       virtual void resizeEvent(QResizeEvent *e);
00275       virtual void wheelEvent(QWheelEvent *e);
00276       virtual void hideEvent(QHideEvent *e);
00278       virtual void keyPressEvent(QKeyEvent *event);
00279     
00280       public slots:
00281       void showHideMenu();
00282       void setMenuEmbedded(bool embedded);
00283 
00284       void bciModeChanged(int modeIdx);
00285       void brightnessChanged(int val);
00286       void contrastChanged(int val);
00287       void intensityChanged(int val);
00288     
00289       void scaleModeChanged(int modeIdx);
00290       void currentChannelChanged(int modeIdx);
00291 
00292       void captureCurrentImage();
00293       void captureCurrentFrameBuffer();
00294     
00295       void recordButtonToggled(bool checked);
00296       void pauseButtonToggled(bool checked);
00297       void stopButtonClicked();
00298       void skipFramesChanged(int frameSkip);
00299       void menuTabChanged(int index);
00300       void histoPanelParamChanged();
00301     
00302       void setEmbeddedZoomModeEnabled(bool enabled);
00303     
00304       void setLinInterpolationEnabled(bool enabled);
00305 
00306       void setShowPixelGridEnabled(bool enabled);
00307 
00308       void setRangeModeNormalOrScaled(bool enabled);
00309     
00310       void showBackgroundColorDialog();
00311       void showGridColorDialog();
00312       void setGridAlpha(int alpha);
00313       void setBackgroundBlack();
00314       void setBackgroundWhite();
00315       void setBackgroundGray();
00316       void setGridBlack();
00317       void setGridWhite();
00318       void setGridGray();
00319     
00320       private:
00322       const core::Img8u &grabFrameBufferICL();
00323     
00325       std::string getImageCaptureFileName();
00326     
00328       void updateInfoTab();
00329 
00331       void rebufferImageInternal();
00332 
00334       Data *m_data;
00335 
00337       const MouseEvent &createMouseEvent(MouseEventType type);
00338     };
00339   } // namespace qt
00340 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines