Image Component Library (ICL)
DynamicGUI.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/DynamicGUI.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 #pragma once
31 
32 #include <ICLUtils/Uncopyable.h>
33 #include <ICLQt/GUI.h>
34 
36 namespace pugi { class xml_node; }
39 namespace icl{
40  namespace qt{
41 
43 
89  class DynamicGUI : public qt::GUI, public utils::Uncopyable{
91  struct Data;
92 
94  Data *m_data;
95 
96  public:
97 
99 
109  class Node{
111  typedef std::pair<std::string,std::string> KeyValue;
112 
113  Node(const std::string &name="", NodePtr parent=NodePtr(), int level=0); // private constructur
114 
116  NodePtr appendChild(const std::string &name, NodePtr parent, int level);
117 
119  void grabArgs(const pugi::xml_node &n);
120 
122  friend class DynamicGUI;
123 
124 
125  public:
126  std::string name;
128  int level;
130 
131  std::string directArgs;
132  std::vector<KeyValue> args;
133  std::vector<NodePtr> children;
134 
135  bool isContainer() const;
136  bool hasHandle() const;
137  std::string getHandleName() const;
138 
139  };
140 
142  typedef Node ParseTree;
144 
146 
148  DynamicGUI(const std::string &cfgFileName="", QWidget *parent=0);
149 
151  ~DynamicGUI();
152 
154 
155  void initialize(const std::string &cfgXMLString);
156 
158  void load(const std::string &cfgFileName);
159 
161  void release();
162 
165 
166 
167  private:
169  void initInternal(pugi::xml_node &root);
170 
172  friend std::ostream &operator<<(std::ostream &s, const DynamicGUI::Node &n);
173 
175  static void traverse_tree(const pugi::xml_node &n, int level,
177 
179  static void create_gui(Node &n);
180  };
181 
182  }
183 
184 }
utils::SmartPtr< Node > NodePtr
SmartPtr typedef.
Definition: DynamicGUI.h:110
qt::GUI parsedGUI
corresponding parse (but not created) GUI instance
Definition: DynamicGUI.h:129
utils::SmartPtr< ParseTree > ParseTreePtr
pointer typedef
Definition: DynamicGUI.h:143
friend std::ostream & operator<<(std::ostream &s, const DynamicGUI::Node &n)
ostream operator for the node class
undocument this line if you encounter any issues!
Definition: Any.h:37
Class interface for un-copyable classes.
Definition: Uncopyable.h:64
void release()
internally releases everything
Main Class of ICL's GUI creation framework.
Definition: GUI.h:60
DynamicGUI(const std::string &cfgFileName="", QWidget *parent=0)
creates a new DynamicGUI instance from a given XML-description filename
bool hasHandle() const
returns whether a handle was given (e.g. is part of args)
static void create_gui(Node &n)
internal GUI-creation method
std::string directArgs
direct, e.g. component specific arguments
Definition: DynamicGUI.h:131
ParseTreePtr getParseTree()
returns the internal parse-tree representation
Special GUI implementation that allows for defining the GUI layout in an XML-file.
Definition: DynamicGUI.h:89
NodePtr parent
parent container component (or null for the top-level component)
Definition: DynamicGUI.h:127
internal xml-parsing node class
Definition: DynamicGUI.h:109
void initialize(const std::string &cfgXMLString)
intialize DynamicGUI instance from given XML-string
utils::SmartPtr< Node > NodePtr
typedef for node-pointers
Definition: DynamicGUI.h:141
void initInternal(pugi::xml_node &root)
internally used initialization method
std::string getHandleName() const
returns the handle (if there is one)
Node(const std::string &name="", NodePtr parent=NodePtr(), int level=0)
Node ParseTree
A tree is simply the root-node.
Definition: DynamicGUI.h:142
std::vector< KeyValue > args
general arguments, such as handle, label or minsize
Definition: DynamicGUI.h:132
std::pair< std::string, std::string > KeyValue
KeyValue pair class.
Definition: DynamicGUI.h:111
int level
hierarchy containment level of this component
Definition: DynamicGUI.h:128
void grabArgs(const pugi::xml_node &n)
internal utility methods
void load(const std::string &cfgFileName)
intialize DynamicGUI instance from given XML-file
std::string name
component type (e.g. 'slider', or 'combo' or 'image')
Definition: DynamicGUI.h:126
bool isContainer() const
dedicated method to distinguish containers
static void traverse_tree(const pugi::xml_node &n, int level, utils::SmartPtr< DynamicGUI::Node > target)
internal tree-traversal method
std::vector< NodePtr > children
all child-components (for containers only)
Definition: DynamicGUI.h:133
NodePtr appendChild(const std::string &name, NodePtr parent, int level)
internally used appending of children
~DynamicGUI()
Destructor.
Data * m_data
internal data pointer
Definition: DynamicGUI.h:91