26#include <RobotAPI/gui-plugins/HapticUnitPlugin/ui_HapticUnitGuiPlugin.h>
28#include <IceUtil/Time.h>
35#include <RobotAPI/gui-plugins/HapticUnitPlugin/ui_HapticUnitConfigDialog.h>
42#include <QInputDialog>
60 ui = std::make_unique<Ui::HapticUnitGuiPlugin>();
63 hapticObserverProxyName =
"HapticUnitObserver";
64 hapticUnitProxyName =
"WeissHapticUnit";
66 updateTimer =
new QTimer(
this);
83 createMatrixWidgets();
84 updateTimer->start(25);
107 return qobject_cast<HapticUnitConfigDialog*>(dialog);
119 for (std::pair<std::string, MatrixDatafieldDisplayWidget*> pair : matrixDisplays)
122 std::string name = hapticObserverProxy
124 hapticObserverProxyName, pair.first,
"name"))
126 std::string deviceName = hapticObserverProxy
128 hapticObserverProxyName, pair.first,
"device"))
133 hapticObserverProxyName, pair.first,
"timestamp")))
136 matrixDisplay->
setInfoOverlay(QString::fromStdString(deviceName) +
": " +
137 QString::fromStdString(name) +
"\n" +
138 QString::fromStdString(
timestamp->toTime().toDateTime()));
139 matrixDisplay->invokeUpdate();
146 QMenu* contextMenu =
new QMenu(
getWidget());
148 qobject_cast<MatrixDatafieldDisplayWidget*>(sender());
155 QAction* setDeviceTag = contextMenu->addAction(tr(
"Set Device Tag"));
157 QAction* action = contextMenu->exec(matrixDisplay->mapToGlobal(point));
159 std::string channelName = channelNameReverseMap.at(matrixDisplay);
160 std::string deviceName = deviceNameReverseMap.at(matrixDisplay);
162 if (action == setDeviceTag)
164 std::string
tag = hapticObserverProxy
166 hapticObserverProxyName, channelName,
"name"))
170 QString newTag = QInputDialog::getText(
172 tr(
"Set Device Tag"),
173 QString::fromStdString(
"New Tag for Device '" + deviceName +
"'"),
175 QString::fromStdString(
tag),
178 if (ok && !newTag.isEmpty())
181 << newTag.toStdString();
182 weissHapticUnit->setDeviceTag(deviceName, newTag.toStdString());
204 SLOT(updateDisplayWidgets()),
205 Qt::QueuedConnection);
206 connect(updateTimer, SIGNAL(timeout()),
this, SLOT(
updateData()));
207 connect(
ui->checkBoxOffsetFilter,
208 SIGNAL(stateChanged(
int)),
210 SLOT(onCheckBoxOffsetFilterStateChanged(
int)));
214 HapticUnitWidget::createMatrixWidgets()
221 HapticUnitWidget::updateDisplayWidgets()
225 while ((child =
ui->gridLayoutDisplay->takeAt(0)) != 0)
231 ChannelRegistry channels = hapticObserverProxy->getAvailableChannels(
false);
233 for (std::pair<std::string, ChannelRegistryEntry> pair : channels)
235 std::string channelName = pair.first;
236 MatrixDatafieldDisplayWidget* matrixDisplay =
new MatrixDatafieldDisplayWidget(
237 new DatafieldRef(hapticObserverProxy, channelName,
"matrix"),
240 matrixDisplay->setRange(0, 4095);
241 matrixDisplay->setContextMenuPolicy(Qt::CustomContextMenu);
242 connect(matrixDisplay,
243 SIGNAL(customContextMenuRequested(QPoint)),
246 matrixDisplays.insert(std::make_pair(pair.first, matrixDisplay));
247 std::string deviceName = hapticObserverProxy
248 ->getDataField(
new DataFieldIdentifier(
249 hapticObserverProxyName, channelName,
"device"))
251 channelNameReverseMap.insert(std::make_pair(matrixDisplay, channelName));
252 deviceNameReverseMap.insert(std::make_pair(matrixDisplay, deviceName));
253 ui->gridLayoutDisplay->addWidget(matrixDisplay, 0, i);
259 HapticUnitWidget::onCheckBoxOffsetFilterStateChanged(
int state)
262 for (std::pair<std::string, MatrixDatafieldDisplayWidget*> pair : matrixDisplays)
264 pair.second->enableOffsetFilter(
ui->checkBoxOffsetFilter->isChecked());
std::enable_if<!HasGetWidgetName< ArmarXWidgetType >::value >::type addWidget()
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
Implements a Variant type for timestamps.
#define ARMARX_IMPORTANT_S
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
const VariantTypeId DatafieldRef
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< TimestampVariant > TimestampVariantPtr