Apollo  6.0
Open source self driving car software
radarpoints.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #pragma once
18 
19 #include <QtGui/QColor>
20 #include <memory>
21 #include <string>
22 
23 #include "modules/drivers/proto/radar.pb.h"
25 
26 class QOpenGLShaderProgram;
27 
28 class RadarPoints : public RenderableObject {
29  /* struct Point{
30  * GLfloat x, // raw data from radar
31  * GLfloat y,
32  * GLfloat r
33  * };
34  */
35 
36  public:
37  explicit RadarPoints(
38  const std::shared_ptr<QOpenGLShaderProgram>& shaderProgram = nullptr);
39  ~RadarPoints(void) {
40  if (buffer_) {
41  delete[] buffer_;
42  buffer_ = nullptr;
43  }
44  }
45 
46  virtual GLenum GetPrimitiveType(void) const { return GL_POINTS; }
47 
48  void SetupExtraUniforms(void) {
49  shader_program_->setUniformValue("color", color_);
50  }
51 
52  GLfloat red(void) const { return color_.x(); }
53  GLfloat green(void) const { return color_.y(); }
54  GLfloat blue(void) const { return color_.z(); }
55 
56  const QVector3D& color(void) const { return color_; }
57 
58  void set_color(const QRgb& rgb) { set_color(QColor(rgb)); }
59 
60  void set_color(const QColor& color) {
61  color_.setX(static_cast<float>(color.redF()));
62  color_.setY(static_cast<float>(color.greenF()));
63  color_.setZ(static_cast<float>(color.blueF()));
64  }
65 
66  bool FillData(
67  const std::shared_ptr<const apollo::drivers::RadarObstacles>& pData);
68 
69  protected:
70  bool FillVertexBuffer(GLfloat* pBuffer) override;
71 
72  private:
73  QVector3D color_; // r, g, b
74  GLfloat* buffer_;
75 };
bool FillVertexBuffer(GLfloat *pBuffer) override
GLfloat red(void) const
Definition: radarpoints.h:52
Definition: radarpoints.h:28
GLfloat blue(void) const
Definition: radarpoints.h:54
Definition: renderable_object.h:25
RadarPoints(const std::shared_ptr< QOpenGLShaderProgram > &shaderProgram=nullptr)
std::shared_ptr< QOpenGLShaderProgram > shader_program_
Definition: renderable_object.h:88
GLfloat green(void) const
Definition: radarpoints.h:53
bool FillData(const std::shared_ptr< const apollo::drivers::RadarObstacles > &pData)
void SetupExtraUniforms(void)
Definition: radarpoints.h:48
virtual GLenum GetPrimitiveType(void) const
Definition: radarpoints.h:46
void set_color(const QRgb &rgb)
Definition: radarpoints.h:58
~RadarPoints(void)
Definition: radarpoints.h:39
void set_color(const QColor &color)
Definition: radarpoints.h:60
const QVector3D & color(void) const
Definition: radarpoints.h:56