37 #include <QFontDatabase> 46 #include "Entypo_Social.dat" 47 #include "fontawesome.dat" 53 int addFont(
unsigned char* data,
unsigned int data_len)
57 QByteArray::fromRawData(
58 reinterpret_cast<const char*>(data), data_len);
60 QFontDatabase::addApplicationFontFromData(entypo);
69 return (std::abs(a - b) < 0.01);
86 return QFont(
"Entypo Social");
90 return QFont(
"Entypo");
93 return QFont(
"FontAwesome");
127 Ogre::SceneNode* parent,
130 need_to_update_(false),
194 if (
action_ == jsk_rviz_plugins::Pictogram::DELETE) {
204 Ogre::Vector3 position;
205 Ogre::Quaternion quaternion;
212 ROS_ERROR(
"Error transforming pose from frame '%s'",
217 if (
action_ == jsk_rviz_plugins::Pictogram::ADD) {
221 else if (
action_ == jsk_rviz_plugins::Pictogram::ROTATE_Z ||
222 action_ == jsk_rviz_plugins::Pictogram::ROTATE_X ||
223 action_ == jsk_rviz_plugins::Pictogram::ROTATE_Y) {
225 if (
action_ == jsk_rviz_plugins::Pictogram::ROTATE_Z) {
226 axis = Ogre::Vector3(0, 0, 1);
228 else if (
action_ == jsk_rviz_plugins::Pictogram::ROTATE_X) {
229 axis = Ogre::Vector3(1, 0, 0);
231 else if (
action_ == jsk_rviz_plugins::Pictogram::ROTATE_Y) {
232 axis = Ogre::Vector3(0, 1, 0);
238 Ogre::Quaternion offset;
239 offset.FromAngleAxis(
theta, axis);
240 Ogre::Quaternion final_rot = quaternion * offset;
244 else if (
action_ == jsk_rviz_plugins::Pictogram::JUMP ||
245 action_ == jsk_rviz_plugins::Pictogram::JUMP_ONCE) {
246 bool jumpingp =
false;
247 if (
action_ == jsk_rviz_plugins::Pictogram::JUMP) {
250 else if (
action_ == jsk_rviz_plugins::Pictogram::JUMP_ONCE &&
262 Ogre::Vector3 new_pos = position + quaternion * Ogre::Vector3(height, 0, 0);
268 double exceeded_time;
272 setAction(jsk_rviz_plugins::Pictogram::DELETE);
292 QColor transparent(255, 255, 255, 0);
293 QImage Hud = buffer.
getQImage(128, 128, transparent);
294 QPainter painter( &Hud );
295 painter.setRenderHint(QPainter::Antialiasing,
true);
297 painter.setPen(QPen(foreground, 5, Qt::SolidLine));
303 font.setPointSize(100);
306 font.setPointSize(45);
308 painter.setFont(font);
309 painter.drawText(0, 0, 128, 128,
310 Qt::AlignHCenter | Qt::AlignVCenter,
313 }
else if(
mode_ == jsk_rviz_plugins::Pictogram::STRING_MODE){
314 QFont
font(
"Liberation Sans");
315 font.setPointSize(32);
317 painter.setFont(font);
318 painter.drawText(0, 0, 128, 128,
319 Qt::TextWordWrap | Qt::AlignHCenter | Qt::AlignVCenter,
374 MFDClass::onInitialize();
380 pictogram_->setEnable(
false);
383 pictogram_->setColor(QColor(25, 255, 240));
384 pictogram_->setAlpha(1.0);
385 pictogram_->setSpeed(1.0);
386 scene_node_ =
scene_manager_->getRootSceneNode()->createChildSceneNode();
392 pictogram_->setEnable(
false);
401 pictogram_->setEnable(
false);
407 boost::mutex::scoped_lock
lock(mutex_);
409 pictogram_->setEnable(isEnabled());
413 pictogram_->setAction(msg->action);
414 if (msg->action == jsk_rviz_plugins::Pictogram::DELETE) {
418 if (msg->size <= 0.0) {
419 pictogram_->setSize(0.5);
422 pictogram_->setSize(msg->size / 2.0);
424 pictogram_->setColor(QColor(msg->color.r * 255,
426 msg->color.b * 255));
427 pictogram_->setAlpha(msg->color.a);
428 pictogram_->setPose(msg->pose, msg->header.frame_id);
429 pictogram_->setText(msg->character);
430 pictogram_->setMode(msg->mode);
431 pictogram_->setTTL(msg->ttl);
433 pictogram_->setSpeed(msg->speed);
438 boost::mutex::scoped_lock
lock(mutex_);
440 pictogram_->update(wall_dt, ros_dt);
virtual void setSize(double size)
QString lookupPictogramText(std::string character)
virtual void setPosition(Ogre::Vector3 &pos)
virtual void onInitialize()
std::map< std::string, QString > entypo_character_map
void processMessage(const jsk_rviz_plugins::Pictogram::ConstPtr &msg)
virtual void setTTL(double ttl)
QFont getFont(std::string character)
virtual QImage getQImage(unsigned int width, unsigned int height)
virtual void setText(std::string text)
TextureObject::Ptr texture_object_
std::map< std::string, QString > entypo_social_character_map
virtual void setAlpha(double alpha)
SquareObject::Ptr square_object_
virtual void setAlpha(double alpha)
bool epsEqual(double a, double b)
virtual void setOrientation(rviz::DisplayContext *context)
virtual void setContext(rviz::DisplayContext *context)
geometry_msgs::Pose pose_
bool isCharacterSupported(std::string character)
int addFont(unsigned char *data, unsigned int data_len)
std::map< std::string, QString > fontawesome_character_map
virtual void setMode(uint8_t mode)
virtual void update(float wall_dt, float ros_dt)
QColor ogreToQt(const Ogre::ColourValue &c)
bool transform(const Header &header, const geometry_msgs::Pose &pose, Ogre::Vector3 &position, Ogre::Quaternion &orientation)
virtual FrameManager * getFrameManager() const =0
virtual void setSize(double size)
bool isEntypo(std::string text)
bool isFontAwesome(std::string text)
virtual void setColor(QColor color)
rviz::DisplayContext * context_
virtual void updateText()
void update(float wall_dt, float ros_dt)
virtual void updatePose(float dt)
virtual ~PictogramDisplay()
virtual void updateColor()
Ogre::SceneManager * scene_manager_
virtual void setText(std::string text)
virtual void setSpeed(double speed)
virtual void setEnable(bool enable)
virtual void setEnable(bool enable)
virtual void setPose(const geometry_msgs::Pose &pose, const std::string &frame_id)
PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::PictogramDisplay, rviz::Display)
virtual void setColor(QColor color)
virtual void setAction(uint8_t action)
PictogramObject(Ogre::SceneManager *manager, Ogre::SceneNode *parent, double size)