summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/widgets/tracewidget.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-13 14:30:06 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-13 14:30:06 -0500
commit38c51e3a29bab13192ee194e82954885c7dc8bad (patch)
treeb814d7cc0dfbdbe367c6d1330f86efc81f39fe52 /clients/tde/src/widgets/tracewidget.cpp
parentc485c0ef46c7330eba93226ac0ca09415a765d9d (diff)
downloadulab-38c51e3a29bab13192ee194e82954885c7dc8bad.tar.gz
ulab-38c51e3a29bab13192ee194e82954885c7dc8bad.zip
Significant enhancements to trace widget
Diffstat (limited to 'clients/tde/src/widgets/tracewidget.cpp')
-rw-r--r--clients/tde/src/widgets/tracewidget.cpp649
1 files changed, 613 insertions, 36 deletions
diff --git a/clients/tde/src/widgets/tracewidget.cpp b/clients/tde/src/widgets/tracewidget.cpp
index 1fe3ff4..bf0cf92 100644
--- a/clients/tde/src/widgets/tracewidget.cpp
+++ b/clients/tde/src/widgets/tracewidget.cpp
@@ -8,6 +8,7 @@
#include <tqpixmap.h>
#include <tqpainter.h>
+#include <tqpushbutton.h>
#include <tqlabel.h>
#include <tqlayout.h>
@@ -15,8 +16,82 @@
#include <klocale.h>
#define VERIFY_TRACE_ARRAY_SIZE if (traceNumber >= m_traceArray.count()) resizeTraceArray(traceNumber+1);
+#define VERIFY_CURSOR_ARRAY_SIZE if (cursorNumber >= m_cursorArray.count()) resizeCursorArray(cursorNumber+1);
-TraceData::TraceData(TQWidget* labelParent) {
+#define CURSOR_DARKNESS_FACTOR 200
+#define ZOOM_SHADING_DARKNESS_FACTOR 200
+
+TQRectF::TQRectF() {
+ m_valid = false;
+}
+
+TQRectF::TQRectF(double x, double y, double w, double h) {
+ m_x = x;
+ m_y = y;
+ m_w = w;
+ m_h = h;
+ m_valid = true;
+}
+
+double TQRectF::x() const {
+ return m_x;
+}
+
+double TQRectF::y() const {
+ return m_y;
+}
+
+double TQRectF::width() const {
+ return m_w;
+}
+
+double TQRectF::height() const {
+ return m_h;
+}
+
+void TQRectF::setX(double val) {
+ m_x = val;
+ m_valid = true;
+}
+
+void TQRectF::setY(double val) {
+ m_y = val;
+ m_valid = true;
+}
+
+void TQRectF::setWidth(double val) {
+ m_w = val;
+ m_valid = true;
+}
+
+void TQRectF::setHeight(double val) {
+ m_h = val;
+ m_valid = true;
+}
+
+bool TQRectF::isNull() const {
+ return !m_valid;
+}
+
+bool TQRectF::operator!() const {
+ return isNull();
+}
+
+bool TQRectF::operator==(const TQRectF &r1) {
+ bool match = true;
+ if (r1.m_valid != m_valid) match = false;
+ if (r1.m_x != m_x) match = false;
+ if (r1.m_y != m_y) match = false;
+ if (r1.m_w != m_w) match = false;
+ if (r1.m_h != m_h) match = false;
+ return match;
+}
+
+bool TQRectF::operator!=(const TQRectF &r1) {
+ return !operator==(r1);
+}
+
+TraceData::TraceData(TQWidget* labelParent) : TQObject() {
color = TQColor(0, 255, 0);
numberOfSamples = 0;
leftEdge = 0;
@@ -29,14 +104,20 @@ TraceData::TraceData(TQWidget* labelParent) {
enabled = false;
if (labelParent) {
- infoLabel = new TQLabel(labelParent);
- infoLabel->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
- infoLabel->setPaletteForegroundColor(color);
- infoLabel->setAlignment(TQt::AlignHCenter|TQt::AlignVCenter|TQt::SingleLine);
- infoLabel->hide();
+ paramLabel = new TQLabel(labelParent);
+ paramLabel->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
+ paramLabel->setPaletteForegroundColor(color);
+ paramLabel->setAlignment(TQt::AlignHCenter|TQt::AlignVCenter|TQt::SingleLine);
+ paramLabel->hide();
+ graphStatusLabel = new TQLabel(labelParent);
+ graphStatusLabel->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
+ graphStatusLabel->setPaletteForegroundColor(color);
+ graphStatusLabel->setAlignment(TQt::AlignHCenter|TQt::AlignVCenter|TQt::SingleLine);
+ graphStatusLabel->hide();
}
else {
- infoLabel = NULL;
+ paramLabel = NULL;
+ graphStatusLabel = NULL;
}
}
@@ -45,9 +126,6 @@ TraceData::~TraceData() {
}
// RAJA FIXME
-// Add cursor support
-
-// RAJA FIXME
// Add offset (x and y) support
// RAJA FIXME
@@ -56,7 +134,7 @@ TraceData::~TraceData() {
void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_height) {
p->setPen(color);
- if ((bottomEdge != topEdge) && (enabled)) {
+ if ((bottomEdge != topEdge) && (enabled) && (positionArray.count() >= numberOfSamples) && (sampleArray.count() >= numberOfSamples) && (numberOfSamples > 0)) {
// Draw the points
unsigned int n;
int x,y,x2,y2;
@@ -70,6 +148,146 @@ void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_heigh
}
}
+CursorData::CursorData(TraceWidget* parent, TQWidget* labelParent) : TQObject(), parentWidget(parent) {
+ color = TQColor(0, 255, 0);
+ enabled = false;
+ orientation = TQt::Vertical;
+ position = 50;
+ cursorName = i18n("Cursor <?>");
+
+ if (labelParent) {
+ paramLabel = new TQLabel(labelParent);
+ paramLabel->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
+ paramLabel->setPaletteForegroundColor(color);
+ paramLabel->setAlignment(TQt::AlignHCenter|TQt::AlignVCenter|TQt::SingleLine);
+ paramLabel->hide();
+ singleIncrBtn = new TQPushButton(labelParent);
+ singleDecrBtn = new TQPushButton(labelParent);
+ multiIncrBtn = new TQPushButton(labelParent);
+ multiDecrBtn = new TQPushButton(labelParent);
+ singleIncrBtn->setText("+");
+ singleDecrBtn->setText("-");
+ multiIncrBtn->setText("++");
+ multiDecrBtn->setText("--");
+ singleIncrBtn->setAutoRepeat(true);
+ singleDecrBtn->setAutoRepeat(true);
+ multiIncrBtn->setAutoRepeat(true);
+ multiDecrBtn->setAutoRepeat(true);
+ singleIncrBtn->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
+ singleDecrBtn->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
+ multiIncrBtn->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
+ multiDecrBtn->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
+ singleIncrBtn->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
+ singleIncrBtn->setPaletteForegroundColor(color);
+ singleDecrBtn->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
+ singleDecrBtn->setPaletteForegroundColor(color);
+ multiIncrBtn->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
+ multiIncrBtn->setPaletteForegroundColor(color);
+ multiDecrBtn->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
+ multiDecrBtn->setPaletteForegroundColor(color);
+ singleIncrBtn->hide();
+ singleDecrBtn->hide();
+ multiIncrBtn->hide();
+ multiDecrBtn->hide();
+ connect(singleIncrBtn, SIGNAL(clicked()), this, SLOT(movePosOneTick()));
+ connect(singleDecrBtn, SIGNAL(clicked()), this, SLOT(moveNegOneTick()));
+ connect(multiIncrBtn, SIGNAL(clicked()), this, SLOT(movePosMultiTicks()));
+ connect(multiDecrBtn, SIGNAL(clicked()), this, SLOT(moveNegMultiTicks()));
+ }
+ else {
+ paramLabel = NULL;
+ singleIncrBtn = NULL;
+ singleDecrBtn = NULL;
+ multiIncrBtn = NULL;
+ multiDecrBtn = NULL;
+ }
+}
+
+CursorData::~CursorData() {
+ //
+}
+
+void CursorData::drawCursor(TQPainter* p, int graticule_width, int graticule_height) {
+ p->setPen(color.dark(parentWidget->m_cursorDarkness));
+
+ if (orientation == TQt::Vertical) {
+ int x = abs(((position)/(100.0))*(graticule_width));
+ p->drawLine(x, 0, x, graticule_height);
+ }
+ else {
+ int y = abs(((position)/(100.0))*(graticule_height));
+ p->drawLine(0, y, graticule_width, y);
+ }
+}
+
+void CursorData::movePosOneTick() {
+ double increment;
+ if (orientation == TQt::Horizontal) {
+ increment = 100.0/parentWidget->m_graticuleWidget->height();
+ }
+ else {
+ increment = 100.0/parentWidget->m_graticuleWidget->width();
+ }
+ position += increment;
+ if (position < 0.0) position = 0.0;
+ if (position > 100.0) position = 100.0;
+
+ parentWidget->updateCursorText();
+ parentWidget->m_graticuleWidget->updateGraticule();
+ parentWidget->m_graticuleWidget->repaint(true);
+}
+
+void CursorData::moveNegOneTick() {
+ double increment;
+ if (orientation == TQt::Horizontal) {
+ increment = 100.0/parentWidget->m_graticuleWidget->height();
+ }
+ else {
+ increment = 100.0/parentWidget->m_graticuleWidget->width();
+ }
+ position -= increment;
+ if (position < 0.0) position = 0.0;
+ if (position > 100.0) position = 100.0;
+
+ parentWidget->updateCursorText();
+ parentWidget->m_graticuleWidget->updateGraticule();
+ parentWidget->m_graticuleWidget->repaint(true);
+}
+
+void CursorData::movePosMultiTicks() {
+ double increment;
+ if (orientation == TQt::Horizontal) {
+ increment = 100.0/parentWidget->m_graticuleWidget->height();
+ }
+ else {
+ increment = 100.0/parentWidget->m_graticuleWidget->width();
+ }
+ position += (increment*10.0);
+ if (position < 0.0) position = 0.0;
+ if (position > 100.0) position = 100.0;
+
+ parentWidget->updateCursorText();
+ parentWidget->m_graticuleWidget->updateGraticule();
+ parentWidget->m_graticuleWidget->repaint(true);
+}
+
+void CursorData::moveNegMultiTicks() {
+ double increment;
+ if (orientation == TQt::Horizontal) {
+ increment = 100.0/parentWidget->m_graticuleWidget->height();
+ }
+ else {
+ increment = 100.0/parentWidget->m_graticuleWidget->width();
+ }
+ position -= (increment*10.0);
+ if (position < 0.0) position = 0.0;
+ if (position > 100.0) position = 100.0;
+
+ parentWidget->updateCursorText();
+ parentWidget->m_graticuleWidget->updateGraticule();
+ parentWidget->m_graticuleWidget->repaint(true);
+}
+
GraticuleWidget::GraticuleWidget(TraceWidget* parent, const char* name) : TQWidget(parent, name),
m_base(parent),
m_graticulePixmap(0) {
@@ -78,6 +296,7 @@ GraticuleWidget::GraticuleWidget(TraceWidget* parent, const char* name) : TQWidg
setPaletteBackgroundColor(TQt::black);
setPaletteForegroundColor(TQColor(0,128,0));
+ setMouseTracking(true);
}
GraticuleWidget::~GraticuleWidget() {
@@ -97,18 +316,18 @@ void GraticuleWidget::updateGraticule() {
p.setPen(TQPen(foregroundColor(), 1, TQt::SolidLine));
p.fillRect(0, 0, m_graticulePixmap->width(), m_graticulePixmap->height(), backgroundColor());
p.setPen(TQPen(foregroundColor(), 1, TQt::DotLine));
- if (m_base->m_vertDivs > 0) {
- s = m_graticulePixmap->width() / m_base->m_vertDivs;
+ if (m_base->m_horizDivs > 0) {
+ s = m_graticulePixmap->width() / m_base->m_horizDivs;
x = 0;
- for (d=0; d<m_base->m_vertDivs; d++) {
+ for (d=0; d<m_base->m_horizDivs; d++) {
p.drawLine(x, 0, x, m_graticulePixmap->height());
x += s;
}
}
- if (m_base->m_horizDivs > 0) {
- s = m_graticulePixmap->height() / m_base->m_horizDivs;
+ if (m_base->m_vertDivs > 0) {
+ s = m_graticulePixmap->height() / m_base->m_vertDivs;
y = 0;
- for (d=0; d<m_base->m_horizDivs; d++) {
+ for (d=0; d<m_base->m_vertDivs; d++) {
p.drawLine(0, y, m_graticulePixmap->width(), y);
y += s;
}
@@ -116,6 +335,14 @@ void GraticuleWidget::updateGraticule() {
p.setPen(TQPen(foregroundColor(), 1, TQt::SolidLine));
p.drawRect(0, 0, m_graticulePixmap->width(), m_graticulePixmap->height());
+ // If there are 4 or more cursors, lightly shade the area returned by ZoomBox
+ TQRectF zoomBox = m_base->zoomBox();
+ if (!zoomBox.isNull()) {
+ // Translate zoombox coordinates to local drawing coordinates
+ TQRect drawingRect(abs(((zoomBox.x())/(100.0))*(width())), abs(((zoomBox.y())/(100.0))*(height())), abs(((zoomBox.width())/(100.0))*(width())), abs(((zoomBox.height())/(100.0))*(height())));
+ p.fillRect(drawingRect, TQBrush(foregroundColor().dark(m_base->m_zoomBoxDarkness), TQt::BDiagPattern));
+ }
+
// Repaint the widget
repaint();
}
@@ -131,6 +358,11 @@ void GraticuleWidget::paintEvent(TQPaintEvent*) {
for (uint trace=0;trace<m_base->m_traceArray.count();trace++) {
m_base->m_traceArray[trace]->drawTrace(&p, m_graticulePixmap->width(), m_graticulePixmap->height());
}
+
+ // Draw the cursors
+ for (uint cursor=0;cursor<m_base->m_cursorArray.count();cursor++) {
+ m_base->m_cursorArray[cursor]->drawCursor(&p, m_graticulePixmap->width(), m_graticulePixmap->height());
+ }
}
else {
p.fillRect(x(), y(), width(), height(), backgroundColor());
@@ -141,16 +373,72 @@ void GraticuleWidget::resizeEvent(TQResizeEvent *) {
updateGraticule();
}
+void GraticuleWidget::mousePressEvent(TQMouseEvent *) {
+ //
+}
+
+void GraticuleWidget::mouseReleaseEvent(TQMouseEvent *) {
+ //
+}
+
+void GraticuleWidget::mouseDoubleClickEvent(TQMouseEvent *) {
+ //
+}
+
+void GraticuleWidget::mouseMoveEvent(TQMouseEvent *e) {
+ // Print current cursor location for all traces
+ if ((e->x() < width()) && (e->y() < height())) {
+ for (uint trace=0;trace<m_base->m_traceArray.count();trace++) {
+ // Calculate location
+ double scaledYPos = (e->y()*100.0)/height();
+ double scaledXPos = (e->x()*100.0)/width();
+ double horizontal_range = (m_base->m_traceArray[trace]->rightEdge-m_base->m_traceArray[trace]->leftEdge);
+ double vertical_range = (m_base->m_traceArray[trace]->bottomEdge-m_base->m_traceArray[trace]->topEdge);
+ double realCursorYPosition = (m_base->m_traceArray[trace]->topEdge+((scaledYPos/100.0)*vertical_range));
+ double realCursorXPosition = (m_base->m_traceArray[trace]->leftEdge+((scaledXPos/100.0)*horizontal_range));
+ m_base->m_traceArray[trace]->graphStatusLabel->setText(TQString("<qt><nobr>%1<br>@%2,%3</qt>").arg(m_base->m_traceArray[trace]->traceName).arg(TraceWidget::prettyFormat(realCursorXPosition, horizontal_range, m_base->m_traceArray[trace]->horizontalUnits)).arg(TraceWidget::prettyFormat(realCursorYPosition, vertical_range, m_base->m_traceArray[trace]->verticalUnits)));
+ }
+ }
+ else {
+ for (uint trace=0;trace<m_base->m_traceArray.count();trace++) {
+ m_base->m_traceArray[trace]->graphStatusLabel->setText("");
+ }
+ }
+}
+
+void GraticuleWidget::enterEvent(TQEvent *) {
+ //
+}
+
+void GraticuleWidget::leaveEvent(TQEvent *) {
+ for (uint trace=0;trace<m_base->m_traceArray.count();trace++) {
+ m_base->m_traceArray[trace]->graphStatusLabel->setText("");
+ }
+}
+
TraceWidget::TraceWidget(TQWidget* parent, const char* name) : TQWidget(parent, name),
m_horizDivs(0),
- m_vertDivs(0) {
+ m_vertDivs(0),
+ m_cursorDarkness(CURSOR_DARKNESS_FACTOR),
+ m_zoomBoxDarkness(ZOOM_SHADING_DARKNESS_FACTOR),
+ m_zoomBoxEnabled(false) {
setBackgroundMode(NoBackground);
- m_primaryLayout = new TQVBoxLayout(this);
+ m_primaryLayout = new TQGridLayout(this);
m_graticuleWidget = new GraticuleWidget(this);
- m_primaryLayout->addWidget(m_graticuleWidget);
- m_traceLabelLayout = new TQGridLayout(m_primaryLayout);
+ m_primaryLayout->addWidget(m_graticuleWidget, 0, 0);
+ m_rightPaneLayout = new TQGridLayout;
+ m_traceLabelLayout = new TQGridLayout;
+ m_infoLabelLayout = new TQGridLayout;
+ m_cursorLabelLayout = new TQGridLayout;
+ m_statusLabelLayout = new TQGridLayout;
+ m_primaryLayout->addLayout(m_traceLabelLayout, 1, 0);
+ m_primaryLayout->addLayout(m_rightPaneLayout, 0, 1);
+ m_primaryLayout->addLayout(m_statusLabelLayout, 1, 1);
+ m_rightPaneLayout->addLayout(m_cursorLabelLayout, 0, 0);
+ m_rightPaneLayout->addLayout(m_infoLabelLayout, 1, 0);
m_traceLabelLayout->addItem(new TQSpacerItem(0, 0, TQSizePolicy::Expanding, TQSizePolicy::Minimum), 0, 255);
+ m_rightPaneLayout->addItem(new TQSpacerItem(0, 0, TQSizePolicy::Minimum, TQSizePolicy::Expanding), 255, 0);
setPaletteBackgroundColor(TQt::black);
setPaletteForegroundColor(TQColor(0,128,0));
@@ -177,23 +465,33 @@ void TraceWidget::setNumberOfHorizontalDivisions(unsigned int divisions) {
m_horizDivs = divisions;
m_graticuleWidget->updateGraticule();
updateTraceText();
+ updateCursorText();
}
void TraceWidget::setNumberOfVerticalDivisions(unsigned int divisions) {
m_vertDivs = divisions;
m_graticuleWidget->updateGraticule();
updateTraceText();
+ updateCursorText();
}
-void TraceWidget::setDisplayLimits(uint traceNumber, double x, double y, double w, double h) {
+void TraceWidget::setDisplayLimits(uint traceNumber, TQRectF limits) {
VERIFY_TRACE_ARRAY_SIZE
- m_traceArray[traceNumber]->leftEdge = x;
- m_traceArray[traceNumber]->rightEdge = w;
- m_traceArray[traceNumber]->topEdge = y;
- m_traceArray[traceNumber]->bottomEdge = h;
+ m_traceArray[traceNumber]->leftEdge = limits.x();
+ m_traceArray[traceNumber]->rightEdge = limits.width();
+ m_traceArray[traceNumber]->topEdge = limits.y();
+ m_traceArray[traceNumber]->bottomEdge = limits.height();
+ m_graticuleWidget->repaint(true);
updateTraceText();
+ updateCursorText();
+}
+
+TQRectF TraceWidget::displayLimits(uint traceNumber) {
+ VERIFY_TRACE_ARRAY_SIZE
+
+ return TQRectF(m_traceArray[traceNumber]->leftEdge, m_traceArray[traceNumber]->topEdge, m_traceArray[traceNumber]->rightEdge, m_traceArray[traceNumber]->bottomEdge);
}
void TraceWidget::updateTraceText() {
@@ -209,10 +507,39 @@ void TraceWidget::updateTraceText() {
double vertical_units_per_division;
horizontal_units_per_division = fabs(m_traceArray[trace]->rightEdge-m_traceArray[trace]->leftEdge)/m_horizDivs;
- vertical_units_per_division = fabs(m_traceArray[trace]->topEdge-m_traceArray[trace]->bottomEdge)/m_vertDivs;
- m_traceArray[trace]->infoLabel->setPaletteBackgroundColor(paletteBackgroundColor());
- m_traceArray[trace]->infoLabel->setPaletteForegroundColor(m_traceArray[trace]->color);
- m_traceArray[trace]->infoLabel->setText(TQString("<qt>%1<br>%2 %3/div<br>%4 %5/div</qt>").arg(m_traceArray[trace]->traceName).arg(horizontal_units_per_division).arg(m_traceArray[trace]->horizontalUnits).arg(vertical_units_per_division).arg(m_traceArray[trace]->verticalUnits));
+ vertical_units_per_division = fabs(m_traceArray[trace]->bottomEdge-m_traceArray[trace]->topEdge)/m_vertDivs;
+ m_traceArray[trace]->paramLabel->setPaletteBackgroundColor(paletteBackgroundColor());
+ m_traceArray[trace]->paramLabel->setPaletteForegroundColor(m_traceArray[trace]->color);
+ m_traceArray[trace]->graphStatusLabel->setPaletteBackgroundColor(paletteBackgroundColor());
+ m_traceArray[trace]->graphStatusLabel->setPaletteForegroundColor(m_traceArray[trace]->color);
+ m_traceArray[trace]->paramLabel->setText(TQString("<qt><nobr>%1<br>%2/div<br>%3/div</qt>").arg(m_traceArray[trace]->traceName).arg(prettyFormat(horizontal_units_per_division, horizontal_units_per_division, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(vertical_units_per_division, vertical_units_per_division, m_traceArray[trace]->verticalUnits)));
+ }
+}
+
+void TraceWidget::updateCursorText() {
+ for (uint cursor=0;cursor<m_cursorArray.count();cursor++) {
+ m_cursorArray[cursor]->paramLabel->setPaletteBackgroundColor(paletteBackgroundColor());
+ m_cursorArray[cursor]->paramLabel->setPaletteForegroundColor(m_cursorArray[cursor]->color);
+ TQString cursorText;
+ cursorText = TQString("<qt><nobr>%1").arg(m_cursorArray[cursor]->cursorName);
+ // If this is a horizontal cursor, list all vertical positions for all channels
+ // If this is a vertical cursor, list the horizontal positions for all channels
+ for (uint trace=0;trace<m_traceArray.count();trace++) {
+ 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));
+ cursorText.append(TQString("<br>%1: %2").arg(m_traceArray[trace]->traceName).arg(prettyFormat(realCursorPosition, vertical_range, m_traceArray[trace]->verticalUnits)));
+ }
+ else {
+ double realCursorPosition = (m_traceArray[trace]->leftEdge+((m_cursorArray[cursor]->position/100.0)*horizontal_range));
+ cursorText.append(TQString("<br>%1: %2").arg(m_traceArray[trace]->traceName).arg(prettyFormat(realCursorPosition, horizontal_range, m_traceArray[trace]->horizontalUnits)));
+ }
+ }
+
+ cursorText.append("</qt>");
+ m_cursorArray[cursor]->paramLabel->setText(cursorText);
}
}
@@ -227,6 +554,8 @@ void TraceWidget::setSamples(uint traceNumber, TQDoubleArray& tqda) {
m_traceArray[traceNumber]->sampleArray = tqda;
m_traceArray[traceNumber]->numberOfSamples = tqda.size();
+
+ m_graticuleWidget->repaint(true);
}
TQDoubleArray& TraceWidget::positions(uint traceNumber) {
@@ -240,6 +569,8 @@ void TraceWidget::setPositions(uint traceNumber, TQDoubleArray& tqda) {
m_traceArray[traceNumber]->positionArray = tqda;
m_traceArray[traceNumber]->numberOfSamples = tqda.size();
+
+ m_graticuleWidget->repaint(true);
}
TQColor& TraceWidget::traceColor(uint traceNumber) {
@@ -254,6 +585,7 @@ void TraceWidget::setTraceColor(uint traceNumber, TQColor& color) {
m_traceArray[traceNumber]->color = color;
m_graticuleWidget->updateGraticule();
+ m_graticuleWidget->repaint(true);
updateTraceText();
}
@@ -263,18 +595,22 @@ bool TraceWidget::traceEnabled(uint traceNumber) {
return m_traceArray[traceNumber]->enabled;
}
-void TraceWidget::setTraceEnabled(uint traceNumber, bool enabled) {
+void TraceWidget::setTraceEnabled(uint traceNumber, bool enabled, bool showText) {
VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->enabled = enabled;
- if (enabled) {
- m_traceArray[traceNumber]->infoLabel->show();
+ if ((enabled) && (showText)) {
+ m_traceArray[traceNumber]->paramLabel->show();
+ m_traceArray[traceNumber]->graphStatusLabel->show();
+
}
else {
- m_traceArray[traceNumber]->infoLabel->hide();
+ m_traceArray[traceNumber]->paramLabel->hide();
+ m_traceArray[traceNumber]->graphStatusLabel->hide();
}
m_graticuleWidget->updateGraticule();
+ m_graticuleWidget->repaint(true);
updateTraceText();
}
@@ -317,6 +653,210 @@ void TraceWidget::setTraceVerticalUnits(uint traceNumber, TQString units) {
updateTraceText();
}
+double TraceWidget::cursorPosition(uint cursorNumber) {
+ VERIFY_CURSOR_ARRAY_SIZE
+
+ return m_cursorArray[cursorNumber]->position;
+}
+
+void TraceWidget::setCursorPosition(uint cursorNumber, double position) {
+ VERIFY_CURSOR_ARRAY_SIZE
+
+ if (position < 0.0) position = 0.0;
+ if (position > 100.0) position = 100.0;
+
+ m_cursorArray[cursorNumber]->position = position;
+ updateCursorText();
+}
+
+bool TraceWidget::cursorEnabled(uint cursorNumber) {
+ VERIFY_CURSOR_ARRAY_SIZE
+
+ return m_cursorArray[cursorNumber]->enabled;
+}
+
+void TraceWidget::setCursorEnabled(uint cursorNumber, bool enabled) {
+ VERIFY_CURSOR_ARRAY_SIZE
+
+ m_cursorArray[cursorNumber]->enabled = enabled;
+ if (enabled) {
+ m_cursorArray[cursorNumber]->paramLabel->show();
+ m_cursorArray[cursorNumber]->singleIncrBtn->show();
+ m_cursorArray[cursorNumber]->singleDecrBtn->show();
+ m_cursorArray[cursorNumber]->multiIncrBtn->show();
+ m_cursorArray[cursorNumber]->multiDecrBtn->show();
+ }
+ else {
+ m_cursorArray[cursorNumber]->paramLabel->hide();
+ m_cursorArray[cursorNumber]->singleIncrBtn->hide();
+ m_cursorArray[cursorNumber]->singleDecrBtn->hide();
+ m_cursorArray[cursorNumber]->multiIncrBtn->hide();
+ m_cursorArray[cursorNumber]->multiDecrBtn->hide();
+ }
+
+ m_graticuleWidget->updateGraticule();
+ updateCursorText();
+}
+
+TQString TraceWidget::cursorName(uint cursorNumber) {
+ VERIFY_CURSOR_ARRAY_SIZE
+
+ return m_cursorArray[cursorNumber]->cursorName;
+}
+
+void TraceWidget::setCursorName(uint cursorNumber, TQString name) {
+ VERIFY_CURSOR_ARRAY_SIZE
+
+ m_cursorArray[cursorNumber]->cursorName = name;
+ updateCursorText();
+}
+
+TQt::Orientation TraceWidget::cursorOrientation(uint cursorNumber) {
+ VERIFY_CURSOR_ARRAY_SIZE
+
+ return m_cursorArray[cursorNumber]->orientation;
+}
+
+void TraceWidget::setCursorOrientation(uint cursorNumber, TQt::Orientation orient) {
+ VERIFY_CURSOR_ARRAY_SIZE
+
+ m_cursorArray[cursorNumber]->orientation = orient;
+ updateCursorText();
+}
+
+void TraceWidget::setNumberOfTraces(uint traceNumber) {
+ resizeTraceArray(traceNumber);
+}
+
+void TraceWidget::setNumberOfCursors(uint cursorNumber) {
+ resizeCursorArray(cursorNumber);
+}
+
+TQRectF TraceWidget::zoomBox() {
+ uint i;
+
+ if ((m_cursorArray.count() < 4) || (!m_zoomBoxEnabled)) {
+ if (!m_zoomBoxPrev.isNull()) {
+ m_zoomBoxPrev = TQRectF();
+ emit(zoomBoxChanged(m_zoomBoxPrev));
+ }
+ return m_zoomBoxPrev;
+ }
+ else {
+ // Find the first two horizontal and first two vertical cursors
+ // If two of each cannot be found, return TQRectF()
+ double horiz[2];
+ double vert[2];
+ int j = 0;
+ int k = 0;
+ for (i=0;i<m_cursorArray.count(); i++) {
+ if (m_cursorArray[i]->orientation == TQt::Horizontal) {
+ if (j<2) {
+ vert[j] = m_cursorArray[i]->position;
+ j++;
+ }
+ }
+ else {
+ if (k<2) {
+ horiz[k] = m_cursorArray[i]->position;
+ k++;
+ }
+ }
+ if ((j>1) && (k>1)) {
+ break;
+ }
+ }
+ if ((j>1) && (k>1)) {
+ // Calculate zoom box
+ double leftBound = (horiz[0] < horiz[1])?horiz[0]:horiz[1];
+ double topBound = (vert[0] < vert[1])?vert[0]:vert[1];
+ TQRectF newRect(leftBound, topBound, fabs(horiz[0]-horiz[1]), fabs(vert[0]-vert[1]));
+ if (m_zoomBoxPrev != newRect) {
+ m_zoomBoxPrev = newRect;
+ emit(zoomBoxChanged(m_zoomBoxPrev));
+ }
+ return m_zoomBoxPrev;
+ }
+ else {
+ if (!m_zoomBoxPrev.isNull()) {
+ m_zoomBoxPrev = TQRectF();
+ emit(zoomBoxChanged(m_zoomBoxPrev));
+ }
+ return m_zoomBoxPrev;
+ }
+ }
+}
+
+void TraceWidget::setZoomBoxEnabled(bool enabled) {
+ m_zoomBoxEnabled = enabled;
+ m_graticuleWidget->updateGraticule();
+}
+
+TQString TraceWidget::prettyFormat(double value, double rangeDetectValue, TQString baseUnits, unsigned int precision) {
+ TQString result;
+ TQString unitMultiplier;
+ double valueMultiplier;
+
+ if (fabs(rangeDetectValue) < 1e-9) {
+ unitMultiplier = "p";
+ valueMultiplier = 1e+12;
+ }
+ else if (fabs(rangeDetectValue) < 1e-6) {
+ unitMultiplier = "n";
+ valueMultiplier = 1e+9;
+ }
+ else if (fabs(rangeDetectValue) < 1e-3) {
+ unitMultiplier = "u";
+ valueMultiplier = 1e+6;
+ }
+ else if (fabs(rangeDetectValue) < 1e-0) {
+ unitMultiplier = "m";
+ valueMultiplier = 1e+3;
+ }
+ else if (fabs(rangeDetectValue) < 1e+3) {
+ unitMultiplier = "";
+ valueMultiplier = 1e+0;
+ }
+ else if (fabs(rangeDetectValue) < 1e+6) {
+ unitMultiplier = "k";
+ valueMultiplier = 1e-3;
+ }
+ else if (fabs(rangeDetectValue) < 1e+9) {
+ unitMultiplier = "M";
+ valueMultiplier = 1e-6;
+ }
+ else if (fabs(rangeDetectValue) < 1e+12) {
+ unitMultiplier = "G";
+ valueMultiplier = 1e-9;
+ }
+ else if (fabs(rangeDetectValue) < 1e+15) {
+ unitMultiplier = "T";
+ valueMultiplier = 1e-12;
+ }
+ else {
+ unitMultiplier = "";
+ valueMultiplier = 1.0;
+ }
+
+ double scaledValue = value * valueMultiplier;
+ TQString valueString = TQString("%1").arg(scaledValue, 0, 'g', precision);
+ if (valueString.contains("-") && valueString.contains(".")) {
+ valueString.truncate(precision+2);
+ }
+ else if (valueString.contains("-")) {
+ valueString.truncate(precision+1);
+ }
+ else if (valueString.contains(".")) {
+ valueString.truncate(precision+1);
+ }
+ else {
+ valueString.truncate(precision);
+ }
+ result = TQString("%1%2%3").arg(valueString).arg(unitMultiplier).arg(baseUnits);
+
+ return result;
+}
+
void TraceWidget::resizeTraceArray(uint newsize) {
uint oldcount = m_traceArray.count();
@@ -324,14 +864,51 @@ void TraceWidget::resizeTraceArray(uint newsize) {
m_traceArray.resize(newsize);
for (uint i=oldcount;i<newsize;i++) {
m_traceArray[i] = new TraceData(this);
- m_traceLabelLayout->addWidget(m_traceArray[i]->infoLabel, 0, i);
+ if (m_traceArray[i]->paramLabel) {
+ m_traceLabelLayout->addWidget(m_traceArray[i]->paramLabel, 0, i);
+ m_statusLabelLayout->addWidget(m_traceArray[i]->graphStatusLabel, i, 0);
+ }
}
}
else {
m_traceArray.resize(newsize);
for (uint i=newsize;i<oldcount;i++) {
- m_traceLabelLayout->remove(m_traceArray[i]->infoLabel);
+ if (m_traceArray[i]->paramLabel) {
+ m_traceLabelLayout->remove(m_traceArray[i]->paramLabel);
+ m_traceLabelLayout->remove(m_traceArray[i]->graphStatusLabel);
+ }
delete m_traceArray[i];
}
}
+}
+
+void TraceWidget::resizeCursorArray(uint newsize) {
+ uint oldcount = m_cursorArray.count();
+
+ if (newsize > oldcount) {
+ m_cursorArray.resize(newsize);
+ for (uint i=oldcount;i<newsize;i++) {
+ m_cursorArray[i] = new CursorData(this, this);
+ if (m_cursorArray[i]->paramLabel) {
+ m_cursorLabelLayout->addMultiCellWidget(m_cursorArray[i]->paramLabel, i*2, i*2, 0, 3);
+ m_cursorLabelLayout->addMultiCellWidget(m_cursorArray[i]->multiIncrBtn, (i*2)+1, (i*2)+1, 0, 0);
+ m_cursorLabelLayout->addMultiCellWidget(m_cursorArray[i]->singleIncrBtn, (i*2)+1, (i*2)+1, 1, 1);
+ m_cursorLabelLayout->addMultiCellWidget(m_cursorArray[i]->singleDecrBtn, (i*2)+1, (i*2)+1, 2, 2);
+ m_cursorLabelLayout->addMultiCellWidget(m_cursorArray[i]->multiDecrBtn, (i*2)+1, (i*2)+1, 3, 3);
+ }
+ }
+ }
+ else {
+ m_cursorArray.resize(newsize);
+ for (uint i=newsize;i<oldcount;i++) {
+ if (m_cursorArray[i]->paramLabel) {
+ m_cursorLabelLayout->remove(m_cursorArray[i]->paramLabel);
+ m_cursorLabelLayout->remove(m_cursorArray[i]->multiIncrBtn);
+ m_cursorLabelLayout->remove(m_cursorArray[i]->singleIncrBtn);
+ m_cursorLabelLayout->remove(m_cursorArray[i]->singleDecrBtn);
+ m_cursorLabelLayout->remove(m_cursorArray[i]->multiDecrBtn);
+ }
+ delete m_cursorArray[i];
+ }
+ }
} \ No newline at end of file