Commit 7ece95e3 authored by hengli's avatar hengli

Fixed module display issues in 3D widgets.

parent 5b27576f
...@@ -40,7 +40,7 @@ HUDScaleGeode::HUDScaleGeode() ...@@ -40,7 +40,7 @@ HUDScaleGeode::HUDScaleGeode()
} }
void void
HUDScaleGeode::init(void) HUDScaleGeode::init(osg::ref_ptr<osgText::Font>& font)
{ {
osg::ref_ptr<osg::Vec2Array> outlineVertices(new osg::Vec2Array); osg::ref_ptr<osg::Vec2Array> outlineVertices(new osg::Vec2Array);
outlineVertices->push_back(osg::Vec2(20.0f, 50.0f)); outlineVertices->push_back(osg::Vec2(20.0f, 50.0f));
...@@ -96,7 +96,7 @@ HUDScaleGeode::init(void) ...@@ -96,7 +96,7 @@ HUDScaleGeode::init(void)
text = new osgText::Text; text = new osgText::Text;
text->setCharacterSize(11); text->setCharacterSize(11);
text->setFont("images/Vera.ttf"); text->setFont(font);
text->setAxisAlignment(osgText::Text::SCREEN); text->setAxisAlignment(osgText::Text::SCREEN);
text->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); text->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
text->setPosition(osg::Vec3(40.0f, 45.0f, -1.5f)); text->setPosition(osg::Vec3(40.0f, 45.0f, -1.5f));
......
...@@ -41,7 +41,7 @@ class HUDScaleGeode : public osg::Geode ...@@ -41,7 +41,7 @@ class HUDScaleGeode : public osg::Geode
public: public:
HUDScaleGeode(); HUDScaleGeode();
void init(void); void init(osg::ref_ptr<osgText::Font>& font);
void update(int windowHeight, float cameraFov, float cameraDistance, void update(int windowHeight, float cameraFov, float cameraDistance,
bool darkBackground); bool darkBackground);
......
...@@ -31,11 +31,17 @@ ...@@ -31,11 +31,17 @@
#include "ImageWindowGeode.h" #include "ImageWindowGeode.h"
ImageWindowGeode::ImageWindowGeode(const QString& caption, ImageWindowGeode::ImageWindowGeode()
const osg::Vec4& backgroundColor,
osg::ref_ptr<osg::Image>& image)
: border(5) : border(5)
{ {
}
void
ImageWindowGeode::init(const QString& caption, const osg::Vec4& backgroundColor,
osg::ref_ptr<osg::Image>& image,
osg::ref_ptr<osgText::Font>& font)
{
// image // image
osg::ref_ptr<osg::Geometry> imageGeometry = new osg::Geometry; osg::ref_ptr<osg::Geometry> imageGeometry = new osg::Geometry;
imageVertices = new osg::Vec3Array(4); imageVertices = new osg::Vec3Array(4);
...@@ -82,7 +88,7 @@ ImageWindowGeode::ImageWindowGeode(const QString& caption, ...@@ -82,7 +88,7 @@ ImageWindowGeode::ImageWindowGeode(const QString& caption,
text = new osgText::Text; text = new osgText::Text;
text->setText(caption.toStdString().c_str()); text->setText(caption.toStdString().c_str());
text->setCharacterSize(11); text->setCharacterSize(11);
text->setFont("images/Vera.ttf"); text->setFont(font);
text->setAxisAlignment(osgText::Text::SCREEN); text->setAxisAlignment(osgText::Text::SCREEN);
text->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); text->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
......
...@@ -40,8 +40,10 @@ ...@@ -40,8 +40,10 @@
class ImageWindowGeode : public osg::Geode class ImageWindowGeode : public osg::Geode
{ {
public: public:
ImageWindowGeode(const QString& caption, const osg::Vec4& backgroundColor, ImageWindowGeode();
osg::ref_ptr<osg::Image>& image); void init(const QString& caption, const osg::Vec4& backgroundColor,
osg::ref_ptr<osg::Image>& image,
osg::ref_ptr<osgText::Font>& font);
void setAttributes(int x, int y, int width, int height); void setAttributes(int x, int y, int width, int height);
......
...@@ -114,6 +114,8 @@ Pixhawk3DWidget::Pixhawk3DWidget(QWidget* parent) ...@@ -114,6 +114,8 @@ Pixhawk3DWidget::Pixhawk3DWidget(QWidget* parent)
buildLayout(); buildLayout();
updateHUD(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "132N");
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
this, SLOT(setActiveUAS(UASInterface*))); this, SLOT(setActiveUAS(UASInterface*)));
} }
...@@ -567,9 +569,30 @@ Pixhawk3DWidget::buildLayout(void) ...@@ -567,9 +569,30 @@ Pixhawk3DWidget::buildLayout(void)
this, SLOT(toggleFollowCamera(int))); this, SLOT(toggleFollowCamera(int)));
} }
void
Pixhawk3DWidget::resizeGL(int width, int height)
{
Q3DWidget::resizeGL(width, height);
resizeHUD();
}
void void
Pixhawk3DWidget::display(void) Pixhawk3DWidget::display(void)
{ {
// set node visibility
rollingMap->setChildValue(gridNode, displayGrid);
rollingMap->setChildValue(trailNode, displayTrail);
rollingMap->setChildValue(mapNode, displayImagery);
rollingMap->setChildValue(waypointGroupNode, displayWaypoints);
rollingMap->setChildValue(targetNode, enableTarget);
#ifdef QGC_PROTOBUF_ENABLED
rollingMap->setChildValue(obstacleGroupNode, displayObstacleList);
#endif
rollingMap->setChildValue(rgbd3DNode, displayRGBD3D);
hudGroup->setChildValue(rgb2DGeode, displayRGBD2D);
hudGroup->setChildValue(depth2DGeode, displayRGBD2D);
if (!uas) if (!uas)
{ {
return; return;
...@@ -636,20 +659,6 @@ Pixhawk3DWidget::display(void) ...@@ -636,20 +659,6 @@ Pixhawk3DWidget::display(void)
updateHUD(robotX, robotY, robotZ, robotRoll, robotPitch, robotYaw, utmZone); updateHUD(robotX, robotY, robotZ, robotRoll, robotPitch, robotYaw, utmZone);
// set node visibility
rollingMap->setChildValue(gridNode, displayGrid);
rollingMap->setChildValue(trailNode, displayTrail);
rollingMap->setChildValue(mapNode, displayImagery);
rollingMap->setChildValue(waypointGroupNode, displayWaypoints);
rollingMap->setChildValue(targetNode, enableTarget);
#ifdef QGC_PROTOBUF_ENABLED
rollingMap->setChildValue(obstacleGroupNode, displayObstacleList);
#endif
rollingMap->setChildValue(rgbd3DNode, displayRGBD3D);
hudGroup->setChildValue(rgb2DGeode, displayRGBD2D);
hudGroup->setChildValue(depth2DGeode, displayRGBD2D);
lastRobotX = robotX; lastRobotX = robotX;
lastRobotY = robotY; lastRobotY = robotY;
lastRobotZ = robotZ; lastRobotZ = robotZ;
...@@ -952,27 +961,25 @@ Pixhawk3DWidget::setupHUD(void) ...@@ -952,27 +961,25 @@ Pixhawk3DWidget::setupHUD(void)
statusText->setAxisAlignment(osgText::Text::SCREEN); statusText->setAxisAlignment(osgText::Text::SCREEN);
statusText->setColor(osg::Vec4(255, 255, 255, 1)); statusText->setColor(osg::Vec4(255, 255, 255, 1));
resizeHUD();
osg::ref_ptr<osg::Geode> statusGeode = new osg::Geode; osg::ref_ptr<osg::Geode> statusGeode = new osg::Geode;
statusGeode->addDrawable(hudBackgroundGeometry); statusGeode->addDrawable(hudBackgroundGeometry);
statusGeode->addDrawable(statusText); statusGeode->addDrawable(statusText);
hudGroup->addChild(statusGeode); hudGroup->addChild(statusGeode);
rgbImage = new osg::Image; rgbImage = new osg::Image;
rgb2DGeode = new ImageWindowGeode("RGB Image", rgb2DGeode = new ImageWindowGeode;
osg::Vec4(0.0f, 0.0f, 0.1f, 1.0f), rgb2DGeode->init("RGB Image", osg::Vec4(0.0f, 0.0f, 0.1f, 1.0f),
rgbImage); rgbImage, font);
hudGroup->addChild(rgb2DGeode); hudGroup->addChild(rgb2DGeode);
depthImage = new osg::Image; depthImage = new osg::Image;
depth2DGeode = new ImageWindowGeode("Depth Image", depth2DGeode = new ImageWindowGeode;
osg::Vec4(0.0f, 0.0f, 0.1f, 1.0f), depth2DGeode->init("Depth Image", osg::Vec4(0.0f, 0.0f, 0.1f, 1.0f),
depthImage); depthImage, font);
hudGroup->addChild(depth2DGeode); hudGroup->addChild(depth2DGeode);
scaleGeode = new HUDScaleGeode; scaleGeode = new HUDScaleGeode;
scaleGeode->init(); scaleGeode->init(font);
hudGroup->addChild(scaleGeode); hudGroup->addChild(scaleGeode);
} }
...@@ -1018,8 +1025,6 @@ Pixhawk3DWidget::updateHUD(double robotX, double robotY, double robotZ, ...@@ -1018,8 +1025,6 @@ Pixhawk3DWidget::updateHUD(double robotX, double robotY, double robotZ,
double robotRoll, double robotPitch, double robotYaw, double robotRoll, double robotPitch, double robotYaw,
const QString& utmZone) const QString& utmZone)
{ {
resizeHUD();
std::pair<double,double> cursorPosition = std::pair<double,double> cursorPosition =
getGlobalCursorPosition(getMouseX(), getMouseY(), -robotZ); getGlobalCursorPosition(getMouseX(), getMouseY(), -robotZ);
......
...@@ -81,6 +81,7 @@ private slots: ...@@ -81,6 +81,7 @@ private slots:
protected: protected:
QVector< osg::ref_ptr<osg::Node> > findVehicleModels(void); QVector< osg::ref_ptr<osg::Node> > findVehicleModels(void);
void buildLayout(void); void buildLayout(void);
virtual void resizeGL(int width, int height);
virtual void display(void); virtual void display(void);
virtual void keyPressEvent(QKeyEvent* event); virtual void keyPressEvent(QKeyEvent* event);
virtual void mousePressEvent(QMouseEvent* event); virtual void mousePressEvent(QMouseEvent* event);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment