Skip to content

Commit

Permalink
Additional clang-tidy action cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaulat committed Dec 16, 2024
1 parent 57b773d commit a3eb53a
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 122 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Checks:
- 'misc-*'
- 'modernize-*'
- 'performance-*'
- '-cppcoreguidelines-pro-type-reinterpret-cast'
- '-misc-include-cleaner'
- '-misc-non-private-member-variables-in-classes'
- '-modernize-use-trailing-return-type'
Expand Down
4 changes: 2 additions & 2 deletions scwx-qt/source/scwx/qt/main/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,12 +1098,12 @@ void MainWindowImpl::ConnectOtherSignals()
mainWindow_,
[this](Qt::CheckState state)
{
bool smoothingEnabled = (state == Qt::CheckState::Checked);
const bool smoothingEnabled = (state == Qt::CheckState::Checked);

auto it = std::find(maps_.cbegin(), maps_.cend(), activeMap_);
if (it != maps_.cend())
{
std::size_t i = std::distance(maps_.cbegin(), it);
const std::size_t i = std::distance(maps_.cbegin(), it);
settings::MapSettings::Instance().smoothing_enabled(i).StageValue(
smoothingEnabled);
}
Expand Down
12 changes: 6 additions & 6 deletions scwx-qt/source/scwx/qt/manager/radar_product_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class RadarProductManager : public QObject
*/
static void DumpRecords();

const std::vector<float>& coordinates(common::RadialSize radialSize,
bool smoothingEnabled) const;
const scwx::util::time_zone* default_time_zone() const;
float gate_size() const;
std::string radar_id() const;
std::shared_ptr<config::RadarSite> radar_site() const;
[[nodiscard]] const std::vector<float>&
coordinates(common::RadialSize radialSize, bool smoothingEnabled) const;
[[nodiscard]] const scwx::util::time_zone* default_time_zone() const;
[[nodiscard]] float gate_size() const;
[[nodiscard]] std::string radar_id() const;
[[nodiscard]] std::shared_ptr<config::RadarSite> radar_site() const;

void Initialize();

Expand Down
4 changes: 2 additions & 2 deletions scwx-qt/source/scwx/qt/map/map_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace map

struct MapSettings
{
explicit MapSettings() {}
~MapSettings() = default;
explicit MapSettings() = default;
~MapSettings() = default;

MapSettings(const MapSettings&) = delete;
MapSettings& operator=(const MapSettings&) = delete;
Expand Down
25 changes: 13 additions & 12 deletions scwx-qt/source/scwx/qt/map/map_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,19 @@ class MapWidget : public QOpenGLWidget

void DumpLayerList() const;

common::Level3ProductCategoryMap GetAvailableLevel3Categories();
float GetElevation() const;
std::vector<float> GetElevationCuts() const;
std::vector<std::string> GetLevel3Products();
std::string GetMapStyle() const;
common::RadarProductGroup GetRadarProductGroup() const;
std::string GetRadarProductName() const;
std::shared_ptr<config::RadarSite> GetRadarSite() const;
bool GetRadarWireframeEnabled() const;
std::chrono::system_clock::time_point GetSelectedTime() const;
bool GetSmoothingEnabled() const;
std::uint16_t GetVcp() const;
[[nodiscard]] common::Level3ProductCategoryMap
GetAvailableLevel3Categories();
[[nodiscard]] float GetElevation() const;
[[nodiscard]] std::vector<float> GetElevationCuts() const;
[[nodiscard]] std::vector<std::string> GetLevel3Products();
[[nodiscard]] std::string GetMapStyle() const;
[[nodiscard]] common::RadarProductGroup GetRadarProductGroup() const;
[[nodiscard]] std::string GetRadarProductName() const;
[[nodiscard]] std::shared_ptr<config::RadarSite> GetRadarSite() const;
[[nodiscard]] bool GetRadarWireframeEnabled() const;
[[nodiscard]] std::chrono::system_clock::time_point GetSelectedTime() const;
[[nodiscard]] bool GetSmoothingEnabled() const;
[[nodiscard]] std::uint16_t GetVcp() const;

void SelectElevation(float elevation);

Expand Down
2 changes: 1 addition & 1 deletion scwx-qt/source/scwx/qt/map/radar_product_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void RadarProductLayer::Render(
// Set OpenGL blend mode for transparency
gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

bool wireframeEnabled = context()->settings().radarWireframeEnabled_;
const bool wireframeEnabled = context()->settings().radarWireframeEnabled_;
if (wireframeEnabled)
{
// Set polygon mode to draw wireframe
Expand Down
11 changes: 5 additions & 6 deletions scwx-qt/source/scwx/qt/settings/map_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,28 +157,27 @@ std::size_t MapSettings::count() const
return kCount_;
}

SettingsVariable<std::string>& MapSettings::map_style(std::size_t i) const
SettingsVariable<std::string>& MapSettings::map_style(std::size_t i)
{
return p->map_.at(i).mapStyle_;
}

SettingsVariable<std::string>& MapSettings::radar_site(std::size_t i) const
SettingsVariable<std::string>& MapSettings::radar_site(std::size_t i)
{
return p->map_.at(i).radarSite_;
}

SettingsVariable<std::string>&
MapSettings::radar_product_group(std::size_t i) const
SettingsVariable<std::string>& MapSettings::radar_product_group(std::size_t i)
{
return p->map_.at(i).radarProductGroup_;
}

SettingsVariable<std::string>& MapSettings::radar_product(std::size_t i) const
SettingsVariable<std::string>& MapSettings::radar_product(std::size_t i)
{
return p->map_.at(i).radarProduct_;
}

SettingsVariable<bool>& MapSettings::smoothing_enabled(std::size_t i) const
SettingsVariable<bool>& MapSettings::smoothing_enabled(std::size_t i)
{
return p->map_.at(i).smoothingEnabled_;
}
Expand Down
10 changes: 5 additions & 5 deletions scwx-qt/source/scwx/qt/settings/map_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class MapSettings : public SettingsCategory
MapSettings& operator=(MapSettings&&) noexcept;

std::size_t count() const;
SettingsVariable<std::string>& map_style(std::size_t i) const;
SettingsVariable<std::string>& radar_site(std::size_t i) const;
SettingsVariable<std::string>& radar_product_group(std::size_t i) const;
SettingsVariable<std::string>& radar_product(std::size_t i) const;
SettingsVariable<bool>& smoothing_enabled(std::size_t i) const;
SettingsVariable<std::string>& map_style(std::size_t i);
SettingsVariable<std::string>& radar_site(std::size_t i);
SettingsVariable<std::string>& radar_product_group(std::size_t i);
SettingsVariable<std::string>& radar_product(std::size_t i);
SettingsVariable<bool>& smoothing_enabled(std::size_t i);

bool Shutdown();

Expand Down
4 changes: 2 additions & 2 deletions scwx-qt/source/scwx/qt/ui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ void SettingsDialogImpl::SetupGeneralTab()
self_,
[this](const QString& text)
{
types::UiStyle style = types::GetUiStyle(text.toStdString());
bool themeFileEnabled = style == types::UiStyle::FusionCustom;
const types::UiStyle style = types::GetUiStyle(text.toStdString());
const bool themeFileEnabled = style == types::UiStyle::FusionCustom;

self_->ui->themeFileLineEdit->setEnabled(themeFileEnabled);
self_->ui->themeFileSelectButton->setEnabled(themeFileEnabled);
Expand Down
51 changes: 29 additions & 22 deletions scwx-qt/source/scwx/qt/view/level2_product_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ static constexpr std::uint32_t kMaxRadialGates_ =
common::MAX_0_5_DEGREE_RADIALS * common::MAX_DATA_MOMENT_GATES;
static constexpr std::uint32_t kMaxCoordinates_ = kMaxRadialGates_ * 2u;

static constexpr std::uint8_t kDataWordSize8_ = 8u;
static constexpr std::uint8_t kDataWordSize16_ = 16u;

static constexpr std::size_t kVerticesPerGate_ = 6u;
static constexpr std::size_t kVerticesPerOriginGate_ = 3u;

Expand Down Expand Up @@ -108,6 +111,12 @@ class Level2ProductView::Impl
threadPool_.join();
};

Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;

Impl(Impl&&) noexcept = default;
Impl& operator=(Impl&&) noexcept = default;

void ComputeCoordinates(
const std::shared_ptr<wsr88d::rda::ElevationScan>& radarData,
bool smoothingEnabled);
Expand All @@ -119,7 +128,7 @@ class Level2ProductView::Impl

void ComputeEdgeValue();
template<typename T>
inline T RemapDataMoment(T dataMoment) const;
[[nodiscard]] inline T RemapDataMoment(T dataMoment) const;

static bool IsRadarDataIncomplete(
const std::shared_ptr<const wsr88d::rda::ElevationScan>& radarData);
Expand All @@ -130,7 +139,8 @@ class Level2ProductView::Impl
boost::asio::thread_pool threadPool_ {1u};

common::Level2Product product_;
wsr88d::rda::DataBlockType dataBlockType_;
wsr88d::rda::DataBlockType dataBlockType_ {
wsr88d::rda::DataBlockType::Unknown};

float selectedElevation_;

Expand Down Expand Up @@ -525,9 +535,9 @@ void Level2ProductView::ComputeSweep()

std::shared_ptr<manager::RadarProductManager> radarProductManager =
radar_product_manager();
const bool smoothingEnabled = smoothing_enabled();
p->showSmoothedRangeFolding_ = show_smoothed_range_folding();
bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_;
const bool smoothingEnabled = smoothing_enabled();
p->showSmoothedRangeFolding_ = show_smoothed_range_folding();
const bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_;

std::shared_ptr<wsr88d::rda::ElevationScan> radarData;
std::chrono::system_clock::time_point requestedTime {selected_time()};
Expand Down Expand Up @@ -661,7 +671,7 @@ void Level2ProductView::ComputeSweep()
const auto& radialPair = *it;
std::uint16_t radial = radialPair.first;
const auto& radialData = radialPair.second;
std::shared_ptr<wsr88d::rda::GenericRadarData::MomentDataBlock>
const std::shared_ptr<wsr88d::rda::GenericRadarData::MomentDataBlock>
momentData = radialData->moment_data_block(p->dataBlockType_);

if (momentData0->data_word_size() != momentData->data_word_size())
Expand Down Expand Up @@ -748,7 +758,7 @@ void Level2ProductView::ComputeSweep()
continue;
}

if (nextMomentData->data_word_size() == 8)
if (nextMomentData->data_word_size() == kDataWordSize8_)
{
nextDataMomentsArray8 = reinterpret_cast<const std::uint8_t*>(
nextMomentData->data_moments());
Expand Down Expand Up @@ -783,15 +793,15 @@ void Level2ProductView::ComputeSweep()
{
if (!smoothingEnabled)
{
std::uint8_t dataValue = dataMomentsArray8[i];
const std::uint8_t& dataValue = dataMomentsArray8[i];
if (dataValue < snrThreshold && dataValue != RANGE_FOLDED)
{
continue;
}

for (std::size_t m = 0; m < vertexCount; m++)
{
dataMoments8[mIndex++] = dataMomentsArray8[i];
dataMoments8[mIndex++] = dataValue;

if (cfpMomentsArray != nullptr)
{
Expand Down Expand Up @@ -851,15 +861,15 @@ void Level2ProductView::ComputeSweep()
{
if (!smoothingEnabled)
{
std::uint16_t dataValue = dataMomentsArray16[i];
const std::uint16_t& dataValue = dataMomentsArray16[i];
if (dataValue < snrThreshold && dataValue != RANGE_FOLDED)
{
continue;
}

for (std::size_t m = 0; m < vertexCount; m++)
{
dataMoments16[mIndex++] = dataMomentsArray16[i];
dataMoments16[mIndex++] = dataValue;
}
}
else if (gate > 0)
Expand Down Expand Up @@ -924,18 +934,19 @@ void Level2ProductView::ComputeSweep()

const std::uint16_t baseCoord = gate - 1;

std::size_t offset1 = ((startRadial + radial) % vertexRadials *
common::MAX_DATA_MOMENT_GATES +
baseCoord) *
2;
std::size_t offset2 =
const std::size_t offset1 =
((startRadial + radial) % vertexRadials *
common::MAX_DATA_MOMENT_GATES +
baseCoord) *
2;
const std::size_t offset2 =
offset1 + static_cast<std::size_t>(gateSize) * 2;
std::size_t offset3 =
const std::size_t offset3 =
(((startRadial + radial + 1) % vertexRadials) *
common::MAX_DATA_MOMENT_GATES +
baseCoord) *
2;
std::size_t offset4 =
const std::size_t offset4 =
offset3 + static_cast<std::size_t>(gateSize) * 2;

vertices[vIndex++] = coordinates[offset1];
Expand All @@ -955,8 +966,6 @@ void Level2ProductView::ComputeSweep()

vertices[vIndex++] = coordinates[offset4];
vertices[vIndex++] = coordinates[offset4 + 1];

vertexCount = kVerticesPerGate_;
}
else
{
Expand All @@ -980,8 +989,6 @@ void Level2ProductView::ComputeSweep()

vertices[vIndex++] = coordinates[offset2];
vertices[vIndex++] = coordinates[offset2 + 1];

vertexCount = kVerticesPerOriginGate_;
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions scwx-qt/source/scwx/qt/view/level3_product_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,20 +489,21 @@ std::uint8_t Level3ProductView::ComputeEdgeValue() const
{
std::uint8_t edgeValue = 0;

std::shared_ptr<wsr88d::rpg::ProductDescriptionBlock> descriptionBlock =
p->graphicMessage_->description_block();
const std::shared_ptr<wsr88d::rpg::ProductDescriptionBlock>
descriptionBlock = p->graphicMessage_->description_block();

const float offset = descriptionBlock->offset();
const float scale = descriptionBlock->scale();

switch (p->category_)
{
case common::Level3ProductCategory::Velocity:
edgeValue = (scale > 0.0f) ? (-offset / scale) : -offset;
edgeValue = static_cast<std::uint8_t>((scale > 0.0f) ? (-offset / scale) :
-offset);
break;

case common::Level3ProductCategory::DifferentialReflectivity:
edgeValue = -offset;
edgeValue = static_cast<std::uint8_t>(-offset);
break;

case common::Level3ProductCategory::SpectrumWidth:
Expand All @@ -512,7 +513,8 @@ std::uint8_t Level3ProductView::ComputeEdgeValue() const

case common::Level3ProductCategory::CorrelationCoefficient:
edgeValue = static_cast<std::uint8_t>(
std::max<std::uint16_t>(255, descriptionBlock->number_of_levels()));
std::max<std::uint16_t>(std::numeric_limits<std::uint8_t>::max(),
descriptionBlock->number_of_levels()));
break;

case common::Level3ProductCategory::Reflectivity:
Expand Down
2 changes: 1 addition & 1 deletion scwx-qt/source/scwx/qt/view/level3_product_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Level3ProductView : public RadarProductView
void DisconnectRadarProductManager() override;
void UpdateColorTableLut() override;

std::uint8_t ComputeEdgeValue() const;
[[nodiscard]] std::uint8_t ComputeEdgeValue() const;

private:
class Impl;
Expand Down
Loading

0 comments on commit a3eb53a

Please sign in to comment.