Image Component Library (ICL)
GUIComponents.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/GUIComponents.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 <ICLUtils/Any.h>
36 
37 namespace icl{
39  namespace utils{
40  class Configurable;
41  }
44  namespace qt{
46 
50  struct Button : public GUIComponentWithOutput{
51  private:
53  static std::string form_args(const std::string &text, const std::string &toggledText, bool initiallyToggled){
54  if(!toggledText.length()){
55  return text;
56  }
57  std::ostringstream str;
58  str << text << ',';
59  if(initiallyToggled) str << '!';
60  str << toggledText;
61  return str.str();
62  }
63  public:
65  Button(const std::string &text, const std::string &toggledText="", bool initiallyToggled=false):
66  GUIComponentWithOutput(toggledText.length() ? "togglebutton" : "button",form_args(text,toggledText,initiallyToggled)){}
67  };
68 
70 
72  ButtonGroup(const std::string &commaSepTexts):
73  GUIComponentWithOutput("buttongroup",commaSepTexts){}
74  };
75 
77 
80  CheckBox(const std::string &label, bool checked=false):
81  GUIComponentWithOutput("checkbox",label+','+(checked ? "checked":"unchecked")){}
82  };
83 
85 
86  struct Label : public GUIComponent{
88  Label(const std::string &text=""):GUIComponent("label",text){}
89  };
90 
92 
94  struct Slider : public GUIComponentWithOutput{
96  Slider(int min=0, int max=100, int curr=50, bool vertical=false, int stepping=1):
97  GUIComponentWithOutput("slider",form_args_6(min,max,curr,vertical?"vertical":"horizontal","on",stepping)){}
98 
100  Slider(const utils::Range32f &r, int curr, bool vertical=false, int stepping=1):
101  GUIComponentWithOutput("slider",form_args_6(r.minVal,r.maxVal,curr,vertical?"vertical":"horizontal","on",stepping)){}
102  };
103 
105 
109  FSlider(float min=0, float max=1, float curr=0.5, bool vertical=false):
110  GUIComponentWithOutput("fslider",form_args_4(min,max,curr,vertical?"vertical":"horizontal")){}
111 
113  FSlider(const utils::Range32f &r, float curr=0.5, bool vertical=false):
114  GUIComponentWithOutput("fslider",form_args_4(r.minVal,r.maxVal,curr,vertical?"vertical":"horizontal")){}
115  };
116 
118 
119  struct Int : public GUIComponentWithOutput{
121  Int(int min=0, int max=100, int curr=50):
122  GUIComponentWithOutput("int",form_args_3(min, max, curr)){}
123  };
124 
126 
127  struct Float : public GUIComponentWithOutput{
129  Float(float min=0, float max=1, float curr=0.5):
130  GUIComponentWithOutput("float",form_args_3(min, max, curr)){}
131  };
132 
134 
135  struct String : public GUIComponent{
137  String(const std::string &initText, int maxLen=100):GUIComponent("string",initText+','+utils::str(maxLen)){}
138  };
139 
141 
142  struct Disp : public GUIComponent{
143  Disp(int nxCells, int nyCells):
144  GUIComponent("disp",utils::str(nxCells)+','+utils::str(nyCells)){}
145  };
146 
148 
149  struct Image : public GUIComponent{
151  Image():GUIComponent("image"){}
152  };
153 
155 
156  struct Draw : public GUIComponent{
158 
160  Draw(const utils::Size &defaultViewPortsize=utils::Size::VGA):
161  GUIComponent("draw",str(defaultViewPortsize)){}
162  };
163 
165 
168  struct Draw3D : public GUIComponent{
170 
172  Draw3D(const utils::Size &defaultViewPortsize=utils::Size::VGA):
173  GUIComponent("draw3D",str(defaultViewPortsize)){}
174  };
175 
177 
178  struct Plot : public GUIComponent{
179  private:
181  static std::string form_args(const utils::Range32f xRange,
182  const utils::Range32f yRange, bool useOpenGL,
183  const std::string &xLabel, const std::string &yLabel){
184  std::ostringstream str;
185  str << xRange.minVal << ',' << xRange.maxVal << ',' << yRange.minVal << ',' << yRange.maxVal << ','
186  << (useOpenGL ? "gl" : "noGL");
187  if(xLabel.length()){
188  str << ',' << xLabel;
189  if(xLabel.length()){
190  str << ',' << yLabel;
191  }
192  }
193  return str.str();
194  }
195 
196  public:
198 
204  Plot(const utils::Range32f xRange=utils::Range32f(0,0),
205  const utils::Range32f yRange=utils::Range32f(0,0),
206  bool useOpenGL=false,
207  const std::string &xLabel="",
208  const std::string &yLabel=""):
209  GUIComponent("plot",form_args(xRange,xRange, useOpenGL, xLabel, yLabel)){}
210 
212 
213  Plot(float minX, float maxX=0, float minY=0, float maxY=0,
214  bool useOpenGL=false,
215  const std::string &xLabel="",
216  const std::string &yLabel=""):
217  GUIComponent("plot",form_args(utils::Range32f(minX,maxX),utils::Range32f(minY,maxY), useOpenGL, xLabel, yLabel)){}
218  };
219 
220 
221 
222 
224 
225  struct Combo : public GUIComponent{
226  private:
228  static std::string form_args(const std::string &entries, int initialIndex){
229  if(!initialIndex) return entries;
230  std::vector<std::string> ls = utils::tok(entries,",");
231  if(initialIndex < 0 || initialIndex >= (int)ls.size()){
232  throw utils::ICLException("Combo::Combo(entries,initialIndex): initialIndex is invalid");
233  }
234  ls[initialIndex] = '!' + ls[initialIndex];
235  return utils::cat(ls,",");
236  }
237  public:
239  Combo(const std::string &commaSepEntries, int initialIndex=0):
240  GUIComponent("combo",form_args(commaSepEntries,initialIndex)){}
241  };
242 
244 
247  Spinner(int min, int max, int curr):
248  GUIComponentWithOutput("spinner",form_args_3(min,max,curr)){}
249  };
250 
251 
253 
255  struct Fps : public GUIComponent{
257  Fps(int timeWindowSize=10):
258  GUIComponent("fps",utils::str(timeWindowSize)){}
259  };
260 
262 
269  struct CamCfg : public GUIComponent{
270  private:
272  static inline std::string form_args(const std::string &a, const std::string &b){
273  std::ostringstream str;
274  if(a.length()){
275  str << a;
276  if(b.length()){
277  str << ',' << b;
278  }
279  }
280  return str.str();
281  }
282  public:
284  CamCfg(const std::string &deviceTypeHint="", const std::string &deviceIDHint=""):GUIComponent("camcfg",form_args(deviceTypeHint,deviceIDHint)){}
285  };
286 
288 
292  struct Prop : public GUIComponent{
294  Prop(const std::string &configurableID):GUIComponent("prop",configurableID){}
295 
297  Prop(const utils::Configurable *cfg) : GUIComponent("prop","@pointer@:"+utils::Any::ptr(cfg)){
298  ICLASSERT_THROW(cfg, utils::ICLException("GUIComponent Prop(NULL-Pointer) cannot be created!"));
299  }
300 
302  Prop(const utils::Configurable &cfg):GUIComponent("prop","@pointer@:"+utils::Any::ptr(&cfg)){}
303  };
304 
306 
309 
310  ColorSelect(int r, int g, int b, int a=-1):GUIComponentWithOutput("color",a>=0 ? form_args_4(r,g,b,a) : form_args_3(r,g,b)){}
311  };
312 
314 
315  struct Ps : public GUIComponent{
317  Ps(int updatePFS=10):GUIComponent("ps",utils::str(updatePFS)){}
318  };
319 
320 
322  struct State : public GUIComponent{
324  State(int maxLines=100):GUIComponent("state",utils::str(maxLines)){}
325  };
326 
328  struct Dummy : public GUIComponent{
330  };
331 
333  struct Show : public GUIComponent{
334  Show():GUIComponent("!show"){};
335  };
336 
338  struct Create : public GUIComponent{
339  Create():GUIComponent("!create"){};
340  };
341 
342  } // namespace qt
343 }
ButtonGroup component (aka vertical list of radio buttons)
Definition: GUIComponents.h:71
For a state log panel.
Definition: GUIComponents.h:322
ComboBox GUI component.
Definition: GUIComponents.h:225
Plot(float minX, float maxX=0, float minY=0, float maxY=0, bool useOpenGL=false, const std::string &xLabel="", const std::string &yLabel="")
Create Plot component with optionally given POD parameters.
Definition: GUIComponents.h:213
Combo(const std::string &commaSepEntries, int initialIndex=0)
Constructor with given comma separated list of initial entries.
Definition: GUIComponents.h:239
static std::string form_args_4(const A &a, const B &b, const C &c, const D &d)
utility method to concatenate 4 values
Definition: GUIComponent.h:83
undocument this line if you encounter any issues!
Definition: Any.h:37
Show()
Definition: GUIComponents.h:334
Prop(const utils::Configurable *cfg)
create configurable component from given configurable (pointer)
Definition: GUIComponents.h:297
Finalizes GUI creation (actually creates the Qt-GUI but initially hidden)
Definition: GUIComponents.h:338
Int(int min=0, int max=100, int curr=50)
create integer input component with given range and initial value
Definition: GUIComponents.h:121
Color selection component.
Definition: GUIComponents.h:307
Definition: GUIComponentWithOutput.h:39
ICLQt_API void text(ImgQ &image, int x, int y, const string &text)
renders a text into an image (only available with Qt-Support)
Propery adjustment component for configuable instances.
Definition: GUIComponents.h:292
Finalizes GUI creation (actually creates the Qt-GUI and makes it visible)
Definition: GUIComponents.h:333
Create()
Definition: GUIComponents.h:339
Float(float min=0, float max=1, float curr=0.5)
create float input component with given range and initial value
Definition: GUIComponents.h:129
ICLUtils_API std::string cat(const std::vector< std::string > &v)
concatinates at string-vector to a single string
Frames per second estimator component.
Definition: GUIComponents.h:255
Button Component.
Definition: GUIComponents.h:50
Label(const std::string &text="")
create label with optionally given initial text
Definition: GUIComponents.h:88
Image visualization component.
Definition: GUIComponents.h:149
FSlider(const utils::Range32f &r, float curr=0.5, bool vertical=false)
creates a FSlider from given float-range
Definition: GUIComponents.h:113
String(const std::string &initText, int maxLen=100)
create string input compoent with given max length
Definition: GUIComponents.h:137
State(int maxLines=100)
create state widget
Definition: GUIComponents.h:324
Prop(const std::string &configurableID)
create configurable component reflecting the properties of the given Configurable instance
Definition: GUIComponents.h:294
Slider component for int-ranges.
Definition: GUIComponents.h:94
Dummy()
Definition: GUIComponents.h:329
static const Size VGA
Video Graphics Array res. 640x480.
Definition: Size.h:82
Text Input component, that allows integer inputs in a given range.
Definition: GUIComponents.h:119
CamCfg(const std::string &deviceTypeHint="", const std::string &deviceIDHint="")
create a camera configurabion component with optionally specified device
Definition: GUIComponents.h:284
static std::string form_args(const std::string &entries, int initialIndex)
utility method
Definition: GUIComponents.h:228
Slider(int min=0, int max=100, int curr=50, bool vertical=false, int stepping=1)
creates a slider with given POD parameters
Definition: GUIComponents.h:96
ButtonGroup(const std::string &commaSepTexts)
Definition: GUIComponents.h:72
const GUIComponentWithOutput & label(const std::string &label) const
sets the component label
Definition: GUIComponentWithOutput.h:50
Image visualization compoent that allows for 2D and 3D image annotation.
Definition: GUIComponents.h:168
Size class of the ICL.
Definition: Size.h:61
Text Input component, that allows float inputs in a given range.
Definition: GUIComponents.h:127
Process status component.
Definition: GUIComponents.h:315
The GUIComponent class servers as a generic interface for GUI definitions.
Definition: GUIComponent.h:44
Image()
constructor
Definition: GUIComponents.h:151
static std::string form_args_3(const A &a, const B &b, const C &c)
utility method to concatenate 3 values
Definition: GUIComponent.h:75
CheckBox component.
Definition: GUIComponents.h:78
static std::string form_args(const std::string &a, const std::string &b)
utility method
Definition: GUIComponents.h:272
camera configuration component
Definition: GUIComponents.h:269
std::string str(const T &t)
convert a data type into a string using an std::ostringstream instance
Definition: StringUtils.h:136
SpinBox component.
Definition: GUIComponents.h:245
static std::string form_args_6(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f)
utility method to concatenate 5 values
Definition: GUIComponent.h:99
Slider(const utils::Range32f &r, int curr, bool vertical=false, int stepping=1)
creates a slider from given int-range
Definition: GUIComponents.h:100
Draw3D(const utils::Size &defaultViewPortsize=utils::Size::VGA)
create Draw3D component with given defaultViewPortsize
Definition: GUIComponents.h:172
Text Input component, that allows float inputs with a given maximun length.
Definition: GUIComponents.h:135
Interface for classes that can be configured from configuration-files and GUI-Components.
Definition: Configurable.h:194
Base class for Exception handling in the ICL.
Definition: Exception.h:42
Ps(int updatePFS=10)
create ps component with given update rate
Definition: GUIComponents.h:317
Float-valued Slider component.
Definition: GUIComponents.h:107
Disp(int nxCells, int nyCells)
Definition: GUIComponents.h:143
Fps(int timeWindowSize=10)
creates fps component with given time window for estimating a running-average of the computed FPS-val...
Definition: GUIComponents.h:257
static std::string form_args(const utils::Range32f xRange, const utils::Range32f yRange, bool useOpenGL, const std::string &xLabel, const std::string &yLabel)
utility method
Definition: GUIComponents.h:181
FSlider(float min=0, float max=1, float curr=0.5, bool vertical=false)
creates a FSlider with given POD parameters
Definition: GUIComponents.h:109
Prop(const utils::Configurable &cfg)
create configurable component from given configurable (reference)
Definition: GUIComponents.h:302
Creates not component.
Definition: GUIComponents.h:328
static std::string form_args(const std::string &text, const std::string &toggledText, bool initiallyToggled)
utility method
Definition: GUIComponents.h:53
Display component for a 2D Array of labels.
Definition: GUIComponents.h:142
CheckBox(const std::string &label, bool checked=false)
create a check box component, optionally checked intially
Definition: GUIComponents.h:80
Spinner(int min, int max, int curr)
creat spinbox component with given range and initial value
Definition: GUIComponents.h:247
Simple generic data type implementation that uses a string based data representation.
Definition: Any.h:109
ColorSelect(int r, int g, int b, int a=-1)
create color selection component
Definition: GUIComponents.h:310
Plot(const utils::Range32f xRange=utils::Range32f(0, 0), const utils::Range32f yRange=utils::Range32f(0, 0), bool useOpenGL=false, const std::string &xLabel="", const std::string &yLabel="")
Create Plot component with optionally given range parameters.
Definition: GUIComponents.h:204
Draw(const utils::Size &defaultViewPortsize=utils::Size::VGA)
create draw component with given default view port size
Definition: GUIComponents.h:160
ICLUtils_API std::vector< std::string > tok(const std::string &s, const std::string &delims=" ", bool singleCharDelims=true, char escapeChar='\0')
tokenizes a string with given delimiters (internally using a temporary StrTok instance)
#define ICLASSERT_THROW(X, OBJ)
Definition: Macros.h:155
Label component for displaying text.
Definition: GUIComponents.h:86
Button(const std::string &text, const std::string &toggledText="", bool initiallyToggled=false)
creates button component (if toggledText is empty, a push-button is created)
Definition: GUIComponents.h:65
Image visualization component that allows for overlayed 2D image annotation.
Definition: GUIComponents.h:156
a 2D function and data plotting component
Definition: GUIComponents.h:178