mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:30:05 +00:00
Add select Map Layers to View menu
This commit is contained in:
parent
54047b7645
commit
9e3b2916e1
6 changed files with 199 additions and 5 deletions
|
|
@ -12,6 +12,7 @@
|
||||||
#include <scwx/qt/manager/update_manager.hpp>
|
#include <scwx/qt/manager/update_manager.hpp>
|
||||||
#include <scwx/qt/map/map_provider.hpp>
|
#include <scwx/qt/map/map_provider.hpp>
|
||||||
#include <scwx/qt/map/map_widget.hpp>
|
#include <scwx/qt/map/map_widget.hpp>
|
||||||
|
#include <scwx/qt/model/layer_model.hpp>
|
||||||
#include <scwx/qt/model/radar_site_model.hpp>
|
#include <scwx/qt/model/radar_site_model.hpp>
|
||||||
#include <scwx/qt/settings/general_settings.hpp>
|
#include <scwx/qt/settings/general_settings.hpp>
|
||||||
#include <scwx/qt/settings/map_settings.hpp>
|
#include <scwx/qt/settings/map_settings.hpp>
|
||||||
|
|
@ -36,6 +37,8 @@
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
#include <scwx/util/time.hpp>
|
#include <scwx/util/time.hpp>
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include <boost/asio/post.hpp>
|
#include <boost/asio/post.hpp>
|
||||||
#include <boost/asio/thread_pool.hpp>
|
#include <boost/asio/thread_pool.hpp>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
@ -142,6 +145,7 @@ public:
|
||||||
void ConnectMapSignals();
|
void ConnectMapSignals();
|
||||||
void ConnectOtherSignals();
|
void ConnectOtherSignals();
|
||||||
void HandleFocusChange(QWidget* focused);
|
void HandleFocusChange(QWidget* focused);
|
||||||
|
void InitializeLayerDisplayActions();
|
||||||
void PopulateMapStyles();
|
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,
|
||||||
|
|
@ -197,11 +201,17 @@ public:
|
||||||
std::shared_ptr<manager::TimelineManager> timelineManager_;
|
std::shared_ptr<manager::TimelineManager> timelineManager_;
|
||||||
std::shared_ptr<manager::UpdateManager> updateManager_;
|
std::shared_ptr<manager::UpdateManager> updateManager_;
|
||||||
|
|
||||||
|
std::shared_ptr<model::LayerModel> layerModel_ {
|
||||||
|
model::LayerModel::Instance()};
|
||||||
std::shared_ptr<model::RadarSiteModel> radarSiteModel_ {
|
std::shared_ptr<model::RadarSiteModel> radarSiteModel_ {
|
||||||
model::RadarSiteModel::Instance()};
|
model::RadarSiteModel::Instance()};
|
||||||
std::map<std::string, std::shared_ptr<QAction>> radarSitePresetsActions_ {};
|
std::map<std::string, std::shared_ptr<QAction>> radarSitePresetsActions_ {};
|
||||||
QMenu* radarSitePresetsMenu_ {nullptr};
|
QMenu* radarSitePresetsMenu_ {nullptr};
|
||||||
|
|
||||||
|
std::set<std::tuple<types::LayerType, types::LayerDescription, QAction*>>
|
||||||
|
layerActions_ {};
|
||||||
|
bool layerActionsInitialized_ {false};
|
||||||
|
|
||||||
std::vector<map::MapWidget*> maps_;
|
std::vector<map::MapWidget*> maps_;
|
||||||
|
|
||||||
std::chrono::system_clock::time_point volumeTime_ {};
|
std::chrono::system_clock::time_point volumeTime_ {};
|
||||||
|
|
@ -221,6 +231,8 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
p->InitializeLayerDisplayActions();
|
||||||
|
|
||||||
// Assign the bottom left corner to the left dock widget
|
// Assign the bottom left corner to the left dock widget
|
||||||
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||||
|
|
||||||
|
|
@ -494,6 +506,26 @@ void MainWindow::on_actionExit_triggered()
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionColorTable_triggered(bool checked)
|
||||||
|
{
|
||||||
|
p->layerModel_->SetLayerDisplayed(types::LayerType::Information,
|
||||||
|
types::InformationLayer::ColorTable,
|
||||||
|
checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionRadarRange_triggered(bool checked)
|
||||||
|
{
|
||||||
|
p->layerModel_->SetLayerDisplayed(
|
||||||
|
types::LayerType::Data, types::DataLayer::RadarRange, checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionRadarSites_triggered(bool checked)
|
||||||
|
{
|
||||||
|
p->layerModel_->SetLayerDisplayed(types::LayerType::Information,
|
||||||
|
types::InformationLayer::RadarSite,
|
||||||
|
checked);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionPlacefileManager_triggered()
|
void MainWindow::on_actionPlacefileManager_triggered()
|
||||||
{
|
{
|
||||||
p->placefileDialog_->show();
|
p->placefileDialog_->show();
|
||||||
|
|
@ -989,6 +1021,39 @@ void MainWindowImpl::ConnectOtherSignals()
|
||||||
&MainWindow::ActiveMapMoved,
|
&MainWindow::ActiveMapMoved,
|
||||||
radarSiteDialog_,
|
radarSiteDialog_,
|
||||||
&ui::RadarSiteDialog::HandleMapUpdate);
|
&ui::RadarSiteDialog::HandleMapUpdate);
|
||||||
|
connect(layerModel_.get(),
|
||||||
|
&model::LayerModel::LayerDisplayChanged,
|
||||||
|
this,
|
||||||
|
[this](types::LayerInfo layer)
|
||||||
|
{
|
||||||
|
// Find matching layer action
|
||||||
|
auto it =
|
||||||
|
std::find_if(layerActions_.begin(),
|
||||||
|
layerActions_.end(),
|
||||||
|
[&](const auto& layerAction)
|
||||||
|
{
|
||||||
|
const auto& [type, description, action] =
|
||||||
|
layerAction;
|
||||||
|
return layer.type_ == type &&
|
||||||
|
layer.description_ == description;
|
||||||
|
});
|
||||||
|
|
||||||
|
// If matching layer action was found
|
||||||
|
if (it != layerActions_.end())
|
||||||
|
{
|
||||||
|
// Check the action if the layer is displayed on any map
|
||||||
|
bool anyDisplayed = std::find(layer.displayed_.begin(),
|
||||||
|
layer.displayed_.end(),
|
||||||
|
true) != layer.displayed_.end();
|
||||||
|
|
||||||
|
auto& action = std::get<2>(*it);
|
||||||
|
action->setChecked(anyDisplayed);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(layerModel_.get(),
|
||||||
|
&QAbstractItemModel::modelReset,
|
||||||
|
this,
|
||||||
|
[this]() { InitializeLayerDisplayActions(); });
|
||||||
connect(radarSiteDialog_,
|
connect(radarSiteDialog_,
|
||||||
&ui::RadarSiteDialog::accepted,
|
&ui::RadarSiteDialog::accepted,
|
||||||
this,
|
this,
|
||||||
|
|
@ -1046,6 +1111,36 @@ void MainWindowImpl::ConnectOtherSignals()
|
||||||
clockTimer_.start(1000);
|
clockTimer_.start(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindowImpl::InitializeLayerDisplayActions()
|
||||||
|
{
|
||||||
|
if (!layerActionsInitialized_)
|
||||||
|
{
|
||||||
|
layerActions_.emplace(types::LayerType::Information,
|
||||||
|
types::InformationLayer::ColorTable,
|
||||||
|
mainWindow_->ui->actionColorTable);
|
||||||
|
layerActions_.emplace(types::LayerType::Information,
|
||||||
|
types::InformationLayer::RadarSite,
|
||||||
|
mainWindow_->ui->actionRadarSites);
|
||||||
|
layerActions_.emplace(types::LayerType::Data,
|
||||||
|
types::DataLayer::RadarRange,
|
||||||
|
mainWindow_->ui->actionRadarRange);
|
||||||
|
layerActionsInitialized_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& layerAction : layerActions_)
|
||||||
|
{
|
||||||
|
auto& [type, description, action] = layerAction;
|
||||||
|
|
||||||
|
types::LayerInfo layer = layerModel_->GetLayerInfo(type, description);
|
||||||
|
|
||||||
|
bool anyDisplayed =
|
||||||
|
std::find(layer.displayed_.begin(), layer.displayed_.end(), true) !=
|
||||||
|
layer.displayed_.end();
|
||||||
|
|
||||||
|
action->setChecked(anyDisplayed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindowImpl::AddRadarSitePreset(const std::string& siteId)
|
void MainWindowImpl::AddRadarSitePreset(const std::string& siteId)
|
||||||
{
|
{
|
||||||
auto radarSite = config::RadarSite::Get(siteId);
|
auto radarSite = config::RadarSite::Get(siteId);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ private slots:
|
||||||
void on_actionOpenTextEvent_triggered();
|
void on_actionOpenTextEvent_triggered();
|
||||||
void on_actionSettings_triggered();
|
void on_actionSettings_triggered();
|
||||||
void on_actionExit_triggered();
|
void on_actionExit_triggered();
|
||||||
|
void on_actionColorTable_triggered(bool checked);
|
||||||
|
void on_actionRadarRange_triggered(bool checked);
|
||||||
|
void on_actionRadarSites_triggered(bool checked);
|
||||||
void on_actionPlacefileManager_triggered();
|
void on_actionPlacefileManager_triggered();
|
||||||
void on_actionLayerManager_triggered();
|
void on_actionLayerManager_triggered();
|
||||||
void on_actionImGuiDebug_triggered();
|
void on_actionImGuiDebug_triggered();
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,18 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&View</string>
|
<string>&View</string>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuMapLayers">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Map Layers</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionColorTable"/>
|
||||||
|
<addaction name="actionRadarSites"/>
|
||||||
|
<addaction name="actionRadarRange"/>
|
||||||
|
</widget>
|
||||||
<addaction name="actionRadarToolbox"/>
|
<addaction name="actionRadarToolbox"/>
|
||||||
<addaction name="actionAlerts"/>
|
<addaction name="actionAlerts"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="menuMapLayers"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuDebug">
|
<widget class="QMenu" name="menuDebug">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
@ -166,7 +176,7 @@
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0,0,0">
|
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0,0">
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="radarSiteValueLabel">
|
<widget class="QLabel" name="radarSiteValueLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
@ -447,6 +457,30 @@
|
||||||
<string>Dump &Layer List</string>
|
<string>Dump &Layer List</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionRadarRange">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Radar &Range</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionColorTable">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Color Table</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionRadarSites">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Radar &Sites</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../../scwx-qt.qrc"/>
|
<include location="../../../../scwx-qt.qrc"/>
|
||||||
|
|
|
||||||
|
|
@ -395,11 +395,63 @@ void LayerModel::Impl::WriteLayerSettings()
|
||||||
util::json::WriteJsonFile(layerSettingsPath_, layerJson);
|
util::json::WriteJsonFile(layerSettingsPath_, layerJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
types::LayerInfo
|
||||||
|
LayerModel::GetLayerInfo(types::LayerType type,
|
||||||
|
types::LayerDescription description) const
|
||||||
|
{
|
||||||
|
// Find the matching layer
|
||||||
|
auto it = std::find_if(p->layers_.begin(),
|
||||||
|
p->layers_.end(),
|
||||||
|
[&](const types::LayerInfo& layer) {
|
||||||
|
return layer.type_ == type &&
|
||||||
|
layer.description_ == description;
|
||||||
|
});
|
||||||
|
if (it != p->layers_.end())
|
||||||
|
{
|
||||||
|
// Return the layer info
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
types::LayerVector LayerModel::GetLayers() const
|
types::LayerVector LayerModel::GetLayers() const
|
||||||
{
|
{
|
||||||
return p->layers_;
|
return p->layers_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayerModel::SetLayerDisplayed(types::LayerType type,
|
||||||
|
types::LayerDescription description,
|
||||||
|
bool displayed)
|
||||||
|
{
|
||||||
|
// Find the matching layer
|
||||||
|
auto it = std::find_if(p->layers_.begin(),
|
||||||
|
p->layers_.end(),
|
||||||
|
[&](const types::LayerInfo& layer) {
|
||||||
|
return layer.type_ == type &&
|
||||||
|
layer.description_ == description;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (it != p->layers_.end())
|
||||||
|
{
|
||||||
|
// Find the row
|
||||||
|
const int row = std::distance(p->layers_.begin(), it);
|
||||||
|
QModelIndex topLeft =
|
||||||
|
createIndex(row, static_cast<int>(Column::DisplayMap1));
|
||||||
|
QModelIndex bottomRight =
|
||||||
|
createIndex(row, static_cast<int>(Column::DisplayMap4));
|
||||||
|
|
||||||
|
// Set the layer to displayed
|
||||||
|
for (std::size_t i = 0; i < kMapCount_; ++i)
|
||||||
|
{
|
||||||
|
it->displayed_[i] = displayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notify observers
|
||||||
|
Q_EMIT dataChanged(topLeft, bottomRight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LayerModel::ResetLayers()
|
void LayerModel::ResetLayers()
|
||||||
{
|
{
|
||||||
// Initialize a new layer vector from the default
|
// Initialize a new layer vector from the default
|
||||||
|
|
@ -751,6 +803,7 @@ bool LayerModel::setData(const QModelIndex& index,
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Q_EMIT dataChanged(index, index);
|
Q_EMIT dataChanged(index, index);
|
||||||
|
Q_EMIT LayerDisplayChanged(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace model
|
||||||
|
|
||||||
class LayerModel : public QAbstractTableModel
|
class LayerModel : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY_MOVE(LayerModel)
|
Q_DISABLE_COPY_MOVE(LayerModel)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -36,7 +37,12 @@ public:
|
||||||
explicit LayerModel(QObject* parent = nullptr);
|
explicit LayerModel(QObject* parent = nullptr);
|
||||||
~LayerModel();
|
~LayerModel();
|
||||||
|
|
||||||
|
types::LayerInfo GetLayerInfo(types::LayerType type,
|
||||||
|
types::LayerDescription description) const;
|
||||||
types::LayerVector GetLayers() const;
|
types::LayerVector GetLayers() const;
|
||||||
|
void SetLayerDisplayed(types::LayerType type,
|
||||||
|
types::LayerDescription description,
|
||||||
|
bool displayed);
|
||||||
|
|
||||||
void ResetLayers();
|
void ResetLayers();
|
||||||
|
|
||||||
|
|
@ -77,6 +83,9 @@ public:
|
||||||
|
|
||||||
static std::shared_ptr<LayerModel> Instance();
|
static std::shared_ptr<LayerModel> Instance();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void LayerDisplayChanged(types::LayerInfo layer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
std::unique_ptr<Impl> p;
|
std::unique_ptr<Impl> p;
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ public:
|
||||||
void UpdateMapDisplayColumns();
|
void UpdateMapDisplayColumns();
|
||||||
void UpdateMoveButtonsEnabled();
|
void UpdateMoveButtonsEnabled();
|
||||||
|
|
||||||
std::vector<int> GetSelectedRows();
|
std::vector<int> GetSelectedRows() const;
|
||||||
std::vector<std::vector<int>> GetContiguousRows();
|
std::vector<std::vector<int>> GetContiguousRows() const;
|
||||||
|
|
||||||
LayerDialog* self_;
|
LayerDialog* self_;
|
||||||
std::shared_ptr<model::LayerModel> layerModel_;
|
std::shared_ptr<model::LayerModel> layerModel_;
|
||||||
|
|
@ -247,7 +247,7 @@ void LayerDialogImpl::ConnectSignals()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> LayerDialogImpl::GetSelectedRows()
|
std::vector<int> LayerDialogImpl::GetSelectedRows() const
|
||||||
{
|
{
|
||||||
QModelIndexList selectedRows =
|
QModelIndexList selectedRows =
|
||||||
self_->ui->layerTreeView->selectionModel()->selectedRows();
|
self_->ui->layerTreeView->selectionModel()->selectedRows();
|
||||||
|
|
@ -260,7 +260,7 @@ std::vector<int> LayerDialogImpl::GetSelectedRows()
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::vector<int>> LayerDialogImpl::GetContiguousRows()
|
std::vector<std::vector<int>> LayerDialogImpl::GetContiguousRows() const
|
||||||
{
|
{
|
||||||
std::vector<std::vector<int>> contiguousRows {};
|
std::vector<std::vector<int>> contiguousRows {};
|
||||||
std::vector<int> currentContiguousRows {};
|
std::vector<int> currentContiguousRows {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue