mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:20:05 +00:00 
			
		
		
		
	Extracting Level 2 Settings Widget from MainWindow
This commit is contained in:
		
							parent
							
								
									0fc573a962
								
							
						
					
					
						commit
						e911882bb7
					
				
					 7 changed files with 299 additions and 143 deletions
				
			
		|  | @ -97,9 +97,11 @@ set(SRC_SETTINGS source/scwx/qt/settings/general_settings.cpp | ||||||
| set(HDR_TYPES source/scwx/qt/types/radar_product_record.hpp) | set(HDR_TYPES source/scwx/qt/types/radar_product_record.hpp) | ||||||
| set(SRC_TYPES source/scwx/qt/types/radar_product_record.cpp) | set(SRC_TYPES source/scwx/qt/types/radar_product_record.cpp) | ||||||
| set(HDR_UI source/scwx/qt/ui/flow_layout.hpp | set(HDR_UI source/scwx/qt/ui/flow_layout.hpp | ||||||
|            source/scwx/qt/ui/level2_products_widget.hpp) |            source/scwx/qt/ui/level2_products_widget.hpp | ||||||
|  |            source/scwx/qt/ui/level2_settings_widget.hpp) | ||||||
| set(SRC_UI source/scwx/qt/ui/flow_layout.cpp | set(SRC_UI source/scwx/qt/ui/flow_layout.cpp | ||||||
|            source/scwx/qt/ui/level2_products_widget.cpp) |            source/scwx/qt/ui/level2_products_widget.cpp | ||||||
|  |            source/scwx/qt/ui/level2_settings_widget.cpp) | ||||||
| set(HDR_UTIL source/scwx/qt/util/font.hpp | set(HDR_UTIL source/scwx/qt/util/font.hpp | ||||||
|              source/scwx/qt/util/font_buffer.hpp |              source/scwx/qt/util/font_buffer.hpp | ||||||
|              source/scwx/qt/util/json.hpp) |              source/scwx/qt/util/json.hpp) | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ | ||||||
| #include <scwx/qt/map/map_widget.hpp> | #include <scwx/qt/map/map_widget.hpp> | ||||||
| #include <scwx/qt/ui/flow_layout.hpp> | #include <scwx/qt/ui/flow_layout.hpp> | ||||||
| #include <scwx/qt/ui/level2_products_widget.hpp> | #include <scwx/qt/ui/level2_products_widget.hpp> | ||||||
|  | #include <scwx/qt/ui/level2_settings_widget.hpp> | ||||||
| #include <scwx/common/characters.hpp> | #include <scwx/common/characters.hpp> | ||||||
| #include <scwx/common/products.hpp> | #include <scwx/common/products.hpp> | ||||||
| #include <scwx/common/vcp.hpp> | #include <scwx/common/vcp.hpp> | ||||||
|  | @ -39,6 +40,7 @@ public: | ||||||
|        settings_ {}, |        settings_ {}, | ||||||
|        activeMap_ {nullptr}, |        activeMap_ {nullptr}, | ||||||
|        level2ProductsWidget_ {nullptr}, |        level2ProductsWidget_ {nullptr}, | ||||||
|  |        level2SettingsWidget_ {nullptr}, | ||||||
|        maps_ {}, |        maps_ {}, | ||||||
|        elevationCuts_ {}, |        elevationCuts_ {}, | ||||||
|        elevationButtonsChanged_ {false}, |        elevationButtonsChanged_ {false}, | ||||||
|  | @ -71,7 +73,6 @@ public: | ||||||
| 
 | 
 | ||||||
|    void ConfigureMapLayout(); |    void ConfigureMapLayout(); | ||||||
|    void HandleFocusChange(QWidget* focused); |    void HandleFocusChange(QWidget* focused); | ||||||
|    void NormalizeElevationButtons(); |  | ||||||
|    void SelectElevation(map::MapWidget* mapWidget, float elevation); |    void SelectElevation(map::MapWidget* mapWidget, float elevation); | ||||||
|    void SelectRadarProduct(map::MapWidget*           mapWidget, |    void SelectRadarProduct(map::MapWidget*           mapWidget, | ||||||
|                            common::RadarProductGroup group, |                            common::RadarProductGroup group, | ||||||
|  | @ -90,6 +91,7 @@ public: | ||||||
|    map::MapWidget*   activeMap_; |    map::MapWidget*   activeMap_; | ||||||
| 
 | 
 | ||||||
|    ui::Level2ProductsWidget* level2ProductsWidget_; |    ui::Level2ProductsWidget* level2ProductsWidget_; | ||||||
|  |    ui::Level2SettingsWidget* level2SettingsWidget_; | ||||||
| 
 | 
 | ||||||
|    std::vector<map::MapWidget*> maps_; |    std::vector<map::MapWidget*> maps_; | ||||||
|    std::vector<float>           elevationCuts_; |    std::vector<float>           elevationCuts_; | ||||||
|  | @ -125,11 +127,10 @@ MainWindow::MainWindow(QWidget* parent) : | ||||||
|    delete ui->level2ProductFrame; |    delete ui->level2ProductFrame; | ||||||
|    ui->level2ProductFrame = p->level2ProductsWidget_; |    ui->level2ProductFrame = p->level2ProductsWidget_; | ||||||
| 
 | 
 | ||||||
|    QLayout* elevationLayout = new ui::FlowLayout(); |    // Add Level 2 Settings
 | ||||||
|    ui->elevationGroupBox->setLayout(elevationLayout); |    p->level2SettingsWidget_ = new ui::Level2SettingsWidget(ui->settingsFrame); | ||||||
| 
 |    ui->settingsFrame->layout()->addWidget(p->level2SettingsWidget_); | ||||||
|    ui->settingsGroupBox->setVisible(false); |    p->level2SettingsWidget_->setVisible(false); | ||||||
|    ui->declutterCheckbox->setVisible(false); |  | ||||||
| 
 | 
 | ||||||
|    p->SelectRadarProduct( |    p->SelectRadarProduct( | ||||||
|       p->maps_.at(0), |       p->maps_.at(0), | ||||||
|  | @ -168,6 +169,11 @@ MainWindow::MainWindow(QWidget* parent) : | ||||||
|               p->SelectRadarProduct( |               p->SelectRadarProduct( | ||||||
|                  p->activeMap_, group, productName, productCode); |                  p->activeMap_, group, productName, productCode); | ||||||
|            }); |            }); | ||||||
|  |    connect(p->level2SettingsWidget_, | ||||||
|  |            &ui::Level2SettingsWidget::ElevationSelected, | ||||||
|  |            this, | ||||||
|  |            [&](float elevation) | ||||||
|  |            { p->SelectElevation(p->activeMap_, elevation); }); | ||||||
| 
 | 
 | ||||||
|    p->HandleFocusChange(p->activeMap_); |    p->HandleFocusChange(p->activeMap_); | ||||||
| } | } | ||||||
|  | @ -177,57 +183,13 @@ MainWindow::~MainWindow() | ||||||
|    delete ui; |    delete ui; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool MainWindow::event(QEvent* event) |  | ||||||
| { |  | ||||||
|    if (event->type() == QEvent::Type::Paint) |  | ||||||
|    { |  | ||||||
|       if (p->elevationButtonsChanged_) |  | ||||||
|       { |  | ||||||
|          p->elevationButtonsChanged_ = false; |  | ||||||
|       } |  | ||||||
|       else if (p->resizeElevationButtons_) |  | ||||||
|       { |  | ||||||
|          p->NormalizeElevationButtons(); |  | ||||||
|       } |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    return QMainWindow::event(event); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void MainWindow::showEvent(QShowEvent* event) | void MainWindow::showEvent(QShowEvent* event) | ||||||
| { | { | ||||||
|    QMainWindow::showEvent(event); |    QMainWindow::showEvent(event); | ||||||
| 
 | 
 | ||||||
|    p->NormalizeElevationButtons(); |  | ||||||
| 
 |  | ||||||
|    resizeDocks({ui->radarToolboxDock}, {150}, Qt::Horizontal); |    resizeDocks({ui->radarToolboxDock}, {150}, Qt::Horizontal); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainWindowImpl::NormalizeElevationButtons() |  | ||||||
| { |  | ||||||
|    // Set each elevation cut's tool button to the same size
 |  | ||||||
|    int elevationCutMaxWidth = 0; |  | ||||||
|    for (QToolButton* widget : |  | ||||||
|         mainWindow_->ui->elevationGroupBox->findChildren<QToolButton*>()) |  | ||||||
|    { |  | ||||||
|       if (widget->isVisible()) |  | ||||||
|       { |  | ||||||
|          elevationCutMaxWidth = std::max(elevationCutMaxWidth, widget->width()); |  | ||||||
|       } |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    if (elevationCutMaxWidth > 0) |  | ||||||
|    { |  | ||||||
|       for (QToolButton* widget : |  | ||||||
|            mainWindow_->ui->elevationGroupBox->findChildren<QToolButton*>()) |  | ||||||
|       { |  | ||||||
|          widget->setMinimumWidth(elevationCutMaxWidth); |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       resizeElevationButtons_ = false; |  | ||||||
|    } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void MainWindow::on_actionOpen_triggered() | void MainWindow::on_actionOpen_triggered() | ||||||
| { | { | ||||||
|    static const std::string nexradFilter = "NEXRAD Products (*)"; |    static const std::string nexradFilter = "NEXRAD Products (*)"; | ||||||
|  | @ -388,12 +350,12 @@ void MainWindowImpl::HandleFocusChange(QWidget* focused) | ||||||
| 
 | 
 | ||||||
| void MainWindowImpl::SelectElevation(map::MapWidget* mapWidget, float elevation) | void MainWindowImpl::SelectElevation(map::MapWidget* mapWidget, float elevation) | ||||||
| { | { | ||||||
|    mapWidget->SelectElevation(elevation); |  | ||||||
| 
 |  | ||||||
|    if (mapWidget == activeMap_) |    if (mapWidget == activeMap_) | ||||||
|    { |    { | ||||||
|       UpdateElevationSelection(elevation); |       UpdateElevationSelection(elevation); | ||||||
|    } |    } | ||||||
|  | 
 | ||||||
|  |    mapWidget->SelectElevation(elevation); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainWindowImpl::SelectRadarProduct(map::MapWidget*           mapWidget, | void MainWindowImpl::SelectRadarProduct(map::MapWidget*           mapWidget, | ||||||
|  | @ -401,7 +363,6 @@ void MainWindowImpl::SelectRadarProduct(map::MapWidget*           mapWidget, | ||||||
|                                         const std::string&        productName, |                                         const std::string&        productName, | ||||||
|                                         int16_t                   productCode) |                                         int16_t                   productCode) | ||||||
| { | { | ||||||
| 
 |  | ||||||
|    logger_->debug("Selecting radar product: {}, {}", |    logger_->debug("Selecting radar product: {}, {}", | ||||||
|                   common::GetRadarProductGroupName(group), |                   common::GetRadarProductGroupName(group), | ||||||
|                   productName); |                   productName); | ||||||
|  | @ -432,23 +393,7 @@ void MainWindowImpl::SetActiveMap(map::MapWidget* mapWidget) | ||||||
| 
 | 
 | ||||||
| void MainWindowImpl::UpdateElevationSelection(float elevation) | void MainWindowImpl::UpdateElevationSelection(float elevation) | ||||||
| { | { | ||||||
|    QString buttonText {QString::number(elevation, 'f', 1) + |    level2SettingsWidget_->UpdateElevationSelection(elevation); | ||||||
|                        common::Characters::DEGREE}; |  | ||||||
| 
 |  | ||||||
|    for (QToolButton* toolButton : |  | ||||||
|         mainWindow_->ui->elevationGroupBox->findChildren<QToolButton*>()) |  | ||||||
|    { |  | ||||||
|       if (toolButton->text() == buttonText) |  | ||||||
|       { |  | ||||||
|          toolButton->setCheckable(true); |  | ||||||
|          toolButton->setChecked(true); |  | ||||||
|       } |  | ||||||
|       else |  | ||||||
|       { |  | ||||||
|          toolButton->setChecked(false); |  | ||||||
|          toolButton->setCheckable(false); |  | ||||||
|       } |  | ||||||
|    } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainWindowImpl::UpdateMapParameters( | void MainWindowImpl::UpdateMapParameters( | ||||||
|  | @ -468,39 +413,15 @@ void MainWindowImpl::UpdateRadarProductSelection( | ||||||
| 
 | 
 | ||||||
| void MainWindowImpl::UpdateRadarProductSettings() | void MainWindowImpl::UpdateRadarProductSettings() | ||||||
| { | { | ||||||
|    float              currentElevation = activeMap_->GetElevation(); |    if (activeMap_->GetRadarProductGroup() == common::RadarProductGroup::Level2) | ||||||
|    std::vector<float> elevationCuts    = activeMap_->GetElevationCuts(); |  | ||||||
| 
 |  | ||||||
|    if (elevationCuts_ != elevationCuts) |  | ||||||
|    { |    { | ||||||
|       for (QToolButton* toolButton : |       level2SettingsWidget_->UpdateSettings(activeMap_); | ||||||
|            mainWindow_->ui->elevationGroupBox->findChildren<QToolButton*>()) |       level2SettingsWidget_->setVisible(true); | ||||||
|  |    } | ||||||
|  |    else | ||||||
|    { |    { | ||||||
|          delete toolButton; |       level2SettingsWidget_->setVisible(false); | ||||||
|    } |    } | ||||||
| 
 |  | ||||||
|       QLayout* layout = mainWindow_->ui->elevationGroupBox->layout(); |  | ||||||
| 
 |  | ||||||
|       // Create elevation cut tool buttons
 |  | ||||||
|       for (float elevationCut : elevationCuts) |  | ||||||
|       { |  | ||||||
|          QToolButton* toolButton = new QToolButton(); |  | ||||||
|          toolButton->setText(QString::number(elevationCut, 'f', 1) + |  | ||||||
|                              common::Characters::DEGREE); |  | ||||||
|          layout->addWidget(toolButton); |  | ||||||
| 
 |  | ||||||
|          connect(toolButton, |  | ||||||
|                  &QToolButton::clicked, |  | ||||||
|                  this, |  | ||||||
|                  [=]() { SelectElevation(activeMap_, elevationCut); }); |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       elevationCuts_           = elevationCuts; |  | ||||||
|       elevationButtonsChanged_ = true; |  | ||||||
|       resizeElevationButtons_  = true; |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    UpdateElevationSelection(currentElevation); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainWindowImpl::UpdateRadarSite() | void MainWindowImpl::UpdateRadarSite() | ||||||
|  |  | ||||||
|  | @ -26,7 +26,6 @@ public: | ||||||
|    MainWindow(QWidget* parent = nullptr); |    MainWindow(QWidget* parent = nullptr); | ||||||
|    ~MainWindow(); |    ~MainWindow(); | ||||||
| 
 | 
 | ||||||
|    bool event(QEvent* event) override; |  | ||||||
|    void showEvent(QShowEvent* event) override; |    void showEvent(QShowEvent* event) override; | ||||||
| 
 | 
 | ||||||
| private slots: | private slots: | ||||||
|  |  | ||||||
|  | @ -191,25 +191,20 @@ | ||||||
|       </widget> |       </widget> | ||||||
|      </item> |      </item> | ||||||
|      <item> |      <item> | ||||||
|       <widget class="QGroupBox" name="elevationGroupBox"> |       <widget class="QWidget" name="settingsFrame" native="true"> | ||||||
|        <property name="title"> |        <layout class="QVBoxLayout" name="verticalLayout_4"> | ||||||
|         <string>Elevation</string> |         <property name="leftMargin"> | ||||||
|  |          <number>0</number> | ||||||
|         </property> |         </property> | ||||||
|       </widget> |         <property name="topMargin"> | ||||||
|      </item> |          <number>0</number> | ||||||
|      <item> |  | ||||||
|       <widget class="QGroupBox" name="settingsGroupBox"> |  | ||||||
|        <property name="title"> |  | ||||||
|         <string>Settings</string> |  | ||||||
|         </property> |         </property> | ||||||
|        <layout class="QVBoxLayout" name="verticalLayout_3"> |         <property name="rightMargin"> | ||||||
|         <item> |          <number>0</number> | ||||||
|          <widget class="QCheckBox" name="declutterCheckbox"> |         </property> | ||||||
|           <property name="text"> |         <property name="bottomMargin"> | ||||||
|            <string>Declutter</string> |          <number>0</number> | ||||||
|         </property> |         </property> | ||||||
|          </widget> |  | ||||||
|         </item> |  | ||||||
|        </layout> |        </layout> | ||||||
|       </widget> |       </widget> | ||||||
|      </item> |      </item> | ||||||
|  |  | ||||||
							
								
								
									
										199
									
								
								scwx-qt/source/scwx/qt/ui/level2_settings_widget.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										199
									
								
								scwx-qt/source/scwx/qt/ui/level2_settings_widget.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,199 @@ | ||||||
|  | #include <scwx/qt/ui/level2_settings_widget.hpp> | ||||||
|  | #include <scwx/qt/ui/flow_layout.hpp> | ||||||
|  | #include <scwx/common/characters.hpp> | ||||||
|  | 
 | ||||||
|  | #include <execution> | ||||||
|  | 
 | ||||||
|  | #include <QCheckBox> | ||||||
|  | #include <QEvent> | ||||||
|  | #include <QGroupBox> | ||||||
|  | #include <QToolButton> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace qt | ||||||
|  | { | ||||||
|  | namespace ui | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | class Level2SettingsWidgetImpl : public QObject | ||||||
|  | { | ||||||
|  |    Q_OBJECT | ||||||
|  | 
 | ||||||
|  | public: | ||||||
|  |    explicit Level2SettingsWidgetImpl(Level2SettingsWidget* self) : | ||||||
|  |        self_ {self}, | ||||||
|  |        layout_ {new QVBoxLayout(self)}, | ||||||
|  |        elevationGroupBox_ {}, | ||||||
|  |        elevationButtons_ {}, | ||||||
|  |        elevationCuts_ {}, | ||||||
|  |        elevationButtonsChanged_ {false}, | ||||||
|  |        resizeElevationButtons_ {false}, | ||||||
|  |        settingsGroupBox_ {}, | ||||||
|  |        declutterCheckBox_ {} | ||||||
|  |    { | ||||||
|  |       layout_->setContentsMargins(0, 0, 0, 0); | ||||||
|  | 
 | ||||||
|  |       elevationGroupBox_       = new QGroupBox(tr("Elevation"), self); | ||||||
|  |       QLayout* elevationLayout = new ui::FlowLayout(elevationGroupBox_); | ||||||
|  |       layout_->addWidget(elevationGroupBox_); | ||||||
|  | 
 | ||||||
|  |       settingsGroupBox_       = new QGroupBox(tr("Settings"), self); | ||||||
|  |       QLayout* settingsLayout = new QVBoxLayout(settingsGroupBox_); | ||||||
|  |       layout_->addWidget(settingsGroupBox_); | ||||||
|  | 
 | ||||||
|  |       declutterCheckBox_ = new QCheckBox(tr("Declutter"), settingsGroupBox_); | ||||||
|  |       settingsLayout->addWidget(declutterCheckBox_); | ||||||
|  | 
 | ||||||
|  |       settingsGroupBox_->setVisible(false); | ||||||
|  |    } | ||||||
|  |    ~Level2SettingsWidgetImpl() = default; | ||||||
|  | 
 | ||||||
|  |    void NormalizeElevationButtons(); | ||||||
|  |    void SelectElevation(float elevation); | ||||||
|  |    void UpdateSettings(); | ||||||
|  | 
 | ||||||
|  |    Level2SettingsWidget* self_; | ||||||
|  |    QLayout*              layout_; | ||||||
|  | 
 | ||||||
|  |    QGroupBox*              elevationGroupBox_; | ||||||
|  |    std::list<QToolButton*> elevationButtons_; | ||||||
|  |    std::vector<float>      elevationCuts_; | ||||||
|  |    bool                    elevationButtonsChanged_; | ||||||
|  |    bool                    resizeElevationButtons_; | ||||||
|  | 
 | ||||||
|  |    QGroupBox* settingsGroupBox_; | ||||||
|  |    QCheckBox* declutterCheckBox_; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | Level2SettingsWidget::Level2SettingsWidget(QWidget* parent) : | ||||||
|  |     QWidget(parent), p {std::make_shared<Level2SettingsWidgetImpl>(this)} | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Level2SettingsWidget::~Level2SettingsWidget() {} | ||||||
|  | 
 | ||||||
|  | bool Level2SettingsWidget::event(QEvent* event) | ||||||
|  | { | ||||||
|  |    if (event->type() == QEvent::Type::Paint) | ||||||
|  |    { | ||||||
|  |       if (p->elevationButtonsChanged_) | ||||||
|  |       { | ||||||
|  |          p->elevationButtonsChanged_ = false; | ||||||
|  |       } | ||||||
|  |       else if (p->resizeElevationButtons_) | ||||||
|  |       { | ||||||
|  |          p->NormalizeElevationButtons(); | ||||||
|  |       } | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    return QWidget::event(event); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void Level2SettingsWidget::showEvent(QShowEvent* event) | ||||||
|  | { | ||||||
|  |    QWidget::showEvent(event); | ||||||
|  | 
 | ||||||
|  |    p->NormalizeElevationButtons(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void Level2SettingsWidgetImpl::NormalizeElevationButtons() | ||||||
|  | { | ||||||
|  |    // Set each elevation cut's tool button to the same size
 | ||||||
|  |    int elevationCutMaxWidth = 0; | ||||||
|  |    std::for_each(elevationButtons_.cbegin(), | ||||||
|  |                  elevationButtons_.cend(), | ||||||
|  |                  [&](auto& toolButton) | ||||||
|  |                  { | ||||||
|  |                     if (toolButton->isVisible()) | ||||||
|  |                     { | ||||||
|  |                        elevationCutMaxWidth = | ||||||
|  |                           std::max(elevationCutMaxWidth, toolButton->width()); | ||||||
|  |                     } | ||||||
|  |                  }); | ||||||
|  | 
 | ||||||
|  |    if (elevationCutMaxWidth > 0) | ||||||
|  |    { | ||||||
|  |       std::for_each(elevationButtons_.cbegin(), | ||||||
|  |                     elevationButtons_.cend(), | ||||||
|  |                     [&](auto& toolButton) | ||||||
|  |                     { toolButton->setMinimumWidth(elevationCutMaxWidth); }); | ||||||
|  | 
 | ||||||
|  |       resizeElevationButtons_ = false; | ||||||
|  |    } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void Level2SettingsWidgetImpl::SelectElevation(float elevation) | ||||||
|  | { | ||||||
|  |    self_->UpdateElevationSelection(elevation); | ||||||
|  | 
 | ||||||
|  |    emit self_->ElevationSelected(elevation); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void Level2SettingsWidget::UpdateElevationSelection(float elevation) | ||||||
|  | { | ||||||
|  |    QString buttonText {QString::number(elevation, 'f', 1) + | ||||||
|  |                        common::Characters::DEGREE}; | ||||||
|  | 
 | ||||||
|  |    std::for_each(std::execution::par_unseq, | ||||||
|  |                  p->elevationButtons_.cbegin(), | ||||||
|  |                  p->elevationButtons_.cend(), | ||||||
|  |                  [&](auto& toolButton) | ||||||
|  |                  { | ||||||
|  |                     if (toolButton->text() == buttonText) | ||||||
|  |                     { | ||||||
|  |                        toolButton->setCheckable(true); | ||||||
|  |                        toolButton->setChecked(true); | ||||||
|  |                     } | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                        toolButton->setChecked(false); | ||||||
|  |                        toolButton->setCheckable(false); | ||||||
|  |                     } | ||||||
|  |                  }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void Level2SettingsWidget::UpdateSettings(map::MapWidget* activeMap) | ||||||
|  | { | ||||||
|  |    float              currentElevation = activeMap->GetElevation(); | ||||||
|  |    std::vector<float> elevationCuts    = activeMap->GetElevationCuts(); | ||||||
|  | 
 | ||||||
|  |    if (p->elevationCuts_ != elevationCuts) | ||||||
|  |    { | ||||||
|  |       for (auto it = p->elevationButtons_.begin(); | ||||||
|  |            it != p->elevationButtons_.end();) | ||||||
|  |       { | ||||||
|  |          delete *it; | ||||||
|  |          it = p->elevationButtons_.erase(it); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       QLayout* layout = p->elevationGroupBox_->layout(); | ||||||
|  | 
 | ||||||
|  |       // Create elevation cut tool buttons
 | ||||||
|  |       for (float elevationCut : elevationCuts) | ||||||
|  |       { | ||||||
|  |          QToolButton* toolButton = new QToolButton(); | ||||||
|  |          toolButton->setText(QString::number(elevationCut, 'f', 1) + | ||||||
|  |                              common::Characters::DEGREE); | ||||||
|  |          layout->addWidget(toolButton); | ||||||
|  |          p->elevationButtons_.push_back(toolButton); | ||||||
|  | 
 | ||||||
|  |          connect(toolButton, | ||||||
|  |                  &QToolButton::clicked, | ||||||
|  |                  this, | ||||||
|  |                  [=]() { p->SelectElevation(elevationCut); }); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       p->elevationCuts_           = elevationCuts; | ||||||
|  |       p->elevationButtonsChanged_ = true; | ||||||
|  |       p->resizeElevationButtons_  = true; | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    UpdateElevationSelection(currentElevation); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } // namespace ui
 | ||||||
|  | } // namespace qt
 | ||||||
|  | } // namespace scwx
 | ||||||
|  | 
 | ||||||
|  | #include "level2_settings_widget.moc" | ||||||
							
								
								
									
										37
									
								
								scwx-qt/source/scwx/qt/ui/level2_settings_widget.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								scwx-qt/source/scwx/qt/ui/level2_settings_widget.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include <scwx/qt/map/map_widget.hpp> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace qt | ||||||
|  | { | ||||||
|  | namespace ui | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | class Level2SettingsWidgetImpl; | ||||||
|  | 
 | ||||||
|  | class Level2SettingsWidget : public QWidget | ||||||
|  | { | ||||||
|  |    Q_OBJECT | ||||||
|  | 
 | ||||||
|  | public: | ||||||
|  |    explicit Level2SettingsWidget(QWidget* parent = nullptr); | ||||||
|  |    ~Level2SettingsWidget(); | ||||||
|  | 
 | ||||||
|  |    bool event(QEvent* event) override; | ||||||
|  |    void showEvent(QShowEvent* event) override; | ||||||
|  | 
 | ||||||
|  |    void UpdateElevationSelection(float elevation); | ||||||
|  |    void UpdateSettings(map::MapWidget* activeMap); | ||||||
|  | 
 | ||||||
|  | signals: | ||||||
|  |    void ElevationSelected(float elevation); | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |    std::shared_ptr<Level2SettingsWidgetImpl> p; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | } // namespace ui
 | ||||||
|  | } // namespace qt
 | ||||||
|  | } // namespace scwx
 | ||||||
|  | @ -18,16 +18,6 @@ | ||||||
|         <source>Level 3</source> |         <source>Level 3</source> | ||||||
|         <translation type="unfinished"></translation> |         <translation type="unfinished"></translation> | ||||||
|     </message> |     </message> | ||||||
|     <message> |  | ||||||
|         <location filename="../source/scwx/qt/main/main_window.ui" line="203"/> |  | ||||||
|         <source>Settings</source> |  | ||||||
|         <translation type="unfinished"></translation> |  | ||||||
|     </message> |  | ||||||
|     <message> |  | ||||||
|         <location filename="../source/scwx/qt/main/main_window.ui" line="209"/> |  | ||||||
|         <source>Declutter</source> |  | ||||||
|         <translation type="unfinished"></translation> |  | ||||||
|     </message> |  | ||||||
|     <message> |     <message> | ||||||
|         <location filename="../source/scwx/qt/main/main_window.ui" line="129"/> |         <location filename="../source/scwx/qt/main/main_window.ui" line="129"/> | ||||||
|         <source>Radar Site</source> |         <source>Radar Site</source> | ||||||
|  | @ -74,27 +64,22 @@ | ||||||
|         <translation type="unfinished"></translation> |         <translation type="unfinished"></translation> | ||||||
|     </message> |     </message> | ||||||
|     <message> |     <message> | ||||||
|         <location filename="../source/scwx/qt/main/main_window.ui" line="196"/> |         <location filename="../source/scwx/qt/main/main_window.ui" line="229"/> | ||||||
|         <source>Elevation</source> |  | ||||||
|         <translation type="unfinished"></translation> |  | ||||||
|     </message> |  | ||||||
|     <message> |  | ||||||
|         <location filename="../source/scwx/qt/main/main_window.ui" line="234"/> |  | ||||||
|         <source>E&xit</source> |         <source>E&xit</source> | ||||||
|         <translation type="unfinished"></translation> |         <translation type="unfinished"></translation> | ||||||
|     </message> |     </message> | ||||||
|     <message> |     <message> | ||||||
|         <location filename="../source/scwx/qt/main/main_window.ui" line="239"/> |         <location filename="../source/scwx/qt/main/main_window.ui" line="234"/> | ||||||
|         <source>About &Supercell Wx...</source> |         <source>About &Supercell Wx...</source> | ||||||
|         <translation type="unfinished"></translation> |         <translation type="unfinished"></translation> | ||||||
|     </message> |     </message> | ||||||
|     <message> |     <message> | ||||||
|         <location filename="../source/scwx/qt/main/main_window.ui" line="244"/> |         <location filename="../source/scwx/qt/main/main_window.ui" line="239"/> | ||||||
|         <source>&Open...</source> |         <source>&Open...</source> | ||||||
|         <translation type="unfinished"></translation> |         <translation type="unfinished"></translation> | ||||||
|     </message> |     </message> | ||||||
|     <message> |     <message> | ||||||
|         <location filename="../source/scwx/qt/main/main_window.ui" line="247"/> |         <location filename="../source/scwx/qt/main/main_window.ui" line="242"/> | ||||||
|         <source>Ctrl+O</source> |         <source>Ctrl+O</source> | ||||||
|         <translation type="unfinished"></translation> |         <translation type="unfinished"></translation> | ||||||
|     </message> |     </message> | ||||||
|  | @ -102,9 +87,27 @@ | ||||||
| <context> | <context> | ||||||
|     <name>scwx::qt::main::MainWindow</name> |     <name>scwx::qt::main::MainWindow</name> | ||||||
|     <message> |     <message> | ||||||
|         <location filename="../source/scwx/qt/main/main_window.cpp" line="281"/> |         <location filename="../source/scwx/qt/main/main_window.cpp" line="243"/> | ||||||
|         <source>Unrecognized NEXRAD Product:</source> |         <source>Unrecognized NEXRAD Product:</source> | ||||||
|         <translation type="unfinished"></translation> |         <translation type="unfinished"></translation> | ||||||
|     </message> |     </message> | ||||||
| </context> | </context> | ||||||
|  | <context> | ||||||
|  |     <name>scwx::qt::ui::Level2SettingsWidgetImpl</name> | ||||||
|  |     <message> | ||||||
|  |         <location filename="../source/scwx/qt/ui/level2_settings_widget.cpp" line="37"/> | ||||||
|  |         <source>Elevation</source> | ||||||
|  |         <translation type="unfinished"></translation> | ||||||
|  |     </message> | ||||||
|  |     <message> | ||||||
|  |         <location filename="../source/scwx/qt/ui/level2_settings_widget.cpp" line="41"/> | ||||||
|  |         <source>Settings</source> | ||||||
|  |         <translation type="unfinished"></translation> | ||||||
|  |     </message> | ||||||
|  |     <message> | ||||||
|  |         <location filename="../source/scwx/qt/ui/level2_settings_widget.cpp" line="45"/> | ||||||
|  |         <source>Declutter</source> | ||||||
|  |         <translation type="unfinished"></translation> | ||||||
|  |     </message> | ||||||
|  | </context> | ||||||
| </TS> | </TS> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat