diff --git a/clients/tde/src/part/scope/part.cpp b/clients/tde/src/part/scope/part.cpp index 75bf488..04fdb55 100644 --- a/clients/tde/src/part/scope/part.cpp +++ b/clients/tde/src/part/scope/part.cpp @@ -818,6 +818,9 @@ void ScopePart::saveWaveforms() { ds << m_traceWidget->samples(traceno-1); ds << m_traceWidget->positions(traceno-1); } + for (int cursorno=0; cursorno<4; cursorno++) { + ds << m_traceWidget->cursorPosition(cursorno); + } } } @@ -852,6 +855,11 @@ void ScopePart::recallWaveforms() { m_base->traceZoomWidget->setSamples(traceno-1, values); m_base->traceZoomWidget->setPositions(traceno-1, positions); } + for (int cursorno=0; cursorno<4; cursorno++) { + double cursorPos; + ds >> cursorPos; + m_traceWidget->setCursorPosition(cursorno, cursorPos); + } updateGraticule(); postProcessTrace(); // HACK diff --git a/clients/tde/src/widgets/tracewidget.cpp b/clients/tde/src/widgets/tracewidget.cpp index 1f7c576..e3803ed 100644 --- a/clients/tde/src/widgets/tracewidget.cpp +++ b/clients/tde/src/widgets/tracewidget.cpp @@ -97,6 +97,8 @@ bool TQRectF::operator!=(const TQRectF &r1) { TraceData::TraceData(TraceWidget* parent, TQWidget* labelParent) : TQObject(), parentWidget(parent) { color = TQColor(0, 255, 0); numberOfSamples = 0; + leftEdgeIndex = -1; + rightEdgeIndex = -1; offset = 0.0; leftEdge = 0; rightEdge = 0; @@ -178,21 +180,45 @@ void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_heigh if ((bottomEdge != topEdge) && (enabled) && (positionArray.count() >= numberOfSamples) && (sampleArray.count() >= numberOfSamples) && (numberOfSamples > 0)) { // Draw the points unsigned int n; + unsigned int incr; + unsigned int activeSamples; int x,y,x2,y2; - for (n=0; n= 0) { + leftEdgeIndex = n; + } + } + else { + if (x >= graticule_width) { + rightEdgeIndex = n; + break; + } + } + } + if (rightEdgeIndex < 0) { + rightEdgeIndex = numberOfSamples-1; + } + } + activeSamples = abs(rightEdgeIndex-leftEdgeIndex); + incr = (activeSamples/graticule_width)+1; + for (n=leftEdgeIndex; n graticule_width) x = graticule_width; if (y < 0) y = 0; - if (y > graticule_width) y = graticule_height; + if (y > graticule_height) y = graticule_height; if (x2 < 0) x2 = 0; if (x2 > graticule_width) x2 = graticule_width; if (y2 < 0) y2 = 0; - if (y2 > graticule_width) y2 = graticule_height; + if (y2 > graticule_height) y2 = graticule_height; p->drawLine(x, y, x2, y2); } @@ -535,6 +561,7 @@ void GraticuleWidget::mousePressEvent(TQMouseEvent *e) { if (m_base->m_zoomBoxEnabled) { m_middleMouseDown = true; m_prevDownPos = e->pos(); + setCursor(tqsizeAllCursor); } } } @@ -545,7 +572,24 @@ void GraticuleWidget::mouseReleaseEvent(TQMouseEvent *e) { m_leftMouseDown = false; if (m_movingCursor >= 0) { + TQPoint diff = e->pos() - m_prevDownPos; + double dx = diff.x()*(100.0/width()); + double dy = diff.y()*(100.0/height()); + if (m_base->m_cursorArray[m_movingCursor]->orientation == TQt::Horizontal) { + m_base->m_cursorArray[m_movingCursor]->position = m_prevCursorPos+dy; + } + else { + m_base->m_cursorArray[m_movingCursor]->position = m_prevCursorPos+dx; + } + if (m_base->m_cursorArray[m_movingCursor]->position < 0.0) { + m_base->m_cursorArray[m_movingCursor]->position = 0.0; + } + if (m_base->m_cursorArray[m_movingCursor]->position > 100.0) { + m_base->m_cursorArray[m_movingCursor]->position = 100.0; + } m_movingCursor = -1; + updateGraticule(); + repaint(false); } else { double x1 = m_prevDownPos.x(); @@ -578,13 +622,15 @@ void GraticuleWidget::mouseReleaseEvent(TQMouseEvent *e) { double y2 = e->y(); if ((x1 < width()) && (y1 < height()) && (x2 < width()) && (y2 < height()) && (x1 > 0) && (y1 > 0) && (x2 > 0) && (y2 > 0)) { TQPoint diff = e->pos() - m_prevDownPos; - diff = TQPoint(diff.x()*(100.0/width()), diff.y()*(100.0/height())); - m_base->setZoomCursorBox(TQRectF(m_prevCursorRect.x()+diff.x(), m_prevCursorRect.y()+diff.y(), m_prevCursorRect.width()+diff.x(), m_prevCursorRect.height()+diff.y())); + double dx = diff.x()*(100.0/width()); + double dy = diff.y()*(100.0/height()); + m_base->setZoomCursorBox(TQRectF(m_prevCursorRect.x()+dx, m_prevCursorRect.y()+dy, m_prevCursorRect.width()+dx, m_prevCursorRect.height()+dy)); } else { // Reset original zoom box m_base->setZoomCursorBox(m_prevCursorRect); } + setCursor(tqcrossCursor); } } @@ -694,12 +740,13 @@ void GraticuleWidget::mouseMoveEvent(TQMouseEvent *e) { } else if ((m_leftMouseDown) && (m_movingCursor >= 0)) { TQPoint diff = e->pos() - m_prevDownPos; - diff = TQPoint(diff.x()*(100.0/width()), diff.y()*(100.0/height())); + double dx = diff.x()*(100.0/width()); + double dy = diff.y()*(100.0/height()); if (m_base->m_cursorArray[m_movingCursor]->orientation == TQt::Horizontal) { - m_base->m_cursorArray[m_movingCursor]->position = m_prevCursorPos+diff.y(); + m_base->m_cursorArray[m_movingCursor]->position = m_prevCursorPos+dy; } else { - m_base->m_cursorArray[m_movingCursor]->position = m_prevCursorPos+diff.x(); + m_base->m_cursorArray[m_movingCursor]->position = m_prevCursorPos+dx; } if (m_base->m_cursorArray[m_movingCursor]->position < 0.0) { m_base->m_cursorArray[m_movingCursor]->position = 0.0; @@ -713,8 +760,9 @@ void GraticuleWidget::mouseMoveEvent(TQMouseEvent *e) { } else if (m_middleMouseDown) { TQPoint diff = e->pos() - m_prevDownPos; - diff = TQPoint(diff.x()*(100.0/width()), diff.y()*(100.0/height())); - m_base->setZoomCursorBox(TQRectF(m_prevCursorRect.x()+diff.x(), m_prevCursorRect.y()+diff.y(), m_prevCursorRect.width()+diff.x(), m_prevCursorRect.height()+diff.y())); + double dx = diff.x()*(100.0/width()); + double dy = diff.y()*(100.0/height()); + m_base->setZoomCursorBox(TQRectF(m_prevCursorRect.x()+dx, m_prevCursorRect.y()+dy, m_prevCursorRect.width()+dx, m_prevCursorRect.height()+dy)); } m_base->updateCursorText(); @@ -805,6 +853,8 @@ void TraceWidget::setNumberOfSamples(uint traceNumber, unsigned int samples) { m_traceArray[traceNumber]->numberOfSamples = samples; m_traceArray[traceNumber]->sampleArray.resize(samples); m_traceArray[traceNumber]->positionArray.resize(samples); + m_traceArray[traceNumber]->leftEdgeIndex = -1; + m_traceArray[traceNumber]->rightEdgeIndex = -1; m_graticuleWidget->updateGraticule(); updateTraceText(); @@ -831,6 +881,8 @@ void TraceWidget::setDisplayLimits(uint traceNumber, TQRectF limits) { m_traceArray[traceNumber]->rightEdge = limits.width(); m_traceArray[traceNumber]->topEdge = limits.y(); m_traceArray[traceNumber]->bottomEdge = limits.height(); + m_traceArray[traceNumber]->leftEdgeIndex = -1; + m_traceArray[traceNumber]->rightEdgeIndex = -1; m_graticuleWidget->updateGraticule(); m_graticuleWidget->repaint(false); @@ -958,6 +1010,8 @@ void TraceWidget::setPositions(uint traceNumber, TQDoubleArray& tqda) { m_traceArray[traceNumber]->positionArray = tqda; m_traceArray[traceNumber]->numberOfSamples = tqda.size(); + m_traceArray[traceNumber]->leftEdgeIndex = -1; + m_traceArray[traceNumber]->rightEdgeIndex = -1; m_graticuleWidget->repaint(false); } diff --git a/clients/tde/src/widgets/tracewidget.h b/clients/tde/src/widgets/tracewidget.h index f3e093b..9a478ac 100644 --- a/clients/tde/src/widgets/tracewidget.h +++ b/clients/tde/src/widgets/tracewidget.h @@ -63,6 +63,8 @@ class TraceData : public TQObject TQDoubleArray sampleArray; TQDoubleArray positionArray; unsigned int numberOfSamples; + long leftEdgeIndex; + long rightEdgeIndex; double offset; TQColor color; bool enabled;