26 #include <RobotAPI/gui-plugins/HapticUnitPlugin/ui_HapticUnitConfigDialog.h>
32 #include <IceUtil/Time.h>
36 #include <QInputDialog>
39 #include <QPushButton>
47 addWidget<HapticUnitWidget>();
56 hapticObserverProxyName =
"HapticUnitObserver";
57 hapticUnitProxyName =
"WeissHapticUnit";
59 updateTimer =
new QTimer(
this);
77 hapticObserverProxy = getProxy<ObserverInterfacePrx>(hapticObserverProxyName);
78 weissHapticUnit = getProxy<WeissHapticUnitInterfacePrx>(hapticUnitProxyName);
81 createMatrixWidgets();
82 updateTimer->start(25);
105 return qobject_cast<HapticUnitConfigDialog*>(dialog);
117 for (std::pair<std::string, MatrixDatafieldDisplayWidget*> pair : matrixDisplays)
120 std::string name = hapticObserverProxy->getDataField(
new DataFieldIdentifier(hapticObserverProxyName, pair.first,
"name"))->getString();
121 std::string deviceName = hapticObserverProxy->getDataField(
new DataFieldIdentifier(hapticObserverProxyName, pair.first,
"device"))->getString();
125 matrixDisplay->
setInfoOverlay(QString::fromStdString(deviceName) +
": " + QString::fromStdString(name) +
"\n" + QString::fromStdString(timestamp->toTime().toDateTime()));
126 matrixDisplay->invokeUpdate();
133 QMenu* contextMenu =
new QMenu(
getWidget());
141 QAction* setDeviceTag = contextMenu->addAction(tr(
"Set Device Tag"));
143 QAction* action = contextMenu->exec(matrixDisplay->mapToGlobal(point));
145 std::string channelName = channelNameReverseMap.at(matrixDisplay);
146 std::string deviceName = deviceNameReverseMap.at(matrixDisplay);
148 if (action == setDeviceTag)
150 std::string
tag = hapticObserverProxy->getDataField(
new DataFieldIdentifier(hapticObserverProxyName, channelName,
"name"))->getString();
153 QString newTag = QInputDialog::getText(
getWidget(), tr(
"Set Device Tag"),
154 QString::fromStdString(
"New Tag for Device '" + deviceName +
"'"), QLineEdit::Normal,
155 QString::fromStdString(
tag), &
ok);
157 if (
ok && !newTag.isEmpty())
159 ARMARX_IMPORTANT_S <<
"requesting to set new device tag for " << deviceName <<
": " << newTag.toStdString();
160 weissHapticUnit->setDeviceTag(deviceName, newTag.toStdString());
181 connect(updateTimer, SIGNAL(timeout()),
this, SLOT(
updateData()));
182 connect(
ui.checkBoxOffsetFilter, SIGNAL(stateChanged(
int)),
this, SLOT(onCheckBoxOffsetFilterStateChanged(
int)));
185 void HapticUnitWidget::createMatrixWidgets()
191 void HapticUnitWidget::updateDisplayWidgets()
195 while ((child =
ui.gridLayoutDisplay->takeAt(0)) != 0)
201 ChannelRegistry channels = hapticObserverProxy->getAvailableChannels(
false);
203 for (std::pair<std::string, ChannelRegistryEntry> pair : channels)
205 std::string channelName = pair.first;
206 MatrixDatafieldDisplayWidget* matrixDisplay =
new MatrixDatafieldDisplayWidget(
new DatafieldRef(hapticObserverProxy, channelName,
"matrix"), hapticObserverProxy,
getWidget());
207 matrixDisplay->setRange(0, 4095);
208 matrixDisplay->setContextMenuPolicy(Qt::CustomContextMenu);
209 connect(matrixDisplay, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(
onContextMenu(QPoint)));
210 matrixDisplays.insert(std::make_pair(pair.first, matrixDisplay));
211 std::string deviceName = hapticObserverProxy->getDataField(
new DataFieldIdentifier(hapticObserverProxyName, channelName,
"device"))->getString();
212 channelNameReverseMap.insert(std::make_pair(matrixDisplay, channelName));
213 deviceNameReverseMap.insert(std::make_pair(matrixDisplay, deviceName));
214 ui.gridLayoutDisplay->addWidget(matrixDisplay, 0, i);
219 void HapticUnitWidget::onCheckBoxOffsetFilterStateChanged(
int state)
222 for (std::pair<std::string, MatrixDatafieldDisplayWidget*> pair : matrixDisplays)
224 pair.second->enableOffsetFilter(
ui.checkBoxOffsetFilter->isChecked());