mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:30:05 +00:00
Cleanup of level 2 product selection, removing flicker from updates
This commit is contained in:
parent
159b3d8412
commit
52771b41f0
5 changed files with 129 additions and 111 deletions
|
|
@ -83,6 +83,8 @@ public:
|
||||||
const std::string& before = {});
|
const std::string& before = {});
|
||||||
void AutoRefreshConnect();
|
void AutoRefreshConnect();
|
||||||
void AutoRefreshDisconnect();
|
void AutoRefreshDisconnect();
|
||||||
|
void RadarProductViewConnect();
|
||||||
|
void RadarProductViewDisconnect();
|
||||||
void SetRadarSite(const std::string& radarSite);
|
void SetRadarSite(const std::string& radarSite);
|
||||||
bool UpdateStoredMapParameters();
|
bool UpdateStoredMapParameters();
|
||||||
|
|
||||||
|
|
@ -132,8 +134,7 @@ MapWidget::MapWidget(const QMapboxGLSettings& settings) :
|
||||||
|
|
||||||
MapWidget::~MapWidget()
|
MapWidget::~MapWidget()
|
||||||
{
|
{
|
||||||
// Make sure we have a valid context so we
|
// Make sure we have a valid context so we can delete the QMapboxGL.
|
||||||
// can delete the QMapboxGL.
|
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,46 +251,31 @@ void MapWidget::SelectElevation(float elevation)
|
||||||
|
|
||||||
void MapWidget::SelectRadarProduct(common::Level2Product product)
|
void MapWidget::SelectRadarProduct(common::Level2Product product)
|
||||||
{
|
{
|
||||||
float currentElevation = 0.0f;
|
bool radarProductViewCreated = false;
|
||||||
|
|
||||||
std::shared_ptr<view::RadarProductView>& radarProductView =
|
std::shared_ptr<view::RadarProductView>& radarProductView =
|
||||||
p->context_->radarProductView_;
|
p->context_->radarProductView_;
|
||||||
|
|
||||||
if (p->context_->radarProductView_ != nullptr)
|
if (radarProductView == nullptr ||
|
||||||
|
radarProductView->GetRadarProductGroup() !=
|
||||||
|
common::RadarProductGroup::Level2 ||
|
||||||
|
p->selectedLevel2Product_ != product)
|
||||||
{
|
{
|
||||||
currentElevation = p->context_->radarProductView_->elevation();
|
p->RadarProductViewDisconnect();
|
||||||
}
|
|
||||||
|
|
||||||
radarProductView = view::RadarProductViewFactory::Create(
|
radarProductView = view::RadarProductViewFactory::Create(
|
||||||
product, currentElevation, p->radarProductManager_);
|
product, p->radarProductManager_);
|
||||||
|
|
||||||
|
p->RadarProductViewConnect();
|
||||||
|
|
||||||
|
radarProductViewCreated = true;
|
||||||
|
}
|
||||||
radarProductView->SelectTime(p->selectedTime_);
|
radarProductView->SelectTime(p->selectedTime_);
|
||||||
|
|
||||||
p->selectedLevel2Product_ = product;
|
p->selectedLevel2Product_ = product;
|
||||||
|
|
||||||
connect(
|
if (radarProductViewCreated)
|
||||||
radarProductView.get(),
|
|
||||||
&view::RadarProductView::ColorTableUpdated,
|
|
||||||
this,
|
|
||||||
[&]() { update(); },
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
connect(
|
|
||||||
radarProductView.get(),
|
|
||||||
&view::RadarProductView::SweepComputed,
|
|
||||||
this,
|
|
||||||
[&]()
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<config::RadarSite> radarSite =
|
|
||||||
p->radarProductManager_->radar_site();
|
|
||||||
|
|
||||||
RadarRangeLayer::Update(
|
|
||||||
p->map_,
|
|
||||||
radarProductView->range(),
|
|
||||||
{radarSite->latitude(), radarSite->longitude()});
|
|
||||||
update();
|
|
||||||
emit RadarSweepUpdated();
|
|
||||||
},
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
|
|
||||||
util::async(
|
util::async(
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
|
@ -310,8 +296,16 @@ void MapWidget::SelectRadarProduct(common::Level2Product product)
|
||||||
{
|
{
|
||||||
AddLayers();
|
AddLayers();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
radarProductView->Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->autoRefreshEnabled_)
|
||||||
|
{
|
||||||
p->radarProductManager_->EnableLevel2Refresh(true);
|
p->radarProductManager_->EnableLevel2Refresh(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::SelectRadarProduct(
|
void MapWidget::SelectRadarProduct(
|
||||||
|
|
@ -353,7 +347,7 @@ void MapWidget::SelectRadarProduct(
|
||||||
manager::RadarProductManager::Instance(radarId);
|
manager::RadarProductManager::Instance(radarId);
|
||||||
std::shared_ptr<view::RadarProductView> radarProductView =
|
std::shared_ptr<view::RadarProductView> radarProductView =
|
||||||
view::RadarProductViewFactory::Create(
|
view::RadarProductViewFactory::Create(
|
||||||
group, product, productCode, 0.0f, radarProductManager);
|
group, product, productCode, radarProductManager);
|
||||||
|
|
||||||
if (radarProductView == nullptr)
|
if (radarProductView == nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -361,34 +355,14 @@ void MapWidget::SelectRadarProduct(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->RadarProductViewDisconnect();
|
||||||
|
|
||||||
p->context_->radarProductView_ = radarProductView;
|
p->context_->radarProductView_ = radarProductView;
|
||||||
p->SetRadarSite(radarId);
|
p->SetRadarSite(radarId);
|
||||||
p->selectedTime_ = time;
|
p->selectedTime_ = time;
|
||||||
radarProductView->SelectTime(p->selectedTime_);
|
radarProductView->SelectTime(p->selectedTime_);
|
||||||
|
|
||||||
connect(
|
p->RadarProductViewConnect();
|
||||||
radarProductView.get(),
|
|
||||||
&view::RadarProductView::ColorTableUpdated,
|
|
||||||
this,
|
|
||||||
[&]() { update(); },
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
connect(
|
|
||||||
radarProductView.get(),
|
|
||||||
&view::RadarProductView::SweepComputed,
|
|
||||||
this,
|
|
||||||
[=]()
|
|
||||||
{
|
|
||||||
std::shared_ptr<config::RadarSite> radarSite =
|
|
||||||
p->radarProductManager_->radar_site();
|
|
||||||
|
|
||||||
RadarRangeLayer::Update(
|
|
||||||
p->map_,
|
|
||||||
radarProductView->range(),
|
|
||||||
{radarSite->latitude(), radarSite->longitude()});
|
|
||||||
update();
|
|
||||||
emit RadarSweepUpdated();
|
|
||||||
},
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
|
|
||||||
util::async(
|
util::async(
|
||||||
[=]()
|
[=]()
|
||||||
|
|
@ -448,6 +422,8 @@ void MapWidget::changeStyle()
|
||||||
|
|
||||||
void MapWidget::AddLayers()
|
void MapWidget::AddLayers()
|
||||||
{
|
{
|
||||||
|
logger_->debug("AddLayers()");
|
||||||
|
|
||||||
// Clear custom layers
|
// Clear custom layers
|
||||||
for (const std::string& id : p->layerList_)
|
for (const std::string& id : p->layerList_)
|
||||||
{
|
{
|
||||||
|
|
@ -594,6 +570,8 @@ void MapWidget::wheelEvent(QWheelEvent* ev)
|
||||||
|
|
||||||
void MapWidget::initializeGL()
|
void MapWidget::initializeGL()
|
||||||
{
|
{
|
||||||
|
logger_->debug("initializeGL()");
|
||||||
|
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
p->context_->gl_.initializeOpenGLFunctions();
|
p->context_->gl_.initializeOpenGLFunctions();
|
||||||
|
|
||||||
|
|
@ -652,6 +630,10 @@ void MapWidgetImpl::AutoRefreshConnect()
|
||||||
&manager::RadarProductManager::NewLevel2DataAvailable,
|
&manager::RadarProductManager::NewLevel2DataAvailable,
|
||||||
this,
|
this,
|
||||||
[&](std::chrono::system_clock::time_point latestTime)
|
[&](std::chrono::system_clock::time_point latestTime)
|
||||||
|
{
|
||||||
|
if (autoRefreshEnabled_ && context_->radarProductView_ != nullptr &&
|
||||||
|
context_->radarProductView_->GetRadarProductGroup() ==
|
||||||
|
common::RadarProductGroup::Level2)
|
||||||
{
|
{
|
||||||
// Create file request
|
// Create file request
|
||||||
std::shared_ptr<request::NexradFileRequest> request =
|
std::shared_ptr<request::NexradFileRequest> request =
|
||||||
|
|
@ -674,8 +656,10 @@ void MapWidgetImpl::AutoRefreshConnect()
|
||||||
|
|
||||||
// Load file
|
// Load file
|
||||||
util::async(
|
util::async(
|
||||||
[=]()
|
[=]() {
|
||||||
{ radarProductManager_->LoadLevel2Data(latestTime, request); });
|
radarProductManager_->LoadLevel2Data(latestTime, request);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
@ -692,6 +676,51 @@ void MapWidgetImpl::AutoRefreshDisconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapWidgetImpl::RadarProductViewConnect()
|
||||||
|
{
|
||||||
|
if (context_->radarProductView_ != nullptr)
|
||||||
|
{
|
||||||
|
connect(
|
||||||
|
context_->radarProductView_.get(),
|
||||||
|
&view::RadarProductView::ColorTableUpdated,
|
||||||
|
this,
|
||||||
|
[&]() { widget_->update(); },
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
connect(
|
||||||
|
context_->radarProductView_.get(),
|
||||||
|
&view::RadarProductView::SweepComputed,
|
||||||
|
this,
|
||||||
|
[&]()
|
||||||
|
{
|
||||||
|
std::shared_ptr<config::RadarSite> radarSite =
|
||||||
|
radarProductManager_->radar_site();
|
||||||
|
|
||||||
|
RadarRangeLayer::Update(
|
||||||
|
map_,
|
||||||
|
context_->radarProductView_->range(),
|
||||||
|
{radarSite->latitude(), radarSite->longitude()});
|
||||||
|
widget_->update();
|
||||||
|
emit widget_->RadarSweepUpdated();
|
||||||
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapWidgetImpl::RadarProductViewDisconnect()
|
||||||
|
{
|
||||||
|
if (context_->radarProductView_ != nullptr)
|
||||||
|
{
|
||||||
|
disconnect(context_->radarProductView_.get(),
|
||||||
|
&view::RadarProductView::ColorTableUpdated,
|
||||||
|
this,
|
||||||
|
nullptr);
|
||||||
|
disconnect(context_->radarProductView_.get(),
|
||||||
|
&view::RadarProductView::SweepComputed,
|
||||||
|
this,
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MapWidgetImpl::SetRadarSite(const std::string& radarSite)
|
void MapWidgetImpl::SetRadarSite(const std::string& radarSite)
|
||||||
{
|
{
|
||||||
// Check if radar site has changed
|
// Check if radar site has changed
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,10 @@ class Level2ProductViewImpl
|
||||||
public:
|
public:
|
||||||
explicit Level2ProductViewImpl(
|
explicit Level2ProductViewImpl(
|
||||||
common::Level2Product product,
|
common::Level2Product product,
|
||||||
float elevation,
|
|
||||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||||
product_ {product},
|
product_ {product},
|
||||||
radarProductManager_ {radarProductManager},
|
radarProductManager_ {radarProductManager},
|
||||||
selectedElevation_ {elevation},
|
selectedElevation_ {0.0f},
|
||||||
selectedTime_ {},
|
selectedTime_ {},
|
||||||
elevationScan_ {nullptr},
|
elevationScan_ {nullptr},
|
||||||
momentDataBlock0_ {nullptr},
|
momentDataBlock0_ {nullptr},
|
||||||
|
|
@ -117,10 +116,8 @@ public:
|
||||||
|
|
||||||
Level2ProductView::Level2ProductView(
|
Level2ProductView::Level2ProductView(
|
||||||
common::Level2Product product,
|
common::Level2Product product,
|
||||||
float elevation,
|
|
||||||
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
std::shared_ptr<manager::RadarProductManager> radarProductManager) :
|
||||||
p(std::make_unique<Level2ProductViewImpl>(
|
p(std::make_unique<Level2ProductViewImpl>(product, radarProductManager))
|
||||||
product, elevation, radarProductManager))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Level2ProductView::~Level2ProductView() = default;
|
Level2ProductView::~Level2ProductView() = default;
|
||||||
|
|
@ -642,11 +639,9 @@ void Level2ProductView::ComputeSweep()
|
||||||
|
|
||||||
std::shared_ptr<Level2ProductView> Level2ProductView::Create(
|
std::shared_ptr<Level2ProductView> Level2ProductView::Create(
|
||||||
common::Level2Product product,
|
common::Level2Product product,
|
||||||
float elevation,
|
|
||||||
std::shared_ptr<manager::RadarProductManager> radarProductManager)
|
std::shared_ptr<manager::RadarProductManager> radarProductManager)
|
||||||
{
|
{
|
||||||
return std::make_shared<Level2ProductView>(
|
return std::make_shared<Level2ProductView>(product, radarProductManager);
|
||||||
product, elevation, radarProductManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace view
|
} // namespace view
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ class Level2ProductView : public RadarProductView
|
||||||
public:
|
public:
|
||||||
explicit Level2ProductView(
|
explicit Level2ProductView(
|
||||||
common::Level2Product product,
|
common::Level2Product product,
|
||||||
float elevation,
|
|
||||||
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
||||||
~Level2ProductView();
|
~Level2ProductView();
|
||||||
|
|
||||||
|
|
@ -51,7 +50,6 @@ public:
|
||||||
|
|
||||||
static std::shared_ptr<Level2ProductView>
|
static std::shared_ptr<Level2ProductView>
|
||||||
Create(common::Level2Product product,
|
Create(common::Level2Product product,
|
||||||
float elevation,
|
|
||||||
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ std::shared_ptr<RadarProductView> RadarProductViewFactory::Create(
|
||||||
common::RadarProductGroup productGroup,
|
common::RadarProductGroup productGroup,
|
||||||
const std::string& productName,
|
const std::string& productName,
|
||||||
int16_t productCode,
|
int16_t productCode,
|
||||||
float elevation,
|
|
||||||
std::shared_ptr<manager::RadarProductManager> radarProductManager)
|
std::shared_ptr<manager::RadarProductManager> radarProductManager)
|
||||||
{
|
{
|
||||||
std::shared_ptr<RadarProductView> view = nullptr;
|
std::shared_ptr<RadarProductView> view = nullptr;
|
||||||
|
|
@ -50,7 +49,7 @@ std::shared_ptr<RadarProductView> RadarProductViewFactory::Create(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
view = Create(product, elevation, radarProductManager);
|
view = Create(product, radarProductManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (productGroup == common::RadarProductGroup::Level3)
|
else if (productGroup == common::RadarProductGroup::Level3)
|
||||||
|
|
@ -75,10 +74,9 @@ std::shared_ptr<RadarProductView> RadarProductViewFactory::Create(
|
||||||
|
|
||||||
std::shared_ptr<RadarProductView> RadarProductViewFactory::Create(
|
std::shared_ptr<RadarProductView> RadarProductViewFactory::Create(
|
||||||
common::Level2Product product,
|
common::Level2Product product,
|
||||||
float elevation,
|
|
||||||
std::shared_ptr<manager::RadarProductManager> radarProductManager)
|
std::shared_ptr<manager::RadarProductManager> radarProductManager)
|
||||||
{
|
{
|
||||||
return Level2ProductView::Create(product, elevation, radarProductManager);
|
return Level2ProductView::Create(product, radarProductManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace view
|
} // namespace view
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,9 @@ public:
|
||||||
Create(common::RadarProductGroup productGroup,
|
Create(common::RadarProductGroup productGroup,
|
||||||
const std::string& productName,
|
const std::string& productName,
|
||||||
int16_t productCode,
|
int16_t productCode,
|
||||||
float elevation,
|
|
||||||
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
||||||
static std::shared_ptr<RadarProductView>
|
static std::shared_ptr<RadarProductView>
|
||||||
Create(common::Level2Product product,
|
Create(common::Level2Product product,
|
||||||
float elevation,
|
|
||||||
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
std::shared_ptr<manager::RadarProductManager> radarProductManager);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue