-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathplugin-template.cpp
More file actions
136 lines (115 loc) · 3.43 KB
/
plugin-template.cpp
File metadata and controls
136 lines (115 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* Copyright (C) 2011 Georgia Institute of Technology, University of Utah,
* Weill Cornell Medical College
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This is a template implementation file for a user module derived from
* DefaultGUIModel with a custom GUI.
*/
#include "plugin-template.h"
#include <iostream>
#include <main_window.h>
extern "C" Plugin::Object*
createRTXIPlugin(void)
{
return new PluginTemplate();
}
static DefaultGUIModel::variable_t vars[] = {
{
"GUI label", "Tooltip description",
DefaultGUIModel::PARAMETER | DefaultGUIModel::DOUBLE,
},
{
"A State", "Tooltip description", DefaultGUIModel::STATE,
},
};
static size_t num_vars = sizeof(vars) / sizeof(DefaultGUIModel::variable_t);
PluginTemplate::PluginTemplate(void)
: DefaultGUIModel("PluginTemplate with Custom GUI", ::vars, ::num_vars)
{
setWhatsThis("<p><b>PluginTemplate:</b><br>QWhatsThis description.</p>");
DefaultGUIModel::createGUI(vars,
num_vars); // this is required to create the GUI
customizeGUI();
initParameters();
update(INIT); // this is optional, you may place initialization code directly
// into the constructor
refresh(); // this is required to update the GUI with parameter and state
// values
QTimer::singleShot(0, this, SLOT(resizeMe()));
}
PluginTemplate::~PluginTemplate(void)
{
}
void
PluginTemplate::execute(void)
{
return;
}
void
PluginTemplate::initParameters(void)
{
some_parameter = 0;
some_state = 0;
}
void
PluginTemplate::update(DefaultGUIModel::update_flags_t flag)
{
switch (flag) {
case INIT:
period = RT::System::getInstance()->getPeriod() * 1e-6; // ms
setParameter("GUI label", some_parameter);
setState("A State", some_state);
break;
case MODIFY:
some_parameter = getParameter("GUI label").toDouble();
break;
case UNPAUSE:
break;
case PAUSE:
break;
case PERIOD:
period = RT::System::getInstance()->getPeriod() * 1e-6; // ms
break;
default:
break;
}
}
void
PluginTemplate::customizeGUI(void)
{
QGridLayout* customlayout = DefaultGUIModel::getLayout();
QGroupBox* button_group = new QGroupBox;
QPushButton* abutton = new QPushButton("Button A");
QPushButton* bbutton = new QPushButton("Button B");
QHBoxLayout* button_layout = new QHBoxLayout;
button_group->setLayout(button_layout);
button_layout->addWidget(abutton);
button_layout->addWidget(bbutton);
QObject::connect(abutton, SIGNAL(clicked()), this, SLOT(aBttn_event()));
QObject::connect(bbutton, SIGNAL(clicked()), this, SLOT(bBttn_event()));
customlayout->addWidget(button_group, 0, 0);
setLayout(customlayout);
}
// functions designated as Qt slots are implemented as regular C++ functions
void
PluginTemplate::aBttn_event(void)
{
}
void
PluginTemplate::bBttn_event(void)
{
}