public:
FreqdBmPicker
(int xAxis,
int yAxis, RubberBand rubberBand, DisplayMode trackerMode,
QWidget* canvas
);
};
class FreqdBmPicker : public QwtPlotPicker {
public:
FreqdBmPicker( QWidget *canvas );
FreqdBmPicker(int xAxis, int yAxis, RubberBand rubberBand, DisplayMode trackerMode, QWidget* canvas);
virtual QwtText trackerTextF( const QPointF & ) const;
};
To copy to clipboard, switch view to plain text mode
QwtText TimeScaleDraw
::label(double v
) const { //Convert Double date to a string return QwtText(QDateTime::fromMSecsSinceEpoch((qint64
) (v
*1000)).
toString("yyyy-MM-dd\nHH:mm:ss.zzz"));
}
FreqdBmPicker
::FreqdBmPicker(int x,
int y, RubberBand rb, DisplayMode dm,
QWidget* w
): QwtPlotPicker(x, y, rb, dm, w
) { setTrackerMode( dm );
setRubberBand( rb );
setStateMachine( new QwtPickerTrackerMachine() );
setTrackerPen
(QColor(Qt
::cyan));
setRubberBandPen
(QColor(Qt
::cyan));
qDebug() << isEnabled();
setEnabled(true);
}
setStateMachine( new QwtPickerTrackerMachine() );
setTrackerPen
(QColor(Qt
::cyan));
setRubberBandPen
(QColor(Qt
::cyan));
qDebug() << isEnabled();
setEnabled(true);
}
switch ( (int) std::log10(pos.x())) {
case 9: rtn
= QString("(%1GHz, %2dBm)").
arg(pos.
x()/1e9,
0,
'f',
2);
break;
case 8:
case 7:
case 6: rtn
= QString("(%1MHz, %2dBm)").
arg(pos.
x()/1e6,
0,
'f',
2);
break;
case 5:
case 4:
case 3: rtn
= QString("(%1kHz, %2dBm)").
arg(pos.
x()/1e3,
0,
'f',
2);
break;
case 2:
case 1:
case 0:
default: rtn
= QString("(%1Hz, %2dBm)").
arg(pos.
x(),
0,
'f',
2);
break;
}
rtn = rtn.arg(pos.y(), 0, 'f', 1);
}
QwtText TimeScaleDraw::label(double v) const { //Convert Double date to a string
return QwtText(QDateTime::fromMSecsSinceEpoch((qint64) (v*1000)).toString("yyyy-MM-dd\nHH:mm:ss.zzz"));
}
FreqdBmPicker::FreqdBmPicker(int x, int y, RubberBand rb, DisplayMode dm, QWidget* w): QwtPlotPicker(x, y, rb, dm, w) {
setTrackerMode( dm );
setRubberBand( rb );
setStateMachine( new QwtPickerTrackerMachine() );
setTrackerPen(QColor(Qt::cyan));
setRubberBandPen(QColor(Qt::cyan));
qDebug() << isEnabled();
setEnabled(true);
}
FreqdBmPicker::FreqdBmPicker( QWidget *canvas ): QwtPlotPicker( canvas ) {
setTrackerMode( QwtPicker::AlwaysOn );
setRubberBand( QwtPlotPicker::CrossRubberBand );
setStateMachine( new QwtPickerTrackerMachine() );
setTrackerPen(QColor(Qt::cyan));
setRubberBandPen(QColor(Qt::cyan));
qDebug() << isEnabled();
setEnabled(true);
}
QwtText FreqdBmPicker::trackerTextF( const QPointF &pos ) const {
QString rtn;
switch ( (int) std::log10(pos.x())) {
case 9: rtn = QString("(%1GHz, %2dBm)").arg(pos.x()/1e9, 0, 'f', 2); break;
case 8:
case 7:
case 6: rtn = QString("(%1MHz, %2dBm)").arg(pos.x()/1e6, 0, 'f', 2); break;
case 5:
case 4:
case 3: rtn = QString("(%1kHz, %2dBm)").arg(pos.x()/1e3, 0, 'f', 2); break;
case 2:
case 1:
case 0:
default: rtn = QString("(%1Hz, %2dBm)").arg(pos.x(), 0, 'f', 2); break;
}
rtn = rtn.arg(pos.y(), 0, 'f', 1);
return QwtText(rtn);
}
To copy to clipboard, switch view to plain text mode
SweepInspector
::SweepInspector(QWidget *parent
) : QWidget(parent
), data
(NULL), d_curve
(NULL), picker
(NULL) { setupUi(this);
plot->setObjectName( "SweepData" );
plot->setTitle( "RF Sweep" );
plot
->setAxisTitle
( QwtPlot::xBottom,
"Frequency");
plot->setAutoReplot(true);
plot
->enableAxis
(QwtPlot::xBottom,
true);
plot
->enableAxis
(QwtPlot::yLeft,
true);
plot
->enableAxis
(QwtPlot::xTop,
false);
plot
->enableAxis
(QwtPlot::yRight,
false);
canvas->setPalette( Qt::black );
canvas->setBorderRadius(0);
plot->setCanvas(canvas);
//Allow zooming / panning
// zoomer = new QwtPlotZoomer( canvas );
// zoomer->setRubberBandPen( QColor( Qt::white ) );
// zoomer->setTrackerPen( QColor( Qt::white ) );
panner->setMouseButton( Qt::MidButton );
//Setup grid
grid->enableXMin( true );
grid->enableYMin( true );
QColor color
(Qt
::gray); color.
setAlpha(128);
grid->setMajorPen( color, 1, Qt::DotLine );
grid->setMinorPen( color, 1, Qt::DotLine );
grid->attach( plot );
//format in kHz, MHz, GHz, not raw values
plot
->setAxisScaleDraw
(QwtPlot::xBottom,
new FreqScaleDraw
);
//connects
connect(timeIndex, SIGNAL(valueChanged(int)), this, SLOT(loadSweep(int)));
connect(timeIndex, SIGNAL(sliderMoved(int)), this, SLOT(sliderMoved(int)));
}
void SweepInspector::loadSweep(int index) {
//load in new sweep values from data
if (data == NULL) return;
//remove old data and get new
if (d_curve) d_curve->attach(NULL);
plot->detachItems();
fsweep sweep = data->getSweep(index);
d_curve
= new QwtPlotCurve( timestamp
->text
() );
//Qwt will delete() this when its done with it d_curve
->setRenderHint
( QwtPlotItem::RenderAntialiased );
d_curve
->setPen
( QColor( Qt
::yellow ),
2, Qt
::SolidLine );
d_curve->setSamples( sweep );
d_curve->attach(plot);
delete(picker);
connect(picker,
SIGNAL(selected
(QPointF)),
this,
SLOT(moved
(QPointF)));
QwtInterval frange = data->limits(FREQ);
plot
->setAxisScale
(QwtPlot::xBottom, frange.
minValue(), frange.
maxValue(),
(frange.
maxValue() - frange.
minValue())/ 5.0);
plot
->setAxisScale
(QwtPlot::yLeft,
-135,
20,
10.0);
plot
->setTitle
( QString("RF Sweep @ %1").
arg(timestamp
->text
()) );
//set maximum zoom out
// zoomer->setZoomBase(QRectF(QPointF(frange.minValue(), 20), QPointF(frange.maxValue(), -135)));
// zoomer->zoomBase();
plot->replot();
plot->repaint();
}
SweepInspector::SweepInspector(QWidget *parent) : QWidget(parent), data(NULL), d_curve(NULL), picker(NULL) {
setupUi(this);
plot->setObjectName( "SweepData" );
plot->setTitle( "RF Sweep" );
plot->setAxisTitle( QwtPlot::xBottom, "Frequency");
plot->setAxisTitle( QwtPlot::yLeft, QString( "Power Level (dBm)"));
plot->setAutoReplot(true);
plot->enableAxis(QwtPlot::xBottom, true);
plot->enableAxis(QwtPlot::yLeft, true);
plot->enableAxis(QwtPlot::xTop, false);
plot->enableAxis(QwtPlot::yRight, false);
canvas = new QwtPlotCanvas();
canvas->setPalette( Qt::black );
canvas->setBorderRadius(0);
plot->setCanvas(canvas);
//Allow zooming / panning
// zoomer = new QwtPlotZoomer( canvas );
// zoomer->setRubberBandPen( QColor( Qt::white ) );
// zoomer->setTrackerPen( QColor( Qt::white ) );
panner = new QwtPlotPanner( canvas );
panner->setMouseButton( Qt::MidButton );
picker = new FreqdBmPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas);
//Setup grid
grid = new QwtPlotGrid();
grid->enableXMin( true );
grid->enableYMin( true );
QColor color(Qt::gray); color.setAlpha(128);
grid->setMajorPen( color, 1, Qt::DotLine );
grid->setMinorPen( color, 1, Qt::DotLine );
grid->attach( plot );
//format in kHz, MHz, GHz, not raw values
plot->setAxisScaleDraw(QwtPlot::xBottom, new FreqScaleDraw);
//connects
connect(timeIndex, SIGNAL(valueChanged(int)), this, SLOT(loadSweep(int)));
connect(timeIndex, SIGNAL(sliderMoved(int)), this, SLOT(sliderMoved(int)));
}
void SweepInspector::loadSweep(int index) {
//load in new sweep values from data
if (data == NULL) return;
//remove old data and get new
if (d_curve) d_curve->attach(NULL);
plot->detachItems();
fsweep sweep = data->getSweep(index);
d_curve = new QwtPlotCurve( timestamp->text() ); //Qwt will delete() this when its done with it
d_curve->setRenderHint( QwtPlotItem::RenderAntialiased );
d_curve->setStyle( QwtPlotCurve::Lines );
d_curve->setPen( QColor( Qt::yellow ), 2, Qt::SolidLine );
d_curve->setSamples( sweep );
d_curve->attach(plot);
delete(picker);
picker = new FreqdBmPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas);
connect(picker, SIGNAL(selected(QPointF)), this, SLOT(moved(QPointF)));
QwtInterval frange = data->limits(FREQ);
plot->setAxisScale(QwtPlot::xBottom, frange.minValue(), frange.maxValue(), (frange.maxValue() - frange.minValue())/ 5.0);
plot->setAxisScale(QwtPlot::yLeft, -135, 20, 10.0);
plot->setTitle( QString("RF Sweep @ %1").arg(timestamp->text()) );
//set maximum zoom out
// zoomer->setZoomBase(QRectF(QPointF(frange.minValue(), 20), QPointF(frange.maxValue(), -135)));
// zoomer->zoomBase();
plot->replot();
plot->repaint();
}
To copy to clipboard, switch view to plain text mode
Bookmarks