Image Component Library (ICL)
|
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.GPL ** 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 <QtOpenGL/QGLWidget> 00034 #include <ICLCore/ImgBase.h> 00035 #include <ICLCore/Types.h> 00036 #include <ICLQt/ImageStatistics.h> 00037 #include <ICLQt/MouseHandler.h> 00038 #include <ICLQt/WidgetCaptureMode.h> 00039 #include <ICLQt/GUI.h> 00040 #include <ICLUtils/Function.h> 00041 #include <ICLCore/Color.h> 00042 00043 namespace icl{ 00044 namespace qt{ 00045 00047 class PaintEngine; 00048 class OSDGLButton; 00051 00052 00065 class ICLWidget : public QGLWidget{ 00066 Q_OBJECT 00067 public: 00069 friend class OSDGLButton; 00070 00071 class Data; 00072 class OutputBufferCapturer; 00073 00075 enum fitmode{ 00076 fmNoScale=0, 00077 fmHoldAR=1, 00078 fmFit=2, 00079 fmZoom=3 00080 }; 00081 00083 enum rangemode { 00084 rmOn = 1 , 00085 rmOff = 2 , 00086 rmAuto 00087 }; 00088 00090 ICLWidget(QWidget *parent=0); 00091 00093 virtual ~ICLWidget(); 00094 00096 virtual void initializeGL(); 00097 00099 virtual void resizeGL(int w, int h); 00100 00102 virtual void paintGL(); 00103 00105 virtual void paintEvent(QPaintEvent *e); 00106 00108 virtual void customPaintEvent(PaintEngine *e); 00109 00110 virtual void setVisible(bool visible); 00111 00113 void setFitMode(fitmode fm); 00114 00116 void setRangeMode(rangemode rm); 00117 00119 void setBCI(int brightness, int contrast, int intensity); 00120 00121 00123 utils::Size getSize() { return utils::Size(width(),height()); } 00124 00126 utils::Size getImageSize(bool fromGUIThread=false); 00127 00129 utils::Rect getImageRect(bool fromGUIThread=false); 00130 00132 fitmode getFitMode(); 00133 00135 rangemode getRangeMode(); 00136 00138 std::vector<std::string> getImageInfo(); 00139 00140 00142 00143 void install(MouseHandler *h); 00144 00146 00147 void uninstall(MouseHandler *h); 00148 00150 00160 void registerCallback(const GUI::Callback &cb, const std::string &eventList="drag,press"); 00161 00163 void removeCallbacks(); 00164 00166 00167 void render(); 00168 00170 virtual bool event(QEvent *event); 00171 00173 const ImageStatistics &getImageStatistics(); 00174 00176 void setMenuEnabled(bool enabled); 00177 00179 void setImageInfoIndicatorEnabled(bool enabled); 00180 00182 void setShowNoImageWarnings(bool showWarnings); 00183 00185 00187 void setViewPort(const utils::Size &size); 00188 00190 00206 void addSpecialToggleButton(const std::string &id, 00207 const core::ImgBase* untoggledIcon = 0, 00208 const core::ImgBase *toggledIcon = 0, 00209 bool initiallyToggled = 0, 00210 const utils::Function<void,bool> &cb=(utils::FunctionImpl<void,bool>*)0,//Function<void,bool>(), fix for clang 00211 const std::string &toolTipText=""); 00212 00214 00215 void addSpecialButton(const std::string &id, 00216 const core::ImgBase* icon = 0, 00217 const utils::Function<void> &cb=(utils::FunctionImpl<void>*)0,//Function<void>(), fix for clang 00218 const std::string &toolTipText=""); 00219 00221 00223 void setInfoText(const std::string &text); 00224 00226 void removeSpecialButton(const std::string &id); 00227 00229 00231 void setAutoRenderOnSetImage(bool on); 00232 00233 public slots: 00235 void setImage(const core::ImgBase *image); 00236 00237 signals: 00239 void mouseEvent(const MouseEvent &event); 00240 00242 void specialButtonClicked(const std::string &id); 00243 00245 void specialButtonToggled(const std::string &id, bool down); 00246 00247 public: 00249 typedef utils::Function<core::Color> BGColorSource; 00250 00252 00256 void setBackgroundColorSource(BGColorSource src); 00257 00258 protected: 00259 00261 void showInfoDialog(); 00262 00264 00265 virtual void swapQueues(){} 00266 00267 public: 00268 virtual void mousePressEvent(QMouseEvent *e); 00269 virtual void mouseReleaseEvent(QMouseEvent *e); 00270 virtual void mouseMoveEvent(QMouseEvent *e); 00271 virtual void enterEvent(QEvent *e); 00272 virtual void leaveEvent(QEvent *e); 00273 virtual void resizeEvent(QResizeEvent *e); 00274 virtual void wheelEvent(QWheelEvent *e); 00275 virtual void hideEvent(QHideEvent *e); 00277 virtual void keyPressEvent(QKeyEvent *event); 00278 00279 public slots: 00280 void showHideMenu(); 00281 void setMenuEmbedded(bool embedded); 00282 00283 void bciModeChanged(int modeIdx); 00284 void brightnessChanged(int val); 00285 void contrastChanged(int val); 00286 void intensityChanged(int val); 00287 00288 void scaleModeChanged(int modeIdx); 00289 void currentChannelChanged(int modeIdx); 00290 00291 void captureCurrentImage(); 00292 void captureCurrentFrameBuffer(); 00293 00294 void recordButtonToggled(bool checked); 00295 void pauseButtonToggled(bool checked); 00296 void stopButtonClicked(); 00297 void skipFramesChanged(int frameSkip); 00298 void menuTabChanged(int index); 00299 void histoPanelParamChanged(); 00300 00301 void setEmbeddedZoomModeEnabled(bool enabled); 00302 00303 void setLinInterpolationEnabled(bool enabled); 00304 00305 void setShowPixelGridEnabled(bool enabled); 00306 00307 void setRangeModeNormalOrScaled(bool enabled); 00308 00309 void showBackgroundColorDialog(); 00310 void showGridColorDialog(); 00311 void setGridAlpha(int alpha); 00312 void setBackgroundBlack(); 00313 void setBackgroundWhite(); 00314 void setBackgroundGray(); 00315 void setGridBlack(); 00316 void setGridWhite(); 00317 void setGridGray(); 00318 00319 private: 00321 const core::Img8u &grabFrameBufferICL(); 00322 00324 std::string getImageCaptureFileName(); 00325 00327 void updateInfoTab(); 00328 00330 void rebufferImageInternal(); 00331 00333 Data *m_data; 00334 00336 const MouseEvent &createMouseEvent(MouseEventType type); 00337 }; 00338 } // namespace qt 00339 }