diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index bd03dde8..50767c34 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -163,6 +163,7 @@ set(HDR_TYPES source/scwx/qt/types/alert_types.hpp source/scwx/qt/types/font_types.hpp source/scwx/qt/types/github_types.hpp source/scwx/qt/types/imgui_font.hpp + source/scwx/qt/types/layer_types.hpp source/scwx/qt/types/map_types.hpp source/scwx/qt/types/qt_types.hpp source/scwx/qt/types/radar_product_record.hpp @@ -171,6 +172,7 @@ set(HDR_TYPES source/scwx/qt/types/alert_types.hpp set(SRC_TYPES source/scwx/qt/types/alert_types.cpp source/scwx/qt/types/github_types.cpp source/scwx/qt/types/imgui_font.cpp + source/scwx/qt/types/layer_types.cpp source/scwx/qt/types/map_types.cpp source/scwx/qt/types/radar_product_record.cpp source/scwx/qt/types/text_event_key.cpp diff --git a/scwx-qt/source/scwx/qt/model/layer_model.cpp b/scwx-qt/source/scwx/qt/model/layer_model.cpp index 5514c655..9de658a6 100644 --- a/scwx-qt/source/scwx/qt/model/layer_model.cpp +++ b/scwx-qt/source/scwx/qt/model/layer_model.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/scwx-qt/source/scwx/qt/types/layer_types.cpp b/scwx-qt/source/scwx/qt/types/layer_types.cpp new file mode 100644 index 00000000..24cbd989 --- /dev/null +++ b/scwx-qt/source/scwx/qt/types/layer_types.cpp @@ -0,0 +1,77 @@ +#include + +#include + +#include + +namespace scwx +{ +namespace qt +{ +namespace types +{ + +static const std::unordered_map layerTypeName_ { + {LayerType::Map, "Map"}, + {LayerType::Radar, "Radar"}, + {LayerType::Alert, "Alert"}, + {LayerType::Placefile, "Placefile"}, + {LayerType::Information, "Information"}, + {LayerType::Unknown, "?"}}; + +static const std::unordered_map layerName_ { + {Layer::MapOverlay, "Map Overlay"}, + {Layer::ColorTable, "Color Table"}, + {Layer::MapSymbology, "Map Symbology"}, + {Layer::MapUnderlay, "Map Underlay"}, + {Layer::Unknown, "?"}}; + +LayerType GetLayerType(const std::string& name) +{ + auto result = + std::find_if(layerTypeName_.cbegin(), + layerTypeName_.cend(), + [&](const std::pair& pair) -> bool + { return boost::iequals(pair.second, name); }); + + if (result != layerTypeName_.cend()) + { + return result->first; + } + else + { + return LayerType::Unknown; + } +} + +std::string GetLayerTypeName(LayerType layerType) +{ + return layerTypeName_.at(layerType); +} + +Layer GetLayer(const std::string& name) +{ + auto result = + std::find_if(layerName_.cbegin(), + layerName_.cend(), + [&](const std::pair& pair) -> bool + { return boost::iequals(pair.second, name); }); + + if (result != layerName_.cend()) + { + return result->first; + } + else + { + return Layer::Unknown; + } +} + +std::string GetLayerName(Layer layer) +{ + return layerName_.at(layer); +} + +} // namespace types +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/types/layer_types.hpp b/scwx-qt/source/scwx/qt/types/layer_types.hpp new file mode 100644 index 00000000..1f771879 --- /dev/null +++ b/scwx-qt/source/scwx/qt/types/layer_types.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include + +namespace scwx +{ +namespace qt +{ +namespace types +{ + +enum class LayerType +{ + Map, + Radar, + Alert, + Placefile, + Information, + Unknown +}; + +enum class Layer +{ + MapOverlay, + ColorTable, + MapSymbology, + MapUnderlay, + Unknown +}; + +LayerType GetLayerType(const std::string& name); +std::string GetLayerTypeName(LayerType layerType); + +Layer GetLayer(const std::string& name); +std::string GetLayerName(Layer layer); + +} // namespace types +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/types/map_types.cpp b/scwx-qt/source/scwx/qt/types/map_types.cpp index 21202914..d3ea6bc0 100644 --- a/scwx-qt/source/scwx/qt/types/map_types.cpp +++ b/scwx-qt/source/scwx/qt/types/map_types.cpp @@ -2,8 +2,6 @@ #include -#include - namespace scwx { namespace qt @@ -11,70 +9,9 @@ namespace qt namespace types { -static const std::unordered_map layerTypeName_ { - {LayerType::Map, "Map"}, - {LayerType::Radar, "Radar"}, - {LayerType::Alert, "Alert"}, - {LayerType::Placefile, "Placefile"}, - {LayerType::Information, "Information"}, - {LayerType::Unknown, "?"}}; - -static const std::unordered_map layerName_ { - {Layer::MapOverlay, "Map Overlay"}, - {Layer::ColorTable, "Color Table"}, - {Layer::MapSymbology, "Map Symbology"}, - {Layer::MapUnderlay, "Map Underlay"}, - {Layer::Unknown, "?"}}; - static const std::unordered_map mapTimeName_ { {MapTime::Live, "Live"}, {MapTime::Archive, "Archive"}}; -LayerType GetLayerType(const std::string& name) -{ - auto result = - std::find_if(layerTypeName_.cbegin(), - layerTypeName_.cend(), - [&](const std::pair& pair) -> bool - { return boost::iequals(pair.second, name); }); - - if (result != layerTypeName_.cend()) - { - return result->first; - } - else - { - return LayerType::Unknown; - } -} - -std::string GetLayerTypeName(LayerType layerType) -{ - return layerTypeName_.at(layerType); -} - -Layer GetLayer(const std::string& name) -{ - auto result = - std::find_if(layerName_.cbegin(), - layerName_.cend(), - [&](const std::pair& pair) -> bool - { return boost::iequals(pair.second, name); }); - - if (result != layerName_.cend()) - { - return result->first; - } - else - { - return Layer::Unknown; - } -} - -std::string GetLayerName(Layer layer) -{ - return layerName_.at(layer); -} - std::string GetMapTimeName(MapTime mapTime) { return mapTimeName_.at(mapTime); diff --git a/scwx-qt/source/scwx/qt/types/map_types.hpp b/scwx-qt/source/scwx/qt/types/map_types.hpp index ca2ecf04..5853a188 100644 --- a/scwx-qt/source/scwx/qt/types/map_types.hpp +++ b/scwx-qt/source/scwx/qt/types/map_types.hpp @@ -9,25 +9,6 @@ namespace qt namespace types { -enum class LayerType -{ - Map, - Radar, - Alert, - Placefile, - Information, - Unknown -}; - -enum class Layer -{ - MapOverlay, - ColorTable, - MapSymbology, - MapUnderlay, - Unknown -}; - enum class AnimationState { Play, @@ -48,12 +29,6 @@ enum class NoUpdateReason InvalidData }; -LayerType GetLayerType(const std::string& name); -std::string GetLayerTypeName(LayerType layerType); - -Layer GetLayer(const std::string& name); -std::string GetLayerName(Layer layer); - std::string GetMapTimeName(MapTime mapTime); } // namespace types