Refactor color table functions to reference the lookup table where appropriate

This commit is contained in:
Dan Paulat 2024-01-04 23:16:05 -06:00
parent c1280c05aa
commit 03f08d54f1
11 changed files with 30 additions and 29 deletions

View file

@ -109,7 +109,7 @@ void ColorTableLayer::Initialize()
gl.glEnableVertexAttribArray(1); gl.glEnableVertexAttribArray(1);
connect(context()->radar_product_view().get(), connect(context()->radar_product_view().get(),
&view::RadarProductView::ColorTableUpdated, &view::RadarProductView::ColorTableLutUpdated,
this, this,
[this]() { p->colorTableNeedsUpdate_ = true; }); [this]() { p->colorTableNeedsUpdate_ = true; });
} }
@ -142,7 +142,7 @@ void ColorTableLayer::Render(
if (p->colorTableNeedsUpdate_) if (p->colorTableNeedsUpdate_)
{ {
p->colorTable_ = radarProductView->color_table(); p->colorTable_ = radarProductView->color_table_lut();
gl.glActiveTexture(GL_TEXTURE0); gl.glActiveTexture(GL_TEXTURE0);
gl.glBindTexture(GL_TEXTURE_1D, p->texture_); gl.glBindTexture(GL_TEXTURE_1D, p->texture_);

View file

@ -182,8 +182,6 @@ public:
manager::PlacefileManager::Instance()}; manager::PlacefileManager::Instance()};
std::shared_ptr<manager::RadarProductManager> radarProductManager_; std::shared_ptr<manager::RadarProductManager> radarProductManager_;
std::shared_ptr<common::ColorTable> colorTable_;
std::shared_ptr<RadarProductLayer> radarProductLayer_; std::shared_ptr<RadarProductLayer> radarProductLayer_;
std::shared_ptr<AlertLayer> alertLayer_; std::shared_ptr<AlertLayer> alertLayer_;
std::shared_ptr<OverlayLayer> overlayLayer_; std::shared_ptr<OverlayLayer> overlayLayer_;
@ -1377,7 +1375,7 @@ void MapWidgetImpl::RadarProductViewConnect()
{ {
connect( connect(
radarProductView.get(), radarProductView.get(),
&view::RadarProductView::ColorTableUpdated, &view::RadarProductView::ColorTableLutUpdated,
this, this,
[this]() { widget_->update(); }, [this]() { widget_->update(); },
Qt::QueuedConnection); Qt::QueuedConnection);
@ -1412,7 +1410,7 @@ void MapWidgetImpl::RadarProductViewDisconnect()
if (radarProductView != nullptr) if (radarProductView != nullptr)
{ {
disconnect(radarProductView.get(), disconnect(radarProductView.get(),
&view::RadarProductView::ColorTableUpdated, &view::RadarProductView::ColorTableLutUpdated,
this, this,
nullptr); nullptr);
disconnect(radarProductView.get(), disconnect(radarProductView.get(),

View file

@ -77,7 +77,7 @@ RadarProductLayer::RadarProductLayer(std::shared_ptr<MapContext> context) :
{ {
auto radarProductView = context->radar_product_view(); auto radarProductView = context->radar_product_view();
connect(radarProductView.get(), connect(radarProductView.get(),
&view::RadarProductView::ColorTableUpdated, &view::RadarProductView::ColorTableLutUpdated,
this, this,
[this]() { p->colorTableNeedsUpdate_ = true; }); [this]() { p->colorTableNeedsUpdate_ = true; });
connect(radarProductView.get(), connect(radarProductView.get(),
@ -334,7 +334,7 @@ void RadarProductLayer::UpdateColorTable()
context()->radar_product_view(); context()->radar_product_view();
const std::vector<boost::gil::rgba8_pixel_t>& colorTable = const std::vector<boost::gil::rgba8_pixel_t>& colorTable =
radarProductView->color_table(); radarProductView->color_table_lut();
const uint16_t rangeMin = radarProductView->color_table_min(); const uint16_t rangeMin = radarProductView->color_table_min();
const uint16_t rangeMax = radarProductView->color_table_max(); const uint16_t rangeMax = radarProductView->color_table_max();

View file

@ -164,11 +164,11 @@ boost::asio::thread_pool& Level2ProductView::thread_pool()
} }
const std::vector<boost::gil::rgba8_pixel_t>& const std::vector<boost::gil::rgba8_pixel_t>&
Level2ProductView::color_table() const Level2ProductView::color_table_lut() const
{ {
if (p->colorTableLut_.size() == 0) if (p->colorTableLut_.size() == 0)
{ {
return RadarProductView::color_table(); return RadarProductView::color_table_lut();
} }
else else
{ {
@ -282,7 +282,7 @@ void Level2ProductView::LoadColorTable(
std::shared_ptr<common::ColorTable> colorTable) std::shared_ptr<common::ColorTable> colorTable)
{ {
p->colorTable_ = colorTable; p->colorTable_ = colorTable;
UpdateColorTable(); UpdateColorTableLut();
} }
void Level2ProductView::SelectElevation(float elevation) void Level2ProductView::SelectElevation(float elevation)
@ -317,7 +317,7 @@ void Level2ProductViewImpl::SetProduct(common::Level2Product product)
} }
} }
void Level2ProductView::UpdateColorTable() void Level2ProductView::UpdateColorTableLut()
{ {
if (p->momentDataBlock0_ == nullptr || // if (p->momentDataBlock0_ == nullptr || //
p->colorTable_ == nullptr || // p->colorTable_ == nullptr || //
@ -398,7 +398,7 @@ void Level2ProductView::UpdateColorTable()
p->savedOffset_ = offset; p->savedOffset_ = offset;
p->savedScale_ = scale; p->savedScale_ = scale;
Q_EMIT ColorTableUpdated(); Q_EMIT ColorTableLutUpdated();
} }
void Level2ProductView::ComputeSweep() void Level2ProductView::ComputeSweep()
@ -702,7 +702,7 @@ void Level2ProductView::ComputeSweep()
timer.stop(); timer.stop();
logger_->debug("Vertices calculated in {}", timer.format(6, "%ws")); logger_->debug("Vertices calculated in {}", timer.format(6, "%ws"));
UpdateColorTable(); UpdateColorTableLut();
Q_EMIT SweepComputed(); Q_EMIT SweepComputed();
} }

View file

@ -27,7 +27,8 @@ public:
std::shared_ptr<manager::RadarProductManager> radarProductManager); std::shared_ptr<manager::RadarProductManager> radarProductManager);
~Level2ProductView(); ~Level2ProductView();
const std::vector<boost::gil::rgba8_pixel_t>& color_table() const override; const std::vector<boost::gil::rgba8_pixel_t>&
color_table_lut() const override;
std::uint16_t color_table_min() const override; std::uint16_t color_table_min() const override;
std::uint16_t color_table_max() const override; std::uint16_t color_table_max() const override;
float elevation() const override; float elevation() const override;
@ -63,7 +64,7 @@ protected:
void ConnectRadarProductManager() override; void ConnectRadarProductManager() override;
void DisconnectRadarProductManager() override; void DisconnectRadarProductManager() override;
void UpdateColorTable() override; void UpdateColorTableLut() override;
protected slots: protected slots:
void ComputeSweep() override; void ComputeSweep() override;

View file

@ -97,11 +97,11 @@ void Level3ProductView::DisconnectRadarProductManager()
} }
const std::vector<boost::gil::rgba8_pixel_t>& const std::vector<boost::gil::rgba8_pixel_t>&
Level3ProductView::color_table() const Level3ProductView::color_table_lut() const
{ {
if (p->colorTableLut_.size() == 0) if (p->colorTableLut_.size() == 0)
{ {
return RadarProductView::color_table(); return RadarProductView::color_table_lut();
} }
else else
{ {
@ -218,10 +218,10 @@ void Level3ProductView::LoadColorTable(
std::shared_ptr<common::ColorTable> colorTable) std::shared_ptr<common::ColorTable> colorTable)
{ {
p->colorTable_ = colorTable; p->colorTable_ = colorTable;
UpdateColorTable(); UpdateColorTableLut();
} }
void Level3ProductView::UpdateColorTable() void Level3ProductView::UpdateColorTableLut()
{ {
logger_->debug("UpdateColorTable()"); logger_->debug("UpdateColorTable()");
@ -346,7 +346,7 @@ void Level3ProductView::UpdateColorTable()
p->savedOffset_ = offset; p->savedOffset_ = offset;
p->savedScale_ = scale; p->savedScale_ = scale;
Q_EMIT ColorTableUpdated(); Q_EMIT ColorTableLutUpdated();
} }
} // namespace view } // namespace view

View file

@ -25,7 +25,8 @@ public:
std::shared_ptr<manager::RadarProductManager> radarProductManager); std::shared_ptr<manager::RadarProductManager> radarProductManager);
virtual ~Level3ProductView(); virtual ~Level3ProductView();
const std::vector<boost::gil::rgba8_pixel_t>& color_table() const override; const std::vector<boost::gil::rgba8_pixel_t>&
color_table_lut() const override;
std::uint16_t color_table_min() const override; std::uint16_t color_table_min() const override;
std::uint16_t color_table_max() const override; std::uint16_t color_table_max() const override;
@ -47,7 +48,7 @@ protected:
void ConnectRadarProductManager() override; void ConnectRadarProductManager() override;
void DisconnectRadarProductManager() override; void DisconnectRadarProductManager() override;
void UpdateColorTable() override; void UpdateColorTableLut() override;
private: private:
class Impl; class Impl;

View file

@ -423,7 +423,7 @@ void Level3RadialView::ComputeSweep()
timer.stop(); timer.stop();
logger_->debug("Vertices calculated in {}", timer.format(6, "%ws")); logger_->debug("Vertices calculated in {}", timer.format(6, "%ws"));
UpdateColorTable(); UpdateColorTableLut();
Q_EMIT SweepComputed(); Q_EMIT SweepComputed();
} }

View file

@ -347,7 +347,7 @@ void Level3RasterView::ComputeSweep()
timer.stop(); timer.stop();
logger_->debug("Vertices calculated in {}", timer.format(6, "%ws")); logger_->debug("Vertices calculated in {}", timer.format(6, "%ws"));
UpdateColorTable(); UpdateColorTableLut();
Q_EMIT SweepComputed(); Q_EMIT SweepComputed();
} }

View file

@ -51,7 +51,7 @@ RadarProductView::RadarProductView(
RadarProductView::~RadarProductView() = default; RadarProductView::~RadarProductView() = default;
const std::vector<boost::gil::rgba8_pixel_t>& const std::vector<boost::gil::rgba8_pixel_t>&
RadarProductView::color_table() const RadarProductView::color_table_lut() const
{ {
return kDefaultColorTable_; return kDefaultColorTable_;
} }

View file

@ -34,7 +34,8 @@ public:
std::shared_ptr<manager::RadarProductManager> radarProductManager); std::shared_ptr<manager::RadarProductManager> radarProductManager);
virtual ~RadarProductView(); virtual ~RadarProductView();
virtual const std::vector<boost::gil::rgba8_pixel_t>& color_table() const; virtual const std::vector<boost::gil::rgba8_pixel_t>&
color_table_lut() const;
virtual std::uint16_t color_table_min() const; virtual std::uint16_t color_table_min() const;
virtual std::uint16_t color_table_max() const; virtual std::uint16_t color_table_max() const;
virtual float elevation() const; virtual float elevation() const;
@ -84,13 +85,13 @@ protected:
virtual void ConnectRadarProductManager() = 0; virtual void ConnectRadarProductManager() = 0;
virtual void DisconnectRadarProductManager() = 0; virtual void DisconnectRadarProductManager() = 0;
virtual void UpdateColorTable() = 0; virtual void UpdateColorTableLut() = 0;
protected slots: protected slots:
virtual void ComputeSweep(); virtual void ComputeSweep();
signals: signals:
void ColorTableUpdated(); void ColorTableLutUpdated();
void SweepComputed(); void SweepComputed();
void SweepNotComputed(types::NoUpdateReason reason); void SweepNotComputed(types::NoUpdateReason reason);