mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:20:06 +00:00 
			
		
		
		
	Add unit enumerations for various product types
This commit is contained in:
		
							parent
							
								
									dccbf0d12f
								
							
						
					
					
						commit
						7a71b9e244
					
				
					 3 changed files with 161 additions and 2 deletions
				
			
		|  | @ -207,7 +207,8 @@ set(HDR_TYPES source/scwx/qt/types/alert_types.hpp | |||
|               source/scwx/qt/types/text_event_key.hpp | ||||
|               source/scwx/qt/types/text_types.hpp | ||||
|               source/scwx/qt/types/texture_types.hpp | ||||
|               source/scwx/qt/types/time_types.hpp) | ||||
|               source/scwx/qt/types/time_types.hpp | ||||
|               source/scwx/qt/types/unit_types.hpp) | ||||
| set(SRC_TYPES source/scwx/qt/types/alert_types.cpp | ||||
|               source/scwx/qt/types/github_types.cpp | ||||
|               source/scwx/qt/types/hotkey_types.cpp | ||||
|  | @ -222,7 +223,8 @@ set(SRC_TYPES source/scwx/qt/types/alert_types.cpp | |||
|               source/scwx/qt/types/text_event_key.cpp | ||||
|               source/scwx/qt/types/text_types.cpp | ||||
|               source/scwx/qt/types/texture_types.cpp | ||||
|               source/scwx/qt/types/time_types.cpp) | ||||
|               source/scwx/qt/types/time_types.cpp | ||||
|               source/scwx/qt/types/unit_types.cpp) | ||||
| set(HDR_UI source/scwx/qt/ui/about_dialog.hpp | ||||
|            source/scwx/qt/ui/alert_dialog.hpp | ||||
|            source/scwx/qt/ui/alert_dock_widget.hpp | ||||
|  |  | |||
							
								
								
									
										93
									
								
								scwx-qt/source/scwx/qt/types/unit_types.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								scwx-qt/source/scwx/qt/types/unit_types.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,93 @@ | |||
| #include <scwx/qt/types/unit_types.hpp> | ||||
| #include <scwx/util/enum.hpp> | ||||
| 
 | ||||
| #include <unordered_map> | ||||
| 
 | ||||
| #include <boost/algorithm/string.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace types | ||||
| { | ||||
| 
 | ||||
| static const std::unordered_map<AccumulationUnits, std::string> | ||||
|    accumulationUnitsAbbreviation_ {{AccumulationUnits::Inches, "in"}, | ||||
|                                    {AccumulationUnits::Millimeters, "mm"}, | ||||
|                                    {AccumulationUnits::User, "?"}, | ||||
|                                    {AccumulationUnits::Unknown, "?"}}; | ||||
| 
 | ||||
| static const std::unordered_map<AccumulationUnits, std::string> | ||||
|    accumulationUnitsName_ {{AccumulationUnits::Inches, "Inches"}, | ||||
|                            {AccumulationUnits::Millimeters, "Millimeters"}, | ||||
|                            {AccumulationUnits::User, "User-defined"}, | ||||
|                            {AccumulationUnits::Unknown, "?"}}; | ||||
| 
 | ||||
| static const std::unordered_map<EchoTopsUnits, std::string> | ||||
|    echoTopsUnitsAbbreviation_ {{EchoTopsUnits::Kilofeet, "kft"}, | ||||
|                                {EchoTopsUnits::Kilometers, "km"}, | ||||
|                                {EchoTopsUnits::User, "?"}, | ||||
|                                {EchoTopsUnits::Unknown, "?"}}; | ||||
| 
 | ||||
| static const std::unordered_map<EchoTopsUnits, std::string> echoTopsUnitsName_ { | ||||
|    {EchoTopsUnits::Kilofeet, "Kilofeet"}, | ||||
|    {EchoTopsUnits::Kilometers, "Kilometers"}, | ||||
|    {EchoTopsUnits::User, "User-defined"}, | ||||
|    {EchoTopsUnits::Unknown, "?"}}; | ||||
| 
 | ||||
| static const std::unordered_map<SpeedUnits, std::string> | ||||
|    speedUnitsAbbreviation_ {{SpeedUnits::KilometersPerHour, "km/h"}, | ||||
|                             {SpeedUnits::Knots, "kts"}, | ||||
|                             {SpeedUnits::MilesPerHour, "mph"}, | ||||
|                             {SpeedUnits::MetersPerSecond, "m/s"}, | ||||
|                             {SpeedUnits::User, "?"}, | ||||
|                             {SpeedUnits::Unknown, "?"}}; | ||||
| 
 | ||||
| static const std::unordered_map<SpeedUnits, std::string> speedUnitsName_ { | ||||
|    {SpeedUnits::KilometersPerHour, "Kilometers per hour"}, | ||||
|    {SpeedUnits::Knots, "Knots"}, | ||||
|    {SpeedUnits::MilesPerHour, "Miles per hour"}, | ||||
|    {SpeedUnits::MetersPerSecond, "Meters per second"}, | ||||
|    {SpeedUnits::User, "User-defined"}, | ||||
|    {SpeedUnits::Unknown, "?"}}; | ||||
| 
 | ||||
| SCWX_GET_ENUM(AccumulationUnits, | ||||
|               GetAccumulationUnitsFromName, | ||||
|               accumulationUnitsName_) | ||||
| SCWX_GET_ENUM(EchoTopsUnits, GetEchoTopsUnitsFromName, echoTopsUnitsName_) | ||||
| SCWX_GET_ENUM(SpeedUnits, GetSpeedUnitsFromName, speedUnitsName_) | ||||
| 
 | ||||
| const std::string& GetAccumulationUnitsAbbreviation(AccumulationUnits units) | ||||
| { | ||||
|    return accumulationUnitsAbbreviation_.at(units); | ||||
| } | ||||
| 
 | ||||
| const std::string& GetAccumulationUnitsName(AccumulationUnits units) | ||||
| { | ||||
|    return accumulationUnitsName_.at(units); | ||||
| } | ||||
| 
 | ||||
| const std::string& GetEchoTopsUnitsAbbreviation(EchoTopsUnits units) | ||||
| { | ||||
|    return echoTopsUnitsAbbreviation_.at(units); | ||||
| } | ||||
| 
 | ||||
| const std::string& GetEchoTopsUnitsName(EchoTopsUnits units) | ||||
| { | ||||
|    return echoTopsUnitsName_.at(units); | ||||
| } | ||||
| 
 | ||||
| const std::string& GetSpeedUnitsAbbreviation(SpeedUnits units) | ||||
| { | ||||
|    return speedUnitsAbbreviation_.at(units); | ||||
| } | ||||
| 
 | ||||
| const std::string& GetSpeedUnitsName(SpeedUnits units) | ||||
| { | ||||
|    return speedUnitsName_.at(units); | ||||
| } | ||||
| 
 | ||||
| } // namespace types
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
							
								
								
									
										64
									
								
								scwx-qt/source/scwx/qt/types/unit_types.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								scwx-qt/source/scwx/qt/types/unit_types.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,64 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <scwx/util/iterator.hpp> | ||||
| 
 | ||||
| #include <string> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace types | ||||
| { | ||||
| 
 | ||||
| enum class AccumulationUnits | ||||
| { | ||||
|    Inches, | ||||
|    Millimeters, | ||||
|    User, | ||||
|    Unknown | ||||
| }; | ||||
| typedef scwx::util::Iterator<AccumulationUnits, | ||||
|                              AccumulationUnits::Inches, | ||||
|                              AccumulationUnits::User> | ||||
|    AccumulationUnitsIterator; | ||||
| 
 | ||||
| enum class EchoTopsUnits | ||||
| { | ||||
|    Kilofeet, | ||||
|    Kilometers, | ||||
|    User, | ||||
|    Unknown | ||||
| }; | ||||
| typedef scwx::util:: | ||||
|    Iterator<EchoTopsUnits, EchoTopsUnits::Kilofeet, EchoTopsUnits::User> | ||||
|       EchoTopsUnitsIterator; | ||||
| 
 | ||||
| enum class SpeedUnits | ||||
| { | ||||
|    KilometersPerHour, | ||||
|    Knots, | ||||
|    MilesPerHour, | ||||
|    MetersPerSecond, | ||||
|    User, | ||||
|    Unknown | ||||
| }; | ||||
| typedef scwx::util:: | ||||
|    Iterator<SpeedUnits, SpeedUnits::KilometersPerHour, SpeedUnits::User> | ||||
|       SpeedUnitsIterator; | ||||
| 
 | ||||
| const std::string& GetAccumulationUnitsAbbreviation(AccumulationUnits units); | ||||
| const std::string& GetAccumulationUnitsName(AccumulationUnits units); | ||||
| AccumulationUnits  GetAccumulationUnitsFromName(const std::string& name); | ||||
| 
 | ||||
| const std::string& GetEchoTopsUnitsAbbreviation(EchoTopsUnits units); | ||||
| const std::string& GetEchoTopsUnitsName(EchoTopsUnits units); | ||||
| EchoTopsUnits      GetEchoTopsUnitsFromName(const std::string& name); | ||||
| 
 | ||||
| const std::string& GetSpeedUnitsAbbreviation(SpeedUnits units); | ||||
| const std::string& GetSpeedUnitsName(SpeedUnits units); | ||||
| SpeedUnits         GetSpeedUnitsFromName(const std::string& name); | ||||
| 
 | ||||
| } // namespace types
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat