mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:40:05 +00:00
Add radar site layer to layer model, and display on map
This commit is contained in:
parent
71c0ec4b69
commit
798dc479f0
4 changed files with 29 additions and 11 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
#include <scwx/qt/map/placefile_layer.hpp>
|
#include <scwx/qt/map/placefile_layer.hpp>
|
||||||
#include <scwx/qt/map/radar_product_layer.hpp>
|
#include <scwx/qt/map/radar_product_layer.hpp>
|
||||||
#include <scwx/qt/map/radar_range_layer.hpp>
|
#include <scwx/qt/map/radar_range_layer.hpp>
|
||||||
|
#include <scwx/qt/map/radar_site_layer.hpp>
|
||||||
#include <scwx/qt/model/imgui_context_model.hpp>
|
#include <scwx/qt/model/imgui_context_model.hpp>
|
||||||
#include <scwx/qt/model/layer_model.hpp>
|
#include <scwx/qt/model/layer_model.hpp>
|
||||||
#include <scwx/qt/settings/general_settings.hpp>
|
#include <scwx/qt/settings/general_settings.hpp>
|
||||||
|
|
@ -186,6 +187,7 @@ public:
|
||||||
std::shared_ptr<OverlayLayer> overlayLayer_;
|
std::shared_ptr<OverlayLayer> overlayLayer_;
|
||||||
std::shared_ptr<PlacefileLayer> placefileLayer_;
|
std::shared_ptr<PlacefileLayer> placefileLayer_;
|
||||||
std::shared_ptr<ColorTableLayer> colorTableLayer_;
|
std::shared_ptr<ColorTableLayer> colorTableLayer_;
|
||||||
|
std::shared_ptr<RadarSiteLayer> radarSiteLayer_ {nullptr};
|
||||||
|
|
||||||
std::list<std::shared_ptr<PlacefileLayer>> placefileLayers_ {};
|
std::list<std::shared_ptr<PlacefileLayer>> placefileLayers_ {};
|
||||||
|
|
||||||
|
|
@ -890,6 +892,12 @@ void MapWidgetImpl::AddLayer(types::LayerType type,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Create the radar site layer
|
||||||
|
case types::InformationLayer::RadarSite:
|
||||||
|
radarSiteLayer_ = std::make_shared<RadarSiteLayer>(context_);
|
||||||
|
AddLayer(layerName, radarSiteLayer_, before);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,10 @@ static const QString kMimeFormat {"application/x.scwx-layer-model"};
|
||||||
static const std::vector<types::LayerInfo> kDefaultLayers_ {
|
static const std::vector<types::LayerInfo> kDefaultLayers_ {
|
||||||
{types::LayerType::Information, types::InformationLayer::MapOverlay, false},
|
{types::LayerType::Information, types::InformationLayer::MapOverlay, false},
|
||||||
{types::LayerType::Information, types::InformationLayer::ColorTable, false},
|
{types::LayerType::Information, types::InformationLayer::ColorTable, false},
|
||||||
|
{types::LayerType::Information,
|
||||||
|
types::InformationLayer::RadarSite,
|
||||||
|
false,
|
||||||
|
{false, false, false, false}},
|
||||||
{types::LayerType::Data, types::DataLayer::RadarRange, true},
|
{types::LayerType::Data, types::DataLayer::RadarRange, true},
|
||||||
{types::LayerType::Alert, awips::Phenomenon::Tornado, true},
|
{types::LayerType::Alert, awips::Phenomenon::Tornado, true},
|
||||||
{types::LayerType::Alert, awips::Phenomenon::SnowSquall, true},
|
{types::LayerType::Alert, awips::Phenomenon::SnowSquall, true},
|
||||||
|
|
@ -53,6 +57,10 @@ static const std::vector<types::LayerInfo> kDefaultLayers_ {
|
||||||
static const std::vector<types::LayerInfo> kImmovableLayers_ {
|
static const std::vector<types::LayerInfo> kImmovableLayers_ {
|
||||||
{types::LayerType::Information, types::InformationLayer::MapOverlay, false},
|
{types::LayerType::Information, types::InformationLayer::MapOverlay, false},
|
||||||
{types::LayerType::Information, types::InformationLayer::ColorTable, false},
|
{types::LayerType::Information, types::InformationLayer::ColorTable, false},
|
||||||
|
{types::LayerType::Information,
|
||||||
|
types::InformationLayer::RadarSite,
|
||||||
|
false,
|
||||||
|
{false, false, false, false}},
|
||||||
{types::LayerType::Map, types::MapLayer::MapSymbology, false},
|
{types::LayerType::Map, types::MapLayer::MapSymbology, false},
|
||||||
{types::LayerType::Map, types::MapLayer::MapUnderlay, false},
|
{types::LayerType::Map, types::MapLayer::MapUnderlay, false},
|
||||||
};
|
};
|
||||||
|
|
@ -235,13 +243,13 @@ void LayerModel::Impl::ValidateLayerSettings(types::LayerVector& layers)
|
||||||
|
|
||||||
// Validate immovable layers
|
// Validate immovable layers
|
||||||
std::vector<types::LayerVector::iterator> immovableIterators {};
|
std::vector<types::LayerVector::iterator> immovableIterators {};
|
||||||
types::LayerVector::iterator colorTableIterator {};
|
types::LayerVector::iterator radarSiteIterator {};
|
||||||
types::LayerVector::iterator mapSymbologyIterator {};
|
types::LayerVector::iterator mapSymbologyIterator {};
|
||||||
types::LayerVector::iterator mapUnderlayIterator {};
|
types::LayerVector::iterator mapUnderlayIterator {};
|
||||||
for (auto& immovableLayer : kImmovableLayers_)
|
for (auto& immovableLayer : kImmovableLayers_)
|
||||||
{
|
{
|
||||||
// Set the default displayed state for a layer that is not found
|
// Set the default displayed state for a layer that is not found
|
||||||
std::array<bool, kMapCount_> displayed {true, true, true, true};
|
std::array<bool, kMapCount_> displayed = immovableLayer.displayed_;
|
||||||
|
|
||||||
// Find the immovable layer
|
// Find the immovable layer
|
||||||
auto it = std::find_if(layers.begin(),
|
auto it = std::find_if(layers.begin(),
|
||||||
|
|
@ -285,8 +293,8 @@ void LayerModel::Impl::ValidateLayerSettings(types::LayerVector& layers)
|
||||||
{
|
{
|
||||||
switch (std::get<types::InformationLayer>(it->description_))
|
switch (std::get<types::InformationLayer>(it->description_))
|
||||||
{
|
{
|
||||||
case types::InformationLayer::ColorTable:
|
case types::InformationLayer::RadarSite:
|
||||||
colorTableIterator = it;
|
radarSiteIterator = it;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -330,10 +338,10 @@ void LayerModel::Impl::ValidateLayerSettings(types::LayerVector& layers)
|
||||||
|
|
||||||
if (it == layers.end())
|
if (it == layers.end())
|
||||||
{
|
{
|
||||||
// If this is the first data layer, insert after the color table layer,
|
// If this is the first data layer, insert after the radar site layer,
|
||||||
// otherwise, insert after the previous data layer
|
// otherwise, insert after the previous data layer
|
||||||
types::LayerVector::iterator insertPosition =
|
types::LayerVector::iterator insertPosition =
|
||||||
dataIterators.empty() ? colorTableIterator + 1 :
|
dataIterators.empty() ? radarSiteIterator + 1 :
|
||||||
dataIterators.back() + 1;
|
dataIterators.back() + 1;
|
||||||
it =
|
it =
|
||||||
layers.insert(insertPosition, {types::LayerType::Data, dataLayer});
|
layers.insert(insertPosition, {types::LayerType::Data, dataLayer});
|
||||||
|
|
@ -398,7 +406,7 @@ void LayerModel::ResetLayers()
|
||||||
types::LayerVector newLayers {};
|
types::LayerVector newLayers {};
|
||||||
newLayers.assign(kDefaultLayers_.cbegin(), kDefaultLayers_.cend());
|
newLayers.assign(kDefaultLayers_.cbegin(), kDefaultLayers_.cend());
|
||||||
|
|
||||||
auto colorTableIterator = std::find_if(
|
auto radarSiteIterator = std::find_if(
|
||||||
newLayers.begin(),
|
newLayers.begin(),
|
||||||
newLayers.end(),
|
newLayers.end(),
|
||||||
[](const types::LayerInfo& layerInfo)
|
[](const types::LayerInfo& layerInfo)
|
||||||
|
|
@ -406,7 +414,7 @@ void LayerModel::ResetLayers()
|
||||||
return std::holds_alternative<types::InformationLayer>(
|
return std::holds_alternative<types::InformationLayer>(
|
||||||
layerInfo.description_) &&
|
layerInfo.description_) &&
|
||||||
std::get<types::InformationLayer>(layerInfo.description_) ==
|
std::get<types::InformationLayer>(layerInfo.description_) ==
|
||||||
types::InformationLayer::ColorTable;
|
types::InformationLayer::RadarSite;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add all existing placefile layers
|
// Add all existing placefile layers
|
||||||
|
|
@ -415,7 +423,7 @@ void LayerModel::ResetLayers()
|
||||||
if (it->type_ == types::LayerType::Placefile)
|
if (it->type_ == types::LayerType::Placefile)
|
||||||
{
|
{
|
||||||
newLayers.insert(
|
newLayers.insert(
|
||||||
colorTableIterator + 1,
|
radarSiteIterator + 1,
|
||||||
{it->type_, it->description_, it->movable_, it->displayed_});
|
{it->type_, it->description_, it->movable_, it->displayed_});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1007,7 +1015,7 @@ void LayerModel::Impl::HandlePlacefileUpdate(const std::string& name,
|
||||||
|
|
||||||
void LayerModel::Impl::AddPlacefile(const std::string& name)
|
void LayerModel::Impl::AddPlacefile(const std::string& name)
|
||||||
{
|
{
|
||||||
// Insert after color table
|
// Insert after radar site
|
||||||
auto insertPosition = std::find_if(
|
auto insertPosition = std::find_if(
|
||||||
layers_.begin(),
|
layers_.begin(),
|
||||||
layers_.end(),
|
layers_.end(),
|
||||||
|
|
@ -1016,7 +1024,7 @@ void LayerModel::Impl::AddPlacefile(const std::string& name)
|
||||||
return std::holds_alternative<types::InformationLayer>(
|
return std::holds_alternative<types::InformationLayer>(
|
||||||
layerInfo.description_) &&
|
layerInfo.description_) &&
|
||||||
std::get<types::InformationLayer>(layerInfo.description_) ==
|
std::get<types::InformationLayer>(layerInfo.description_) ==
|
||||||
types::InformationLayer::ColorTable;
|
types::InformationLayer::RadarSite;
|
||||||
});
|
});
|
||||||
if (insertPosition != layers_.end())
|
if (insertPosition != layers_.end())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ static const std::unordered_map<DataLayer, std::string> dataLayerName_ {
|
||||||
|
|
||||||
static const std::unordered_map<InformationLayer, std::string>
|
static const std::unordered_map<InformationLayer, std::string>
|
||||||
informationLayerName_ {{InformationLayer::MapOverlay, "Map Overlay"},
|
informationLayerName_ {{InformationLayer::MapOverlay, "Map Overlay"},
|
||||||
|
{InformationLayer::RadarSite, "Radar Site"},
|
||||||
{InformationLayer::ColorTable, "Color Table"},
|
{InformationLayer::ColorTable, "Color Table"},
|
||||||
{InformationLayer::Unknown, "?"}};
|
{InformationLayer::Unknown, "?"}};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ typedef scwx::util::
|
||||||
enum class InformationLayer
|
enum class InformationLayer
|
||||||
{
|
{
|
||||||
MapOverlay,
|
MapOverlay,
|
||||||
|
RadarSite,
|
||||||
ColorTable,
|
ColorTable,
|
||||||
Unknown
|
Unknown
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue