Enhance trace viewer

master
Timothy Pearson 13 years ago
parent ad5dff2bda
commit c485c0ef46

@ -15,6 +15,7 @@ InstrumentView::InstrumentView(const TQString &library, TQWidget *parentWidget,
: KMdiChildView(parentWidget, name, f) : KMdiChildView(parentWidget, name, f)
, m_libraryName(library) , m_libraryName(library)
, m_instrumentPart( 0 ) , m_instrumentPart( 0 )
, m_fixedSize( false )
, m_canary( NULL ) , m_canary( NULL )
{ {
init(); init();
@ -24,6 +25,7 @@ InstrumentView::InstrumentView(const TQString &library, const TQString &caption,
: KMdiChildView(caption, parentWidget, name, f) : KMdiChildView(caption, parentWidget, name, f)
, m_libraryName(library) , m_libraryName(library)
, m_instrumentPart( 0 ) , m_instrumentPart( 0 )
, m_fixedSize( false )
, m_canary( NULL ) , m_canary( NULL )
{ {
init(); init();
@ -45,16 +47,37 @@ void InstrumentView::init() {
else { else {
m_instrumentPart = (InstrumentPart *)factory->create(TQT_TQOBJECT(this), "part", "KParts::RemoteInstrumentPart"); m_instrumentPart = (InstrumentPart *)factory->create(TQT_TQOBJECT(this), "part", "KParts::RemoteInstrumentPart");
connect(m_instrumentPart, SIGNAL(statusMessageSet(const TQString&)), this, SLOT(setStatusMessage(const TQString&))); connect(m_instrumentPart, SIGNAL(statusMessageSet(const TQString&)), this, SLOT(setStatusMessage(const TQString&)));
connect(m_instrumentPart, SIGNAL(usingFixedSizeChanged(bool)), this, SLOT(setUsingFixedSize(bool)));
} }
} }
void InstrumentView::resizeEvent(TQResizeEvent *) { void InstrumentView::setChildSizeToHint() {
if (m_instrumentPart) { if (m_instrumentPart) {
TQWidget *childPartWidget = m_instrumentPart->widget(); TQWidget *childPartWidget = m_instrumentPart->widget();
if (childPartWidget) { if (childPartWidget) {
if (m_fixedSize) {
setFixedSize(childPartWidget->sizeHint()); setFixedSize(childPartWidget->sizeHint());
} }
else {
TQSize childSizeHint = childPartWidget->sizeHint();
setMinimumSize(childSizeHint.width(), childSizeHint.height());
childPartWidget->resize(size());
}
}
}
}
void InstrumentView::setUsingFixedSize(bool fixed) {
m_fixedSize = fixed;
if (!fixed) {
setMinimumSize(0, 0);
setMaximumSize(TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX);
} }
setChildSizeToHint();
}
void InstrumentView::resizeEvent(TQResizeEvent *) {
setChildSizeToHint();
} }
TQPtrList<KAction> InstrumentView::menuActionList() { TQPtrList<KAction> InstrumentView::menuActionList() {

@ -37,6 +37,8 @@ class InstrumentView : public KMdiChildView
private slots: private slots:
void setStatusMessage(const TQString& message); void setStatusMessage(const TQString& message);
void setUsingFixedSize(bool fixed);
void setChildSizeToHint();
signals: signals:
void statusMessageSet(const TQString&); void statusMessageSet(const TQString&);
@ -45,6 +47,7 @@ class InstrumentView : public KMdiChildView
void init(); void init();
TQString m_libraryName; TQString m_libraryName;
RemoteLab::InstrumentPart *m_instrumentPart; RemoteLab::InstrumentPart *m_instrumentPart;
bool m_fixedSize;
bool* m_canary; bool* m_canary;
}; };

@ -61,6 +61,11 @@ CommAnalyzerPart::CommAnalyzerPart( TQWidget *parentWidget, const char *widgetNa
// Create widgets // Create widgets
m_base = new CommAnalyzerBase(widget()); m_base = new CommAnalyzerBase(widget());
m_traceWidget = m_base->traceWidget; m_traceWidget = m_base->traceWidget;
m_base->traceWidget->setSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding));
m_base->traceWidget->setTraceEnabled(0, true);
m_traceWidget->setTraceName(0, "Trace 1");
m_traceWidget->setTraceHorizontalUnits(0, "Hz");
m_traceWidget->setTraceVerticalUnits(0, "dBm");
m_base->saRefLevel->setFloatMin(-128); m_base->saRefLevel->setFloatMin(-128);
m_base->saRefLevel->setFloatMax(128); m_base->saRefLevel->setFloatMax(128);
m_base->saRefLevel->setLineStep(1); m_base->saRefLevel->setLineStep(1);
@ -80,7 +85,7 @@ CommAnalyzerPart::~CommAnalyzerPart() {
} }
void CommAnalyzerPart::postInit() { void CommAnalyzerPart::postInit() {
// setUsingFixedSize(false);
} }
bool CommAnalyzerPart::openURL(const KURL &url) { bool CommAnalyzerPart::openURL(const KURL &url) {
@ -480,7 +485,7 @@ void CommAnalyzerPart::mainEventLoop() {
if (result == "ACK") { if (result == "ACK") {
// Update display widget(s) // Update display widget(s)
m_traceWidget->setSamples(trace, 0); m_traceWidget->setSamples(0, trace);
postProcessTrace(); postProcessTrace();
m_traceWidget->repaint(); m_traceWidget->repaint();
} }
@ -590,13 +595,23 @@ void CommAnalyzerPart::postProcessTrace() {
} }
void CommAnalyzerPart::updateGraticule() { void CommAnalyzerPart::updateGraticule() {
m_traceWidget->setNumberOfSamples(m_samplesInTrace, 0); m_traceWidget->setNumberOfSamples(0, m_samplesInTrace);
m_traceWidget->setNumberOfHorizontalDivisions(m_hdivs); m_traceWidget->setNumberOfHorizontalDivisions(m_hdivs);
m_traceWidget->setNumberOfVerticalDivisions(m_vdivs); m_traceWidget->setNumberOfVerticalDivisions(m_vdivs);
m_leftFrequency = m_centerfreq - (m_spanfreq/2.0); m_leftFrequency = m_centerfreq - (m_spanfreq/2.0);
m_rightFrequency = m_centerfreq + (m_spanfreq/2.0); m_rightFrequency = m_centerfreq + (m_spanfreq/2.0);
m_traceWidget->setDisplayLimits(m_leftFrequency, m_rpower, m_rightFrequency, m_rpower-(m_vscale*m_hdivs), 0);
double freqincr = (m_rightFrequency-m_leftFrequency)/m_samplesInTrace;
double freqpos = m_leftFrequency;
TQDoubleArray tracepositions;
tracepositions.resize(m_samplesInTrace);
for (int i=0; i<m_samplesInTrace; i++) {
tracepositions[i] = freqpos;
freqpos = freqpos + freqincr;
}
m_traceWidget->setPositions(0, tracepositions);
m_traceWidget->setDisplayLimits(0, m_leftFrequency, m_rpower, m_rightFrequency, m_rpower-(m_vscale*m_hdivs));
// Also update controls // Also update controls
m_base->saRefLevel->blockSignals(true); m_base->saRefLevel->blockSignals(true);

@ -140,7 +140,7 @@ void FPGAProgramPart::connectionClosed() {
} }
void FPGAProgramPart::postInit() { void FPGAProgramPart::postInit() {
// setUsingFixedSize(true);
} }
bool FPGAProgramPart::openURL(const KURL &url) { bool FPGAProgramPart::openURL(const KURL &url) {

@ -978,6 +978,7 @@ void FPGAViewPart::connectionClosed() {
} }
void FPGAViewPart::postInit() { void FPGAViewPart::postInit() {
setUsingFixedSize(true);
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updateDisplay())); connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updateDisplay()));
} }

@ -4,22 +4,55 @@
#include "tracewidget.h" #include "tracewidget.h"
#include <stdlib.h> #include <stdlib.h>
#include <cmath>
#include <tqpixmap.h> #include <tqpixmap.h>
#include <tqpainter.h> #include <tqpainter.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <klocale.h>
#define VERIFY_TRACE_ARRAY_SIZE if (traceNumber >= m_traceArray.count()) resizeTraceArray(traceNumber+1); #define VERIFY_TRACE_ARRAY_SIZE if (traceNumber >= m_traceArray.count()) resizeTraceArray(traceNumber+1);
TraceData::TraceData() { TraceData::TraceData(TQWidget* labelParent) {
color = TQColor(0, 255, 0); color = TQColor(0, 255, 0);
numberOfSamples = 0; numberOfSamples = 0;
leftEdge = 0; leftEdge = 0;
rightEdge = 0; rightEdge = 0;
topEdge = 0; topEdge = 0;
bottomEdge = 0; bottomEdge = 0;
traceName = i18n("Unknown");
horizontalUnits = i18n("Units");
verticalUnits = i18n("Units");
enabled = false; 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();
}
else {
infoLabel = NULL;
}
} }
TraceData::~TraceData() {
//
}
// RAJA FIXME
// Add cursor support
// RAJA FIXME
// Add offset (x and y) support
// RAJA FIXME
// Add scaling support
void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_height) { void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_height) {
p->setPen(color); p->setPen(color);
@ -28,55 +61,159 @@ void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_heigh
unsigned int n; unsigned int n;
int x,y,x2,y2; int x,y,x2,y2;
for (n=0; n<numberOfSamples-1; n++) { for (n=0; n<numberOfSamples-1; n++) {
x = abs(((n*1.0)/(numberOfSamples-1))*(graticule_width)); x = abs(((positionArray[n]-leftEdge)/(rightEdge-leftEdge))*(graticule_width));
y = abs(((sampleArray[n]-topEdge)/(bottomEdge-topEdge))*(graticule_height)); y = abs(((sampleArray[n]-topEdge)/(bottomEdge-topEdge))*(graticule_height));
x2 = abs(((n+1*1.0)/(numberOfSamples-1))*(graticule_width)); x2 = abs(((positionArray[n+1]-leftEdge)/(rightEdge-leftEdge))*(graticule_width));
y2 = abs(((sampleArray[n+1]-topEdge)/(bottomEdge-topEdge))*(graticule_height)); y2 = abs(((sampleArray[n+1]-topEdge)/(bottomEdge-topEdge))*(graticule_height));
p->drawLine(x, y, x2, y2); p->drawLine(x, y, x2, y2);
} }
} }
} }
GraticuleWidget::GraticuleWidget(TraceWidget* parent, const char* name) : TQWidget(parent, name),
m_base(parent),
m_graticulePixmap(0) {
setBackgroundMode(NoBackground);
setSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding));
setPaletteBackgroundColor(TQt::black);
setPaletteForegroundColor(TQColor(0,128,0));
}
GraticuleWidget::~GraticuleWidget() {
//
}
void GraticuleWidget::updateGraticule() {
unsigned int d,s,x,y;
if (m_graticulePixmap) {
delete m_graticulePixmap;
}
m_graticulePixmap = new TQPixmap(width(), height());
// Draw the graticule into the pixmap
TQPainter p(m_graticulePixmap);
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;
x = 0;
for (d=0; d<m_base->m_vertDivs; 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;
y = 0;
for (d=0; d<m_base->m_horizDivs; d++) {
p.drawLine(0, y, m_graticulePixmap->width(), y);
y += s;
}
}
p.setPen(TQPen(foregroundColor(), 1, TQt::SolidLine));
p.drawRect(0, 0, m_graticulePixmap->width(), m_graticulePixmap->height());
// Repaint the widget
repaint();
}
void GraticuleWidget::paintEvent(TQPaintEvent*) {
TQPainter p(this);
if (m_graticulePixmap) {
// Draw the graticule pixmap to erase the widget
p.drawPixmap(0, 0, *m_graticulePixmap);
// Draw the traces
for (uint trace=0;trace<m_base->m_traceArray.count();trace++) {
m_base->m_traceArray[trace]->drawTrace(&p, m_graticulePixmap->width(), m_graticulePixmap->height());
}
}
else {
p.fillRect(x(), y(), width(), height(), backgroundColor());
}
}
void GraticuleWidget::resizeEvent(TQResizeEvent *) {
updateGraticule();
}
TraceWidget::TraceWidget(TQWidget* parent, const char* name) : TQWidget(parent, name), TraceWidget::TraceWidget(TQWidget* parent, const char* name) : TQWidget(parent, name),
m_horizDivs(0), m_horizDivs(0),
m_vertDivs(0), m_vertDivs(0) {
m_graticulePixmap(0) {
setBackgroundMode(NoBackground); setBackgroundMode(NoBackground);
m_primaryLayout = new TQVBoxLayout(this);
m_graticuleWidget = new GraticuleWidget(this);
m_primaryLayout->addWidget(m_graticuleWidget);
m_traceLabelLayout = new TQGridLayout(m_primaryLayout);
m_traceLabelLayout->addItem(new TQSpacerItem(0, 0, TQSizePolicy::Expanding, TQSizePolicy::Minimum), 0, 255);
setPaletteBackgroundColor(TQt::black); setPaletteBackgroundColor(TQt::black);
setPaletteForegroundColor(TQColor(0,128,0)); setPaletteForegroundColor(TQColor(0,128,0));
} }
TraceWidget::~TraceWidget() { TraceWidget::~TraceWidget() {
resizeTraceArray(0); for (uint i=0;i<m_traceArray.count();i++) {
delete m_traceArray[i];
}
} }
void TraceWidget::setNumberOfSamples(unsigned int samples, uint traceNumber) { void TraceWidget::setNumberOfSamples(uint traceNumber, unsigned int samples) {
VERIFY_TRACE_ARRAY_SIZE VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->numberOfSamples = samples; m_traceArray[traceNumber]->numberOfSamples = samples;
m_traceArray[traceNumber]->sampleArray.resize(samples); m_traceArray[traceNumber]->sampleArray.resize(samples);
m_traceArray[traceNumber]->positionArray.resize(samples);
updateGraticule(); m_graticuleWidget->updateGraticule();
updateTraceText();
} }
void TraceWidget::setNumberOfHorizontalDivisions(unsigned int divisions) { void TraceWidget::setNumberOfHorizontalDivisions(unsigned int divisions) {
m_horizDivs = divisions; m_horizDivs = divisions;
updateGraticule(); m_graticuleWidget->updateGraticule();
updateTraceText();
} }
void TraceWidget::setNumberOfVerticalDivisions(unsigned int divisions) { void TraceWidget::setNumberOfVerticalDivisions(unsigned int divisions) {
m_vertDivs = divisions; m_vertDivs = divisions;
updateGraticule(); m_graticuleWidget->updateGraticule();
updateTraceText();
} }
void TraceWidget::setDisplayLimits(double x, double y, double w, double h, uint traceNumber) { void TraceWidget::setDisplayLimits(uint traceNumber, double x, double y, double w, double h) {
VERIFY_TRACE_ARRAY_SIZE VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->leftEdge = x; m_traceArray[traceNumber]->leftEdge = x;
m_traceArray[traceNumber]->rightEdge = w; m_traceArray[traceNumber]->rightEdge = w;
m_traceArray[traceNumber]->topEdge = y; m_traceArray[traceNumber]->topEdge = y;
m_traceArray[traceNumber]->bottomEdge = h; m_traceArray[traceNumber]->bottomEdge = h;
updateTraceText();
}
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]->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));
}
} }
TQDoubleArray& TraceWidget::samples(uint traceNumber) { TQDoubleArray& TraceWidget::samples(uint traceNumber) {
@ -85,23 +222,39 @@ TQDoubleArray& TraceWidget::samples(uint traceNumber) {
return m_traceArray[traceNumber]->sampleArray; return m_traceArray[traceNumber]->sampleArray;
} }
void TraceWidget::setSamples(TQDoubleArray& tqda, uint traceNumber) { void TraceWidget::setSamples(uint traceNumber, TQDoubleArray& tqda) {
VERIFY_TRACE_ARRAY_SIZE VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->sampleArray = tqda; m_traceArray[traceNumber]->sampleArray = tqda;
m_traceArray[traceNumber]->numberOfSamples = tqda.size(); m_traceArray[traceNumber]->numberOfSamples = tqda.size();
} }
TQDoubleArray& TraceWidget::positions(uint traceNumber) {
VERIFY_TRACE_ARRAY_SIZE
return m_traceArray[traceNumber]->positionArray;
}
void TraceWidget::setPositions(uint traceNumber, TQDoubleArray& tqda) {
VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->positionArray = tqda;
m_traceArray[traceNumber]->numberOfSamples = tqda.size();
}
TQColor& TraceWidget::traceColor(uint traceNumber) { TQColor& TraceWidget::traceColor(uint traceNumber) {
VERIFY_TRACE_ARRAY_SIZE VERIFY_TRACE_ARRAY_SIZE
return m_traceArray[traceNumber]->color; return m_traceArray[traceNumber]->color;
} }
void TraceWidget::setTraceColor(TQColor& color, uint traceNumber) { void TraceWidget::setTraceColor(uint traceNumber, TQColor& color) {
VERIFY_TRACE_ARRAY_SIZE VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->color = color; m_traceArray[traceNumber]->color = color;
m_graticuleWidget->updateGraticule();
updateTraceText();
} }
bool TraceWidget::traceEnabled(uint traceNumber) { bool TraceWidget::traceEnabled(uint traceNumber) {
@ -110,82 +263,75 @@ bool TraceWidget::traceEnabled(uint traceNumber) {
return m_traceArray[traceNumber]->enabled; return m_traceArray[traceNumber]->enabled;
} }
void TraceWidget::setTraceEnabled(bool enabled, uint traceNumber) { void TraceWidget::setTraceEnabled(uint traceNumber, bool enabled) {
VERIFY_TRACE_ARRAY_SIZE VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->enabled = enabled; m_traceArray[traceNumber]->enabled = enabled;
} if (enabled) {
m_traceArray[traceNumber]->infoLabel->show();
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;
}
} }
else { else {
m_traceArray.resize(newsize); m_traceArray[traceNumber]->infoLabel->hide();
for (uint i=newsize;i<oldcount;i++) {
delete m_traceArray[i];
}
} }
m_graticuleWidget->updateGraticule();
updateTraceText();
} }
void TraceWidget::updateGraticule() { TQString TraceWidget::traceName(uint traceNumber) {
unsigned int d,s,x,y; VERIFY_TRACE_ARRAY_SIZE
if (m_graticulePixmap) { return m_traceArray[traceNumber]->traceName;
delete m_graticulePixmap; }
}
m_graticulePixmap = new TQPixmap(width(), height());
// Draw the graticule into the pixmap void TraceWidget::setTraceName(uint traceNumber, TQString name) {
TQPainter p(m_graticulePixmap); VERIFY_TRACE_ARRAY_SIZE
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_vertDivs > 0) {
s = m_graticulePixmap->width() / m_vertDivs;
x = 0;
for (d=0; d<m_vertDivs; d++) {
p.drawLine(x, 0, x, m_graticulePixmap->height());
x += s;
}
}
if (m_horizDivs > 0) {
s = m_graticulePixmap->height() / m_horizDivs;
y = 0;
for (d=0; d<m_horizDivs; d++) {
p.drawLine(0, y, m_graticulePixmap->width(), y);
y += s;
}
}
p.setPen(TQPen(foregroundColor(), 1, TQt::SolidLine));
p.drawRect(0, 0, m_graticulePixmap->width(), m_graticulePixmap->height());
// Repaint the widget m_traceArray[traceNumber]->traceName = name;
repaint(); updateTraceText();
} }
void TraceWidget::paintEvent(TQPaintEvent*) { TQString TraceWidget::traceHorizontalUnits(uint traceNumber) {
TQPainter p(this); VERIFY_TRACE_ARRAY_SIZE
if (m_graticulePixmap) { return m_traceArray[traceNumber]->horizontalUnits;
// Draw the graticule pixmap to erase the widget }
p.drawPixmap(0, 0, *m_graticulePixmap);
// Draw the traces void TraceWidget::setTraceHorizontalUnits(uint traceNumber, TQString units) {
for (uint trace=0;trace<m_traceArray.count();trace++) { VERIFY_TRACE_ARRAY_SIZE
m_traceArray[trace]->drawTrace(&p, m_graticulePixmap->width(), m_graticulePixmap->height());
m_traceArray[traceNumber]->horizontalUnits = units;
updateTraceText();
}
TQString TraceWidget::traceVerticalUnits(uint traceNumber) {
VERIFY_TRACE_ARRAY_SIZE
return m_traceArray[traceNumber]->verticalUnits;
}
void TraceWidget::setTraceVerticalUnits(uint traceNumber, TQString units) {
VERIFY_TRACE_ARRAY_SIZE
m_traceArray[traceNumber]->verticalUnits = units;
updateTraceText();
}
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_traceLabelLayout->addWidget(m_traceArray[i]->infoLabel, 0, i);
} }
} }
else { else {
p.fillRect(x(), y(), width(), height(), backgroundColor()); m_traceArray.resize(newsize);
for (uint i=newsize;i<oldcount;i++) {
m_traceLabelLayout->remove(m_traceArray[i]->infoLabel);
delete m_traceArray[i];
}
} }
}
void TraceWidget::resizeEvent(TQResizeEvent *) {
updateGraticule();
} }

@ -6,15 +6,21 @@
#include <tqtrla.h> #include <tqtrla.h>
class TQPixmap; class TQPixmap;
class TQLabel;
class TQVBoxLayout;
class TQGridLayout;
class TraceWidget;
class TraceData class TraceData
{ {
public: public:
TraceData(); TraceData(TQWidget* labelParent=0);
~TraceData();
void drawTrace(TQPainter* p, int graticule_width, int graticule_height); void drawTrace(TQPainter* p, int graticule_width, int graticule_height);
public: public:
TQDoubleArray sampleArray; TQDoubleArray sampleArray;
TQDoubleArray positionArray;
unsigned int numberOfSamples; unsigned int numberOfSamples;
TQColor color; TQColor color;
bool enabled; bool enabled;
@ -22,10 +28,36 @@ class TraceData
double rightEdge; double rightEdge;
double topEdge; double topEdge;
double bottomEdge; double bottomEdge;
TQString traceName;
TQString horizontalUnits;
TQString verticalUnits;
TQLabel* infoLabel;
}; };
typedef TQMemArray<TraceData*> TraceList; typedef TQMemArray<TraceData*> TraceList;
class GraticuleWidget : public TQWidget
{
Q_OBJECT
public:
GraticuleWidget(TraceWidget*, const char* = 0);
~GraticuleWidget();
protected:
virtual void paintEvent(TQPaintEvent*);
virtual void resizeEvent(TQResizeEvent *);
private slots:
void updateGraticule();
private:
TraceWidget* m_base;
TQPixmap* m_graticulePixmap;
friend class TraceWidget;
};
class TraceWidget : public TQWidget class TraceWidget : public TQWidget
{ {
Q_OBJECT Q_OBJECT
@ -34,24 +66,28 @@ class TraceWidget : public TQWidget
TraceWidget(TQWidget* = 0, const char* = 0); TraceWidget(TQWidget* = 0, const char* = 0);
~TraceWidget(); ~TraceWidget();
void setNumberOfSamples(unsigned int samples, uint traceNumber); void setNumberOfSamples(uint traceNumber, unsigned int samples);
void setNumberOfHorizontalDivisions(unsigned int divisions); void setNumberOfHorizontalDivisions(unsigned int divisions);
void setNumberOfVerticalDivisions(unsigned int divisions); void setNumberOfVerticalDivisions(unsigned int divisions);
void setDisplayLimits(double x, double y, double w, double h, uint traceNumber); void setDisplayLimits(uint traceNumber, double x, double y, double w, double h);
TQDoubleArray& samples(uint traceNumber); TQDoubleArray& samples(uint traceNumber);
void setSamples(TQDoubleArray&, uint traceNumber); void setSamples(uint traceNumber, TQDoubleArray&);
TQDoubleArray& positions(uint traceNumber);
void setPositions(uint traceNumber, TQDoubleArray&);
TQColor& traceColor(uint traceNumber); TQColor& traceColor(uint traceNumber);
void setTraceColor(TQColor&, uint traceNumber); void setTraceColor(uint traceNumber, TQColor&);
bool traceEnabled(uint traceNumber); bool traceEnabled(uint traceNumber);
void setTraceEnabled(bool enabled, uint traceNumber); void setTraceEnabled(uint traceNumber, bool enabled);
TQString traceName(uint traceNumber);
protected: void setTraceName(uint traceNumber, TQString name);
virtual void paintEvent(TQPaintEvent*); TQString traceHorizontalUnits(uint traceNumber);
virtual void resizeEvent(TQResizeEvent *); void setTraceHorizontalUnits(uint traceNumber, TQString units);
TQString traceVerticalUnits(uint traceNumber);
void setTraceVerticalUnits(uint traceNumber, TQString units);
private slots: private slots:
void updateGraticule(); void updateTraceText();
private: private:
void resizeTraceArray(uint newsize); void resizeTraceArray(uint newsize);
@ -60,5 +96,9 @@ class TraceWidget : public TQWidget
unsigned int m_horizDivs; unsigned int m_horizDivs;
unsigned int m_vertDivs; unsigned int m_vertDivs;
TraceList m_traceArray; TraceList m_traceArray;
TQPixmap* m_graticulePixmap; TQVBoxLayout* m_primaryLayout;
TQGridLayout* m_traceLabelLayout;
GraticuleWidget* m_graticuleWidget;
friend class GraticuleWidget;
}; };

@ -47,7 +47,7 @@ namespace KParts
RemoteInstrumentPart::RemoteInstrumentPart(TQObject *parent, const char *name) RemoteInstrumentPart::RemoteInstrumentPart(TQObject *parent, const char *name)
: Part( parent, name ), : Part( parent, name ),
m_socket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL) m_socket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL), m_fixedSize(false)
{ {
d = new RemoteInstrumentPartPrivate; d = new RemoteInstrumentPartPrivate;
@ -70,6 +70,18 @@ namespace KParts
return false; return false;
} }
void RemoteInstrumentPart::setUsingFixedSize(bool fixed) {
m_fixedSize = fixed;
if (!fixed) {
TQWidget* parentWidget = dynamic_cast<TQWidget*>(parent());
if (parentWidget) {
parentWidget->setMinimumSize(0, 0);
parentWidget->setMaximumSize(TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX);
}
}
emit(usingFixedSizeChanged(fixed));
}
TQPtrList<KAction> RemoteInstrumentPart::menuActionList() { TQPtrList<KAction> RemoteInstrumentPart::menuActionList() {
return TQPtrList<KAction>(); return TQPtrList<KAction>();
} }
@ -77,8 +89,13 @@ namespace KParts
void RemoteInstrumentPart::resize(TQSize size) { void RemoteInstrumentPart::resize(TQSize size) {
TQWidget* parentWidget = dynamic_cast<TQWidget*>(parent()); TQWidget* parentWidget = dynamic_cast<TQWidget*>(parent());
if (parentWidget) { if (parentWidget) {
if (m_fixedSize) {
parentWidget->setFixedSize(size); parentWidget->setFixedSize(size);
} }
else {
parentWidget->resize(size);
}
}
} }
void RemoteInstrumentPart::close() { void RemoteInstrumentPart::close() {

@ -56,6 +56,7 @@ namespace KParts
protected: protected:
TQStringList textForServerError(TQString shortError); TQStringList textForServerError(TQString shortError);
TQ_ULONG maximumSocketDataChunkSize(); TQ_ULONG maximumSocketDataChunkSize();
void setUsingFixedSize(bool fixed);
public: public:
int connectToServer(TQString server); int connectToServer(TQString server);
@ -74,6 +75,7 @@ namespace KParts
signals: signals:
void statusMessageSet(const TQString&); void statusMessageSet(const TQString&);
void usingFixedSizeChanged(bool);
protected: protected:
KURL m_url; KURL m_url;
@ -85,6 +87,7 @@ namespace KParts
bool connToServerConnecting; bool connToServerConnecting;
int connToServerState; int connToServerState;
TQTimer *connToServerTimeoutTimer; TQTimer *connToServerTimeoutTimer;
bool m_fixedSize;
private: private:
RemoteInstrumentPartPrivate *d; RemoteInstrumentPartPrivate *d;

Loading…
Cancel
Save