mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:30:05 +00:00
Add map style combo box
This commit is contained in:
parent
1cd3228e22
commit
e5ffe16efb
4 changed files with 107 additions and 7 deletions
|
|
@ -75,12 +75,12 @@ public:
|
||||||
elevationButtonsChanged_ {false},
|
elevationButtonsChanged_ {false},
|
||||||
resizeElevationButtons_ {false}
|
resizeElevationButtons_ {false}
|
||||||
{
|
{
|
||||||
map::MapProvider mapProvider =
|
mapProvider_ =
|
||||||
map::GetMapProvider(manager::SettingsManager::general_settings()
|
map::GetMapProvider(manager::SettingsManager::general_settings()
|
||||||
.map_provider()
|
.map_provider()
|
||||||
.GetValue());
|
.GetValue());
|
||||||
const map::MapProviderInfo& mapProviderInfo =
|
const map::MapProviderInfo& mapProviderInfo =
|
||||||
map::GetMapProviderInfo(mapProvider);
|
map::GetMapProviderInfo(mapProvider_);
|
||||||
|
|
||||||
std::string appDataPath {
|
std::string appDataPath {
|
||||||
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
|
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
|
||||||
|
|
@ -98,7 +98,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string mapProviderApiKey = map::GetMapProviderApiKey(mapProvider);
|
std::string mapProviderApiKey = map::GetMapProviderApiKey(mapProvider_);
|
||||||
|
|
||||||
settings_.resetToTemplate(mapProviderInfo.settingsTemplate_);
|
settings_.resetToTemplate(mapProviderInfo.settingsTemplate_);
|
||||||
settings_.setApiKey(QString {mapProviderApiKey.c_str()});
|
settings_.setApiKey(QString {mapProviderApiKey.c_str()});
|
||||||
|
|
@ -112,6 +112,7 @@ public:
|
||||||
void ConnectMapSignals();
|
void ConnectMapSignals();
|
||||||
void ConnectOtherSignals();
|
void ConnectOtherSignals();
|
||||||
void HandleFocusChange(QWidget* focused);
|
void HandleFocusChange(QWidget* focused);
|
||||||
|
void PopulateMapStyles();
|
||||||
void SelectElevation(map::MapWidget* mapWidget, float elevation);
|
void SelectElevation(map::MapWidget* mapWidget, float elevation);
|
||||||
void SelectRadarProduct(map::MapWidget* mapWidget,
|
void SelectRadarProduct(map::MapWidget* mapWidget,
|
||||||
common::RadarProductGroup group,
|
common::RadarProductGroup group,
|
||||||
|
|
@ -120,6 +121,7 @@ public:
|
||||||
void SetActiveMap(map::MapWidget* mapWidget);
|
void SetActiveMap(map::MapWidget* mapWidget);
|
||||||
void UpdateAvailableLevel3Products();
|
void UpdateAvailableLevel3Products();
|
||||||
void UpdateElevationSelection(float elevation);
|
void UpdateElevationSelection(float elevation);
|
||||||
|
void UpdateMapStyle(const std::string& styleName);
|
||||||
void UpdateRadarProductSelection(common::RadarProductGroup group,
|
void UpdateRadarProductSelection(common::RadarProductGroup group,
|
||||||
const std::string& product);
|
const std::string& product);
|
||||||
void UpdateRadarProductSettings();
|
void UpdateRadarProductSettings();
|
||||||
|
|
@ -128,6 +130,7 @@ public:
|
||||||
|
|
||||||
MainWindow* mainWindow_;
|
MainWindow* mainWindow_;
|
||||||
QMapLibreGL::Settings settings_;
|
QMapLibreGL::Settings settings_;
|
||||||
|
map::MapProvider mapProvider_;
|
||||||
map::MapWidget* activeMap_;
|
map::MapWidget* activeMap_;
|
||||||
|
|
||||||
ui::Level2ProductsWidget* level2ProductsWidget_;
|
ui::Level2ProductsWidget* level2ProductsWidget_;
|
||||||
|
|
@ -252,6 +255,7 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->PopulateMapStyles();
|
||||||
p->ConnectMapSignals();
|
p->ConnectMapSignals();
|
||||||
p->ConnectOtherSignals();
|
p->ConnectOtherSignals();
|
||||||
p->HandleFocusChange(p->activeMap_);
|
p->HandleFocusChange(p->activeMap_);
|
||||||
|
|
@ -593,6 +597,11 @@ void MainWindowImpl::ConnectMapSignals()
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
|
connect(mapWidget,
|
||||||
|
&map::MapWidget::MapStyleChanged,
|
||||||
|
this,
|
||||||
|
&MainWindowImpl::UpdateMapStyle);
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
mapWidget,
|
mapWidget,
|
||||||
&map::MapWidget::RadarSweepUpdated,
|
&map::MapWidget::RadarSweepUpdated,
|
||||||
|
|
@ -631,6 +640,11 @@ void MainWindowImpl::ConnectOtherSignals()
|
||||||
&QApplication::focusChanged,
|
&QApplication::focusChanged,
|
||||||
mainWindow_,
|
mainWindow_,
|
||||||
[this](QWidget* /*old*/, QWidget* now) { HandleFocusChange(now); });
|
[this](QWidget* /*old*/, QWidget* now) { HandleFocusChange(now); });
|
||||||
|
connect(mainWindow_->ui->mapStyleComboBox,
|
||||||
|
&QComboBox::currentTextChanged,
|
||||||
|
mainWindow_,
|
||||||
|
[&](const QString& text)
|
||||||
|
{ activeMap_->SetMapStyle(text.toStdString()); });
|
||||||
connect(level2ProductsWidget_,
|
connect(level2ProductsWidget_,
|
||||||
&ui::Level2ProductsWidget::RadarProductSelected,
|
&ui::Level2ProductsWidget::RadarProductSelected,
|
||||||
mainWindow_,
|
mainWindow_,
|
||||||
|
|
@ -703,6 +717,7 @@ void MainWindowImpl::HandleFocusChange(QWidget* focused)
|
||||||
{
|
{
|
||||||
SetActiveMap(mapWidget);
|
SetActiveMap(mapWidget);
|
||||||
UpdateAvailableLevel3Products();
|
UpdateAvailableLevel3Products();
|
||||||
|
UpdateMapStyle(mapWidget->GetMapStyle());
|
||||||
UpdateRadarProductSelection(mapWidget->GetRadarProductGroup(),
|
UpdateRadarProductSelection(mapWidget->GetRadarProductGroup(),
|
||||||
mapWidget->GetRadarProductName());
|
mapWidget->GetRadarProductName());
|
||||||
UpdateRadarProductSettings();
|
UpdateRadarProductSettings();
|
||||||
|
|
@ -711,6 +726,16 @@ void MainWindowImpl::HandleFocusChange(QWidget* focused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindowImpl::PopulateMapStyles()
|
||||||
|
{
|
||||||
|
const auto& mapProviderInfo = map::GetMapProviderInfo(mapProvider_);
|
||||||
|
for (const auto& mapStyle : mapProviderInfo.mapStyles_)
|
||||||
|
{
|
||||||
|
mainWindow_->ui->mapStyleComboBox->addItem(
|
||||||
|
QString::fromStdString(mapStyle.name_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindowImpl::SelectElevation(map::MapWidget* mapWidget, float elevation)
|
void MainWindowImpl::SelectElevation(map::MapWidget* mapWidget, float elevation)
|
||||||
{
|
{
|
||||||
if (mapWidget == activeMap_)
|
if (mapWidget == activeMap_)
|
||||||
|
|
@ -774,6 +799,16 @@ void MainWindowImpl::UpdateMapParameters(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindowImpl::UpdateMapStyle(const std::string& styleName)
|
||||||
|
{
|
||||||
|
int index = mainWindow_->ui->mapStyleComboBox->findText(
|
||||||
|
QString::fromStdString(styleName));
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
mainWindow_->ui->mapStyleComboBox->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindowImpl::UpdateRadarProductSelection(
|
void MainWindowImpl::UpdateRadarProductSelection(
|
||||||
common::RadarProductGroup group, const std::string& product)
|
common::RadarProductGroup group, const std::string& product)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,25 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="mapSettingsGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Map Settings</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="mapStyleLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Map Style</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="mapStyleComboBox"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="radarProductGroupBox">
|
<widget class="QGroupBox" name="radarProductGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ public:
|
||||||
selectedTime_ {},
|
selectedTime_ {},
|
||||||
lastPos_(),
|
lastPos_(),
|
||||||
currentStyleIndex_ {0},
|
currentStyleIndex_ {0},
|
||||||
|
currentStyle_ {nullptr},
|
||||||
frameDraws_(0),
|
frameDraws_(0),
|
||||||
prevLatitude_ {0.0},
|
prevLatitude_ {0.0},
|
||||||
prevLongitude_ {0.0},
|
prevLongitude_ {0.0},
|
||||||
|
|
@ -148,8 +149,9 @@ public:
|
||||||
common::Level2Product selectedLevel2Product_;
|
common::Level2Product selectedLevel2Product_;
|
||||||
std::chrono::system_clock::time_point selectedTime_;
|
std::chrono::system_clock::time_point selectedTime_;
|
||||||
|
|
||||||
QPointF lastPos_;
|
QPointF lastPos_;
|
||||||
uint8_t currentStyleIndex_;
|
std::size_t currentStyleIndex_;
|
||||||
|
const MapStyle* currentStyle_;
|
||||||
|
|
||||||
uint64_t frameDraws_;
|
uint64_t frameDraws_;
|
||||||
|
|
||||||
|
|
@ -260,6 +262,18 @@ std::vector<std::string> MapWidget::GetLevel3Products()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string MapWidget::GetMapStyle() const
|
||||||
|
{
|
||||||
|
if (p->currentStyle_ != nullptr)
|
||||||
|
{
|
||||||
|
return p->currentStyle_->name_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
common::RadarProductGroup MapWidget::GetRadarProductGroup() const
|
common::RadarProductGroup MapWidget::GetRadarProductGroup() const
|
||||||
{
|
{
|
||||||
auto radarProductView = p->context_->radar_product_view();
|
auto radarProductView = p->context_->radar_product_view();
|
||||||
|
|
@ -530,6 +544,32 @@ void MapWidget::SetMapParameters(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapWidget::SetMapStyle(const std::string& styleName)
|
||||||
|
{
|
||||||
|
const auto& mapProviderInfo = GetMapProviderInfo(p->mapProvider_);
|
||||||
|
auto& styles = mapProviderInfo.mapStyles_;
|
||||||
|
|
||||||
|
for (size_t i = 0u; i < styles.size(); ++i)
|
||||||
|
{
|
||||||
|
if (styles[i].name_ == styleName)
|
||||||
|
{
|
||||||
|
p->currentStyleIndex_ = i;
|
||||||
|
p->currentStyle_ = &styles[i];
|
||||||
|
|
||||||
|
logger_->debug("Updating style: {}", styles[i].name_);
|
||||||
|
|
||||||
|
p->map_->setStyleUrl(styles[i].url_.c_str());
|
||||||
|
|
||||||
|
if (++p->currentStyleIndex_ == styles.size())
|
||||||
|
{
|
||||||
|
p->currentStyleIndex_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qreal MapWidget::pixelRatio()
|
qreal MapWidget::pixelRatio()
|
||||||
{
|
{
|
||||||
return devicePixelRatioF();
|
return devicePixelRatioF();
|
||||||
|
|
@ -540,6 +580,8 @@ void MapWidget::changeStyle()
|
||||||
const auto& mapProviderInfo = GetMapProviderInfo(p->mapProvider_);
|
const auto& mapProviderInfo = GetMapProviderInfo(p->mapProvider_);
|
||||||
auto& styles = mapProviderInfo.mapStyles_;
|
auto& styles = mapProviderInfo.mapStyles_;
|
||||||
|
|
||||||
|
p->currentStyle_ = &styles[p->currentStyleIndex_];
|
||||||
|
|
||||||
logger_->debug("Updating style: {}", styles[p->currentStyleIndex_].name_);
|
logger_->debug("Updating style: {}", styles[p->currentStyleIndex_].name_);
|
||||||
|
|
||||||
p->map_->setStyleUrl(styles[p->currentStyleIndex_].url_.c_str());
|
p->map_->setStyleUrl(styles[p->currentStyleIndex_].url_.c_str());
|
||||||
|
|
@ -548,6 +590,8 @@ void MapWidget::changeStyle()
|
||||||
{
|
{
|
||||||
p->currentStyleIndex_ = 0;
|
p->currentStyleIndex_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit MapStyleChanged(p->currentStyle_->name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::AddLayers()
|
void MapWidget::AddLayers()
|
||||||
|
|
@ -571,8 +615,7 @@ void MapWidget::AddLayers()
|
||||||
std::shared_ptr<config::RadarSite> radarSite =
|
std::shared_ptr<config::RadarSite> radarSite =
|
||||||
p->radarProductManager_->radar_site();
|
p->radarProductManager_->radar_site();
|
||||||
|
|
||||||
const auto& mapStyle =
|
const auto& mapStyle = *p->currentStyle_;
|
||||||
GetMapProviderInfo(p->mapProvider_).mapStyles_[p->currentStyleIndex_];
|
|
||||||
|
|
||||||
std::string before = "ferry";
|
std::string before = "ferry";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ public:
|
||||||
float GetElevation() const;
|
float GetElevation() const;
|
||||||
std::vector<float> GetElevationCuts() const;
|
std::vector<float> GetElevationCuts() const;
|
||||||
std::vector<std::string> GetLevel3Products();
|
std::vector<std::string> GetLevel3Products();
|
||||||
|
std::string GetMapStyle() const;
|
||||||
common::RadarProductGroup GetRadarProductGroup() const;
|
common::RadarProductGroup GetRadarProductGroup() const;
|
||||||
std::string GetRadarProductName() const;
|
std::string GetRadarProductName() const;
|
||||||
std::shared_ptr<config::RadarSite> GetRadarSite() const;
|
std::shared_ptr<config::RadarSite> GetRadarSite() const;
|
||||||
|
|
@ -98,6 +99,7 @@ public:
|
||||||
double zoom,
|
double zoom,
|
||||||
double bearing,
|
double bearing,
|
||||||
double pitch);
|
double pitch);
|
||||||
|
void SetMapStyle(const std::string& styleName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeStyle();
|
void changeStyle();
|
||||||
|
|
@ -129,6 +131,7 @@ signals:
|
||||||
double zoom,
|
double zoom,
|
||||||
double bearing,
|
double bearing,
|
||||||
double pitch);
|
double pitch);
|
||||||
|
void MapStyleChanged(const std::string& styleName);
|
||||||
void RadarSweepUpdated();
|
void RadarSweepUpdated();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue