itom  3.0.0
paramEditorWidget.h
1 /* ********************************************************************
2 itom measurement system
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2017, Institut fuer Technische Optik (ITO),
5 Universitaet Stuttgart, Germany
6 
7 This file is part of itom.
8 
9 itom is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 itom is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef PARAMEDITORWIDGET_H
24 #define PARAMEDITORWIDGET_H
25 
26 
27 #include "commonWidgets.h"
28 
29 #include "common/sharedStructuresQt.h"
30 #include "common/param.h"
31 
32 #include <qwidget.h>
33 #include <qscopedpointer.h>
34 #include <qpointer.h>
35 #include <qvector.h>
36 
37 class ParamEditorModel;
39 class QtProperty;
40 class QtBrowserItem;
41 class QTimerEvent;
42 
43 namespace ito {
44  class AddInBase; //forward declaration
45 };
46 
47 class ITOMWIDGETS_EXPORT ParamEditorWidget : public QWidget
48 {
49  Q_OBJECT
50 
51 #if QT_VERSION < 0x050500
52  //for >= Qt 5.5.0 see Q_ENUM definition below
53  Q_ENUMS(ResizeMode)
54 #endif
55  Q_PROPERTY(QPointer<ito::AddInBase> plugin READ plugin WRITE setPlugin)
56  Q_PROPERTY(int indentation READ indentation WRITE setIndentation)
57  Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated)
58  Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
59  Q_PROPERTY(bool headerVisible READ isHeaderVisible WRITE setHeaderVisible)
60  Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
61  Q_PROPERTY(int splitterPosition READ splitterPosition WRITE setSplitterPosition)
62  Q_PROPERTY(bool propertiesWithoutValueMarked READ propertiesWithoutValueMarked WRITE setPropertiesWithoutValueMarked)
63  Q_PROPERTY(bool readonly READ readonly WRITE setReadonly)
64  Q_PROPERTY(bool showDescriptions READ showDescriptions WRITE setShowDescriptions)
65  Q_PROPERTY(QStringList filteredCategories READ filteredCategories WRITE setFilteredCategories)
66 
67  Q_CLASSINFO("prop://plugin", "Actuator or dataIO instance whose parameters are observed and set by this widget.")
68  Q_CLASSINFO("prop://indentation", "Indentation level of child items in the tree.")
69  Q_CLASSINFO("prop://rootIsDecorated", "Slightly changes the visualization of root and child elements.")
70  Q_CLASSINFO("prop://alternatingRowColors", "En- or disables alternating row colors.")
71  Q_CLASSINFO("prop://headerVisible", "Indicates if the header line (property, value) is visible.")
72  Q_CLASSINFO("prop://resizeMode", "Sets the mode how the columns can be resized.")
73  Q_CLASSINFO("prop://splitterPosition", "Width of the first column (not possible if resizeMode is set to Stretch).")
74  Q_CLASSINFO("prop://propertiesWithoutValueMarked", "If True, category values are marked with a dark gray background.")
75  Q_CLASSINFO("prop://readonly", "Indicates if widget is readonly or if values can be changed.")
76  Q_CLASSINFO("prop://showDescriptions", "If True, a text box is visible below the properties to show an information text about the currently set entry.")
77  Q_CLASSINFO("prop://filteredCategories", "If empty, all categories are shown. Else pass a list of category names to only show these categories.")
78 
79 public:
80  enum ResizeMode
81  {
82  Interactive,
83  Stretch,
84  Fixed,
85  ResizeToContents
86  };
87 
88 #if QT_VERSION >= 0x050500
89  //Q_ENUM exposes a meta object to the enumeration types, such that the key names for the enumeration
90  //values are always accessible.
91  Q_ENUM(ResizeMode)
92 #endif
93 
100  ParamEditorWidget(QWidget* parent = 0);
101 
103  virtual ~ParamEditorWidget();
104 
105  QPointer<ito::AddInBase> plugin() const;
106  void setPlugin(QPointer<ito::AddInBase> plugin);
107 
108  void refresh();
109 
110  int indentation() const;
111  void setIndentation(int i);
112 
113  bool rootIsDecorated() const;
114  void setRootIsDecorated(bool show);
115 
116  bool alternatingRowColors() const;
117  void setAlternatingRowColors(bool enable);
118 
119  bool readonly() const;
120  void setReadonly(bool enable);
121 
122  bool isHeaderVisible() const;
123  void setHeaderVisible(bool visible);
124 
125  ResizeMode resizeMode() const;
126  void setResizeMode(ResizeMode mode);
127 
128  int splitterPosition() const;
129  void setSplitterPosition(int position);
130 
131  void setPropertiesWithoutValueMarked(bool mark);
132  bool propertiesWithoutValueMarked() const;
133 
134  void setShowDescriptions(bool show);
135  bool showDescriptions() const;
136 
137  void setFilteredCategories(const QStringList &filteredCategories);
138  QStringList filteredCategories() const;
139 
140 protected:
146  {
147  msgLevelNo = 0,
148  msgLevelErrorOnly = 1,
149  msgLevelWarningOnly = 2,
150  msgLevelWarningAndError = msgLevelErrorOnly | msgLevelWarningOnly
151  };
152 
153  ito::RetVal setPluginParameter(QSharedPointer<ito::ParamBase> param, MessageLevel msgLevel = msgLevelWarningAndError) const;
154  ito::RetVal setPluginParameters(const QVector<QSharedPointer<ito::ParamBase> > params, MessageLevel msgLevel = msgLevelWarningAndError) const;
155  ito::RetVal observeInvocation(ItomSharedSemaphore *waitCond, MessageLevel msgLevel) const;
156 
157  ito::RetVal addParam(const ito::Param &param);
158  ito::RetVal addParamInt(const ito::Param &param, QtProperty *groupProperty);
159  ito::RetVal addParamChar(const ito::Param &param, QtProperty *groupProperty);
160  ito::RetVal addParamDouble(const ito::Param &param, QtProperty *groupProperty);
161  ito::RetVal addParamString(const ito::Param &param, QtProperty *groupProperty);
162  ito::RetVal addParamOthers(const ito::Param &param, QtProperty *groupProperty);
163  ito::RetVal addParamInterval(const ito::Param &param, QtProperty *groupProperty);
164  ito::RetVal addParamRect(const ito::Param &param, QtProperty *groupProperty);
165  ito::RetVal addParamIntArray(const ito::Param &param, QtProperty *groupProperty);
166  ito::RetVal addParamCharArray(const ito::Param &param, QtProperty *groupProperty);
167  ito::RetVal addParamDoubleArray(const ito::Param &param, QtProperty *groupProperty);
168 
169  ito::RetVal loadPlugin(QPointer<ito::AddInBase> plugin);
170 
171 protected:
172  void timerEvent(QTimerEvent *event);
173 
174 private:
175  QScopedPointer<ParamEditorWidgetPrivate> d_ptr;
176 
177  Q_DECLARE_PRIVATE(ParamEditorWidget);
178  Q_DISABLE_COPY(ParamEditorWidget);
179 
180 private slots:
181  void valueChanged(QtProperty* prop, int value);
182  void valueChanged(QtProperty* prop, char value);
183  void valueChanged(QtProperty* prop, double value);
184  void valueChanged(QtProperty* prop, int num, const char* values);
185  void valueChanged(QtProperty* prop, int num, const int* values);
186  void valueChanged(QtProperty* prop, int num, const double* values);
187  void valueChanged(QtProperty* prop, const QByteArray &value);
188  void valueChanged(QtProperty* prop, int min, int max);
189  void valueChanged(QtProperty* prop, int left, int top, int width, int height);
190 
191  void currentItemChanged(QtBrowserItem *);
192 
193  void parametersChanged(QMap<QString, ito::Param> parameters);
194 
195 
196 };
197 
198 #endif
Definition: paramEditorWidget.cpp:43
MessageLevel
Definition: paramEditorWidget.h:145
Class for managing status values (like errors or warning)
Definition: retVal.h:54
class for parameter handling e.g. to pass paramters to plugins
Definition: param.h:251
Definition: paramEditorWidget.h:47
Definition: apiFunctionsGraph.cpp:39
semaphore which can be used for asychronous thread communication. By using this class it is possible ...
Definition: sharedStructuresQt.h:57
The QtBrowserItem class represents a property in a property browser instance.
Definition: qtpropertybrowser.h:238
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:60