Bugfix: use correct time/distance data when changing X scale

This commit is contained in:
Jan Käberich 2020-11-02 18:12:06 +01:00
parent 32270dc747
commit 8d71cd6541
4 changed files with 10 additions and 14 deletions

View File

@ -43,7 +43,6 @@ void Generator::updateDevice()
// can't update if not connected
return;
}
// TODO comment in once status is filled with valid values
Protocol::PacketInfo p;
p.type = Protocol::PacketType::Generator;
p.generator = central->getDeviceStatus();

View File

@ -56,10 +56,10 @@ static double TimeAxisTransformation(TraceXYPlot::YAxisType type, Trace *t, int
class QwtTraceSeries : public QwtSeriesData<QPointF> {
public:
QwtTraceSeries(Trace &t, TraceXYPlot::YAxisType Ytype, TraceXYPlot::XAxisType Xtype)
QwtTraceSeries(Trace &t, TraceXYPlot::YAxisType Ytype, const TraceXYPlot *plot)
: QwtSeriesData<QPointF>(),
Ytype(Ytype),
Xtype(Xtype),
plot(plot),
t(t){}
size_t size() const override {
switch(Ytype) {
@ -91,7 +91,7 @@ public:
case TraceXYPlot::YAxisType::Impedance: {
auto sample = t.getTDR()[i];
QPointF p;
if(Xtype == TraceXYPlot::XAxisType::Time) {
if(plot->XAxis.type == TraceXYPlot::XAxisType::Time) {
p.setX(sample.time);
} else {
p.setX(sample.distance);
@ -110,7 +110,7 @@ public:
private:
TraceXYPlot::YAxisType Ytype;
TraceXYPlot::XAxisType Xtype;
const TraceXYPlot *plot;
Trace &t;
};
@ -499,20 +499,19 @@ void TraceXYPlot::updateXAxis()
}
auto div_step = max_div_step * decimals_shift;
// round min up to next multiple of div_step
min = ceil(min / div_step) * div_step;
auto start_div = ceil(min / div_step) * div_step;
QList<double> tickList;
for(double tick = min;tick <= max;tick += div_step) {
for(double tick = start_div;tick <= max;tick += div_step) {
tickList.append(tick);
}
QwtScaleDiv scalediv(min, max, QList<double>(), QList<double>(), tickList);
plot->setAxisScaleDiv(QwtPlot::xBottom, scalediv);
}
triggerReplot();
}
QwtSeriesData<QPointF> *TraceXYPlot::createQwtSeriesData(Trace &t, int axis)
{
return new QwtTraceSeries(t, YAxis[axis].type, XAxis.type);
return new QwtTraceSeries(t, YAxis[axis].type, this);
}
void TraceXYPlot::traceColorChanged(Trace *t)

View File

@ -27,6 +27,7 @@ public:
class TraceXYPlot : public TracePlot
{
friend class XYplotAxisDialog;
friend class QwtTraceSeries;
Q_OBJECT
public:
TraceXYPlot(TraceModel &model, QWidget *parent = nullptr);

View File

@ -528,7 +528,6 @@ void VNA::SpanZoomOut()
void VNA::SetSourceLevel(double level)
{
// TODO remove hardcoded limits
if(level > Device::Limits().cdbm_max / 100.0) {
level = Device::Limits().cdbm_max / 100.0;
} else if(level < Device::Limits().cdbm_min / 100.0) {
@ -541,9 +540,8 @@ void VNA::SetSourceLevel(double level)
void VNA::SetPoints(unsigned int points)
{
// TODO remove hardcoded limits
if (points < 1) {
points = 1;
if (points < 2) {
points = 2;
} else if(points > Device::Limits().maxPoints) {
points = Device::Limits().maxPoints;
}
@ -611,7 +609,6 @@ void VNA::ApplyCalibration(Calibration::Type type)
}
} else {
// Not all required traces available
// TODO start tracedata dialog with required traces
QMessageBox::information(window, "Missing calibration traces", "Not all calibration traces for this type of calibration have been measured. The calibration can be enabled after the missing traces have been acquired.");
DisableCalibration(true);
StartCalibrationDialog(type);