Skip to content

Commit

Permalink
Line meter: Fixed issue with 12beca8
Browse files Browse the repository at this point in the history
  • Loading branch information
brianferguson committed Sep 18, 2022
1 parent 12beca8 commit 6377a20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions Library/MeterLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ bool MeterLine::Draw(Gfx::Canvas& canvas)
int maxSize = m_GraphHorizontalOrientation ? m_H : m_W;
if (!Meter::Draw(canvas) || maxSize <= 0) return false;

double maxValue = 0.0, minValue = 0.0;
// Set the max/min values to the floating point limits
double maxValue = -(DBL_MAX); // Intentional
double minValue = DBL_MAX;

// Find the maximum / minimum value
if (m_Autoscale)
Expand Down Expand Up @@ -252,7 +254,7 @@ bool MeterLine::Draw(Gfx::Canvas& canvas)
for (auto i = m_Measures.cbegin(); i != m_Measures.cend(); ++i)
{
double val = (*i)->GetMinValue();
minValue = max(minValue, val);
minValue = min(minValue, val);
}
}
else
Expand All @@ -263,18 +265,14 @@ bool MeterLine::Draw(Gfx::Canvas& canvas)
maxValue = max(maxValue, val);

val = (*i)->GetMinValue();
minValue = max(minValue, val);
minValue = min(minValue, val);
}
}

if (maxValue <= 0.0)
{
maxValue = 1.0;
}

if (minValue <= 0.0)
if (maxValue == minValue)
{
minValue = 0.0;
maxValue = 1.0;
}

D2D1_RECT_F meterRect = GetMeterRectPadding();
Expand Down
2 changes: 1 addition & 1 deletion Library/MeterLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MeterLine : public Meter
D2D1_COLOR_F m_HorizontalColor;
D2D1_STROKE_TRANSFORM_TYPE m_StrokeType;

std::vector< std::vector<double> > m_AllValues;
std::vector<std::vector<double>> m_AllValues;
int m_CurrentPos;

bool m_GraphStartLeft;
Expand Down

0 comments on commit 6377a20

Please sign in to comment.