cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsQtWidgetFunction.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Praneeth Sadda, Anton Deguet
7  Created on: 2011-11-11
8 
9  (C) Copyright 2011 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 #ifndef _mtsQtWidgetFunction_h
23 #define _mtsQtWidgetFunction_h
24 
25 #include <map>
26 
29 
36 
38 
39 #include <QWidget>
40 #include <QFrame>
41 #include <QTime>
42 
43 class QLabel;
44 class QPushButton;
45 class QVBoxLayout;
46 class QHBoxLayout;
47 class QFormLayout;
48 class QDoubleSpinBox;
49 class QToolButton;
50 
51 // Always include last
53 
54 /* ! A widget that wraps a single mtsCommand, allowing the user to execute the command and view its output. */
55 class CISST_EXPORT mtsQtWidgetFunction: public QWidget, public cmnGenericObject
56 {
57  Q_OBJECT;
59 
60  private:
61  QLabel * Label;
62  QVBoxLayout * MainLayout;
63  QHBoxLayout * ControlLayout;
64  QFormLayout * ResultLayout;
65 
66  // periodic execution
67  QDoubleSpinBox * PeriodSpinBox;
68 
69  // execution result
70  QLabel * ExecutionResultLabel;
71  mtsExecutionResult LastResult;
72  void timerEvent(QTimerEvent * event);
73 
74  protected:
75 
76  QPushButton * ExecuteButton;
77 
78  void SetExecutionResult(mtsExecutionResult result);
79  void DisableExecute(void);
80 
85 
86  int TimerID;
87  bool HasTimer;
88  bool Enabled;
89 
90  /* ! Add an editor widget to the mtsQtWidgetFunction. The editor widget can be used
91  to provide the value for an argument for the mtsCommand.
92  @param label The text to put in the QLabel associated with the widget.
93  @param prototype An instance of the datatype that the widget should handle.
94  */
95  void SetWriteWidget(const std::string & label, const mtsGenericObject & prototype);
96 
97  /* ! Add a display widget to the mtsQtWidgetFunction. The display widget can be used
98  to show the result of executing an mtsCommand.
99  @param label The text to put in the QLabel associated with the widget.
100  @param prototype An instance of the datatype that the widget should handle.
101  */
102  void SetReadWidget(const std::string & label, const mtsGenericObject & prototype);
103 
104  /* ! Add an EventInformationWidget to the mtsQtWidgetFunction. */
105  void AddEventWidgets(void);
106 
107  virtual void Execute(void) = 0;
108 
109  public slots:
110  void ExecuteIfEnabled(void);
111  void StopPeriodicExecution(void);
112  void HandleIntervalChanged(double newInterval);
113 
114  public:
115  mtsQtWidgetFunction(void);
116  virtual void CreateArgumentsWidgets(void) = 0;
117  void SetTimer(int interval);
118  void StopTimer(void);
119 };
120 
122 
123 
124 
126 {
127  Q_OBJECT;
128  private:
129  mtsFunctionVoid * Function;
130  public slots:
131  virtual void Execute(void);
132  public:
133  explicit mtsQtWidgetFunctionVoid(mtsFunctionVoid * function);
134  void CreateArgumentsWidgets(void);
135 };
136 
137 
139 {
140  Q_OBJECT;
141  private:
142  mtsFunctionVoidReturn * Function;
143  public slots:
144  virtual void Execute(void);
145  public:
147  void CreateArgumentsWidgets(void);
148 };
149 
150 
152 {
153  Q_OBJECT;
154  private:
155  mtsFunctionWrite * Function;
156  public slots:
157  virtual void Execute(void);
158  public:
159  explicit mtsQtWidgetFunctionWrite(mtsFunctionWrite * function);
160  void CreateArgumentsWidgets(void);
161 };
162 
163 
165 {
166  Q_OBJECT;
167  private:
168  mtsFunctionWriteReturn * Function;
169  public slots:
170  virtual void Execute(void);
171  public:
173  void CreateArgumentsWidgets(void);
174 };
175 
176 
178 {
179  Q_OBJECT;
180  private:
181  mtsFunctionRead * Function;
182  public slots:
183  virtual void Execute(void);
184  public:
185  explicit mtsQtWidgetFunctionRead(mtsFunctionRead * function);
186  void CreateArgumentsWidgets(void);
187 };
188 
189 
191 {
192  Q_OBJECT;
193  private:
194  mtsFunctionQualifiedRead * Function;
195  public slots:
196  virtual void Execute(void);
197  public:
199  void CreateArgumentsWidgets(void);
200 };
201 
202 
204 {
205  Q_OBJECT;
206 private:
207  QWidget * TitleBar;
208  QLabel * TitleLabel;
209  QToolButton * ToggleButton;
210  QWidget * FunctionWidgetContainer;
211 
212 private slots:
213  void ToggleCollapsed();
214 
215 public:
217  void SetFunctionWidget(QWidget * widget, const QString & name = "");
218 };
219 
220 
222 {
223  Q_OBJECT;
224 public:
226  void addItem(QWidget * widget, const QString & name);
227 };
228 
229 
230 #endif // _mtsQtWidgetFunction_h
Defines the command interfaces.
Defines a function object to use a void command (mtsCommandVoid)
Definition: mtsQtWidgetFunction.h:190
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Defines the command interfaces.
Definition: mtsFunctionRead.h:37
Definition: mtsQtWidgetFunction.h:151
Definition: mtsQtWidgetFunction.h:138
Definition: mtsFunctionQualifiedRead.h:37
Definition: mtsQtWidgetFunction.h:125
mtsQtWidgetGenericObjectRead * ReadWidget
Definition: mtsQtWidgetFunction.h:81
Definition: mtsFunctionVoidReturn.h:38
Definition: mtsFunctionVoid.h:36
Base class for high level objects.
Definition: cmnGenericObject.h:51
Base class for data object in cisstMultiTask.
Definition: mtsGenericObject.h:56
mtsQtWidgetGenericObjectWrite * WriteWidget
Definition: mtsQtWidgetFunction.h:82
Defines the command interfaces.
virtual void Execute(void)=0
mtsGenericObject * ReadValue
Definition: mtsQtWidgetFunction.h:83
Definition: mtsQtWidgetFunction.h:177
virtual void CreateArgumentsWidgets(void)=0
Defines a function object to use a void command (mtsCommandWriteReturn)
Definition: mtsQtWidgetFunction.h:55
Defines mtsGenericObject.
Defines a function object to use a void command (mtsCommandVoidReturn)
Definition: mtsQtWidgetFunction.h:221
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
Definition: mtsQtWidgetGenericObject.h:35
mtsGenericObject * WriteValue
Definition: mtsQtWidgetFunction.h:84
Definition: mtsExecutionResult.h:34
Definition: mtsQtWidgetFunction.h:203
bool HasTimer
Definition: mtsQtWidgetFunction.h:87
QPushButton * ExecuteButton
Definition: mtsQtWidgetFunction.h:76
int TimerID
Definition: mtsQtWidgetFunction.h:86
Definition: mtsQtWidgetGenericObject.h:48
Definition: mtsFunctionWrite.h:37
const int CMN_NO_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:328
Rules of exporting.
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition: cmnClassRegisterMacros.h:202
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
bool Enabled
Definition: mtsQtWidgetFunction.h:88
Definition: mtsFunctionWriteReturn.h:38
Definition: mtsQtWidgetFunction.h:164