Skip to content
Snippets Groups Projects
Commit 9e19e97b authored by Silas Dohm's avatar Silas Dohm
Browse files

label can be turned on and off

parent 48440013
No related branches found
No related tags found
No related merge requests found
......@@ -97,7 +97,8 @@ private:
ros::WallTime last_command_time_;
float meter_;
QString label = "0";
bool label_on_ = false;
QString label_ = "";
struct TeleportRequest
{
......
......@@ -92,7 +92,8 @@ bool Turtle::setPenCallback(turtlesim::SetPen::Request& req, turtlesim::SetPen::
}
bool Turtle::setLabelCallback(turtlesim_xl::SetLabel::Request& req, turtlesim_xl::SetLabel::Response&){
Turtle::label = QString(req.name.c_str());
Turtle::label_ = QString(req.name.c_str());
label_on_ = req.on;
return true;
}
bool Turtle::teleportRelativeCallback(turtlesim::TeleportRelative::Request& req, turtlesim::TeleportRelative::Response&)
......@@ -220,14 +221,15 @@ bool Turtle::update(double dt, QPainter& path_painter, const QImage& path_image,
void Turtle::paint(QPainter& painter)
{
QPointF p = pos_ * meter_;
QPointF pl = pos_ * meter_;
pl.rx() -= 0.3 * turtle_rotated_image_.width();
//pl.ry() -= 0.5 * turtle_rotated_image_.height();
p.rx() -= 0.5 * turtle_rotated_image_.width();
p.ry() -= 0.5 * turtle_rotated_image_.height();
painter.drawImage(p, turtle_rotated_image_);
if(label_on_){
QPointF pl = pos_ * meter_;
pl.rx() -= 0.3 * turtle_rotated_image_.width();
painter.setPen(Qt::red);
painter.drawText(pl,Turtle::label);
painter.drawText(pl,Turtle::label_);
}
}
}
......@@ -35,9 +35,9 @@
#include <cstdlib>
#include <ctime>
#define DEFAULT_BG_R 0x2a
#define DEFAULT_BG_G 0x2a
#define DEFAULT_BG_B 0x2e
#define DEFAULT_BG_R 0x00
#define DEFAULT_BG_G 0x00
#define DEFAULT_BG_B 0x00
#define FRAME_WIDTH 1200
#define FRAME_HEIGHT 800
......
string name
uint8 on
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment