32 #include <RobotAPI/gui-plugins/HapticUnitPlugin/ui_MatrixDisplayWidget.h>
42 this->data = MatrixXf(1, 1);
44 QColor
c[] = {QColor::fromHsv(0, 0, 0),
45 QColor::fromHsv(240, 255, 255),
46 QColor::fromHsv(270, 255, 255),
47 QColor::fromHsv(300, 255, 255),
48 QColor::fromHsv(0, 255, 255),
49 QColor::fromHsv(30, 255, 255),
50 QColor::fromHsv(60, 255, 255)};
51 this->colors = std::valarray<QColor>(
c,
sizeof c /
sizeof c[0]);
54 connect(
this, SIGNAL(
doUpdate()), SLOT(
update()), Qt::QueuedConnection);
66 MatrixXf data = this->data;
71 int dx = (width() - pixelSize *
data.cols()) / 2;
72 int dy = (height() - pixelSize *
data.rows()) / 2;
73 QPainter painter(
this);
74 painter.fillRect(rect(), QColor::fromRgb(0, 0, 0));
75 painter.setFont(QFont(
"Arial", 8));
77 for (
int x = 0; x <
data.cols(); x++)
79 for (
int y = 0; y <
data.rows(); y++)
81 QRect
target = QRect(dx + x * pixelSize, dy + y * pixelSize, pixelSize, pixelSize);
83 painter.drawText(
target, Qt::AlignCenter, QString::number(
data(y, x)));
87 painter.setFont(QFont(
"Arial", 12));
88 painter.drawText(rect(), Qt::AlignBottom | Qt::AlignRight, infoOverlay);
103 if (
value >= colors.size() - 1)
105 return colors[colors.size() - 1];
109 float f2 =
value - i;
111 QColor c1 = colors[i];
112 QColor c2 = colors[i + 1];
113 return QColor((
int)(c1.red() * f1 + c2.red() * f2),
114 (
int)(c1.green() * f1 + c2.green() * f2),
115 (
int)(c1.blue() * f1 + c2.blue() * f2));