From c529ff516ac7d22e7f2c7ec8e73a578146e44361 Mon Sep 17 00:00:00 2001 From: Lionel Heng Date: Sun, 26 Feb 2012 21:45:04 +0100 Subject: [PATCH] Added text (component id) to cone/circle symbol symbolizing pose data from that component in 3D view. --- src/ui/map3D/Pixhawk3DWidget.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/ui/map3D/Pixhawk3DWidget.cc b/src/ui/map3D/Pixhawk3DWidget.cc index 931f1969b..ea3b7b5de 100644 --- a/src/ui/map3D/Pixhawk3DWidget.cc +++ b/src/ui/map3D/Pixhawk3DWidget.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include "../MainWindow.h" #include "PixhawkCheetahGeode.h" @@ -236,6 +237,29 @@ Pixhawk3DWidget::localPositionChanged(UASInterface* uas, int component, geode->addDrawable(sd); group->addChild(geode); + // text indicates component id + osg::ref_ptr text = new osgText::Text; + text->setFont(m3DWidget->font()); + text->setText(QString::number(component).toStdString().c_str()); + text->setColor(color); + text->setCharacterSize(0.3f); + text->setAxisAlignment(osgText::Text::XY_PLANE); + text->setAlignment(osgText::Text::CENTER_CENTER); + text->setPosition(osg::Vec3(0.0, -0.8, 0.0)); + + sd = new osg::ShapeDrawable; + osg::ref_ptr textBox = + new osg::Box(osg::Vec3(0.0, -0.8, -0.01), 0.7, 0.4, 0.01); + + sd->setShape(textBox); + sd->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); + sd->setColor(osg::Vec4(0.0, 0.0, 0.0, 1.0)); + + geode = new osg::Geode; + geode->addDrawable(text); + geode->addDrawable(sd); + group->addChild(geode); + pat = new osg::PositionAttitudeTransform; pat->addChild(group); systemData.orientationNode()->addChild(pat); -- 2.22.0