Fill area under logical 1s in TraceWidget digital mode

master
Timothy Pearson 11 years ago
parent bc7497f24c
commit d7b08ca2de

@ -1271,6 +1271,7 @@ void LogicAnalyzerPart::updateGraticule() {
m_traceWidget->setTraceVerticalUnits(traceno-1, "", true);
m_traceWidget->setNumberOfSamples(traceno-1, m_samplesInTrace[traceno], true);
m_traceWidget->setDigitalTraceMode(traceno-1, true, true);
m_traceWidget->setDisplayLimits(traceno-1, TQRectF(0.0, (m_voltsDiv[traceno]*m_vdivs)/2.0, (m_secsDiv[traceno]*m_hdivs), (m_voltsDiv[traceno]*m_vdivs)/-2.0), (traceno<m_maxNumberOfTraces)?true:false);
}

@ -288,6 +288,7 @@ TraceData::TraceData(TraceWidget* parent, TQWidget* labelParent) : TQObject(), p
traceName = i18n("Unknown");
horizontalUnits = i18n("Units");
verticalUnits = i18n("Units");
m_digitalTraceDrawing = false;
enabled = false;
if (labelParent) {
@ -387,7 +388,7 @@ void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_heigh
unsigned int n;
unsigned int incr;
unsigned int activeSamples;
int x,y,x2,y2,horizoffset;
int x,y,x2,y2,baseline,horizoffset;
// Obtain horizontal scrolling offset
horizoffset = parentWidget->horizScrollOffset();
@ -419,6 +420,7 @@ void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_heigh
y = ((((sampleArray[n]+offset)-topEdge)/(bottomEdge-topEdge))*(virtual_height));
x2 = (((positionArray[n+incr]-leftEdge)/(rightEdge-leftEdge))*(virtual_width))-horizoffset;
y2 = ((((sampleArray[n+incr]+offset)-topEdge)/(bottomEdge-topEdge))*(virtual_height));
baseline = ((((offset)-topEdge)/(bottomEdge-topEdge))*(virtual_height));
// Do not draw lines that are placed fully off the screen
if ((x < 0) && (x2 < 0)) continue;
@ -435,9 +437,42 @@ void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_heigh
if (x2 > (virtual_width-horizoffset)) x2 = (virtual_width-horizoffset);
if (y2 < 0) y2 = 0;
if (y2 > virtual_height) y2 = virtual_height;
// Draw line!
p->drawLine(x, y, x2, y2);
if (baseline < 0) baseline = 0;
if (baseline > virtual_height) baseline = virtual_height;
// Draw line(s)!
if (m_digitalTraceDrawing) {
p->drawLine(x+1, y, x2-1, y);
p->drawLine(x2-1, y, x2+1, y2);
// Draw fill areas
if ((sampleArray[n] != 0) && (sampleArray[n+1] != 0)) {
p->save();
p->fillRect(x+1, y+1, x2-x, baseline-y-1, TQBrush(color.dark(400)));
p->restore();
}
else if ((sampleArray[n] != 0) && (sampleArray[n+1] == 0)) {
p->save();
// Fill sloping edges
p->setPen(color.dark(400));
p->drawLine(x2-3, y+1, x2-1, y2-1);
p->drawLine(x2-2, y+1, x2, y2-1);
// Fill rectangle under trace
p->fillRect(x+2, y+1, (x2-1)-(x+1)-1, baseline-y-1, TQBrush(color.dark(400)));
p->restore();
}
else if ((sampleArray[n] == 0) && (sampleArray[n+1] != 0)) {
p->save();
// Fill sloping edges
p->setPen(color.dark(400));
p->drawLine(x2+1, y+1, x2+3, y2-1);
p->drawLine(x2, y+1, x2+2, y2-1);
p->restore();
}
}
else {
p->drawLine(x, y, x2, y2);
}
}
// Draw the zero level indicator
@ -800,7 +835,7 @@ void GraticuleWidget::updateGraticule() {
p.fillRect(0, 0, m_graticulePixmap->width(), m_graticulePixmap->height(), backgroundColor());
p.setPen(TQPen(foregroundColor(), 1, TQt::DotLine));
if (m_base->m_horizDivs > 0) {
s = m_graticulePixmap->width() / m_base->m_horizDivs;
s = virtualWidth() / m_base->m_horizDivs;
x = 0;
for (d=0; d<m_base->m_horizDivs; d++) {
rx = x - m_base->horizScrollOffset();
@ -1222,6 +1257,17 @@ void TraceWidget::setNumberOfSamples(uint traceNumber, unsigned int samples, boo
}
}
void TraceWidget::setDigitalTraceMode(uint traceNumber, bool enabled, bool deferUpdate) {
VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->m_digitalTraceDrawing = enabled;
if (!deferUpdate) {
m_graticuleWidget->updateGraticule();
updateTraceText();
}
}
void TraceWidget::setNumberOfHorizontalDivisions(unsigned int divisions) {
m_horizDivs = divisions;
m_graticuleWidget->updateGraticule();

@ -82,6 +82,7 @@ class TraceData : public TQObject
TQString traceName;
TQString horizontalUnits;
TQString verticalUnits;
bool m_digitalTraceDrawing;
TQLabel* paramLabel;
TQLabel* leftLabel;
TQLabel* graphStatusLabel;
@ -227,6 +228,7 @@ class TraceWidget : public TQWidget
void setTraceHorizontalUnits(uint traceNumber, TQString units, bool deferUpdate=false);
TQString traceVerticalUnits(uint traceNumber);
void setTraceVerticalUnits(uint traceNumber, TQString units, bool deferUpdate=false);
void setDigitalTraceMode(uint traceNumber, bool enabled, bool deferUpdate=false);
double cursorPosition(uint cursorNumber);
void setCursorPosition(uint cursorNumber, double position);

Loading…
Cancel
Save