15 #include <QResizeEvent>
23 #include <hri_msgs/IdsList.h>
25 #include "ui_radar_tabs.h"
36 connect(
timer_, &QTimer::timeout,
this, QOverload<>::of(&RadarCanvas::update));
63 yOffset_ = parent->size().height()/2;
69 QColor lightGrey(232, 232, 233);
70 QColor lighterGrey(237, 238, 239);
71 QColor midGrey(175, 175, 175);
85 double distanceFromTopRightCorner =
90 this->setMouseTracking(
true);
109 QPainter painter(
this);
110 painter.setRenderHint(QPainter::Antialiasing);
111 font_ = painter.font();
116 painter.setPen(QPen(Qt::transparent));
122 double circleRectOriginX =
xOffset_ - circleRange;
123 double circleRectOriginY =
yOffset_ - circleRange;
124 double circleRectWidth = 2*circleRange;
125 double circleRectHeight = 2*circleRange;
128 circleRectOriginX, circleRectOriginY, circleRectWidth, circleRectHeight);
131 QString rangeDescription =
132 QString::fromStdString(std::to_string(arcN)+
"m");
142 painter.drawEllipse(circleRect);
144 painter.translate(textPoint);
146 painter.drawText(QPoint(0, 0), rangeDescription);
148 painter.translate(-textPoint);
160 painter.translate(QPointF(xToPrint, yToPrint));
161 painter.rotate(
angle*180/M_PI);
164 QString::fromStdString(
165 std::to_string(
int(std::round(
angle*180/M_PI))*-1)+
"°"));
166 painter.rotate(-
angle*180/M_PI);
167 painter.translate(-QPointF(xToPrint, yToPrint));
171 painter.setPen(QPen(Qt::transparent));
180 double m = std::tan(
angle/180*M_PI);
183 double candidateXMaxHeight =
185 if(candidateYMaxWidth > this->size().height())
194 if(candidateYMaxWidth < 0)
204 painter.setBrush(QBrush(Qt::transparent));
205 painter.setPen(QPen(Qt::black));
211 for(
auto&
body: bodies){
212 geometry_msgs::Vector3Stamped rotatedVersor;
214 std::string
id =
body.first;
215 std::string bodyFrame =
"body_" + id;
216 versor_.header.frame_id = bodyFrame;
224 std::sqrt(std::pow(bodyTrans.
getOrigin().x(), 2)
225 + std::pow(bodyTrans.
getOrigin().y(), 2));
227 std::atan2(-(rotatedVersor.vector.y), -(rotatedVersor.vector.x));
242 double rotatedHeightX =
244 double rotatedHeightY =
249 double personRectTopLeftX =
254 double personRectTopLeftY =
260 double personRectBottomRightX =
265 double personRectBottomRightY =
271 double personRectBottomLeftX =
276 double personRectBottomLeftY =
282 double personRectTopRightX =
287 double personRectTopRightY =
293 QPointF topLeftCorner(personRectTopLeftX, personRectTopLeftY);
294 QPointF bottomRightCorner(personRectBottomRightX, personRectBottomRightY);
295 QPointF bottomLeftCorner(personRectBottomLeftX, personRectBottomLeftY);
296 QPointF topRightCorner(personRectTopRightX, personRectTopRightY);
300 painter.translate(topLeftCorner);
301 painter.rotate(-(theta*180)/M_PI);
304 painter.rotate((theta*180)/M_PI);
305 painter.translate(-topLeftCorner);
310 QVector<QPoint> points;
311 points.append(topLeftCorner.toPoint());
312 points.append(bottomLeftCorner.toPoint());
313 points.append(bottomRightCorner.toPoint());
314 points.append(topRightCorner.toPoint());
317 std::pair<std::string, QPolygon>(
id, QPolygon(points)));
322 QString identificator = QString::fromStdString(
id);
324 painter.drawText(bottomRightCorner, identificator);
326 std::ostringstream distanceStream;
327 distanceStream << std::fixed << std::setprecision(2) << distance;
328 std::string distanceString = distanceStream.str();
329 QString distanceInfo =
330 QString::fromStdString(
"Distance: " + distanceString);
331 painter.drawText(bottomRightCorner, identificator);
332 painter.drawText(bottomLeftCorner, distanceInfo);
364 if(elem.second.containsPoint(QPoint(event->x(), event->y()), Qt::OddEvenFill)){
372 return (x > 0) && (y > 0) && (x < this->size().width()) && (y < this->size().height());
376 double distanceFromTopRightCorner =