|
|
|
@ -8,14 +8,38 @@
|
|
|
|
|
#include <tqpixmap.h>
|
|
|
|
|
#include <tqpainter.h>
|
|
|
|
|
|
|
|
|
|
#define VERIFY_TRACE_ARRAY_SIZE if (traceNumber >= m_traceArray.count()) resizeTraceArray(traceNumber+1);
|
|
|
|
|
|
|
|
|
|
TraceData::TraceData() {
|
|
|
|
|
color = TQColor(0, 255, 0);
|
|
|
|
|
numberOfSamples = 0;
|
|
|
|
|
leftEdge = 0;
|
|
|
|
|
rightEdge = 0;
|
|
|
|
|
topEdge = 0;
|
|
|
|
|
bottomEdge = 0;
|
|
|
|
|
enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceData::drawTrace(TQPainter* p, int graticule_width, int graticule_height) {
|
|
|
|
|
p->setPen(color);
|
|
|
|
|
|
|
|
|
|
if ((bottomEdge != topEdge) && (enabled)) {
|
|
|
|
|
// Draw the points
|
|
|
|
|
unsigned int n;
|
|
|
|
|
int x,y,x2,y2;
|
|
|
|
|
for (n=0; n<numberOfSamples-1; n++) {
|
|
|
|
|
x = abs(((n*1.0)/(numberOfSamples-1))*(graticule_width));
|
|
|
|
|
y = abs(((sampleArray[n]-topEdge)/(bottomEdge-topEdge))*(graticule_height));
|
|
|
|
|
x2 = abs(((n+1*1.0)/(numberOfSamples-1))*(graticule_width));
|
|
|
|
|
y2 = abs(((sampleArray[n+1]-topEdge)/(bottomEdge-topEdge))*(graticule_height));
|
|
|
|
|
p->drawLine(x, y, x2, y2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TraceWidget::TraceWidget(TQWidget* parent, const char* name) : TQWidget(parent, name),
|
|
|
|
|
m_samples(0),
|
|
|
|
|
m_horizDivs(0),
|
|
|
|
|
m_vertDivs(0),
|
|
|
|
|
m_leftEdge(0),
|
|
|
|
|
m_rightEdge(0),
|
|
|
|
|
m_topEdge(0),
|
|
|
|
|
m_bottomEdge(0),
|
|
|
|
|
m_graticulePixmap(0) {
|
|
|
|
|
setBackgroundMode(NoBackground);
|
|
|
|
|
|
|
|
|
@ -24,12 +48,14 @@ TraceWidget::TraceWidget(TQWidget* parent, const char* name) : TQWidget(parent,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TraceWidget::~TraceWidget() {
|
|
|
|
|
//
|
|
|
|
|
resizeTraceArray(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWidget::setNumberOfSamples(unsigned int samples) {
|
|
|
|
|
m_samples = samples;
|
|
|
|
|
m_sampleArray.resize(m_samples);
|
|
|
|
|
void TraceWidget::setNumberOfSamples(unsigned int samples, uint traceNumber) {
|
|
|
|
|
VERIFY_TRACE_ARRAY_SIZE
|
|
|
|
|
|
|
|
|
|
m_traceArray[traceNumber]->numberOfSamples = samples;
|
|
|
|
|
m_traceArray[traceNumber]->sampleArray.resize(samples);
|
|
|
|
|
|
|
|
|
|
updateGraticule();
|
|
|
|
|
}
|
|
|
|
@ -44,20 +70,67 @@ void TraceWidget::setNumberOfVerticalDivisions(unsigned int divisions) {
|
|
|
|
|
updateGraticule();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWidget::setDisplayLimits(double x, double y, double w, double h) {
|
|
|
|
|
m_leftEdge = x;
|
|
|
|
|
m_rightEdge = w;
|
|
|
|
|
m_topEdge = y;
|
|
|
|
|
m_bottomEdge = h;
|
|
|
|
|
void TraceWidget::setDisplayLimits(double x, double y, double w, double h, uint traceNumber) {
|
|
|
|
|
VERIFY_TRACE_ARRAY_SIZE
|
|
|
|
|
|
|
|
|
|
m_traceArray[traceNumber]->leftEdge = x;
|
|
|
|
|
m_traceArray[traceNumber]->rightEdge = w;
|
|
|
|
|
m_traceArray[traceNumber]->topEdge = y;
|
|
|
|
|
m_traceArray[traceNumber]->bottomEdge = h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQDoubleArray& TraceWidget::samples(uint traceNumber) {
|
|
|
|
|
VERIFY_TRACE_ARRAY_SIZE
|
|
|
|
|
|
|
|
|
|
return m_traceArray[traceNumber]->sampleArray;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWidget::setSamples(TQDoubleArray& tqda, uint traceNumber) {
|
|
|
|
|
VERIFY_TRACE_ARRAY_SIZE
|
|
|
|
|
|
|
|
|
|
m_traceArray[traceNumber]->sampleArray = tqda;
|
|
|
|
|
m_traceArray[traceNumber]->numberOfSamples = tqda.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQColor& TraceWidget::traceColor(uint traceNumber) {
|
|
|
|
|
VERIFY_TRACE_ARRAY_SIZE
|
|
|
|
|
|
|
|
|
|
return m_traceArray[traceNumber]->color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWidget::setTraceColor(TQColor& color, uint traceNumber) {
|
|
|
|
|
VERIFY_TRACE_ARRAY_SIZE
|
|
|
|
|
|
|
|
|
|
m_traceArray[traceNumber]->color = color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQDoubleArray& TraceWidget::samples() {
|
|
|
|
|
return m_sampleArray;
|
|
|
|
|
bool TraceWidget::traceEnabled(uint traceNumber) {
|
|
|
|
|
VERIFY_TRACE_ARRAY_SIZE
|
|
|
|
|
|
|
|
|
|
return m_traceArray[traceNumber]->enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWidget::setSamples(TQDoubleArray& tqda) {
|
|
|
|
|
m_sampleArray = tqda;
|
|
|
|
|
m_samples = tqda.size();
|
|
|
|
|
void TraceWidget::setTraceEnabled(bool enabled, uint traceNumber) {
|
|
|
|
|
VERIFY_TRACE_ARRAY_SIZE
|
|
|
|
|
|
|
|
|
|
m_traceArray[traceNumber]->enabled = enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
m_traceArray.resize(newsize);
|
|
|
|
|
for (uint i=newsize;i<oldcount;i++) {
|
|
|
|
|
delete m_traceArray[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWidget::updateGraticule() {
|
|
|
|
@ -98,21 +171,14 @@ void TraceWidget::updateGraticule() {
|
|
|
|
|
|
|
|
|
|
void TraceWidget::paintEvent(TQPaintEvent*) {
|
|
|
|
|
TQPainter p(this);
|
|
|
|
|
p.setPen(foregroundColor().light(150));
|
|
|
|
|
|
|
|
|
|
if ((m_graticulePixmap) && (m_bottomEdge != m_topEdge)) {
|
|
|
|
|
if (m_graticulePixmap) {
|
|
|
|
|
// Draw the graticule pixmap to erase the widget
|
|
|
|
|
p.drawPixmap(0, 0, *m_graticulePixmap);
|
|
|
|
|
|
|
|
|
|
// Draw the points
|
|
|
|
|
unsigned int n;
|
|
|
|
|
int x,y,x2,y2;
|
|
|
|
|
for (n=0; n<m_samples-1; n++) {
|
|
|
|
|
x = abs(((n*1.0)/(m_samples-1))*(m_graticulePixmap->width()));
|
|
|
|
|
y = abs(((m_sampleArray[n]-m_topEdge)/(m_bottomEdge-m_topEdge))*(m_graticulePixmap->height()));
|
|
|
|
|
x2 = abs(((n+1*1.0)/(m_samples-1))*(m_graticulePixmap->width()));
|
|
|
|
|
y2 = abs(((m_sampleArray[n+1]-m_topEdge)/(m_bottomEdge-m_topEdge))*(m_graticulePixmap->height()));
|
|
|
|
|
p.drawLine(x, y, x2, y2);
|
|
|
|
|
// Draw the traces
|
|
|
|
|
for (uint trace=0;trace<m_traceArray.count();trace++) {
|
|
|
|
|
m_traceArray[trace]->drawTrace(&p, m_graticulePixmap->width(), m_graticulePixmap->height());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|