mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-30 23:50:05 +00:00 
			
		
		
		
	Timeline step next
This commit is contained in:
		
							parent
							
								
									0ddd9d91ea
								
							
						
					
					
						commit
						5f97718469
					
				
					 1 changed files with 47 additions and 17 deletions
				
			
		|  | @ -19,6 +19,12 @@ namespace manager | ||||||
| static const std::string logPrefix_ = "scwx::qt::manager::timeline_manager"; | static const std::string logPrefix_ = "scwx::qt::manager::timeline_manager"; | ||||||
| static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||||
| 
 | 
 | ||||||
|  | enum class Direction | ||||||
|  | { | ||||||
|  |    Back, | ||||||
|  |    Next | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| class TimelineManager::Impl | class TimelineManager::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|  | @ -33,7 +39,7 @@ public: | ||||||
|    TimelineManager* self_; |    TimelineManager* self_; | ||||||
| 
 | 
 | ||||||
|    void SelectTime(std::chrono::system_clock::time_point selectedTime = {}); |    void SelectTime(std::chrono::system_clock::time_point selectedTime = {}); | ||||||
|    void StepBack(); |    void Step(Direction direction); | ||||||
| 
 | 
 | ||||||
|    std::string                           radarSite_ {"?"}; |    std::string                           radarSite_ {"?"}; | ||||||
|    std::string                           previousRadarSite_ {"?"}; |    std::string                           previousRadarSite_ {"?"}; | ||||||
|  | @ -131,7 +137,7 @@ void TimelineManager::AnimationStepBack() | ||||||
| { | { | ||||||
|    logger_->debug("AnimationStepBack"); |    logger_->debug("AnimationStepBack"); | ||||||
| 
 | 
 | ||||||
|    p->StepBack(); |    p->Step(Direction::Back); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void TimelineManager::AnimationPlay() | void TimelineManager::AnimationPlay() | ||||||
|  | @ -147,6 +153,8 @@ void TimelineManager::AnimationPause() | ||||||
| void TimelineManager::AnimationStepNext() | void TimelineManager::AnimationStepNext() | ||||||
| { | { | ||||||
|    logger_->debug("AnimationStepNext"); |    logger_->debug("AnimationStepNext"); | ||||||
|  | 
 | ||||||
|  |    p->Step(Direction::Next); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void TimelineManager::AnimationStepEnd() | void TimelineManager::AnimationStepEnd() | ||||||
|  | @ -226,10 +234,10 @@ void TimelineManager::Impl::SelectTime( | ||||||
|       }); |       }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void TimelineManager::Impl::StepBack() | void TimelineManager::Impl::Step(Direction direction) | ||||||
| { | { | ||||||
|    scwx::util::async( |    scwx::util::async( | ||||||
|       [this]() |       [=, this]() | ||||||
|       { |       { | ||||||
|          // Take a lock for time selection
 |          // Take a lock for time selection
 | ||||||
|          std::unique_lock lock {selectTimeMutex_}; |          std::unique_lock lock {selectTimeMutex_}; | ||||||
|  | @ -247,16 +255,18 @@ void TimelineManager::Impl::StepBack() | ||||||
|          auto volumeTimes = |          auto volumeTimes = | ||||||
|             radarProductManager->GetActiveVolumeTimes(queryTime); |             radarProductManager->GetActiveVolumeTimes(queryTime); | ||||||
| 
 | 
 | ||||||
|  |          if (volumeTimes.empty()) | ||||||
|  |          { | ||||||
|  |             logger_->debug("No products to step through"); | ||||||
|  |             return; | ||||||
|  |          } | ||||||
|  | 
 | ||||||
|          std::set<std::chrono::system_clock::time_point>::const_iterator it; |          std::set<std::chrono::system_clock::time_point>::const_iterator it; | ||||||
| 
 | 
 | ||||||
|          if (adjustedTime_ == std::chrono::system_clock::time_point {}) |          if (adjustedTime_ == std::chrono::system_clock::time_point {}) | ||||||
|          { |          { | ||||||
|             // If the adjusted time is live, get the last element in the set
 |             // If the adjusted time is live, get the last element in the set
 | ||||||
|             it = volumeTimes.cend(); |             it = std::prev(volumeTimes.cend()); | ||||||
|             if (!volumeTimes.empty()) |  | ||||||
|             { |  | ||||||
|                --it; |  | ||||||
|             } |  | ||||||
|          } |          } | ||||||
|          else |          else | ||||||
|          { |          { | ||||||
|  | @ -265,17 +275,37 @@ void TimelineManager::Impl::StepBack() | ||||||
|                                                        adjustedTime_); |                                                        adjustedTime_); | ||||||
|          } |          } | ||||||
| 
 | 
 | ||||||
|          // Only if we aren't at the beginning of the volume times set
 |          if (direction == Direction::Back) | ||||||
|          if (it != volumeTimes.cbegin()) |  | ||||||
|          { |          { | ||||||
|             // Select the previous time
 |             // Only if we aren't at the beginning of the volume times set
 | ||||||
|             adjustedTime_ = *(--it); |             if (it != volumeTimes.cbegin()) | ||||||
|             selectedTime_ = adjustedTime_; |             { | ||||||
|  |                // Select the previous time
 | ||||||
|  |                adjustedTime_ = *(--it); | ||||||
|  |                selectedTime_ = adjustedTime_; | ||||||
| 
 | 
 | ||||||
|             logger_->debug("Volume time updated: {}", |                logger_->debug("Volume time updated: {}", | ||||||
|                            scwx::util::TimeString(adjustedTime_)); |                               scwx::util::TimeString(adjustedTime_)); | ||||||
| 
 | 
 | ||||||
|             emit self_->VolumeTimeUpdated(adjustedTime_); |                emit self_->VolumeTimeUpdated(adjustedTime_); | ||||||
|  |                emit self_->SelectedTimeUpdated(adjustedTime_); | ||||||
|  |             } | ||||||
|  |          } | ||||||
|  |          else | ||||||
|  |          { | ||||||
|  |             // Only if we aren't at the end of the volume times set
 | ||||||
|  |             if (it != std::prev(volumeTimes.cend())) | ||||||
|  |             { | ||||||
|  |                // Select the next time
 | ||||||
|  |                adjustedTime_ = *(++it); | ||||||
|  |                selectedTime_ = adjustedTime_; | ||||||
|  | 
 | ||||||
|  |                logger_->debug("Volume time updated: {}", | ||||||
|  |                               scwx::util::TimeString(adjustedTime_)); | ||||||
|  | 
 | ||||||
|  |                emit self_->VolumeTimeUpdated(adjustedTime_); | ||||||
|  |                emit self_->SelectedTimeUpdated(adjustedTime_); | ||||||
|  |             } | ||||||
|          } |          } | ||||||
|       }); |       }); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat