1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-20 00:25:53 -05:00

New scope: implemented view trace toggle

This commit is contained in:
f4exb 2017-02-26 22:27:03 +01:00
parent 3bf3e4e737
commit 68b28fc648
5 changed files with 90 additions and 52 deletions

View File

@ -67,6 +67,7 @@ public:
float m_traceColorB; //!< Trace display color - blue shortcut float m_traceColorB; //!< Trace display color - blue shortcut
bool m_hasTextOverlay; //!< True if a text overlay has to be displayed bool m_hasTextOverlay; //!< True if a text overlay has to be displayed
QString m_textOverlay; //!< Text overlay to display QString m_textOverlay; //!< Text overlay to display
bool m_viewTrace; //!< Trace visibility
TraceData() : TraceData() :
m_projectionType(ProjectionReal), m_projectionType(ProjectionReal),
@ -81,7 +82,8 @@ public:
m_traceDelayFine(0), m_traceDelayFine(0),
m_triggerDisplayLevel(2.0), // OVer scale by default (2.0) m_triggerDisplayLevel(2.0), // OVer scale by default (2.0)
m_traceColor(255,255,64), m_traceColor(255,255,64),
m_hasTextOverlay(false) m_hasTextOverlay(false),
m_viewTrace(true)
{ {
setColor(m_traceColor); setColor(m_traceColor);
} }

View File

@ -303,60 +303,63 @@ void GLScopeNG::paintGL()
const float *trace = (*m_traces)[0]; const float *trace = (*m_traces)[0];
const ScopeVisNG::TraceData& traceData = (*m_tracesData)[0]; const ScopeVisNG::TraceData& traceData = (*m_tracesData)[0];
int start = (m_timeOfsProMill/1000.0) * m_traceSize; if (traceData.m_viewTrace)
int end = std::min(start + m_traceSize/m_timeBase, m_traceSize);
if(end - start < 2)
start--;
float rectX = m_glScopeRect1.x();
float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f;
float rectW = m_glScopeRect1.width() * (float)m_timeBase / (float)(m_traceSize - 1);
//float rectH = -(m_glScopeRect1.height() / 2.0f) * traceData.m_amp;
float rectH = -m_glScopeRect1.height() / 2.0f;
//QVector4D color(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0f);
QVector4D color(traceData.m_traceColorR, traceData.m_traceColorG, traceData.m_traceColorB, m_displayTraceIntensity / 100.0f);
QMatrix4x4 mat;
mat.setToIdentity();
mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY);
mat.scale(2.0f * rectW, -2.0f * rectH);
m_glShaderSimple.drawPolyline(mat, color, (GLfloat *) &trace[2*start], end - start);
// Paint trigger level if any
if ((traceData.m_triggerDisplayLevel > -1.0f) && (traceData.m_triggerDisplayLevel < 1.0f))
{ {
GLfloat q3[] { int start = (m_timeOfsProMill/1000.0) * m_traceSize;
0, traceData.m_triggerDisplayLevel, int end = std::min(start + m_traceSize/m_timeBase, m_traceSize);
1, traceData.m_triggerDisplayLevel
};
float rectX = m_glScopeRect1.x(); if(end - start < 2)
float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f; start--;
float rectW = m_glScopeRect1.width();
float rectH = -m_glScopeRect1.height() / 2.0f;
QVector4D color( float rectX = m_glScopeRect1.x();
m_focusedTriggerData.m_triggerColorR, float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f;
m_focusedTriggerData.m_triggerColorG, float rectW = m_glScopeRect1.width() * (float)m_timeBase / (float)(m_traceSize - 1);
m_focusedTriggerData.m_triggerColorB, //float rectH = -(m_glScopeRect1.height() / 2.0f) * traceData.m_amp;
0.4f); float rectH = -m_glScopeRect1.height() / 2.0f;
QMatrix4x4 mat;
mat.setToIdentity();
mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY);
mat.scale(2.0f * rectW, -2.0f * rectH);
m_glShaderSimple.drawSegments(mat, color, q3, 2);
} // display trigger
// Paint overlay if any //QVector4D color(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0f);
if ((m_focusedTraceIndex == 0) && (traceData.m_hasTextOverlay)) QVector4D color(traceData.m_traceColorR, traceData.m_traceColorG, traceData.m_traceColorB, m_displayTraceIntensity / 100.0f);
{ QMatrix4x4 mat;
drawChannelOverlay( mat.setToIdentity();
traceData.m_textOverlay, mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY);
traceData.m_traceColor, mat.scale(2.0f * rectW, -2.0f * rectH);
m_channelOverlayPixmap1, m_glShaderSimple.drawPolyline(mat, color, (GLfloat *) &trace[2*start], end - start);
m_glScopeRect1);
} // Paint trigger level if any
if ((traceData.m_triggerDisplayLevel > -1.0f) && (traceData.m_triggerDisplayLevel < 1.0f))
{
GLfloat q3[] {
0, traceData.m_triggerDisplayLevel,
1, traceData.m_triggerDisplayLevel
};
float rectX = m_glScopeRect1.x();
float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f;
float rectW = m_glScopeRect1.width();
float rectH = -m_glScopeRect1.height() / 2.0f;
QVector4D color(
m_focusedTriggerData.m_triggerColorR,
m_focusedTriggerData.m_triggerColorG,
m_focusedTriggerData.m_triggerColorB,
0.4f);
QMatrix4x4 mat;
mat.setToIdentity();
mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY);
mat.scale(2.0f * rectW, -2.0f * rectH);
m_glShaderSimple.drawSegments(mat, color, q3, 2);
} // display trigger
// Paint overlay if any
if ((m_focusedTraceIndex == 0) && (traceData.m_hasTextOverlay))
{
drawChannelOverlay(
traceData.m_textOverlay,
traceData.m_traceColor,
m_channelOverlayPixmap1,
m_glScopeRect1);
} // display overlay
} // displayable trace
} // trace length > 0 } // trace length > 0
} // Display X } // Display X
@ -481,6 +484,10 @@ void GLScopeNG::paintGL()
const float *trace = (*m_traces)[i]; const float *trace = (*m_traces)[i];
const ScopeVisNG::TraceData& traceData = (*m_tracesData)[i]; const ScopeVisNG::TraceData& traceData = (*m_tracesData)[i];
if (!traceData.m_viewTrace) {
continue;
}
float rectX = m_glScopeRect2.x(); float rectX = m_glScopeRect2.x();
float rectY = m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0f; float rectY = m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0f;
float rectW = m_glScopeRect2.width() * (float)m_timeBase / (float)(m_traceSize - 1); float rectW = m_glScopeRect2.width() * (float)m_timeBase / (float)(m_traceSize - 1);
@ -700,6 +707,10 @@ void GLScopeNG::paintGL()
const float *trace = (*m_traces)[i]; const float *trace = (*m_traces)[i];
const ScopeVisNG::TraceData& traceData = (*m_tracesData)[i]; const ScopeVisNG::TraceData& traceData = (*m_tracesData)[i];
if (!traceData.m_viewTrace) {
continue;
}
float rectX = m_glScopeRect1.x(); float rectX = m_glScopeRect1.x();
float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f; float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f;
float rectW = m_glScopeRect1.width() * (float)m_timeBase / (float)(m_traceSize - 1); float rectW = m_glScopeRect1.width() * (float)m_timeBase / (float)(m_traceSize - 1);
@ -869,6 +880,10 @@ void GLScopeNG::paintGL()
const float *trace = (*m_traces)[i]; const float *trace = (*m_traces)[i];
const ScopeVisNG::TraceData& traceData = (*m_tracesData)[i]; const ScopeVisNG::TraceData& traceData = (*m_tracesData)[i];
if (!traceData.m_viewTrace) {
continue;
}
for(int i = start; i < end; i++) for(int i = start; i < end; i++)
{ {
float y = trace[2*i+1]; float y = trace[2*i+1];

View File

@ -719,6 +719,11 @@ void GLScopeNGGUI::on_traceDelayFine_valueChanged(int value)
changeCurrentTrace(); changeCurrentTrace();
} }
void GLScopeNGGUI::on_traceView_toggled(bool checked)
{
changeCurrentTrace();
}
void GLScopeNGGUI::on_traceColor_clicked() void GLScopeNGGUI::on_traceColor_clicked()
{ {
QColor newColor = QColorDialog::getColor(m_focusedTraceColor); QColor newColor = QColorDialog::getColor(m_focusedTraceColor);
@ -1196,8 +1201,8 @@ void GLScopeNGGUI::fillTraceData(ScopeVisNG::TraceData& traceData)
traceData.m_traceDelayCoarse = ui->traceDelayCoarse->value(); traceData.m_traceDelayCoarse = ui->traceDelayCoarse->value();
traceData.m_traceDelayFine = ui->traceDelayFine->value(); traceData.m_traceDelayFine = ui->traceDelayFine->value();
traceData.m_traceDelay = traceData.m_traceDelayCoarse * 100 + traceData.m_traceDelayFine; traceData.m_traceDelay = traceData.m_traceDelayCoarse * 100 + traceData.m_traceDelayFine;
traceData.setColor(m_focusedTraceColor); traceData.setColor(m_focusedTraceColor);
traceData.m_viewTrace = ui->traceView->isChecked();
} }
void GLScopeNGGUI::fillTriggerData(ScopeVisNG::TriggerData& triggerData) void GLScopeNGGUI::fillTriggerData(ScopeVisNG::TriggerData& triggerData)
@ -1237,6 +1242,8 @@ void GLScopeNGGUI::setTraceUI(ScopeVisNG::TraceData& traceData)
int r, g, b, a; int r, g, b, a;
m_focusedTraceColor.getRgb(&r, &g, &b, &a); m_focusedTraceColor.getRgb(&r, &g, &b, &a);
ui->traceColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b)); ui->traceColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b));
ui->traceView->setChecked(traceData.m_viewTrace);
} }
void GLScopeNGGUI::setTriggerUI(ScopeVisNG::TriggerData& triggerData) void GLScopeNGGUI::setTriggerUI(ScopeVisNG::TriggerData& triggerData)

View File

@ -183,6 +183,7 @@ private slots:
void on_ofsFine_valueChanged(int value); void on_ofsFine_valueChanged(int value);
void on_traceDelayCoarse_valueChanged(int value); void on_traceDelayCoarse_valueChanged(int value);
void on_traceDelayFine_valueChanged(int value); void on_traceDelayFine_valueChanged(int value);
void on_traceView_toggled(bool checked);
void on_traceColor_clicked(); void on_traceColor_clicked();
void on_mem_valueChanged(int value); void on_mem_valueChanged(int value);
// Third row // Third row

View File

@ -980,6 +980,19 @@ kS/s</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="traceView">
<property name="toolTip">
<string>View trace toggle</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="ClickableLabel" name="traceColor"> <widget class="ClickableLabel" name="traceColor">
<property name="minimumSize"> <property name="minimumSize">