Add trace offset support

master
Timothy Pearson 13 years ago
parent 38c51e3a29
commit 34a27d54d6

@ -95,6 +95,7 @@ CommAnalyzerPart::CommAnalyzerPart( TQWidget *parentWidget, const char *widgetNa
m_base->traceZoomWidget->setTraceHorizontalUnits(0, "Hz");
m_base->traceZoomWidget->setTraceVerticalUnits(0, "dBm");
connect(m_traceWidget, SIGNAL(zoomBoxChanged(const TQRectF&)), this, SLOT(updateZoomWidgetLimits(const TQRectF&)));
connect(m_traceWidget, SIGNAL(offsetChanged(uint, double)), m_base->traceZoomWidget, SLOT(setTraceOffset(uint, double)));
m_base->saRefLevel->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
m_base->saRefLevel->setFloatMin(-128);
@ -575,8 +576,8 @@ void CommAnalyzerPart::mainEventLoop() {
m_traceWidget->setSamples(0, trace);
m_base->traceZoomWidget->setSamples(0, trace);
postProcessTrace();
m_traceWidget->repaint();
m_base->traceZoomWidget->repaint();
m_traceWidget->repaint(true);
m_base->traceZoomWidget->repaint(true);
}
if (result == "ACK") {
@ -702,9 +703,6 @@ void CommAnalyzerPart::updateZoomWidgetLimits(const TQRectF& zoomRect) {
TQRectF zoomLimitsRect((fullZoomRect.x()+(widthSpan*(zoomRect.x()/100.0))), (fullZoomRect.y()+(heightSpan*(zoomRect.y()/100.0))), (fullZoomRect.x()+(widthSpan*((zoomRect.x()/100.0)+(zoomRect.width()/100.0)))), (fullZoomRect.y()+(heightSpan*((zoomRect.y()/100.0)+(zoomRect.height()/100.0)))));
printf("[RAJA DEBUG 760.0] Current full limits: x1: %f y1: %f x2: %f y2: %f\n\r", fullZoomRect.x(), fullZoomRect.y(), fullZoomRect.width(), fullZoomRect.height()); fflush(stdout);
printf("[RAJA DEBUG 760.1] Current zoom limits: x1: %f y1: %f x2: %f y2: %f\n\r", zoomLimitsRect.x(), zoomLimitsRect.y(), zoomLimitsRect.width(), zoomLimitsRect.height()); fflush(stdout);
m_base->traceZoomWidget->setDisplayLimits(0, zoomLimitsRect);
}
@ -712,7 +710,6 @@ void CommAnalyzerPart::updateGraticule() {
m_traceWidget->setNumberOfSamples(0, m_samplesInTrace);
m_traceWidget->setNumberOfHorizontalDivisions(m_hdivs);
m_traceWidget->setNumberOfVerticalDivisions(m_vdivs);
printf("[RAJA DEBUG 750.0] m_hdivs: %d m_vdivs: %d m_vscale: %E\n\r", m_hdivs, m_vdivs, m_vscale); fflush(stdout);
m_base->traceZoomWidget->setNumberOfSamples(0, m_samplesInTrace);
m_base->traceZoomWidget->setNumberOfHorizontalDivisions(m_hdivs);
m_base->traceZoomWidget->setNumberOfVerticalDivisions(m_vdivs);

@ -9,6 +9,7 @@
#include <tqpixmap.h>
#include <tqpainter.h>
#include <tqpushbutton.h>
#include <tqtoolbutton.h>
#include <tqlabel.h>
#include <tqlayout.h>
@ -91,9 +92,10 @@ bool TQRectF::operator!=(const TQRectF &r1) {
return !operator==(r1);
}
TraceData::TraceData(TQWidget* labelParent) : TQObject() {
TraceData::TraceData(TraceWidget* parent, TQWidget* labelParent) : TQObject(), parentWidget(parent) {
color = TQColor(0, 255, 0);
numberOfSamples = 0;
offset = 0.0;
leftEdge = 0;
rightEdge = 0;
topEdge = 0;
@ -114,10 +116,44 @@ TraceData::TraceData(TQWidget* labelParent) : TQObject() {
graphStatusLabel->setPaletteForegroundColor(color);
graphStatusLabel->setAlignment(TQt::AlignHCenter|TQt::AlignVCenter|TQt::SingleLine);
graphStatusLabel->hide();
graphStatusLabelInner = new TQLabel(labelParent);
graphStatusLabelInner->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
graphStatusLabelInner->setPaletteForegroundColor(color);
graphStatusLabelInner->setAlignment(TQt::AlignHCenter|TQt::AlignVCenter|TQt::SingleLine);
graphStatusLabelInner->hide();
singleIncrBtn = new TQToolButton(TQt::UpArrow, labelParent);
singleDecrBtn = new TQToolButton(TQt::DownArrow, labelParent);
posResetBtn = new TQToolButton(labelParent);
posResetBtn->setText("0");
singleIncrBtn->setFixedSize(16,16);
singleDecrBtn->setFixedSize(16,16);
posResetBtn->setFixedSize(16,16);
singleIncrBtn->setAutoRepeat(true);
singleDecrBtn->setAutoRepeat(true);
posResetBtn->setAutoRepeat(false);
singleIncrBtn->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
singleDecrBtn->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
posResetBtn->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
singleIncrBtn->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
singleIncrBtn->setPaletteForegroundColor(color);
singleDecrBtn->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
singleDecrBtn->setPaletteForegroundColor(color);
posResetBtn->setPaletteBackgroundColor(labelParent->paletteBackgroundColor());
posResetBtn->setPaletteForegroundColor(color);
singleIncrBtn->hide();
singleDecrBtn->hide();
posResetBtn->hide();
connect(singleIncrBtn, SIGNAL(clicked()), this, SLOT(movePosOneTick()));
connect(singleDecrBtn, SIGNAL(clicked()), this, SLOT(moveNegOneTick()));
connect(posResetBtn, SIGNAL(clicked()), this, SLOT(resetVPosition()));
}
else {
paramLabel = NULL;
graphStatusLabel = NULL;
graphStatusLabelInner = NULL;
singleIncrBtn = NULL;
singleDecrBtn = NULL;
posResetBtn = NULL;
}
}
@ -125,12 +161,6 @@ TraceData::~TraceData() {
//
}
// RAJA FIXME
// Add offset (x and y) support
// RAJA FIXME
// Add scaling support
void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_height) {
p->setPen(color);
@ -139,14 +169,44 @@ void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_heigh
unsigned int n;
int x,y,x2,y2;
for (n=0; n<numberOfSamples-1; n++) {
x = abs(((positionArray[n]-leftEdge)/(rightEdge-leftEdge))*(graticule_width));
y = abs(((sampleArray[n]-topEdge)/(bottomEdge-topEdge))*(graticule_height));
x2 = abs(((positionArray[n+1]-leftEdge)/(rightEdge-leftEdge))*(graticule_width));
y2 = abs(((sampleArray[n+1]-topEdge)/(bottomEdge-topEdge))*(graticule_height));
x = (((positionArray[n]-leftEdge)/(rightEdge-leftEdge))*(graticule_width));
y = ((((sampleArray[n]+offset)-topEdge)/(bottomEdge-topEdge))*(graticule_height));
x2 = (((positionArray[n+1]-leftEdge)/(rightEdge-leftEdge))*(graticule_width));
y2 = ((((sampleArray[n+1]+offset)-topEdge)/(bottomEdge-topEdge))*(graticule_height));
if ((x > 0) && (x < graticule_width) && (y > 0) && (y < graticule_height) && (x2 > 0) && (x2 < graticule_width) && (y2 > 0) && (y2 < graticule_height)) {
p->drawLine(x, y, x2, y2);
}
}
}
}
void TraceData::movePosOneTick() {
double increment;
increment = (bottomEdge-topEdge)/parentWidget->m_graticuleWidget->height();
offset -= increment;
emit(offsetChanged(offset));
parentWidget->updateTraceText();
parentWidget->m_graticuleWidget->repaint(true);
}
void TraceData::moveNegOneTick() {
double increment;
increment = (bottomEdge-topEdge)/parentWidget->m_graticuleWidget->height();
offset += increment;
emit(offsetChanged(offset));
parentWidget->updateTraceText();
parentWidget->m_graticuleWidget->repaint(true);
}
void TraceData::resetVPosition() {
offset = 0.0;
emit(offsetChanged(offset));
parentWidget->updateTraceText();
parentWidget->m_graticuleWidget->repaint(true);
}
CursorData::CursorData(TraceWidget* parent, TQWidget* labelParent) : TQObject(), parentWidget(parent) {
color = TQColor(0, 255, 0);
@ -228,7 +288,12 @@ void CursorData::movePosOneTick() {
else {
increment = 100.0/parentWidget->m_graticuleWidget->width();
}
if (orientation == TQt::Horizontal) {
position -= increment;
}
else {
position += increment;
}
if (position < 0.0) position = 0.0;
if (position > 100.0) position = 100.0;
@ -245,7 +310,12 @@ void CursorData::moveNegOneTick() {
else {
increment = 100.0/parentWidget->m_graticuleWidget->width();
}
if (orientation == TQt::Horizontal) {
position += increment;
}
else {
position -= increment;
}
if (position < 0.0) position = 0.0;
if (position > 100.0) position = 100.0;
@ -262,7 +332,12 @@ void CursorData::movePosMultiTicks() {
else {
increment = 100.0/parentWidget->m_graticuleWidget->width();
}
if (orientation == TQt::Horizontal) {
position -= (increment*10.0);
}
else {
position += (increment*10.0);
}
if (position < 0.0) position = 0.0;
if (position > 100.0) position = 100.0;
@ -279,7 +354,12 @@ void CursorData::moveNegMultiTicks() {
else {
increment = 100.0/parentWidget->m_graticuleWidget->width();
}
if (orientation == TQt::Horizontal) {
position += (increment*10.0);
}
else {
position -= (increment*10.0);
}
if (position < 0.0) position = 0.0;
if (position > 100.0) position = 100.0;
@ -397,11 +477,13 @@ void GraticuleWidget::mouseMoveEvent(TQMouseEvent *e) {
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)));
m_base->m_traceArray[trace]->graphStatusLabelInner->setText(m_base->m_traceArray[trace]->graphStatusLabel->text());
}
}
else {
for (uint trace=0;trace<m_base->m_traceArray.count();trace++) {
m_base->m_traceArray[trace]->graphStatusLabel->setText("");
m_base->m_traceArray[trace]->graphStatusLabelInner->setText(m_base->m_traceArray[trace]->graphStatusLabel->text());
}
}
}
@ -413,6 +495,7 @@ 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("");
m_base->m_traceArray[trace]->graphStatusLabelInner->setText(m_base->m_traceArray[trace]->graphStatusLabel->text());
}
}
@ -426,19 +509,22 @@ TraceWidget::TraceWidget(TQWidget* parent, const char* name) : TQWidget(parent,
m_primaryLayout = new TQGridLayout(this);
m_graticuleWidget = new GraticuleWidget(this);
m_primaryLayout->addWidget(m_graticuleWidget, 0, 0);
m_primaryLayout->addMultiCellWidget(m_graticuleWidget, 0, 254, 0, 254);
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_statusLabelLayoutInner = new TQGridLayout;
m_primaryLayout->addLayout(m_traceLabelLayout, 255, 0);
m_primaryLayout->addLayout(m_rightPaneLayout, 0, 255);
m_primaryLayout->addLayout(m_statusLabelLayout, 255, 255);
m_primaryLayout->addLayout(m_statusLabelLayoutInner, 1, 253);
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);
m_primaryLayout->addItem(new TQSpacerItem(0, 0, TQSizePolicy::Expanding, TQSizePolicy::Minimum), 1, 128);
setPaletteBackgroundColor(TQt::black);
setPaletteForegroundColor(TQColor(0,128,0));
@ -495,24 +581,28 @@ TQRectF TraceWidget::displayLimits(uint traceNumber) {
}
void TraceWidget::updateTraceText() {
// RAJA FIXME
// Display current scaling and offset values for all traces
// RAJA FIXME
// Display upper/lower/left/right boundary values,
// possibly in a different routine
for (uint trace=0;trace<m_traceArray.count();trace++) {
double horizontal_units_per_division;
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]->bottomEdge-m_traceArray[trace]->topEdge)/m_vertDivs;
double horizontal_units_per_division = fabs(m_traceArray[trace]->rightEdge-m_traceArray[trace]->leftEdge)/m_horizDivs;
double vertical_units_per_division = fabs(m_traceArray[trace]->bottomEdge-m_traceArray[trace]->topEdge)/m_vertDivs;
double horizontal_range = (m_traceArray[trace]->rightEdge-m_traceArray[trace]->leftEdge);
double vertical_range = (m_traceArray[trace]->bottomEdge-m_traceArray[trace]->topEdge);
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)));
m_traceArray[trace]->graphStatusLabelInner->setPaletteBackgroundColor(paletteBackgroundColor());
m_traceArray[trace]->graphStatusLabelInner->setPaletteForegroundColor(m_traceArray[trace]->color);
TQString offsetText;
double offset = m_traceArray[trace]->offset;
if (offset != 0) {
if (offset < 0) {
offsetText = TQString(" -%1").arg(prettyFormat(fabs(offset), vertical_range, m_traceArray[trace]->verticalUnits));
}
else {
offsetText = TQString(" +%1").arg(prettyFormat(fabs(offset), vertical_range, m_traceArray[trace]->verticalUnits));
}
}
m_traceArray[trace]->paramLabel->setText(TQString("<qt><nobr>%1%2<br>%3/div%4/div<br>%5,%6<br>%7,%8</qt>").arg(m_traceArray[trace]->traceName).arg(offsetText).arg(prettyFormat(horizontal_units_per_division, horizontal_range, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(vertical_units_per_division, vertical_range, m_traceArray[trace]->verticalUnits)).arg(prettyFormat(m_traceArray[trace]->leftEdge, horizontal_range, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(m_traceArray[trace]->topEdge, vertical_range, m_traceArray[trace]->verticalUnits)).arg(prettyFormat(m_traceArray[trace]->rightEdge, horizontal_range, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(m_traceArray[trace]->bottomEdge, vertical_range, m_traceArray[trace]->verticalUnits)));
}
}
@ -602,11 +692,19 @@ void TraceWidget::setTraceEnabled(uint traceNumber, bool enabled, bool showText)
if ((enabled) && (showText)) {
m_traceArray[traceNumber]->paramLabel->show();
m_traceArray[traceNumber]->graphStatusLabel->show();
m_traceArray[traceNumber]->graphStatusLabelInner->hide();
m_traceArray[traceNumber]->singleIncrBtn->show();
m_traceArray[traceNumber]->singleDecrBtn->show();
m_traceArray[traceNumber]->posResetBtn->show();
}
else {
m_traceArray[traceNumber]->paramLabel->hide();
m_traceArray[traceNumber]->graphStatusLabel->hide();
m_traceArray[traceNumber]->graphStatusLabelInner->show();
m_traceArray[traceNumber]->singleIncrBtn->hide();
m_traceArray[traceNumber]->singleDecrBtn->hide();
m_traceArray[traceNumber]->posResetBtn->hide();
}
m_graticuleWidget->updateGraticule();
@ -839,7 +937,7 @@ TQString TraceWidget::prettyFormat(double value, double rangeDetectValue, TQStri
}
double scaledValue = value * valueMultiplier;
TQString valueString = TQString("%1").arg(scaledValue, 0, 'g', precision);
TQString valueString = TQString("%1").arg(scaledValue, 0, 'f', precision);
if (valueString.contains("-") && valueString.contains(".")) {
valueString.truncate(precision+2);
}
@ -857,16 +955,46 @@ TQString TraceWidget::prettyFormat(double value, double rangeDetectValue, TQStri
return result;
}
void TraceWidget::setTraceOffset(uint traceNumber, double offset) {
VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->offset = offset;
m_graticuleWidget->repaint(true);
updateTraceText();
}
void TraceWidget::processChangedOffset(double offset) {
// Find the sending trace number
const TraceData* sendingTrace = dynamic_cast<const TraceData*>(sender());
if (sendingTrace) {
int tracenumber = -1;
for (uint trace=0;trace<m_traceArray.count();trace++) {
if (sendingTrace == m_traceArray[trace]) {
tracenumber = trace;
}
}
if (tracenumber >= 0) {
emit(offsetChanged(tracenumber, offset));
}
}
}
void TraceWidget::resizeTraceArray(uint newsize) {
uint oldcount = m_traceArray.count();
if (newsize > oldcount) {
m_traceArray.resize(newsize);
for (uint i=oldcount;i<newsize;i++) {
m_traceArray[i] = new TraceData(this);
m_traceArray[i] = new TraceData(this, this);
connect(m_traceArray[i], SIGNAL(offsetChanged(double)), this, SLOT(processChangedOffset(double)));
if (m_traceArray[i]->paramLabel) {
m_traceLabelLayout->addWidget(m_traceArray[i]->paramLabel, 0, i);
m_traceLabelLayout->addMultiCellWidget(m_traceArray[i]->paramLabel, 0, 2, i*2, i*2);
m_traceLabelLayout->addWidget(m_traceArray[i]->singleIncrBtn, 0, (i*2)+1);
m_traceLabelLayout->addWidget(m_traceArray[i]->posResetBtn, 1, (i*2)+1);
m_traceLabelLayout->addWidget(m_traceArray[i]->singleDecrBtn, 2, (i*2)+1);
m_statusLabelLayout->addWidget(m_traceArray[i]->graphStatusLabel, i, 0);
m_statusLabelLayoutInner->addWidget(m_traceArray[i]->graphStatusLabelInner, i, 0);
}
}
}
@ -875,7 +1003,11 @@ void TraceWidget::resizeTraceArray(uint newsize) {
for (uint i=newsize;i<oldcount;i++) {
if (m_traceArray[i]->paramLabel) {
m_traceLabelLayout->remove(m_traceArray[i]->paramLabel);
m_traceLabelLayout->remove(m_traceArray[i]->graphStatusLabel);
m_traceLabelLayout->remove(m_traceArray[i]->singleIncrBtn);
m_traceLabelLayout->remove(m_traceArray[i]->posResetBtn);
m_traceLabelLayout->remove(m_traceArray[i]->singleDecrBtn);
m_statusLabelLayout->remove(m_traceArray[i]->graphStatusLabel);
m_statusLabelLayoutInner->remove(m_traceArray[i]->graphStatusLabelInner);
}
delete m_traceArray[i];
}

@ -10,6 +10,7 @@ class TQLabel;
class TQVBoxLayout;
class TQGridLayout;
class TQPushButton;
class TQToolButton;
class TraceWidget;
class TQRectF
@ -46,14 +47,23 @@ class TraceData : public TQObject
Q_OBJECT
public:
TraceData(TQWidget* labelParent=0);
TraceData(TraceWidget* parent, TQWidget* labelParent=0);
~TraceData();
void drawTrace(TQPainter* p, int graticule_width, int graticule_height);
public slots:
void movePosOneTick();
void moveNegOneTick();
void resetVPosition();
signals:
void offsetChanged(double offset);
private:
TQDoubleArray sampleArray;
TQDoubleArray positionArray;
unsigned int numberOfSamples;
double offset;
TQColor color;
bool enabled;
double leftEdge;
@ -65,6 +75,11 @@ class TraceData : public TQObject
TQString verticalUnits;
TQLabel* paramLabel;
TQLabel* graphStatusLabel;
TQLabel* graphStatusLabelInner;
TQToolButton* singleIncrBtn;
TQToolButton* singleDecrBtn;
TQToolButton* posResetBtn;
TraceWidget* parentWidget;
friend class TraceWidget;
friend class GraticuleWidget;
@ -131,6 +146,7 @@ class GraticuleWidget : public TQWidget
TQPixmap* m_graticulePixmap;
friend class TraceWidget;
friend class TraceData;
friend class CursorData;
};
@ -179,12 +195,17 @@ class TraceWidget : public TQWidget
static TQString prettyFormat(double value, double rangeDetectValue, TQString baseUnits, unsigned int precision=3);
public slots:
void setTraceOffset(uint traceNumber, double offset);
private slots:
void updateTraceText();
void updateCursorText();
void processChangedOffset(double offset);
signals:
void zoomBoxChanged(const TQRectF&);
void offsetChanged(uint traceNumber, double offset);
private:
void resizeTraceArray(uint newsize);
@ -205,8 +226,10 @@ class TraceWidget : public TQWidget
TQGridLayout* m_infoLabelLayout;
TQGridLayout* m_cursorLabelLayout;
TQGridLayout* m_statusLabelLayout;
TQGridLayout* m_statusLabelLayoutInner;
GraticuleWidget* m_graticuleWidget;
friend class GraticuleWidget;
friend class TraceData;
friend class CursorData;
};
Loading…
Cancel
Save