diff --git a/clients/tde/src/part/logicanalyzer/part.cpp b/clients/tde/src/part/logicanalyzer/part.cpp index 28f2c3f..97da2e3 100644 --- a/clients/tde/src/part/logicanalyzer/part.cpp +++ b/clients/tde/src/part/logicanalyzer/part.cpp @@ -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), (tracenohorizScrollOffset(); @@ -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; dm_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(); diff --git a/clients/tde/src/widgets/tracewidget.h b/clients/tde/src/widgets/tracewidget.h index fabde7c..0afc9d4 100644 --- a/clients/tde/src/widgets/tracewidget.h +++ b/clients/tde/src/widgets/tracewidget.h @@ -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);