Skip to content

Commit

Permalink
add support for using constant values as fill baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
ElderOrb committed Jun 16, 2024
1 parent 9ef4354 commit 3d1cfd0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Source/Core/VideoCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const struct per_item VideoPerItem [Item_VideoMax]=
{ Group_Y, Group_VideoMax, "Y MIN", "lavfi.signalstats.YMIN", 0, false, DBL_MAX, DBL_MAX, ActiveFilter_Video_signalstats, "gray", 1, }, // "Y LOW;green;0.5" },
{ Group_Y, Group_VideoMax, "Y LOW", "lavfi.signalstats.YLOW", 0, false, DBL_MAX, DBL_MAX, ActiveFilter_Video_signalstats, "green", 2, }, // "Y LOW;transparent;0.5" },
{ Group_Y, Group_VideoMax, "Y AVG", "lavfi.signalstats.YAVG", 0, false, DBL_MAX, DBL_MAX, ActiveFilter_Video_signalstats, "yellow", 3, }, // "Y LOW;red;0.5" },
{ Group_Y, Group_VideoMax, "Y HIGH", "lavfi.signalstats.YHIGH", 0, false, DBL_MAX, DBL_MAX, ActiveFilter_Video_signalstats, nullptr, -1, "Y AVG;yellow;0.8" },
{ Group_Y, Group_VideoMax, "Y HIGH", "lavfi.signalstats.YHIGH", 0, false, DBL_MAX, DBL_MAX, ActiveFilter_Video_signalstats, nullptr, -1, "10.0;yellow;0.8" },
{ Group_Y, Group_VideoMax, "Y MAX", "lavfi.signalstats.YMAX", 0, true, DBL_MAX, DBL_MAX, ActiveFilter_Video_signalstats, nullptr, -1, "Y HIGH;green;0.5" },
//U
{ Group_U, Group_VideoMax, "U MIN", "lavfi.signalstats.UMIN", 0, false, DBL_MAX, DBL_MAX, ActiveFilter_Video_signalstats, nullptr, -1 },
Expand Down
31 changes: 23 additions & 8 deletions Source/GUI/Plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,12 @@ class PlotCurve : public QwtPlotCurve {
m_count = count;
}

void setClipCurve(QwtPlotCurve* curve) {
m_clipCurve = curve;
void setFillCurve(QwtPlotCurve* curve) {
m_fillCurve = curve;
}

void setFillBaseLine(float value) {
m_fillBaseline = value;
}

void setFillBrush(QBrush brush) {
Expand All @@ -263,7 +267,7 @@ class PlotCurve : public QwtPlotCurve {
virtual void drawCurve( QPainter* painter , int style, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to ) const {
QwtPlotCurve::drawCurve(painter, style, xMap, yMap, canvasRect, from, to);

if(m_clipCurve && !symbol())
if((m_fillBaseline || m_fillCurve) && !symbol())
{
auto brush = m_fillBrush;

Expand All @@ -288,7 +292,13 @@ class PlotCurve : public QwtPlotCurve {

mapper.setBoundingRect( canvasRect );
QPolygonF polygon = mapper.toPolygonF( xMap, yMap, data(), from, to);
QPolygonF baselinePolygon = mapper.toPolygonF( xMap, yMap, m_clipCurve->data(), from, to);
QPolygonF baselinePolygon;
if(m_fillCurve)
baselinePolygon = mapper.toPolygonF( xMap, yMap, m_fillCurve->data(), from, to);
else if(m_fillBaseline) {
baselinePolygon += QPointF(xMap.transform(qreal(from)), yMap.transform(m_fillBaseline.value()));
baselinePolygon += QPointF(xMap.transform(qreal(to)), yMap.transform(m_fillBaseline.value()));
}

for(auto it = baselinePolygon.rbegin(); it != baselinePolygon.rend(); ++it) {
polygon += *it;
Expand Down Expand Up @@ -362,7 +372,8 @@ class PlotCurve : public QwtPlotCurve {
int m_index;
int m_count;
QBrush m_fillBrush;
QwtPlotCurve* m_clipCurve { nullptr };
QwtPlotCurve* m_fillCurve { nullptr };
std::optional<float> m_fillBaseline;
};

//***************************************************************************
Expand Down Expand Up @@ -630,9 +641,13 @@ Plot::Plot( size_t streamPos, size_t Type, size_t Group, const FileInformation*
auto curve = curvesByName[item.Name];
curve->setFillBrush(QBrush(color));

auto fillCurve = curvesByName[curveName];

curve->setClipCurve(fillCurve);
if(curvesByName.contains(curveName)) {
auto fillCurve = curvesByName[curveName];
curve->setFillCurve(fillCurve);
} else {
auto fillValue = curveName.toFloat();
curve->setFillBaseLine(fillValue);
}
}
}

Expand Down

0 comments on commit 3d1cfd0

Please sign in to comment.