diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-04-24 20:33:06 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-04-24 20:33:06 -0500 |
commit | 55e9906b78d8d0d22359d67e8d98e8c8c49f5b28 (patch) | |
tree | fc422798fd78315bfe51f044815457a7fa072b37 /clients/tde/src/widgets | |
parent | 31f91d555b16487cc1670cbfa8c18b2f14993d57 (diff) | |
download | ulab-55e9906b78d8d0d22359d67e8d98e8c8c49f5b28.tar.gz ulab-55e9906b78d8d0d22359d67e8d98e8c8c49f5b28.zip |
Add timebase controls to scope part
Build debug symbols package
Diffstat (limited to 'clients/tde/src/widgets')
-rw-r--r-- | clients/tde/src/widgets/tracewidget.cpp | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/clients/tde/src/widgets/tracewidget.cpp b/clients/tde/src/widgets/tracewidget.cpp index 8de3d52..c3c3475 100644 --- a/clients/tde/src/widgets/tracewidget.cpp +++ b/clients/tde/src/widgets/tracewidget.cpp @@ -136,9 +136,9 @@ TraceWidgetPushButton::~TraceWidgetPushButton() { // Largely taken from TQPushButton::sizeHint() TQSize TraceWidgetPushButton::sizeHint() const { constPolish(); - + int w = 0, h = 0; - + // calculate contents size... if (iconSet() && !iconSet()->isNull()) { int iw = iconSet()->pixmap( TQIconSet::Small, TQIconSet::Normal ).width() + 4; @@ -150,7 +150,7 @@ TQSize TraceWidgetPushButton::sizeHint() const { if (isMenuButton()) { w += style().pixelMetric(TQStyle::PM_MenuButtonIndicator, this); } - + if (pixmap()) { TQPixmap *pm = (TQPixmap *)pixmap(); w += pm->width(); @@ -171,7 +171,7 @@ TQSize TraceWidgetPushButton::sizeHint() const { h = TQMAX(h, sz.height()); } } - + return (TQSize(w, h).expandedTo(TQApplication::globalStrut()).expandedTo(TQSize(20, 20))); } @@ -221,7 +221,7 @@ class TraceLabelLayoutIterator : public TQGLayoutIterator TQLayoutItem *takeCurrent() { return list->take(idx); } - + private: int idx; TQPtrList<TQLayoutItem> *list; @@ -279,11 +279,11 @@ void TraceLabelLayout::setGeometry(const TQRect &rect) { break; } } - + TQFontMetrics fm(currentTrace->leftLabel->font()); int font_height = fm.boundingRect(currentTrace->leftLabel->text()).height(); int font_vertical_offset = font_height/2; - + int graticule_height = m_traceWidget->m_graticuleWidget->height(); int y = ((((currentTrace->offset+currentTrace->textOffset)-currentTrace->topEdge)/(currentTrace->bottomEdge-currentTrace->topEdge))*(graticule_height))-font_vertical_offset; if (m_traceWidget->m_showLeftTraceInfoArea) { @@ -400,7 +400,7 @@ class TraceCursorLabelLayoutIterator : public TQGLayoutIterator TQLayoutItem *takeCurrent() { return list->take(idx); } - + private: int idx; TQPtrList<TQLayoutItem> *list; @@ -458,11 +458,11 @@ void TraceCursorLabelLayout::setGeometry(const TQRect &rect) { break; } } - + TQFontMetrics fm(currentTrace->leftCursorLabel->font()); int font_height = fm.boundingRect(currentTrace->leftCursorLabel->text()).height(); int font_vertical_offset = font_height/2; - + int graticule_height = m_traceWidget->m_graticuleWidget->height(); int y = ((((currentTrace->offset+currentTrace->textOffset)-currentTrace->topEdge)/(currentTrace->bottomEdge-currentTrace->topEdge))*(graticule_height))-font_vertical_offset; if (m_traceWidget->m_showLeftTraceInfoArea) { @@ -1081,7 +1081,7 @@ int GraticuleWidget::virtualWidth() { } } } - + return m_virtualWidth; } @@ -1509,6 +1509,7 @@ TraceWidget::TraceWidget(TQWidget* parent, const char* name) : TQWidget(parent, TraceWidget::~TraceWidget() { for (uint i=0;i<m_traceArray.count();i++) { delete m_traceArray[i]; + m_traceArray[i] = NULL; } } @@ -1688,7 +1689,7 @@ void TraceWidget::updateCursorText() { if (m_cursorArray[cursor]->activeTraceLabelList.contains(trace) > 0) { double horizontal_range = (m_traceArray[trace]->rightEdge-m_traceArray[trace]->leftEdge); double vertical_range = (m_traceArray[trace]->bottomEdge-m_traceArray[trace]->topEdge); - + if (m_cursorArray[cursor]->orientation == TQt::Horizontal) { double realCursorPosition = (m_traceArray[trace]->topEdge+((m_cursorArray[cursor]->position/100.0)*vertical_range)-m_traceArray[trace]->offset); TQString deltaText; @@ -1743,7 +1744,12 @@ void TraceWidget::updateCursorText() { } } - m_traceArray[trace]->leftCursorLabel->setText(TQString("<qt><nobr>%2</qt>").arg((m_traceArray[trace]->sampleArray[closest]==0)?"0":"1")); + if (m_traceArray[trace]->sampleArray.count() > 0) { + m_traceArray[trace]->leftCursorLabel->setText(TQString("<qt><nobr>%2</qt>").arg((m_traceArray[trace]->sampleArray[closest]==0)?"0":"1")); + } + else { + m_traceArray[trace]->leftCursorLabel->setText(TQString("<qt><nobr></qt>")); + } } else { // Find closest data point @@ -1751,14 +1757,21 @@ void TraceWidget::updateCursorText() { unsigned int closest = 0; double diff; double distance = DBL_MAX; - for (n=0; n<m_traceArray[trace]->numberOfSamples; n++) { - diff = fabs(m_traceArray[trace]->positionArray[n] - realCursorPosition); - if (diff < distance) { - distance = diff; - closest = n; + if (m_traceArray[trace]->positionArray.count() >= m_traceArray[trace]->numberOfSamples) { + for (n=0; n<m_traceArray[trace]->numberOfSamples; n++) { + diff = fabs(m_traceArray[trace]->positionArray[n] - realCursorPosition); + if (diff < distance) { + distance = diff; + closest = n; + } } } - m_traceArray[trace]->leftCursorLabel->setText(TQString("<qt><nobr>%2</qt>").arg(TraceWidget::prettyFormat(m_traceArray[trace]->sampleArray[closest], m_traceArray[trace]->sampleArray[closest], m_traceArray[trace]->verticalUnits))); + if (m_traceArray[trace]->sampleArray.count() > 0) { + m_traceArray[trace]->leftCursorLabel->setText(TQString("<qt><nobr>%2</qt>").arg(TraceWidget::prettyFormat(m_traceArray[trace]->sampleArray[closest], m_traceArray[trace]->sampleArray[closest], m_traceArray[trace]->verticalUnits))); + } + else { + m_traceArray[trace]->leftCursorLabel->setText(TQString("<qt><nobr></qt>")); + } } } } @@ -2479,8 +2492,7 @@ void TraceWidget::resizeTraceArray(uint newsize) { } } } - else { - m_traceArray.resize(newsize); + else if (newsize < oldcount) { for (uint i=newsize;i<oldcount;i++) { if (m_traceArray[i]->paramLabel) { m_traceLabelLayout->remove(m_traceArray[i]->paramLabel); @@ -2494,7 +2506,9 @@ void TraceWidget::resizeTraceArray(uint newsize) { m_statusLabelLayoutInner->remove(m_traceArray[i]->graphStatusLabelInner); } delete m_traceArray[i]; + m_traceArray[i] = NULL; } + m_traceArray.resize(newsize); } } |