mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:40:06 +00:00 
			
		
		
		
	Enable/disable auto update of radar data based on timeline selection
This commit is contained in:
		
							parent
							
								
									80f04be510
								
							
						
					
					
						commit
						4963add9cc
					
				
					 8 changed files with 129 additions and 39 deletions
				
			
		|  | @ -706,6 +706,20 @@ void MainWindowImpl::ConnectAnimationSignals() | |||
|            &manager::TimelineManager::AnimationStateUpdated, | ||||
|            animationDockWidget_, | ||||
|            &ui::AnimationDockWidget::UpdateAnimationState); | ||||
| 
 | ||||
|    connect(timelineManager_.get(), | ||||
|            &manager::TimelineManager::LiveStateUpdated, | ||||
|            animationDockWidget_, | ||||
|            &ui::AnimationDockWidget::UpdateLiveState); | ||||
|    connect(timelineManager_.get(), | ||||
|            &manager::TimelineManager::LiveStateUpdated, | ||||
|            [this](bool isLive) | ||||
|            { | ||||
|               for (auto map : maps_) | ||||
|               { | ||||
|                  map->SetAutoUpdate(isLive); | ||||
|               } | ||||
|            }); | ||||
| } | ||||
| 
 | ||||
| void MainWindowImpl::ConnectOtherSignals() | ||||
|  |  | |||
|  | @ -366,6 +366,7 @@ void TimelineManager::Impl::SelectTime( | |||
| 
 | ||||
|       logger_->debug("Time updated: Live"); | ||||
| 
 | ||||
|       emit self_->LiveStateUpdated(true); | ||||
|       emit self_->VolumeTimeUpdated(selectedTime); | ||||
|       emit self_->SelectedTimeUpdated(selectedTime); | ||||
| 
 | ||||
|  | @ -391,6 +392,9 @@ void TimelineManager::Impl::SelectTime( | |||
|          auto elementPtr = | ||||
|             util::GetBoundedElementPointer(volumeTimes, selectedTime); | ||||
| 
 | ||||
|          // The timeline is no longer live
 | ||||
|          emit self_->LiveStateUpdated(false); | ||||
| 
 | ||||
|          if (elementPtr != nullptr) | ||||
|          { | ||||
| 
 | ||||
|  | @ -469,6 +473,13 @@ void TimelineManager::Impl::Step(Direction direction) | |||
|                                                        adjustedTime_); | ||||
|          } | ||||
| 
 | ||||
|          if (it == volumeTimes.cend()) | ||||
|          { | ||||
|             // Should not get here, but protect against an error
 | ||||
|             logger_->error("No suitable volume time found"); | ||||
|             return; | ||||
|          } | ||||
| 
 | ||||
|          if (direction == Direction::Back) | ||||
|          { | ||||
|             // Only if we aren't at the beginning of the volume times set
 | ||||
|  | @ -481,6 +492,7 @@ void TimelineManager::Impl::Step(Direction direction) | |||
|                logger_->debug("Volume time updated: {}", | ||||
|                               scwx::util::TimeString(adjustedTime_)); | ||||
| 
 | ||||
|                emit self_->LiveStateUpdated(false); | ||||
|                emit self_->VolumeTimeUpdated(adjustedTime_); | ||||
|                emit self_->SelectedTimeUpdated(adjustedTime_); | ||||
|             } | ||||
|  | @ -497,6 +509,7 @@ void TimelineManager::Impl::Step(Direction direction) | |||
|                logger_->debug("Volume time updated: {}", | ||||
|                               scwx::util::TimeString(adjustedTime_)); | ||||
| 
 | ||||
|                emit self_->LiveStateUpdated(false); | ||||
|                emit self_->VolumeTimeUpdated(adjustedTime_); | ||||
|                emit self_->SelectedTimeUpdated(adjustedTime_); | ||||
|             } | ||||
|  |  | |||
|  | @ -44,6 +44,7 @@ signals: | |||
|    void VolumeTimeUpdated(std::chrono::system_clock::time_point dateTime); | ||||
| 
 | ||||
|    void AnimationStateUpdated(types::AnimationState state); | ||||
|    void LiveStateUpdated(bool isLive); | ||||
|    void ViewTypeUpdated(types::MapTime viewType); | ||||
| 
 | ||||
| private: | ||||
|  |  | |||
|  | @ -62,6 +62,7 @@ public: | |||
|        overlayLayer_ {nullptr}, | ||||
|        colorTableLayer_ {nullptr}, | ||||
|        autoRefreshEnabled_ {true}, | ||||
|        autoUpdateEnabled_ {true}, | ||||
|        selectedLevel2Product_ {common::Level2Product::Unknown}, | ||||
|        lastPos_(), | ||||
|        currentStyleIndex_ {0}, | ||||
|  | @ -146,6 +147,7 @@ public: | |||
|    std::shared_ptr<ColorTableLayer>   colorTableLayer_; | ||||
| 
 | ||||
|    bool autoRefreshEnabled_; | ||||
|    bool autoUpdateEnabled_; | ||||
| 
 | ||||
|    common::Level2Product selectedLevel2Product_; | ||||
| 
 | ||||
|  | @ -520,6 +522,11 @@ void MapWidget::SetAutoRefresh(bool enabled) | |||
|    } | ||||
| } | ||||
| 
 | ||||
| void MapWidget::SetAutoUpdate(bool enabled) | ||||
| { | ||||
|    p->autoUpdateEnabled_ = enabled; | ||||
| } | ||||
| 
 | ||||
| void MapWidget::SetMapLocation(double latitude, | ||||
|                                double longitude, | ||||
|                                bool   updateRadarSite) | ||||
|  | @ -869,7 +876,7 @@ void MapWidgetImpl::RadarProductManagerConnect() | |||
|                 const std::string&                    product, | ||||
|                 std::chrono::system_clock::time_point latestTime) | ||||
|          { | ||||
|             if (autoRefreshEnabled_ && | ||||
|             if (autoUpdateEnabled_ && | ||||
|                 context_->radar_product_group() == group && | ||||
|                 (group == common::RadarProductGroup::Level2 || | ||||
|                  context_->radar_product() == product)) | ||||
|  |  | |||
|  | @ -89,6 +89,7 @@ public: | |||
| 
 | ||||
|    void SetActive(bool isActive); | ||||
|    void SetAutoRefresh(bool enabled); | ||||
|    void SetAutoUpdate(bool enabled); | ||||
| 
 | ||||
|    /**
 | ||||
|     * @brief Sets the current map location. | ||||
|  |  | |||
|  | @ -198,6 +198,22 @@ void AnimationDockWidget::UpdateAnimationState(types::AnimationState state) | |||
|    } | ||||
| } | ||||
| 
 | ||||
| void AnimationDockWidget::UpdateLiveState(bool isLive) | ||||
| { | ||||
|    static const QString prefix   = tr("Auto Update"); | ||||
|    static const QString disabled = tr("Disabled"); | ||||
|    static const QString enabled  = tr("Enabled"); | ||||
| 
 | ||||
|    if (isLive) | ||||
|    { | ||||
|       ui->autoUpdateLabel->setText(QString("%1: %2").arg(prefix).arg(enabled)); | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       ui->autoUpdateLabel->setText(QString("%1: %2").arg(prefix).arg(disabled)); | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| } // namespace ui
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
|  | @ -30,6 +30,7 @@ public: | |||
| 
 | ||||
| public slots: | ||||
|    void UpdateAnimationState(types::AnimationState state); | ||||
|    void UpdateLiveState(bool isLive); | ||||
| 
 | ||||
| signals: | ||||
|    void ViewTypeChanged(types::MapTime viewType); | ||||
|  |  | |||
|  | @ -21,6 +21,13 @@ | |||
|        <string>Timeline</string> | ||||
|       </property> | ||||
|       <layout class="QVBoxLayout" name="verticalLayout_6"> | ||||
|        <item> | ||||
|         <widget class="QLabel" name="autoUpdateLabel"> | ||||
|          <property name="text"> | ||||
|           <string>Auto Update: Enabled</string> | ||||
|          </property> | ||||
|         </widget> | ||||
|        </item> | ||||
|        <item> | ||||
|         <widget class="QRadioButton" name="liveViewRadioButton"> | ||||
|          <property name="text"> | ||||
|  | @ -103,46 +110,76 @@ | |||
|         </widget> | ||||
|        </item> | ||||
|        <item> | ||||
|         <widget class="QLabel" name="loopTimeLabel"> | ||||
|          <property name="text"> | ||||
|           <string>Loop Time (Minutes)</string> | ||||
|         <widget class="QFrame" name="frame_3"> | ||||
|          <property name="frameShape"> | ||||
|           <enum>QFrame::StyledPanel</enum> | ||||
|          </property> | ||||
|         </widget> | ||||
|        </item> | ||||
|        <item> | ||||
|         <widget class="QSpinBox" name="loopTimeSpinBox"> | ||||
|          <property name="correctionMode"> | ||||
|           <enum>QAbstractSpinBox::CorrectToNearestValue</enum> | ||||
|          </property> | ||||
|          <property name="minimum"> | ||||
|           <number>1</number> | ||||
|          </property> | ||||
|          <property name="maximum"> | ||||
|           <number>1440</number> | ||||
|          </property> | ||||
|          <property name="value"> | ||||
|           <number>30</number> | ||||
|          </property> | ||||
|         </widget> | ||||
|        </item> | ||||
|        <item> | ||||
|         <widget class="QLabel" name="loopSpeedLabel"> | ||||
|          <property name="text"> | ||||
|           <string>Loop Speed</string> | ||||
|          </property> | ||||
|         </widget> | ||||
|        </item> | ||||
|        <item> | ||||
|         <widget class="QDoubleSpinBox" name="loopSpeedSpinBox"> | ||||
|          <property name="correctionMode"> | ||||
|           <enum>QAbstractSpinBox::CorrectToNearestValue</enum> | ||||
|          </property> | ||||
|          <property name="minimum"> | ||||
|           <double>1.000000000000000</double> | ||||
|          </property> | ||||
|          <property name="value"> | ||||
|           <double>1.000000000000000</double> | ||||
|          <property name="frameShadow"> | ||||
|           <enum>QFrame::Raised</enum> | ||||
|          </property> | ||||
|          <layout class="QGridLayout" name="gridLayout"> | ||||
|           <property name="leftMargin"> | ||||
|            <number>0</number> | ||||
|           </property> | ||||
|           <property name="topMargin"> | ||||
|            <number>0</number> | ||||
|           </property> | ||||
|           <property name="rightMargin"> | ||||
|            <number>0</number> | ||||
|           </property> | ||||
|           <property name="bottomMargin"> | ||||
|            <number>0</number> | ||||
|           </property> | ||||
|           <item row="0" column="0"> | ||||
|            <widget class="QLabel" name="loopTimeLabel"> | ||||
|             <property name="text"> | ||||
|              <string>Loop Time</string> | ||||
|             </property> | ||||
|            </widget> | ||||
|           </item> | ||||
|           <item row="0" column="1"> | ||||
|            <widget class="QSpinBox" name="loopTimeSpinBox"> | ||||
|             <property name="correctionMode"> | ||||
|              <enum>QAbstractSpinBox::CorrectToNearestValue</enum> | ||||
|             </property> | ||||
|             <property name="suffix"> | ||||
|              <string> min</string> | ||||
|             </property> | ||||
|             <property name="minimum"> | ||||
|              <number>1</number> | ||||
|             </property> | ||||
|             <property name="maximum"> | ||||
|              <number>1440</number> | ||||
|             </property> | ||||
|             <property name="value"> | ||||
|              <number>30</number> | ||||
|             </property> | ||||
|            </widget> | ||||
|           </item> | ||||
|           <item row="1" column="0"> | ||||
|            <widget class="QLabel" name="loopSpeedLabel"> | ||||
|             <property name="text"> | ||||
|              <string>Loop Speed</string> | ||||
|             </property> | ||||
|            </widget> | ||||
|           </item> | ||||
|           <item row="1" column="1"> | ||||
|            <widget class="QDoubleSpinBox" name="loopSpeedSpinBox"> | ||||
|             <property name="correctionMode"> | ||||
|              <enum>QAbstractSpinBox::CorrectToNearestValue</enum> | ||||
|             </property> | ||||
|             <property name="suffix"> | ||||
|              <string>x</string> | ||||
|             </property> | ||||
|             <property name="minimum"> | ||||
|              <double>1.000000000000000</double> | ||||
|             </property> | ||||
|             <property name="value"> | ||||
|              <double>1.000000000000000</double> | ||||
|             </property> | ||||
|            </widget> | ||||
|           </item> | ||||
|          </layout> | ||||
|         </widget> | ||||
|        </item> | ||||
|        <item> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat