25 #include <RobotAPI/gui-plugins/HapticUnitPlugin/ui_MatrixDisplayWidget.h>
40 this->data = MatrixXf(1, 1);
42 QColor
c[] = {QColor::fromHsv(0, 0, 0), QColor::fromHsv(240, 255, 255), QColor::fromHsv(270, 255, 255), QColor::fromHsv(300, 255, 255),
43 QColor::fromHsv(0, 255, 255), QColor::fromHsv(30, 255, 255), QColor::fromHsv(60, 255, 255)
45 this->colors = std::valarray<QColor>(
c,
sizeof c /
sizeof c[0]);
48 connect(
this, SIGNAL(
doUpdate()), SLOT(
update()), Qt::QueuedConnection);
59 MatrixXf data = this->data;
64 int dx = (width() - pixelSize *
data.cols()) / 2;
65 int dy = (height() - pixelSize *
data.rows()) / 2;
66 QPainter painter(
this);
67 painter.fillRect(rect(), QColor::fromRgb(0, 0, 0));
68 painter.setFont(QFont(
"Arial", 8));
70 for (
int x = 0; x <
data.cols(); x++)
72 for (
int y = 0; y <
data.rows(); y++)
74 QRect
target = QRect(dx + x * pixelSize, dy + y * pixelSize, pixelSize, pixelSize);
76 painter.drawText(
target, Qt::AlignCenter, QString::number(
data(y, x)));
80 painter.setFont(QFont(
"Arial", 12));
81 painter.drawText(rect(), Qt::AlignBottom | Qt::AlignRight, infoOverlay);
95 if (
value >= colors.size() - 1)
97 return colors[colors.size() - 1];
101 float f2 =
value - i;
103 QColor c1 = colors[i];
104 QColor c2 = colors[i + 1];
105 return QColor((
int)(c1.red() * f1 + c2.red() * f2), (
int)(c1.green() * f1 + c2.green() * f2), (
int)(c1.blue() * f1 + c2.blue() * f2));