Apollo 11.0
自动驾驶开放平台
VideoImgViewer类 参考

#include <video_image_viewer.h>

类 VideoImgViewer 继承关系图:
VideoImgViewer 的协作图:

Public 成员函数

 VideoImgViewer (QWidget *parent=nullptr)
 
 ~VideoImgViewer ()
 

Protected 成员函数

void initializeGL () override
 
void resizeGL (int w, int h) override
 
void paintGL () override
 

友元

class FixedAspectRatioWidget
 

详细描述

在文件 video_image_viewer.h 第 28 行定义.

构造及析构函数说明

◆ VideoImgViewer()

VideoImgViewer::VideoImgViewer ( QWidget *  parent = nullptr)
explicit

在文件 video_image_viewer.cc 第 21 行定义.

22 : QOpenGLWidget(parent),
23 QOpenGLFunctions(),
24 is_init_(false),
25 mvp_id_(),
26 plane_(),
27 ortho_camera_(),
28 default_image_(nullptr),
29 video_image_shader_prog_(nullptr) {}

◆ ~VideoImgViewer()

VideoImgViewer::~VideoImgViewer ( )

在文件 video_image_viewer.cc 第 31 行定义.

31 {
32 if (is_init_) {
33 is_init_ = false;
34
35 makeCurrent();
36
37 plane_.Destroy();
38 video_image_shader_prog_->destroyed();
39 video_image_shader_prog_.reset();
40 default_image_.reset();
41
42 doneCurrent();
43 }
44}

成员函数说明

◆ initializeGL()

void VideoImgViewer::initializeGL ( )
overrideprotected

在文件 video_image_viewer.cc 第 46 行定义.

46 {
47 initializeOpenGLFunctions();
48
49 glPointSize(1.0f);
50 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
51
52 QImage noImage;
53 if (!noImage.load(tr(":/images/no_image.png"))) {
54 std::cout << "--------can not load the default texture------------"
55 << std::endl;
56 return;
57 }
58
59 default_image_ = std::make_shared<Texture>();
60 if (default_image_ == nullptr || !default_image_->UpdateData(noImage)) {
61 std::cout << "--------can not create the default texture------------"
62 << std::endl;
63 return;
64 }
65
66 video_image_shader_prog_ = RenderableObject::CreateShaderProgram(
67 tr("/apollo/modules/tools/visualizer/shaders/video_image_plane.vert"),
68 tr("/apollo/modules/tools/visualizer/shaders/video_image_plane.frag"));
69 if (video_image_shader_prog_ == nullptr) {
70 return;
71 }
72
73 plane_.set_texture(default_image_);
74 if (!plane_.Init(video_image_shader_prog_)) {
75 return;
76 }
77
78 ortho_camera_.set_near_plane_width(GLfloat(width()));
79 ortho_camera_.set_near_plane_height(GLfloat(height()));
80
81 ortho_camera_.set_fov(static_cast<float>(height()));
83 ortho_camera_.set_position(0.0f, 0.0f, 0.0f);
84
85 ortho_camera_.UpdateWorld();
86 ortho_camera_.UpdateProjection();
87
88 QMatrix4x4 mvp =
89 ortho_camera_.projection_matrix() * ortho_camera_.model_view_matrix();
90
91 video_image_shader_prog_->bind();
92 video_image_shader_prog_->setUniformValue(mvp_id_, mvp);
93 video_image_shader_prog_->release();
94
95 is_init_ = true;
96}
void set_near_plane_width(const float npWidth)
void set_position(const QVector3D &pos)
const QMatrix4x4 & model_view_matrix(void) const
void UpdateProjection(void)
const QMatrix4x4 & projection_matrix(void) const
void set_camera_mode(CameraMode cm)
void set_fov(const float fovInDegrees)
void set_near_plane_height(const float npHeight)
virtual void UpdateWorld(void)
void set_texture(const std::shared_ptr< Texture > &t)
Definition plane.h:40
bool Init(std::shared_ptr< QOpenGLShaderProgram > &shaderProgram=NullRenderableObj)
static std::shared_ptr< QOpenGLShaderProgram > CreateShaderProgram(const QString &vertexShaderFileName, const QString &fragShaderFileName)
uint32_t height
Height of point cloud
uint32_t width
Width of point cloud

◆ paintGL()

void VideoImgViewer::paintGL ( )
overrideprotected

在文件 video_image_viewer.cc 第 116 行定义.

116 {
117 if (is_init_) {
118 plane_.Render();
119 }
120}
void Render(const QMatrix4x4 *mvp=nullptr)

◆ resizeGL()

void VideoImgViewer::resizeGL ( int  w,
int  h 
)
overrideprotected

在文件 video_image_viewer.cc 第 98 行定义.

98 {
99 glViewport(0, 0, (GLsizei)width, (GLsizei)height);
100
101 if (is_init_) {
102 ortho_camera_.set_fov(static_cast<float>(height));
103 ortho_camera_.set_near_plane_width(GLfloat(width));
104 ortho_camera_.set_near_plane_height(GLfloat(height));
105 ortho_camera_.UpdateProjection();
106
107 QMatrix4x4 mvp =
108 ortho_camera_.projection_matrix() * ortho_camera_.model_view_matrix();
109
110 video_image_shader_prog_->bind();
111 video_image_shader_prog_->setUniformValue(mvp_id_, mvp);
112 video_image_shader_prog_->release();
113 }
114}

友元及相关函数文档

◆ FixedAspectRatioWidget

friend class FixedAspectRatioWidget
friend

在文件 video_image_viewer.h 第 47 行定义.


该类的文档由以下文件生成: