Delegate retrieval of moment data to view class

This commit is contained in:
Dan Paulat 2021-10-30 23:20:50 -05:00
parent 5cbe986734
commit 7747e869ba
3 changed files with 32 additions and 12 deletions

View file

@ -129,11 +129,7 @@ void RadarProductLayer::UpdateSweep()
boost::timer::cpu_timer timer;
const std::vector<float>& vertices = p->radarProductView_->vertices();
const std::vector<uint8_t>& dataMoments8 =
p->radarProductView_->data_moments8();
const std::vector<uint16_t>& dataMoments16 =
p->radarProductView_->data_moments16();
const std::vector<float>& vertices = p->radarProductView_->vertices();
// Bind a vertex array object
gl.glBindVertexArray(p->vao_);
@ -158,19 +154,19 @@ void RadarProductLayer::UpdateSweep()
// Buffer data moments
const GLvoid* data;
GLsizeiptr dataSize;
size_t componentSize;
GLenum type;
if (dataMoments8.size() > 0)
std::tie(data, dataSize, componentSize) =
p->radarProductView_->GetMomentData();
if (componentSize == 1)
{
data = static_cast<const GLvoid*>(dataMoments8.data());
dataSize = dataMoments8.size() * sizeof(GLubyte);
type = GL_UNSIGNED_BYTE;
type = GL_UNSIGNED_BYTE;
}
else
{
data = static_cast<const GLvoid*>(dataMoments16.data());
dataSize = dataMoments16.size() * sizeof(GLushort);
type = GL_UNSIGNED_SHORT;
type = GL_UNSIGNED_SHORT;
}
gl.glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[1]);

View file

@ -96,6 +96,28 @@ void RadarProductView::Initialize()
UpdatePlot();
}
std::tuple<const void*, size_t, size_t> RadarProductView::GetMomentData()
{
const void* data;
size_t dataSize;
size_t componentSize;
if (p->dataMoments8_.size() > 0)
{
data = p->dataMoments8_.data();
dataSize = p->dataMoments8_.size() * sizeof(uint8_t);
componentSize = 1;
}
else
{
data = p->dataMoments16_.data();
dataSize = p->dataMoments16_.size() * sizeof(uint16_t);
componentSize = 2;
}
return std::tie(data, dataSize, componentSize);
}
void RadarProductView::LoadColorTable(
std::shared_ptr<common::ColorTable> colorTable)
{

View file

@ -37,6 +37,8 @@ public:
const std::vector<boost::gil::rgba8_pixel_t>& color_table() const;
void Initialize();
std::tuple<const void*, size_t, size_t> GetMomentData();
void LoadColorTable(std::shared_ptr<common::ColorTable> colorTable);
std::chrono::system_clock::time_point PlotTime();