26 #include <IceUtil/Time.h>
33 #include <RobotAPI/gui-plugins/HapticUnitPlugin/ui_HapticUnitConfigDialog.h>
40 #include <QInputDialog>
42 #include <QPushButton>
50 addWidget<HapticUnitWidget>();
58 hapticObserverProxyName =
"HapticUnitObserver";
59 hapticUnitProxyName =
"WeissHapticUnit";
61 updateTimer =
new QTimer(
this);
74 hapticObserverProxy = getProxy<ObserverInterfacePrx>(hapticObserverProxyName);
75 weissHapticUnit = getProxy<WeissHapticUnitInterfacePrx>(hapticUnitProxyName);
78 createMatrixWidgets();
79 updateTimer->start(25);
102 return qobject_cast<HapticUnitConfigDialog*>(dialog);
114 for (std::pair<std::string, MatrixDatafieldDisplayWidget*> pair : matrixDisplays)
117 std::string name = hapticObserverProxy
119 hapticObserverProxyName, pair.first,
"name"))
121 std::string deviceName = hapticObserverProxy
123 hapticObserverProxyName, pair.first,
"device"))
128 hapticObserverProxyName, pair.first,
"timestamp")))
131 matrixDisplay->
setInfoOverlay(QString::fromStdString(deviceName) +
": " +
132 QString::fromStdString(name) +
"\n" +
133 QString::fromStdString(timestamp->toTime().toDateTime()));
134 matrixDisplay->invokeUpdate();
141 QMenu* contextMenu =
new QMenu(
getWidget());
143 qobject_cast<MatrixDatafieldDisplayWidget*>(sender());
150 QAction* setDeviceTag = contextMenu->addAction(tr(
"Set Device Tag"));
152 QAction* action = contextMenu->exec(matrixDisplay->mapToGlobal(point));
154 std::string channelName = channelNameReverseMap.at(matrixDisplay);
155 std::string deviceName = deviceNameReverseMap.at(matrixDisplay);
157 if (action == setDeviceTag)
159 std::string
tag = hapticObserverProxy
161 hapticObserverProxyName, channelName,
"name"))
165 QString newTag = QInputDialog::getText(
167 tr(
"Set Device Tag"),
168 QString::fromStdString(
"New Tag for Device '" + deviceName +
"'"),
170 QString::fromStdString(
tag),
173 if (
ok && !newTag.isEmpty())
176 << newTag.toStdString();
177 weissHapticUnit->setDeviceTag(deviceName, newTag.toStdString());
199 SLOT(updateDisplayWidgets()),
200 Qt::QueuedConnection);
201 connect(updateTimer, SIGNAL(timeout()),
this, SLOT(
updateData()));
202 connect(
ui.checkBoxOffsetFilter,
203 SIGNAL(stateChanged(
int)),
205 SLOT(onCheckBoxOffsetFilterStateChanged(
int)));
209 HapticUnitWidget::createMatrixWidgets()
216 HapticUnitWidget::updateDisplayWidgets()
220 while ((child =
ui.gridLayoutDisplay->takeAt(0)) != 0)
226 ChannelRegistry channels = hapticObserverProxy->getAvailableChannels(
false);
228 for (std::pair<std::string, ChannelRegistryEntry> pair : channels)
230 std::string channelName = pair.first;
231 MatrixDatafieldDisplayWidget* matrixDisplay =
new MatrixDatafieldDisplayWidget(
232 new DatafieldRef(hapticObserverProxy, channelName,
"matrix"),
235 matrixDisplay->setRange(0, 4095);
236 matrixDisplay->setContextMenuPolicy(Qt::CustomContextMenu);
237 connect(matrixDisplay,
238 SIGNAL(customContextMenuRequested(QPoint)),
241 matrixDisplays.insert(std::make_pair(pair.first, matrixDisplay));
242 std::string deviceName = hapticObserverProxy
243 ->getDataField(
new DataFieldIdentifier(
244 hapticObserverProxyName, channelName,
"device"))
246 channelNameReverseMap.insert(std::make_pair(matrixDisplay, channelName));
247 deviceNameReverseMap.insert(std::make_pair(matrixDisplay, deviceName));
248 ui.gridLayoutDisplay->addWidget(matrixDisplay, 0, i);
254 HapticUnitWidget::onCheckBoxOffsetFilterStateChanged(
int state)
257 for (std::pair<std::string, MatrixDatafieldDisplayWidget*> pair : matrixDisplays)
259 pair.second->enableOffsetFilter(
ui.checkBoxOffsetFilter->isChecked());