cisst-saw
Loading...
Searching...
No Matches
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 Author(s): Praneeth Sadda, Anton Deguet
6 Created on: 2011-11-11
7
8 (C) Copyright 2011-2023 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19#ifndef _mtsQtWidgetFunction_h
20#define _mtsQtWidgetFunction_h
21
22#include <map>
23
26
33
35
36#include <QWidget>
37#include <QFrame>
38#include <QTime>
39
40class QLabel;
41class QPushButton;
42class QVBoxLayout;
43class QHBoxLayout;
44class QFormLayout;
45class QDoubleSpinBox;
46class QToolButton;
47
48// Always include last
50
51/* ! A widget that wraps a single mtsCommand, allowing the user to execute the command and view its output. */
53{
54 Q_OBJECT;
56
57 private:
58 QLabel * Label;
59 QVBoxLayout * MainLayout;
60 QHBoxLayout * ControlLayout;
61 QFormLayout * ResultLayout;
62
63 // periodic execution
64 QDoubleSpinBox * PeriodSpinBox;
65
66 // execution result
67 QLabel * ExecutionResultLabel;
68 mtsExecutionResult LastResult;
69 void timerEvent(QTimerEvent * event) override;
70
71 protected:
72
73 QPushButton * ExecuteButton;
74
76 void DisableExecute(void);
77
82
85 bool Enabled;
86
87 /* ! Add an editor widget to the mtsQtWidgetFunction. The editor widget can be used
88 to provide the value for an argument for the mtsCommand.
89 @param label The text to put in the QLabel associated with the widget.
90 @param prototype An instance of the datatype that the widget should handle.
91 */
92 void SetWriteWidget(const std::string & label, const mtsGenericObject & prototype);
93
94 /* ! Add a display widget to the mtsQtWidgetFunction. The display widget can be used
95 to show the result of executing an mtsCommand.
96 @param label The text to put in the QLabel associated with the widget.
97 @param prototype An instance of the datatype that the widget should handle.
98 */
99 void SetReadWidget(const std::string & label, const mtsGenericObject & prototype);
100
101 /* ! Add an EventInformationWidget to the mtsQtWidgetFunction. */
102 void AddEventWidgets(void);
103
104 virtual void Execute(void) = 0;
105
106 public slots:
109 void HandleIntervalChanged(double newInterval);
110
111 public:
113 virtual void CreateArgumentsWidgets(void) = 0;
114 void SetTimer(int interval);
115 void StopTimer(void);
116};
117
119
120
121
123{
124 Q_OBJECT;
125 private:
126 mtsFunctionVoid * Function;
127 public slots:
128 virtual void Execute(void);
129 public:
132};
133
134
136{
137 Q_OBJECT;
138 private:
139 mtsFunctionVoidReturn * Function;
140 public slots:
141 virtual void Execute(void);
142 public:
145};
146
147
149{
150 Q_OBJECT;
151 private:
152 mtsFunctionWrite * Function;
153 public slots:
154 virtual void Execute(void);
155 public:
158};
159
160
162{
163 Q_OBJECT;
164 private:
165 mtsFunctionWriteReturn * Function;
166 public slots:
167 virtual void Execute(void);
168 public:
171};
172
173
175{
176 Q_OBJECT;
177 private:
178 mtsFunctionRead * Function;
179 public slots:
180 virtual void Execute(void);
181 public:
184};
185
186
188{
189 Q_OBJECT;
190 private:
191 mtsFunctionQualifiedRead * Function;
192 public slots:
193 virtual void Execute(void);
194 public:
197};
198
199
201{
202 Q_OBJECT;
203private:
204 QWidget * TitleBar;
205 QLabel * TitleLabel;
206 QToolButton * ToggleButton;
207 QWidget * FunctionWidgetContainer;
208
209private slots:
210 void ToggleCollapsed();
211
212public:
214 void SetFunctionWidget(QWidget * widget, const QString & name = "");
215};
216
217
219{
220 Q_OBJECT;
221public:
223 void addItem(QWidget * widget, const QString & name);
224};
225
226
227#endif // _mtsQtWidgetFunction_h
Base class for high level objects.
Definition cmnGenericObject.h:53
Definition mtsExecutionResult.h:34
Definition mtsFunctionQualifiedRead.h:37
Definition mtsFunctionRead.h:37
Definition mtsFunctionVoid.h:36
Definition mtsFunctionVoidReturn.h:38
Definition mtsFunctionWrite.h:37
Definition mtsFunctionWriteReturn.h:38
Base class for data object in cisstMultiTask.
Definition mtsGenericObject.h:52
void SetFunctionWidget(QWidget *widget, const QString &name="")
void addItem(QWidget *widget, const QString &name)
Definition mtsQtWidgetFunction.h:53
void ExecuteIfEnabled(void)
void SetTimer(int interval)
bool HasTimer
Definition mtsQtWidgetFunction.h:84
mtsGenericObject * WriteValue
Definition mtsQtWidgetFunction.h:81
virtual void Execute(void)=0
void AddEventWidgets(void)
void SetReadWidget(const std::string &label, const mtsGenericObject &prototype)
mtsQtWidgetGenericObjectRead * ReadWidget
Definition mtsQtWidgetFunction.h:78
void HandleIntervalChanged(double newInterval)
mtsQtWidgetGenericObjectWrite * WriteWidget
Definition mtsQtWidgetFunction.h:79
void SetExecutionResult(mtsExecutionResult result)
mtsGenericObject * ReadValue
Definition mtsQtWidgetFunction.h:80
int TimerID
Definition mtsQtWidgetFunction.h:83
virtual void CreateArgumentsWidgets(void)=0
void StopTimer(void)
void StopPeriodicExecution(void)
QPushButton * ExecuteButton
Definition mtsQtWidgetFunction.h:73
bool Enabled
Definition mtsQtWidgetFunction.h:85
void SetWriteWidget(const std::string &label, const mtsGenericObject &prototype)
void DisableExecute(void)
mtsQtWidgetFunctionQualifiedRead(mtsFunctionQualifiedRead *function)
mtsQtWidgetFunctionRead(mtsFunctionRead *function)
virtual void Execute(void)
void CreateArgumentsWidgets(void)
mtsQtWidgetFunctionVoid(mtsFunctionVoid *function)
virtual void Execute(void)
void CreateArgumentsWidgets(void)
virtual void Execute(void)
mtsQtWidgetFunctionVoidReturn(mtsFunctionVoidReturn *function)
virtual void Execute(void)
mtsQtWidgetFunctionWrite(mtsFunctionWrite *function)
void CreateArgumentsWidgets(void)
virtual void Execute(void)
mtsQtWidgetFunctionWriteReturn(mtsFunctionWriteReturn *function)
Definition mtsQtWidgetGenericObject.h:36
Definition mtsQtWidgetGenericObject.h:49
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199
const int CMN_NO_DYNAMIC_CREATION
Definition cmnClassRegisterMacros.h:325
#define CISST_EXPORT
Definition cmnExportMacros.h:50
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76
Rules of exporting.
Defines the command interfaces.
Defines the command interfaces.
Defines a function object to use a void command (mtsCommandVoid).
Defines a function object to use a void command (mtsCommandVoidReturn).
Defines the command interfaces.
Defines a function object to use a void command (mtsCommandWriteReturn).
Defines mtsGenericObject.