Image Component Library (ICL)
Widget.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLQt/src/ICLQt/Widget.h **
10 ** Module : ICLQt **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLCore/ImgBase.h>
35 #include <QtOpenGL/QGLWidget>
36 #include <ICLCore/Types.h>
37 #include <ICLQt/ImageStatistics.h>
38 #include <ICLQt/MouseHandler.h>
40 #include <ICLQt/GUI.h>
41 #include <ICLUtils/Function.h>
42 #include <ICLCore/Color.h>
43 
44 namespace icl{
45  namespace qt{
46 
48  class PaintEngine;
49  class OSDGLButton;
52 
66  class ICLQt_API ICLWidget : public QGLWidget{
67  Q_OBJECT
68  public:
70  friend class OSDGLButton;
71 
72  class Data;
73  class OutputBufferCapturer;
74 
76  enum fitmode{
77  fmNoScale=0,
78  fmHoldAR=1,
79  fmFit=2,
80  fmZoom=3
81  };
82 
84  enum rangemode {
85  rmOn = 1 ,
86  rmOff = 2 ,
87  rmAuto
88  };
89 
91  ICLWidget(QWidget *parent = 0);
92 
94  virtual ~ICLWidget();
95 
97  virtual void initializeGL();
98 
100  virtual void resizeGL(int w, int h);
101 
103  virtual void paintGL();
104 
106  virtual void paintEvent(QPaintEvent *e);
107 
109  virtual void customPaintEvent(PaintEngine *e);
110 
111  virtual void setVisible(bool visible);
112 
114  void setFitMode(fitmode fm);
115 
117  void setRangeMode(rangemode rm);
118 
120  void setBCI(int brightness, int contrast, int intensity);
121 
122 
124  utils::Size getSize() { return utils::Size(width(),height()); }
125 
127  utils::Size getImageSize(bool fromGUIThread = false);
128 
130  utils::Rect getImageRect(bool fromGUIThread = false);
131 
133  fitmode getFitMode();
134 
136  rangemode getRangeMode();
137 
139  std::vector<std::string> getImageInfo();
140 
141 
143 
144  void install(MouseHandler *h);
145 
147 
148  void uninstall(MouseHandler *h);
149 
151 
161  void registerCallback(const GUI::Callback &cb, const std::string &eventList = "drag,press");
162 
164  void removeCallbacks();
165 
167 
168  void render();
169 
171  virtual bool event(QEvent *event);
172 
174  const ImageStatistics &getImageStatistics();
175 
177  void setMenuEnabled(bool enabled);
178 
180  void setImageInfoIndicatorEnabled(bool enabled);
181 
183  void setShowNoImageWarnings(bool showWarnings);
184 
186 
188  void setViewPort(const utils::Size &size);
189 
190 
192 
193  void setFullScreenMode(bool on, int screen=-1);
194 
195 
197 
213  void addSpecialToggleButton(const std::string &id,
214  const core::ImgBase* untoggledIcon = 0,
215  const core::ImgBase *toggledIcon = 0,
216  bool initiallyToggled = 0,
217  const utils::Function<void,bool> &cb=(utils::FunctionImpl<void,bool>*)0,//Function<void,bool>(), fix for clang
218  const std::string &toolTipText="");
219 
221 
222  void addSpecialButton(const std::string &id,
223  const core::ImgBase* icon = 0,
224  const utils::Function<void> &cb=(utils::FunctionImpl<void>*)0,//Function<void>(), fix for clang
225  const std::string &toolTipText="");
226 
228 
230  void setInfoText(const std::string &text);
231 
233  void removeSpecialButton(const std::string &id);
234 
236 
238  void setAutoRenderOnSetImage(bool on);
239 
240  public Q_SLOTS:
242  void setImage(const core::ImgBase *image);
243 
244  private Q_SLOTS:
246  void reEmbed();
247 
248  Q_SIGNALS:
250  void mouseEvent(const MouseEvent &event);
251 
253  void specialButtonClicked(const std::string &id);
254 
256  void specialButtonToggled(const std::string &id, bool down);
257 
258  public:
261 
263 
267  void setBackgroundColorSource(BGColorSource src);
268 
269 
271  void startRecording(const std::string &outputDevice,
272  const std::string &outputInfo,
273  bool framebuffer=true, int frameskip=0,
274  bool setParamsOnlyButDoNotStartRecording=false);
275 
277 
280  void registerRecordingCallback(utils::Function<void,const core::ImgBase*> cb,
281  const std::string &handle="default");
282 
284  void unregisterRecordingCallback(const std::string &handle="default");
285 
286  protected:
287 
289  void showInfoDialog();
290 
292 
293  virtual void swapQueues(){}
294 
295  public:
296  virtual void mousePressEvent(QMouseEvent *e);
297  virtual void mouseReleaseEvent(QMouseEvent *e);
298  virtual void mouseMoveEvent(QMouseEvent *e);
299  virtual void enterEvent(QEvent *e);
300  virtual void leaveEvent(QEvent *e);
301  virtual void resizeEvent(QResizeEvent *e);
302  virtual void wheelEvent(QWheelEvent *e);
303  virtual void hideEvent(QHideEvent *e);
305  virtual void keyPressEvent(QKeyEvent *event);
306 
307  public Q_SLOTS:
308  void showHideMenu();
309  void setMenuEmbedded(bool embedded);
310 
311  void bciModeChanged(int modeIdx);
312  void brightnessChanged(int val);
313  void contrastChanged(int val);
314  void intensityChanged(int val);
315 
316  void scaleModeChanged(int modeIdx);
317  void currentChannelChanged(int modeIdx);
318 
319  void captureCurrentImage();
320  void captureCurrentFrameBuffer();
321 
322  void recordButtonToggled(bool checked);
323  void pauseButtonToggled(bool checked);
324  void stopButtonClicked();
325  void skipFramesChanged(int frameSkip);
326  void menuTabChanged(int index);
327  void histoPanelParamChanged();
328 
329  void setEmbeddedZoomModeEnabled(bool enabled);
330 
331  void setLinInterpolationEnabled(bool enabled);
332 
333  void setShowPixelGridEnabled(bool enabled);
334 
335  void setRangeModeNormalOrScaled(bool enabled);
336 
337  void showBackgroundColorDialog();
338  void showGridColorDialog();
339  void setGridAlpha(int alpha);
340  void setBackgroundBlack();
341  void setBackgroundWhite();
342  void setBackgroundGray();
343  void setGridBlack();
344  void setGridWhite();
345  void setGridGray();
346 
347  private:
349  const core::Img8u &grabFrameBufferICL();
350 
352  std::string getImageCaptureFileName();
353 
355  void updateInfoTab();
356 
358  void rebufferImageInternal();
359 
361  Data *m_data;
362 
364  const MouseEvent &createMouseEvent(MouseEventType type);
365  };
366  } // namespace qt
367 }
undocument this line if you encounter any issues!
Definition: Any.h:37
Class for openGL-based image visualization components.
Definition: Widget.h:66
MouseEventType
list of supported mouse event types
Definition: MouseEvent.h:48
ICLQt_API void text(ImgQ &image, int x, int y, const string &text)
renders a text into an image (only available with Qt-Support)
rangemode
determines intensity adaption mode
Definition: Widget.h:84
utils::Function< core::Color > BGColorSource
generic background color creator plugin
Definition: Widget.h:260
General Implementation for binary functions.
Definition: Function.h:47
Size class of the ICL.
Definition: Size.h:61
Data * m_data
Internal data class (large, so it's hidden)
Definition: Widget.h:361
utils::Size getSize()
returns the widgets size as icl::Size
Definition: Widget.h:124
virtual void swapQueues()
this is reimplemented by the DrawWidget and by the DrawWidget3D for internal buffers swapping
Definition: Widget.h:293
Definition: ImageStatistics.h:42
MouseEvent Handler.
Definition: MouseHandler.h:92
fitmode
determines how the image is fit into the widget geometry
Definition: Widget.h:76
#define ICLQt_API
Definition: CompatMacros.h:178
Provided by interface MouseGrabber.
Definition: MouseEvent.h:86
pure virtual Paint engine interface
Definition: PaintEngine.h:49
Rectangle class of the ICL used e.g. for the Images ROI-rect.
Definition: Rect.h:95
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131